@neo4j-ndl/react 4.9.40 → 4.9.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/ai/prompt/Prompt.js +2 -2
- package/lib/cjs/ai/prompt/Prompt.js.map +1 -1
- package/lib/cjs/ai/prompt/stories/prompt-default.story.js +6 -4
- package/lib/cjs/ai/prompt/stories/prompt-default.story.js.map +1 -1
- package/lib/cjs/ai/prompt/stories/prompt-loading.story.js +5 -3
- package/lib/cjs/ai/prompt/stories/prompt-loading.story.js.map +1 -1
- package/lib/esm/ai/prompt/Prompt.js +2 -2
- package/lib/esm/ai/prompt/Prompt.js.map +1 -1
- package/lib/esm/ai/prompt/stories/prompt-default.story.js +3 -1
- package/lib/esm/ai/prompt/stories/prompt-default.story.js.map +1 -1
- package/lib/esm/ai/prompt/stories/prompt-loading.story.js +3 -1
- package/lib/esm/ai/prompt/stories/prompt-loading.story.js.map +1 -1
- package/lib/types/ai/prompt/stories/prompt-default.story.d.ts.map +1 -1
- package/lib/types/ai/prompt/stories/prompt-loading.story.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -109,11 +109,11 @@ const PromptComponent = (_a) => {
|
|
|
109
109
|
const maxHeight = lineHeight * maxRows;
|
|
110
110
|
if (ta.scrollHeight <= maxHeight) {
|
|
111
111
|
ta.style.overflowY = 'hidden';
|
|
112
|
-
ta.style.height = `${ta.scrollHeight}px`;
|
|
112
|
+
ta.style.height = `${ta.scrollHeight + 12}px`;
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
115
|
ta.style.overflowY = 'auto';
|
|
116
|
-
ta.style.height = `${maxHeight}px`;
|
|
116
|
+
ta.style.height = `${maxHeight + 12}px`;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}, [lineHeight, maxRows]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prompt.js","sourceRoot":"","sources":["../../../../src/ai/prompt/Prompt.tsx"],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AAC,EACD,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,aAEnC,uBAAC,eAAO,CAAC,OAAO,IAAC,gBAAgB,kBAC/B,iCAAK,SAAS,EAAC,2BAA2B,aACxC,uBAAC,qBAAa,IAAC,SAAS,EAAC,gCAAgC,GAAG,EAC5D,uBAAC,kBAAU,IACT,OAAO,EAAC,aAAa,EACrB,SAAS,EAAC,gCAAgC,EAC1C,GAAG,EAAE,OAAO,YAEX,QAAQ,GACE,EAEb,mCACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,gBACJ,mBAAmB,QAAQ,EAAE,EACzC,SAAS,EAAC,wCAAwC,YAElD,uBAAC,wBAAgB,IAAC,SAAS,EAAC,gCAAgC,GAAG,GACxD,IACL,GACU,EAClB,uBAAC,eAAO,CAAC,OAAO,cAAE,QAAQ,GAAmB,IACrC,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;IAC5C,UAAU,EAAE,UAAU;IACtB,MAAM,EAAE,WAAW;CACpB,CAAC,CAAC;AAEM,wBAAM","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 {\n CleanIconButton,\n DropdownButton,\n LoadingSpinner,\n Menu,\n OutlinedButton,\n Tooltip,\n Typography,\n} from '@neo4j-ndl/react';\nimport {\n ArrowSendIcon,\n ArrowSmallUpIconOutline,\n StopIconOutline,\n XMarkIconOutline,\n} from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { CommonProps, HtmlAttributes } from '../../_common/types';\n\ntype PromptProps = {\n /** The prompt text */\n value?: React.ComponentPropsWithoutRef<'textarea'>['value'];\n /** Callback function called when the prompt text changes */\n onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\n /** Whether the submit button is disabled */\n isSubmitDisabled?: boolean;\n /** Maximum number of rows the textarea can expand to */\n maxRows?: number;\n /** Whether the submit button is \"running\". Shows a stop icon when true. */\n isRunningPrompt?: boolean;\n /** Callback function called when the submit button is clicked */\n onSubmitPrompt?: (\n e:\n | React.KeyboardEvent<HTMLTextAreaElement>\n | React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => void;\n /** Callback function called when the cancel button is clicked */\n onCancelPrompt?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Content to display above the textarea */\n topContent?: React.ReactNode;\n /** Content to display below the textarea */\n bottomContent?: React.ReactNode;\n /** Disclaimer to display below the component */\n disclaimer?: React.ReactNode;\n /** Props for the textarea element */\n textareaProps?: HtmlAttributes<'textarea'>;\n};\n\n/**\n * The component is used to display the prompt input for an LLM.\n * It includes a textarea for the user to enter their prompt and a submit button.\n * It can also display content above and below the textarea, like uploaded files or a select for changing agents.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PromptComponent = ({\n value,\n onChange,\n maxRows = 5,\n isRunningPrompt = false,\n onSubmitPrompt,\n onCancelPrompt,\n isSubmitDisabled = false,\n topContent,\n bottomContent,\n disclaimer = 'All information should be verified.',\n className,\n style,\n htmlAttributes,\n ref,\n textareaProps,\n ...restProps\n}: CommonProps<'div', PromptProps>) => {\n const classes = classNames('ndl-ai-prompt', className);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const textareaAboveRef = useRef<HTMLDivElement>(null);\n const [lineHeight, setLineHeight] = useState(0);\n\n /** File overflow stuff */\n useEffect(() => {\n let rafId: number | null = null;\n\n const checkOverflow = () => {\n if (textareaAboveRef.current !== null) {\n const element = textareaAboveRef.current;\n const maxHeight = parseFloat(\n getComputedStyle(element).maxHeight.replace('px', ''),\n );\n const scrollHeight = element.scrollHeight;\n\n if (scrollHeight > maxHeight) {\n element.classList.add('ndl-can-scroll');\n } else {\n element.classList.remove('ndl-can-scroll');\n }\n }\n };\n\n const debouncedCheck = () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(checkOverflow);\n };\n\n // Initial check\n checkOverflow();\n\n const resizeObserver = new ResizeObserver(debouncedCheck);\n const mutationObserver = new MutationObserver(debouncedCheck);\n\n if (textareaAboveRef.current !== null) {\n resizeObserver.observe(textareaAboveRef.current);\n mutationObserver.observe(textareaAboveRef.current, {\n childList: true,\n subtree: true,\n });\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n }, []);\n\n /** Textarea stuff */\n useEffect(() => {\n if (textareaRef.current !== null) {\n const computed = window.getComputedStyle(textareaRef.current);\n setLineHeight(parseInt(computed.lineHeight));\n }\n }, []);\n\n const adjustTextareaHeight = useCallback(() => {\n const ta = textareaRef.current;\n\n if (ta !== null && lineHeight > 0) {\n // Reset height so scrollHeight measures correctly\n ta.style.height = 'auto';\n\n const maxHeight = lineHeight * maxRows;\n\n if (ta.scrollHeight <= maxHeight) {\n ta.style.overflowY = 'hidden';\n ta.style.height = `${ta.scrollHeight}px`;\n } else {\n ta.style.overflowY = 'auto';\n ta.style.height = `${maxHeight}px`;\n }\n }\n }, [lineHeight, maxRows]);\n\n // Adjust height when prompt value changes (including when cleared)\n useEffect(() => {\n adjustTextareaHeight();\n }, [value, adjustTextareaHeight]);\n\n const handleInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n adjustTextareaHeight();\n onChange?.(e);\n };\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-ai-prompt-wrapper\">\n <div\n className={classNames('ndl-ai-prompt-loading-container', {\n 'ndl-expanded': isRunningPrompt,\n })}\n aria-hidden={!isRunningPrompt}\n inert={!isRunningPrompt}\n >\n <div className=\"ndl-ai-prompt-loading-shell\">\n <div className=\"ndl-ai-prompt-loading-content\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"body-medium\">\n Working\n <span className=\"ndl-ai-prompt-loading-dots\">\n <span>.</span>\n <span>.</span>\n <span>.</span>\n </span>\n </Typography>\n </div>\n </div>\n </div>\n <div className=\"ndl-ai-prompt-wrapper-inner\">\n {Boolean(topContent) && (\n <div\n className=\"ndl-ai-prompt-textarea-above\"\n ref={textareaAboveRef}\n >\n {topContent}\n </div>\n )}\n <textarea\n placeholder=\"Ask anything\"\n className=\"ndl-ai-prompt-textarea\"\n rows={1}\n onChange={handleInput}\n value={value}\n ref={textareaRef}\n onKeyDown={(e) => {\n if (\n e.key === 'Enter' &&\n !e.shiftKey &&\n isSubmitDisabled !== true\n ) {\n e.preventDefault();\n\n if (isRunningPrompt !== true) {\n onSubmitPrompt?.(e);\n }\n }\n }}\n {...textareaProps}\n />\n <div className=\"ndl-ai-prompt-textarea-below\">\n {Boolean(bottomContent) && (\n <div className=\"ndl-ai-prompt-textarea-below-leading\">\n {bottomContent}\n </div>\n )}\n </div>\n </div>\n <SubmitPromptButton\n isDisabled={isSubmitDisabled}\n isRunningPrompt={isRunningPrompt}\n onSubmit={onSubmitPrompt}\n onCancel={onCancelPrompt}\n />\n </div>\n {Boolean(disclaimer) && (\n <Typography variant=\"body-small\" className=\"ndl-ai-prompt-footer\">\n {disclaimer}\n </Typography>\n )}\n </div>\n );\n};\n\nconst SubmitPromptButton = ({\n onSubmit,\n onCancel,\n isDisabled,\n isRunningPrompt,\n}: {\n isDisabled?: boolean;\n isRunningPrompt?: boolean;\n onSubmit?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n onCancel?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}) => {\n return (\n <div\n className={classNames('ndl-ai-prompt-button-container', {\n 'ndl-in-loading': isRunningPrompt,\n })}\n >\n <Tooltip\n type=\"simple\"\n isDisabled={isDisabled || isRunningPrompt}\n hoverDelay={{ close: 0, open: 500 }}\n shouldCloseOnReferenceClick={true}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <button\n type=\"button\"\n style={{\n borderRadius: isRunningPrompt\n ? 'var(--border-radius-sm)'\n : 'var(--border-radius-lg)',\n }}\n onClick={isRunningPrompt ? onCancel : onSubmit}\n disabled={isDisabled}\n aria-label={isRunningPrompt ? 'Stop' : 'Send'}\n >\n {isRunningPrompt === true ? (\n <OutlinedButton\n as=\"div\"\n variant=\"neutral\"\n className=\"ndl-ai-prompt-stop-button\"\n size=\"small\"\n isDisabled={isDisabled}\n leadingVisual={<StopIconOutline />}\n >\n Stop\n </OutlinedButton>\n ) : (\n <CleanIconButton\n description=\"Send\"\n as=\"div\"\n className=\"ndl-ai-prompt-submit-button\"\n size=\"medium\"\n isDisabled={isDisabled}\n htmlAttributes={{\n 'aria-pressed': undefined,\n }}\n >\n <ArrowSmallUpIconOutline />\n </CleanIconButton>\n )}\n </button>\n </Tooltip.Trigger>\n <Tooltip.Content>Send</Tooltip.Content>\n </Tooltip>\n </div>\n );\n};\n\ntype AgentSelectProps = {\n value: { label: React.ReactNode; value: string };\n options: Array<{ label: React.ReactNode; value: string }>;\n onChange: (option: { label: React.ReactNode; value: string }) => void;\n};\n\nconst AgentSelect = ({ value, options = [], onChange }: AgentSelectProps) => {\n const anchorRef = useRef<HTMLButtonElement>(null);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n\n const displayLabel = value?.label ?? options[0]?.label ?? '';\n\n const handleItemClick = (option: {\n label: React.ReactNode;\n value: string;\n }) => {\n onChange?.(option);\n setIsMenuOpen(false);\n };\n\n return (\n <>\n <DropdownButton\n size=\"small\"\n className=\"ndl-ai-prompt-dropdown-button\"\n onClick={() => setIsMenuOpen((old) => !old)}\n isOpen={isMenuOpen}\n ref={anchorRef}\n >\n {displayLabel}\n </DropdownButton>\n <Menu\n isOpen={isMenuOpen}\n onClose={() => setIsMenuOpen(false)}\n anchorRef={anchorRef}\n placement=\"top-start-bottom-start\"\n >\n {options.map((option) => (\n <Menu.RadioItem\n key={option.value}\n title={option.label}\n isChecked={value?.value === option.value}\n onClick={() => handleItemClick(option)}\n />\n ))}\n </Menu>\n </>\n );\n};\n\ntype ContextTagProps = {\n children?: string;\n onClose: () => void;\n};\n\nconst ContextTag = ({ children, onClose }: ContextTagProps) => {\n const textRef = useRef<HTMLSpanElement>(null);\n const [isTooltipOpen, setIsTooltipOpen] = useState(false);\n\n return (\n <Tooltip\n type=\"simple\"\n isOpen={isTooltipOpen}\n onOpenChange={(isOpen) => {\n if (isOpen) {\n const isTruncated =\n textRef.current?.scrollWidth &&\n textRef.current?.clientWidth &&\n textRef.current.scrollWidth > textRef.current.clientWidth;\n if (isTruncated) {\n setIsTooltipOpen(true);\n }\n } else {\n setIsTooltipOpen(false);\n }\n }}\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <div className=\"ndl-ai-prompt-context-tag\">\n <ArrowSendIcon className=\"ndl-ai-prompt-context-tag-icon\" />\n <Typography\n variant=\"body-medium\"\n className=\"ndl-ai-prompt-context-tag-text\"\n ref={textRef}\n >\n {children}\n </Typography>\n\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={`Remove context: ${children}`}\n className=\"ndl-ai-prompt-context-tag-close-button\"\n >\n <XMarkIconOutline className=\"ndl-ai-prompt-context-tag-icon\" />\n </button>\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>{children}</Tooltip.Content>\n </Tooltip>\n );\n};\n\nconst Prompt = Object.assign(PromptComponent, {\n ContextTag: ContextTag,\n Select: AgentSelect,\n});\n\nexport { Prompt };\n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AC,CAAC;gBACzB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC,EACD,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,aAEnC,uBAAC,eAAO,CAAC,OAAO,IAAC,gBAAgB,kBAC/B,iCAAK,SAAS,EAAC,2BAA2B,aACxC,uBAAC,qBAAa,IAAC,SAAS,EAAC,gCAAgC,GAAG,EAC5D,uBAAC,kBAAU,IACT,OAAO,EAAC,aAAa,EACrB,SAAS,EAAC,gCAAgC,EAC1C,GAAG,EAAE,OAAO,YAEX,QAAQ,GACE,EAEb,mCACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,gBACJ,mBAAmB,QAAQ,EAAE,EACzC,SAAS,EAAC,wCAAwC,YAElD,uBAAC,wBAAgB,IAAC,SAAS,EAAC,gCAAgC,GAAG,GACxD,IACL,GACU,EAClB,uBAAC,eAAO,CAAC,OAAO,cAAE,QAAQ,GAAmB,IACrC,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;IAC5C,UAAU,EAAE,UAAU;IACtB,MAAM,EAAE,WAAW;CACpB,CAAC,CAAC;AAEM,wBAAM","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 {\n CleanIconButton,\n DropdownButton,\n LoadingSpinner,\n Menu,\n OutlinedButton,\n Tooltip,\n Typography,\n} from '@neo4j-ndl/react';\nimport {\n ArrowSendIcon,\n ArrowSmallUpIconOutline,\n StopIconOutline,\n XMarkIconOutline,\n} from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { CommonProps, HtmlAttributes } from '../../_common/types';\n\ntype PromptProps = {\n /** The prompt text */\n value?: React.ComponentPropsWithoutRef<'textarea'>['value'];\n /** Callback function called when the prompt text changes */\n onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\n /** Whether the submit button is disabled */\n isSubmitDisabled?: boolean;\n /** Maximum number of rows the textarea can expand to */\n maxRows?: number;\n /** Whether the submit button is \"running\". Shows a stop icon when true. */\n isRunningPrompt?: boolean;\n /** Callback function called when the submit button is clicked */\n onSubmitPrompt?: (\n e:\n | React.KeyboardEvent<HTMLTextAreaElement>\n | React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => void;\n /** Callback function called when the cancel button is clicked */\n onCancelPrompt?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Content to display above the textarea */\n topContent?: React.ReactNode;\n /** Content to display below the textarea */\n bottomContent?: React.ReactNode;\n /** Disclaimer to display below the component */\n disclaimer?: React.ReactNode;\n /** Props for the textarea element */\n textareaProps?: HtmlAttributes<'textarea'>;\n};\n\n/**\n * The component is used to display the prompt input for an LLM.\n * It includes a textarea for the user to enter their prompt and a submit button.\n * It can also display content above and below the textarea, like uploaded files or a select for changing agents.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PromptComponent = ({\n value,\n onChange,\n maxRows = 5,\n isRunningPrompt = false,\n onSubmitPrompt,\n onCancelPrompt,\n isSubmitDisabled = false,\n topContent,\n bottomContent,\n disclaimer = 'All information should be verified.',\n className,\n style,\n htmlAttributes,\n ref,\n textareaProps,\n ...restProps\n}: CommonProps<'div', PromptProps>) => {\n const classes = classNames('ndl-ai-prompt', className);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const textareaAboveRef = useRef<HTMLDivElement>(null);\n const [lineHeight, setLineHeight] = useState(0);\n\n /** File overflow stuff */\n useEffect(() => {\n let rafId: number | null = null;\n\n const checkOverflow = () => {\n if (textareaAboveRef.current !== null) {\n const element = textareaAboveRef.current;\n const maxHeight = parseFloat(\n getComputedStyle(element).maxHeight.replace('px', ''),\n );\n const scrollHeight = element.scrollHeight;\n\n if (scrollHeight > maxHeight) {\n element.classList.add('ndl-can-scroll');\n } else {\n element.classList.remove('ndl-can-scroll');\n }\n }\n };\n\n const debouncedCheck = () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(checkOverflow);\n };\n\n // Initial check\n checkOverflow();\n\n const resizeObserver = new ResizeObserver(debouncedCheck);\n const mutationObserver = new MutationObserver(debouncedCheck);\n\n if (textareaAboveRef.current !== null) {\n resizeObserver.observe(textareaAboveRef.current);\n mutationObserver.observe(textareaAboveRef.current, {\n childList: true,\n subtree: true,\n });\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n }, []);\n\n /** Textarea stuff */\n useEffect(() => {\n if (textareaRef.current !== null) {\n const computed = window.getComputedStyle(textareaRef.current);\n setLineHeight(parseInt(computed.lineHeight));\n }\n }, []);\n\n const adjustTextareaHeight = useCallback(() => {\n const ta = textareaRef.current;\n\n if (ta !== null && lineHeight > 0) {\n // Reset height so scrollHeight measures correctly\n ta.style.height = 'auto';\n\n const maxHeight = lineHeight * maxRows;\n\n if (ta.scrollHeight <= maxHeight) {\n ta.style.overflowY = 'hidden';\n ta.style.height = `${ta.scrollHeight + 12}px`;\n } else {\n ta.style.overflowY = 'auto';\n ta.style.height = `${maxHeight + 12}px`;\n }\n }\n }, [lineHeight, maxRows]);\n\n // Adjust height when prompt value changes (including when cleared)\n useEffect(() => {\n adjustTextareaHeight();\n }, [value, adjustTextareaHeight]);\n\n const handleInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n adjustTextareaHeight();\n onChange?.(e);\n };\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-ai-prompt-wrapper\">\n <div\n className={classNames('ndl-ai-prompt-loading-container', {\n 'ndl-expanded': isRunningPrompt,\n })}\n aria-hidden={!isRunningPrompt}\n inert={!isRunningPrompt}\n >\n <div className=\"ndl-ai-prompt-loading-shell\">\n <div className=\"ndl-ai-prompt-loading-content\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"body-medium\">\n Working\n <span className=\"ndl-ai-prompt-loading-dots\">\n <span>.</span>\n <span>.</span>\n <span>.</span>\n </span>\n </Typography>\n </div>\n </div>\n </div>\n <div className=\"ndl-ai-prompt-wrapper-inner\">\n {Boolean(topContent) && (\n <div\n className=\"ndl-ai-prompt-textarea-above\"\n ref={textareaAboveRef}\n >\n {topContent}\n </div>\n )}\n <textarea\n placeholder=\"Ask anything\"\n className=\"ndl-ai-prompt-textarea\"\n rows={1}\n onChange={handleInput}\n value={value}\n ref={textareaRef}\n onKeyDown={(e) => {\n if (\n e.key === 'Enter' &&\n !e.shiftKey &&\n isSubmitDisabled !== true\n ) {\n e.preventDefault();\n\n if (isRunningPrompt !== true) {\n onSubmitPrompt?.(e);\n }\n }\n }}\n {...textareaProps}\n />\n <div className=\"ndl-ai-prompt-textarea-below\">\n {Boolean(bottomContent) && (\n <div className=\"ndl-ai-prompt-textarea-below-leading\">\n {bottomContent}\n </div>\n )}\n </div>\n </div>\n <SubmitPromptButton\n isDisabled={isSubmitDisabled}\n isRunningPrompt={isRunningPrompt}\n onSubmit={onSubmitPrompt}\n onCancel={onCancelPrompt}\n />\n </div>\n {Boolean(disclaimer) && (\n <Typography variant=\"body-small\" className=\"ndl-ai-prompt-footer\">\n {disclaimer}\n </Typography>\n )}\n </div>\n );\n};\n\nconst SubmitPromptButton = ({\n onSubmit,\n onCancel,\n isDisabled,\n isRunningPrompt,\n}: {\n isDisabled?: boolean;\n isRunningPrompt?: boolean;\n onSubmit?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n onCancel?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}) => {\n return (\n <div\n className={classNames('ndl-ai-prompt-button-container', {\n 'ndl-in-loading': isRunningPrompt,\n })}\n >\n <Tooltip\n type=\"simple\"\n isDisabled={isDisabled || isRunningPrompt}\n hoverDelay={{ close: 0, open: 500 }}\n shouldCloseOnReferenceClick={true}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <button\n type=\"button\"\n style={{\n borderRadius: isRunningPrompt\n ? 'var(--border-radius-sm)'\n : 'var(--border-radius-lg)',\n }}\n onClick={isRunningPrompt ? onCancel : onSubmit}\n disabled={isDisabled}\n aria-label={isRunningPrompt ? 'Stop' : 'Send'}\n >\n {isRunningPrompt === true ? (\n <OutlinedButton\n as=\"div\"\n variant=\"neutral\"\n className=\"ndl-ai-prompt-stop-button\"\n size=\"small\"\n isDisabled={isDisabled}\n leadingVisual={<StopIconOutline />}\n >\n Stop\n </OutlinedButton>\n ) : (\n <CleanIconButton\n description=\"Send\"\n as=\"div\"\n className=\"ndl-ai-prompt-submit-button\"\n size=\"medium\"\n isDisabled={isDisabled}\n htmlAttributes={{\n 'aria-pressed': undefined,\n }}\n >\n <ArrowSmallUpIconOutline />\n </CleanIconButton>\n )}\n </button>\n </Tooltip.Trigger>\n <Tooltip.Content>Send</Tooltip.Content>\n </Tooltip>\n </div>\n );\n};\n\ntype AgentSelectProps = {\n value: { label: React.ReactNode; value: string };\n options: Array<{ label: React.ReactNode; value: string }>;\n onChange: (option: { label: React.ReactNode; value: string }) => void;\n};\n\nconst AgentSelect = ({ value, options = [], onChange }: AgentSelectProps) => {\n const anchorRef = useRef<HTMLButtonElement>(null);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n\n const displayLabel = value?.label ?? options[0]?.label ?? '';\n\n const handleItemClick = (option: {\n label: React.ReactNode;\n value: string;\n }) => {\n onChange?.(option);\n setIsMenuOpen(false);\n };\n\n return (\n <>\n <DropdownButton\n size=\"small\"\n className=\"ndl-ai-prompt-dropdown-button\"\n onClick={() => setIsMenuOpen((old) => !old)}\n isOpen={isMenuOpen}\n ref={anchorRef}\n >\n {displayLabel}\n </DropdownButton>\n <Menu\n isOpen={isMenuOpen}\n onClose={() => setIsMenuOpen(false)}\n anchorRef={anchorRef}\n placement=\"top-start-bottom-start\"\n >\n {options.map((option) => (\n <Menu.RadioItem\n key={option.value}\n title={option.label}\n isChecked={value?.value === option.value}\n onClick={() => handleItemClick(option)}\n />\n ))}\n </Menu>\n </>\n );\n};\n\ntype ContextTagProps = {\n children?: string;\n onClose: () => void;\n};\n\nconst ContextTag = ({ children, onClose }: ContextTagProps) => {\n const textRef = useRef<HTMLSpanElement>(null);\n const [isTooltipOpen, setIsTooltipOpen] = useState(false);\n\n return (\n <Tooltip\n type=\"simple\"\n isOpen={isTooltipOpen}\n onOpenChange={(isOpen) => {\n if (isOpen) {\n const isTruncated =\n textRef.current?.scrollWidth &&\n textRef.current?.clientWidth &&\n textRef.current.scrollWidth > textRef.current.clientWidth;\n if (isTruncated) {\n setIsTooltipOpen(true);\n }\n } else {\n setIsTooltipOpen(false);\n }\n }}\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <div className=\"ndl-ai-prompt-context-tag\">\n <ArrowSendIcon className=\"ndl-ai-prompt-context-tag-icon\" />\n <Typography\n variant=\"body-medium\"\n className=\"ndl-ai-prompt-context-tag-text\"\n ref={textRef}\n >\n {children}\n </Typography>\n\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={`Remove context: ${children}`}\n className=\"ndl-ai-prompt-context-tag-close-button\"\n >\n <XMarkIconOutline className=\"ndl-ai-prompt-context-tag-icon\" />\n </button>\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>{children}</Tooltip.Content>\n </Tooltip>\n );\n};\n\nconst Prompt = Object.assign(PromptComponent, {\n ContextTag: ContextTag,\n Select: AgentSelect,\n});\n\nexport { Prompt };\n"]}
|
|
@@ -22,17 +22,19 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
22
22
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
23
|
*/
|
|
24
24
|
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const react_1 = require("@neo4j-ndl/react");
|
|
25
26
|
const ai_1 = require("@neo4j-ndl/react/ai");
|
|
26
|
-
const
|
|
27
|
+
const icons_1 = require("@neo4j-ndl/react/icons");
|
|
28
|
+
const react_2 = require("react");
|
|
27
29
|
const Component = () => {
|
|
28
|
-
const [prompt, setPrompt] = (0,
|
|
29
|
-
const [isRunningPrompt, setIsRunningPrompt] = (0,
|
|
30
|
+
const [prompt, setPrompt] = (0, react_2.useState)('');
|
|
31
|
+
const [isRunningPrompt, setIsRunningPrompt] = (0, react_2.useState)(false);
|
|
30
32
|
const handleSubmitPrompt = () => {
|
|
31
33
|
setIsRunningPrompt(true);
|
|
32
34
|
alert(`You submitted the following prompt: ${prompt}`);
|
|
33
35
|
setPrompt('');
|
|
34
36
|
};
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)(ai_1.Prompt, { isRunningPrompt: isRunningPrompt, value: prompt, onChange: (e) => setPrompt(e.target.value), onSubmitPrompt: handleSubmitPrompt, onCancelPrompt: () => setIsRunningPrompt(false) }));
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(ai_1.Prompt, { isRunningPrompt: isRunningPrompt, value: prompt, onChange: (e) => setPrompt(e.target.value), onSubmitPrompt: handleSubmitPrompt, onCancelPrompt: () => setIsRunningPrompt(false), bottomContent: (0, jsx_runtime_1.jsx)(react_1.CleanIconButton, { description: "Add files", size: "small", children: (0, jsx_runtime_1.jsx)(icons_1.PlusIconOutline, {}) }) }));
|
|
36
38
|
};
|
|
37
39
|
exports.default = Component;
|
|
38
40
|
//# sourceMappingURL=prompt-default.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-default.story.js","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-default.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAA6C;AAC7C,iCAAiC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC;IACzC,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAE9D,MAAM,kBAAkB,GAAG,GAAG,EAAE;QAC9B,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACzB,KAAK,CAAC,uCAAuC,MAAM,EAAE,CAAC,CAAC;QACvD,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO,CACL,uBAAC,WAAM,IACL,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,CAAyC,EAAE,EAAE,CACtD,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAE3B,cAAc,EAAE,kBAAkB,EAClC,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"prompt-default.story.js","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-default.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAmD;AACnD,4CAA6C;AAC7C,kDAAyD;AACzD,iCAAiC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC;IACzC,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAE9D,MAAM,kBAAkB,GAAG,GAAG,EAAE;QAC9B,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACzB,KAAK,CAAC,uCAAuC,MAAM,EAAE,CAAC,CAAC;QACvD,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO,CACL,uBAAC,WAAM,IACL,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,CAAyC,EAAE,EAAE,CACtD,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAE3B,cAAc,EAAE,kBAAkB,EAClC,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAC/C,aAAa,EACX,uBAAC,uBAAe,IAAC,WAAW,EAAC,WAAW,EAAC,IAAI,EAAC,OAAO,YACnD,uBAAC,uBAAe,KAAG,GACH,GAEpB,CACH,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 { CleanIconButton } from '@neo4j-ndl/react';\nimport { Prompt } from '@neo4j-ndl/react/ai';\nimport { PlusIconOutline } from '@neo4j-ndl/react/icons';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [prompt, setPrompt] = useState('');\n const [isRunningPrompt, setIsRunningPrompt] = useState(false);\n\n const handleSubmitPrompt = () => {\n setIsRunningPrompt(true);\n alert(`You submitted the following prompt: ${prompt}`);\n setPrompt('');\n };\n\n return (\n <Prompt\n isRunningPrompt={isRunningPrompt}\n value={prompt}\n onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) =>\n setPrompt(e.target.value)\n }\n onSubmitPrompt={handleSubmitPrompt}\n onCancelPrompt={() => setIsRunningPrompt(false)}\n bottomContent={\n <CleanIconButton description=\"Add files\" size=\"small\">\n <PlusIconOutline />\n </CleanIconButton>\n }\n />\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -22,11 +22,13 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
22
22
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
23
|
*/
|
|
24
24
|
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const react_1 = require("@neo4j-ndl/react");
|
|
25
26
|
const ai_1 = require("@neo4j-ndl/react/ai");
|
|
26
|
-
const
|
|
27
|
+
const icons_1 = require("@neo4j-ndl/react/icons");
|
|
28
|
+
const react_2 = require("react");
|
|
27
29
|
const Component = () => {
|
|
28
|
-
const [isRunningPrompt, setIsRunningPrompt] = (0,
|
|
29
|
-
return ((0, jsx_runtime_1.jsx)(ai_1.Prompt, { isRunningPrompt: isRunningPrompt, onSubmitPrompt: () => setIsRunningPrompt(true), onCancelPrompt: () => setIsRunningPrompt(false) }));
|
|
30
|
+
const [isRunningPrompt, setIsRunningPrompt] = (0, react_2.useState)(true);
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(ai_1.Prompt, { isRunningPrompt: isRunningPrompt, onSubmitPrompt: () => setIsRunningPrompt(true), onCancelPrompt: () => setIsRunningPrompt(false), bottomContent: (0, jsx_runtime_1.jsx)(react_1.CleanIconButton, { description: "Add files", size: "small", children: (0, jsx_runtime_1.jsx)(icons_1.PlusIconOutline, {}) }) }));
|
|
30
32
|
};
|
|
31
33
|
exports.default = Component;
|
|
32
34
|
//# sourceMappingURL=prompt-loading.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-loading.story.js","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-loading.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAA6C;AAC7C,iCAAiC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IAE7D,OAAO,CACL,uBAAC,WAAM,IACL,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAC9C,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"prompt-loading.story.js","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-loading.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAmD;AACnD,4CAA6C;AAC7C,kDAAyD;AACzD,iCAAiC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IAE7D,OAAO,CACL,uBAAC,WAAM,IACL,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAC9C,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAC/C,aAAa,EACX,uBAAC,uBAAe,IAAC,WAAW,EAAC,WAAW,EAAC,IAAI,EAAC,OAAO,YACnD,uBAAC,uBAAe,KAAG,GACH,GAEpB,CACH,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 { CleanIconButton } from '@neo4j-ndl/react';\nimport { Prompt } from '@neo4j-ndl/react/ai';\nimport { PlusIconOutline } from '@neo4j-ndl/react/icons';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [isRunningPrompt, setIsRunningPrompt] = useState(true);\n\n return (\n <Prompt\n isRunningPrompt={isRunningPrompt}\n onSubmitPrompt={() => setIsRunningPrompt(true)}\n onCancelPrompt={() => setIsRunningPrompt(false)}\n bottomContent={\n <CleanIconButton description=\"Add files\" size=\"small\">\n <PlusIconOutline />\n </CleanIconButton>\n }\n />\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -103,11 +103,11 @@ const PromptComponent = (_a) => {
|
|
|
103
103
|
const maxHeight = lineHeight * maxRows;
|
|
104
104
|
if (ta.scrollHeight <= maxHeight) {
|
|
105
105
|
ta.style.overflowY = 'hidden';
|
|
106
|
-
ta.style.height = `${ta.scrollHeight}px`;
|
|
106
|
+
ta.style.height = `${ta.scrollHeight + 12}px`;
|
|
107
107
|
}
|
|
108
108
|
else {
|
|
109
109
|
ta.style.overflowY = 'auto';
|
|
110
|
-
ta.style.height = `${maxHeight}px`;
|
|
110
|
+
ta.style.height = `${maxHeight + 12}px`;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
}, [lineHeight, maxRows]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prompt.js","sourceRoot":"","sources":["../../../../src/ai/prompt/Prompt.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,IAAI,EACJ,cAAc,EACd,OAAO,EACP,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,eAAe,EACf,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAiCjE;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,CAAC,EAiBS,EAAE,EAAE;QAjBb,EACvB,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,CAAC,EACX,eAAe,GAAG,KAAK,EACvB,cAAc,EACd,cAAc,EACd,gBAAgB,GAAG,KAAK,EACxB,UAAU,EACV,aAAa,EACb,UAAU,GAAG,qCAAqC,EAClD,SAAS,EACT,KAAK,EACL,cAAc,EACd,GAAG,EACH,aAAa,OAEmB,EAD7B,SAAS,cAhBW,wNAiBxB,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAEvD,MAAM,WAAW,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IACtD,MAAM,gBAAgB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACtD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEhD,0BAA0B;IAC1B,SAAS,C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A,MAAA,OAAO,CAAC,OAAO,0CAAE,WAAW;qBAC5B,MAAA,OAAO,CAAC,OAAO,0CAAE,WAAW,CAAA;oBAC5B,OAAO,CAAC,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;gBAC5D,IAAI,WAAW,EAAE,CAAC;oBAChB,gBAAgB,CAAC,IAAI,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC,EACD,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,aAEnC,KAAC,OAAO,CAAC,OAAO,IAAC,gBAAgB,kBAC/B,eAAK,SAAS,EAAC,2BAA2B,aACxC,KAAC,aAAa,IAAC,SAAS,EAAC,gCAAgC,GAAG,EAC5D,KAAC,UAAU,IACT,OAAO,EAAC,aAAa,EACrB,SAAS,EAAC,gCAAgC,EAC1C,GAAG,EAAE,OAAO,YAEX,QAAQ,GACE,EAEb,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,gBACJ,mBAAmB,QAAQ,EAAE,EACzC,SAAS,EAAC,wCAAwC,YAElD,KAAC,gBAAgB,IAAC,SAAS,EAAC,gCAAgC,GAAG,GACxD,IACL,GACU,EAClB,KAAC,OAAO,CAAC,OAAO,cAAE,QAAQ,GAAmB,IACrC,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;IAC5C,UAAU,EAAE,UAAU;IACtB,MAAM,EAAE,WAAW;CACpB,CAAC,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport {\n CleanIconButton,\n DropdownButton,\n LoadingSpinner,\n Menu,\n OutlinedButton,\n Tooltip,\n Typography,\n} from '@neo4j-ndl/react';\nimport {\n ArrowSendIcon,\n ArrowSmallUpIconOutline,\n StopIconOutline,\n XMarkIconOutline,\n} from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { CommonProps, HtmlAttributes } from '../../_common/types';\n\ntype PromptProps = {\n /** The prompt text */\n value?: React.ComponentPropsWithoutRef<'textarea'>['value'];\n /** Callback function called when the prompt text changes */\n onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\n /** Whether the submit button is disabled */\n isSubmitDisabled?: boolean;\n /** Maximum number of rows the textarea can expand to */\n maxRows?: number;\n /** Whether the submit button is \"running\". Shows a stop icon when true. */\n isRunningPrompt?: boolean;\n /** Callback function called when the submit button is clicked */\n onSubmitPrompt?: (\n e:\n | React.KeyboardEvent<HTMLTextAreaElement>\n | React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => void;\n /** Callback function called when the cancel button is clicked */\n onCancelPrompt?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Content to display above the textarea */\n topContent?: React.ReactNode;\n /** Content to display below the textarea */\n bottomContent?: React.ReactNode;\n /** Disclaimer to display below the component */\n disclaimer?: React.ReactNode;\n /** Props for the textarea element */\n textareaProps?: HtmlAttributes<'textarea'>;\n};\n\n/**\n * The component is used to display the prompt input for an LLM.\n * It includes a textarea for the user to enter their prompt and a submit button.\n * It can also display content above and below the textarea, like uploaded files or a select for changing agents.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PromptComponent = ({\n value,\n onChange,\n maxRows = 5,\n isRunningPrompt = false,\n onSubmitPrompt,\n onCancelPrompt,\n isSubmitDisabled = false,\n topContent,\n bottomContent,\n disclaimer = 'All information should be verified.',\n className,\n style,\n htmlAttributes,\n ref,\n textareaProps,\n ...restProps\n}: CommonProps<'div', PromptProps>) => {\n const classes = classNames('ndl-ai-prompt', className);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const textareaAboveRef = useRef<HTMLDivElement>(null);\n const [lineHeight, setLineHeight] = useState(0);\n\n /** File overflow stuff */\n useEffect(() => {\n let rafId: number | null = null;\n\n const checkOverflow = () => {\n if (textareaAboveRef.current !== null) {\n const element = textareaAboveRef.current;\n const maxHeight = parseFloat(\n getComputedStyle(element).maxHeight.replace('px', ''),\n );\n const scrollHeight = element.scrollHeight;\n\n if (scrollHeight > maxHeight) {\n element.classList.add('ndl-can-scroll');\n } else {\n element.classList.remove('ndl-can-scroll');\n }\n }\n };\n\n const debouncedCheck = () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(checkOverflow);\n };\n\n // Initial check\n checkOverflow();\n\n const resizeObserver = new ResizeObserver(debouncedCheck);\n const mutationObserver = new MutationObserver(debouncedCheck);\n\n if (textareaAboveRef.current !== null) {\n resizeObserver.observe(textareaAboveRef.current);\n mutationObserver.observe(textareaAboveRef.current, {\n childList: true,\n subtree: true,\n });\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n }, []);\n\n /** Textarea stuff */\n useEffect(() => {\n if (textareaRef.current !== null) {\n const computed = window.getComputedStyle(textareaRef.current);\n setLineHeight(parseInt(computed.lineHeight));\n }\n }, []);\n\n const adjustTextareaHeight = useCallback(() => {\n const ta = textareaRef.current;\n\n if (ta !== null && lineHeight > 0) {\n // Reset height so scrollHeight measures correctly\n ta.style.height = 'auto';\n\n const maxHeight = lineHeight * maxRows;\n\n if (ta.scrollHeight <= maxHeight) {\n ta.style.overflowY = 'hidden';\n ta.style.height = `${ta.scrollHeight}px`;\n } else {\n ta.style.overflowY = 'auto';\n ta.style.height = `${maxHeight}px`;\n }\n }\n }, [lineHeight, maxRows]);\n\n // Adjust height when prompt value changes (including when cleared)\n useEffect(() => {\n adjustTextareaHeight();\n }, [value, adjustTextareaHeight]);\n\n const handleInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n adjustTextareaHeight();\n onChange?.(e);\n };\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-ai-prompt-wrapper\">\n <div\n className={classNames('ndl-ai-prompt-loading-container', {\n 'ndl-expanded': isRunningPrompt,\n })}\n aria-hidden={!isRunningPrompt}\n inert={!isRunningPrompt}\n >\n <div className=\"ndl-ai-prompt-loading-shell\">\n <div className=\"ndl-ai-prompt-loading-content\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"body-medium\">\n Working\n <span className=\"ndl-ai-prompt-loading-dots\">\n <span>.</span>\n <span>.</span>\n <span>.</span>\n </span>\n </Typography>\n </div>\n </div>\n </div>\n <div className=\"ndl-ai-prompt-wrapper-inner\">\n {Boolean(topContent) && (\n <div\n className=\"ndl-ai-prompt-textarea-above\"\n ref={textareaAboveRef}\n >\n {topContent}\n </div>\n )}\n <textarea\n placeholder=\"Ask anything\"\n className=\"ndl-ai-prompt-textarea\"\n rows={1}\n onChange={handleInput}\n value={value}\n ref={textareaRef}\n onKeyDown={(e) => {\n if (\n e.key === 'Enter' &&\n !e.shiftKey &&\n isSubmitDisabled !== true\n ) {\n e.preventDefault();\n\n if (isRunningPrompt !== true) {\n onSubmitPrompt?.(e);\n }\n }\n }}\n {...textareaProps}\n />\n <div className=\"ndl-ai-prompt-textarea-below\">\n {Boolean(bottomContent) && (\n <div className=\"ndl-ai-prompt-textarea-below-leading\">\n {bottomContent}\n </div>\n )}\n </div>\n </div>\n <SubmitPromptButton\n isDisabled={isSubmitDisabled}\n isRunningPrompt={isRunningPrompt}\n onSubmit={onSubmitPrompt}\n onCancel={onCancelPrompt}\n />\n </div>\n {Boolean(disclaimer) && (\n <Typography variant=\"body-small\" className=\"ndl-ai-prompt-footer\">\n {disclaimer}\n </Typography>\n )}\n </div>\n );\n};\n\nconst SubmitPromptButton = ({\n onSubmit,\n onCancel,\n isDisabled,\n isRunningPrompt,\n}: {\n isDisabled?: boolean;\n isRunningPrompt?: boolean;\n onSubmit?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n onCancel?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}) => {\n return (\n <div\n className={classNames('ndl-ai-prompt-button-container', {\n 'ndl-in-loading': isRunningPrompt,\n })}\n >\n <Tooltip\n type=\"simple\"\n isDisabled={isDisabled || isRunningPrompt}\n hoverDelay={{ close: 0, open: 500 }}\n shouldCloseOnReferenceClick={true}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <button\n type=\"button\"\n style={{\n borderRadius: isRunningPrompt\n ? 'var(--border-radius-sm)'\n : 'var(--border-radius-lg)',\n }}\n onClick={isRunningPrompt ? onCancel : onSubmit}\n disabled={isDisabled}\n aria-label={isRunningPrompt ? 'Stop' : 'Send'}\n >\n {isRunningPrompt === true ? (\n <OutlinedButton\n as=\"div\"\n variant=\"neutral\"\n className=\"ndl-ai-prompt-stop-button\"\n size=\"small\"\n isDisabled={isDisabled}\n leadingVisual={<StopIconOutline />}\n >\n Stop\n </OutlinedButton>\n ) : (\n <CleanIconButton\n description=\"Send\"\n as=\"div\"\n className=\"ndl-ai-prompt-submit-button\"\n size=\"medium\"\n isDisabled={isDisabled}\n htmlAttributes={{\n 'aria-pressed': undefined,\n }}\n >\n <ArrowSmallUpIconOutline />\n </CleanIconButton>\n )}\n </button>\n </Tooltip.Trigger>\n <Tooltip.Content>Send</Tooltip.Content>\n </Tooltip>\n </div>\n );\n};\n\ntype AgentSelectProps = {\n value: { label: React.ReactNode; value: string };\n options: Array<{ label: React.ReactNode; value: string }>;\n onChange: (option: { label: React.ReactNode; value: string }) => void;\n};\n\nconst AgentSelect = ({ value, options = [], onChange }: AgentSelectProps) => {\n const anchorRef = useRef<HTMLButtonElement>(null);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n\n const displayLabel = value?.label ?? options[0]?.label ?? '';\n\n const handleItemClick = (option: {\n label: React.ReactNode;\n value: string;\n }) => {\n onChange?.(option);\n setIsMenuOpen(false);\n };\n\n return (\n <>\n <DropdownButton\n size=\"small\"\n className=\"ndl-ai-prompt-dropdown-button\"\n onClick={() => setIsMenuOpen((old) => !old)}\n isOpen={isMenuOpen}\n ref={anchorRef}\n >\n {displayLabel}\n </DropdownButton>\n <Menu\n isOpen={isMenuOpen}\n onClose={() => setIsMenuOpen(false)}\n anchorRef={anchorRef}\n placement=\"top-start-bottom-start\"\n >\n {options.map((option) => (\n <Menu.RadioItem\n key={option.value}\n title={option.label}\n isChecked={value?.value === option.value}\n onClick={() => handleItemClick(option)}\n />\n ))}\n </Menu>\n </>\n );\n};\n\ntype ContextTagProps = {\n children?: string;\n onClose: () => void;\n};\n\nconst ContextTag = ({ children, onClose }: ContextTagProps) => {\n const textRef = useRef<HTMLSpanElement>(null);\n const [isTooltipOpen, setIsTooltipOpen] = useState(false);\n\n return (\n <Tooltip\n type=\"simple\"\n isOpen={isTooltipOpen}\n onOpenChange={(isOpen) => {\n if (isOpen) {\n const isTruncated =\n textRef.current?.scrollWidth &&\n textRef.current?.clientWidth &&\n textRef.current.scrollWidth > textRef.current.clientWidth;\n if (isTruncated) {\n setIsTooltipOpen(true);\n }\n } else {\n setIsTooltipOpen(false);\n }\n }}\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <div className=\"ndl-ai-prompt-context-tag\">\n <ArrowSendIcon className=\"ndl-ai-prompt-context-tag-icon\" />\n <Typography\n variant=\"body-medium\"\n className=\"ndl-ai-prompt-context-tag-text\"\n ref={textRef}\n >\n {children}\n </Typography>\n\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={`Remove context: ${children}`}\n className=\"ndl-ai-prompt-context-tag-close-button\"\n >\n <XMarkIconOutline className=\"ndl-ai-prompt-context-tag-icon\" />\n </button>\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>{children}</Tooltip.Content>\n </Tooltip>\n );\n};\n\nconst Prompt = Object.assign(PromptComponent, {\n ContextTag: ContextTag,\n Select: AgentSelect,\n});\n\nexport { Prompt };\n"]}
|
|
1
|
+
{"version":3,"file":"Prompt.js","sourceRoot":"","sources":["../../../../src/ai/prompt/Prompt.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,IAAI,EACJ,cAAc,EACd,OAAO,EACP,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,eAAe,EACf,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAiCjE;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,CAAC,EAiBS,EAAE,EAAE;QAjBb,EACvB,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,CAAC,EACX,eAAe,GAAG,KAAK,EACvB,cAAc,EACd,cAAc,EACd,gBAAgB,GAAG,KAAK,EACxB,UAAU,EACV,aAAa,EACb,UAAU,GAAG,qCAAqC,EAClD,SAAS,EACT,KAAK,EACL,cAAc,EACd,GAAG,EACH,aAAa,OAEmB,EAD7B,SAAS,cAhBW,wNAiBxB,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAEvD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AAU,EAAE,UAAU;IACtB,MAAM,EAAE,WAAW;CACpB,CAAC,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport {\n CleanIconButton,\n DropdownButton,\n LoadingSpinner,\n Menu,\n OutlinedButton,\n Tooltip,\n Typography,\n} from '@neo4j-ndl/react';\nimport {\n ArrowSendIcon,\n ArrowSmallUpIconOutline,\n StopIconOutline,\n XMarkIconOutline,\n} from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { CommonProps, HtmlAttributes } from '../../_common/types';\n\ntype PromptProps = {\n /** The prompt text */\n value?: React.ComponentPropsWithoutRef<'textarea'>['value'];\n /** Callback function called when the prompt text changes */\n onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\n /** Whether the submit button is disabled */\n isSubmitDisabled?: boolean;\n /** Maximum number of rows the textarea can expand to */\n maxRows?: number;\n /** Whether the submit button is \"running\". Shows a stop icon when true. */\n isRunningPrompt?: boolean;\n /** Callback function called when the submit button is clicked */\n onSubmitPrompt?: (\n e:\n | React.KeyboardEvent<HTMLTextAreaElement>\n | React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => void;\n /** Callback function called when the cancel button is clicked */\n onCancelPrompt?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Content to display above the textarea */\n topContent?: React.ReactNode;\n /** Content to display below the textarea */\n bottomContent?: React.ReactNode;\n /** Disclaimer to display below the component */\n disclaimer?: React.ReactNode;\n /** Props for the textarea element */\n textareaProps?: HtmlAttributes<'textarea'>;\n};\n\n/**\n * The component is used to display the prompt input for an LLM.\n * It includes a textarea for the user to enter their prompt and a submit button.\n * It can also display content above and below the textarea, like uploaded files or a select for changing agents.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PromptComponent = ({\n value,\n onChange,\n maxRows = 5,\n isRunningPrompt = false,\n onSubmitPrompt,\n onCancelPrompt,\n isSubmitDisabled = false,\n topContent,\n bottomContent,\n disclaimer = 'All information should be verified.',\n className,\n style,\n htmlAttributes,\n ref,\n textareaProps,\n ...restProps\n}: CommonProps<'div', PromptProps>) => {\n const classes = classNames('ndl-ai-prompt', className);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const textareaAboveRef = useRef<HTMLDivElement>(null);\n const [lineHeight, setLineHeight] = useState(0);\n\n /** File overflow stuff */\n useEffect(() => {\n let rafId: number | null = null;\n\n const checkOverflow = () => {\n if (textareaAboveRef.current !== null) {\n const element = textareaAboveRef.current;\n const maxHeight = parseFloat(\n getComputedStyle(element).maxHeight.replace('px', ''),\n );\n const scrollHeight = element.scrollHeight;\n\n if (scrollHeight > maxHeight) {\n element.classList.add('ndl-can-scroll');\n } else {\n element.classList.remove('ndl-can-scroll');\n }\n }\n };\n\n const debouncedCheck = () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(checkOverflow);\n };\n\n // Initial check\n checkOverflow();\n\n const resizeObserver = new ResizeObserver(debouncedCheck);\n const mutationObserver = new MutationObserver(debouncedCheck);\n\n if (textareaAboveRef.current !== null) {\n resizeObserver.observe(textareaAboveRef.current);\n mutationObserver.observe(textareaAboveRef.current, {\n childList: true,\n subtree: true,\n });\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n }, []);\n\n /** Textarea stuff */\n useEffect(() => {\n if (textareaRef.current !== null) {\n const computed = window.getComputedStyle(textareaRef.current);\n setLineHeight(parseInt(computed.lineHeight));\n }\n }, []);\n\n const adjustTextareaHeight = useCallback(() => {\n const ta = textareaRef.current;\n\n if (ta !== null && lineHeight > 0) {\n // Reset height so scrollHeight measures correctly\n ta.style.height = 'auto';\n\n const maxHeight = lineHeight * maxRows;\n\n if (ta.scrollHeight <= maxHeight) {\n ta.style.overflowY = 'hidden';\n ta.style.height = `${ta.scrollHeight + 12}px`;\n } else {\n ta.style.overflowY = 'auto';\n ta.style.height = `${maxHeight + 12}px`;\n }\n }\n }, [lineHeight, maxRows]);\n\n // Adjust height when prompt value changes (including when cleared)\n useEffect(() => {\n adjustTextareaHeight();\n }, [value, adjustTextareaHeight]);\n\n const handleInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n adjustTextareaHeight();\n onChange?.(e);\n };\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-ai-prompt-wrapper\">\n <div\n className={classNames('ndl-ai-prompt-loading-container', {\n 'ndl-expanded': isRunningPrompt,\n })}\n aria-hidden={!isRunningPrompt}\n inert={!isRunningPrompt}\n >\n <div className=\"ndl-ai-prompt-loading-shell\">\n <div className=\"ndl-ai-prompt-loading-content\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"body-medium\">\n Working\n <span className=\"ndl-ai-prompt-loading-dots\">\n <span>.</span>\n <span>.</span>\n <span>.</span>\n </span>\n </Typography>\n </div>\n </div>\n </div>\n <div className=\"ndl-ai-prompt-wrapper-inner\">\n {Boolean(topContent) && (\n <div\n className=\"ndl-ai-prompt-textarea-above\"\n ref={textareaAboveRef}\n >\n {topContent}\n </div>\n )}\n <textarea\n placeholder=\"Ask anything\"\n className=\"ndl-ai-prompt-textarea\"\n rows={1}\n onChange={handleInput}\n value={value}\n ref={textareaRef}\n onKeyDown={(e) => {\n if (\n e.key === 'Enter' &&\n !e.shiftKey &&\n isSubmitDisabled !== true\n ) {\n e.preventDefault();\n\n if (isRunningPrompt !== true) {\n onSubmitPrompt?.(e);\n }\n }\n }}\n {...textareaProps}\n />\n <div className=\"ndl-ai-prompt-textarea-below\">\n {Boolean(bottomContent) && (\n <div className=\"ndl-ai-prompt-textarea-below-leading\">\n {bottomContent}\n </div>\n )}\n </div>\n </div>\n <SubmitPromptButton\n isDisabled={isSubmitDisabled}\n isRunningPrompt={isRunningPrompt}\n onSubmit={onSubmitPrompt}\n onCancel={onCancelPrompt}\n />\n </div>\n {Boolean(disclaimer) && (\n <Typography variant=\"body-small\" className=\"ndl-ai-prompt-footer\">\n {disclaimer}\n </Typography>\n )}\n </div>\n );\n};\n\nconst SubmitPromptButton = ({\n onSubmit,\n onCancel,\n isDisabled,\n isRunningPrompt,\n}: {\n isDisabled?: boolean;\n isRunningPrompt?: boolean;\n onSubmit?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n onCancel?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}) => {\n return (\n <div\n className={classNames('ndl-ai-prompt-button-container', {\n 'ndl-in-loading': isRunningPrompt,\n })}\n >\n <Tooltip\n type=\"simple\"\n isDisabled={isDisabled || isRunningPrompt}\n hoverDelay={{ close: 0, open: 500 }}\n shouldCloseOnReferenceClick={true}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <button\n type=\"button\"\n style={{\n borderRadius: isRunningPrompt\n ? 'var(--border-radius-sm)'\n : 'var(--border-radius-lg)',\n }}\n onClick={isRunningPrompt ? onCancel : onSubmit}\n disabled={isDisabled}\n aria-label={isRunningPrompt ? 'Stop' : 'Send'}\n >\n {isRunningPrompt === true ? (\n <OutlinedButton\n as=\"div\"\n variant=\"neutral\"\n className=\"ndl-ai-prompt-stop-button\"\n size=\"small\"\n isDisabled={isDisabled}\n leadingVisual={<StopIconOutline />}\n >\n Stop\n </OutlinedButton>\n ) : (\n <CleanIconButton\n description=\"Send\"\n as=\"div\"\n className=\"ndl-ai-prompt-submit-button\"\n size=\"medium\"\n isDisabled={isDisabled}\n htmlAttributes={{\n 'aria-pressed': undefined,\n }}\n >\n <ArrowSmallUpIconOutline />\n </CleanIconButton>\n )}\n </button>\n </Tooltip.Trigger>\n <Tooltip.Content>Send</Tooltip.Content>\n </Tooltip>\n </div>\n );\n};\n\ntype AgentSelectProps = {\n value: { label: React.ReactNode; value: string };\n options: Array<{ label: React.ReactNode; value: string }>;\n onChange: (option: { label: React.ReactNode; value: string }) => void;\n};\n\nconst AgentSelect = ({ value, options = [], onChange }: AgentSelectProps) => {\n const anchorRef = useRef<HTMLButtonElement>(null);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n\n const displayLabel = value?.label ?? options[0]?.label ?? '';\n\n const handleItemClick = (option: {\n label: React.ReactNode;\n value: string;\n }) => {\n onChange?.(option);\n setIsMenuOpen(false);\n };\n\n return (\n <>\n <DropdownButton\n size=\"small\"\n className=\"ndl-ai-prompt-dropdown-button\"\n onClick={() => setIsMenuOpen((old) => !old)}\n isOpen={isMenuOpen}\n ref={anchorRef}\n >\n {displayLabel}\n </DropdownButton>\n <Menu\n isOpen={isMenuOpen}\n onClose={() => setIsMenuOpen(false)}\n anchorRef={anchorRef}\n placement=\"top-start-bottom-start\"\n >\n {options.map((option) => (\n <Menu.RadioItem\n key={option.value}\n title={option.label}\n isChecked={value?.value === option.value}\n onClick={() => handleItemClick(option)}\n />\n ))}\n </Menu>\n </>\n );\n};\n\ntype ContextTagProps = {\n children?: string;\n onClose: () => void;\n};\n\nconst ContextTag = ({ children, onClose }: ContextTagProps) => {\n const textRef = useRef<HTMLSpanElement>(null);\n const [isTooltipOpen, setIsTooltipOpen] = useState(false);\n\n return (\n <Tooltip\n type=\"simple\"\n isOpen={isTooltipOpen}\n onOpenChange={(isOpen) => {\n if (isOpen) {\n const isTruncated =\n textRef.current?.scrollWidth &&\n textRef.current?.clientWidth &&\n textRef.current.scrollWidth > textRef.current.clientWidth;\n if (isTruncated) {\n setIsTooltipOpen(true);\n }\n } else {\n setIsTooltipOpen(false);\n }\n }}\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger hasButtonWrapper>\n <div className=\"ndl-ai-prompt-context-tag\">\n <ArrowSendIcon className=\"ndl-ai-prompt-context-tag-icon\" />\n <Typography\n variant=\"body-medium\"\n className=\"ndl-ai-prompt-context-tag-text\"\n ref={textRef}\n >\n {children}\n </Typography>\n\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={`Remove context: ${children}`}\n className=\"ndl-ai-prompt-context-tag-close-button\"\n >\n <XMarkIconOutline className=\"ndl-ai-prompt-context-tag-icon\" />\n </button>\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>{children}</Tooltip.Content>\n </Tooltip>\n );\n};\n\nconst Prompt = Object.assign(PromptComponent, {\n ContextTag: ContextTag,\n Select: AgentSelect,\n});\n\nexport { Prompt };\n"]}
|
|
@@ -20,7 +20,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
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 { CleanIconButton } from '@neo4j-ndl/react';
|
|
23
24
|
import { Prompt } from '@neo4j-ndl/react/ai';
|
|
25
|
+
import { PlusIconOutline } from '@neo4j-ndl/react/icons';
|
|
24
26
|
import { useState } from 'react';
|
|
25
27
|
const Component = () => {
|
|
26
28
|
const [prompt, setPrompt] = useState('');
|
|
@@ -30,7 +32,7 @@ const Component = () => {
|
|
|
30
32
|
alert(`You submitted the following prompt: ${prompt}`);
|
|
31
33
|
setPrompt('');
|
|
32
34
|
};
|
|
33
|
-
return (_jsx(Prompt, { isRunningPrompt: isRunningPrompt, value: prompt, onChange: (e) => setPrompt(e.target.value), onSubmitPrompt: handleSubmitPrompt, onCancelPrompt: () => setIsRunningPrompt(false) }));
|
|
35
|
+
return (_jsx(Prompt, { isRunningPrompt: isRunningPrompt, value: prompt, onChange: (e) => setPrompt(e.target.value), onSubmitPrompt: handleSubmitPrompt, onCancelPrompt: () => setIsRunningPrompt(false), bottomContent: _jsx(CleanIconButton, { description: "Add files", size: "small", children: _jsx(PlusIconOutline, {}) }) }));
|
|
34
36
|
};
|
|
35
37
|
export default Component;
|
|
36
38
|
//# sourceMappingURL=prompt-default.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-default.story.js","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-default.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACzC,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9D,MAAM,kBAAkB,GAAG,GAAG,EAAE;QAC9B,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACzB,KAAK,CAAC,uCAAuC,MAAM,EAAE,CAAC,CAAC;QACvD,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,MAAM,IACL,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,CAAyC,EAAE,EAAE,CACtD,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAE3B,cAAc,EAAE,kBAAkB,EAClC,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"prompt-default.story.js","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-default.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACzC,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9D,MAAM,kBAAkB,GAAG,GAAG,EAAE;QAC9B,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACzB,KAAK,CAAC,uCAAuC,MAAM,EAAE,CAAC,CAAC;QACvD,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,MAAM,IACL,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,CAAyC,EAAE,EAAE,CACtD,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAE3B,cAAc,EAAE,kBAAkB,EAClC,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAC/C,aAAa,EACX,KAAC,eAAe,IAAC,WAAW,EAAC,WAAW,EAAC,IAAI,EAAC,OAAO,YACnD,KAAC,eAAe,KAAG,GACH,GAEpB,CACH,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 { CleanIconButton } from '@neo4j-ndl/react';\nimport { Prompt } from '@neo4j-ndl/react/ai';\nimport { PlusIconOutline } from '@neo4j-ndl/react/icons';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [prompt, setPrompt] = useState('');\n const [isRunningPrompt, setIsRunningPrompt] = useState(false);\n\n const handleSubmitPrompt = () => {\n setIsRunningPrompt(true);\n alert(`You submitted the following prompt: ${prompt}`);\n setPrompt('');\n };\n\n return (\n <Prompt\n isRunningPrompt={isRunningPrompt}\n value={prompt}\n onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) =>\n setPrompt(e.target.value)\n }\n onSubmitPrompt={handleSubmitPrompt}\n onCancelPrompt={() => setIsRunningPrompt(false)}\n bottomContent={\n <CleanIconButton description=\"Add files\" size=\"small\">\n <PlusIconOutline />\n </CleanIconButton>\n }\n />\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -20,11 +20,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
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 { CleanIconButton } from '@neo4j-ndl/react';
|
|
23
24
|
import { Prompt } from '@neo4j-ndl/react/ai';
|
|
25
|
+
import { PlusIconOutline } from '@neo4j-ndl/react/icons';
|
|
24
26
|
import { useState } from 'react';
|
|
25
27
|
const Component = () => {
|
|
26
28
|
const [isRunningPrompt, setIsRunningPrompt] = useState(true);
|
|
27
|
-
return (_jsx(Prompt, { isRunningPrompt: isRunningPrompt, onSubmitPrompt: () => setIsRunningPrompt(true), onCancelPrompt: () => setIsRunningPrompt(false) }));
|
|
29
|
+
return (_jsx(Prompt, { isRunningPrompt: isRunningPrompt, onSubmitPrompt: () => setIsRunningPrompt(true), onCancelPrompt: () => setIsRunningPrompt(false), bottomContent: _jsx(CleanIconButton, { description: "Add files", size: "small", children: _jsx(PlusIconOutline, {}) }) }));
|
|
28
30
|
};
|
|
29
31
|
export default Component;
|
|
30
32
|
//# sourceMappingURL=prompt-loading.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-loading.story.js","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-loading.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE7D,OAAO,CACL,KAAC,MAAM,IACL,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAC9C,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"prompt-loading.story.js","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-loading.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE7D,OAAO,CACL,KAAC,MAAM,IACL,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAC9C,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAC/C,aAAa,EACX,KAAC,eAAe,IAAC,WAAW,EAAC,WAAW,EAAC,IAAI,EAAC,OAAO,YACnD,KAAC,eAAe,KAAG,GACH,GAEpB,CACH,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 { CleanIconButton } from '@neo4j-ndl/react';\nimport { Prompt } from '@neo4j-ndl/react/ai';\nimport { PlusIconOutline } from '@neo4j-ndl/react/icons';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [isRunningPrompt, setIsRunningPrompt] = useState(true);\n\n return (\n <Prompt\n isRunningPrompt={isRunningPrompt}\n onSubmitPrompt={() => setIsRunningPrompt(true)}\n onCancelPrompt={() => setIsRunningPrompt(false)}\n bottomContent={\n <CleanIconButton description=\"Add files\" size=\"small\">\n <PlusIconOutline />\n </CleanIconButton>\n }\n />\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-default.story.d.ts","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-default.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-default.story.d.ts","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-default.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAOjD,QAAA,MAAM,SAAS,+CA0Bd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-loading.story.d.ts","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-loading.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-loading.story.d.ts","sourceRoot":"","sources":["../../../../../src/ai/prompt/stories/prompt-loading.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAOjD,QAAA,MAAM,SAAS,+CAed,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-ndl/react",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.41",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "React implementation of Neo4j Design System",
|
|
6
6
|
"keywords": [
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@tanstack/react-table": "8.21.3",
|
|
88
88
|
"react": ">=19.0.0",
|
|
89
89
|
"react-dom": ">=19.0.0",
|
|
90
|
-
"@neo4j-ndl/base": "^4.9.
|
|
90
|
+
"@neo4j-ndl/base": "^4.9.19"
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@dnd-kit/core": "6.3.1",
|