@neo4j-ndl/react 4.14.0 → 4.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -157,7 +157,7 @@ const Response = (0, react_2.memo)((_a) => {
157
157
  },
158
158
  code: (_a) => {
159
159
  var _b, _c, _d, _e;
160
- var { node, className, key, children: codeChildren } = _a, props = __rest(_a, ["node", "className", "key", "children"]);
160
+ var { node, className, children: codeChildren } = _a, props = __rest(_a, ["node", "className", "children"]);
161
161
  const isInline = ((_b = node === null || node === void 0 ? void 0 : node.position) === null || _b === void 0 ? void 0 : _b.start.line) === ((_c = node === null || node === void 0 ? void 0 : node.position) === null || _c === void 0 ? void 0 : _c.end.line);
162
162
  const nodeClassNamesRaw = (_d = node === null || node === void 0 ? void 0 : node.properties) === null || _d === void 0 ? void 0 : _d.className;
163
163
  const nodeClassNamesArray = [];
@@ -187,7 +187,7 @@ const Response = (0, react_2.memo)((_a) => {
187
187
  const hasUnclosedFence = fenceCount % 2 !== 0;
188
188
  // Show loading state when there's an unclosed fence (code block is streaming)
189
189
  const isCodeBlockLoading = hasUnclosedFence;
190
- return ((0, jsx_runtime_1.jsx)(code_preview_1.CodePreview, { code: codeChildren, isLoading: isCodeBlockLoading, language: language, className: className, htmlAttributes: Object.assign({}, props) }, key));
190
+ return ((0, jsx_runtime_1.jsx)(code_preview_1.CodePreview, { code: codeChildren, isLoading: isCodeBlockLoading, language: language, className: className, htmlAttributes: Object.assign({}, props) }, props.key));
191
191
  }
192
192
  else {
193
193
  return (0, jsx_runtime_1.jsx)("code", { className: className, children: codeChildren });
@@ -1 +1 @@
1
- {"version":3,"file":"Response.js","sourceRoot":"","sources":["../../../../src/ai/response/Response.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,4CAA8D;AAC9D,4DAAoC;AACpC,iCAA8C;AAC9C,2CAAwC;AAGxC,oEAA+E;AAC/E,kDAA8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AC1C,GAAG,EAAE,CAAC,EAAuC,EAAE,EAAE;gBAA3C,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAY,EAAP,KAAK,cAArC,mCAAuC,CAAF;YAAO,OAAA,CAChD,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,EAAC,iBAAiB,EAAE,SAAS,CAAC,IAC/C,SAAS,EACT,cAAc,cAElB,uBAAC,uBAAU,IACT,WAAW,EAAE,WAAW,EACxB,uBAAuB,EAAE,WAAW,EACpC,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 classNames from 'classnames';\nimport { memo, useMemo, useRef } from 'react';\nimport { Streamdown } from 'streamdown';\n\nimport { type CommonProps } from '../../_common/types';\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 // oxlint-disable-next-line no-unused-vars\n ol: ({ node, children, className, ...props }) => (\n <ol className={className} {...props}>\n {children}\n </ol>\n ),\n // oxlint-disable-next-line no-unused-vars\n ul: ({ node, children, className, ...props }) => (\n <ul className={classNames(className)} {...props}>\n {children}\n </ul>\n ),\n // oxlint-disable-next-line no-unused-vars\n li: ({ node, children, className, ...props }) => (\n <li className={className} {...props}>\n {children}\n </li>\n ),\n // oxlint-disable-next-line no-unused-vars\n hr: ({ node, className, ...props }) => (\n <hr className={classNames(className)} {...props} />\n ),\n // oxlint-disable-next-line no-unused-vars\n strong: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n em: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n a: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h1: ({ node, children, className, ...props }) => (\n <Typography\n as=\"h1\"\n variant=\"display\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n // oxlint-disable-next-line no-unused-vars\n h2: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h3: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h4: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h5: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h6: ({ node, children, className, ...props }) => (\n <Typography\n as=\"h6\"\n variant=\"label\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n // oxlint-disable-next-line no-unused-vars\n table: ({ node, children, className, ...props }) => (\n <div className=\"ndl-ai-response-table-wrapper\">\n <table className={className} {...props}>\n {children}\n </table>\n </div>\n ),\n // oxlint-disable-next-line no-unused-vars\n thead: ({ node, children, className, ...props }) => (\n <thead className={className} {...props}>\n {children}\n </thead>\n ),\n // oxlint-disable-next-line no-unused-vars\n tbody: ({ node, children, className, ...props }) => (\n <tbody className={className} {...props}>\n {children}\n </tbody>\n ),\n // oxlint-disable-next-line no-unused-vars\n tr: ({ node, children, className, ...props }) => (\n <tr className={className} {...props}>\n {children}\n </tr>\n ),\n // oxlint-disable-next-line no-unused-vars\n th: ({ node, children, className, ...props }) => (\n <th className={className} {...props}>\n {children}\n </th>\n ),\n // oxlint-disable-next-line no-unused-vars\n td: ({ node, children, className, ...props }) => (\n <td className={className} {...props}>\n {children}\n </td>\n ),\n // oxlint-disable-next-line no-unused-vars\n blockquote: ({ node, 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\n const nodeClassNamesRaw = node?.properties?.className;\n const nodeClassNamesArray: string[] = [];\n\n if (typeof nodeClassNamesRaw === 'string') {\n nodeClassNamesArray.push.apply(\n nodeClassNamesArray,\n nodeClassNamesRaw.split(' '),\n );\n } else if (Array.isArray(nodeClassNamesRaw)) {\n nodeClassNamesArray.push.apply(\n nodeClassNamesArray,\n nodeClassNamesRaw as string[],\n );\n }\n\n let language: LanguageProp | 'text' = 'text';\n const rawLanguage = nodeClassNamesArray.find((string: string) =>\n string.startsWith('language-'),\n );\n if (rawLanguage !== undefined) {\n language =\n (rawLanguage.replace('language-', '') as LanguageProp) ??\n 'text';\n }\n language = (Languages as readonly string[]).includes(language)\n ? (language as LanguageProp)\n : 'text';\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 // oxlint-disable-next-line no-unused-vars\n pre: ({ node, className, children, ...props }) => {\n return (\n <pre className={className} {...props}>\n {children}\n </pre>\n );\n },\n // oxlint-disable-next-line no-unused-vars\n p: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n img: ({ node, 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('ndl-ai-response', className)}\n {...restProps}\n {...htmlAttributes}\n >\n <Streamdown\n isAnimating={isAnimating}\n parseIncompleteMarkdown={isAnimating}\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;AAC9D,4DAAoC;AACpC,iCAA8C;AAC9C,2CAAwC;AAGxC,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,CA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SAAS,EAAE,IAAA,oBAAU,EAAC,iBAAiB,EAAE,SAAS,CAAC,IAC/C,SAAS,EACT,cAAc,cAElB,uBAAC,uBAAU,IACT,WAAW,EAAE,WAAW,EACxB,uBAAuB,EAAE,WAAW,EACpC,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 classNames from 'classnames';\nimport { memo, useMemo, useRef } from 'react';\nimport { Streamdown } from 'streamdown';\n\nimport { type CommonProps } from '../../_common/types';\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 // oxlint-disable-next-line no-unused-vars\n ol: ({ node, children, className, ...props }) => (\n <ol className={className} {...props}>\n {children}\n </ol>\n ),\n // oxlint-disable-next-line no-unused-vars\n ul: ({ node, children, className, ...props }) => (\n <ul className={classNames(className)} {...props}>\n {children}\n </ul>\n ),\n // oxlint-disable-next-line no-unused-vars\n li: ({ node, children, className, ...props }) => (\n <li className={className} {...props}>\n {children}\n </li>\n ),\n // oxlint-disable-next-line no-unused-vars\n hr: ({ node, className, ...props }) => (\n <hr className={classNames(className)} {...props} />\n ),\n // oxlint-disable-next-line no-unused-vars\n strong: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n em: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n a: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h1: ({ node, children, className, ...props }) => (\n <Typography\n as=\"h1\"\n variant=\"display\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n // oxlint-disable-next-line no-unused-vars\n h2: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h3: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h4: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h5: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h6: ({ node, children, className, ...props }) => (\n <Typography\n as=\"h6\"\n variant=\"label\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n // oxlint-disable-next-line no-unused-vars\n table: ({ node, children, className, ...props }) => (\n <div className=\"ndl-ai-response-table-wrapper\">\n <table className={className} {...props}>\n {children}\n </table>\n </div>\n ),\n // oxlint-disable-next-line no-unused-vars\n thead: ({ node, children, className, ...props }) => (\n <thead className={className} {...props}>\n {children}\n </thead>\n ),\n // oxlint-disable-next-line no-unused-vars\n tbody: ({ node, children, className, ...props }) => (\n <tbody className={className} {...props}>\n {children}\n </tbody>\n ),\n // oxlint-disable-next-line no-unused-vars\n tr: ({ node, children, className, ...props }) => (\n <tr className={className} {...props}>\n {children}\n </tr>\n ),\n // oxlint-disable-next-line no-unused-vars\n th: ({ node, children, className, ...props }) => (\n <th className={className} {...props}>\n {children}\n </th>\n ),\n // oxlint-disable-next-line no-unused-vars\n td: ({ node, children, className, ...props }) => (\n <td className={className} {...props}>\n {children}\n </td>\n ),\n // oxlint-disable-next-line no-unused-vars\n blockquote: ({ node, children, className, ...props }) => (\n <blockquote className={classNames(className)} {...props}>\n {children}\n </blockquote>\n ),\n code: ({ node, className, children: codeChildren, ...props }) => {\n const isInline =\n node?.position?.start.line === node?.position?.end.line;\n\n const nodeClassNamesRaw = node?.properties?.className;\n const nodeClassNamesArray: string[] = [];\n\n if (typeof nodeClassNamesRaw === 'string') {\n nodeClassNamesArray.push.apply(\n nodeClassNamesArray,\n nodeClassNamesRaw.split(' '),\n );\n } else if (Array.isArray(nodeClassNamesRaw)) {\n nodeClassNamesArray.push.apply(\n nodeClassNamesArray,\n nodeClassNamesRaw as string[],\n );\n }\n\n let language: LanguageProp | 'text' = 'text';\n const rawLanguage = nodeClassNamesArray.find((string: string) =>\n string.startsWith('language-'),\n );\n if (rawLanguage !== undefined) {\n language =\n (rawLanguage.replace('language-', '') as LanguageProp) ??\n 'text';\n }\n language = (Languages as readonly string[]).includes(language)\n ? (language as LanguageProp)\n : 'text';\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={props.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 // oxlint-disable-next-line no-unused-vars\n pre: ({ node, className, children, ...props }) => {\n return (\n <pre className={className} {...props}>\n {children}\n </pre>\n );\n },\n // oxlint-disable-next-line no-unused-vars\n p: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n img: ({ node, 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('ndl-ai-response', className)}\n {...restProps}\n {...htmlAttributes}\n >\n <Streamdown\n isAnimating={isAnimating}\n parseIncompleteMarkdown={isAnimating}\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"]}
@@ -151,7 +151,7 @@ const Response = memo((_a) => {
151
151
  },
152
152
  code: (_a) => {
153
153
  var _b, _c, _d, _e;
154
- var { node, className, key, children: codeChildren } = _a, props = __rest(_a, ["node", "className", "key", "children"]);
154
+ var { node, className, children: codeChildren } = _a, props = __rest(_a, ["node", "className", "children"]);
155
155
  const isInline = ((_b = node === null || node === void 0 ? void 0 : node.position) === null || _b === void 0 ? void 0 : _b.start.line) === ((_c = node === null || node === void 0 ? void 0 : node.position) === null || _c === void 0 ? void 0 : _c.end.line);
156
156
  const nodeClassNamesRaw = (_d = node === null || node === void 0 ? void 0 : node.properties) === null || _d === void 0 ? void 0 : _d.className;
157
157
  const nodeClassNamesArray = [];
@@ -181,7 +181,7 @@ const Response = memo((_a) => {
181
181
  const hasUnclosedFence = fenceCount % 2 !== 0;
182
182
  // Show loading state when there's an unclosed fence (code block is streaming)
183
183
  const isCodeBlockLoading = hasUnclosedFence;
184
- return (_jsx(CodePreview, { code: codeChildren, isLoading: isCodeBlockLoading, language: language, className: className, htmlAttributes: Object.assign({}, props) }, key));
184
+ return (_jsx(CodePreview, { code: codeChildren, isLoading: isCodeBlockLoading, language: language, className: className, htmlAttributes: Object.assign({}, props) }, props.key));
185
185
  }
186
186
  else {
187
187
  return _jsx("code", { className: className, children: codeChildren });
@@ -1 +1 @@
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;AAC9D,OAA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A,CAC9C,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,0CAA0C;QAC1C,GAAG,EAAE,CAAC,EAAuC,EAAE,EAAE;gBAA3C,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAY,EAAP,KAAK,cAArC,mCAAuC,CAAF;YAAO,OAAA,CAChD,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,CAAC,iBAAiB,EAAE,SAAS,CAAC,IAC/C,SAAS,EACT,cAAc,cAElB,KAAC,UAAU,IACT,WAAW,EAAE,WAAW,EACxB,uBAAuB,EAAE,WAAW,EACpC,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 classNames from 'classnames';\nimport { memo, useMemo, useRef } from 'react';\nimport { Streamdown } from 'streamdown';\n\nimport { type CommonProps } from '../../_common/types';\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 // oxlint-disable-next-line no-unused-vars\n ol: ({ node, children, className, ...props }) => (\n <ol className={className} {...props}>\n {children}\n </ol>\n ),\n // oxlint-disable-next-line no-unused-vars\n ul: ({ node, children, className, ...props }) => (\n <ul className={classNames(className)} {...props}>\n {children}\n </ul>\n ),\n // oxlint-disable-next-line no-unused-vars\n li: ({ node, children, className, ...props }) => (\n <li className={className} {...props}>\n {children}\n </li>\n ),\n // oxlint-disable-next-line no-unused-vars\n hr: ({ node, className, ...props }) => (\n <hr className={classNames(className)} {...props} />\n ),\n // oxlint-disable-next-line no-unused-vars\n strong: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n em: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n a: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h1: ({ node, children, className, ...props }) => (\n <Typography\n as=\"h1\"\n variant=\"display\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n // oxlint-disable-next-line no-unused-vars\n h2: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h3: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h4: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h5: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h6: ({ node, children, className, ...props }) => (\n <Typography\n as=\"h6\"\n variant=\"label\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n // oxlint-disable-next-line no-unused-vars\n table: ({ node, children, className, ...props }) => (\n <div className=\"ndl-ai-response-table-wrapper\">\n <table className={className} {...props}>\n {children}\n </table>\n </div>\n ),\n // oxlint-disable-next-line no-unused-vars\n thead: ({ node, children, className, ...props }) => (\n <thead className={className} {...props}>\n {children}\n </thead>\n ),\n // oxlint-disable-next-line no-unused-vars\n tbody: ({ node, children, className, ...props }) => (\n <tbody className={className} {...props}>\n {children}\n </tbody>\n ),\n // oxlint-disable-next-line no-unused-vars\n tr: ({ node, children, className, ...props }) => (\n <tr className={className} {...props}>\n {children}\n </tr>\n ),\n // oxlint-disable-next-line no-unused-vars\n th: ({ node, children, className, ...props }) => (\n <th className={className} {...props}>\n {children}\n </th>\n ),\n // oxlint-disable-next-line no-unused-vars\n td: ({ node, children, className, ...props }) => (\n <td className={className} {...props}>\n {children}\n </td>\n ),\n // oxlint-disable-next-line no-unused-vars\n blockquote: ({ node, 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\n const nodeClassNamesRaw = node?.properties?.className;\n const nodeClassNamesArray: string[] = [];\n\n if (typeof nodeClassNamesRaw === 'string') {\n nodeClassNamesArray.push.apply(\n nodeClassNamesArray,\n nodeClassNamesRaw.split(' '),\n );\n } else if (Array.isArray(nodeClassNamesRaw)) {\n nodeClassNamesArray.push.apply(\n nodeClassNamesArray,\n nodeClassNamesRaw as string[],\n );\n }\n\n let language: LanguageProp | 'text' = 'text';\n const rawLanguage = nodeClassNamesArray.find((string: string) =>\n string.startsWith('language-'),\n );\n if (rawLanguage !== undefined) {\n language =\n (rawLanguage.replace('language-', '') as LanguageProp) ??\n 'text';\n }\n language = (Languages as readonly string[]).includes(language)\n ? (language as LanguageProp)\n : 'text';\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 // oxlint-disable-next-line no-unused-vars\n pre: ({ node, className, children, ...props }) => {\n return (\n <pre className={className} {...props}>\n {children}\n </pre>\n );\n },\n // oxlint-disable-next-line no-unused-vars\n p: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n img: ({ node, 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('ndl-ai-response', className)}\n {...restProps}\n {...htmlAttributes}\n >\n <Streamdown\n isAnimating={isAnimating}\n parseIncompleteMarkdown={isAnimating}\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;AAC9D,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;AAGxC,OAAO,EAAqB,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAA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,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAY,EAAP,KAAK,cAArC,mCAAuC,CAAF;YAAO,OAAA,CAChD,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,CAAC,iBAAiB,EAAE,SAAS,CAAC,IAC/C,SAAS,EACT,cAAc,cAElB,KAAC,UAAU,IACT,WAAW,EAAE,WAAW,EACxB,uBAAuB,EAAE,WAAW,EACpC,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 classNames from 'classnames';\nimport { memo, useMemo, useRef } from 'react';\nimport { Streamdown } from 'streamdown';\n\nimport { type CommonProps } from '../../_common/types';\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 // oxlint-disable-next-line no-unused-vars\n ol: ({ node, children, className, ...props }) => (\n <ol className={className} {...props}>\n {children}\n </ol>\n ),\n // oxlint-disable-next-line no-unused-vars\n ul: ({ node, children, className, ...props }) => (\n <ul className={classNames(className)} {...props}>\n {children}\n </ul>\n ),\n // oxlint-disable-next-line no-unused-vars\n li: ({ node, children, className, ...props }) => (\n <li className={className} {...props}>\n {children}\n </li>\n ),\n // oxlint-disable-next-line no-unused-vars\n hr: ({ node, className, ...props }) => (\n <hr className={classNames(className)} {...props} />\n ),\n // oxlint-disable-next-line no-unused-vars\n strong: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n em: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n a: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h1: ({ node, children, className, ...props }) => (\n <Typography\n as=\"h1\"\n variant=\"display\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n // oxlint-disable-next-line no-unused-vars\n h2: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h3: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h4: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h5: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n h6: ({ node, children, className, ...props }) => (\n <Typography\n as=\"h6\"\n variant=\"label\"\n className={className}\n htmlAttributes={{ ...props }}\n >\n {children}\n </Typography>\n ),\n // oxlint-disable-next-line no-unused-vars\n table: ({ node, children, className, ...props }) => (\n <div className=\"ndl-ai-response-table-wrapper\">\n <table className={className} {...props}>\n {children}\n </table>\n </div>\n ),\n // oxlint-disable-next-line no-unused-vars\n thead: ({ node, children, className, ...props }) => (\n <thead className={className} {...props}>\n {children}\n </thead>\n ),\n // oxlint-disable-next-line no-unused-vars\n tbody: ({ node, children, className, ...props }) => (\n <tbody className={className} {...props}>\n {children}\n </tbody>\n ),\n // oxlint-disable-next-line no-unused-vars\n tr: ({ node, children, className, ...props }) => (\n <tr className={className} {...props}>\n {children}\n </tr>\n ),\n // oxlint-disable-next-line no-unused-vars\n th: ({ node, children, className, ...props }) => (\n <th className={className} {...props}>\n {children}\n </th>\n ),\n // oxlint-disable-next-line no-unused-vars\n td: ({ node, children, className, ...props }) => (\n <td className={className} {...props}>\n {children}\n </td>\n ),\n // oxlint-disable-next-line no-unused-vars\n blockquote: ({ node, children, className, ...props }) => (\n <blockquote className={classNames(className)} {...props}>\n {children}\n </blockquote>\n ),\n code: ({ node, className, children: codeChildren, ...props }) => {\n const isInline =\n node?.position?.start.line === node?.position?.end.line;\n\n const nodeClassNamesRaw = node?.properties?.className;\n const nodeClassNamesArray: string[] = [];\n\n if (typeof nodeClassNamesRaw === 'string') {\n nodeClassNamesArray.push.apply(\n nodeClassNamesArray,\n nodeClassNamesRaw.split(' '),\n );\n } else if (Array.isArray(nodeClassNamesRaw)) {\n nodeClassNamesArray.push.apply(\n nodeClassNamesArray,\n nodeClassNamesRaw as string[],\n );\n }\n\n let language: LanguageProp | 'text' = 'text';\n const rawLanguage = nodeClassNamesArray.find((string: string) =>\n string.startsWith('language-'),\n );\n if (rawLanguage !== undefined) {\n language =\n (rawLanguage.replace('language-', '') as LanguageProp) ??\n 'text';\n }\n language = (Languages as readonly string[]).includes(language)\n ? (language as LanguageProp)\n : 'text';\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={props.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 // oxlint-disable-next-line no-unused-vars\n pre: ({ node, className, children, ...props }) => {\n return (\n <pre className={className} {...props}>\n {children}\n </pre>\n );\n },\n // oxlint-disable-next-line no-unused-vars\n p: ({ node, 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 // oxlint-disable-next-line no-unused-vars\n img: ({ node, 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('ndl-ai-response', className)}\n {...restProps}\n {...htmlAttributes}\n >\n <Streamdown\n isAnimating={isAnimating}\n parseIncompleteMarkdown={isAnimating}\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 +1 @@
1
- {"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../../../src/ai/response/Response.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,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,6CA4SrC,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;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,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,6CAsSrC,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-ndl/react",
3
- "version": "4.14.0",
3
+ "version": "4.14.1",
4
4
  "sideEffects": false,
5
5
  "description": "React implementation of Neo4j Design System",
6
6
  "keywords": [