@neo4j-ndl/react 4.18.9 → 4.18.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/_common/TruncatedTextWithTooltip.js +67 -0
- package/lib/cjs/_common/TruncatedTextWithTooltip.js.map +1 -0
- package/lib/cjs/ai/preview/Preview.js +4 -3
- package/lib/cjs/ai/preview/Preview.js.map +1 -1
- package/lib/cjs/ai/preview/stories/index.js +9 -9
- package/lib/cjs/ai/preview/stories/index.js.map +1 -1
- package/lib/cjs/ai/preview/stories/preview-code-confirmation.story.js +1 -1
- package/lib/cjs/ai/preview/stories/preview-code-confirmation.story.js.map +1 -1
- package/lib/cjs/ai/preview/stories/{preview-code-read.story.js → preview-code-cypher.story.js} +2 -2
- package/lib/cjs/ai/preview/stories/preview-code-cypher.story.js.map +1 -0
- package/lib/cjs/ai/preview/stories/preview-code-languages.story.js +1 -1
- package/lib/cjs/ai/preview/stories/preview-code-languages.story.js.map +1 -1
- package/lib/cjs/ai/preview/stories/{preview-code-write.story.js → preview-code-truncation.story.js} +5 -5
- package/lib/cjs/ai/preview/stories/preview-code-truncation.story.js.map +1 -0
- package/lib/cjs/menu/Menu.js +10 -1
- package/lib/cjs/menu/Menu.js.map +1 -1
- package/lib/cjs/menu/stories/menu-custom-items.story.js +1 -1
- package/lib/cjs/menu/stories/menu-custom-items.story.js.map +1 -1
- package/lib/cjs/menu/stories/menu-default.story.js +1 -1
- package/lib/cjs/menu/stories/menu-default.story.js.map +1 -1
- package/lib/cjs/menu/stories/menu-in-dialog.story.js +1 -1
- package/lib/cjs/menu/stories/menu-in-dialog.story.js.map +1 -1
- package/lib/cjs/menu/stories/menu-in-popover.story.js +1 -1
- package/lib/cjs/menu/stories/menu-in-popover.story.js.map +1 -1
- package/lib/cjs/menu/stories/menu-nested.story.js +1 -1
- package/lib/cjs/menu/stories/menu-nested.story.js.map +1 -1
- package/lib/cjs/menu/stories/menu-placements.story.js +1 -1
- package/lib/cjs/menu/stories/menu-placements.story.js.map +1 -1
- package/lib/cjs/menu/stories/menu-with-category.story.js +1 -1
- package/lib/cjs/menu/stories/menu-with-category.story.js.map +1 -1
- package/lib/cjs/menu/stories/menu-with-disabled-item.story.js +1 -1
- package/lib/cjs/menu/stories/menu-with-disabled-item.story.js.map +1 -1
- package/lib/cjs/menu/stories/menu-with-divider.story.js +1 -1
- package/lib/cjs/menu/stories/menu-with-divider.story.js.map +1 -1
- package/lib/cjs/menu/stories/menu-with-icon.story.js +1 -1
- package/lib/cjs/menu/stories/menu-with-icon.story.js.map +1 -1
- package/lib/cjs/menu/stories/menu-with-keyboard-shortcuts.story.js +1 -1
- package/lib/cjs/menu/stories/menu-with-keyboard-shortcuts.story.js.map +1 -1
- package/lib/esm/_common/TruncatedTextWithTooltip.js +60 -0
- package/lib/esm/_common/TruncatedTextWithTooltip.js.map +1 -0
- package/lib/esm/ai/preview/Preview.js +4 -3
- package/lib/esm/ai/preview/Preview.js.map +1 -1
- package/lib/esm/ai/preview/stories/index.js +6 -6
- package/lib/esm/ai/preview/stories/index.js.map +1 -1
- package/lib/esm/ai/preview/stories/preview-code-confirmation.story.js +1 -1
- package/lib/esm/ai/preview/stories/preview-code-confirmation.story.js.map +1 -1
- package/lib/esm/ai/preview/stories/{preview-code-read.story.js → preview-code-cypher.story.js} +2 -2
- package/lib/esm/ai/preview/stories/preview-code-cypher.story.js.map +1 -0
- package/lib/esm/ai/preview/stories/preview-code-languages.story.js +1 -1
- package/lib/esm/ai/preview/stories/preview-code-languages.story.js.map +1 -1
- package/lib/esm/ai/preview/stories/{preview-code-write.story.js → preview-code-truncation.story.js} +8 -8
- package/lib/esm/ai/preview/stories/preview-code-truncation.story.js.map +1 -0
- package/lib/esm/menu/Menu.js +11 -2
- package/lib/esm/menu/Menu.js.map +1 -1
- package/lib/esm/menu/stories/menu-custom-items.story.js +2 -2
- package/lib/esm/menu/stories/menu-custom-items.story.js.map +1 -1
- package/lib/esm/menu/stories/menu-default.story.js +2 -2
- package/lib/esm/menu/stories/menu-default.story.js.map +1 -1
- package/lib/esm/menu/stories/menu-in-dialog.story.js +2 -2
- package/lib/esm/menu/stories/menu-in-dialog.story.js.map +1 -1
- package/lib/esm/menu/stories/menu-in-popover.story.js +2 -2
- package/lib/esm/menu/stories/menu-in-popover.story.js.map +1 -1
- package/lib/esm/menu/stories/menu-nested.story.js +2 -2
- package/lib/esm/menu/stories/menu-nested.story.js.map +1 -1
- package/lib/esm/menu/stories/menu-placements.story.js +2 -2
- package/lib/esm/menu/stories/menu-placements.story.js.map +1 -1
- package/lib/esm/menu/stories/menu-with-category.story.js +2 -2
- package/lib/esm/menu/stories/menu-with-category.story.js.map +1 -1
- package/lib/esm/menu/stories/menu-with-disabled-item.story.js +2 -2
- package/lib/esm/menu/stories/menu-with-disabled-item.story.js.map +1 -1
- package/lib/esm/menu/stories/menu-with-divider.story.js +2 -2
- package/lib/esm/menu/stories/menu-with-divider.story.js.map +1 -1
- package/lib/esm/menu/stories/menu-with-icon.story.js +2 -2
- package/lib/esm/menu/stories/menu-with-icon.story.js.map +1 -1
- package/lib/esm/menu/stories/menu-with-keyboard-shortcuts.story.js +2 -2
- package/lib/esm/menu/stories/menu-with-keyboard-shortcuts.story.js.map +1 -1
- package/lib/types/_common/TruncatedTextWithTooltip.d.ts +46 -0
- package/lib/types/_common/TruncatedTextWithTooltip.d.ts.map +1 -0
- package/lib/types/ai/preview/Preview.d.ts +8 -2
- package/lib/types/ai/preview/Preview.d.ts.map +1 -1
- package/lib/types/ai/preview/stories/index.d.ts +4 -4
- package/lib/types/ai/preview/stories/index.d.ts.map +1 -1
- package/lib/types/ai/preview/stories/{preview-code-write.story.d.ts → preview-code-cypher.story.d.ts} +1 -1
- package/lib/types/ai/preview/stories/preview-code-cypher.story.d.ts.map +1 -0
- package/lib/types/ai/preview/stories/preview-code-languages.story.d.ts.map +1 -1
- package/lib/types/ai/preview/stories/{preview-code-read.story.d.ts → preview-code-truncation.story.d.ts} +1 -1
- package/lib/types/ai/preview/stories/preview-code-truncation.story.d.ts.map +1 -0
- package/lib/types/menu/Menu.d.ts.map +1 -1
- package/package.json +2 -2
- package/skills/ndl-react/SKILL.md +1 -1
- package/skills/ndl-react/components/ai/preview.md +86 -66
- package/skills/ndl-react/components/ai/user-bubble.md +1 -12
- package/skills/ndl-react/components/breadcrumbs.md +2 -2
- package/skills/ndl-react/components/data-grid.md +22 -0
- package/skills/ndl-react/components/menu.md +46 -46
- package/lib/cjs/ai/preview/stories/preview-code-read.story.js.map +0 -1
- package/lib/cjs/ai/preview/stories/preview-code-write.story.js.map +0 -1
- package/lib/esm/ai/preview/stories/preview-code-read.story.js.map +0 -1
- package/lib/esm/ai/preview/stories/preview-code-write.story.js.map +0 -1
- package/lib/types/ai/preview/stories/preview-code-read.story.d.ts.map +0 -1
- package/lib/types/ai/preview/stories/preview-code-write.story.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-with-icon.story.js","sourceRoot":"","sources":["../../../../src/menu/stories/menu-with-icon.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,
|
|
1
|
+
{"version":3,"file":"menu-with-icon.story.js","sourceRoot":"","sources":["../../../../src/menu/stories/menu-with-icon.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAwD;AACxD,kDAA2E;AAC3E,iCAAyC;AAEzC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,QAAQ,GAAG,IAAA,cAAM,EAA2B,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAE5C,OAAO,CACL,6DACE,wBAAC,YAAI,IACH,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,QAAQ,EACnB,OAAO,EAAE,CAAC,MAA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,EAClC,KAAK,EAAC,UAAU,EAChB,WAAW,EAAC,qBAAqB,EACjC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,GAC/B,IACG,EACP,uBAAC,sBAAc,IACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAC9B,GAAG,EAAE,QAAQ,mBACC,MAAM,0BAGL,IAChB,CACJ,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 { DropdownButton, Menu } from '@neo4j-ndl/react';\nimport { PhotoIconOutline, PlusIconOutline } from '@neo4j-ndl/react/icons';\nimport { useRef, useState } from 'react';\n\nconst Component = () => {\n const anchorEl = useRef<HTMLButtonElement | null>(null);\n const [isOpen, setIsOpen] = useState(false);\n\n return (\n <>\n <Menu\n isOpen={isOpen}\n anchorRef={anchorEl}\n onClose={(_event, _data) => {\n setIsOpen(false);\n }}\n htmlAttributes={{ id: 'icon-menu' }}\n >\n <Menu.Item\n leadingVisual={<PlusIconOutline />}\n title=\"Action 1\"\n onClick={() => alert('Action1')}\n />\n <Menu.Item\n leadingVisual={<PlusIconOutline />}\n title=\"Action 2\"\n onClick={() => alert('Action2')}\n />\n <Menu.Item\n leadingVisual={<PlusIconOutline />}\n title=\"Action 3\"\n description=\"Action 3 is disabled\"\n isDisabled={true}\n onClick={() => alert('Action3')}\n />\n <Menu\n title=\"Action 3.1\"\n description=\"Action with sub menu\"\n icon={<PlusIconOutline />}\n >\n <Menu.Item title=\"Text\" />\n <Menu.Item title=\"Video\" />\n <Menu title=\"Image\" icon={<PhotoIconOutline />}>\n <Menu.Item title=\".png\" />\n <Menu.Item title=\".jpg\" />\n </Menu>\n <Menu.Item title=\"Audio\" />\n </Menu>\n <Menu.Item\n leadingVisual={<PlusIconOutline />}\n title=\"Action 4\"\n description=\"Action 4 is awesome\"\n onClick={() => alert('Action4')}\n />\n </Menu>\n <DropdownButton\n isOpen={isOpen}\n onClick={() => setIsOpen(true)}\n ref={anchorEl}\n aria-haspopup=\"menu\"\n >\n Open Menu\n </DropdownButton>\n </>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -30,7 +30,7 @@ const Component = () => {
|
|
|
30
30
|
const [isOpen, setIsOpen] = (0, react_2.useState)(false);
|
|
31
31
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_1.Menu, { isOpen: isOpen, anchorRef: anchorEl, onClose: (_event, _data) => {
|
|
32
32
|
setIsOpen(false);
|
|
33
|
-
}, htmlAttributes: { id: 'keyboard-shortcuts-menu' }, children: [(0, jsx_runtime_1.jsx)(react_1.Menu.Item, { leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.PlusIconOutline, {}), title: "Action 1", onClick: () => alert('Action1') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.PlusIconOutline, {}), trailingContent: (0, jsx_runtime_1.jsx)(react_1.Kbd, { keys: ['A', ['B']] }), title: "Action 2", description: "Action 4 has a keyboard shortcut", onClick: () => alert('Action4') })] }), (0, jsx_runtime_1.jsx)(react_1.
|
|
33
|
+
}, htmlAttributes: { id: 'keyboard-shortcuts-menu' }, children: [(0, jsx_runtime_1.jsx)(react_1.Menu.Item, { leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.PlusIconOutline, {}), title: "Action 1", onClick: () => alert('Action1') }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { leadingVisual: (0, jsx_runtime_1.jsx)(icons_1.PlusIconOutline, {}), trailingContent: (0, jsx_runtime_1.jsx)(react_1.Kbd, { keys: ['A', ['B']] }), title: "Action 2", description: "Action 4 has a keyboard shortcut", onClick: () => alert('Action4') })] }), (0, jsx_runtime_1.jsx)(react_1.DropdownButton, { isOpen: isOpen, onClick: () => setIsOpen(true), ref: anchorEl, "aria-haspopup": "menu", children: "Open Menu" })] }));
|
|
34
34
|
};
|
|
35
35
|
exports.default = Component;
|
|
36
36
|
//# sourceMappingURL=menu-with-keyboard-shortcuts.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-with-keyboard-shortcuts.story.js","sourceRoot":"","sources":["../../../../src/menu/stories/menu-with-keyboard-shortcuts.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,
|
|
1
|
+
{"version":3,"file":"menu-with-keyboard-shortcuts.story.js","sourceRoot":"","sources":["../../../../src/menu/stories/menu-with-keyboard-shortcuts.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAA6D;AAC7D,kDAAyD;AACzD,iCAAyC;AAEzC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,QAAQ,GAAG,IAAA,cAAM,EAA2B,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAE5C,OAAO,CACL,6DACE,wBAAC,YAAI,IACH,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,QAAQ,EACnB,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;oBACzB,SAAS,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC,EACD,cAAc,EAAE,EAAE,EAAE,EAAE,yBAAyB,EAAE,aAEjD,uBAAC,YAAI,CAAC,IAAI,IACR,aAAa,EAAE,uBAAC,uBAAe,KAAG,EAClC,KAAK,EAAC,UAAU,EAChB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,GAC/B,EACF,uBAAC,YAAI,CAAC,IAAI,IACR,aAAa,EAAE,uBAAC,uBAAe,KAAG,EAClC,eAAe,EAAE,uBAAC,WAAG,IAAC,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAI,EAC5C,KAAK,EAAC,UAAU,EAChB,WAAW,EAAC,kCAAkC,EAC9C,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,GAC/B,IACG,EACP,uBAAC,sBAAc,IACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAC9B,GAAG,EAAE,QAAQ,mBACC,MAAM,0BAGL,IAChB,CACJ,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 { DropdownButton, Kbd, Menu } from '@neo4j-ndl/react';\nimport { PlusIconOutline } from '@neo4j-ndl/react/icons';\nimport { useRef, useState } from 'react';\n\nconst Component = () => {\n const anchorEl = useRef<HTMLButtonElement | null>(null);\n const [isOpen, setIsOpen] = useState(false);\n\n return (\n <>\n <Menu\n isOpen={isOpen}\n anchorRef={anchorEl}\n onClose={(_event, _data) => {\n setIsOpen(false);\n }}\n htmlAttributes={{ id: 'keyboard-shortcuts-menu' }}\n >\n <Menu.Item\n leadingVisual={<PlusIconOutline />}\n title=\"Action 1\"\n onClick={() => alert('Action1')}\n />\n <Menu.Item\n leadingVisual={<PlusIconOutline />}\n trailingContent={<Kbd keys={['A', ['B']]} />}\n title=\"Action 2\"\n description=\"Action 4 has a keyboard shortcut\"\n onClick={() => alert('Action4')}\n />\n </Menu>\n <DropdownButton\n isOpen={isOpen}\n onClick={() => setIsOpen(true)}\n ref={anchorEl}\n aria-haspopup=\"menu\"\n >\n Open Menu\n </DropdownButton>\n </>\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: [
|
|
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',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Preview.js","sourceRoot":"","sources":["../../../../src/ai/preview/Preview.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,eAAe,EAEf,cAAc,EACd,WAAW,EACX,UAAU,EACV,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,UAAU,IA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EAOkB,EAAE,EAAE;QAPtB,EACtB,QAAQ,EACR,GAAG,EACH,KAAK,EACL,SAAS,EACT,cAAc,OAE0B,EADrC,SAAS,cANU,2DAOvB,CADa;IAEZ,OAAO,CACL,4BACE,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,UAAU,CAAC,wBAAwB,EAAE,SAAS,CAAC,IACtD,SAAS,EACT,cAAc,cAEjB,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,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;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,eAAe,EAEf,cAAc,EACd,WAAW,EACX,UAAU,EACV,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAElF,OAAO,EAEL,SAAS,EACT,YAAY,GACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,WAAW,MAAM,uCAAuC,CAAC;AAChE,OAAO,YAAY,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAMpF;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,CAAC,EAOS,EAAE,EAAE;QAPb,EACxB,QAAQ,EACR,GAAG,EACH,KAAK,EACL,SAAS,EACT,cAAc,OAEmB,EAD9B,SAAS,cANY,2DAOzB,CADa;IAEZ,OAAO,CACL,4BACE,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,IAC9C,SAAS,EACT,cAAc,cAEjB,QAAQ,IACL,CACP,CAAC;AACJ,CAA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;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"]}
|
|
@@ -22,17 +22,17 @@ export { default as PreviewDataGrid } from './preview-data-grid.story';
|
|
|
22
22
|
export { default as PreviewConfirmationStandalone } from './preview-confirmation-standalone.story';
|
|
23
23
|
export { default as PreviewCodeConfirmation } from './preview-code-confirmation.story';
|
|
24
24
|
export { default as PreviewCodeLoading } from './preview-code-loading.story';
|
|
25
|
-
export { default as PreviewCodeRead } from './preview-code-read.story';
|
|
26
|
-
export { default as PreviewCodeWrite } from './preview-code-write.story';
|
|
27
25
|
export { default as PreviewCodeLanguages } from './preview-code-languages.story';
|
|
28
26
|
export { default as PreviewSimple } from './preview-simple.story';
|
|
29
27
|
export { default as PreviewSimpleWithContent } from './preview-simple-with-content.story';
|
|
28
|
+
export { default as PreviewCodeCypher } from './preview-code-cypher.story';
|
|
29
|
+
export { default as PreviewCodeTruncation } from './preview-code-truncation.story';
|
|
30
30
|
import { removeLicenseHeader } from '../../../_common/export-stories-utils';
|
|
31
31
|
import PreviewCodeConfirmationSrcRaw from './preview-code-confirmation.story?raw';
|
|
32
|
+
import PreviewCodeCypherSrcRaw from './preview-code-cypher.story?raw';
|
|
32
33
|
import PreviewCodeLanguagesSrcRaw from './preview-code-languages.story?raw';
|
|
33
34
|
import PreviewCodeLoadingSrcRaw from './preview-code-loading.story?raw';
|
|
34
|
-
import
|
|
35
|
-
import PreviewCodeWriteSrcRaw from './preview-code-write.story?raw';
|
|
35
|
+
import PreviewCodeTruncationSrcRaw from './preview-code-truncation.story?raw';
|
|
36
36
|
import PreviewConfirmationStandaloneSrcRaw from './preview-confirmation-standalone.story?raw';
|
|
37
37
|
import PreviewDataGridSrcRaw from './preview-data-grid.story?raw';
|
|
38
38
|
import PreviewSimpleSrcRaw from './preview-simple.story?raw';
|
|
@@ -41,9 +41,9 @@ export const PreviewDataGridSrc = removeLicenseHeader(PreviewDataGridSrcRaw);
|
|
|
41
41
|
export const PreviewConfirmationStandaloneSrc = removeLicenseHeader(PreviewConfirmationStandaloneSrcRaw);
|
|
42
42
|
export const PreviewCodeConfirmationSrc = removeLicenseHeader(PreviewCodeConfirmationSrcRaw);
|
|
43
43
|
export const PreviewCodeLoadingSrc = removeLicenseHeader(PreviewCodeLoadingSrcRaw);
|
|
44
|
-
export const PreviewCodeReadSrc = removeLicenseHeader(PreviewCodeReadSrcRaw);
|
|
45
|
-
export const PreviewCodeWriteSrc = removeLicenseHeader(PreviewCodeWriteSrcRaw);
|
|
46
44
|
export const PreviewCodeLanguagesSrc = removeLicenseHeader(PreviewCodeLanguagesSrcRaw);
|
|
45
|
+
export const PreviewCodeCypherSrc = removeLicenseHeader(PreviewCodeCypherSrcRaw);
|
|
46
|
+
export const PreviewCodeTruncationSrc = removeLicenseHeader(PreviewCodeTruncationSrcRaw);
|
|
47
47
|
export const PreviewSimpleSrc = removeLicenseHeader(PreviewSimpleSrcRaw);
|
|
48
48
|
export const PreviewSimpleWithContentSrc = removeLicenseHeader(PreviewSimpleWithContentSrcRaw);
|
|
49
49
|
//# 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,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACnG,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,
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AAgC,GAAG,mBAAmB,CACjE,mCAAmC,CACpC,CAAC;AACF,MAAM,CAAC,MAAM,0BAA0B,GAAG,mBAAmB,CAC3D,6BAA6B,CAC9B,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CACtD,wBAAwB,CACzB,CAAC;AACF,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CACxD,0BAA0B,CAC3B,CAAC;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CACrD,uBAAuB,CACxB,CAAC;AACF,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CACzD,2BAA2B,CAC5B,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;AACzE,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAC5D,8BAA8B,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 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"]}
|
|
@@ -28,7 +28,7 @@ username
|
|
|
28
28
|
[YIELD { * | field[, ...] } [ORDER BY field ...`;
|
|
29
29
|
const Component = () => {
|
|
30
30
|
const [status, setStatus] = useState('pending');
|
|
31
|
-
return (_jsxs(Preview, { children: [_jsx(Preview.Code, { code: cypherCode, language: "cypher",
|
|
31
|
+
return (_jsxs(Preview, { children: [_jsx(Preview.Code, { code: cypherCode, language: "cypher", heading: "Show functions executable by user", isLoading: false, headerActions: null }), _jsx(Preview.Confirmation, { status: status, isFooter: true, confirmedActionText: "Action confirmed", rejectedActionText: "Action rejected", actions: _jsxs(_Fragment, { children: [_jsx(OutlinedButton, { variant: "neutral", size: "small", onClick: () => setStatus('rejected'), children: "Skip" }), _jsx(FilledButton, { variant: "primary", size: "small", onClick: () => setStatus('confirmed'), children: "Run query" })] }), children: "Assistant wants to run this query" })] }));
|
|
32
32
|
};
|
|
33
33
|
export default Component;
|
|
34
34
|
//# 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,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,UAAU,GAAG;;gDAE6B,CAAC;AAEjD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACvB,QAAQ,CACN,SAAS,CACV,CAAC;IAEJ,OAAO,CACL,MAAC,OAAO,eACN,KAAC,OAAO,CAAC,IAAI,IACX,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAC,QAAQ,EACjB,
|
|
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,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,UAAU,GAAG;;gDAE6B,CAAC;AAEjD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACvB,QAAQ,CACN,SAAS,CACV,CAAC;IAEJ,OAAO,CACL,MAAC,OAAO,eACN,KAAC,OAAO,CAAC,IAAI,IACX,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAC,QAAQ,EACjB,OAAO,EAAC,mCAAmC,EAC3C,SAAS,EAAE,KAAK,EAChB,aAAa,EAAE,IAAI,GACnB,EACF,KAAC,OAAO,CAAC,YAAY,IACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,IAAI,EACd,mBAAmB,EAAC,kBAAkB,EACtC,kBAAkB,EAAC,iBAAiB,EACpC,OAAO,EACL,8BACE,KAAC,cAAc,IACb,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,qBAGrB,EACjB,KAAC,YAAY,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,eAAe,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"]}
|
package/lib/esm/ai/preview/stories/{preview-code-read.story.js → preview-code-cypher.story.js}
RENAMED
|
@@ -27,7 +27,7 @@ const cypherCode = `SHOW [ALL|BUILT IN|USER DEFINED] FUNCTION[S] EXECUTABLE BY
|
|
|
27
27
|
username
|
|
28
28
|
[YIELD { * | field[, ...] } [ORDER BY field ...`;
|
|
29
29
|
const Component = () => {
|
|
30
|
-
return (_jsx(Preview, { children: _jsx(Preview.Code, { code: cypherCode, language: "cypher",
|
|
30
|
+
return (_jsx(Preview, { children: _jsx(Preview.Code, { code: cypherCode, language: "cypher", heading: "Show functions executable by user", headerActions: _jsx(OutlinedButton, { leadingVisual: _jsx(PencilSquareIconOutline, {}), variant: "neutral", size: "small", children: "Send to Query" }) }) }));
|
|
31
31
|
};
|
|
32
32
|
export default Component;
|
|
33
|
-
//# sourceMappingURL=preview-code-
|
|
33
|
+
//# 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,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,UAAU,GAAG;;gDAE6B,CAAC;AAEjD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,KAAC,OAAO,cACN,KAAC,OAAO,CAAC,IAAI,IACX,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAC,QAAQ,EACjB,OAAO,EAAC,mCAAmC,EAC3C,aAAa,EACX,KAAC,cAAc,IACb,aAAa,EAAE,KAAC,uBAAuB,KAAG,EAC1C,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,8BAGG,GAEnB,GACM,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,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"]}
|
|
@@ -28,7 +28,7 @@ const pythonCode = `def show_functions(username, function_type='ALL'):
|
|
|
28
28
|
query = f"SHOW {function_type} FUNCTIONS EXECUTABLE BY {username}"
|
|
29
29
|
return query`;
|
|
30
30
|
const Component = () => {
|
|
31
|
-
return (_jsx(Preview, { children: _jsx(Preview.Code, { code: pythonCode, language: "python" }) }));
|
|
31
|
+
return (_jsx(Preview, { children: _jsx(Preview.Code, { code: pythonCode, language: "python", heading: "Show functions executable by user" }) }));
|
|
32
32
|
};
|
|
33
33
|
export default Component;
|
|
34
34
|
//# 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,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,UAAU,GAAG;;;;;iBAKF,CAAC;AAElB,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,KAAC,OAAO,cACN,KAAC,OAAO,CAAC,IAAI,
|
|
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,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,UAAU,GAAG;;;;;iBAKF,CAAC;AAElB,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,KAAC,OAAO,cACN,KAAC,OAAO,CAAC,IAAI,IACX,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAC,QAAQ,EACjB,OAAO,EAAC,mCAAmC,GAC3C,GACM,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,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"]}
|
package/lib/esm/ai/preview/stories/{preview-code-write.story.js → preview-code-truncation.story.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) "Neo4j"
|
|
@@ -20,14 +20,14 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
20
20
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
21
|
*/
|
|
22
22
|
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
23
|
-
import {
|
|
23
|
+
import { OutlinedButton } from '@neo4j-ndl/react';
|
|
24
24
|
import { Preview } from '@neo4j-ndl/react/ai';
|
|
25
|
-
import { PencilSquareIconOutline
|
|
26
|
-
const cypherCode = `
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
import { PencilSquareIconOutline } from '@neo4j-ndl/react/icons';
|
|
26
|
+
const cypherCode = `MATCH (person:Person)-[:ACTED_IN]->(movie:Movie)
|
|
27
|
+
WHERE movie.released > 2000
|
|
28
|
+
RETURN person.name, movie.title`;
|
|
29
29
|
const Component = () => {
|
|
30
|
-
return (_jsx(Preview, { children: _jsx(Preview.Code, { code: cypherCode, language: "cypher",
|
|
30
|
+
return (_jsx("div", { style: { maxWidth: 400 }, children: _jsx(Preview, { children: _jsx(Preview.Code, { code: cypherCode, language: "cypher", heading: "Find all people who acted in movies released after the year 2000", headerActions: _jsx(OutlinedButton, { leadingVisual: _jsx(PencilSquareIconOutline, {}), variant: "neutral", size: "small", children: "Send to Query" }) }) }) }));
|
|
31
31
|
};
|
|
32
32
|
export default Component;
|
|
33
|
-
//# sourceMappingURL=preview-code-
|
|
33
|
+
//# 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,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,UAAU,GAAG;;gCAEa,CAAC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,cAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,YAC3B,KAAC,OAAO,cACN,KAAC,OAAO,CAAC,IAAI,IACX,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAC,QAAQ,EACjB,OAAO,EAAC,kEAAkE,EAC1E,aAAa,EACX,KAAC,cAAc,IACb,aAAa,EAAE,KAAC,uBAAuB,KAAG,EAC1C,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,8BAGG,GAEnB,GACM,GACN,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,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"]}
|
package/lib/esm/menu/Menu.js
CHANGED
|
@@ -32,7 +32,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
32
32
|
*/
|
|
33
33
|
import { autoUpdate, flip, FloatingFocusManager, FloatingList, FloatingNode, FloatingPortal, FloatingTree, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useHover, useInteractions, useListItem, useListNavigation, useMergeRefs, useRole, useTypeahead, } from '@floating-ui/react';
|
|
34
34
|
import classNames from 'classnames';
|
|
35
|
-
import { createContext, useCallback, useContext, useEffect, useId, useRef, useState, } from 'react';
|
|
35
|
+
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useRef, useState, } from 'react';
|
|
36
36
|
import { ConditionalWrap } from '../conditional-wrap';
|
|
37
37
|
import { useIsInsideDialog } from '../dialog/dialog-context';
|
|
38
38
|
import { Divider } from '../divider';
|
|
@@ -84,6 +84,15 @@ const MenuComponent = ({ children, isOpen: controlledOpen, onClose, isRoot, anch
|
|
|
84
84
|
setActiveIndex(0);
|
|
85
85
|
}
|
|
86
86
|
}, [isOpen]);
|
|
87
|
+
// Unmounting is deferred by one pre-paint commit so that anything an item's
|
|
88
|
+
// action focused (e.g. an autofocused input mounted by onClick) is already
|
|
89
|
+
// the active element when the focus manager cleans up. floating-ui then
|
|
90
|
+
// respects the moved focus instead of returning it to the trigger.
|
|
91
|
+
// See https://github.com/floating-ui/floating-ui/issues/2607
|
|
92
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
93
|
+
useLayoutEffect(() => {
|
|
94
|
+
setIsMounted(isOpen);
|
|
95
|
+
}, [isOpen]);
|
|
87
96
|
// A single interaction can reach us twice, since floating-ui's focus manager
|
|
88
97
|
// reports a focus-out after a dismissal without checking whether the menu is
|
|
89
98
|
// still open. Ignoring an already closed menu keeps `onClose` to one call.
|
|
@@ -241,7 +250,7 @@ const MenuComponent = ({ children, isOpen: controlledOpen, onClose, isRoot, anch
|
|
|
241
250
|
isOpen: isDisabled === true ? false : isOpen,
|
|
242
251
|
setActiveIndex,
|
|
243
252
|
setHasFocusInside,
|
|
244
|
-
}, children: _jsx(FloatingList, { elementsRef: elementsRef, labelsRef: labelsRef, children: isOpen && (_jsx(ConditionalWrap, { shouldWrap: isPortaled, wrap: (wrapChildren) => (_jsx(FloatingPortal, { root: portalTarget, children: wrapChildren })), children: _jsx(FloatingFocusManager, { context: context, modal: false, initialFocus: 0, returnFocus: !isNested, closeOnFocusOut: true, guards: true, children: _jsx(Component, Object.assign({ ref: refs.setFloating, className: menuClasses, style: Object.assign(Object.assign({ minWidth: minWidth !== undefined ? `${minWidth}px` : undefined }, floatingStyles), style) }, getFloatingProps({
|
|
253
|
+
}, children: _jsx(FloatingList, { elementsRef: elementsRef, labelsRef: labelsRef, children: (isOpen || isMounted) && (_jsx(ConditionalWrap, { shouldWrap: isPortaled, wrap: (wrapChildren) => (_jsx(FloatingPortal, { root: portalTarget, children: wrapChildren })), children: _jsx(FloatingFocusManager, { context: context, modal: false, initialFocus: 0, returnFocus: !isNested, closeOnFocusOut: true, guards: true, children: _jsx(Component, Object.assign({ ref: refs.setFloating, className: menuClasses, style: Object.assign(Object.assign({ minWidth: minWidth !== undefined ? `${minWidth}px` : undefined }, floatingStyles), style) }, getFloatingProps({
|
|
245
254
|
onKeyDown: handleFloatingKeyDown,
|
|
246
255
|
}), { children: children })) }) })) }) })] }));
|
|
247
256
|
};
|