@vectara/vectara-ui 9.6.0 → 9.7.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.
|
@@ -8,11 +8,12 @@ import "prismjs/components/prism-tsx";
|
|
|
8
8
|
import { CodeLanguage } from "./types";
|
|
9
9
|
type Props = {
|
|
10
10
|
language?: CodeLanguage;
|
|
11
|
-
onCopy?: () => void;
|
|
12
11
|
isFullscreenEnabled?: boolean;
|
|
12
|
+
isCopyEnabled?: boolean;
|
|
13
13
|
children?: string;
|
|
14
14
|
fullHeight?: boolean;
|
|
15
|
+
onCopy?: () => void;
|
|
15
16
|
"data-testid"?: string;
|
|
16
17
|
};
|
|
17
|
-
export declare const VuiCode: ({ onCopy, isFullscreenEnabled, language, fullHeight, children, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const VuiCode: ({ onCopy, isFullscreenEnabled, isCopyEnabled, language, fullHeight, children, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
18
19
|
export {};
|
|
@@ -38,7 +38,7 @@ import { VuiPortal } from "../portal/Portal";
|
|
|
38
38
|
import { copyToClipboard } from "../../utils/copyToClipboard";
|
|
39
39
|
// PrismJS clears highlighting when language-none is set.
|
|
40
40
|
export const VuiCode = (_a) => {
|
|
41
|
-
var { onCopy, isFullscreenEnabled = true, language = "none", fullHeight, children = "" } = _a, rest = __rest(_a, ["onCopy", "isFullscreenEnabled", "language", "fullHeight", "children"]);
|
|
41
|
+
var { onCopy, isFullscreenEnabled = true, isCopyEnabled = true, language = "none", fullHeight, children = "" } = _a, rest = __rest(_a, ["onCopy", "isFullscreenEnabled", "isCopyEnabled", "language", "fullHeight", "children"]);
|
|
42
42
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
|
43
43
|
useEffect(() => {
|
|
44
44
|
Prism.highlightAll();
|
|
@@ -50,15 +50,19 @@ export const VuiCode = (_a) => {
|
|
|
50
50
|
"vuiCode--fullHeight": fullHeight
|
|
51
51
|
});
|
|
52
52
|
const testId = rest["data-testid"];
|
|
53
|
-
const actions = (_jsxs(VuiFlexContainer, Object.assign({ className: "vuiCodeActions", spacing: "xxs" }, { children: [isFullscreenEnabled && (_jsx(VuiIconButton, { color: "neutral", size: "xs", icon: _jsx(VuiIcon, { children: _jsx(BiFullscreen, {}) }), "aria-label": "Full screen", onClick: () => {
|
|
53
|
+
const actions = (isFullscreenEnabled || isCopyEnabled) && (_jsxs(VuiFlexContainer, Object.assign({ className: "vuiCodeActions", spacing: "xxs" }, { children: [isFullscreenEnabled && (_jsx(VuiIconButton, { color: "neutral", size: "xs", icon: _jsx(VuiIcon, { children: _jsx(BiFullscreen, {}) }), "aria-label": "Full screen", onClick: () => {
|
|
54
54
|
setIsFullscreen(!isFullscreen);
|
|
55
|
-
} })), _jsx(VuiIconButton, { color: "neutral", size: "xs", icon: _jsx(VuiIcon, { children: _jsx(BiClipboard, {}) }), "aria-label": "Copy to clipboard", onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
} })), isCopyEnabled && (_jsx(VuiIconButton, { color: "neutral", size: "xs", icon: _jsx(VuiIcon, { children: _jsx(BiClipboard, {}) }), "aria-label": "Copy to clipboard", onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
56
|
yield copyToClipboard(children);
|
|
57
57
|
if (onCopy)
|
|
58
58
|
onCopy();
|
|
59
|
-
}) })] })));
|
|
59
|
+
}) }))] })));
|
|
60
60
|
const code = (_jsx("pre", Object.assign({ className: "vuiCodePre" }, { children: _jsx("code", Object.assign({ className: classes }, { children: children })) })));
|
|
61
61
|
return (_jsxs("div", Object.assign({ className: containerClasses }, rest, { children: [code, actions, testId && (_jsx("div", Object.assign({ "data-testid": `${testId}-hidden`, hidden: true }, { children: children }))), _jsx(VuiPortal, { children: isFullscreen && (_jsx(FocusOn, Object.assign({ onEscapeKey: () => {
|
|
62
62
|
setIsFullscreen(false);
|
|
63
|
-
} }, { children: _jsxs("div", Object.assign({ className: "vuiCodeFullscreen" }, { children: [
|
|
63
|
+
} }, { children: _jsxs("div", Object.assign({ className: "vuiCodeFullscreen" }, { children: [_jsxs(VuiFlexContainer, Object.assign({ className: "vuiCodeFullscreen__actions", spacing: "xxs" }, { children: [isCopyEnabled && (_jsx(VuiIconButton, { color: "neutral", size: "m", icon: _jsx(VuiIcon, { children: _jsx(BiClipboard, {}) }), "aria-label": "Copy to clipboard", onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
yield copyToClipboard(children);
|
|
65
|
+
if (onCopy)
|
|
66
|
+
onCopy();
|
|
67
|
+
}) })), _jsx(VuiIconButton, { className: "vuiCodeFullscreen__closeButton", color: "neutral", size: "m", icon: _jsx(VuiIcon, { children: _jsx(BiX, {}) }), "aria-label": "Exit fullscreen code", onClick: () => setIsFullscreen(false) })] })), code] })) }))) })] })));
|
|
64
68
|
};
|
package/lib/styles/index.css
CHANGED