@neo4j-ndl/react 4.13.2 → 4.14.1
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/lib/cjs/ai/response/Response.js +2 -2
- package/lib/cjs/ai/response/Response.js.map +1 -1
- package/lib/cjs/code-block/CodeBlock.js +68 -86
- package/lib/cjs/code-block/CodeBlock.js.map +1 -1
- package/lib/cjs/code-block/code-themes.js +23 -0
- package/lib/cjs/code-block/code-themes.js.map +1 -0
- package/lib/cjs/code-block/hooks/use-code-language.js +49 -0
- package/lib/cjs/code-block/hooks/use-code-language.js.map +1 -0
- package/lib/cjs/code-block/hooks/use-code-theme.js +62 -0
- package/lib/cjs/code-block/hooks/use-code-theme.js.map +1 -0
- package/lib/cjs/code-block/hooks/use-expandable.js +78 -0
- package/lib/cjs/code-block/hooks/use-expandable.js.map +1 -0
- package/lib/cjs/icons/generated/custom/GraphBuilder.js +30 -0
- package/lib/cjs/icons/generated/custom/GraphBuilder.js.map +1 -0
- package/lib/cjs/icons/generated/custom/index.js +5 -3
- package/lib/cjs/icons/generated/custom/index.js.map +1 -1
- package/lib/esm/ai/response/Response.js +2 -2
- package/lib/esm/ai/response/Response.js.map +1 -1
- package/lib/esm/code-block/CodeBlock.js +62 -80
- package/lib/esm/code-block/CodeBlock.js.map +1 -1
- package/lib/esm/code-block/code-themes.js +22 -0
- package/lib/esm/code-block/code-themes.js.map +1 -0
- package/lib/esm/code-block/hooks/use-code-language.js +45 -0
- package/lib/esm/code-block/hooks/use-code-language.js.map +1 -0
- package/lib/esm/code-block/hooks/use-code-theme.js +55 -0
- package/lib/esm/code-block/hooks/use-code-theme.js.map +1 -0
- package/lib/esm/code-block/hooks/use-expandable.js +74 -0
- package/lib/esm/code-block/hooks/use-expandable.js.map +1 -0
- package/lib/esm/icons/generated/custom/GraphBuilder.js +28 -0
- package/lib/esm/icons/generated/custom/GraphBuilder.js.map +1 -0
- package/lib/esm/icons/generated/custom/index.js +1 -0
- package/lib/esm/icons/generated/custom/index.js.map +1 -1
- package/lib/types/ai/response/Response.d.ts.map +1 -1
- package/lib/types/code-block/CodeBlock.d.ts +3 -1
- package/lib/types/code-block/CodeBlock.d.ts.map +1 -1
- package/lib/types/code-block/code-themes.d.ts +22 -0
- package/lib/types/code-block/code-themes.d.ts.map +1 -0
- package/lib/types/code-block/hooks/use-code-language.d.ts +27 -0
- package/lib/types/code-block/hooks/use-code-language.d.ts.map +1 -0
- package/lib/types/code-block/hooks/use-code-theme.d.ts +29 -0
- package/lib/types/code-block/hooks/use-code-theme.d.ts.map +1 -0
- package/lib/types/code-block/hooks/use-expandable.d.ts +34 -0
- package/lib/types/code-block/hooks/use-expandable.d.ts.map +1 -0
- package/lib/types/icons/generated/custom/GraphBuilder.d.ts +29 -0
- package/lib/types/icons/generated/custom/GraphBuilder.d.ts.map +1 -0
- package/lib/types/icons/generated/custom/index.d.ts +1 -0
- package/lib/types/icons/generated/custom/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/lib/cjs/_common/CodeBlockWrapper.js +0 -105
- package/lib/cjs/_common/CodeBlockWrapper.js.map +0 -1
- package/lib/esm/_common/CodeBlockWrapper.js +0 -98
- package/lib/esm/_common/CodeBlockWrapper.js.map +0 -1
- package/lib/types/_common/CodeBlockWrapper.d.ts +0 -40
- package/lib/types/_common/CodeBlockWrapper.d.ts.map +0 -1
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.CodeBlockWrapper = void 0;
|
|
18
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) "Neo4j"
|
|
22
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
23
|
-
*
|
|
24
|
-
* This file is part of Neo4j.
|
|
25
|
-
*
|
|
26
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
27
|
-
* it under the terms of the GNU General Public License as published by
|
|
28
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
29
|
-
* (at your option) any later version.
|
|
30
|
-
*
|
|
31
|
-
* This program is distributed in the hope that it will be useful,
|
|
32
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
33
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
34
|
-
* GNU General Public License for more details.
|
|
35
|
-
*
|
|
36
|
-
* You should have received a copy of the GNU General Public License
|
|
37
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
38
|
-
*/
|
|
39
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
40
|
-
const react_1 = require("react");
|
|
41
|
-
const clean_icon_button_1 = require("../clean-icon-button");
|
|
42
|
-
const icons_1 = require("../icons");
|
|
43
|
-
const defaultElement = 'div';
|
|
44
|
-
const CodeBlockWrapper = (_a) => {
|
|
45
|
-
var _b;
|
|
46
|
-
var { as, maxHeight, code, heading, children, isDisabled, actions, shouldShowExpandButton, setShouldShowExpandButton, className, style, ref, htmlAttributes } = _a, restProps = __rest(_a, ["as", "maxHeight", "code", "heading", "children", "isDisabled", "actions", "shouldShowExpandButton", "setShouldShowExpandButton", "className", "style", "ref", "htmlAttributes"]);
|
|
47
|
-
const Component = as !== null && as !== void 0 ? as : defaultElement;
|
|
48
|
-
const syntaxHighlighterWrapperRef = (0, react_1.useRef)(null);
|
|
49
|
-
const [containerHeight, setContainerHeight] = (0, react_1.useState)(`${maxHeight}px`);
|
|
50
|
-
const [isExpanded, setIsExpanded] = (0, react_1.useState)(maxHeight === undefined);
|
|
51
|
-
(0, react_1.useEffect)(() => {
|
|
52
|
-
var _a, _b, _c, _d;
|
|
53
|
-
if (((_b = (_a = syntaxHighlighterWrapperRef.current) === null || _a === void 0 ? void 0 : _a.scrollHeight) !== null && _b !== void 0 ? _b : 0) <=
|
|
54
|
-
((_d = (_c = syntaxHighlighterWrapperRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight) !== null && _d !== void 0 ? _d : 0)) {
|
|
55
|
-
setIsExpanded(true);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
setIsExpanded(false);
|
|
59
|
-
}
|
|
60
|
-
}, []);
|
|
61
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
62
|
-
var _a, _b, _c, _d;
|
|
63
|
-
if (maxHeight === undefined) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (((_b = (_a = syntaxHighlighterWrapperRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight) !== null && _b !== void 0 ? _b : 0) >=
|
|
67
|
-
((_d = (_c = syntaxHighlighterWrapperRef.current) === null || _c === void 0 ? void 0 : _c.scrollHeight) !== null && _d !== void 0 ? _d : 0)) {
|
|
68
|
-
setContainerHeight(`fit-content`);
|
|
69
|
-
setShouldShowExpandButton(false);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
setContainerHeight(`${maxHeight}px`);
|
|
73
|
-
setShouldShowExpandButton(true);
|
|
74
|
-
}
|
|
75
|
-
}, [maxHeight, code, setShouldShowExpandButton]);
|
|
76
|
-
return ((0, jsx_runtime_1.jsxs)(Component, Object.assign({ ref: ref, className: (0, classnames_1.default)('ndl-code-block-container', className), style: Object.assign({ height: containerHeight }, style) }, restProps, htmlAttributes, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "n-flex n-flex-col n-h-full", children: [Boolean(heading) === true && ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ndl-code-block-title', {
|
|
77
|
-
'ndl-disabled': isDisabled,
|
|
78
|
-
}), style: {
|
|
79
|
-
maxWidth: `calc(100% - ${((_b = actions === null || actions === void 0 ? void 0 : actions.length) !== null && _b !== void 0 ? _b : 0) * 36 + 20}px)`,
|
|
80
|
-
}, "data-testid": "ndl-code-block-title", children: heading })), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ndl-code-content-container', {
|
|
81
|
-
'ndl-disabled': isDisabled,
|
|
82
|
-
}), style: {
|
|
83
|
-
height: Boolean(heading) === true ? 'calc(100% - 24px - 12px)' : '100%',
|
|
84
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { ref: syntaxHighlighterWrapperRef, className: "ndl-highlight-wrapper", tabIndex: 0, role: "region", "aria-label": "Code content", children: children }) })] }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ndl-code-block-actions', {
|
|
85
|
-
'ndl-disabled': isDisabled,
|
|
86
|
-
}), children: actions === null || actions === void 0 ? void 0 : actions.map((iconButtonProps, i) => {
|
|
87
|
-
const { htmlAttributes, description } = iconButtonProps, restCleanIconButtonProps = __rest(iconButtonProps, ["htmlAttributes", "description"]);
|
|
88
|
-
return ((0, jsx_runtime_1.jsx)(clean_icon_button_1.CleanIconButton, Object.assign({ description: `${description !== null && description !== void 0 ? description : 'CodeBlock Action'}`, isDisabled: isDisabled, htmlAttributes: Object.assign({ 'data-testid': `ndl-action-button-${i}` }, htmlAttributes) }, restCleanIconButtonProps), i));
|
|
89
|
-
}) }), shouldShowExpandButton && ((0, jsx_runtime_1.jsx)("div", { className: "ndl-code-block-expand-button", children: (0, jsx_runtime_1.jsx)(clean_icon_button_1.CleanIconButton, { description: isExpanded ? 'Collapse' : 'Expand', tooltipProps: {
|
|
90
|
-
root: {
|
|
91
|
-
shouldCloseOnReferenceClick: true,
|
|
92
|
-
},
|
|
93
|
-
}, onClick: () => {
|
|
94
|
-
if (isExpanded) {
|
|
95
|
-
setContainerHeight(`${maxHeight}px`);
|
|
96
|
-
setIsExpanded(false);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
setContainerHeight(`fit-content`);
|
|
100
|
-
setIsExpanded(true);
|
|
101
|
-
}
|
|
102
|
-
}, children: isExpanded ? (0, jsx_runtime_1.jsx)(icons_1.ChevronUpIconOutline, {}) : (0, jsx_runtime_1.jsx)(icons_1.ChevronDownIconOutline, {}) }) }))] })));
|
|
103
|
-
};
|
|
104
|
-
exports.CodeBlockWrapper = CodeBlockWrapper;
|
|
105
|
-
//# sourceMappingURL=CodeBlockWrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockWrapper.js","sourceRoot":"","sources":["../../../src/_common/CodeBlockWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AAEpC,iCAAqE;AAErE,4DAAuD;AACvD,oCAAwE;AAgBxE,MAAM,cAAc,GAAG,KAAK,CAAC;AAEtB,MAAM,gBAAgB,GAAG,CAE9B,EAeiD,EAAE,EAAE;;QAfrD,EACA,EAAE,EACF,SAAS,EACT,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,UAAU,EACV,OAAO,EACP,sBAAsB,EACtB,yBAAyB,EACzB,SAAS,EACT,KAAK,EACL,GAAG,EACH,cAAc,OAEmC,EAD9C,SAAS,cAdZ,iLAeD,CADa;IAEZ,MAAM,SAAS,GAAsB,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,cAAc,CAAC;IAE1D,MAAM,2BAA2B,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAA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tB,cAAc,kBACZ,aAAa,EAAE,qBAAqB,CAAC,EAAE,IACpC,cAAc,KAEf,wBAAwB,GAPvB,CAAC,CAQN,CACH,CAAC;gBACJ,CAAC,CAAC,GACE,EACL,sBAAsB,IAAI,CACzB,gCAAK,SAAS,EAAC,8BAA8B,YAC3C,uBAAC,mCAAe,IACd,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,EAC/C,YAAY,EAAE;wBACZ,IAAI,EAAE;4BACJ,2BAA2B,EAAE,IAAI;yBAClC;qBACF,EACD,OAAO,EAAE,GAAG,EAAE;wBACZ,IAAI,UAAU,EAAE,CAAC;4BACf,kBAAkB,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC;4BACrC,aAAa,CAAC,KAAK,CAAC,CAAC;wBACvB,CAAC;6BAAM,CAAC;4BACN,kBAAkB,CAAC,aAAa,CAAC,CAAC;4BAClC,aAAa,CAAC,IAAI,CAAC,CAAC;wBACtB,CAAC;oBACH,CAAC,YAEA,UAAU,CAAC,CAAC,CAAC,uBAAC,4BAAoB,KAAG,CAAC,CAAC,CAAC,uBAAC,8BAAsB,KAAG,GACnD,GACd,CACP,KACS,CACb,CAAC;AACJ,CAAC,CAAC;AA9IW,QAAA,gBAAgB,oBA8I3B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react';\n\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ChevronDownIconOutline, ChevronUpIconOutline } from '../icons';\nimport { type PolymorphicCommonProps } from './types';\n\nexport interface CodeBlockWrapperProps {\n maxHeight?: number;\n code: string;\n heading?: string | React.ReactNode;\n children: React.ReactNode;\n isDisabled?: boolean;\n actions?: React.ComponentPropsWithoutRef<typeof CleanIconButton<'button'>>[];\n shouldShowExpandButton: boolean;\n setShouldShowExpandButton: React.Dispatch<React.SetStateAction<boolean>>;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst defaultElement = 'div';\n\nexport const CodeBlockWrapper = <\n T extends React.ElementType = typeof defaultElement,\n>({\n as,\n maxHeight,\n code,\n heading,\n children,\n isDisabled,\n actions,\n shouldShowExpandButton,\n setShouldShowExpandButton,\n className,\n style,\n ref,\n htmlAttributes,\n ...restProps\n}: PolymorphicCommonProps<T, CodeBlockWrapperProps>) => {\n const Component: React.ElementType = as ?? defaultElement;\n\n const syntaxHighlighterWrapperRef = useRef<HTMLDivElement>(null);\n\n const [containerHeight, setContainerHeight] = useState(`${maxHeight}px`);\n const [isExpanded, setIsExpanded] = useState(maxHeight === undefined);\n\n useEffect(() => {\n if (\n (syntaxHighlighterWrapperRef.current?.scrollHeight ?? 0) <=\n (syntaxHighlighterWrapperRef.current?.clientHeight ?? 0)\n ) {\n setIsExpanded(true);\n } else {\n setIsExpanded(false);\n }\n }, []);\n\n useLayoutEffect(() => {\n if (maxHeight === undefined) {\n return;\n }\n\n if (\n (syntaxHighlighterWrapperRef.current?.clientHeight ?? 0) >=\n (syntaxHighlighterWrapperRef.current?.scrollHeight ?? 0)\n ) {\n setContainerHeight(`fit-content`);\n setShouldShowExpandButton(false);\n } else {\n setContainerHeight(`${maxHeight}px`);\n setShouldShowExpandButton(true);\n }\n }, [maxHeight, code, setShouldShowExpandButton]);\n\n return (\n <Component\n ref={ref}\n className={classNames('ndl-code-block-container', className)}\n style={{ height: containerHeight, ...style }}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"n-flex n-flex-col n-h-full\">\n {Boolean(heading) === true && (\n <div\n className={classNames('ndl-code-block-title', {\n 'ndl-disabled': isDisabled,\n })}\n style={{\n maxWidth: `calc(100% - ${(actions?.length ?? 0) * 36 + 20}px)`,\n }}\n data-testid=\"ndl-code-block-title\"\n >\n {heading}\n </div>\n )}\n <div\n className={classNames('ndl-code-content-container', {\n 'ndl-disabled': isDisabled,\n })}\n style={{\n height:\n Boolean(heading) === true ? 'calc(100% - 24px - 12px)' : '100%',\n }}\n >\n <div\n ref={syntaxHighlighterWrapperRef}\n className=\"ndl-highlight-wrapper\"\n tabIndex={0}\n role=\"region\"\n aria-label=\"Code content\"\n >\n {children}\n </div>\n </div>\n </div>\n <div\n className={classNames('ndl-code-block-actions', {\n 'ndl-disabled': isDisabled,\n })}\n >\n {actions?.map((iconButtonProps, i) => {\n const { htmlAttributes, description, ...restCleanIconButtonProps } =\n iconButtonProps;\n return (\n <CleanIconButton\n key={i}\n description={`${description ?? 'CodeBlock Action'}`}\n isDisabled={isDisabled}\n htmlAttributes={{\n 'data-testid': `ndl-action-button-${i}`,\n ...htmlAttributes,\n }}\n {...restCleanIconButtonProps}\n />\n );\n })}\n </div>\n {shouldShowExpandButton && (\n <div className=\"ndl-code-block-expand-button\">\n <CleanIconButton\n description={isExpanded ? 'Collapse' : 'Expand'}\n tooltipProps={{\n root: {\n shouldCloseOnReferenceClick: true,\n },\n }}\n onClick={() => {\n if (isExpanded) {\n setContainerHeight(`${maxHeight}px`);\n setIsExpanded(false);\n } else {\n setContainerHeight(`fit-content`);\n setIsExpanded(true);\n }\n }}\n >\n {isExpanded ? <ChevronUpIconOutline /> : <ChevronDownIconOutline />}\n </CleanIconButton>\n </div>\n )}\n </Component>\n );\n};\n"]}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* Copyright (c) "Neo4j"
|
|
16
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
17
|
-
*
|
|
18
|
-
* This file is part of Neo4j.
|
|
19
|
-
*
|
|
20
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
21
|
-
* it under the terms of the GNU General Public License as published by
|
|
22
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
23
|
-
* (at your option) any later version.
|
|
24
|
-
*
|
|
25
|
-
* This program is distributed in the hope that it will be useful,
|
|
26
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
-
* GNU General Public License for more details.
|
|
29
|
-
*
|
|
30
|
-
* You should have received a copy of the GNU General Public License
|
|
31
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
-
*/
|
|
33
|
-
import classNames from 'classnames';
|
|
34
|
-
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
35
|
-
import { CleanIconButton } from '../clean-icon-button';
|
|
36
|
-
import { ChevronDownIconOutline, ChevronUpIconOutline } from '../icons';
|
|
37
|
-
const defaultElement = 'div';
|
|
38
|
-
export const CodeBlockWrapper = (_a) => {
|
|
39
|
-
var _b;
|
|
40
|
-
var { as, maxHeight, code, heading, children, isDisabled, actions, shouldShowExpandButton, setShouldShowExpandButton, className, style, ref, htmlAttributes } = _a, restProps = __rest(_a, ["as", "maxHeight", "code", "heading", "children", "isDisabled", "actions", "shouldShowExpandButton", "setShouldShowExpandButton", "className", "style", "ref", "htmlAttributes"]);
|
|
41
|
-
const Component = as !== null && as !== void 0 ? as : defaultElement;
|
|
42
|
-
const syntaxHighlighterWrapperRef = useRef(null);
|
|
43
|
-
const [containerHeight, setContainerHeight] = useState(`${maxHeight}px`);
|
|
44
|
-
const [isExpanded, setIsExpanded] = useState(maxHeight === undefined);
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
var _a, _b, _c, _d;
|
|
47
|
-
if (((_b = (_a = syntaxHighlighterWrapperRef.current) === null || _a === void 0 ? void 0 : _a.scrollHeight) !== null && _b !== void 0 ? _b : 0) <=
|
|
48
|
-
((_d = (_c = syntaxHighlighterWrapperRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight) !== null && _d !== void 0 ? _d : 0)) {
|
|
49
|
-
setIsExpanded(true);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
setIsExpanded(false);
|
|
53
|
-
}
|
|
54
|
-
}, []);
|
|
55
|
-
useLayoutEffect(() => {
|
|
56
|
-
var _a, _b, _c, _d;
|
|
57
|
-
if (maxHeight === undefined) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (((_b = (_a = syntaxHighlighterWrapperRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight) !== null && _b !== void 0 ? _b : 0) >=
|
|
61
|
-
((_d = (_c = syntaxHighlighterWrapperRef.current) === null || _c === void 0 ? void 0 : _c.scrollHeight) !== null && _d !== void 0 ? _d : 0)) {
|
|
62
|
-
setContainerHeight(`fit-content`);
|
|
63
|
-
setShouldShowExpandButton(false);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
setContainerHeight(`${maxHeight}px`);
|
|
67
|
-
setShouldShowExpandButton(true);
|
|
68
|
-
}
|
|
69
|
-
}, [maxHeight, code, setShouldShowExpandButton]);
|
|
70
|
-
return (_jsxs(Component, Object.assign({ ref: ref, className: classNames('ndl-code-block-container', className), style: Object.assign({ height: containerHeight }, style) }, restProps, htmlAttributes, { children: [_jsxs("div", { className: "n-flex n-flex-col n-h-full", children: [Boolean(heading) === true && (_jsx("div", { className: classNames('ndl-code-block-title', {
|
|
71
|
-
'ndl-disabled': isDisabled,
|
|
72
|
-
}), style: {
|
|
73
|
-
maxWidth: `calc(100% - ${((_b = actions === null || actions === void 0 ? void 0 : actions.length) !== null && _b !== void 0 ? _b : 0) * 36 + 20}px)`,
|
|
74
|
-
}, "data-testid": "ndl-code-block-title", children: heading })), _jsx("div", { className: classNames('ndl-code-content-container', {
|
|
75
|
-
'ndl-disabled': isDisabled,
|
|
76
|
-
}), style: {
|
|
77
|
-
height: Boolean(heading) === true ? 'calc(100% - 24px - 12px)' : '100%',
|
|
78
|
-
}, children: _jsx("div", { ref: syntaxHighlighterWrapperRef, className: "ndl-highlight-wrapper", tabIndex: 0, role: "region", "aria-label": "Code content", children: children }) })] }), _jsx("div", { className: classNames('ndl-code-block-actions', {
|
|
79
|
-
'ndl-disabled': isDisabled,
|
|
80
|
-
}), children: actions === null || actions === void 0 ? void 0 : actions.map((iconButtonProps, i) => {
|
|
81
|
-
const { htmlAttributes, description } = iconButtonProps, restCleanIconButtonProps = __rest(iconButtonProps, ["htmlAttributes", "description"]);
|
|
82
|
-
return (_jsx(CleanIconButton, Object.assign({ description: `${description !== null && description !== void 0 ? description : 'CodeBlock Action'}`, isDisabled: isDisabled, htmlAttributes: Object.assign({ 'data-testid': `ndl-action-button-${i}` }, htmlAttributes) }, restCleanIconButtonProps), i));
|
|
83
|
-
}) }), shouldShowExpandButton && (_jsx("div", { className: "ndl-code-block-expand-button", children: _jsx(CleanIconButton, { description: isExpanded ? 'Collapse' : 'Expand', tooltipProps: {
|
|
84
|
-
root: {
|
|
85
|
-
shouldCloseOnReferenceClick: true,
|
|
86
|
-
},
|
|
87
|
-
}, onClick: () => {
|
|
88
|
-
if (isExpanded) {
|
|
89
|
-
setContainerHeight(`${maxHeight}px`);
|
|
90
|
-
setIsExpanded(false);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
setContainerHeight(`fit-content`);
|
|
94
|
-
setIsExpanded(true);
|
|
95
|
-
}
|
|
96
|
-
}, children: isExpanded ? _jsx(ChevronUpIconOutline, {}) : _jsx(ChevronDownIconOutline, {}) }) }))] })));
|
|
97
|
-
};
|
|
98
|
-
//# sourceMappingURL=CodeBlockWrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockWrapper.js","sourceRoot":"","sources":["../../../src/_common/CodeBlockWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAgBxE,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAE9B,EAeiD,EAAE,EAAE;;QAfrD,EACA,EAAE,EACF,SAAS,EACT,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,UAAU,EACV,OAAO,EACP,sBAAsB,EACtB,yBAAyB,EACzB,SAAS,EACT,KAAK,EACL,GAAG,EACH,cAAc,OAEmC,EAD9C,SAAS,cAdZ,iLAeD,CADa;IAEZ,MAAM,SAAS,GAAsB,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,cAAc,CAAC;IAE1D,MAAM,2BAA2B,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEjE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,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AC,CAAC,GACE,EACL,sBAAsB,IAAI,CACzB,cAAK,SAAS,EAAC,8BAA8B,YAC3C,KAAC,eAAe,IACd,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,EAC/C,YAAY,EAAE;wBACZ,IAAI,EAAE;4BACJ,2BAA2B,EAAE,IAAI;yBAClC;qBACF,EACD,OAAO,EAAE,GAAG,EAAE;wBACZ,IAAI,UAAU,EAAE,CAAC;4BACf,kBAAkB,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC;4BACrC,aAAa,CAAC,KAAK,CAAC,CAAC;wBACvB,CAAC;6BAAM,CAAC;4BACN,kBAAkB,CAAC,aAAa,CAAC,CAAC;4BAClC,aAAa,CAAC,IAAI,CAAC,CAAC;wBACtB,CAAC;oBACH,CAAC,YAEA,UAAU,CAAC,CAAC,CAAC,KAAC,oBAAoB,KAAG,CAAC,CAAC,CAAC,KAAC,sBAAsB,KAAG,GACnD,GACd,CACP,KACS,CACb,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react';\n\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ChevronDownIconOutline, ChevronUpIconOutline } from '../icons';\nimport { type PolymorphicCommonProps } from './types';\n\nexport interface CodeBlockWrapperProps {\n maxHeight?: number;\n code: string;\n heading?: string | React.ReactNode;\n children: React.ReactNode;\n isDisabled?: boolean;\n actions?: React.ComponentPropsWithoutRef<typeof CleanIconButton<'button'>>[];\n shouldShowExpandButton: boolean;\n setShouldShowExpandButton: React.Dispatch<React.SetStateAction<boolean>>;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst defaultElement = 'div';\n\nexport const CodeBlockWrapper = <\n T extends React.ElementType = typeof defaultElement,\n>({\n as,\n maxHeight,\n code,\n heading,\n children,\n isDisabled,\n actions,\n shouldShowExpandButton,\n setShouldShowExpandButton,\n className,\n style,\n ref,\n htmlAttributes,\n ...restProps\n}: PolymorphicCommonProps<T, CodeBlockWrapperProps>) => {\n const Component: React.ElementType = as ?? defaultElement;\n\n const syntaxHighlighterWrapperRef = useRef<HTMLDivElement>(null);\n\n const [containerHeight, setContainerHeight] = useState(`${maxHeight}px`);\n const [isExpanded, setIsExpanded] = useState(maxHeight === undefined);\n\n useEffect(() => {\n if (\n (syntaxHighlighterWrapperRef.current?.scrollHeight ?? 0) <=\n (syntaxHighlighterWrapperRef.current?.clientHeight ?? 0)\n ) {\n setIsExpanded(true);\n } else {\n setIsExpanded(false);\n }\n }, []);\n\n useLayoutEffect(() => {\n if (maxHeight === undefined) {\n return;\n }\n\n if (\n (syntaxHighlighterWrapperRef.current?.clientHeight ?? 0) >=\n (syntaxHighlighterWrapperRef.current?.scrollHeight ?? 0)\n ) {\n setContainerHeight(`fit-content`);\n setShouldShowExpandButton(false);\n } else {\n setContainerHeight(`${maxHeight}px`);\n setShouldShowExpandButton(true);\n }\n }, [maxHeight, code, setShouldShowExpandButton]);\n\n return (\n <Component\n ref={ref}\n className={classNames('ndl-code-block-container', className)}\n style={{ height: containerHeight, ...style }}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"n-flex n-flex-col n-h-full\">\n {Boolean(heading) === true && (\n <div\n className={classNames('ndl-code-block-title', {\n 'ndl-disabled': isDisabled,\n })}\n style={{\n maxWidth: `calc(100% - ${(actions?.length ?? 0) * 36 + 20}px)`,\n }}\n data-testid=\"ndl-code-block-title\"\n >\n {heading}\n </div>\n )}\n <div\n className={classNames('ndl-code-content-container', {\n 'ndl-disabled': isDisabled,\n })}\n style={{\n height:\n Boolean(heading) === true ? 'calc(100% - 24px - 12px)' : '100%',\n }}\n >\n <div\n ref={syntaxHighlighterWrapperRef}\n className=\"ndl-highlight-wrapper\"\n tabIndex={0}\n role=\"region\"\n aria-label=\"Code content\"\n >\n {children}\n </div>\n </div>\n </div>\n <div\n className={classNames('ndl-code-block-actions', {\n 'ndl-disabled': isDisabled,\n })}\n >\n {actions?.map((iconButtonProps, i) => {\n const { htmlAttributes, description, ...restCleanIconButtonProps } =\n iconButtonProps;\n return (\n <CleanIconButton\n key={i}\n description={`${description ?? 'CodeBlock Action'}`}\n isDisabled={isDisabled}\n htmlAttributes={{\n 'data-testid': `ndl-action-button-${i}`,\n ...htmlAttributes,\n }}\n {...restCleanIconButtonProps}\n />\n );\n })}\n </div>\n {shouldShowExpandButton && (\n <div className=\"ndl-code-block-expand-button\">\n <CleanIconButton\n description={isExpanded ? 'Collapse' : 'Expand'}\n tooltipProps={{\n root: {\n shouldCloseOnReferenceClick: true,\n },\n }}\n onClick={() => {\n if (isExpanded) {\n setContainerHeight(`${maxHeight}px`);\n setIsExpanded(false);\n } else {\n setContainerHeight(`fit-content`);\n setIsExpanded(true);\n }\n }}\n >\n {isExpanded ? <ChevronUpIconOutline /> : <ChevronDownIconOutline />}\n </CleanIconButton>\n </div>\n )}\n </Component>\n );\n};\n"]}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* Copyright (c) "Neo4j"
|
|
4
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
-
*
|
|
6
|
-
* This file is part of Neo4j.
|
|
7
|
-
*
|
|
8
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
-
* it under the terms of the GNU General Public License as published by
|
|
10
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
* (at your option) any later version.
|
|
12
|
-
*
|
|
13
|
-
* This program is distributed in the hope that it will be useful,
|
|
14
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
* GNU General Public License for more details.
|
|
17
|
-
*
|
|
18
|
-
* You should have received a copy of the GNU General Public License
|
|
19
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import type React from 'react';
|
|
23
|
-
import { CleanIconButton } from '../clean-icon-button';
|
|
24
|
-
import { type PolymorphicCommonProps } from './types';
|
|
25
|
-
export interface CodeBlockWrapperProps {
|
|
26
|
-
maxHeight?: number;
|
|
27
|
-
code: string;
|
|
28
|
-
heading?: string | React.ReactNode;
|
|
29
|
-
children: React.ReactNode;
|
|
30
|
-
isDisabled?: boolean;
|
|
31
|
-
actions?: React.ComponentPropsWithoutRef<typeof CleanIconButton<'button'>>[];
|
|
32
|
-
shouldShowExpandButton: boolean;
|
|
33
|
-
setShouldShowExpandButton: React.Dispatch<React.SetStateAction<boolean>>;
|
|
34
|
-
className?: string;
|
|
35
|
-
style?: React.CSSProperties;
|
|
36
|
-
}
|
|
37
|
-
declare const defaultElement = "div";
|
|
38
|
-
export declare const CodeBlockWrapper: <T extends React.ElementType = typeof defaultElement>({ as, maxHeight, code, heading, children, isDisabled, actions, shouldShowExpandButton, setShouldShowExpandButton, className, style, ref, htmlAttributes, ...restProps }: PolymorphicCommonProps<T, CodeBlockWrapperProps>) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
-
export {};
|
|
40
|
-
//# sourceMappingURL=CodeBlockWrapper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockWrapper.d.ts","sourceRoot":"","sources":["../../../src/_common/CodeBlockWrapper.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC,wBAAwB,CAAC,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;IAC7E,sBAAsB,EAAE,OAAO,CAAC;IAChC,yBAAyB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,QAAA,MAAM,cAAc,QAAQ,CAAC;AAE7B,eAAO,MAAM,gBAAgB,GAC3B,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,OAAO,cAAc,EACnD,yKAeC,sBAAsB,CAAC,CAAC,EAAE,qBAAqB,CAAC,4CA6HlD,CAAC"}
|