@redis-ui/components 51.16.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.
- package/dist/CodeBlock/CodeBlock.cjs +17 -11
- package/dist/CodeBlock/CodeBlock.js +17 -11
- package/dist/CodeBlock/CodeBlock.style.cjs +32 -11
- package/dist/CodeBlock/CodeBlock.style.d.ts +6 -3
- package/dist/CodeBlock/CodeBlock.style.js +32 -11
- package/dist/CodeBlock/CodeBlock.types.cjs +6 -0
- package/dist/CodeBlock/CodeBlock.types.d.ts +4 -2
- package/dist/CodeBlock/CodeBlock.types.js +6 -1
- package/dist/index.cjs +1 -0
- package/dist/index.js +2 -2
- package/package.json +2 -2
- package/skills/redis-ui-components/references/CodeBlock.md +21 -7
- package/skills/redis-ui-components/references/CopyToClipboardButton.md +3 -3
|
@@ -3,30 +3,34 @@ const require_CodeBlock_style = require("./CodeBlock.style.cjs");
|
|
|
3
3
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
//#region src/CodeBlock/CodeBlock.tsx
|
|
6
|
-
var useIsScrollable = (code, maxHeight) => {
|
|
6
|
+
var useIsScrollable = (code, overflow, maxHeight) => {
|
|
7
7
|
const ref = (0, react.useRef)(null);
|
|
8
8
|
const [isScrollable, setIsScrollable] = (0, react.useState)(false);
|
|
9
9
|
(0, react.useLayoutEffect)(() => {
|
|
10
10
|
const el = ref.current;
|
|
11
11
|
if (!el) return;
|
|
12
|
-
const update = () => setIsScrollable(el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth);
|
|
12
|
+
const update = () => setIsScrollable(el.scrollHeight > el.clientHeight || overflow === "scroll" && el.scrollWidth > el.clientWidth);
|
|
13
13
|
update();
|
|
14
14
|
if (typeof ResizeObserver === "undefined") return;
|
|
15
15
|
const observer = new ResizeObserver(update);
|
|
16
16
|
observer.observe(el);
|
|
17
17
|
return () => observer.disconnect();
|
|
18
|
-
}, [
|
|
18
|
+
}, [
|
|
19
|
+
code,
|
|
20
|
+
overflow,
|
|
21
|
+
maxHeight
|
|
22
|
+
]);
|
|
19
23
|
return [ref, isScrollable];
|
|
20
24
|
};
|
|
21
|
-
var CodeBlock = (0, react.forwardRef)(({ code, copyLabel,
|
|
22
|
-
const [preRef, isScrollable] = useIsScrollable(code, maxHeight);
|
|
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);
|
|
23
27
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_CodeBlock_style.CodeBlock, {
|
|
24
28
|
ref,
|
|
25
29
|
...restProps,
|
|
26
30
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockPre, {
|
|
27
31
|
ref: preRef,
|
|
28
32
|
$size: size,
|
|
29
|
-
$
|
|
33
|
+
$overflow: overflow,
|
|
30
34
|
$maxHeight: maxHeight,
|
|
31
35
|
$withCopy: Boolean(copyLabel),
|
|
32
36
|
...isScrollable && {
|
|
@@ -35,11 +39,13 @@ var CodeBlock = (0, react.forwardRef)(({ code, copyLabel, wrap = false, maxHeigh
|
|
|
35
39
|
"aria-label": ariaLabel
|
|
36
40
|
},
|
|
37
41
|
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, {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
})]
|
|
43
49
|
});
|
|
44
50
|
});
|
|
45
51
|
CodeBlock.displayName = "CodeBlock";
|
|
@@ -3,30 +3,34 @@ import { CodeBlock as CodeBlock$1, CodeBlockCode, CodeBlockCopy, CodeBlockPre }
|
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { forwardRef, useLayoutEffect, useRef, useState } from "react";
|
|
5
5
|
//#region src/CodeBlock/CodeBlock.tsx
|
|
6
|
-
var useIsScrollable = (code, maxHeight) => {
|
|
6
|
+
var useIsScrollable = (code, overflow, maxHeight) => {
|
|
7
7
|
const ref = useRef(null);
|
|
8
8
|
const [isScrollable, setIsScrollable] = useState(false);
|
|
9
9
|
useLayoutEffect(() => {
|
|
10
10
|
const el = ref.current;
|
|
11
11
|
if (!el) return;
|
|
12
|
-
const update = () => setIsScrollable(el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth);
|
|
12
|
+
const update = () => setIsScrollable(el.scrollHeight > el.clientHeight || overflow === "scroll" && el.scrollWidth > el.clientWidth);
|
|
13
13
|
update();
|
|
14
14
|
if (typeof ResizeObserver === "undefined") return;
|
|
15
15
|
const observer = new ResizeObserver(update);
|
|
16
16
|
observer.observe(el);
|
|
17
17
|
return () => observer.disconnect();
|
|
18
|
-
}, [
|
|
18
|
+
}, [
|
|
19
|
+
code,
|
|
20
|
+
overflow,
|
|
21
|
+
maxHeight
|
|
22
|
+
]);
|
|
19
23
|
return [ref, isScrollable];
|
|
20
24
|
};
|
|
21
|
-
var CodeBlock = forwardRef(({ code, copyLabel,
|
|
22
|
-
const [preRef, isScrollable] = useIsScrollable(code, maxHeight);
|
|
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);
|
|
23
27
|
return /* @__PURE__ */ jsxs(CodeBlock$1, {
|
|
24
28
|
ref,
|
|
25
29
|
...restProps,
|
|
26
30
|
children: [/* @__PURE__ */ jsx(CodeBlockPre, {
|
|
27
31
|
ref: preRef,
|
|
28
32
|
$size: size,
|
|
29
|
-
$
|
|
33
|
+
$overflow: overflow,
|
|
30
34
|
$maxHeight: maxHeight,
|
|
31
35
|
$withCopy: Boolean(copyLabel),
|
|
32
36
|
...isScrollable && {
|
|
@@ -35,11 +39,13 @@ var CodeBlock = forwardRef(({ code, copyLabel, wrap = false, maxHeight, size = "
|
|
|
35
39
|
"aria-label": ariaLabel
|
|
36
40
|
},
|
|
37
41
|
children: /* @__PURE__ */ jsx(CodeBlockCode, { children: code })
|
|
38
|
-
}), copyLabel && /* @__PURE__ */ jsx(CodeBlockCopy, {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
}), copyLabel && /* @__PURE__ */ jsx(CodeBlockCopy, {
|
|
43
|
+
$size: size,
|
|
44
|
+
children: /* @__PURE__ */ jsx(CopyToClipboardButton, {
|
|
45
|
+
textToCopy: code,
|
|
46
|
+
"aria-label": copyLabel
|
|
47
|
+
})
|
|
48
|
+
})]
|
|
43
49
|
});
|
|
44
50
|
});
|
|
45
51
|
CodeBlock.displayName = "CodeBlock";
|
|
@@ -6,16 +6,25 @@ let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
|
|
|
6
6
|
var CodeBlock = styled_components.default.div.withConfig({
|
|
7
7
|
displayName: "CodeBlockstyle__CodeBlock",
|
|
8
8
|
componentId: "RedisUI__sc-16pq9cs-0"
|
|
9
|
-
})(["
|
|
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
|
+
});
|
|
10
19
|
var CodeBlockPre = styled_components.default.pre.withConfig({
|
|
11
20
|
displayName: "CodeBlockstyle__CodeBlockPre",
|
|
12
21
|
componentId: "RedisUI__sc-16pq9cs-1"
|
|
13
|
-
})(["", ""], ({ $size, $
|
|
22
|
+
})(["", ""], ({ $size, $overflow, $maxHeight, $withCopy }) => {
|
|
14
23
|
const theme = (0, _redislabsdev_redis_ui_styles.useTheme)().components.codeBlock;
|
|
15
24
|
return styled_components.css`
|
|
16
25
|
margin: 0;
|
|
17
|
-
padding: ${$withCopy ? theme.
|
|
18
|
-
|
|
26
|
+
padding: ${theme.paddingY} ${$withCopy ? theme.paddingRightWithCopy : theme.paddingX}
|
|
27
|
+
${theme.paddingY} ${theme.paddingX};
|
|
19
28
|
color: ${theme.textColor};
|
|
20
29
|
border-radius: ${theme.borderRadius};
|
|
21
30
|
font-family: ${theme.fontFamily};
|
|
@@ -24,8 +33,13 @@ var CodeBlockPre = styled_components.default.pre.withConfig({
|
|
|
24
33
|
text-align: left;
|
|
25
34
|
overflow: auto;
|
|
26
35
|
max-height: ${$maxHeight ?? "none"};
|
|
27
|
-
white-space: ${$wrap ? "pre-wrap" : "pre"};
|
|
28
|
-
overflow-wrap: ${$wrap ? "anywhere" : "normal"};
|
|
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
|
+
`}
|
|
29
43
|
|
|
30
44
|
${(0, _redislabsdev_redis_ui_styles.getFocusStyle)()}
|
|
31
45
|
`;
|
|
@@ -34,14 +48,21 @@ var CodeBlockCode = styled_components.default.code.withConfig({
|
|
|
34
48
|
displayName: "CodeBlockstyle__CodeBlockCode",
|
|
35
49
|
componentId: "RedisUI__sc-16pq9cs-2"
|
|
36
50
|
})(["font:inherit;"]);
|
|
51
|
+
/** Spans the first code line, so the button centers on it */
|
|
37
52
|
var CodeBlockCopy = styled_components.default.div.withConfig({
|
|
38
53
|
displayName: "CodeBlockstyle__CodeBlockCopy",
|
|
39
54
|
componentId: "RedisUI__sc-16pq9cs-3"
|
|
40
|
-
})([
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
});
|
|
45
66
|
//#endregion
|
|
46
67
|
exports.CodeBlock = CodeBlock;
|
|
47
68
|
exports.CodeBlockCode = CodeBlockCode;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { CodeBlockSize } from './CodeBlock.types';
|
|
1
|
+
import { CodeBlockOverflow, CodeBlockSize } from './CodeBlock.types';
|
|
2
2
|
export declare const CodeBlock: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
3
|
export declare const CodeBlockPre: import("styled-components").StyledComponent<"pre", any, {
|
|
4
4
|
$size: CodeBlockSize;
|
|
5
|
-
$
|
|
5
|
+
$overflow: CodeBlockOverflow;
|
|
6
6
|
$maxHeight?: string;
|
|
7
7
|
$withCopy: boolean;
|
|
8
8
|
}, never>;
|
|
9
9
|
export declare const CodeBlockCode: import("styled-components").StyledComponent<"code", any, {}, never>;
|
|
10
|
-
|
|
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>;
|
|
@@ -4,16 +4,25 @@ import { getFocusStyle, useTheme } from "@redis-ui/styles";
|
|
|
4
4
|
var CodeBlock = _styled.div.withConfig({
|
|
5
5
|
displayName: "CodeBlockstyle__CodeBlock",
|
|
6
6
|
componentId: "RedisUI__sc-16pq9cs-0"
|
|
7
|
-
})(["
|
|
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
|
+
});
|
|
8
17
|
var CodeBlockPre = _styled.pre.withConfig({
|
|
9
18
|
displayName: "CodeBlockstyle__CodeBlockPre",
|
|
10
19
|
componentId: "RedisUI__sc-16pq9cs-1"
|
|
11
|
-
})(["", ""], ({ $size, $
|
|
20
|
+
})(["", ""], ({ $size, $overflow, $maxHeight, $withCopy }) => {
|
|
12
21
|
const theme = useTheme().components.codeBlock;
|
|
13
22
|
return css`
|
|
14
23
|
margin: 0;
|
|
15
|
-
padding: ${$withCopy ? theme.
|
|
16
|
-
|
|
24
|
+
padding: ${theme.paddingY} ${$withCopy ? theme.paddingRightWithCopy : theme.paddingX}
|
|
25
|
+
${theme.paddingY} ${theme.paddingX};
|
|
17
26
|
color: ${theme.textColor};
|
|
18
27
|
border-radius: ${theme.borderRadius};
|
|
19
28
|
font-family: ${theme.fontFamily};
|
|
@@ -22,8 +31,13 @@ var CodeBlockPre = _styled.pre.withConfig({
|
|
|
22
31
|
text-align: left;
|
|
23
32
|
overflow: auto;
|
|
24
33
|
max-height: ${$maxHeight ?? "none"};
|
|
25
|
-
white-space: ${$wrap ? "pre-wrap" : "pre"};
|
|
26
|
-
overflow-wrap: ${$wrap ? "anywhere" : "normal"};
|
|
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
|
+
`}
|
|
27
41
|
|
|
28
42
|
${getFocusStyle()}
|
|
29
43
|
`;
|
|
@@ -32,13 +46,20 @@ var CodeBlockCode = _styled.code.withConfig({
|
|
|
32
46
|
displayName: "CodeBlockstyle__CodeBlockCode",
|
|
33
47
|
componentId: "RedisUI__sc-16pq9cs-2"
|
|
34
48
|
})(["font:inherit;"]);
|
|
49
|
+
/** Spans the first code line, so the button centers on it */
|
|
35
50
|
var CodeBlockCopy = _styled.div.withConfig({
|
|
36
51
|
displayName: "CodeBlockstyle__CodeBlockCopy",
|
|
37
52
|
componentId: "RedisUI__sc-16pq9cs-3"
|
|
38
|
-
})([
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
});
|
|
43
64
|
//#endregion
|
|
44
65
|
export { CodeBlock, CodeBlockCode, CodeBlockCopy, CodeBlockPre };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'react';
|
|
2
2
|
export declare const codeBlockSizes: readonly ["M", "S"];
|
|
3
3
|
export type CodeBlockSize = (typeof codeBlockSizes)[number];
|
|
4
|
+
export declare const codeBlockOverflows: readonly ["scroll", "wrap", "ellipsis"];
|
|
5
|
+
export type CodeBlockOverflow = (typeof codeBlockOverflows)[number];
|
|
4
6
|
export type OwnCodeBlockProps = {
|
|
5
7
|
code: string;
|
|
6
8
|
/** Shows a copy button and is used as its accessible name */
|
|
7
9
|
copyLabel?: string;
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
+
/** How long lines behave: scroll horizontally, wrap, or truncate with an ellipsis */
|
|
11
|
+
overflow?: CodeBlockOverflow;
|
|
10
12
|
/** Scrolls vertically past this height */
|
|
11
13
|
maxHeight?: string;
|
|
12
14
|
size?: CodeBlockSize;
|
package/dist/index.cjs
CHANGED
|
@@ -278,6 +278,7 @@ Object.defineProperty(exports, "cardVariants", {
|
|
|
278
278
|
}
|
|
279
279
|
});
|
|
280
280
|
exports.childrenToString = require_react_utils.childrenToString;
|
|
281
|
+
exports.codeBlockOverflows = require_CodeBlock_types.codeBlockOverflows;
|
|
281
282
|
exports.codeBlockSizes = require_CodeBlock_types.codeBlockSizes;
|
|
282
283
|
exports.combineHandlers = require_react_utils.combineHandlers;
|
|
283
284
|
exports.copyToClipboardButtonVariants = require_CopyToClipboardButton_types.copyToClipboardButtonVariants;
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ import Chip from "./Chip/Chip.js";
|
|
|
72
72
|
import { Overflow } from "./Overflow/Overflow.js";
|
|
73
73
|
import ChipList from "./ChipList/ChipList.js";
|
|
74
74
|
import CodeBlock from "./CodeBlock/CodeBlock.js";
|
|
75
|
-
import { codeBlockSizes } from "./CodeBlock/CodeBlock.types.js";
|
|
75
|
+
import { codeBlockOverflows, codeBlockSizes } from "./CodeBlock/CodeBlock.types.js";
|
|
76
76
|
import CountryFlag from "./CountryFlag/CountryFlag.js";
|
|
77
77
|
import Drawer from "./Drawer/Drawer.js";
|
|
78
78
|
import TreeView from "./TreeView/TreeView.js";
|
|
@@ -117,4 +117,4 @@ import { ProgressBar } from "./ProgressBar/ProgressBar.js";
|
|
|
117
117
|
import { ProfileIcon_style_exports } from "./ProfileIcon/ProfileIcon.style.js";
|
|
118
118
|
import ProfileIcon from "./ProfileIcon/ProfileIcon.js";
|
|
119
119
|
import Slider from "./Slider/Slider.js";
|
|
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 };
|
|
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.
|
|
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.
|
|
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"
|
|
@@ -12,7 +12,7 @@ import { CodeBlock } from '@redis-ui/components';
|
|
|
12
12
|
|------|------|---------|-------------|
|
|
13
13
|
| code | `string` | *required* | Text rendered in the block and copied by the copy button |
|
|
14
14
|
| copyLabel | `string` | - | Shows a copy button and is used as its accessible name |
|
|
15
|
-
|
|
|
15
|
+
| overflow | `'scroll' \| 'wrap' \| 'ellipsis'` | `'scroll'` | How long lines behave: scroll horizontally, wrap (use for commands and prompts), or truncate with an ellipsis |
|
|
16
16
|
| maxHeight | `string` | - | Scrolls vertically past this height (any CSS length, e.g. `'19rem'`) |
|
|
17
17
|
| size | `'M' \| 'S'` | `'M'` | Text size. `S` is the compact size |
|
|
18
18
|
| native div props | `Omit<HTMLAttributes<HTMLDivElement>, 'children'>` | - | Passed to the root element. `aria-label` names the block when it scrolls (defaults to `Code`) |
|
|
@@ -22,9 +22,13 @@ import { CodeBlock } from '@redis-ui/components';
|
|
|
22
22
|
### Playground
|
|
23
23
|
|
|
24
24
|
```tsx
|
|
25
|
-
|
|
25
|
+
import { CodeBlock, codeBlockOverflows, codeBlockSizes } from '@redis-ui/components';
|
|
26
|
+
|
|
27
|
+
<CodeBlock code={lensSnippet} copyLabel="Copy code" overflow="scroll" size="M" />
|
|
26
28
|
```
|
|
27
29
|
|
|
30
|
+
`codeBlockOverflows` and `codeBlockSizes` list the allowed `overflow` and `size` values, e.g. for controls.
|
|
31
|
+
|
|
28
32
|
### Default
|
|
29
33
|
|
|
30
34
|
```tsx
|
|
@@ -40,15 +44,15 @@ import { CodeBlock } from '@redis-ui/components';
|
|
|
40
44
|
|
|
41
45
|
### WrappedCommand
|
|
42
46
|
|
|
43
|
-
> `wrap` breaks long lines anywhere. Use it for commands and prompts.
|
|
47
|
+
> `overflow="wrap"` breaks long lines anywhere. Use it for commands and prompts.
|
|
44
48
|
|
|
45
49
|
```tsx
|
|
46
|
-
<CodeBlock code={initCommand} copyLabel="Copy command" wrap />
|
|
50
|
+
<CodeBlock code={initCommand} copyLabel="Copy command" overflow="wrap" />
|
|
47
51
|
```
|
|
48
52
|
|
|
49
53
|
### HorizontalScroll
|
|
50
54
|
|
|
51
|
-
>
|
|
55
|
+
> By default, long lines scroll horizontally, including inside flex and grid layouts.
|
|
52
56
|
|
|
53
57
|
```tsx
|
|
54
58
|
<div style={{ display: 'flex', maxWidth: '48rem' }}>
|
|
@@ -56,6 +60,16 @@ import { CodeBlock } from '@redis-ui/components';
|
|
|
56
60
|
</div>
|
|
57
61
|
```
|
|
58
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
|
+
|
|
59
73
|
### MaxHeight
|
|
60
74
|
|
|
61
75
|
```tsx
|
|
@@ -74,6 +88,6 @@ import { CodeBlock, codeBlockSizes } from '@redis-ui/components';
|
|
|
74
88
|
|
|
75
89
|
## Notes
|
|
76
90
|
- The component forwards refs to the root element.
|
|
77
|
-
- When the content
|
|
78
|
-
- The copy button is `CopyToClipboardButton
|
|
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.
|
|
79
93
|
- No syntax highlighting: `code` is rendered as plain text.
|
|
@@ -12,7 +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
|
+
| variant | `'default' \| 'outline'` | `'default'` | `outline` renders a bordered square button for copyable values |
|
|
16
16
|
| native button props | `Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'>` | - | Standard button attributes except `onClick`, which is handled internally |
|
|
17
17
|
|
|
18
18
|
## Examples
|
|
@@ -32,7 +32,7 @@ import { CopyToClipboardButton } from '@redis-ui/components';
|
|
|
32
32
|
|
|
33
33
|
### Variants
|
|
34
34
|
|
|
35
|
-
> `outline` is a bordered square button for copyable values
|
|
35
|
+
> `outline` is a bordered square button for copyable values.
|
|
36
36
|
|
|
37
37
|
```tsx
|
|
38
38
|
import {
|
|
@@ -80,4 +80,4 @@ import {
|
|
|
80
80
|
- If `copiedLabel` is provided, it is also used as the accessible label while the copied state is active.
|
|
81
81
|
- If `copiedLabel` is omitted, the accessible label falls back to `Copy`.
|
|
82
82
|
- A successful copy is announced to screen readers (`copiedLabel`, or `Copied`).
|
|
83
|
-
- Use `variant="outline"` for copyable values in Ultra surfaces
|
|
83
|
+
- Use `variant="outline"` for copyable values in Ultra surfaces.
|