@redis-ui/components 51.14.1 → 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.
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.cjs +27 -15
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.js +27 -15
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.cjs +28 -1
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.d.ts +2 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.js +29 -2
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.types.cjs +4 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.types.d.ts +3 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.types.js +4 -1
- package/dist/CodeBlock/CodeBlock.cjs +47 -0
- package/dist/CodeBlock/CodeBlock.d.ts +2 -0
- package/dist/CodeBlock/CodeBlock.js +47 -0
- package/dist/CodeBlock/CodeBlock.style.cjs +49 -0
- package/dist/CodeBlock/CodeBlock.style.d.ts +10 -0
- package/dist/CodeBlock/CodeBlock.style.js +44 -0
- package/dist/CodeBlock/CodeBlock.types.cjs +4 -0
- package/dist/CodeBlock/CodeBlock.types.d.ts +15 -0
- package/dist/CodeBlock/CodeBlock.types.js +4 -0
- package/dist/CodeBlock/index.d.ts +2 -0
- package/dist/CodeBlock/index.js +2 -0
- package/dist/Drawer/components/Description/Description.cjs +1 -1
- package/dist/Drawer/components/Description/Description.js +1 -1
- package/dist/Drawer/components/Header/components/Title/Title.cjs +1 -1
- package/dist/Drawer/components/Header/components/Title/Title.js +1 -1
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.cjs +1 -1
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.js +1 -1
- package/dist/Inputs/components/InputTag/InputTag.cjs +1 -1
- package/dist/Inputs/components/InputTag/InputTag.js +1 -1
- package/dist/Modal/components/Content/components/Description/Description.cjs +1 -1
- package/dist/Modal/components/Content/components/Description/Description.js +1 -1
- package/dist/Modal/components/Content/components/Header/components/Title/Title.cjs +1 -1
- package/dist/Modal/components/Content/components/Header/components/Title/Title.js +1 -1
- package/dist/Select/components/Trigger/components/Compose/Compose.cjs +1 -1
- package/dist/Select/components/Trigger/components/Compose/Compose.js +1 -1
- package/dist/SideBar/SideBar.cjs +2 -0
- package/dist/SideBar/SideBar.constants.cjs +2 -0
- package/dist/SideBar/SideBar.constants.d.ts +2 -0
- package/dist/SideBar/SideBar.constants.js +2 -0
- package/dist/SideBar/SideBar.d.ts +4 -0
- package/dist/SideBar/SideBar.js +2 -0
- package/dist/SideBar/components/CollapseButton/CollapseButton.cjs +1 -1
- package/dist/SideBar/components/CollapseButton/CollapseButton.js +1 -1
- package/dist/SideBar/components/CollapseButton/CollapseButton.style.d.ts +1 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.cjs +78 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.context.cjs +11 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.context.d.ts +4 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.context.js +8 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.d.ts +6 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.js +78 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.style.cjs +36 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.style.d.ts +7 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.style.js +30 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.types.d.ts +21 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.types.js +1 -0
- package/dist/SideBar/components/Item/Item.cjs +4 -1
- package/dist/SideBar/components/Item/Item.js +4 -1
- package/dist/SideBar/components/Item/Item.style.cjs +7 -4
- package/dist/SideBar/components/Item/Item.style.d.ts +1 -0
- package/dist/SideBar/components/Item/Item.style.js +7 -4
- package/dist/SideBar/components/Item/components/Text/Text.cjs +3 -0
- package/dist/SideBar/components/Item/components/Text/Text.js +3 -0
- package/dist/SideBar/components/Item/components/Text/Text.style.cjs +3 -2
- package/dist/SideBar/components/Item/components/Text/Text.style.d.ts +1 -0
- package/dist/SideBar/components/Item/components/Text/Text.style.js +3 -2
- package/dist/SideBar/index.d.ts +1 -0
- package/dist/index.cjs +7 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -2
- package/package.json +2 -2
- package/skills/redis-ui-components/SKILL.md +1 -0
- package/skills/redis-ui-components/references/CodeBlock.md +79 -0
- package/skills/redis-ui-components/references/CopyToClipboardButton.md +37 -1
- package/skills/redis-ui-components/references/SideBar.md +115 -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: [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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: [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
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"
|
|
@@ -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
|
}
|
|
@@ -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,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,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;
|
|
@@ -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";
|