@neo4j-ndl/react 4.18.10 → 4.18.12

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.
Files changed (50) hide show
  1. package/lib/cjs/_common/TruncatedTextWithTooltip.js +67 -0
  2. package/lib/cjs/_common/TruncatedTextWithTooltip.js.map +1 -0
  3. package/lib/cjs/ai/preview/Preview.js +4 -3
  4. package/lib/cjs/ai/preview/Preview.js.map +1 -1
  5. package/lib/cjs/ai/preview/stories/index.js +9 -9
  6. package/lib/cjs/ai/preview/stories/index.js.map +1 -1
  7. package/lib/cjs/ai/preview/stories/preview-code-confirmation.story.js +1 -1
  8. package/lib/cjs/ai/preview/stories/preview-code-confirmation.story.js.map +1 -1
  9. package/lib/cjs/ai/preview/stories/{preview-code-read.story.js → preview-code-cypher.story.js} +2 -2
  10. package/lib/cjs/ai/preview/stories/preview-code-cypher.story.js.map +1 -0
  11. package/lib/cjs/ai/preview/stories/preview-code-languages.story.js +1 -1
  12. package/lib/cjs/ai/preview/stories/preview-code-languages.story.js.map +1 -1
  13. package/lib/cjs/ai/preview/stories/{preview-code-write.story.js → preview-code-truncation.story.js} +5 -5
  14. package/lib/cjs/ai/preview/stories/preview-code-truncation.story.js.map +1 -0
  15. package/lib/esm/_common/TruncatedTextWithTooltip.js +60 -0
  16. package/lib/esm/_common/TruncatedTextWithTooltip.js.map +1 -0
  17. package/lib/esm/ai/preview/Preview.js +4 -3
  18. package/lib/esm/ai/preview/Preview.js.map +1 -1
  19. package/lib/esm/ai/preview/stories/index.js +6 -6
  20. package/lib/esm/ai/preview/stories/index.js.map +1 -1
  21. package/lib/esm/ai/preview/stories/preview-code-confirmation.story.js +1 -1
  22. package/lib/esm/ai/preview/stories/preview-code-confirmation.story.js.map +1 -1
  23. package/lib/esm/ai/preview/stories/{preview-code-read.story.js → preview-code-cypher.story.js} +2 -2
  24. package/lib/esm/ai/preview/stories/preview-code-cypher.story.js.map +1 -0
  25. package/lib/esm/ai/preview/stories/preview-code-languages.story.js +1 -1
  26. package/lib/esm/ai/preview/stories/preview-code-languages.story.js.map +1 -1
  27. package/lib/esm/ai/preview/stories/{preview-code-write.story.js → preview-code-truncation.story.js} +8 -8
  28. package/lib/esm/ai/preview/stories/preview-code-truncation.story.js.map +1 -0
  29. package/lib/types/_common/TruncatedTextWithTooltip.d.ts +46 -0
  30. package/lib/types/_common/TruncatedTextWithTooltip.d.ts.map +1 -0
  31. package/lib/types/ai/preview/Preview.d.ts +8 -2
  32. package/lib/types/ai/preview/Preview.d.ts.map +1 -1
  33. package/lib/types/ai/preview/stories/index.d.ts +4 -4
  34. package/lib/types/ai/preview/stories/index.d.ts.map +1 -1
  35. package/lib/types/ai/preview/stories/{preview-code-write.story.d.ts → preview-code-cypher.story.d.ts} +1 -1
  36. package/lib/types/ai/preview/stories/preview-code-cypher.story.d.ts.map +1 -0
  37. package/lib/types/ai/preview/stories/preview-code-languages.story.d.ts.map +1 -1
  38. package/lib/types/ai/preview/stories/{preview-code-read.story.d.ts → preview-code-truncation.story.d.ts} +1 -1
  39. package/lib/types/ai/preview/stories/preview-code-truncation.story.d.ts.map +1 -0
  40. package/package.json +2 -2
  41. package/skills/ndl-react/SKILL.md +1 -1
  42. package/skills/ndl-react/components/ai/preview.md +86 -66
  43. package/skills/ndl-react/components/ai/user-bubble.md +1 -12
  44. package/skills/ndl-react/components/breadcrumbs.md +2 -2
  45. package/lib/cjs/ai/preview/stories/preview-code-read.story.js.map +0 -1
  46. package/lib/cjs/ai/preview/stories/preview-code-write.story.js.map +0 -1
  47. package/lib/esm/ai/preview/stories/preview-code-read.story.js.map +0 -1
  48. package/lib/esm/ai/preview/stories/preview-code-write.story.js.map +0 -1
  49. package/lib/types/ai/preview/stories/preview-code-read.story.d.ts.map +0 -1
  50. package/lib/types/ai/preview/stories/preview-code-write.story.d.ts.map +0 -1
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TruncatedTextWithTooltip = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ /**
9
+ *
10
+ * Copyright (c) "Neo4j"
11
+ * Neo4j Sweden AB [http://neo4j.com]
12
+ *
13
+ * This file is part of Neo4j.
14
+ *
15
+ * Neo4j is free software: you can redistribute it and/or modify
16
+ * it under the terms of the GNU General Public License as published by
17
+ * the Free Software Foundation, either version 3 of the License, or
18
+ * (at your option) any later version.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
27
+ */
28
+ const classnames_1 = __importDefault(require("classnames"));
29
+ const react_1 = require("react");
30
+ const tooltip_1 = require("../tooltip");
31
+ const useIsTruncated = (text) => {
32
+ const ref = (0, react_1.useRef)(null);
33
+ const [isTruncated, setIsTruncated] = (0, react_1.useState)(false);
34
+ (0, react_1.useEffect)(() => {
35
+ const element = ref.current;
36
+ if (element === null) {
37
+ return;
38
+ }
39
+ // Reads inside the ResizeObserver callback are layout-synced and cheap;
40
+ // setState with an unchanged boolean does not trigger a re-render.
41
+ const check = () => setIsTruncated(element.scrollWidth > element.clientWidth);
42
+ check();
43
+ const observer = new ResizeObserver(check);
44
+ observer.observe(element);
45
+ return () => observer.disconnect();
46
+ }, [text]);
47
+ return [ref, isTruncated];
48
+ };
49
+ /**
50
+ * Internal component that renders single-line truncating text and, only while
51
+ * the text is actually clipped, shows a tooltip with the full text.
52
+ *
53
+ * Accessibility: the text element receives `tabIndex={0}` only while truncated,
54
+ * so sighted keyboard users can reveal the full text on focus without adding a
55
+ * dead tab stop otherwise. No button semantics are used since there is no
56
+ * action to perform. Screen readers always receive the full text from the
57
+ * element's own content, as CSS truncation is visual-only. The tooltip is
58
+ * dismissible with Escape and hoverable (WCAG 1.4.13).
59
+ *
60
+ * @internal - Not part of the public API.
61
+ */
62
+ const TruncatedTextWithTooltip = ({ text, className, tooltipPlacement = 'top-start', }) => {
63
+ const [textRef, isTruncated] = useIsTruncated(text);
64
+ return ((0, jsx_runtime_1.jsxs)(tooltip_1.Tooltip, { type: "simple", placement: tooltipPlacement, isDisabled: !isTruncated, children: [(0, jsx_runtime_1.jsx)(tooltip_1.Tooltip.Trigger, { hasButtonWrapper: true, children: (0, jsx_runtime_1.jsx)("span", Object.assign({ ref: textRef, className: (0, classnames_1.default)('ndl-truncated-text', className) }, (isTruncated && { tabIndex: 0 }), { children: text })) }), (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip.Content, { children: text })] }));
65
+ };
66
+ exports.TruncatedTextWithTooltip = TruncatedTextWithTooltip;
67
+ //# sourceMappingURL=TruncatedTextWithTooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TruncatedTextWithTooltip.js","sourceRoot":"","sources":["../../../src/_common/TruncatedTextWithTooltip.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AACpC,iCAAoE;AAEpE,wCAAqC;AAErC,MAAM,cAAc,GAAG,CACrB,IAAY,EACkC,EAAE;IAChD,MAAM,GAAG,GAAG,IAAA,cAAM,EAAkB,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEtD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC5B,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,wEAAwE;QACxE,mEAAmE;QACnE,MAAM,KAAK,GAAG,GAAG,EAAE,CACjB,cAAc,CAAC,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QAE5D,KAAK,EAAE,CAAC;QACR,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;QAC3C,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;AAC5B,CAAC,CAAC;AAWF;;;;;;;;;;;;GAYG;AACI,MAAM,wBAAwB,GAAG,CAAC,EACvC,IAAI,EACJ,SAAS,EACT,gBAAgB,GAAG,WAAW,GACA,EAAE,EAAE;IAClC,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAEpD,OAAO,CACL,wBAAC,iBAAO,IACN,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,gBAAgB,EAC3B,UAAU,EAAE,CAAC,WAAW,aAExB,uBAAC,iBAAO,CAAC,OAAO,IAAC,gBAAgB,kBAC/B,+CACE,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,IAAA,oBAAU,EAAC,oBAAoB,EAAE,SAAS,CAAC,IAClD,CAAC,WAAW,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,cAEnC,IAAI,IACA,GACS,EAClB,uBAAC,iBAAO,CAAC,OAAO,cAAE,IAAI,GAAmB,IACjC,CACX,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,wBAAwB,4BAyBnC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport { type RefObject, useEffect, useRef, useState } from 'react';\n\nimport { Tooltip } from '../tooltip';\n\nconst useIsTruncated = (\n text: string,\n): [RefObject<HTMLSpanElement | null>, boolean] => {\n const ref = useRef<HTMLSpanElement>(null);\n const [isTruncated, setIsTruncated] = useState(false);\n\n useEffect(() => {\n const element = ref.current;\n if (element === null) {\n return;\n }\n\n // Reads inside the ResizeObserver callback are layout-synced and cheap;\n // setState with an unchanged boolean does not trigger a re-render.\n const check = () =>\n setIsTruncated(element.scrollWidth > element.clientWidth);\n\n check();\n const observer = new ResizeObserver(check);\n observer.observe(element);\n return () => observer.disconnect();\n }, [text]);\n\n return [ref, isTruncated];\n};\n\ntype TruncatedTextWithTooltipProps = {\n /** The text to display. Truncated with an ellipsis when space is limited. */\n text: string;\n /** Class name applied to the text element. Typography is inherited from the parent. */\n className?: string;\n /** Placement of the tooltip showing the full text. */\n tooltipPlacement?: React.ComponentProps<typeof Tooltip>['placement'];\n};\n\n/**\n * Internal component that renders single-line truncating text and, only while\n * the text is actually clipped, shows a tooltip with the full text.\n *\n * Accessibility: the text element receives `tabIndex={0}` only while truncated,\n * so sighted keyboard users can reveal the full text on focus without adding a\n * dead tab stop otherwise. No button semantics are used since there is no\n * action to perform. Screen readers always receive the full text from the\n * element's own content, as CSS truncation is visual-only. The tooltip is\n * dismissible with Escape and hoverable (WCAG 1.4.13).\n *\n * @internal - Not part of the public API.\n */\nexport const TruncatedTextWithTooltip = ({\n text,\n className,\n tooltipPlacement = 'top-start',\n}: TruncatedTextWithTooltipProps) => {\n const [textRef, isTruncated] = useIsTruncated(text);\n\n return (\n <Tooltip\n type=\"simple\"\n placement={tooltipPlacement}\n isDisabled={!isTruncated}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <span\n ref={textRef}\n className={classNames('ndl-truncated-text', className)}\n {...(isTruncated && { tabIndex: 0 })}\n >\n {text}\n </span>\n </Tooltip.Trigger>\n <Tooltip.Content>{text}</Tooltip.Content>\n </Tooltip>\n );\n};\n"]}
@@ -40,6 +40,7 @@ const react_1 = require("@neo4j-ndl/react");
40
40
  const classnames_1 = __importDefault(require("classnames"));
41
41
  const react_2 = require("react");
42
42
  const react_syntax_highlighter_1 = require("react-syntax-highlighter");
43
+ const TruncatedTextWithTooltip_1 = require("../../_common/TruncatedTextWithTooltip");
43
44
  const code_languages_1 = require("../../code-block/code-languages");
44
45
  const ndl_code_dark_1 = __importDefault(require("../../code-block/themes/ndl-code-dark"));
45
46
  const ndl_code_light_1 = __importDefault(require("../../code-block/themes/ndl-code-light"));
@@ -56,7 +57,7 @@ const PreviewComponent = (_a) => {
56
57
  };
57
58
  const PreviewHeader = (_a) => {
58
59
  var { children, actions, ref, style, className, htmlAttributes } = _a, restProps = __rest(_a, ["children", "actions", "ref", "style", "className", "htmlAttributes"]);
59
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: ref, style: style, className: (0, classnames_1.default)('ndl-ai-preview-header', className) }, restProps, htmlAttributes, { children: [(0, jsx_runtime_1.jsx)(react_1.Typography, { variant: "code", as: "div", className: "ndl-ai-preview-header-leading-content", children: children }), actions && ((0, jsx_runtime_1.jsx)("div", { className: "ndl-ai-preview-header-actions", children: actions }))] })));
60
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: ref, style: style, className: (0, classnames_1.default)('ndl-ai-preview-header', className) }, restProps, htmlAttributes, { children: [(0, jsx_runtime_1.jsx)(react_1.Typography, { variant: "code", as: "div", className: "ndl-ai-preview-header-leading-content", children: typeof children === 'string' ? ((0, jsx_runtime_1.jsx)(TruncatedTextWithTooltip_1.TruncatedTextWithTooltip, { text: children })) : (children) }), actions && ((0, jsx_runtime_1.jsx)("div", { className: "ndl-ai-preview-header-actions", children: actions }))] })));
60
61
  };
61
62
  const PreviewConfirmation = (_a) => {
62
63
  var { children, actions, isFooter = false, status = 'pending', confirmedActionText = 'Action confirmed', rejectedActionText = 'Action rejected', ref, style, className, htmlAttributes } = _a, restProps = __rest(_a, ["children", "actions", "isFooter", "status", "confirmedActionText", "rejectedActionText", "ref", "style", "className", "htmlAttributes"]);
@@ -66,7 +67,7 @@ const PreviewConfirmation = (_a) => {
66
67
  return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: ref, className: classes, style: style }, restProps, htmlAttributes, { children: [!(isFooter && status !== 'pending') && ((0, jsx_runtime_1.jsx)(react_1.Typography, { as: "div", variant: isFooter ? 'subheading-small' : 'body-medium', className: "ndl-ai-preview-confirmation-content", children: children })), (0, jsx_runtime_1.jsxs)(react_1.Typography, { variant: "body-medium", as: "div", className: "ndl-ai-preview-confirmation-actions", children: [status === 'pending' && actions, status === 'confirmed' && ((0, jsx_runtime_1.jsxs)("div", { className: "ndl-ai-preview-confirmation-confirm-reject", children: [(0, jsx_runtime_1.jsx)(CheckIconOutline_1.CheckIconOutline, { className: "ndl-ai-preview-confirmation-action-icon" }), confirmedActionText] })), status === 'rejected' && ((0, jsx_runtime_1.jsxs)("div", { className: "ndl-ai-preview-confirmation-confirm-reject", children: [(0, jsx_runtime_1.jsx)(XMarkIconOutline_1.XMarkIconOutline, { className: "ndl-ai-preview-confirmation-action-icon" }), rejectedActionText] }))] })] })));
67
68
  };
68
69
  const PreviewCode = (_a) => {
69
- var { code, language, label, isLoading = false, headerActions, theme, ref, style, className, htmlAttributes } = _a, restProps = __rest(_a, ["code", "language", "label", "isLoading", "headerActions", "theme", "ref", "style", "className", "htmlAttributes"]);
70
+ var { code, language, label, isLoading = false, headerActions, theme, heading, ref, style, className, htmlAttributes } = _a, restProps = __rest(_a, ["code", "language", "label", "isLoading", "headerActions", "theme", "heading", "ref", "style", "className", "htmlAttributes"]);
70
71
  const [loadedLanguage, setLoadedLanguage] = (0, react_2.useState)(null);
71
72
  const { theme: ndlTheme } = (0, react_1.useNeedleTheme)();
72
73
  (0, react_2.useEffect)(() => {
@@ -91,7 +92,7 @@ const PreviewCode = (_a) => {
91
92
  return ndlTheme === 'light' ? ndl_code_light_1.default : ndl_code_dark_1.default;
92
93
  }
93
94
  };
94
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: ref, style: style, className: (0, classnames_1.default)('ndl-ai-preview-code', className) }, restProps, htmlAttributes, { children: [isLoading && ((0, jsx_runtime_1.jsxs)("div", { className: "ndl-ai-preview-code-loading", children: [(0, jsx_runtime_1.jsx)(react_1.LoadingSpinner, { size: "medium" }), (0, jsx_runtime_1.jsxs)(react_1.Typography, { variant: "code", children: ["WRITING ", language.toUpperCase()] })] })), !isLoading && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(PreviewHeader, { className: "ndl-ai-preview-code-header", actions: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.ClipboardButton, { textToCopy: code, type: "clean-icon-button", size: "small" }), headerActions] }), children: [language, " ", language.toLowerCase() === 'cypher' ? 'QUERY' : '', label && ((0, jsx_runtime_1.jsx)(react_1.StatusLabel, { variant: label === 'write' ? 'warning' : 'info', size: "small", fill: "semi-filled", children: label.toUpperCase() }))] }), (0, jsx_runtime_1.jsx)("div", { className: "ndl-ai-preview-code-content", children: (0, jsx_runtime_1.jsx)(react_syntax_highlighter_1.PrismLight, { language: loadedLanguage !== null && loadedLanguage !== void 0 ? loadedLanguage : 'text', style: Object.assign(Object.assign({}, getTheme()), { 'pre[class*="language-"]': {
95
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: ref, style: style, className: (0, classnames_1.default)('ndl-ai-preview-code', className) }, restProps, htmlAttributes, { children: [isLoading && ((0, jsx_runtime_1.jsxs)("div", { className: "ndl-ai-preview-code-loading", children: [(0, jsx_runtime_1.jsx)(react_1.LoadingSpinner, { size: "medium" }), (0, jsx_runtime_1.jsxs)(react_1.Typography, { variant: "code", children: ["WRITING ", language.toUpperCase()] })] })), !isLoading && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(PreviewHeader, { className: "ndl-ai-preview-code-header", actions: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.ClipboardButton, { textToCopy: code, type: "clean-icon-button", size: "small" }), headerActions] }), children: [(0, jsx_runtime_1.jsx)(TruncatedTextWithTooltip_1.TruncatedTextWithTooltip, { className: "ndl-ai-preview-code-header-heading", text: heading !== null && heading !== void 0 ? heading : `${language}${language.toLowerCase() === 'cypher' ? ' QUERY' : ''}` }), label && ((0, jsx_runtime_1.jsx)(react_1.StatusLabel, { variant: label === 'write' ? 'warning' : 'info', size: "small", fill: "semi-filled", children: label.toUpperCase() }))] }), (0, jsx_runtime_1.jsx)("div", { className: "ndl-ai-preview-code-content", children: (0, jsx_runtime_1.jsx)(react_syntax_highlighter_1.PrismLight, { language: loadedLanguage !== null && loadedLanguage !== void 0 ? loadedLanguage : 'text', style: Object.assign(Object.assign({}, getTheme()), { 'pre[class*="language-"]': {
95
96
  border: 0,
96
97
  color: 'var(--theme-color-neutral-text-default)',
97
98
  lineHeight: '1',
@@ -1 +1 @@
1
- {"version":3,"file":"Preview.js","sourceRoot":"","sources":["../../../../src/ai/preview/Preview.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4CAO0B;AAC1B,4DAAoC;AACpC,iCAA4C;AAC5C,uEAA2E;AAG3E,oEAIyC;AACzC,0FAAgE;AAChE,4FAAkE;AAClE,uFAAoF;AACpF,uFAAoF;AAMpF;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,CAAC,EAOS,EAAE,EAAE;QAPb,EACxB,QAAQ,EACR,GAAG,EACH,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ACP,CAAC;AACJ,CAAC,CAAC;AAEW,QAAA,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IACrD,IAAI,EAAE,WAAW;IACjB,YAAY,EAAE,mBAAmB;IACjC,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;CACtB,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 {\n ClipboardButton,\n type CodeBlock,\n LoadingSpinner,\n StatusLabel,\n Typography,\n useNeedleTheme,\n} from '@neo4j-ndl/react';\nimport classNames from 'classnames';\nimport { useEffect, useState } from 'react';\nimport { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';\n\nimport { type CommonProps } from '../../_common/types';\nimport {\n type LanguageProp,\n Languages,\n loadLanguage,\n} from '../../code-block/code-languages';\nimport ndlCodeDark from '../../code-block/themes/ndl-code-dark';\nimport ndlCodeLight from '../../code-block/themes/ndl-code-light';\nimport { CheckIconOutline } from '../../icons/generated/heroIcons/CheckIconOutline';\nimport { XMarkIconOutline } from '../../icons/generated/heroIcons/XMarkIconOutline';\n\ntype PreviewProps = {\n children: React.ReactNode;\n};\n\n/**\n * Component to use for previewing certain content in AI chat applications.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PreviewComponent = ({\n children,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\ntype PreviewHeaderProps = {\n children?: React.ReactNode;\n actions?: React.ReactNode;\n};\n\nconst PreviewHeader = ({\n children,\n actions,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewHeaderProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-header', className)}\n {...restProps}\n {...htmlAttributes}\n >\n <Typography\n variant=\"code\"\n as=\"div\"\n className=\"ndl-ai-preview-header-leading-content\"\n >\n {children}\n </Typography>\n\n {actions && (\n <div className=\"ndl-ai-preview-header-actions\">{actions}</div>\n )}\n </div>\n );\n};\n\ntype PreviewConfirmationProps = {\n /** The content to display in the confirmation */\n children?: React.ReactNode;\n /** The actions to display in the confirmation, usually two buttons; one for confirming and one for rejecting. */\n actions: React.ReactNode;\n /** Whether the confirmation is used as a footer */\n isFooter?: boolean;\n /** The status of the confirmation */\n status?: 'pending' | 'confirmed' | 'rejected';\n /** The text to display for the confirmed status */\n confirmedActionText?: string;\n /** The text to display for the rejected status */\n rejectedActionText?: string;\n};\n\nconst PreviewConfirmation = ({\n children,\n actions,\n isFooter = false,\n status = 'pending',\n confirmedActionText = 'Action confirmed',\n rejectedActionText = 'Action rejected',\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewConfirmationProps>) => {\n const classes = classNames('ndl-ai-preview-confirmation', className, {\n 'ndl-ai-preview-confirmation-footer': isFooter,\n });\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {!(isFooter && status !== 'pending') && (\n <Typography\n as=\"div\"\n variant={isFooter ? 'subheading-small' : 'body-medium'}\n className=\"ndl-ai-preview-confirmation-content\"\n >\n {children}\n </Typography>\n )}\n <Typography\n variant=\"body-medium\"\n as=\"div\"\n className=\"ndl-ai-preview-confirmation-actions\"\n >\n {status === 'pending' && actions}\n {status === 'confirmed' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <CheckIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {confirmedActionText}\n </div>\n )}\n {status === 'rejected' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <XMarkIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {rejectedActionText}\n </div>\n )}\n </Typography>\n </div>\n );\n};\n\ntype PreviewCodeProps = {\n /** The code content to display */\n code: string;\n /** The language of the code (e.g., 'cypher', 'python', 'javascript') */\n language: React.ComponentProps<typeof CodeBlock>['language'];\n /** The current state of the code block */\n label?: 'read' | 'write';\n /** Whether the code block is loading */\n isLoading?: boolean;\n /** The actions to display in the header. Should be small buttons or icon buttons only. */\n headerActions?: React.ReactNode;\n /** The theme of the code block */\n theme?: 'ndl-code-dark' | 'ndl-code-light';\n};\n\nconst PreviewCode = ({\n code,\n language,\n label,\n isLoading = false,\n headerActions,\n theme,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewCodeProps>) => {\n const [loadedLanguage, setLoadedLanguage] = useState<\n PreviewCodeProps['language'] | null\n >(null);\n const { theme: ndlTheme } = useNeedleTheme();\n\n useEffect(() => {\n if (!language || !(Languages as readonly string[]).includes(language)) {\n setLoadedLanguage('text');\n return;\n }\n\n loadLanguage(language as LanguageProp)\n .then((module) => {\n SyntaxHighlighter.registerLanguage(language, module.default);\n setLoadedLanguage(language);\n })\n .catch((err) => console.error(err));\n }, [language]);\n\n const getTheme = () => {\n switch (theme) {\n case 'ndl-code-dark':\n return ndlCodeDark;\n case 'ndl-code-light':\n return ndlCodeLight;\n default:\n return ndlTheme === 'light' ? ndlCodeLight : ndlCodeDark;\n }\n };\n\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-code', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {isLoading && (\n <div className=\"ndl-ai-preview-code-loading\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"code\">\n WRITING {language.toUpperCase()}\n </Typography>\n </div>\n )}\n {!isLoading && (\n <>\n <PreviewHeader\n className=\"ndl-ai-preview-code-header\"\n actions={\n <>\n <ClipboardButton\n textToCopy={code}\n type=\"clean-icon-button\"\n size=\"small\"\n />\n {headerActions}\n </>\n }\n >\n {language} {language.toLowerCase() === 'cypher' ? 'QUERY' : ''}\n {label && (\n <StatusLabel\n variant={label === 'write' ? 'warning' : 'info'}\n size=\"small\"\n fill=\"semi-filled\"\n >\n {label.toUpperCase()}\n </StatusLabel>\n )}\n </PreviewHeader>\n <div className=\"ndl-ai-preview-code-content\">\n <SyntaxHighlighter\n language={loadedLanguage ?? 'text'}\n style={{\n ...getTheme(),\n 'pre[class*=\"language-\"]': {\n border: 0,\n color: 'var(--theme-color-neutral-text-default)',\n lineHeight: '1',\n overflowX: 'auto',\n padding: 'var(--space-12)',\n width: 'fit-content',\n },\n }}\n // Turn on 'shouldShowLineNumbers' & 'wrapLongLines' at the same time, the display is wrong\n // https://github.com/react-syntax-highlighter/react-syntax-highlighter/issues/402\n // wrapLongLines\n codeTagProps={{ className: 'n-ai-preview-code' }}\n showLineNumbers={false}\n >\n {code}\n </SyntaxHighlighter>\n </div>\n </>\n )}\n </div>\n );\n};\n\ntype PreviewContentProps = {\n children?: React.ReactNode;\n};\n\nconst PreviewContent = ({\n children,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewContentProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-content', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nexport const Preview = Object.assign(PreviewComponent, {\n Code: PreviewCode,\n Confirmation: PreviewConfirmation,\n Content: PreviewContent,\n Header: PreviewHeader,\n});\n"]}
1
+ {"version":3,"file":"Preview.js","sourceRoot":"","sources":["../../../../src/ai/preview/Preview.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;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,aAAa;iCACrB;4BAEH,2FAA2F;4BAC3F,kFAAkF;4BAClF,gBAAgB;4BAChB,YAAY,EAAE,EAAE,SAAS,EAAE,mBAAmB,EAAE,EAChD,eAAe,EAAE,KAAK,YAErB,IAAI,GACa,GAChB,IACL,CACJ,KACG,CACP,CAAC;AACJ,CAAC,CAAC;AAMF,MAAM,cAAc,GAAG,CAAC,EAOkB,EAAE,EAAE;QAPtB,EACtB,QAAQ,EACR,GAAG,EACH,KAAK,EACL,SAAS,EACT,cAAc,OAE0B,EADrC,SAAS,cANU,2DAOvB,CADa;IAEZ,OAAO,CACL,8CACE,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,IAAA,oBAAU,EAAC,wBAAwB,EAAE,SAAS,CAAC,IACtD,SAAS,EACT,cAAc,cAEjB,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEW,QAAA,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IACrD,IAAI,EAAE,WAAW;IACjB,YAAY,EAAE,mBAAmB;IACjC,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;CACtB,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 {\n ClipboardButton,\n type CodeBlock,\n LoadingSpinner,\n StatusLabel,\n Typography,\n useNeedleTheme,\n} from '@neo4j-ndl/react';\nimport classNames from 'classnames';\nimport { useEffect, useState } from 'react';\nimport { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';\n\nimport { TruncatedTextWithTooltip } from '../../_common/TruncatedTextWithTooltip';\nimport { type CommonProps } from '../../_common/types';\nimport {\n type LanguageProp,\n Languages,\n loadLanguage,\n} from '../../code-block/code-languages';\nimport ndlCodeDark from '../../code-block/themes/ndl-code-dark';\nimport ndlCodeLight from '../../code-block/themes/ndl-code-light';\nimport { CheckIconOutline } from '../../icons/generated/heroIcons/CheckIconOutline';\nimport { XMarkIconOutline } from '../../icons/generated/heroIcons/XMarkIconOutline';\n\ntype PreviewProps = {\n children: React.ReactNode;\n};\n\n/**\n * Component to use for previewing certain content in AI chat applications.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PreviewComponent = ({\n children,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\ntype PreviewHeaderProps = {\n /** The content to display in the header. When a plain string is passed, it truncates with an ellipsis and shows a tooltip with the full text when space is limited. */\n children?: React.ReactNode;\n /** The actions to display in the header. Should be small buttons or icon buttons only. */\n actions?: React.ReactNode;\n};\n\nconst PreviewHeader = ({\n children,\n actions,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewHeaderProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-header', className)}\n {...restProps}\n {...htmlAttributes}\n >\n <Typography\n variant=\"code\"\n as=\"div\"\n className=\"ndl-ai-preview-header-leading-content\"\n >\n {typeof children === 'string' ? (\n <TruncatedTextWithTooltip text={children} />\n ) : (\n children\n )}\n </Typography>\n\n {actions && (\n <div className=\"ndl-ai-preview-header-actions\">{actions}</div>\n )}\n </div>\n );\n};\n\ntype PreviewConfirmationProps = {\n /** The content to display in the confirmation */\n children?: React.ReactNode;\n /** The actions to display in the confirmation, usually two buttons; one for confirming and one for rejecting. */\n actions: React.ReactNode;\n /** Whether the confirmation is used as a footer */\n isFooter?: boolean;\n /** The status of the confirmation */\n status?: 'pending' | 'confirmed' | 'rejected';\n /** The text to display for the confirmed status */\n confirmedActionText?: string;\n /** The text to display for the rejected status */\n rejectedActionText?: string;\n};\n\nconst PreviewConfirmation = ({\n children,\n actions,\n isFooter = false,\n status = 'pending',\n confirmedActionText = 'Action confirmed',\n rejectedActionText = 'Action rejected',\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewConfirmationProps>) => {\n const classes = classNames('ndl-ai-preview-confirmation', className, {\n 'ndl-ai-preview-confirmation-footer': isFooter,\n });\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {!(isFooter && status !== 'pending') && (\n <Typography\n as=\"div\"\n variant={isFooter ? 'subheading-small' : 'body-medium'}\n className=\"ndl-ai-preview-confirmation-content\"\n >\n {children}\n </Typography>\n )}\n <Typography\n variant=\"body-medium\"\n as=\"div\"\n className=\"ndl-ai-preview-confirmation-actions\"\n >\n {status === 'pending' && actions}\n {status === 'confirmed' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <CheckIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {confirmedActionText}\n </div>\n )}\n {status === 'rejected' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <XMarkIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {rejectedActionText}\n </div>\n )}\n </Typography>\n </div>\n );\n};\n\ntype PreviewCodeProps = {\n /** The code content to display */\n code: string;\n /** The language of the code (e.g., 'cypher', 'python', 'javascript') */\n language: React.ComponentProps<typeof CodeBlock>['language'];\n /** The current state of the code block\n * @deprecated - The query should be described in the heading property instead.\n */\n label?: 'read' | 'write';\n /** Whether the code block is loading */\n isLoading?: boolean;\n /** The actions to display in the header. Should be small buttons or icon buttons only. */\n headerActions?: React.ReactNode;\n /** The theme of the code block */\n theme?: 'ndl-code-dark' | 'ndl-code-light';\n /** The heading to display in the header. If not provided, the language will be displayed. Truncates with an ellipsis and shows a tooltip with the full text when space is limited. */\n heading?: string;\n};\n\nconst PreviewCode = ({\n code,\n language,\n label,\n isLoading = false,\n headerActions,\n theme,\n heading,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewCodeProps>) => {\n const [loadedLanguage, setLoadedLanguage] = useState<\n PreviewCodeProps['language'] | null\n >(null);\n const { theme: ndlTheme } = useNeedleTheme();\n\n useEffect(() => {\n if (!language || !(Languages as readonly string[]).includes(language)) {\n setLoadedLanguage('text');\n return;\n }\n\n loadLanguage(language as LanguageProp)\n .then((module) => {\n SyntaxHighlighter.registerLanguage(language, module.default);\n setLoadedLanguage(language);\n })\n .catch((err) => console.error(err));\n }, [language]);\n\n const getTheme = () => {\n switch (theme) {\n case 'ndl-code-dark':\n return ndlCodeDark;\n case 'ndl-code-light':\n return ndlCodeLight;\n default:\n return ndlTheme === 'light' ? ndlCodeLight : ndlCodeDark;\n }\n };\n\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-code', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {isLoading && (\n <div className=\"ndl-ai-preview-code-loading\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"code\">\n WRITING {language.toUpperCase()}\n </Typography>\n </div>\n )}\n {!isLoading && (\n <>\n <PreviewHeader\n className=\"ndl-ai-preview-code-header\"\n actions={\n <>\n <ClipboardButton\n textToCopy={code}\n type=\"clean-icon-button\"\n size=\"small\"\n />\n {headerActions}\n </>\n }\n >\n <TruncatedTextWithTooltip\n className=\"ndl-ai-preview-code-header-heading\"\n text={\n heading ??\n `${language}${language.toLowerCase() === 'cypher' ? ' QUERY' : ''}`\n }\n />\n {label && (\n <StatusLabel\n variant={label === 'write' ? 'warning' : 'info'}\n size=\"small\"\n fill=\"semi-filled\"\n >\n {label.toUpperCase()}\n </StatusLabel>\n )}\n </PreviewHeader>\n <div className=\"ndl-ai-preview-code-content\">\n <SyntaxHighlighter\n language={loadedLanguage ?? 'text'}\n style={{\n ...getTheme(),\n 'pre[class*=\"language-\"]': {\n border: 0,\n color: 'var(--theme-color-neutral-text-default)',\n lineHeight: '1',\n overflowX: 'auto',\n padding: 'var(--space-12)',\n width: 'fit-content',\n },\n }}\n // Turn on 'shouldShowLineNumbers' & 'wrapLongLines' at the same time, the display is wrong\n // https://github.com/react-syntax-highlighter/react-syntax-highlighter/issues/402\n // wrapLongLines\n codeTagProps={{ className: 'n-ai-preview-code' }}\n showLineNumbers={false}\n >\n {code}\n </SyntaxHighlighter>\n </div>\n </>\n )}\n </div>\n );\n};\n\ntype PreviewContentProps = {\n children?: React.ReactNode;\n};\n\nconst PreviewContent = ({\n children,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewContentProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-content', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nexport const Preview = Object.assign(PreviewComponent, {\n Code: PreviewCode,\n Confirmation: PreviewConfirmation,\n Content: PreviewContent,\n Header: PreviewHeader,\n});\n"]}
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.PreviewSimpleWithContentSrc = exports.PreviewSimpleSrc = exports.PreviewCodeLanguagesSrc = exports.PreviewCodeWriteSrc = exports.PreviewCodeReadSrc = exports.PreviewCodeLoadingSrc = exports.PreviewCodeConfirmationSrc = exports.PreviewConfirmationStandaloneSrc = exports.PreviewDataGridSrc = exports.PreviewSimpleWithContent = exports.PreviewSimple = exports.PreviewCodeLanguages = exports.PreviewCodeWrite = exports.PreviewCodeRead = exports.PreviewCodeLoading = exports.PreviewCodeConfirmation = exports.PreviewConfirmationStandalone = exports.PreviewDataGrid = void 0;
26
+ exports.PreviewSimpleWithContentSrc = exports.PreviewSimpleSrc = exports.PreviewCodeTruncationSrc = exports.PreviewCodeCypherSrc = exports.PreviewCodeLanguagesSrc = exports.PreviewCodeLoadingSrc = exports.PreviewCodeConfirmationSrc = exports.PreviewConfirmationStandaloneSrc = exports.PreviewDataGridSrc = exports.PreviewCodeTruncation = exports.PreviewCodeCypher = exports.PreviewSimpleWithContent = exports.PreviewSimple = exports.PreviewCodeLanguages = exports.PreviewCodeLoading = exports.PreviewCodeConfirmation = exports.PreviewConfirmationStandalone = exports.PreviewDataGrid = void 0;
27
27
  var preview_data_grid_story_1 = require("./preview-data-grid.story");
28
28
  Object.defineProperty(exports, "PreviewDataGrid", { enumerable: true, get: function () { return __importDefault(preview_data_grid_story_1).default; } });
29
29
  var preview_confirmation_standalone_story_1 = require("./preview-confirmation-standalone.story");
@@ -32,22 +32,22 @@ var preview_code_confirmation_story_1 = require("./preview-code-confirmation.sto
32
32
  Object.defineProperty(exports, "PreviewCodeConfirmation", { enumerable: true, get: function () { return __importDefault(preview_code_confirmation_story_1).default; } });
33
33
  var preview_code_loading_story_1 = require("./preview-code-loading.story");
34
34
  Object.defineProperty(exports, "PreviewCodeLoading", { enumerable: true, get: function () { return __importDefault(preview_code_loading_story_1).default; } });
35
- var preview_code_read_story_1 = require("./preview-code-read.story");
36
- Object.defineProperty(exports, "PreviewCodeRead", { enumerable: true, get: function () { return __importDefault(preview_code_read_story_1).default; } });
37
- var preview_code_write_story_1 = require("./preview-code-write.story");
38
- Object.defineProperty(exports, "PreviewCodeWrite", { enumerable: true, get: function () { return __importDefault(preview_code_write_story_1).default; } });
39
35
  var preview_code_languages_story_1 = require("./preview-code-languages.story");
40
36
  Object.defineProperty(exports, "PreviewCodeLanguages", { enumerable: true, get: function () { return __importDefault(preview_code_languages_story_1).default; } });
41
37
  var preview_simple_story_1 = require("./preview-simple.story");
42
38
  Object.defineProperty(exports, "PreviewSimple", { enumerable: true, get: function () { return __importDefault(preview_simple_story_1).default; } });
43
39
  var preview_simple_with_content_story_1 = require("./preview-simple-with-content.story");
44
40
  Object.defineProperty(exports, "PreviewSimpleWithContent", { enumerable: true, get: function () { return __importDefault(preview_simple_with_content_story_1).default; } });
41
+ var preview_code_cypher_story_1 = require("./preview-code-cypher.story");
42
+ Object.defineProperty(exports, "PreviewCodeCypher", { enumerable: true, get: function () { return __importDefault(preview_code_cypher_story_1).default; } });
43
+ var preview_code_truncation_story_1 = require("./preview-code-truncation.story");
44
+ Object.defineProperty(exports, "PreviewCodeTruncation", { enumerable: true, get: function () { return __importDefault(preview_code_truncation_story_1).default; } });
45
45
  const export_stories_utils_1 = require("../../../_common/export-stories-utils");
46
46
  const preview_code_confirmation_story_raw_1 = __importDefault(require("./preview-code-confirmation.story?raw"));
47
+ const preview_code_cypher_story_raw_1 = __importDefault(require("./preview-code-cypher.story?raw"));
47
48
  const preview_code_languages_story_raw_1 = __importDefault(require("./preview-code-languages.story?raw"));
48
49
  const preview_code_loading_story_raw_1 = __importDefault(require("./preview-code-loading.story?raw"));
49
- const preview_code_read_story_raw_1 = __importDefault(require("./preview-code-read.story?raw"));
50
- const preview_code_write_story_raw_1 = __importDefault(require("./preview-code-write.story?raw"));
50
+ const preview_code_truncation_story_raw_1 = __importDefault(require("./preview-code-truncation.story?raw"));
51
51
  const preview_confirmation_standalone_story_raw_1 = __importDefault(require("./preview-confirmation-standalone.story?raw"));
52
52
  const preview_data_grid_story_raw_1 = __importDefault(require("./preview-data-grid.story?raw"));
53
53
  const preview_simple_story_raw_1 = __importDefault(require("./preview-simple.story?raw"));
@@ -56,9 +56,9 @@ exports.PreviewDataGridSrc = (0, export_stories_utils_1.removeLicenseHeader)(pre
56
56
  exports.PreviewConfirmationStandaloneSrc = (0, export_stories_utils_1.removeLicenseHeader)(preview_confirmation_standalone_story_raw_1.default);
57
57
  exports.PreviewCodeConfirmationSrc = (0, export_stories_utils_1.removeLicenseHeader)(preview_code_confirmation_story_raw_1.default);
58
58
  exports.PreviewCodeLoadingSrc = (0, export_stories_utils_1.removeLicenseHeader)(preview_code_loading_story_raw_1.default);
59
- exports.PreviewCodeReadSrc = (0, export_stories_utils_1.removeLicenseHeader)(preview_code_read_story_raw_1.default);
60
- exports.PreviewCodeWriteSrc = (0, export_stories_utils_1.removeLicenseHeader)(preview_code_write_story_raw_1.default);
61
59
  exports.PreviewCodeLanguagesSrc = (0, export_stories_utils_1.removeLicenseHeader)(preview_code_languages_story_raw_1.default);
60
+ exports.PreviewCodeCypherSrc = (0, export_stories_utils_1.removeLicenseHeader)(preview_code_cypher_story_raw_1.default);
61
+ exports.PreviewCodeTruncationSrc = (0, export_stories_utils_1.removeLicenseHeader)(preview_code_truncation_story_raw_1.default);
62
62
  exports.PreviewSimpleSrc = (0, export_stories_utils_1.removeLicenseHeader)(preview_simple_story_raw_1.default);
63
63
  exports.PreviewSimpleWithContentSrc = (0, export_stories_utils_1.removeLicenseHeader)(preview_simple_with_content_story_raw_1.default);
64
64
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ai/preview/stories/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;AAEH,qEAAuE;AAA9D,2IAAA,OAAO,OAAmB;AACnC,iGAAmG;AAA1F,uKAAA,OAAO,OAAiC;AACjD,qFAAuF;AAA9E,2JAAA,OAAO,OAA2B;AAC3C,2EAA6E;AAApE,iJAAA,OAAO,OAAsB;AACtC,qEAAuE;AAA9D,2IAAA,OAAO,OAAmB;AACnC,uEAAyE;AAAhE,6IAAA,OAAO,OAAoB;AACpC,+EAAiF;AAAxE,qJAAA,OAAO,OAAwB;AACxC,+DAAkE;AAAzD,sIAAA,OAAO,OAAiB;AACjC,yFAA0F;AAAjF,8JAAA,OAAO,OAA4B;AAE5C,gFAA4E;AAC5E,gHAAkF;AAClF,0GAA4E;AAC5E,sGAAwE;AACxE,gGAAkE;AAClE,kGAAoE;AACpE,4HAA8F;AAC9F,gGAAkE;AAClE,0FAA6D;AAC7D,oHAAqF;AAExE,QAAA,kBAAkB,GAAG,IAAA,0CAAmB,EAAC,qCAAqB,CAAC,CAAC;AAChE,QAAA,gCAAgC,GAAG,IAAA,0CAAmB,EACjE,mDAAmC,CACpC,CAAC;AACW,QAAA,0BAA0B,GAAG,IAAA,0CAAmB,EAC3D,6CAA6B,CAC9B,CAAC;AACW,QAAA,qBAAqB,GAAG,IAAA,0CAAmB,EACtD,wCAAwB,CACzB,CAAC;AACW,QAAA,kBAAkB,GAAG,IAAA,0CAAmB,EAAC,qCAAqB,CAAC,CAAC;AAChE,QAAA,mBAAmB,GAAG,IAAA,0CAAmB,EAAC,sCAAsB,CAAC,CAAC;AAClE,QAAA,uBAAuB,GAAG,IAAA,0CAAmB,EACxD,0CAA0B,CAC3B,CAAC;AACW,QAAA,gBAAgB,GAAG,IAAA,0CAAmB,EAAC,kCAAmB,CAAC,CAAC;AAC5D,QAAA,2BAA2B,GAAG,IAAA,0CAAmB,EAC5D,+CAA8B,CAC/B,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\nexport { default as PreviewDataGrid } from './preview-data-grid.story';\nexport { default as PreviewConfirmationStandalone } from './preview-confirmation-standalone.story';\nexport { default as PreviewCodeConfirmation } from './preview-code-confirmation.story';\nexport { default as PreviewCodeLoading } from './preview-code-loading.story';\nexport { default as PreviewCodeRead } from './preview-code-read.story';\nexport { default as PreviewCodeWrite } from './preview-code-write.story';\nexport { default as PreviewCodeLanguages } from './preview-code-languages.story';\nexport { default as PreviewSimple } from './preview-simple.story';\nexport { default as PreviewSimpleWithContent } from './preview-simple-with-content.story';\n\nimport { removeLicenseHeader } from '../../../_common/export-stories-utils';\nimport PreviewCodeConfirmationSrcRaw from './preview-code-confirmation.story?raw';\nimport PreviewCodeLanguagesSrcRaw from './preview-code-languages.story?raw';\nimport PreviewCodeLoadingSrcRaw from './preview-code-loading.story?raw';\nimport PreviewCodeReadSrcRaw from './preview-code-read.story?raw';\nimport PreviewCodeWriteSrcRaw from './preview-code-write.story?raw';\nimport PreviewConfirmationStandaloneSrcRaw from './preview-confirmation-standalone.story?raw';\nimport PreviewDataGridSrcRaw from './preview-data-grid.story?raw';\nimport PreviewSimpleSrcRaw from './preview-simple.story?raw';\nimport PreviewSimpleWithContentSrcRaw from './preview-simple-with-content.story?raw';\n\nexport const PreviewDataGridSrc = removeLicenseHeader(PreviewDataGridSrcRaw);\nexport const PreviewConfirmationStandaloneSrc = removeLicenseHeader(\n PreviewConfirmationStandaloneSrcRaw,\n);\nexport const PreviewCodeConfirmationSrc = removeLicenseHeader(\n PreviewCodeConfirmationSrcRaw,\n);\nexport const PreviewCodeLoadingSrc = removeLicenseHeader(\n PreviewCodeLoadingSrcRaw,\n);\nexport const PreviewCodeReadSrc = removeLicenseHeader(PreviewCodeReadSrcRaw);\nexport const PreviewCodeWriteSrc = removeLicenseHeader(PreviewCodeWriteSrcRaw);\nexport const PreviewCodeLanguagesSrc = removeLicenseHeader(\n PreviewCodeLanguagesSrcRaw,\n);\nexport const PreviewSimpleSrc = removeLicenseHeader(PreviewSimpleSrcRaw);\nexport const PreviewSimpleWithContentSrc = removeLicenseHeader(\n PreviewSimpleWithContentSrcRaw,\n);\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ai/preview/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\"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\nexport { default as PreviewDataGrid } from './preview-data-grid.story';\nexport { default as PreviewConfirmationStandalone } from './preview-confirmation-standalone.story';\nexport { default as PreviewCodeConfirmation } from './preview-code-confirmation.story';\nexport { default as PreviewCodeLoading } from './preview-code-loading.story';\nexport { default as PreviewCodeLanguages } from './preview-code-languages.story';\nexport { default as PreviewSimple } from './preview-simple.story';\nexport { default as PreviewSimpleWithContent } from './preview-simple-with-content.story';\nexport { default as PreviewCodeCypher } from './preview-code-cypher.story';\nexport { default as PreviewCodeTruncation } from './preview-code-truncation.story';\n\nimport { removeLicenseHeader } from '../../../_common/export-stories-utils';\nimport PreviewCodeConfirmationSrcRaw from './preview-code-confirmation.story?raw';\nimport PreviewCodeCypherSrcRaw from './preview-code-cypher.story?raw';\nimport PreviewCodeLanguagesSrcRaw from './preview-code-languages.story?raw';\nimport PreviewCodeLoadingSrcRaw from './preview-code-loading.story?raw';\nimport PreviewCodeTruncationSrcRaw from './preview-code-truncation.story?raw';\nimport PreviewConfirmationStandaloneSrcRaw from './preview-confirmation-standalone.story?raw';\nimport PreviewDataGridSrcRaw from './preview-data-grid.story?raw';\nimport PreviewSimpleSrcRaw from './preview-simple.story?raw';\nimport PreviewSimpleWithContentSrcRaw from './preview-simple-with-content.story?raw';\n\nexport const PreviewDataGridSrc = removeLicenseHeader(PreviewDataGridSrcRaw);\nexport const PreviewConfirmationStandaloneSrc = removeLicenseHeader(\n PreviewConfirmationStandaloneSrcRaw,\n);\nexport const PreviewCodeConfirmationSrc = removeLicenseHeader(\n PreviewCodeConfirmationSrcRaw,\n);\nexport const PreviewCodeLoadingSrc = removeLicenseHeader(\n PreviewCodeLoadingSrcRaw,\n);\nexport const PreviewCodeLanguagesSrc = removeLicenseHeader(\n PreviewCodeLanguagesSrcRaw,\n);\nexport const PreviewCodeCypherSrc = removeLicenseHeader(\n PreviewCodeCypherSrcRaw,\n);\nexport const PreviewCodeTruncationSrc = removeLicenseHeader(\n PreviewCodeTruncationSrcRaw,\n);\nexport const PreviewSimpleSrc = removeLicenseHeader(PreviewSimpleSrcRaw);\nexport const PreviewSimpleWithContentSrc = removeLicenseHeader(\n PreviewSimpleWithContentSrcRaw,\n);\n"]}
@@ -30,7 +30,7 @@ username
30
30
  [YIELD { * | field[, ...] } [ORDER BY field ...`;
31
31
  const Component = () => {
32
32
  const [status, setStatus] = (0, react_2.useState)('pending');
33
- return ((0, jsx_runtime_1.jsxs)(ai_1.Preview, { children: [(0, jsx_runtime_1.jsx)(ai_1.Preview.Code, { code: cypherCode, language: "cypher", label: "write", isLoading: false, headerActions: null }), (0, jsx_runtime_1.jsx)(ai_1.Preview.Confirmation, { status: status, isFooter: true, confirmedActionText: "Action confirmed", rejectedActionText: "Action rejected", actions: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.OutlinedButton, { variant: "neutral", size: "small", onClick: () => setStatus('rejected'), children: "Skip" }), (0, jsx_runtime_1.jsx)(react_1.FilledButton, { variant: "primary", size: "small", onClick: () => setStatus('confirmed'), children: "Run query" })] }), children: "Assistant wants to run this query" })] }));
33
+ return ((0, jsx_runtime_1.jsxs)(ai_1.Preview, { children: [(0, jsx_runtime_1.jsx)(ai_1.Preview.Code, { code: cypherCode, language: "cypher", heading: "Show functions executable by user", isLoading: false, headerActions: null }), (0, jsx_runtime_1.jsx)(ai_1.Preview.Confirmation, { status: status, isFooter: true, confirmedActionText: "Action confirmed", rejectedActionText: "Action rejected", actions: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.OutlinedButton, { variant: "neutral", size: "small", onClick: () => setStatus('rejected'), children: "Skip" }), (0, jsx_runtime_1.jsx)(react_1.FilledButton, { variant: "primary", size: "small", onClick: () => setStatus('confirmed'), children: "Run query" })] }), children: "Assistant wants to run this query" })] }));
34
34
  };
35
35
  exports.default = Component;
36
36
  //# sourceMappingURL=preview-code-confirmation.story.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview-code-confirmation.story.js","sourceRoot":"","sources":["../../../../../src/ai/preview/stories/preview-code-confirmation.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAgE;AAChE,4CAA8C;AAC9C,iCAAiC;AAEjC,MAAM,UAAU,GAAG;;gDAE6B,CAAC;AAEjD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACvB,IAAA,gBAAQ,EACN,SAAS,CACV,CAAC;IAEJ,OAAO,CACL,wBAAC,YAAO,eACN,uBAAC,YAAO,CAAC,IAAI,IACX,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAC,QAAQ,EACjB,KAAK,EAAC,OAAO,EACb,SAAS,EAAE,KAAK,EAChB,aAAa,EAAE,IAAI,GACnB,EACF,uBAAC,YAAO,CAAC,YAAY,IACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,IAAI,EACd,mBAAmB,EAAC,kBAAkB,EACtC,kBAAkB,EAAC,iBAAiB,EACpC,OAAO,EACL,6DACE,uBAAC,sBAAc,IACb,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,qBAGrB,EACjB,uBAAC,oBAAY,IACX,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,0BAGxB,IACd,kDAIgB,IACf,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,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 '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { FilledButton, OutlinedButton } from '@neo4j-ndl/react';\nimport { Preview } from '@neo4j-ndl/react/ai';\nimport { useState } from 'react';\n\nconst cypherCode = `SHOW [ALL|BUILT IN|USER DEFINED] FUNCTION[S] EXECUTABLE BY\nusername\n[YIELD { * | field[, ...] } [ORDER BY field ...`;\n\nconst Component = () => {\n const [status, setStatus] =\n useState<React.ComponentProps<typeof Preview.Confirmation>['status']>(\n 'pending',\n );\n\n return (\n <Preview>\n <Preview.Code\n code={cypherCode}\n language=\"cypher\"\n label=\"write\"\n isLoading={false}\n headerActions={null}\n />\n <Preview.Confirmation\n status={status}\n isFooter={true}\n confirmedActionText=\"Action confirmed\"\n rejectedActionText=\"Action rejected\"\n actions={\n <>\n <OutlinedButton\n variant=\"neutral\"\n size=\"small\"\n onClick={() => setStatus('rejected')}\n >\n Skip\n </OutlinedButton>\n <FilledButton\n variant=\"primary\"\n size=\"small\"\n onClick={() => setStatus('confirmed')}\n >\n Run query\n </FilledButton>\n </>\n }\n >\n Assistant wants to run this query\n </Preview.Confirmation>\n </Preview>\n );\n};\n\nexport default Component;\n"]}
1
+ {"version":3,"file":"preview-code-confirmation.story.js","sourceRoot":"","sources":["../../../../../src/ai/preview/stories/preview-code-confirmation.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAgE;AAChE,4CAA8C;AAC9C,iCAAiC;AAEjC,MAAM,UAAU,GAAG;;gDAE6B,CAAC;AAEjD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACvB,IAAA,gBAAQ,EACN,SAAS,CACV,CAAC;IAEJ,OAAO,CACL,wBAAC,YAAO,eACN,uBAAC,YAAO,CAAC,IAAI,IACX,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAC,QAAQ,EACjB,OAAO,EAAC,mCAAmC,EAC3C,SAAS,EAAE,KAAK,EAChB,aAAa,EAAE,IAAI,GACnB,EACF,uBAAC,YAAO,CAAC,YAAY,IACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,IAAI,EACd,mBAAmB,EAAC,kBAAkB,EACtC,kBAAkB,EAAC,iBAAiB,EACpC,OAAO,EACL,6DACE,uBAAC,sBAAc,IACb,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,qBAGrB,EACjB,uBAAC,oBAAY,IACX,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,0BAGxB,IACd,kDAIgB,IACf,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,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 '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { FilledButton, OutlinedButton } from '@neo4j-ndl/react';\nimport { Preview } from '@neo4j-ndl/react/ai';\nimport { useState } from 'react';\n\nconst cypherCode = `SHOW [ALL|BUILT IN|USER DEFINED] FUNCTION[S] EXECUTABLE BY\nusername\n[YIELD { * | field[, ...] } [ORDER BY field ...`;\n\nconst Component = () => {\n const [status, setStatus] =\n useState<React.ComponentProps<typeof Preview.Confirmation>['status']>(\n 'pending',\n );\n\n return (\n <Preview>\n <Preview.Code\n code={cypherCode}\n language=\"cypher\"\n heading=\"Show functions executable by user\"\n isLoading={false}\n headerActions={null}\n />\n <Preview.Confirmation\n status={status}\n isFooter={true}\n confirmedActionText=\"Action confirmed\"\n rejectedActionText=\"Action rejected\"\n actions={\n <>\n <OutlinedButton\n variant=\"neutral\"\n size=\"small\"\n onClick={() => setStatus('rejected')}\n >\n Skip\n </OutlinedButton>\n <FilledButton\n variant=\"primary\"\n size=\"small\"\n onClick={() => setStatus('confirmed')}\n >\n Run query\n </FilledButton>\n </>\n }\n >\n Assistant wants to run this query\n </Preview.Confirmation>\n </Preview>\n );\n};\n\nexport default Component;\n"]}
@@ -29,7 +29,7 @@ const cypherCode = `SHOW [ALL|BUILT IN|USER DEFINED] FUNCTION[S] EXECUTABLE BY
29
29
  username
30
30
  [YIELD { * | field[, ...] } [ORDER BY field ...`;
31
31
  const Component = () => {
32
- return ((0, jsx_runtime_1.jsx)(ai_1.Preview, { children: (0, jsx_runtime_1.jsx)(ai_1.Preview.Code, { code: cypherCode, language: "cypher", label: "read", headerActions: (0, jsx_runtime_1.jsx)(react_1.OutlinedButton, { leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.PencilSquareIconOutline, {}), variant: "neutral", size: "small", children: "Send to Query" }) }) }));
32
+ return ((0, jsx_runtime_1.jsx)(ai_1.Preview, { children: (0, jsx_runtime_1.jsx)(ai_1.Preview.Code, { code: cypherCode, language: "cypher", heading: "Show functions executable by user", headerActions: (0, jsx_runtime_1.jsx)(react_1.OutlinedButton, { leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.PencilSquareIconOutline, {}), variant: "neutral", size: "small", children: "Send to Query" }) }) }));
33
33
  };
34
34
  exports.default = Component;
35
- //# sourceMappingURL=preview-code-read.story.js.map
35
+ //# sourceMappingURL=preview-code-cypher.story.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-code-cypher.story.js","sourceRoot":"","sources":["../../../../../src/ai/preview/stories/preview-code-cypher.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAkD;AAClD,4CAA8C;AAC9C,kDAAiE;AAEjE,MAAM,UAAU,GAAG;;gDAE6B,CAAC;AAEjD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,uBAAC,YAAO,cACN,uBAAC,YAAO,CAAC,IAAI,IACX,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAC,QAAQ,EACjB,OAAO,EAAC,mCAAmC,EAC3C,aAAa,EACX,uBAAC,sBAAc,IACb,aAAa,EAAE,uBAAC,+BAAuB,KAAG,EAC1C,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,8BAGG,GAEnB,GACM,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,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 '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { OutlinedButton } from '@neo4j-ndl/react';\nimport { Preview } from '@neo4j-ndl/react/ai';\nimport { PencilSquareIconOutline } from '@neo4j-ndl/react/icons';\n\nconst cypherCode = `SHOW [ALL|BUILT IN|USER DEFINED] FUNCTION[S] EXECUTABLE BY\nusername\n[YIELD { * | field[, ...] } [ORDER BY field ...`;\n\nconst Component = () => {\n return (\n <Preview>\n <Preview.Code\n code={cypherCode}\n language=\"cypher\"\n heading=\"Show functions executable by user\"\n headerActions={\n <OutlinedButton\n leadingVisual={<PencilSquareIconOutline />}\n variant=\"neutral\"\n size=\"small\"\n >\n Send to Query\n </OutlinedButton>\n }\n />\n </Preview>\n );\n};\n\nexport default Component;\n"]}
@@ -30,7 +30,7 @@ const pythonCode = `def show_functions(username, function_type='ALL'):
30
30
  query = f"SHOW {function_type} FUNCTIONS EXECUTABLE BY {username}"
31
31
  return query`;
32
32
  const Component = () => {
33
- return ((0, jsx_runtime_1.jsx)(ai_1.Preview, { children: (0, jsx_runtime_1.jsx)(ai_1.Preview.Code, { code: pythonCode, language: "python" }) }));
33
+ return ((0, jsx_runtime_1.jsx)(ai_1.Preview, { children: (0, jsx_runtime_1.jsx)(ai_1.Preview.Code, { code: pythonCode, language: "python", heading: "Show functions executable by user" }) }));
34
34
  };
35
35
  exports.default = Component;
36
36
  //# sourceMappingURL=preview-code-languages.story.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview-code-languages.story.js","sourceRoot":"","sources":["../../../../../src/ai/preview/stories/preview-code-languages.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAA8C;AAE9C,MAAM,UAAU,GAAG;;;;;iBAKF,CAAC;AAElB,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,uBAAC,YAAO,cACN,uBAAC,YAAO,CAAC,IAAI,IAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAC,QAAQ,GAAG,GAC5C,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,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 '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Preview } from '@neo4j-ndl/react/ai';\n\nconst pythonCode = `def show_functions(username, function_type='ALL'):\n \"\"\"\n Show functions executable by user\n \"\"\"\n query = f\"SHOW {function_type} FUNCTIONS EXECUTABLE BY {username}\"\n return query`;\n\nconst Component = () => {\n return (\n <Preview>\n <Preview.Code code={pythonCode} language=\"python\" />\n </Preview>\n );\n};\n\nexport default Component;\n"]}
1
+ {"version":3,"file":"preview-code-languages.story.js","sourceRoot":"","sources":["../../../../../src/ai/preview/stories/preview-code-languages.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAA8C;AAE9C,MAAM,UAAU,GAAG;;;;;iBAKF,CAAC;AAElB,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,uBAAC,YAAO,cACN,uBAAC,YAAO,CAAC,IAAI,IACX,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAC,QAAQ,EACjB,OAAO,EAAC,mCAAmC,GAC3C,GACM,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,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 '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Preview } from '@neo4j-ndl/react/ai';\n\nconst pythonCode = `def show_functions(username, function_type='ALL'):\n \"\"\"\n Show functions executable by user\n \"\"\"\n query = f\"SHOW {function_type} FUNCTIONS EXECUTABLE BY {username}\"\n return query`;\n\nconst Component = () => {\n return (\n <Preview>\n <Preview.Code\n code={pythonCode}\n language=\"python\"\n heading=\"Show functions executable by user\"\n />\n </Preview>\n );\n};\n\nexport default Component;\n"]}
@@ -25,11 +25,11 @@ require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
25
25
  const react_1 = require("@neo4j-ndl/react");
26
26
  const ai_1 = require("@neo4j-ndl/react/ai");
27
27
  const icons_1 = require("@neo4j-ndl/react/icons");
28
- const cypherCode = `SHOW [ALL|BUILT IN|USER DEFINED] FUNCTION[S] EXECUTABLE BY
29
- username
30
- [YIELD { * | field[, ...] } [ORDER BY field ...`;
28
+ const cypherCode = `MATCH (person:Person)-[:ACTED_IN]->(movie:Movie)
29
+ WHERE movie.released > 2000
30
+ RETURN person.name, movie.title`;
31
31
  const Component = () => {
32
- return ((0, jsx_runtime_1.jsx)(ai_1.Preview, { children: (0, jsx_runtime_1.jsx)(ai_1.Preview.Code, { code: cypherCode, language: "cypher", label: "write", headerActions: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.CleanIconButton, { variant: "neutral", description: "Send to Query", size: "small", children: (0, jsx_runtime_1.jsx)(icons_1.PencilSquareIconOutline, {}) }), (0, jsx_runtime_1.jsx)(react_1.CleanIconButton, { variant: "neutral", description: "Run in Query", size: "small", children: (0, jsx_runtime_1.jsx)(icons_1.PlayCircleIconOutline, {}) })] }) }) }));
32
+ return ((0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 400 }, children: (0, jsx_runtime_1.jsx)(ai_1.Preview, { children: (0, jsx_runtime_1.jsx)(ai_1.Preview.Code, { code: cypherCode, language: "cypher", heading: "Find all people who acted in movies released after the year 2000", headerActions: (0, jsx_runtime_1.jsx)(react_1.OutlinedButton, { leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.PencilSquareIconOutline, {}), variant: "neutral", size: "small", children: "Send to Query" }) }) }) }));
33
33
  };
34
34
  exports.default = Component;
35
- //# sourceMappingURL=preview-code-write.story.js.map
35
+ //# sourceMappingURL=preview-code-truncation.story.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-code-truncation.story.js","sourceRoot":"","sources":["../../../../../src/ai/preview/stories/preview-code-truncation.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAkD;AAClD,4CAA8C;AAC9C,kDAAiE;AAEjE,MAAM,UAAU,GAAG;;gCAEa,CAAC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,gCAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,YAC3B,uBAAC,YAAO,cACN,uBAAC,YAAO,CAAC,IAAI,IACX,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAC,QAAQ,EACjB,OAAO,EAAC,kEAAkE,EAC1E,aAAa,EACX,uBAAC,sBAAc,IACb,aAAa,EAAE,uBAAC,+BAAuB,KAAG,EAC1C,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,8BAGG,GAEnB,GACM,GACN,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,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 '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { OutlinedButton } from '@neo4j-ndl/react';\nimport { Preview } from '@neo4j-ndl/react/ai';\nimport { PencilSquareIconOutline } from '@neo4j-ndl/react/icons';\n\nconst cypherCode = `MATCH (person:Person)-[:ACTED_IN]->(movie:Movie)\nWHERE movie.released > 2000\nRETURN person.name, movie.title`;\n\nconst Component = () => {\n return (\n <div style={{ maxWidth: 400 }}>\n <Preview>\n <Preview.Code\n code={cypherCode}\n language=\"cypher\"\n heading=\"Find all people who acted in movies released after the year 2000\"\n headerActions={\n <OutlinedButton\n leadingVisual={<PencilSquareIconOutline />}\n variant=\"neutral\"\n size=\"small\"\n >\n Send to Query\n </OutlinedButton>\n }\n />\n </Preview>\n </div>\n );\n};\n\nexport default Component;\n"]}
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ *
4
+ * Copyright (c) "Neo4j"
5
+ * Neo4j Sweden AB [http://neo4j.com]
6
+ *
7
+ * This file is part of Neo4j.
8
+ *
9
+ * Neo4j is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ */
22
+ import classNames from 'classnames';
23
+ import { useEffect, useRef, useState } from 'react';
24
+ import { Tooltip } from '../tooltip';
25
+ const useIsTruncated = (text) => {
26
+ const ref = useRef(null);
27
+ const [isTruncated, setIsTruncated] = useState(false);
28
+ useEffect(() => {
29
+ const element = ref.current;
30
+ if (element === null) {
31
+ return;
32
+ }
33
+ // Reads inside the ResizeObserver callback are layout-synced and cheap;
34
+ // setState with an unchanged boolean does not trigger a re-render.
35
+ const check = () => setIsTruncated(element.scrollWidth > element.clientWidth);
36
+ check();
37
+ const observer = new ResizeObserver(check);
38
+ observer.observe(element);
39
+ return () => observer.disconnect();
40
+ }, [text]);
41
+ return [ref, isTruncated];
42
+ };
43
+ /**
44
+ * Internal component that renders single-line truncating text and, only while
45
+ * the text is actually clipped, shows a tooltip with the full text.
46
+ *
47
+ * Accessibility: the text element receives `tabIndex={0}` only while truncated,
48
+ * so sighted keyboard users can reveal the full text on focus without adding a
49
+ * dead tab stop otherwise. No button semantics are used since there is no
50
+ * action to perform. Screen readers always receive the full text from the
51
+ * element's own content, as CSS truncation is visual-only. The tooltip is
52
+ * dismissible with Escape and hoverable (WCAG 1.4.13).
53
+ *
54
+ * @internal - Not part of the public API.
55
+ */
56
+ export const TruncatedTextWithTooltip = ({ text, className, tooltipPlacement = 'top-start', }) => {
57
+ const [textRef, isTruncated] = useIsTruncated(text);
58
+ return (_jsxs(Tooltip, { type: "simple", placement: tooltipPlacement, isDisabled: !isTruncated, children: [_jsx(Tooltip.Trigger, { hasButtonWrapper: true, children: _jsx("span", Object.assign({ ref: textRef, className: classNames('ndl-truncated-text', className) }, (isTruncated && { tabIndex: 0 }), { children: text })) }), _jsx(Tooltip.Content, { children: text })] }));
59
+ };
60
+ //# sourceMappingURL=TruncatedTextWithTooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TruncatedTextWithTooltip.js","sourceRoot":"","sources":["../../../src/_common/TruncatedTextWithTooltip.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,cAAc,GAAG,CACrB,IAAY,EACkC,EAAE;IAChD,MAAM,GAAG,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEtD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC5B,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,wEAAwE;QACxE,mEAAmE;QACnE,MAAM,KAAK,GAAG,GAAG,EAAE,CACjB,cAAc,CAAC,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QAE5D,KAAK,EAAE,CAAC;QACR,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;QAC3C,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;AAC5B,CAAC,CAAC;AAWF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACvC,IAAI,EACJ,SAAS,EACT,gBAAgB,GAAG,WAAW,GACA,EAAE,EAAE;IAClC,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAEpD,OAAO,CACL,MAAC,OAAO,IACN,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,gBAAgB,EAC3B,UAAU,EAAE,CAAC,WAAW,aAExB,KAAC,OAAO,CAAC,OAAO,IAAC,gBAAgB,kBAC/B,6BACE,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,UAAU,CAAC,oBAAoB,EAAE,SAAS,CAAC,IAClD,CAAC,WAAW,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,cAEnC,IAAI,IACA,GACS,EAClB,KAAC,OAAO,CAAC,OAAO,cAAE,IAAI,GAAmB,IACjC,CACX,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport { type RefObject, useEffect, useRef, useState } from 'react';\n\nimport { Tooltip } from '../tooltip';\n\nconst useIsTruncated = (\n text: string,\n): [RefObject<HTMLSpanElement | null>, boolean] => {\n const ref = useRef<HTMLSpanElement>(null);\n const [isTruncated, setIsTruncated] = useState(false);\n\n useEffect(() => {\n const element = ref.current;\n if (element === null) {\n return;\n }\n\n // Reads inside the ResizeObserver callback are layout-synced and cheap;\n // setState with an unchanged boolean does not trigger a re-render.\n const check = () =>\n setIsTruncated(element.scrollWidth > element.clientWidth);\n\n check();\n const observer = new ResizeObserver(check);\n observer.observe(element);\n return () => observer.disconnect();\n }, [text]);\n\n return [ref, isTruncated];\n};\n\ntype TruncatedTextWithTooltipProps = {\n /** The text to display. Truncated with an ellipsis when space is limited. */\n text: string;\n /** Class name applied to the text element. Typography is inherited from the parent. */\n className?: string;\n /** Placement of the tooltip showing the full text. */\n tooltipPlacement?: React.ComponentProps<typeof Tooltip>['placement'];\n};\n\n/**\n * Internal component that renders single-line truncating text and, only while\n * the text is actually clipped, shows a tooltip with the full text.\n *\n * Accessibility: the text element receives `tabIndex={0}` only while truncated,\n * so sighted keyboard users can reveal the full text on focus without adding a\n * dead tab stop otherwise. No button semantics are used since there is no\n * action to perform. Screen readers always receive the full text from the\n * element's own content, as CSS truncation is visual-only. The tooltip is\n * dismissible with Escape and hoverable (WCAG 1.4.13).\n *\n * @internal - Not part of the public API.\n */\nexport const TruncatedTextWithTooltip = ({\n text,\n className,\n tooltipPlacement = 'top-start',\n}: TruncatedTextWithTooltipProps) => {\n const [textRef, isTruncated] = useIsTruncated(text);\n\n return (\n <Tooltip\n type=\"simple\"\n placement={tooltipPlacement}\n isDisabled={!isTruncated}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <span\n ref={textRef}\n className={classNames('ndl-truncated-text', className)}\n {...(isTruncated && { tabIndex: 0 })}\n >\n {text}\n </span>\n </Tooltip.Trigger>\n <Tooltip.Content>{text}</Tooltip.Content>\n </Tooltip>\n );\n};\n"]}
@@ -34,6 +34,7 @@ import { ClipboardButton, LoadingSpinner, StatusLabel, Typography, useNeedleThem
34
34
  import classNames from 'classnames';
35
35
  import { useEffect, useState } from 'react';
36
36
  import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';
37
+ import { TruncatedTextWithTooltip } from '../../_common/TruncatedTextWithTooltip';
37
38
  import { Languages, loadLanguage, } from '../../code-block/code-languages';
38
39
  import ndlCodeDark from '../../code-block/themes/ndl-code-dark';
39
40
  import ndlCodeLight from '../../code-block/themes/ndl-code-light';
@@ -50,7 +51,7 @@ const PreviewComponent = (_a) => {
50
51
  };
51
52
  const PreviewHeader = (_a) => {
52
53
  var { children, actions, ref, style, className, htmlAttributes } = _a, restProps = __rest(_a, ["children", "actions", "ref", "style", "className", "htmlAttributes"]);
53
- return (_jsxs("div", Object.assign({ ref: ref, style: style, className: classNames('ndl-ai-preview-header', className) }, restProps, htmlAttributes, { children: [_jsx(Typography, { variant: "code", as: "div", className: "ndl-ai-preview-header-leading-content", children: children }), actions && (_jsx("div", { className: "ndl-ai-preview-header-actions", children: actions }))] })));
54
+ return (_jsxs("div", Object.assign({ ref: ref, style: style, className: classNames('ndl-ai-preview-header', className) }, restProps, htmlAttributes, { children: [_jsx(Typography, { variant: "code", as: "div", className: "ndl-ai-preview-header-leading-content", children: typeof children === 'string' ? (_jsx(TruncatedTextWithTooltip, { text: children })) : (children) }), actions && (_jsx("div", { className: "ndl-ai-preview-header-actions", children: actions }))] })));
54
55
  };
55
56
  const PreviewConfirmation = (_a) => {
56
57
  var { children, actions, isFooter = false, status = 'pending', confirmedActionText = 'Action confirmed', rejectedActionText = 'Action rejected', ref, style, className, htmlAttributes } = _a, restProps = __rest(_a, ["children", "actions", "isFooter", "status", "confirmedActionText", "rejectedActionText", "ref", "style", "className", "htmlAttributes"]);
@@ -60,7 +61,7 @@ const PreviewConfirmation = (_a) => {
60
61
  return (_jsxs("div", Object.assign({ ref: ref, className: classes, style: style }, restProps, htmlAttributes, { children: [!(isFooter && status !== 'pending') && (_jsx(Typography, { as: "div", variant: isFooter ? 'subheading-small' : 'body-medium', className: "ndl-ai-preview-confirmation-content", children: children })), _jsxs(Typography, { variant: "body-medium", as: "div", className: "ndl-ai-preview-confirmation-actions", children: [status === 'pending' && actions, status === 'confirmed' && (_jsxs("div", { className: "ndl-ai-preview-confirmation-confirm-reject", children: [_jsx(CheckIconOutline, { className: "ndl-ai-preview-confirmation-action-icon" }), confirmedActionText] })), status === 'rejected' && (_jsxs("div", { className: "ndl-ai-preview-confirmation-confirm-reject", children: [_jsx(XMarkIconOutline, { className: "ndl-ai-preview-confirmation-action-icon" }), rejectedActionText] }))] })] })));
61
62
  };
62
63
  const PreviewCode = (_a) => {
63
- var { code, language, label, isLoading = false, headerActions, theme, ref, style, className, htmlAttributes } = _a, restProps = __rest(_a, ["code", "language", "label", "isLoading", "headerActions", "theme", "ref", "style", "className", "htmlAttributes"]);
64
+ var { code, language, label, isLoading = false, headerActions, theme, heading, ref, style, className, htmlAttributes } = _a, restProps = __rest(_a, ["code", "language", "label", "isLoading", "headerActions", "theme", "heading", "ref", "style", "className", "htmlAttributes"]);
64
65
  const [loadedLanguage, setLoadedLanguage] = useState(null);
65
66
  const { theme: ndlTheme } = useNeedleTheme();
66
67
  useEffect(() => {
@@ -85,7 +86,7 @@ const PreviewCode = (_a) => {
85
86
  return ndlTheme === 'light' ? ndlCodeLight : ndlCodeDark;
86
87
  }
87
88
  };
88
- return (_jsxs("div", Object.assign({ ref: ref, style: style, className: classNames('ndl-ai-preview-code', className) }, restProps, htmlAttributes, { children: [isLoading && (_jsxs("div", { className: "ndl-ai-preview-code-loading", children: [_jsx(LoadingSpinner, { size: "medium" }), _jsxs(Typography, { variant: "code", children: ["WRITING ", language.toUpperCase()] })] })), !isLoading && (_jsxs(_Fragment, { children: [_jsxs(PreviewHeader, { className: "ndl-ai-preview-code-header", actions: _jsxs(_Fragment, { children: [_jsx(ClipboardButton, { textToCopy: code, type: "clean-icon-button", size: "small" }), headerActions] }), children: [language, " ", language.toLowerCase() === 'cypher' ? 'QUERY' : '', label && (_jsx(StatusLabel, { variant: label === 'write' ? 'warning' : 'info', size: "small", fill: "semi-filled", children: label.toUpperCase() }))] }), _jsx("div", { className: "ndl-ai-preview-code-content", children: _jsx(SyntaxHighlighter, { language: loadedLanguage !== null && loadedLanguage !== void 0 ? loadedLanguage : 'text', style: Object.assign(Object.assign({}, getTheme()), { 'pre[class*="language-"]': {
89
+ return (_jsxs("div", Object.assign({ ref: ref, style: style, className: classNames('ndl-ai-preview-code', className) }, restProps, htmlAttributes, { children: [isLoading && (_jsxs("div", { className: "ndl-ai-preview-code-loading", children: [_jsx(LoadingSpinner, { size: "medium" }), _jsxs(Typography, { variant: "code", children: ["WRITING ", language.toUpperCase()] })] })), !isLoading && (_jsxs(_Fragment, { children: [_jsxs(PreviewHeader, { className: "ndl-ai-preview-code-header", actions: _jsxs(_Fragment, { children: [_jsx(ClipboardButton, { textToCopy: code, type: "clean-icon-button", size: "small" }), headerActions] }), children: [_jsx(TruncatedTextWithTooltip, { className: "ndl-ai-preview-code-header-heading", text: heading !== null && heading !== void 0 ? heading : `${language}${language.toLowerCase() === 'cypher' ? ' QUERY' : ''}` }), label && (_jsx(StatusLabel, { variant: label === 'write' ? 'warning' : 'info', size: "small", fill: "semi-filled", children: label.toUpperCase() }))] }), _jsx("div", { className: "ndl-ai-preview-code-content", children: _jsx(SyntaxHighlighter, { language: loadedLanguage !== null && loadedLanguage !== void 0 ? loadedLanguage : 'text', style: Object.assign(Object.assign({}, getTheme()), { 'pre[class*="language-"]': {
89
90
  border: 0,
90
91
  color: 'var(--theme-color-neutral-text-default)',
91
92
  lineHeight: '1',