@neo4j-ndl/react 4.2.2 → 4.2.4

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.
@@ -1,3 +1,21 @@
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.Response = void 0;
18
+ const jsx_runtime_1 = require("react/jsx-runtime");
1
19
  /**
2
20
  *
3
21
  * Copyright (c) "Neo4j"
@@ -18,30 +36,9 @@
18
36
  * You should have received a copy of the GNU General Public License
19
37
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
38
  */
21
-
22
- "use strict";
23
- var __rest = (this && this.__rest) || function (s, e) {
24
- var t = {};
25
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
26
- t[p] = s[p];
27
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
28
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
29
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
30
- t[p[i]] = s[p[i]];
31
- }
32
- return t;
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.Response = void 0;
39
- const jsx_runtime_1 = require("react/jsx-runtime");
40
- const code_1 = require("@neo4j-ndl/react/code");
41
- const text_link_1 = require("@neo4j-ndl/react/text-link");
42
- const typography_1 = require("@neo4j-ndl/react/typography");
39
+ const react_1 = require("@neo4j-ndl/react");
43
40
  const classnames_1 = __importDefault(require("classnames"));
44
- const react_1 = require("react");
41
+ const react_2 = require("react");
45
42
  const streamdown_1 = require("streamdown");
46
43
  const code_languages_1 = require("../../code-block/code-languages");
47
44
  const code_preview_1 = require("../code-preview");
@@ -51,13 +48,13 @@ const code_preview_1 = require("../code-preview");
51
48
  *
52
49
  * @alpha - Changes to this component may be breaking.
53
50
  */
54
- const Response = (0, react_1.memo)((_a) => {
51
+ const Response = (0, react_2.memo)((_a) => {
55
52
  var { className, children, isAnimating = false, ref, style, htmlAttributes } = _a, restProps = __rest(_a, ["className", "children", "isAnimating", "ref", "style", "htmlAttributes"]);
56
53
  // Use a ref to store the current markdown content so we can check for unclosed fences
57
54
  // without recreating the components object on every render
58
- const childrenRef = (0, react_1.useRef)(children);
55
+ const childrenRef = (0, react_2.useRef)(children);
59
56
  childrenRef.current = children;
60
- const components = (0, react_1.useMemo)(() => ({
57
+ const components = (0, react_2.useMemo)(() => ({
61
58
  ol: (_a) => {
62
59
  var { children, className } = _a, props = __rest(_a, ["children", "className"]);
63
60
  return ((0, jsx_runtime_1.jsx)("ol", Object.assign({ className: className }, props, { children: children })));
@@ -76,39 +73,39 @@ const Response = (0, react_1.memo)((_a) => {
76
73
  },
77
74
  strong: (_a) => {
78
75
  var { children, className, style } = _a, props = __rest(_a, ["children", "className", "style"]);
79
- return ((0, jsx_runtime_1.jsx)(typography_1.Typography, Object.assign({ as: "strong", variant: "body-medium", className: className, style: Object.assign(Object.assign({}, style), { fontWeight: 'bold' }) }, props, { children: children })));
76
+ return ((0, jsx_runtime_1.jsx)(react_1.Typography, Object.assign({ as: "strong", variant: "body-medium", className: className, style: Object.assign(Object.assign({}, style), { fontWeight: 'bold' }) }, props, { children: children })));
80
77
  },
81
78
  em: (_a) => {
82
79
  var { children, className, style } = _a, props = __rest(_a, ["children", "className", "style"]);
83
- return ((0, jsx_runtime_1.jsx)(typography_1.Typography, Object.assign({ as: "em", variant: "body-medium", className: className, style: Object.assign(Object.assign({}, style), { fontStyle: 'italic' }) }, props, { children: children })));
80
+ return ((0, jsx_runtime_1.jsx)(react_1.Typography, Object.assign({ as: "em", variant: "body-medium", className: className, style: Object.assign(Object.assign({}, style), { fontStyle: 'italic' }) }, props, { children: children })));
84
81
  },
85
82
  a: (_a) => {
86
83
  var { children, className, href } = _a, props = __rest(_a, ["children", "className", "href"]);
87
- return ((0, jsx_runtime_1.jsx)(text_link_1.TextLink, { type: "internal-underline", className: className, href: href, htmlAttributes: props, children: children }));
84
+ return ((0, jsx_runtime_1.jsx)(react_1.TextLink, { type: "internal-underline", className: className, href: href, htmlAttributes: props, children: children }));
88
85
  },
89
86
  h1: (_a) => {
90
87
  var { children, className } = _a, props = __rest(_a, ["children", "className"]);
91
- return ((0, jsx_runtime_1.jsx)(typography_1.Typography, { as: "h1", variant: "display", className: className, htmlAttributes: Object.assign({}, props), children: children }));
88
+ return ((0, jsx_runtime_1.jsx)(react_1.Typography, { as: "h1", variant: "display", className: className, htmlAttributes: Object.assign({}, props), children: children }));
92
89
  },
93
90
  h2: (_a) => {
94
91
  var { children, className } = _a, props = __rest(_a, ["children", "className"]);
95
- return ((0, jsx_runtime_1.jsx)(typography_1.Typography, { as: "h2", variant: "title-1", className: className, htmlAttributes: Object.assign({}, props), children: children }));
92
+ return ((0, jsx_runtime_1.jsx)(react_1.Typography, { as: "h2", variant: "title-1", className: className, htmlAttributes: Object.assign({}, props), children: children }));
96
93
  },
97
94
  h3: (_a) => {
98
95
  var { children, className } = _a, props = __rest(_a, ["children", "className"]);
99
- return ((0, jsx_runtime_1.jsx)(typography_1.Typography, { as: "h3", variant: "title-2", className: className, htmlAttributes: Object.assign({}, props), children: children }));
96
+ return ((0, jsx_runtime_1.jsx)(react_1.Typography, { as: "h3", variant: "title-2", className: className, htmlAttributes: Object.assign({}, props), children: children }));
100
97
  },
101
98
  h4: (_a) => {
102
99
  var { children, className } = _a, props = __rest(_a, ["children", "className"]);
103
- return ((0, jsx_runtime_1.jsx)(typography_1.Typography, { as: "h4", variant: "title-3", className: className, htmlAttributes: Object.assign({}, props), children: children }));
100
+ return ((0, jsx_runtime_1.jsx)(react_1.Typography, { as: "h4", variant: "title-3", className: className, htmlAttributes: Object.assign({}, props), children: children }));
104
101
  },
105
102
  h5: (_a) => {
106
103
  var { children, className } = _a, props = __rest(_a, ["children", "className"]);
107
- return ((0, jsx_runtime_1.jsx)(typography_1.Typography, { as: "h5", variant: "title-4", className: className, htmlAttributes: Object.assign({}, props), children: children }));
104
+ return ((0, jsx_runtime_1.jsx)(react_1.Typography, { as: "h5", variant: "title-4", className: className, htmlAttributes: Object.assign({}, props), children: children }));
108
105
  },
109
106
  h6: (_a) => {
110
107
  var { children, className } = _a, props = __rest(_a, ["children", "className"]);
111
- return ((0, jsx_runtime_1.jsx)(typography_1.Typography, { as: "h6", variant: "subheading-large", className: className, htmlAttributes: Object.assign({}, props), children: children }));
108
+ return ((0, jsx_runtime_1.jsx)(react_1.Typography, { as: "h6", variant: "subheading-large", className: className, htmlAttributes: Object.assign({}, props), children: children }));
112
109
  },
113
110
  table: (_a) => {
114
111
  var { children, className } = _a, props = __rest(_a, ["children", "className"]);
@@ -150,7 +147,7 @@ const Response = (0, react_1.memo)((_a) => {
150
147
  : 'text';
151
148
  }
152
149
  if (isInline) {
153
- return ((0, jsx_runtime_1.jsx)(code_1.Code, { isRunnable: false, className: className, htmlAttributes: props, children: codeChildren }));
150
+ return ((0, jsx_runtime_1.jsx)(react_1.Code, { isRunnable: false, className: className, htmlAttributes: props, children: codeChildren }));
154
151
  }
155
152
  if (typeof codeChildren === 'string') {
156
153
  // Check if code fences are balanced in the markdown
@@ -171,7 +168,7 @@ const Response = (0, react_1.memo)((_a) => {
171
168
  },
172
169
  p: (_a) => {
173
170
  var { children, className } = _a, props = __rest(_a, ["children", "className"]);
174
- return ((0, jsx_runtime_1.jsx)(typography_1.Typography, Object.assign({ as: "p", variant: "body-medium", className: (0, classnames_1.default)(className) }, props, { children: children })));
171
+ return ((0, jsx_runtime_1.jsx)(react_1.Typography, Object.assign({ as: "p", variant: "body-medium", className: (0, classnames_1.default)(className) }, props, { children: children })));
175
172
  },
176
173
  img: (_a) => {
177
174
  var { className, src, alt } = _a, props = __rest(_a, ["className", "src", "alt"]);
@@ -1 +1 @@
1
- {"version":3,"file":"Response.js","sourceRoot":"","sources":["../../../../src/ai/response/Response.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,gDAA6C;AAC7C,0DAAsD;AACtD,4DAAyD;AACzD,4DAAoC;AACpC,iCAA8C;AAC9C,2CAAwC;AAExC,oEAA+E;AAC/E,kDAA8C;AAS9C;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,IAAA,YAAI,EACnB,CAAC,EAQmC,EAAE,EAAE;QARvC,EACC,SAAS,EACT,QAAQ,EACR,WAAW,GAAG,KAAK,EACnB,GAAG,EACH,KAAK,EACL,cAAc,OAEoB,EAD/B,SAAS,cAPb,0EAQA,CADa;IAEZ,sFAAsF;IACtF,2DAA2D;IAC3D,MAAM,WAAW,GAAG,IAAA,cAAM,EAAC,QAAQ,CAAC,CAAC;IACrC,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;IAE/B,MAAM,UAAU,GACd,IAAA,eAAO,EACL,GAAG,EAAE,CAAC,CAAC;QACL,EAAE,EAAE,CAAC,EAAiC,EAAE,EAAE;gBAArC,EAAE,QAAQ,EAAE,SAAS,OAAY,EAAP,KAAK,cAA/B,yBAAiC,CAAF;YAAO,OAAA,CACzC,6CAAI,SAAS,EAAE,SAAS,IAAM,KAAK,cAChC,QAAQ,IACN,CACN,CAAA;SAAA;QACD,EAAE,EAAE,CAAC,EAAiC,EAAE,EAAE;gBAArC,EAAE,QAAQ,EAAE,SAAS,OAAY,EAAP,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T,cAAc,cAElB,uBAAC,uBAAU,IACT,WAAW,EAAE,WAAW,EACxB,uBAAuB,EAAE,IAAI,EAC7B,UAAU,EAAE,UAAU,YAErB,QAAQ,GACE,IACT,CACP,CAAC;AACJ,CAAC,EACD,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,CACpE,CAAC;AAIO,4BAAQ;AAFjB,QAAQ,CAAC,WAAW,GAAG,UAAU,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 */\n\nimport { type CommonProps } from '@neo4j-ndl/react/_common/types';\nimport { Code } from '@neo4j-ndl/react/code';\nimport { TextLink } from '@neo4j-ndl/react/text-link';\nimport { Typography } from '@neo4j-ndl/react/typography';\nimport classNames from 'classnames';\nimport { memo, useMemo, useRef } from 'react';\nimport { Streamdown } from 'streamdown';\n\nimport { type LanguageProp, Languages } from '../../code-block/code-languages';\nimport { CodePreview } from '../code-preview';\n\ntype ResponseProps = {\n /** The response from the AI */\n children: string;\n /** Whether the response is animating */\n isAnimating?: React.ComponentProps<typeof Streamdown>['isAnimating'];\n};\n\n/**\n * The component is used to display the response from an LLM.\n * It handles markdown rendering and streaming.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst Response = memo(\n ({\n className,\n children,\n isAnimating = false,\n ref,\n style,\n htmlAttributes,\n ...restProps\n }: CommonProps<'div', ResponseProps>) => {\n // Use a ref to store the current markdown content so we can check for unclosed fences\n // without recreating the components object on every render\n const childrenRef = useRef(children);\n childrenRef.current = children;\n\n const components: React.ComponentProps<typeof Streamdown>['components'] =\n useMemo(\n () => ({\n ol: ({ children, className, ...props }) => (\n <ol className={className} {...props}>\n {children}\n </ol>\n ),\n ul: ({ children, className, ...props }) => (\n <ul className={classNames(className)} {...props}>\n {children}\n </ul>\n ),\n li: ({ children, className, ...props }) => (\n <li className={className} {...props}>\n {children}\n </li>\n ),\n hr: ({ className, ...props }) => (\n <hr className={classNames(className)} {...props} />\n ),\n strong: ({ children, className, style, ...props }) => (\n <Typography\n as=\"strong\"\n variant=\"body-medium\"\n className={className}\n style={{ ...style, fontWeight: 'bold' }}\n {...props}\n >\n {children}\n </Typography>\n ),\n em: ({ children, className, style, ...props }) => (\n <Typography\n as=\"em\"\n variant=\"body-medium\"\n className={className}\n style={{ ...style, fontStyle: 'italic' }}\n {...props}\n >\n {children}\n </Typography>\n ),\n a: ({ children, className, href, ...props }) => (\n <TextLink\n type=\"internal-underline\"\n className={className}\n href={href}\n htmlAttributes={props}\n >\n {children}\n </TextLink>\n ),\n h1: ({ children, className, ...props }) => (\n <Typography\n as=\"h1\"\n variant=\"display\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h2: ({ children, className, ...props }) => (\n <Typography\n as=\"h2\"\n variant=\"title-1\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h3: ({ children, className, ...props }) => (\n <Typography\n as=\"h3\"\n variant=\"title-2\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h4: ({ children, className, ...props }) => (\n <Typography\n as=\"h4\"\n variant=\"title-3\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h5: ({ children, className, ...props }) => (\n <Typography\n as=\"h5\"\n variant=\"title-4\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h6: ({ children, className, ...props }) => (\n <Typography\n as=\"h6\"\n variant=\"subheading-large\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n table: ({ children, className, ...props }) => (\n <div className=\"my-4 overflow-x-auto\">\n <table\n className={classNames(\n 'w-full border-collapse border border-border',\n className,\n )}\n {...props}\n >\n {children}\n </table>\n </div>\n ),\n thead: ({ children, className, ...props }) => (\n <thead className={classNames('bg-muted/50', className)} {...props}>\n {children}\n </thead>\n ),\n tbody: ({ children, className, ...props }) => (\n <tbody\n className={classNames('divide-y divide-border', className)}\n {...props}\n >\n {children}\n </tbody>\n ),\n tr: ({ children, className, ...props }) => (\n <tr\n className={classNames('border-border border-b', className)}\n {...props}\n >\n {children}\n </tr>\n ),\n th: ({ children, className, ...props }) => (\n <th\n className={classNames(\n 'px-4 py-2 text-left font-semibold text-sm',\n className,\n )}\n {...props}\n >\n {children}\n </th>\n ),\n td: ({ children, className, ...props }) => (\n <td\n className={classNames('px-4 py-2 text-sm', className)}\n {...props}\n >\n {children}\n </td>\n ),\n blockquote: ({ children, className, ...props }) => (\n <blockquote className={classNames(className)} {...props}>\n {children}\n </blockquote>\n ),\n code: ({\n node,\n className,\n key,\n children: codeChildren,\n ...props\n }) => {\n const isInline =\n node?.position?.start.line === node?.position?.end.line;\n let language: LanguageProp | 'text' = 'javascript';\n if (typeof node?.properties?.className === 'string') {\n const rawLanguage = node.properties.className.replace(\n 'language-',\n '',\n );\n language = (Languages as readonly string[]).includes(rawLanguage)\n ? (rawLanguage as LanguageProp)\n : 'text';\n }\n if (isInline) {\n return (\n <Code\n isRunnable={false}\n className={className}\n htmlAttributes={props}\n >\n {codeChildren}\n </Code>\n );\n }\n if (typeof codeChildren === 'string') {\n // Check if code fences are balanced in the markdown\n // If there are an odd number of fences, it means there's an unclosed code block\n const fenceMatches = childrenRef.current.match(/```/g);\n const fenceCount = fenceMatches ? fenceMatches.length : 0;\n const hasUnclosedFence = fenceCount % 2 !== 0;\n\n // Show loading state when there's an unclosed fence (code block is streaming)\n const isCodeBlockLoading = hasUnclosedFence;\n return (\n <CodePreview\n key={key}\n code={codeChildren}\n isLoading={isCodeBlockLoading}\n language={language}\n className={className}\n htmlAttributes={{\n ...props,\n }}\n />\n );\n } else {\n return <code className={className}>{codeChildren}</code>;\n }\n },\n pre: ({ className, children }) => {\n return <pre className={classNames(className)}>{children}</pre>;\n },\n p: ({ children, className, ...props }) => (\n <Typography\n as=\"p\"\n variant=\"body-medium\"\n className={classNames(className)}\n {...props}\n >\n {children}\n </Typography>\n ),\n img: ({ className, src, alt, ...props }) => (\n <img\n className={classNames(className)}\n src={src}\n alt={alt}\n {...props}\n />\n ),\n }),\n [],\n );\n\n return (\n <div\n ref={ref}\n style={style}\n className={classNames(\n 'ndl-ai-response size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0',\n className,\n )}\n {...restProps}\n {...htmlAttributes}\n >\n <Streamdown\n isAnimating={isAnimating}\n parseIncompleteMarkdown={true}\n components={components}\n >\n {children}\n </Streamdown>\n </div>\n );\n },\n (prevProps, nextProps) => prevProps.children === nextProps.children,\n);\n\nResponse.displayName = 'Response';\n\nexport { Response };\n"]}
1
+ {"version":3,"file":"Response.js","sourceRoot":"","sources":["../../../../src/ai/response/Response.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,4CAA8D;AAE9D,4DAAoC;AACpC,iCAA8C;AAC9C,2CAAwC;AAExC,oEAA+E;AAC/E,kDAA8C;AAS9C;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,IAAA,YAAI,EACnB,CAAC,EAQmC,EAAE,EAAE;QARvC,EACC,SAAS,EACT,QAAQ,EACR,WAAW,GAAG,KAAK,EACnB,GAAG,EACH,KAAK,EACL,cAAc,OAEoB,EAD/B,SAAS,cAPb,0EAQA,CADa;IAEZ,sFAAsF;IACtF,2DAA2D;IAC3D,MAAM,WAAW,GAAG,IAAA,cAAM,EA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AiC,EAAE,EAAE;gBAArC,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAY,EAAP,KAAK,cAA/B,2BAAiC,CAAF;YAAO,OAAA,CAC1C,8CACE,SAAS,EAAE,IAAA,oBAAU,EAAC,SAAS,CAAC,EAChC,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,IACJ,KAAK,EACT,CACH,CAAA;SAAA;KACF,CAAC,EACF,EAAE,CACH,CAAC;IAEJ,OAAO,CACL,8CACE,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,IAAA,oBAAU,EACnB,wEAAwE,EACxE,SAAS,CACV,IACG,SAAS,EACT,cAAc,cAElB,uBAAC,uBAAU,IACT,WAAW,EAAE,WAAW,EACxB,uBAAuB,EAAE,IAAI,EAC7B,UAAU,EAAE,UAAU,YAErB,QAAQ,GACE,IACT,CACP,CAAC;AACJ,CAAC,EACD,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,CACpE,CAAC;AAIO,4BAAQ;AAFjB,QAAQ,CAAC,WAAW,GAAG,UAAU,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 */\n\nimport { Code, TextLink, Typography } from '@neo4j-ndl/react';\nimport { type CommonProps } from '@neo4j-ndl/react/_common/types';\nimport classNames from 'classnames';\nimport { memo, useMemo, useRef } from 'react';\nimport { Streamdown } from 'streamdown';\n\nimport { type LanguageProp, Languages } from '../../code-block/code-languages';\nimport { CodePreview } from '../code-preview';\n\ntype ResponseProps = {\n /** The response from the AI */\n children: string;\n /** Whether the response is animating */\n isAnimating?: React.ComponentProps<typeof Streamdown>['isAnimating'];\n};\n\n/**\n * The component is used to display the response from an LLM.\n * It handles markdown rendering and streaming.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst Response = memo(\n ({\n className,\n children,\n isAnimating = false,\n ref,\n style,\n htmlAttributes,\n ...restProps\n }: CommonProps<'div', ResponseProps>) => {\n // Use a ref to store the current markdown content so we can check for unclosed fences\n // without recreating the components object on every render\n const childrenRef = useRef(children);\n childrenRef.current = children;\n\n const components: React.ComponentProps<typeof Streamdown>['components'] =\n useMemo(\n () => ({\n ol: ({ children, className, ...props }) => (\n <ol className={className} {...props}>\n {children}\n </ol>\n ),\n ul: ({ children, className, ...props }) => (\n <ul className={classNames(className)} {...props}>\n {children}\n </ul>\n ),\n li: ({ children, className, ...props }) => (\n <li className={className} {...props}>\n {children}\n </li>\n ),\n hr: ({ className, ...props }) => (\n <hr className={classNames(className)} {...props} />\n ),\n strong: ({ children, className, style, ...props }) => (\n <Typography\n as=\"strong\"\n variant=\"body-medium\"\n className={className}\n style={{ ...style, fontWeight: 'bold' }}\n {...props}\n >\n {children}\n </Typography>\n ),\n em: ({ children, className, style, ...props }) => (\n <Typography\n as=\"em\"\n variant=\"body-medium\"\n className={className}\n style={{ ...style, fontStyle: 'italic' }}\n {...props}\n >\n {children}\n </Typography>\n ),\n a: ({ children, className, href, ...props }) => (\n <TextLink\n type=\"internal-underline\"\n className={className}\n href={href}\n htmlAttributes={props}\n >\n {children}\n </TextLink>\n ),\n h1: ({ children, className, ...props }) => (\n <Typography\n as=\"h1\"\n variant=\"display\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h2: ({ children, className, ...props }) => (\n <Typography\n as=\"h2\"\n variant=\"title-1\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h3: ({ children, className, ...props }) => (\n <Typography\n as=\"h3\"\n variant=\"title-2\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h4: ({ children, className, ...props }) => (\n <Typography\n as=\"h4\"\n variant=\"title-3\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h5: ({ children, className, ...props }) => (\n <Typography\n as=\"h5\"\n variant=\"title-4\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h6: ({ children, className, ...props }) => (\n <Typography\n as=\"h6\"\n variant=\"subheading-large\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n table: ({ children, className, ...props }) => (\n <div className=\"my-4 overflow-x-auto\">\n <table\n className={classNames(\n 'w-full border-collapse border border-border',\n className,\n )}\n {...props}\n >\n {children}\n </table>\n </div>\n ),\n thead: ({ children, className, ...props }) => (\n <thead className={classNames('bg-muted/50', className)} {...props}>\n {children}\n </thead>\n ),\n tbody: ({ children, className, ...props }) => (\n <tbody\n className={classNames('divide-y divide-border', className)}\n {...props}\n >\n {children}\n </tbody>\n ),\n tr: ({ children, className, ...props }) => (\n <tr\n className={classNames('border-border border-b', className)}\n {...props}\n >\n {children}\n </tr>\n ),\n th: ({ children, className, ...props }) => (\n <th\n className={classNames(\n 'px-4 py-2 text-left font-semibold text-sm',\n className,\n )}\n {...props}\n >\n {children}\n </th>\n ),\n td: ({ children, className, ...props }) => (\n <td\n className={classNames('px-4 py-2 text-sm', className)}\n {...props}\n >\n {children}\n </td>\n ),\n blockquote: ({ children, className, ...props }) => (\n <blockquote className={classNames(className)} {...props}>\n {children}\n </blockquote>\n ),\n code: ({\n node,\n className,\n key,\n children: codeChildren,\n ...props\n }) => {\n const isInline =\n node?.position?.start.line === node?.position?.end.line;\n let language: LanguageProp | 'text' = 'javascript';\n if (typeof node?.properties?.className === 'string') {\n const rawLanguage = node.properties.className.replace(\n 'language-',\n '',\n );\n language = (Languages as readonly string[]).includes(rawLanguage)\n ? (rawLanguage as LanguageProp)\n : 'text';\n }\n if (isInline) {\n return (\n <Code\n isRunnable={false}\n className={className}\n htmlAttributes={props}\n >\n {codeChildren}\n </Code>\n );\n }\n if (typeof codeChildren === 'string') {\n // Check if code fences are balanced in the markdown\n // If there are an odd number of fences, it means there's an unclosed code block\n const fenceMatches = childrenRef.current.match(/```/g);\n const fenceCount = fenceMatches ? fenceMatches.length : 0;\n const hasUnclosedFence = fenceCount % 2 !== 0;\n\n // Show loading state when there's an unclosed fence (code block is streaming)\n const isCodeBlockLoading = hasUnclosedFence;\n return (\n <CodePreview\n key={key}\n code={codeChildren}\n isLoading={isCodeBlockLoading}\n language={language}\n className={className}\n htmlAttributes={{\n ...props,\n }}\n />\n );\n } else {\n return <code className={className}>{codeChildren}</code>;\n }\n },\n pre: ({ className, children }) => {\n return <pre className={classNames(className)}>{children}</pre>;\n },\n p: ({ children, className, ...props }) => (\n <Typography\n as=\"p\"\n variant=\"body-medium\"\n className={classNames(className)}\n {...props}\n >\n {children}\n </Typography>\n ),\n img: ({ className, src, alt, ...props }) => (\n <img\n className={classNames(className)}\n src={src}\n alt={alt}\n {...props}\n />\n ),\n }),\n [],\n );\n\n return (\n <div\n ref={ref}\n style={style}\n className={classNames(\n 'ndl-ai-response size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0',\n className,\n )}\n {...restProps}\n {...htmlAttributes}\n >\n <Streamdown\n isAnimating={isAnimating}\n parseIncompleteMarkdown={true}\n components={components}\n >\n {children}\n </Streamdown>\n </div>\n );\n },\n (prevProps, nextProps) => prevProps.children === nextProps.children,\n);\n\nResponse.displayName = 'Response';\n\nexport { Response };\n"]}
@@ -52,7 +52,7 @@ const HexagonEnd = ({ direction = 'left', color, htmlAttributes, height = 24, })
52
52
  'ndl-left': direction === 'left',
53
53
  'ndl-right': direction === 'right',
54
54
  });
55
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: classes }, htmlAttributes, { children: [(0, jsx_runtime_1.jsx)("svg", { className: "ndl-hexagon-end-inner", width: "9", height: height, viewBox: "0 0 9 24", preserveAspectRatio: "none", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { style: { fill: color }, fillRule: "evenodd", clipRule: "evenodd", d: "M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z" }) }), (0, jsx_runtime_1.jsx)("svg", { className: "ndl-hexagon-end-active", width: "13", height: height + 6, viewBox: "0 0 13 30", preserveAspectRatio: "none", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z" }) })] })));
55
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: classes }, htmlAttributes, { children: [(0, jsx_runtime_1.jsx)("svg", { "aria-hidden": true, className: "ndl-hexagon-end-inner", fill: "none", height: height, preserveAspectRatio: "none", viewBox: "0 0 9 24", width: "9", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { style: { fill: color }, fillRule: "evenodd", clipRule: "evenodd", d: "M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z" }) }), (0, jsx_runtime_1.jsx)("svg", { "aria-hidden": true, className: "ndl-hexagon-end-active", fill: "none", height: height + 6, preserveAspectRatio: "none", viewBox: "0 0 13 30", width: "13", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z" }) })] })));
56
56
  };
57
57
  const SquareEnd = ({ direction = 'left', color, height = 24, htmlAttributes, }) => {
58
58
  const classes = (0, classnames_1.default)('ndl-square-end', {
@@ -1 +1 @@
1
- {"version":3,"file":"GraphLabel.js","sourceRoot":"","sources":["../../../src/graph-label/GraphLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,0CAAyC;AACzC,4DAAoC;AAEpC,iCAA0C;AAM1C,mCAIiB;AAgDjB;;;;;;GAMG;AAEH,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,GAAG,MAAM,EAClB,KAAK,EACL,cAAc,EACd,MAAM,GAAG,EAAE,GACK,EAAE,EAAE;IACpB,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,iBAAiB,EAAE;QAC5C,UAAU,EAAE,SAAS,KAAK,MAAM;QAChC,WAAW,EAAE,SAAS,KAAK,OAAO;KACnC,CAAC,CAAC;IAEH,OAAO,CACL,+CAAK,SAAS,EAAE,OAAO,IAAM,cAAc,eACzC,gCACE,SAAS,EAAC,uBAAuB,EACjC,KAAK,EAAC,GAAG,EACT,MAAM,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E,eAAe,EAAE,MAAM,EAAE,MAAM,GAAI,CACvE,EACD,iCACE,SAAS,EAAC,kCAAkC,EAC5C,KAAK,EAAE;wBACL,eAAe,EAAE,eAAe;qBACjC,aAED,gCAAK,SAAS,EAAC,gCAAgC,YAAE,QAAQ,GAAO,EAChE,uBAAC,eAAe,IAAC,MAAM,EAAE,MAAM,GAAI,IAC/B,EACL,IAAI,KAAK,mBAAmB,IAAI,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,CACzD,uBAAC,UAAU,IACT,SAAS,EAAC,OAAO,EACjB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,GACd,CACH,CAAC,CAAC,CAAC,CACF,uBAAC,SAAS,IACR,SAAS,EAAC,OAAO,EACjB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,GACd,CACH,KACS,CACb,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,wBAAwB,EAAE,aAAa,CAAC,CAAC;QAEpE,OAAO,CACL,uBAAC,SAAS,kBACR,KAAK,kBACH,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,EACjD,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,IACnC,KAAK,GAEV,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,WAAW,EACpB,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB,EAC9B,GAAG,EAAE,GAAG,IACJ,cAAc,cAElB,gCAAK,SAAS,EAAC,gCAAgC,YAAE,QAAQ,GAAO,IACtD,CACb,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAnNW,QAAA,UAAU,cAmNrB","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 { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useMemo, useState } from 'react';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport {\n getDisabledTextColor,\n getHoverColor,\n getTextColorFromBackground,\n} from './color';\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype GraphLabelProps = {\n /** The type of label */\n type:\n | 'node'\n | 'relationship'\n | 'propertyKey'\n | 'relationshipLeft'\n | 'relationshipRight';\n /** Callback function that is called when the label is clicked */\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Additional styles to apply to the label */\n style?: React.CSSProperties;\n /** Content displayed inside the label */\n children?: React.ReactNode;\n /** The background color of the label */\n color?: string;\n /** Whether the label is disabled */\n isDisabled?: boolean;\n /** Additional class names */\n className?: string;\n /** Whether the label is selected */\n isSelected?: boolean;\n /** Whether the label should expand to full available width */\n isFluid?: boolean;\n /** The size of the label */\n size?: 'small' | 'large';\n};\n\ntype HexagonEndProps = {\n /** The direction of the hexagon end */\n direction: 'left' | 'right';\n /** The color of the hexagon end */\n color?: string;\n /** The height of the hexagon end in pixels */\n height?: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n/**\n *\n *\n * Helpers\n *\n *\n */\n\nconst HexagonEnd = ({\n direction = 'left',\n color,\n htmlAttributes,\n height = 24,\n}: HexagonEndProps) => {\n const classes = classNames('ndl-hexagon-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <svg\n className=\"ndl-hexagon-end-inner\"\n width=\"9\"\n height={height}\n viewBox=\"0 0 9 24\"\n preserveAspectRatio=\"none\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {/* triangle */}\n <path\n style={{ fill: color }}\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z\"\n />\n </svg>\n <svg\n className=\"ndl-hexagon-end-active\"\n width=\"13\"\n height={height + 6}\n viewBox=\"0 0 13 30\"\n preserveAspectRatio=\"none\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype SquareEndProps = {\n /** The direction of the square end (where it's rounded and has the active state) */\n direction: 'left' | 'right';\n /** The color of the square end */\n color: string;\n /** The height of the square end in pixels */\n height: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst SquareEnd = ({\n direction = 'left',\n color,\n height = 24,\n htmlAttributes,\n}: SquareEndProps) => {\n const classes = classNames('ndl-square-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <div\n className=\"ndl-square-end-inner\"\n style={{ backgroundColor: color }}\n />\n <svg\n className=\"ndl-square-end-active\"\n width=\"7\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 7 30\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 3.8774 2 C 3.2697 2 2.7917 2.248 2.3967 2.6605 C 1.928 3.1498 1.7993 3.8555 1.7993 4.5331 V 13.8775 V 25.4669 C 1.7993 26.1445 1.928 26.8502 2.3967 27.3395 C 2.7917 27.752 3.2697 28 3.8774 28 H 7 V 30 H 3.8774 C 2.6211 30 1.4369 29.4282 0.5895 28.4485 C 0.1462 27.936 0.0002 27.2467 0.0002 26.5691 L -0.0002 13.8775 L 0.0002 3.4309 C 0.0002 2.7533 0.1462 2.064 0.5895 1.5515 C 1.4368 0.5718 2.6211 0 3.8774 0 H 7 V 2 H 3.8774 Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype HorizontalLinesProps = {\n height?: number;\n};\n\nconst HorizontalLines = ({ height = 24 }: HorizontalLinesProps) => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 37 30\"\n fill=\"none\"\n className=\"ndl-relationship-label-lines\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 2 H 0 V 0 H 37 V 2 Z\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 30 H 0 V 28 H 37 V 30 Z\"\n />\n </svg>\n );\n};\n\n/**\n *\n *\n * GraphLabel Component\n *\n *\n */\n\nconst MAX_WIDTH = 200;\n\nexport const GraphLabel = <T extends React.ElementType = 'button'>({\n type = 'node',\n color,\n isDisabled = false,\n isSelected = false,\n as,\n onClick,\n className,\n style,\n children,\n htmlAttributes,\n isFluid = false,\n size = 'large',\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, GraphLabelProps>) => {\n const [isHover, setIsHover] = useState(false);\n\n const handleMouseEnter = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(true);\n\n if (htmlAttributes && htmlAttributes.onMouseEnter !== undefined) {\n htmlAttributes.onMouseEnter(event);\n }\n };\n\n const handleMouseLeave = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(false);\n\n htmlAttributes?.onMouseLeave?.(event);\n };\n\n const Component: React.ElementType = as ?? 'button';\n const isButton = Component === 'button';\n\n const handleClick = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n // By default, a <button /> element with disabled set to true will not get its\n // on click handler called. To support the same behavior on <a /> tags we\n // swallow the event here when disabled, since the <a /> tag with disabled set to\n // true will have its onClick handler called\n if (isDisabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n let backgroundColor = useMemo(() => {\n if (color === undefined) {\n switch (type) {\n case 'node':\n return tokens.graph['1'];\n case 'relationship':\n case 'relationshipLeft':\n case 'relationshipRight':\n return tokens.theme.light.color.neutral.bg.strong;\n default:\n return tokens.theme.light.color.neutral.bg.strongest;\n }\n }\n return color;\n }, [color, type]);\n\n const hoverColor = useMemo(\n () =>\n getHoverColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const textColor = useMemo(\n () =>\n getTextColorFromBackground(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const disabledTextColor = useMemo(\n () =>\n getDisabledTextColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n\n if (isHover && !isDisabled) {\n backgroundColor = hoverColor;\n }\n\n const commonClasses = classNames('ndl-graph-label', className, {\n 'ndl-disabled': isDisabled,\n 'ndl-interactable': isButton,\n 'ndl-selected': isSelected,\n 'ndl-small': size === 'small',\n });\n\n if (type === 'node') {\n const classes = classNames('ndl-node-label', commonClasses);\n\n return (\n <Component\n className={classes}\n ref={ref}\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n })}\n {...htmlAttributes}\n >\n <div className=\"ndl-node-label-content\">{children}</div>\n </Component>\n );\n } else if (\n type === 'relationship' ||\n type === 'relationshipLeft' ||\n type === 'relationshipRight'\n ) {\n const classes = classNames('ndl-relationship-label', commonClasses);\n const height = size === 'small' ? 20 : 24;\n\n return (\n <Component\n style={{\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n color: isDisabled ? disabledTextColor : textColor,\n }}\n className={classes}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n })}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {type === 'relationshipLeft' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"left\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd direction=\"left\" color={backgroundColor} height={height} />\n )}\n <div\n className=\"ndl-relationship-label-container\"\n style={{\n backgroundColor: backgroundColor,\n }}\n >\n <div className=\"ndl-relationship-label-content\">{children}</div>\n <HorizontalLines height={height} />\n </div>\n {type === 'relationshipRight' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n )}\n </Component>\n );\n } else {\n const classes = classNames('ndl-property-key-label', commonClasses);\n\n return (\n <Component\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n className={classes}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n ref={ref}\n {...htmlAttributes}\n >\n <div className=\"ndl-property-key-label-content\">{children}</div>\n </Component>\n );\n }\n};\n"]}
1
+ {"version":3,"file":"GraphLabel.js","sourceRoot":"","sources":["../../../src/graph-label/GraphLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,0CAAyC;AACzC,4DAAoC;AAEpC,iCAA0C;AAM1C,mCAIiB;AAgDjB;;;;;;GAMG;AAEH,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,GAAG,MAAM,EAClB,KAAK,EACL,cAAc,EACd,MAAM,GAAG,EAAE,GACK,EAAE,EAAE;IACpB,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,iBAAiB,EAAE;QAC5C,UAAU,EAAE,SAAS,KAAK,MAAM;QAChC,WAAW,EAAE,SAAS,KAAK,OAAO;KACnC,CAAC,CAAC;IAEH,OAAO,CACL,+CAAK,SAAS,EAAE,OAAO,IAAM,cAAc,eACzC,+CACe,IAAI,EACjB,SAAS,EAAC,uBAAuB,EACjC,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAC,MAAM,EAC1B,OAAO,EAAC,UAAU,EAClB,KAAK,EAAC,GAAG,EACT,KAAK,EAAC,4BAA4B,YAGlC,iCACE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EACtB,QAAQ,EAAC,SAAS,EAClB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,oMAAoM,GACtM,GACE,EACN,+CACe,IAAI,EACjB,SAAS,EAAC,wBAAwB,EAClC,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,MAAM,GAAG,CAAC,EAClB,mBAAmB,EAAC,MAAM,EAC1B,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,IAAI,EACV,KAAK,EAAC,4BAA4B,YAElC,iCACE,QAA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ACjB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,GACd,CACH,KACS,CACb,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,wBAAwB,EAAE,aAAa,CAAC,CAAC;QAEpE,OAAO,CACL,uBAAC,SAAS,kBACR,KAAK,kBACH,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,EACjD,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,IACnC,KAAK,GAEV,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,WAAW,EACpB,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB,EAC9B,GAAG,EAAE,GAAG,IACJ,cAAc,cAElB,gCAAK,SAAS,EAAC,gCAAgC,YAAE,QAAQ,GAAO,IACtD,CACb,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAnNW,QAAA,UAAU,cAmNrB","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 { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useMemo, useState } from 'react';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport {\n getDisabledTextColor,\n getHoverColor,\n getTextColorFromBackground,\n} from './color';\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype GraphLabelProps = {\n /** The type of label */\n type:\n | 'node'\n | 'relationship'\n | 'propertyKey'\n | 'relationshipLeft'\n | 'relationshipRight';\n /** Callback function that is called when the label is clicked */\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Additional styles to apply to the label */\n style?: React.CSSProperties;\n /** Content displayed inside the label */\n children?: React.ReactNode;\n /** The background color of the label */\n color?: string;\n /** Whether the label is disabled */\n isDisabled?: boolean;\n /** Additional class names */\n className?: string;\n /** Whether the label is selected */\n isSelected?: boolean;\n /** Whether the label should expand to full available width */\n isFluid?: boolean;\n /** The size of the label */\n size?: 'small' | 'large';\n};\n\ntype HexagonEndProps = {\n /** The direction of the hexagon end */\n direction: 'left' | 'right';\n /** The color of the hexagon end */\n color?: string;\n /** The height of the hexagon end in pixels */\n height?: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n/**\n *\n *\n * Helpers\n *\n *\n */\n\nconst HexagonEnd = ({\n direction = 'left',\n color,\n htmlAttributes,\n height = 24,\n}: HexagonEndProps) => {\n const classes = classNames('ndl-hexagon-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <svg\n aria-hidden={true}\n className=\"ndl-hexagon-end-inner\"\n fill=\"none\"\n height={height}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 9 24\"\n width=\"9\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {/* triangle */}\n <path\n style={{ fill: color }}\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z\"\n />\n </svg>\n <svg\n aria-hidden={true}\n className=\"ndl-hexagon-end-active\"\n fill=\"none\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 13 30\"\n width=\"13\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype SquareEndProps = {\n /** The direction of the square end (where it's rounded and has the active state) */\n direction: 'left' | 'right';\n /** The color of the square end */\n color: string;\n /** The height of the square end in pixels */\n height: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst SquareEnd = ({\n direction = 'left',\n color,\n height = 24,\n htmlAttributes,\n}: SquareEndProps) => {\n const classes = classNames('ndl-square-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <div\n className=\"ndl-square-end-inner\"\n style={{ backgroundColor: color }}\n />\n <svg\n className=\"ndl-square-end-active\"\n width=\"7\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 7 30\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 3.8774 2 C 3.2697 2 2.7917 2.248 2.3967 2.6605 C 1.928 3.1498 1.7993 3.8555 1.7993 4.5331 V 13.8775 V 25.4669 C 1.7993 26.1445 1.928 26.8502 2.3967 27.3395 C 2.7917 27.752 3.2697 28 3.8774 28 H 7 V 30 H 3.8774 C 2.6211 30 1.4369 29.4282 0.5895 28.4485 C 0.1462 27.936 0.0002 27.2467 0.0002 26.5691 L -0.0002 13.8775 L 0.0002 3.4309 C 0.0002 2.7533 0.1462 2.064 0.5895 1.5515 C 1.4368 0.5718 2.6211 0 3.8774 0 H 7 V 2 H 3.8774 Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype HorizontalLinesProps = {\n height?: number;\n};\n\nconst HorizontalLines = ({ height = 24 }: HorizontalLinesProps) => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 37 30\"\n fill=\"none\"\n className=\"ndl-relationship-label-lines\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 2 H 0 V 0 H 37 V 2 Z\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 30 H 0 V 28 H 37 V 30 Z\"\n />\n </svg>\n );\n};\n\n/**\n *\n *\n * GraphLabel Component\n *\n *\n */\n\nconst MAX_WIDTH = 200;\n\nexport const GraphLabel = <T extends React.ElementType = 'button'>({\n type = 'node',\n color,\n isDisabled = false,\n isSelected = false,\n as,\n onClick,\n className,\n style,\n children,\n htmlAttributes,\n isFluid = false,\n size = 'large',\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, GraphLabelProps>) => {\n const [isHover, setIsHover] = useState(false);\n\n const handleMouseEnter = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(true);\n\n if (htmlAttributes && htmlAttributes.onMouseEnter !== undefined) {\n htmlAttributes.onMouseEnter(event);\n }\n };\n\n const handleMouseLeave = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(false);\n\n htmlAttributes?.onMouseLeave?.(event);\n };\n\n const Component: React.ElementType = as ?? 'button';\n const isButton = Component === 'button';\n\n const handleClick = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n // By default, a <button /> element with disabled set to true will not get its\n // on click handler called. To support the same behavior on <a /> tags we\n // swallow the event here when disabled, since the <a /> tag with disabled set to\n // true will have its onClick handler called\n if (isDisabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n let backgroundColor = useMemo(() => {\n if (color === undefined) {\n switch (type) {\n case 'node':\n return tokens.graph['1'];\n case 'relationship':\n case 'relationshipLeft':\n case 'relationshipRight':\n return tokens.theme.light.color.neutral.bg.strong;\n default:\n return tokens.theme.light.color.neutral.bg.strongest;\n }\n }\n return color;\n }, [color, type]);\n\n const hoverColor = useMemo(\n () =>\n getHoverColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const textColor = useMemo(\n () =>\n getTextColorFromBackground(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const disabledTextColor = useMemo(\n () =>\n getDisabledTextColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n\n if (isHover && !isDisabled) {\n backgroundColor = hoverColor;\n }\n\n const commonClasses = classNames('ndl-graph-label', className, {\n 'ndl-disabled': isDisabled,\n 'ndl-interactable': isButton,\n 'ndl-selected': isSelected,\n 'ndl-small': size === 'small',\n });\n\n if (type === 'node') {\n const classes = classNames('ndl-node-label', commonClasses);\n\n return (\n <Component\n className={classes}\n ref={ref}\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n })}\n {...htmlAttributes}\n >\n <div className=\"ndl-node-label-content\">{children}</div>\n </Component>\n );\n } else if (\n type === 'relationship' ||\n type === 'relationshipLeft' ||\n type === 'relationshipRight'\n ) {\n const classes = classNames('ndl-relationship-label', commonClasses);\n const height = size === 'small' ? 20 : 24;\n\n return (\n <Component\n style={{\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n color: isDisabled ? disabledTextColor : textColor,\n }}\n className={classes}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n })}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {type === 'relationshipLeft' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"left\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd direction=\"left\" color={backgroundColor} height={height} />\n )}\n <div\n className=\"ndl-relationship-label-container\"\n style={{\n backgroundColor: backgroundColor,\n }}\n >\n <div className=\"ndl-relationship-label-content\">{children}</div>\n <HorizontalLines height={height} />\n </div>\n {type === 'relationshipRight' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n )}\n </Component>\n );\n } else {\n const classes = classNames('ndl-property-key-label', commonClasses);\n\n return (\n <Component\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n className={classes}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n ref={ref}\n {...htmlAttributes}\n >\n <div className=\"ndl-property-key-label-content\">{children}</div>\n </Component>\n );\n }\n};\n"]}
@@ -1,3 +1,15 @@
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 } from "react/jsx-runtime";
1
13
  /**
2
14
  *
3
15
  * Copyright (c) "Neo4j"
@@ -18,22 +30,7 @@
18
30
  * You should have received a copy of the GNU General Public License
19
31
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
32
  */
21
-
22
- var __rest = (this && this.__rest) || function (s, e) {
23
- var t = {};
24
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
25
- t[p] = s[p];
26
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
27
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
28
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
29
- t[p[i]] = s[p[i]];
30
- }
31
- return t;
32
- };
33
- import { jsx as _jsx } from "react/jsx-runtime";
34
- import { Code } from '@neo4j-ndl/react/code';
35
- import { TextLink } from '@neo4j-ndl/react/text-link';
36
- import { Typography } from '@neo4j-ndl/react/typography';
33
+ import { Code, TextLink, Typography } from '@neo4j-ndl/react';
37
34
  import classNames from 'classnames';
38
35
  import { memo, useMemo, useRef } from 'react';
39
36
  import { Streamdown } from 'streamdown';
@@ -1 +1 @@
1
- {"version":3,"file":"Response.js","sourceRoot":"","sources":["../../../../src/ai/response/Response.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAqB,SAAS,EAAE,MAAM,iCAAi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/B,yBAAiC,CAAF;YAAO,OAAA,CACxC,KAAC,UAAU,kBACT,EAAE,EAAC,GAAG,EACN,OAAO,EAAC,aAAa,EACrB,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,IAC5B,KAAK,cAER,QAAQ,IACE,CACd,CAAA;SAAA;QACD,GAAG,EAAE,CAAC,EAAiC,EAAE,EAAE;gBAArC,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAY,EAAP,KAAK,cAA/B,2BAAiC,CAAF;YAAO,OAAA,CAC1C,4BACE,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,EAChC,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,IACJ,KAAK,EACT,CACH,CAAA;SAAA;KACF,CAAC,EACF,EAAE,CACH,CAAC;IAEJ,OAAO,CACL,4BACE,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,UAAU,CACnB,wEAAwE,EACxE,SAAS,CACV,IACG,SAAS,EACT,cAAc,cAElB,KAAC,UAAU,IACT,WAAW,EAAE,WAAW,EACxB,uBAAuB,EAAE,IAAI,EAC7B,UAAU,EAAE,UAAU,YAErB,QAAQ,GACE,IACT,CACP,CAAC;AACJ,CAAC,EACD,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,CACpE,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,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 */\n\nimport { type CommonProps } from '@neo4j-ndl/react/_common/types';\nimport { Code } from '@neo4j-ndl/react/code';\nimport { TextLink } from '@neo4j-ndl/react/text-link';\nimport { Typography } from '@neo4j-ndl/react/typography';\nimport classNames from 'classnames';\nimport { memo, useMemo, useRef } from 'react';\nimport { Streamdown } from 'streamdown';\n\nimport { type LanguageProp, Languages } from '../../code-block/code-languages';\nimport { CodePreview } from '../code-preview';\n\ntype ResponseProps = {\n /** The response from the AI */\n children: string;\n /** Whether the response is animating */\n isAnimating?: React.ComponentProps<typeof Streamdown>['isAnimating'];\n};\n\n/**\n * The component is used to display the response from an LLM.\n * It handles markdown rendering and streaming.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst Response = memo(\n ({\n className,\n children,\n isAnimating = false,\n ref,\n style,\n htmlAttributes,\n ...restProps\n }: CommonProps<'div', ResponseProps>) => {\n // Use a ref to store the current markdown content so we can check for unclosed fences\n // without recreating the components object on every render\n const childrenRef = useRef(children);\n childrenRef.current = children;\n\n const components: React.ComponentProps<typeof Streamdown>['components'] =\n useMemo(\n () => ({\n ol: ({ children, className, ...props }) => (\n <ol className={className} {...props}>\n {children}\n </ol>\n ),\n ul: ({ children, className, ...props }) => (\n <ul className={classNames(className)} {...props}>\n {children}\n </ul>\n ),\n li: ({ children, className, ...props }) => (\n <li className={className} {...props}>\n {children}\n </li>\n ),\n hr: ({ className, ...props }) => (\n <hr className={classNames(className)} {...props} />\n ),\n strong: ({ children, className, style, ...props }) => (\n <Typography\n as=\"strong\"\n variant=\"body-medium\"\n className={className}\n style={{ ...style, fontWeight: 'bold' }}\n {...props}\n >\n {children}\n </Typography>\n ),\n em: ({ children, className, style, ...props }) => (\n <Typography\n as=\"em\"\n variant=\"body-medium\"\n className={className}\n style={{ ...style, fontStyle: 'italic' }}\n {...props}\n >\n {children}\n </Typography>\n ),\n a: ({ children, className, href, ...props }) => (\n <TextLink\n type=\"internal-underline\"\n className={className}\n href={href}\n htmlAttributes={props}\n >\n {children}\n </TextLink>\n ),\n h1: ({ children, className, ...props }) => (\n <Typography\n as=\"h1\"\n variant=\"display\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h2: ({ children, className, ...props }) => (\n <Typography\n as=\"h2\"\n variant=\"title-1\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h3: ({ children, className, ...props }) => (\n <Typography\n as=\"h3\"\n variant=\"title-2\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h4: ({ children, className, ...props }) => (\n <Typography\n as=\"h4\"\n variant=\"title-3\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h5: ({ children, className, ...props }) => (\n <Typography\n as=\"h5\"\n variant=\"title-4\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h6: ({ children, className, ...props }) => (\n <Typography\n as=\"h6\"\n variant=\"subheading-large\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n table: ({ children, className, ...props }) => (\n <div className=\"my-4 overflow-x-auto\">\n <table\n className={classNames(\n 'w-full border-collapse border border-border',\n className,\n )}\n {...props}\n >\n {children}\n </table>\n </div>\n ),\n thead: ({ children, className, ...props }) => (\n <thead className={classNames('bg-muted/50', className)} {...props}>\n {children}\n </thead>\n ),\n tbody: ({ children, className, ...props }) => (\n <tbody\n className={classNames('divide-y divide-border', className)}\n {...props}\n >\n {children}\n </tbody>\n ),\n tr: ({ children, className, ...props }) => (\n <tr\n className={classNames('border-border border-b', className)}\n {...props}\n >\n {children}\n </tr>\n ),\n th: ({ children, className, ...props }) => (\n <th\n className={classNames(\n 'px-4 py-2 text-left font-semibold text-sm',\n className,\n )}\n {...props}\n >\n {children}\n </th>\n ),\n td: ({ children, className, ...props }) => (\n <td\n className={classNames('px-4 py-2 text-sm', className)}\n {...props}\n >\n {children}\n </td>\n ),\n blockquote: ({ children, className, ...props }) => (\n <blockquote className={classNames(className)} {...props}>\n {children}\n </blockquote>\n ),\n code: ({\n node,\n className,\n key,\n children: codeChildren,\n ...props\n }) => {\n const isInline =\n node?.position?.start.line === node?.position?.end.line;\n let language: LanguageProp | 'text' = 'javascript';\n if (typeof node?.properties?.className === 'string') {\n const rawLanguage = node.properties.className.replace(\n 'language-',\n '',\n );\n language = (Languages as readonly string[]).includes(rawLanguage)\n ? (rawLanguage as LanguageProp)\n : 'text';\n }\n if (isInline) {\n return (\n <Code\n isRunnable={false}\n className={className}\n htmlAttributes={props}\n >\n {codeChildren}\n </Code>\n );\n }\n if (typeof codeChildren === 'string') {\n // Check if code fences are balanced in the markdown\n // If there are an odd number of fences, it means there's an unclosed code block\n const fenceMatches = childrenRef.current.match(/```/g);\n const fenceCount = fenceMatches ? fenceMatches.length : 0;\n const hasUnclosedFence = fenceCount % 2 !== 0;\n\n // Show loading state when there's an unclosed fence (code block is streaming)\n const isCodeBlockLoading = hasUnclosedFence;\n return (\n <CodePreview\n key={key}\n code={codeChildren}\n isLoading={isCodeBlockLoading}\n language={language}\n className={className}\n htmlAttributes={{\n ...props,\n }}\n />\n );\n } else {\n return <code className={className}>{codeChildren}</code>;\n }\n },\n pre: ({ className, children }) => {\n return <pre className={classNames(className)}>{children}</pre>;\n },\n p: ({ children, className, ...props }) => (\n <Typography\n as=\"p\"\n variant=\"body-medium\"\n className={classNames(className)}\n {...props}\n >\n {children}\n </Typography>\n ),\n img: ({ className, src, alt, ...props }) => (\n <img\n className={classNames(className)}\n src={src}\n alt={alt}\n {...props}\n />\n ),\n }),\n [],\n );\n\n return (\n <div\n ref={ref}\n style={style}\n className={classNames(\n 'ndl-ai-response size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0',\n className,\n )}\n {...restProps}\n {...htmlAttributes}\n >\n <Streamdown\n isAnimating={isAnimating}\n parseIncompleteMarkdown={true}\n components={components}\n >\n {children}\n </Streamdown>\n </div>\n );\n },\n (prevProps, nextProps) => prevProps.children === nextProps.children,\n);\n\nResponse.displayName = 'Response';\n\nexport { Response };\n"]}
1
+ {"version":3,"file":"Response.js","sourceRoot":"","sources":["../../../../src/ai/response/Response.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAqB,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAS9C;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,IAAI,CACnB,CAAC,EAQmC,EAAE,EAAE;QARvC,EACC,SAAS,EACT,QAAQ,EACR,WAAW,GAAG,KAAK,EACnB,GAAG,EACH,KAAK,EACL,cAAc,OAEoB,EAD/B,SAAS,cAPb,0EAQA,CADa;IAEZ,sFAAsF;IACtF,2DAA2D;IAC3D,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrC,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;IAE/B,MAAM,UAAU,GACd,OAAO,CACL,GAAG,EAAE,CAAC,CAAC;QACL,EAAE,EAAE,CAAC,EAAiC,EAAE,EAAE;gBAArC,EAAE,QAAQ,EAAE,SAAS,OAAY,EAAP,KAAK,cAA/B,yBAAiC,CAAF;YAAO,OAAA,CACzC,2BAAI,SAAS,EAAE,SAAS,IAAM,KAAK,cAChC,QAAQ,IACN,CACN,CAAA;SAAA;QACD,EAAE,EAAE,CAAC,EAAiC,EAAE,E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AC7B,UAAU,EAAE,UAAU,YAErB,QAAQ,GACE,IACT,CACP,CAAC;AACJ,CAAC,EACD,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,CACpE,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,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 */\n\nimport { Code, TextLink, Typography } from '@neo4j-ndl/react';\nimport { type CommonProps } from '@neo4j-ndl/react/_common/types';\nimport classNames from 'classnames';\nimport { memo, useMemo, useRef } from 'react';\nimport { Streamdown } from 'streamdown';\n\nimport { type LanguageProp, Languages } from '../../code-block/code-languages';\nimport { CodePreview } from '../code-preview';\n\ntype ResponseProps = {\n /** The response from the AI */\n children: string;\n /** Whether the response is animating */\n isAnimating?: React.ComponentProps<typeof Streamdown>['isAnimating'];\n};\n\n/**\n * The component is used to display the response from an LLM.\n * It handles markdown rendering and streaming.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst Response = memo(\n ({\n className,\n children,\n isAnimating = false,\n ref,\n style,\n htmlAttributes,\n ...restProps\n }: CommonProps<'div', ResponseProps>) => {\n // Use a ref to store the current markdown content so we can check for unclosed fences\n // without recreating the components object on every render\n const childrenRef = useRef(children);\n childrenRef.current = children;\n\n const components: React.ComponentProps<typeof Streamdown>['components'] =\n useMemo(\n () => ({\n ol: ({ children, className, ...props }) => (\n <ol className={className} {...props}>\n {children}\n </ol>\n ),\n ul: ({ children, className, ...props }) => (\n <ul className={classNames(className)} {...props}>\n {children}\n </ul>\n ),\n li: ({ children, className, ...props }) => (\n <li className={className} {...props}>\n {children}\n </li>\n ),\n hr: ({ className, ...props }) => (\n <hr className={classNames(className)} {...props} />\n ),\n strong: ({ children, className, style, ...props }) => (\n <Typography\n as=\"strong\"\n variant=\"body-medium\"\n className={className}\n style={{ ...style, fontWeight: 'bold' }}\n {...props}\n >\n {children}\n </Typography>\n ),\n em: ({ children, className, style, ...props }) => (\n <Typography\n as=\"em\"\n variant=\"body-medium\"\n className={className}\n style={{ ...style, fontStyle: 'italic' }}\n {...props}\n >\n {children}\n </Typography>\n ),\n a: ({ children, className, href, ...props }) => (\n <TextLink\n type=\"internal-underline\"\n className={className}\n href={href}\n htmlAttributes={props}\n >\n {children}\n </TextLink>\n ),\n h1: ({ children, className, ...props }) => (\n <Typography\n as=\"h1\"\n variant=\"display\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h2: ({ children, className, ...props }) => (\n <Typography\n as=\"h2\"\n variant=\"title-1\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h3: ({ children, className, ...props }) => (\n <Typography\n as=\"h3\"\n variant=\"title-2\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h4: ({ children, className, ...props }) => (\n <Typography\n as=\"h4\"\n variant=\"title-3\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h5: ({ children, className, ...props }) => (\n <Typography\n as=\"h5\"\n variant=\"title-4\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n h6: ({ children, className, ...props }) => (\n <Typography\n as=\"h6\"\n variant=\"subheading-large\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n table: ({ children, className, ...props }) => (\n <div className=\"my-4 overflow-x-auto\">\n <table\n className={classNames(\n 'w-full border-collapse border border-border',\n className,\n )}\n {...props}\n >\n {children}\n </table>\n </div>\n ),\n thead: ({ children, className, ...props }) => (\n <thead className={classNames('bg-muted/50', className)} {...props}>\n {children}\n </thead>\n ),\n tbody: ({ children, className, ...props }) => (\n <tbody\n className={classNames('divide-y divide-border', className)}\n {...props}\n >\n {children}\n </tbody>\n ),\n tr: ({ children, className, ...props }) => (\n <tr\n className={classNames('border-border border-b', className)}\n {...props}\n >\n {children}\n </tr>\n ),\n th: ({ children, className, ...props }) => (\n <th\n className={classNames(\n 'px-4 py-2 text-left font-semibold text-sm',\n className,\n )}\n {...props}\n >\n {children}\n </th>\n ),\n td: ({ children, className, ...props }) => (\n <td\n className={classNames('px-4 py-2 text-sm', className)}\n {...props}\n >\n {children}\n </td>\n ),\n blockquote: ({ children, className, ...props }) => (\n <blockquote className={classNames(className)} {...props}>\n {children}\n </blockquote>\n ),\n code: ({\n node,\n className,\n key,\n children: codeChildren,\n ...props\n }) => {\n const isInline =\n node?.position?.start.line === node?.position?.end.line;\n let language: LanguageProp | 'text' = 'javascript';\n if (typeof node?.properties?.className === 'string') {\n const rawLanguage = node.properties.className.replace(\n 'language-',\n '',\n );\n language = (Languages as readonly string[]).includes(rawLanguage)\n ? (rawLanguage as LanguageProp)\n : 'text';\n }\n if (isInline) {\n return (\n <Code\n isRunnable={false}\n className={className}\n htmlAttributes={props}\n >\n {codeChildren}\n </Code>\n );\n }\n if (typeof codeChildren === 'string') {\n // Check if code fences are balanced in the markdown\n // If there are an odd number of fences, it means there's an unclosed code block\n const fenceMatches = childrenRef.current.match(/```/g);\n const fenceCount = fenceMatches ? fenceMatches.length : 0;\n const hasUnclosedFence = fenceCount % 2 !== 0;\n\n // Show loading state when there's an unclosed fence (code block is streaming)\n const isCodeBlockLoading = hasUnclosedFence;\n return (\n <CodePreview\n key={key}\n code={codeChildren}\n isLoading={isCodeBlockLoading}\n language={language}\n className={className}\n htmlAttributes={{\n ...props,\n }}\n />\n );\n } else {\n return <code className={className}>{codeChildren}</code>;\n }\n },\n pre: ({ className, children }) => {\n return <pre className={classNames(className)}>{children}</pre>;\n },\n p: ({ children, className, ...props }) => (\n <Typography\n as=\"p\"\n variant=\"body-medium\"\n className={classNames(className)}\n {...props}\n >\n {children}\n </Typography>\n ),\n img: ({ className, src, alt, ...props }) => (\n <img\n className={classNames(className)}\n src={src}\n alt={alt}\n {...props}\n />\n ),\n }),\n [],\n );\n\n return (\n <div\n ref={ref}\n style={style}\n className={classNames(\n 'ndl-ai-response size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0',\n className,\n )}\n {...restProps}\n {...htmlAttributes}\n >\n <Streamdown\n isAnimating={isAnimating}\n parseIncompleteMarkdown={true}\n components={components}\n >\n {children}\n </Streamdown>\n </div>\n );\n },\n (prevProps, nextProps) => prevProps.children === nextProps.children,\n);\n\nResponse.displayName = 'Response';\n\nexport { Response };\n"]}
@@ -46,7 +46,7 @@ const HexagonEnd = ({ direction = 'left', color, htmlAttributes, height = 24, })
46
46
  'ndl-left': direction === 'left',
47
47
  'ndl-right': direction === 'right',
48
48
  });
49
- return (_jsxs("div", Object.assign({ className: classes }, htmlAttributes, { children: [_jsx("svg", { className: "ndl-hexagon-end-inner", width: "9", height: height, viewBox: "0 0 9 24", preserveAspectRatio: "none", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { style: { fill: color }, fillRule: "evenodd", clipRule: "evenodd", d: "M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z" }) }), _jsx("svg", { className: "ndl-hexagon-end-active", width: "13", height: height + 6, viewBox: "0 0 13 30", preserveAspectRatio: "none", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z" }) })] })));
49
+ return (_jsxs("div", Object.assign({ className: classes }, htmlAttributes, { children: [_jsx("svg", { "aria-hidden": true, className: "ndl-hexagon-end-inner", fill: "none", height: height, preserveAspectRatio: "none", viewBox: "0 0 9 24", width: "9", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { style: { fill: color }, fillRule: "evenodd", clipRule: "evenodd", d: "M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z" }) }), _jsx("svg", { "aria-hidden": true, className: "ndl-hexagon-end-active", fill: "none", height: height + 6, preserveAspectRatio: "none", viewBox: "0 0 13 30", width: "13", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z" }) })] })));
50
50
  };
51
51
  const SquareEnd = ({ direction = 'left', color, height = 24, htmlAttributes, }) => {
52
52
  const classes = classNames('ndl-square-end', {
@@ -1 +1 @@
1
- {"version":3,"file":"Gra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U,CAAC,wBAAwB,EAAE,aAAa,CAAC,CAAC;QAEpE,OAAO,CACL,KAAC,SAAS,kBACR,KAAK,kBACH,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,EACjD,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,IACnC,KAAK,GAEV,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,WAAW,EACpB,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB,EAC9B,GAAG,EAAE,GAAG,IACJ,cAAc,cAElB,cAAK,SAAS,EAAC,gCAAgC,YAAE,QAAQ,GAAO,IACtD,CACb,CAAC;IACJ,CAAC;AACH,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 { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useMemo, useState } from 'react';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport {\n getDisabledTextColor,\n getHoverColor,\n getTextColorFromBackground,\n} from './color';\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype GraphLabelProps = {\n /** The type of label */\n type:\n | 'node'\n | 'relationship'\n | 'propertyKey'\n | 'relationshipLeft'\n | 'relationshipRight';\n /** Callback function that is called when the label is clicked */\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Additional styles to apply to the label */\n style?: React.CSSProperties;\n /** Content displayed inside the label */\n children?: React.ReactNode;\n /** The background color of the label */\n color?: string;\n /** Whether the label is disabled */\n isDisabled?: boolean;\n /** Additional class names */\n className?: string;\n /** Whether the label is selected */\n isSelected?: boolean;\n /** Whether the label should expand to full available width */\n isFluid?: boolean;\n /** The size of the label */\n size?: 'small' | 'large';\n};\n\ntype HexagonEndProps = {\n /** The direction of the hexagon end */\n direction: 'left' | 'right';\n /** The color of the hexagon end */\n color?: string;\n /** The height of the hexagon end in pixels */\n height?: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n/**\n *\n *\n * Helpers\n *\n *\n */\n\nconst HexagonEnd = ({\n direction = 'left',\n color,\n htmlAttributes,\n height = 24,\n}: HexagonEndProps) => {\n const classes = classNames('ndl-hexagon-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <svg\n className=\"ndl-hexagon-end-inner\"\n width=\"9\"\n height={height}\n viewBox=\"0 0 9 24\"\n preserveAspectRatio=\"none\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {/* triangle */}\n <path\n style={{ fill: color }}\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z\"\n />\n </svg>\n <svg\n className=\"ndl-hexagon-end-active\"\n width=\"13\"\n height={height + 6}\n viewBox=\"0 0 13 30\"\n preserveAspectRatio=\"none\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype SquareEndProps = {\n /** The direction of the square end (where it's rounded and has the active state) */\n direction: 'left' | 'right';\n /** The color of the square end */\n color: string;\n /** The height of the square end in pixels */\n height: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst SquareEnd = ({\n direction = 'left',\n color,\n height = 24,\n htmlAttributes,\n}: SquareEndProps) => {\n const classes = classNames('ndl-square-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <div\n className=\"ndl-square-end-inner\"\n style={{ backgroundColor: color }}\n />\n <svg\n className=\"ndl-square-end-active\"\n width=\"7\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 7 30\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 3.8774 2 C 3.2697 2 2.7917 2.248 2.3967 2.6605 C 1.928 3.1498 1.7993 3.8555 1.7993 4.5331 V 13.8775 V 25.4669 C 1.7993 26.1445 1.928 26.8502 2.3967 27.3395 C 2.7917 27.752 3.2697 28 3.8774 28 H 7 V 30 H 3.8774 C 2.6211 30 1.4369 29.4282 0.5895 28.4485 C 0.1462 27.936 0.0002 27.2467 0.0002 26.5691 L -0.0002 13.8775 L 0.0002 3.4309 C 0.0002 2.7533 0.1462 2.064 0.5895 1.5515 C 1.4368 0.5718 2.6211 0 3.8774 0 H 7 V 2 H 3.8774 Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype HorizontalLinesProps = {\n height?: number;\n};\n\nconst HorizontalLines = ({ height = 24 }: HorizontalLinesProps) => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 37 30\"\n fill=\"none\"\n className=\"ndl-relationship-label-lines\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 2 H 0 V 0 H 37 V 2 Z\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 30 H 0 V 28 H 37 V 30 Z\"\n />\n </svg>\n );\n};\n\n/**\n *\n *\n * GraphLabel Component\n *\n *\n */\n\nconst MAX_WIDTH = 200;\n\nexport const GraphLabel = <T extends React.ElementType = 'button'>({\n type = 'node',\n color,\n isDisabled = false,\n isSelected = false,\n as,\n onClick,\n className,\n style,\n children,\n htmlAttributes,\n isFluid = false,\n size = 'large',\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, GraphLabelProps>) => {\n const [isHover, setIsHover] = useState(false);\n\n const handleMouseEnter = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(true);\n\n if (htmlAttributes && htmlAttributes.onMouseEnter !== undefined) {\n htmlAttributes.onMouseEnter(event);\n }\n };\n\n const handleMouseLeave = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(false);\n\n htmlAttributes?.onMouseLeave?.(event);\n };\n\n const Component: React.ElementType = as ?? 'button';\n const isButton = Component === 'button';\n\n const handleClick = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n // By default, a <button /> element with disabled set to true will not get its\n // on click handler called. To support the same behavior on <a /> tags we\n // swallow the event here when disabled, since the <a /> tag with disabled set to\n // true will have its onClick handler called\n if (isDisabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n let backgroundColor = useMemo(() => {\n if (color === undefined) {\n switch (type) {\n case 'node':\n return tokens.graph['1'];\n case 'relationship':\n case 'relationshipLeft':\n case 'relationshipRight':\n return tokens.theme.light.color.neutral.bg.strong;\n default:\n return tokens.theme.light.color.neutral.bg.strongest;\n }\n }\n return color;\n }, [color, type]);\n\n const hoverColor = useMemo(\n () =>\n getHoverColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const textColor = useMemo(\n () =>\n getTextColorFromBackground(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const disabledTextColor = useMemo(\n () =>\n getDisabledTextColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n\n if (isHover && !isDisabled) {\n backgroundColor = hoverColor;\n }\n\n const commonClasses = classNames('ndl-graph-label', className, {\n 'ndl-disabled': isDisabled,\n 'ndl-interactable': isButton,\n 'ndl-selected': isSelected,\n 'ndl-small': size === 'small',\n });\n\n if (type === 'node') {\n const classes = classNames('ndl-node-label', commonClasses);\n\n return (\n <Component\n className={classes}\n ref={ref}\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n })}\n {...htmlAttributes}\n >\n <div className=\"ndl-node-label-content\">{children}</div>\n </Component>\n );\n } else if (\n type === 'relationship' ||\n type === 'relationshipLeft' ||\n type === 'relationshipRight'\n ) {\n const classes = classNames('ndl-relationship-label', commonClasses);\n const height = size === 'small' ? 20 : 24;\n\n return (\n <Component\n style={{\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n color: isDisabled ? disabledTextColor : textColor,\n }}\n className={classes}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n })}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {type === 'relationshipLeft' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"left\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd direction=\"left\" color={backgroundColor} height={height} />\n )}\n <div\n className=\"ndl-relationship-label-container\"\n style={{\n backgroundColor: backgroundColor,\n }}\n >\n <div className=\"ndl-relationship-label-content\">{children}</div>\n <HorizontalLines height={height} />\n </div>\n {type === 'relationshipRight' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n )}\n </Component>\n );\n } else {\n const classes = classNames('ndl-property-key-label', commonClasses);\n\n return (\n <Component\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n className={classes}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n ref={ref}\n {...htmlAttributes}\n >\n <div className=\"ndl-property-key-label-content\">{children}</div>\n </Component>\n );\n }\n};\n"]}
1
+ {"version":3,"file":"GraphLabel.js","sourceRoot":"","sources":["../../../src/graph-label/GraphLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAM1C,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AAgDjB;;;;;;GAMG;AAEH,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,GAAG,MAAM,EAClB,KAAK,EACL,cAAc,EACd,MAAM,GAAG,EAAE,GACK,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gC,YAAE,QAAQ,GAAO,IACtD,CACb,CAAC;IACJ,CAAC;AACH,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 { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useMemo, useState } from 'react';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport {\n getDisabledTextColor,\n getHoverColor,\n getTextColorFromBackground,\n} from './color';\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype GraphLabelProps = {\n /** The type of label */\n type:\n | 'node'\n | 'relationship'\n | 'propertyKey'\n | 'relationshipLeft'\n | 'relationshipRight';\n /** Callback function that is called when the label is clicked */\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Additional styles to apply to the label */\n style?: React.CSSProperties;\n /** Content displayed inside the label */\n children?: React.ReactNode;\n /** The background color of the label */\n color?: string;\n /** Whether the label is disabled */\n isDisabled?: boolean;\n /** Additional class names */\n className?: string;\n /** Whether the label is selected */\n isSelected?: boolean;\n /** Whether the label should expand to full available width */\n isFluid?: boolean;\n /** The size of the label */\n size?: 'small' | 'large';\n};\n\ntype HexagonEndProps = {\n /** The direction of the hexagon end */\n direction: 'left' | 'right';\n /** The color of the hexagon end */\n color?: string;\n /** The height of the hexagon end in pixels */\n height?: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n/**\n *\n *\n * Helpers\n *\n *\n */\n\nconst HexagonEnd = ({\n direction = 'left',\n color,\n htmlAttributes,\n height = 24,\n}: HexagonEndProps) => {\n const classes = classNames('ndl-hexagon-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <svg\n aria-hidden={true}\n className=\"ndl-hexagon-end-inner\"\n fill=\"none\"\n height={height}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 9 24\"\n width=\"9\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {/* triangle */}\n <path\n style={{ fill: color }}\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z\"\n />\n </svg>\n <svg\n aria-hidden={true}\n className=\"ndl-hexagon-end-active\"\n fill=\"none\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 13 30\"\n width=\"13\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype SquareEndProps = {\n /** The direction of the square end (where it's rounded and has the active state) */\n direction: 'left' | 'right';\n /** The color of the square end */\n color: string;\n /** The height of the square end in pixels */\n height: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst SquareEnd = ({\n direction = 'left',\n color,\n height = 24,\n htmlAttributes,\n}: SquareEndProps) => {\n const classes = classNames('ndl-square-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <div\n className=\"ndl-square-end-inner\"\n style={{ backgroundColor: color }}\n />\n <svg\n className=\"ndl-square-end-active\"\n width=\"7\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 7 30\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 3.8774 2 C 3.2697 2 2.7917 2.248 2.3967 2.6605 C 1.928 3.1498 1.7993 3.8555 1.7993 4.5331 V 13.8775 V 25.4669 C 1.7993 26.1445 1.928 26.8502 2.3967 27.3395 C 2.7917 27.752 3.2697 28 3.8774 28 H 7 V 30 H 3.8774 C 2.6211 30 1.4369 29.4282 0.5895 28.4485 C 0.1462 27.936 0.0002 27.2467 0.0002 26.5691 L -0.0002 13.8775 L 0.0002 3.4309 C 0.0002 2.7533 0.1462 2.064 0.5895 1.5515 C 1.4368 0.5718 2.6211 0 3.8774 0 H 7 V 2 H 3.8774 Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype HorizontalLinesProps = {\n height?: number;\n};\n\nconst HorizontalLines = ({ height = 24 }: HorizontalLinesProps) => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 37 30\"\n fill=\"none\"\n className=\"ndl-relationship-label-lines\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 2 H 0 V 0 H 37 V 2 Z\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 30 H 0 V 28 H 37 V 30 Z\"\n />\n </svg>\n );\n};\n\n/**\n *\n *\n * GraphLabel Component\n *\n *\n */\n\nconst MAX_WIDTH = 200;\n\nexport const GraphLabel = <T extends React.ElementType = 'button'>({\n type = 'node',\n color,\n isDisabled = false,\n isSelected = false,\n as,\n onClick,\n className,\n style,\n children,\n htmlAttributes,\n isFluid = false,\n size = 'large',\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, GraphLabelProps>) => {\n const [isHover, setIsHover] = useState(false);\n\n const handleMouseEnter = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(true);\n\n if (htmlAttributes && htmlAttributes.onMouseEnter !== undefined) {\n htmlAttributes.onMouseEnter(event);\n }\n };\n\n const handleMouseLeave = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(false);\n\n htmlAttributes?.onMouseLeave?.(event);\n };\n\n const Component: React.ElementType = as ?? 'button';\n const isButton = Component === 'button';\n\n const handleClick = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n // By default, a <button /> element with disabled set to true will not get its\n // on click handler called. To support the same behavior on <a /> tags we\n // swallow the event here when disabled, since the <a /> tag with disabled set to\n // true will have its onClick handler called\n if (isDisabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n let backgroundColor = useMemo(() => {\n if (color === undefined) {\n switch (type) {\n case 'node':\n return tokens.graph['1'];\n case 'relationship':\n case 'relationshipLeft':\n case 'relationshipRight':\n return tokens.theme.light.color.neutral.bg.strong;\n default:\n return tokens.theme.light.color.neutral.bg.strongest;\n }\n }\n return color;\n }, [color, type]);\n\n const hoverColor = useMemo(\n () =>\n getHoverColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const textColor = useMemo(\n () =>\n getTextColorFromBackground(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const disabledTextColor = useMemo(\n () =>\n getDisabledTextColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n\n if (isHover && !isDisabled) {\n backgroundColor = hoverColor;\n }\n\n const commonClasses = classNames('ndl-graph-label', className, {\n 'ndl-disabled': isDisabled,\n 'ndl-interactable': isButton,\n 'ndl-selected': isSelected,\n 'ndl-small': size === 'small',\n });\n\n if (type === 'node') {\n const classes = classNames('ndl-node-label', commonClasses);\n\n return (\n <Component\n className={classes}\n ref={ref}\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n })}\n {...htmlAttributes}\n >\n <div className=\"ndl-node-label-content\">{children}</div>\n </Component>\n );\n } else if (\n type === 'relationship' ||\n type === 'relationshipLeft' ||\n type === 'relationshipRight'\n ) {\n const classes = classNames('ndl-relationship-label', commonClasses);\n const height = size === 'small' ? 20 : 24;\n\n return (\n <Component\n style={{\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n color: isDisabled ? disabledTextColor : textColor,\n }}\n className={classes}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n })}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {type === 'relationshipLeft' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"left\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd direction=\"left\" color={backgroundColor} height={height} />\n )}\n <div\n className=\"ndl-relationship-label-container\"\n style={{\n backgroundColor: backgroundColor,\n }}\n >\n <div className=\"ndl-relationship-label-content\">{children}</div>\n <HorizontalLines height={height} />\n </div>\n {type === 'relationshipRight' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n )}\n </Component>\n );\n } else {\n const classes = classNames('ndl-property-key-label', commonClasses);\n\n return (\n <Component\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n className={classes}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n ref={ref}\n {...htmlAttributes}\n >\n <div className=\"ndl-property-key-label-content\">{children}</div>\n </Component>\n );\n }\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../../../src/ai/response/Response.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAMlE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKxC,KAAK,aAAa,GAAG;IACnB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC;CACtE,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,QAAQ,uHAST,WAAW,CAAC,KAAK,EAAE,aAAa,CAAC,6CAuRrC,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../../../src/ai/response/Response.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAGlE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKxC,KAAK,aAAa,GAAG;IACnB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,WAAW,CAAC,EAAE,K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BAAsB,CAAC,CAAC,EAAE,eAAe,CAAC,4CAoM5C,CAAC"}
1
+ {"version":3,"file":"GraphLabel.d.ts","sourceRoot":"","sources":["../../../src/graph-label/GraphLabel.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAO1B;;;;;;GAMG;AAEH,KAAK,eAAe,GAAG;IACrB,yBAAyB;IACzB,IAAI,EACA,MAAM,GACN,cAAc,GACd,aAAa,GACb,kBAAkB,GAClB,mBAAmB,CAAC;IACxB,iEAAiE;IACjE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;IAC3E,8CAA8C;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4BAA4B;IAC5B,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC1B,CAAC;AA4JF,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,EAAE,oIAehE,sBAAsB,CAAC,CAAC,EAAE,eAAe,CAAC,4CAoM5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-ndl/react",
3
- "version": "4.2.2",
3
+ "version": "4.2.4",
4
4
  "sideEffects": false,
5
5
  "description": "React implementation of Neo4j Design System",
6
6
  "keywords": [