@langchain/macaw-components 1.7.6 → 1.7.8
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/dist/catalog.json +752 -719
- package/dist/components/ChatComposer/ChatComposer.d.ts +5 -0
- package/dist/components/ChatComposer/ChatComposer.js +2 -2
- package/dist/components/ChatComposer/ChatComposer.js.map +1 -1
- package/dist/components/ChatComposer/ChatComposerPlainInput.d.ts +1 -1
- package/dist/components/ChatComposer/ChatComposerPlainInput.js +7 -33
- package/dist/components/ChatComposer/ChatComposerPlainInput.js.map +1 -1
- package/dist/components/ChatComposer/ChatComposerTextarea.d.ts +15 -0
- package/dist/components/ChatComposer/ChatComposerTextarea.js +51 -0
- package/dist/components/ChatComposer/ChatComposerTextarea.js.map +1 -0
- package/dist/components/ChatComposer/index.d.ts +2 -0
- package/dist/components/ChatComposer/index.js +2 -1
- package/dist/components/ChatConversationList/ChatConversationListActions.js +17 -2
- package/dist/components/ChatConversationList/ChatConversationListActions.js.map +1 -1
- package/dist/components/LineChart/LineChartPlot.js +14 -5
- package/dist/components/LineChart/LineChartPlot.js.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +2 -1
- package/dist/index.js +2 -1
- package/docs/DESIGN.md +9 -3
- package/package.json +2 -2
|
@@ -9,6 +9,11 @@ export type ChatComposerProps = ComponentPropsWithRef<'form'> & {
|
|
|
9
9
|
* content should also say it in text or with an icon.
|
|
10
10
|
*/
|
|
11
11
|
drawerIntent?: ChatComposerDrawerIntent;
|
|
12
|
+
/**
|
|
13
|
+
* Blocks writing and sending. Stop stays available while `action` is
|
|
14
|
+
* `stop`, so host controls inside the composer must take `disabled`
|
|
15
|
+
* themselves to stay disabled during a response.
|
|
16
|
+
*/
|
|
12
17
|
disabled?: boolean;
|
|
13
18
|
submitDisabled?: boolean;
|
|
14
19
|
onFilesSelected?: (files: File[]) => void;
|
|
@@ -91,7 +91,7 @@ function ChatComposer({ children, drawer, drawerIntent = "neutral", className, r
|
|
|
91
91
|
children: drawer
|
|
92
92
|
}), /* @__PURE__ */ jsx("fieldset", {
|
|
93
93
|
ref: fieldsetRef,
|
|
94
|
-
disabled,
|
|
94
|
+
disabled: disabled && action !== "stop",
|
|
95
95
|
className: cn("relative m-0 flex w-full min-w-0 flex-col gap-space-2 rounded-lg border border-subtle bg-elevated p-space-2 transition-[border-color,box-shadow,background-color] duration-normal motion-reduce:transition-none", "has-[:is(textarea,[contenteditable=true]):focus]:border-focus has-[:is(textarea,[contenteditable=true]):focus]:shadow-[0_0_0_1px_var(--border-focus)]", disabled && "border-disabled bg-input-disabled", isDropTarget && !disabled && "border-focus bg-surface-level-2 shadow-[0_0_0_1px_var(--border-focus)]"),
|
|
96
96
|
children
|
|
97
97
|
})]
|
|
@@ -131,7 +131,7 @@ function ChatComposerAction({ disabled, label, ...props }) {
|
|
|
131
131
|
type: isStop ? "button" : "submit",
|
|
132
132
|
icon: isStop ? StopIcon : ArrowUpIcon,
|
|
133
133
|
label: label ?? ACTION_LABELS[composer.action],
|
|
134
|
-
disabled:
|
|
134
|
+
disabled: disabled || !isStop && !composer.canSubmit,
|
|
135
135
|
loading: composer.action === "sending",
|
|
136
136
|
onClick: isStop ? composer.onStop : void 0
|
|
137
137
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposer.js","names":[],"sources":["../../../src/components/ChatComposer/ChatComposer.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from 'react';\nimport { useRef, useState } from 'react';\n\nimport { ArrowUpIcon } from '@phosphor-icons/react/dist/ssr/ArrowUp';\nimport { StopIcon } from '@phosphor-icons/react/dist/ssr/Stop';\n\nimport { cn } from '../../utils/cn';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport { IconButton } from '../IconButton';\nimport type { IconButtonProps } from '../IconButton';\nimport {\n ChatComposerContext,\n type ChatComposerContextValue,\n useChatComposerContext,\n} from './ChatComposerContext';\n\nexport type ChatComposerDrawerIntent = 'neutral' | 'info' | 'warning' | 'error';\n\nconst DRAWER_INTENT_CLASSES: Record<ChatComposerDrawerIntent, string> = {\n neutral: 'border-subtle bg-surface-level-2',\n info: 'border-brand-subtle bg-brand-subtle',\n warning: 'border-warning bg-warning',\n error: 'border-error bg-error',\n};\n\nexport type ChatComposerProps = ComponentPropsWithRef<'form'> & {\n /** Supplementary content attached above the editor, inside the composer form. */\n drawer?: ReactNode;\n /**\n * Drawer surface color. Color alone doesn't convey severity, so the drawer\n * content should also say it in text or with an icon.\n */\n drawerIntent?: ChatComposerDrawerIntent;\n disabled?: boolean;\n submitDisabled?: boolean;\n onFilesSelected?: (files: File[]) => void;\n} & (\n | { action?: 'send' | 'sending'; onStop?: never }\n | { action: 'stop'; onStop: () => void }\n );\n\n// A disabled or read-only part of the composer, such as a read-only message\n// input, does not accept input, so files dropped or pasted onto it are not\n// attached either.\nfunction isAttachmentTargetBlocked(target: EventTarget) {\n return (\n target instanceof Element &&\n target.closest(\n ':disabled, [readonly], [aria-disabled=\"true\"], [aria-readonly=\"true\"]'\n ) !== null\n );\n}\n\n// A fieldset is barred from constraint validation, so its own\n// reportValidity() never inspects the controls inside it.\nfunction reportFieldsetValidity(fieldset: HTMLFieldSetElement | null) {\n for (const element of fieldset?.elements ?? []) {\n if (\n (element instanceof HTMLInputElement ||\n element instanceof HTMLSelectElement ||\n element instanceof HTMLTextAreaElement) &&\n !element.reportValidity()\n )\n return false;\n }\n return true;\n}\n\nexport function ChatComposer({\n children,\n drawer,\n drawerIntent = 'neutral',\n className,\n ref,\n disabled = false,\n submitDisabled = false,\n action = 'send',\n onStop,\n onSubmit,\n onFilesSelected,\n onDragOver,\n onDragLeave,\n onDropCapture,\n onPasteCapture,\n noValidate,\n ...props\n}: ChatComposerProps) {\n const formRef = useRef<HTMLFormElement>(null);\n const [isDropTarget, setIsDropTarget] = useState(false);\n const canSubmit =\n !disabled && !submitDisabled && action === 'send' && !!onSubmit;\n const hasDrawer = Boolean(drawer);\n const fieldsetRef = useRef<HTMLFieldSetElement>(null);\n const inputFocusRef = useRef<(() => boolean) | null>(null);\n // Inert drawer fields cannot be focused to report errors, so the drawer's\n // host validates them; fields outside the drawer keep native checks.\n const validatesFieldsetOnly = noValidate === undefined && hasDrawer;\n\n return (\n <ChatComposerContext.Provider\n value={{\n disabled,\n canSubmit,\n action,\n onStop,\n onFilesSelected,\n inputFocusRef,\n submit: onSubmit\n ? () => {\n if (canSubmit) formRef.current?.requestSubmit();\n }\n : undefined,\n }}\n >\n <form\n {...props}\n ref={mergeRefs([formRef, ref])}\n noValidate={noValidate ?? hasDrawer}\n className={cn('isolate w-full min-w-0 @container/composer', className)}\n onSubmit={(event) => {\n event.preventDefault();\n if (!canSubmit) return;\n if (\n validatesFieldsetOnly &&\n !reportFieldsetValidity(fieldsetRef.current)\n )\n return;\n onSubmit?.(event);\n }}\n onDragOver={(event) => {\n onDragOver?.(event);\n if (event.defaultPrevented || !onFilesSelected) return;\n if (!event.dataTransfer.types.includes('Files')) return;\n event.preventDefault();\n const canAttach =\n !disabled && !isAttachmentTargetBlocked(event.target);\n event.dataTransfer.dropEffect = canAttach ? 'copy' : 'none';\n setIsDropTarget(canAttach);\n }}\n onDragLeave={(event) => {\n onDragLeave?.(event);\n if (\n !(event.relatedTarget instanceof Node) ||\n !event.currentTarget.contains(event.relatedTarget)\n ) {\n setIsDropTarget(false);\n }\n }}\n onDropCapture={(event) => {\n onDropCapture?.(event);\n setIsDropTarget(false);\n if (event.defaultPrevented || !onFilesSelected) return;\n const files = Array.from(event.dataTransfer.files);\n if (!files.length) return;\n event.preventDefault();\n if (!disabled && !isAttachmentTargetBlocked(event.target)) {\n onFilesSelected(files);\n }\n }}\n onPasteCapture={(event) => {\n onPasteCapture?.(event);\n if (event.defaultPrevented || !onFilesSelected) return;\n const files = Array.from(event.clipboardData.files);\n if (!files.length) return;\n if (disabled || isAttachmentTargetBlocked(event.target)) {\n event.preventDefault();\n return;\n }\n // Let the focused editor preserve mixed-paste text and its selection.\n if (!event.clipboardData.getData('text/plain')) {\n event.preventDefault();\n }\n onFilesSelected(files);\n }}\n >\n {hasDrawer && (\n <fieldset\n disabled={disabled}\n className={cn(\n // Extends under the composer's rounded top so the seam stays hidden.\n 'mx-space-3 -mb-space-3 max-h-[50dvh] min-w-0 overflow-y-auto overscroll-contain rounded-t-lg border border-b-0 pb-space-3 duration-normal ease-out animate-in fade-in slide-in-from-bottom-2 motion-reduce:animate-none',\n DRAWER_INTENT_CLASSES[drawerIntent],\n disabled && 'border-disabled'\n )}\n >\n {drawer}\n </fieldset>\n )}\n <fieldset\n ref={fieldsetRef}\n disabled={disabled}\n className={cn(\n 'relative m-0 flex w-full min-w-0 flex-col gap-space-2 rounded-lg border border-subtle bg-elevated p-space-2 transition-[border-color,box-shadow,background-color] duration-normal motion-reduce:transition-none',\n // Toolbar menus portal out, so focus-within would flash as focus\n // moves from their trigger to the menu; only typing shows focus.\n 'has-[:is(textarea,[contenteditable=true]):focus]:border-focus has-[:is(textarea,[contenteditable=true]):focus]:shadow-[0_0_0_1px_var(--border-focus)]',\n disabled && 'border-disabled bg-input-disabled',\n isDropTarget &&\n !disabled &&\n 'border-focus bg-surface-level-2 shadow-[0_0_0_1px_var(--border-focus)]'\n )}\n >\n {children}\n </fieldset>\n </form>\n </ChatComposerContext.Provider>\n );\n}\n\nexport interface ChatComposerToolbarProps extends ComponentPropsWithRef<'div'> {\n modelSelector?: ReactNode;\n actions?: ReactNode;\n}\n\nexport function ChatComposerToolbar({\n children,\n modelSelector,\n actions = <ChatComposerAction />,\n className,\n ...props\n}: ChatComposerToolbarProps) {\n return (\n <div\n {...props}\n className={cn('flex min-w-0 items-center gap-space-2', className)}\n >\n <div className=\"flex min-w-0 flex-1 flex-wrap items-center gap-space-1 @[440px]/composer:gap-space-2\">\n {children}\n {modelSelector != null && (\n <div className=\"min-w-0 max-w-full [&>*]:max-w-full\">\n {modelSelector}\n </div>\n )}\n </div>\n <div className=\"flex shrink-0 items-center gap-space-1\">{actions}</div>\n </div>\n );\n}\n\nconst ACTION_LABELS = {\n send: 'Send message',\n sending: 'Sending message',\n stop: 'Stop response',\n} satisfies Record<ChatComposerContextValue['action'], string>;\n\n// Pending sends use the composer's action=\"sending\", which also blocks the\n// send shortcuts; a button-level loading state would only block clicks.\nexport type ChatComposerActionProps = Omit<\n IconButtonProps,\n 'icon' | 'type' | 'onClick' | 'asChild' | 'label' | 'loading'\n> & { label?: string };\n\nexport function ChatComposerAction({\n disabled,\n label,\n ...props\n}: ChatComposerActionProps) {\n const composer = useChatComposerContext();\n const isStop = composer.action === 'stop';\n return (\n <IconButton\n size=\"sm\"\n round\n color=\"primary\"\n iconWeight=\"regular\"\n {...props}\n type={isStop ? 'button' : 'submit'}\n icon={isStop ? StopIcon : ArrowUpIcon}\n label={label ?? ACTION_LABELS[composer.action]}\n disabled={\n composer.disabled || disabled || (!isStop && !composer.canSubmit)\n }\n loading={composer.action === 'sending'}\n onClick={isStop ? composer.onStop : undefined}\n />\n );\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAM,wBAAkE;CACtE,SAAS;CACT,MAAM;CACN,SAAS;CACT,OAAO;AACT;AAqBA,SAAS,0BAA0B,QAAqB;CACtD,OACE,kBAAkB,WAClB,OAAO,QACL,2EACF,MAAM;AAEV;AAIA,SAAS,uBAAuB,UAAsC;CACpE,KAAK,MAAM,WAAW,UAAU,YAAY,CAAC,GAC3C,KACG,mBAAmB,oBAClB,mBAAmB,qBACnB,mBAAmB,wBACrB,CAAC,QAAQ,eAAe,GAExB,OAAO;CAEX,OAAO;AACT;AAEA,SAAgB,aAAa,EAC3B,UACA,QACA,eAAe,WACf,WACA,KACA,WAAW,OACX,iBAAiB,OACjB,SAAS,QACT,QACA,UACA,iBACA,YACA,aACA,eACA,gBACA,YACA,GAAG,SACiB;CACpB,MAAM,UAAU,OAAwB,IAAI;CAC5C,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK;CACtD,MAAM,YACJ,CAAC,YAAY,CAAC,k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GAAI;EACJ,MAAM,SAAS,WAAW;EAC1B,MAAM,SAAS,WAAW;EAC1B,OAAO,SAAS,cAAc,SAAS;EACvC,UACE,SAAS,YAAY,YAAa,CAAC,UAAU,CAAC,SAAS;EAEzD,SAAS,SAAS,WAAW;EAC7B,SAAS,SAAS,SAAS,SAAS,KAAA;CACrC,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"ChatComposer.js","names":[],"sources":["../../../src/components/ChatComposer/ChatComposer.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from 'react';\nimport { useRef, useState } from 'react';\n\nimport { ArrowUpIcon } from '@phosphor-icons/react/dist/ssr/ArrowUp';\nimport { StopIcon } from '@phosphor-icons/react/dist/ssr/Stop';\n\nimport { cn } from '../../utils/cn';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport { IconButton } from '../IconButton';\nimport type { IconButtonProps } from '../IconButton';\nimport {\n ChatComposerContext,\n type ChatComposerContextValue,\n useChatComposerContext,\n} from './ChatComposerContext';\n\nexport type ChatComposerDrawerIntent = 'neutral' | 'info' | 'warning' | 'error';\n\nconst DRAWER_INTENT_CLASSES: Record<ChatComposerDrawerIntent, string> = {\n neutral: 'border-subtle bg-surface-level-2',\n info: 'border-brand-subtle bg-brand-subtle',\n warning: 'border-warning bg-warning',\n error: 'border-error bg-error',\n};\n\nexport type ChatComposerProps = ComponentPropsWithRef<'form'> & {\n /** Supplementary content attached above the editor, inside the composer form. */\n drawer?: ReactNode;\n /**\n * Drawer surface color. Color alone doesn't convey severity, so the drawer\n * content should also say it in text or with an icon.\n */\n drawerIntent?: ChatComposerDrawerIntent;\n /**\n * Blocks writing and sending. Stop stays available while `action` is\n * `stop`, so host controls inside the composer must take `disabled`\n * themselves to stay disabled during a response.\n */\n disabled?: boolean;\n submitDisabled?: boolean;\n onFilesSelected?: (files: File[]) => void;\n} & (\n | { action?: 'send' | 'sending'; onStop?: never }\n | { action: 'stop'; onStop: () => void }\n );\n\n// A disabled or read-only part of the composer, such as a read-only message\n// input, does not accept input, so files dropped or pasted onto it are not\n// attached either.\nfunction isAttachmentTargetBlocked(target: EventTarget) {\n return (\n target instanceof Element &&\n target.closest(\n ':disabled, [readonly], [aria-disabled=\"true\"], [aria-readonly=\"true\"]'\n ) !== null\n );\n}\n\n// A fieldset is barred from constraint validation, so its own\n// reportValidity() never inspects the controls inside it.\nfunction reportFieldsetValidity(fieldset: HTMLFieldSetElement | null) {\n for (const element of fieldset?.elements ?? []) {\n if (\n (element instanceof HTMLInputElement ||\n element instanceof HTMLSelectElement ||\n element instanceof HTMLTextAreaElement) &&\n !element.reportValidity()\n )\n return false;\n }\n return true;\n}\n\nexport function ChatComposer({\n children,\n drawer,\n drawerIntent = 'neutral',\n className,\n ref,\n disabled = false,\n submitDisabled = false,\n action = 'send',\n onStop,\n onSubmit,\n onFilesSelected,\n onDragOver,\n onDragLeave,\n onDropCapture,\n onPasteCapture,\n noValidate,\n ...props\n}: ChatComposerProps) {\n const formRef = useRef<HTMLFormElement>(null);\n const [isDropTarget, setIsDropTarget] = useState(false);\n const canSubmit =\n !disabled && !submitDisabled && action === 'send' && !!onSubmit;\n const hasDrawer = Boolean(drawer);\n const fieldsetRef = useRef<HTMLFieldSetElement>(null);\n const inputFocusRef = useRef<(() => boolean) | null>(null);\n // Inert drawer fields cannot be focused to report errors, so the drawer's\n // host validates them; fields outside the drawer keep native checks.\n const validatesFieldsetOnly = noValidate === undefined && hasDrawer;\n\n return (\n <ChatComposerContext.Provider\n value={{\n disabled,\n canSubmit,\n action,\n onStop,\n onFilesSelected,\n inputFocusRef,\n submit: onSubmit\n ? () => {\n if (canSubmit) formRef.current?.requestSubmit();\n }\n : undefined,\n }}\n >\n <form\n {...props}\n ref={mergeRefs([formRef, ref])}\n noValidate={noValidate ?? hasDrawer}\n className={cn('isolate w-full min-w-0 @container/composer', className)}\n onSubmit={(event) => {\n event.preventDefault();\n if (!canSubmit) return;\n if (\n validatesFieldsetOnly &&\n !reportFieldsetValidity(fieldsetRef.current)\n )\n return;\n onSubmit?.(event);\n }}\n onDragOver={(event) => {\n onDragOver?.(event);\n if (event.defaultPrevented || !onFilesSelected) return;\n if (!event.dataTransfer.types.includes('Files')) return;\n event.preventDefault();\n const canAttach =\n !disabled && !isAttachmentTargetBlocked(event.target);\n event.dataTransfer.dropEffect = canAttach ? 'copy' : 'none';\n setIsDropTarget(canAttach);\n }}\n onDragLeave={(event) => {\n onDragLeave?.(event);\n if (\n !(event.relatedTarget instanceof Node) ||\n !event.currentTarget.contains(event.relatedTarget)\n ) {\n setIsDropTarget(false);\n }\n }}\n onDropCapture={(event) => {\n onDropCapture?.(event);\n setIsDropTarget(false);\n if (event.defaultPrevented || !onFilesSelected) return;\n const files = Array.from(event.dataTransfer.files);\n if (!files.length) return;\n event.preventDefault();\n if (!disabled && !isAttachmentTargetBlocked(event.target)) {\n onFilesSelected(files);\n }\n }}\n onPasteCapture={(event) => {\n onPasteCapture?.(event);\n if (event.defaultPrevented || !onFilesSelected) return;\n const files = Array.from(event.clipboardData.files);\n if (!files.length) return;\n if (disabled || isAttachmentTargetBlocked(event.target)) {\n event.preventDefault();\n return;\n }\n // Let the focused editor preserve mixed-paste text and its selection.\n if (!event.clipboardData.getData('text/plain')) {\n event.preventDefault();\n }\n onFilesSelected(files);\n }}\n >\n {hasDrawer && (\n <fieldset\n disabled={disabled}\n className={cn(\n // Extends under the composer's rounded top so the seam stays hidden.\n 'mx-space-3 -mb-space-3 max-h-[50dvh] min-w-0 overflow-y-auto overscroll-contain rounded-t-lg border border-b-0 pb-space-3 duration-normal ease-out animate-in fade-in slide-in-from-bottom-2 motion-reduce:animate-none',\n DRAWER_INTENT_CLASSES[drawerIntent],\n disabled && 'border-disabled'\n )}\n >\n {drawer}\n </fieldset>\n )}\n <fieldset\n ref={fieldsetRef}\n // A disabled fieldset would also disable Stop; the composer's own\n // parts read `disabled` from context instead.\n disabled={disabled && action !== 'stop'}\n className={cn(\n 'relative m-0 flex w-full min-w-0 flex-col gap-space-2 rounded-lg border border-subtle bg-elevated p-space-2 transition-[border-color,box-shadow,background-color] duration-normal motion-reduce:transition-none',\n // Toolbar menus portal out, so focus-within would flash as focus\n // moves from their trigger to the menu; only typing shows focus.\n 'has-[:is(textarea,[contenteditable=true]):focus]:border-focus has-[:is(textarea,[contenteditable=true]):focus]:shadow-[0_0_0_1px_var(--border-focus)]',\n disabled && 'border-disabled bg-input-disabled',\n isDropTarget &&\n !disabled &&\n 'border-focus bg-surface-level-2 shadow-[0_0_0_1px_var(--border-focus)]'\n )}\n >\n {children}\n </fieldset>\n </form>\n </ChatComposerContext.Provider>\n );\n}\n\nexport interface ChatComposerToolbarProps extends ComponentPropsWithRef<'div'> {\n modelSelector?: ReactNode;\n actions?: ReactNode;\n}\n\nexport function ChatComposerToolbar({\n children,\n modelSelector,\n actions = <ChatComposerAction />,\n className,\n ...props\n}: ChatComposerToolbarProps) {\n return (\n <div\n {...props}\n className={cn('flex min-w-0 items-center gap-space-2', className)}\n >\n <div className=\"flex min-w-0 flex-1 flex-wrap items-center gap-space-1 @[440px]/composer:gap-space-2\">\n {children}\n {modelSelector != null && (\n <div className=\"min-w-0 max-w-full [&>*]:max-w-full\">\n {modelSelector}\n </div>\n )}\n </div>\n <div className=\"flex shrink-0 items-center gap-space-1\">{actions}</div>\n </div>\n );\n}\n\nconst ACTION_LABELS = {\n send: 'Send message',\n sending: 'Sending message',\n stop: 'Stop response',\n} satisfies Record<ChatComposerContextValue['action'], string>;\n\n// Pending sends use the composer's action=\"sending\", which also blocks the\n// send shortcuts; a button-level loading state would only block clicks.\nexport type ChatComposerActionProps = Omit<\n IconButtonProps,\n 'icon' | 'type' | 'onClick' | 'asChild' | 'label' | 'loading'\n> & { label?: string };\n\nexport function ChatComposerAction({\n disabled,\n label,\n ...props\n}: ChatComposerActionProps) {\n const composer = useChatComposerContext();\n const isStop = composer.action === 'stop';\n return (\n <IconButton\n size=\"sm\"\n round\n color=\"primary\"\n iconWeight=\"regular\"\n {...props}\n type={isStop ? 'button' : 'submit'}\n icon={isStop ? StopIcon : ArrowUpIcon}\n label={label ?? ACTION_LABELS[composer.action]}\n // canSubmit already accounts for a disabled composer; Stop ignores it.\n disabled={disabled || (!isStop && !composer.canSubmit)}\n loading={composer.action === 'sending'}\n onClick={isStop ? composer.onStop : undefined}\n />\n );\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAM,wBAAkE;CACtE,SAAS;CACT,MAAM;CACN,SAAS;CACT,OAAO;AACT;AA0BA,SAAS,0BAA0B,QAAqB;CACtD,OACE,kBAAkB,WAClB,OAAO,QACL,2EACF,MAAM;AAEV;AAIA,SAAS,uBAAuB,UAAsC;CACpE,KAAK,MAAM,WAAW,UAAU,YAAY,CAAC,GAC3C,KACG,mBAAmB,oBAClB,mBAAmB,qBACnB,mBAAmB,wBACrB,CAAC,QAAQ,eAAe,GAExB,OAAO;CAEX,OAAO;AACT;AAEA,SAAgB,aAAa,EAC3B,UACA,QACA,eAAe,WACf,WACA,KACA,WAAW,OACX,iBAAiB,OACjB,SAAS,QACT,QACA,UACA,iBACA,YACA,aACA,eACA,gBACA,YACA,GAAG,SACiB;CACpB,MAAM,UAAU,OAAwB,IAAI;CAC5C,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK;CACtD,MAAM,YACJ,CAAC,YAAY,CAAC,kBAAkB,WAAW,UAAU,CAAC,CAAC;CACzD,MAAM,YAAY,QAAQ,MAAM;CAChC,MAAM,cAAc,OAA4B,IAAI;CACpD,MAAM,gBAAgB,OAA+B,IAAI;CAGzD,MAAM,wBAAwB,eAAe,KAAA,KAAa;CAE1D,OACE,oBAAC,oBAAoB,UAArB;EACE,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA,QAAQ,iBACE;IACJ,IAAI,WAAW,QAAQ,SAAS,cAAc;GAChD,IACA,KAAA;EACN;EAEA,UAAA,qBAAC,QAAD;GACE,GAAI;GACJ,KAAK,UAAU,CAAC,SAAS,GAAG,CAAC;GAC7B,YAAY,cAAc;GAC1B,W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sBAAsB,eACtB,YAAY,iBACd;IAEC,UAAA;GACO,CAAA,GAEZ,oBAAC,YAAD;IACE,KAAK;IAGL,UAAU,YAAY,WAAW;IACjC,WAAW,GACT,mNAGA,yJACA,YAAY,qCACZ,gBACE,CAAC,YACD,wEACJ;IAEC;GACO,CAAA,CACN;;CACsB,CAAA;AAElC;AAOA,SAAgB,oBAAoB,EAClC,UACA,eACA,UAAU,oBAAC,oBAAD,CAAqB,CAAA,GAC/B,WACA,GAAG,SACwB;CAC3B,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,WAAW,GAAG,yCAAyC,SAAS;EAFlE,UAAA,CAIE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACG,UACA,iBAAiB,QAChB,oBAAC,OAAD;IAAK,WAAU;IACZ,UAAA;GACE,CAAA,CAEJ;EACL,CAAA,GAAA,oBAAC,OAAD;GAAK,WAAU;GAA0C,UAAA;EAAa,CAAA,CACnE;;AAET;AAEA,IAAM,gBAAgB;CACpB,MAAM;CACN,SAAS;CACT,MAAM;AACR;AASA,SAAgB,mBAAmB,EACjC,UACA,OACA,GAAG,SACuB;CAC1B,MAAM,WAAW,uBAAuB;CACxC,MAAM,SAAS,SAAS,WAAW;CACnC,OACE,oBAAC,YAAD;EACE,MAAK;EACL,OAAA;EACA,OAAM;EACN,YAAW;EACX,GAAI;EACJ,MAAM,SAAS,WAAW;EAC1B,MAAM,SAAS,WAAW;EAC1B,OAAO,SAAS,cAAc,SAAS;EAEvC,UAAU,YAAa,CAAC,UAAU,CAAC,SAAS;EAC5C,SAAS,SAAS,WAAW;EAC7B,SAAS,SAAS,SAAS,SAAS,KAAA;CACrC,CAAA;AAEL"}
|
|
@@ -4,5 +4,5 @@ interface ChatComposerPlainInputProps extends ChatComposerInputProps {
|
|
|
4
4
|
maxHeight: number;
|
|
5
5
|
}
|
|
6
6
|
/** Keeps the composer usable with plain Markdown text when the rich editor fails. */
|
|
7
|
-
export declare function ChatComposerPlainInput({ ref,
|
|
7
|
+
export declare function ChatComposerPlainInput({ ref, ...props }: ChatComposerPlainInputProps): import("react").JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,45 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useChatComposerContext } from "./ChatComposerContext.js";
|
|
2
|
+
import { ChatComposerTextarea } from "./ChatComposerTextarea.js";
|
|
3
3
|
import { useImperativeHandle, useRef } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region packages/components/src/components/ChatComposer/ChatComposerPlainInput.tsx
|
|
6
6
|
/** Keeps the composer usable with plain Markdown text when the rich editor fails. */
|
|
7
|
-
function ChatComposerPlainInput({ ref,
|
|
7
|
+
function ChatComposerPlainInput({ ref, ...props }) {
|
|
8
8
|
const composer = useChatComposerContext();
|
|
9
9
|
const textareaRef = useRef(null);
|
|
10
|
-
const
|
|
11
|
-
const editable = !isDisabled && !readOnly;
|
|
10
|
+
const editable = !composer.disabled && !props.disabled && !(props.readOnly ?? false);
|
|
12
11
|
useImperativeHandle(ref, () => ({ focus: () => {
|
|
13
12
|
if (editable) textareaRef.current?.focus();
|
|
14
13
|
} }), [editable]);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
textareaRef
|
|
18
|
-
return true;
|
|
19
|
-
}, [editable]);
|
|
20
|
-
return /* @__PURE__ */ jsx(Textarea, {
|
|
21
|
-
ref: textareaRef,
|
|
22
|
-
variant: "plain",
|
|
23
|
-
size: "md",
|
|
24
|
-
rows: 1,
|
|
25
|
-
autoResize: true,
|
|
26
|
-
maxHeight,
|
|
27
|
-
value,
|
|
28
|
-
onChange,
|
|
29
|
-
placeholder,
|
|
30
|
-
disabled: isDisabled,
|
|
31
|
-
readOnly,
|
|
32
|
-
autoFocus,
|
|
33
|
-
"aria-label": ariaLabel,
|
|
34
|
-
"aria-describedby": ariaDescribedBy,
|
|
35
|
-
className,
|
|
36
|
-
style: { minHeight },
|
|
37
|
-
onKeyDown: (event) => {
|
|
38
|
-
if (!composer.submit || !editable) return;
|
|
39
|
-
if (!isComposerSubmitKey(event.nativeEvent)) return;
|
|
40
|
-
event.preventDefault();
|
|
41
|
-
composer.submit();
|
|
42
|
-
}
|
|
14
|
+
return /* @__PURE__ */ jsx(ChatComposerTextarea, {
|
|
15
|
+
...props,
|
|
16
|
+
ref: textareaRef
|
|
43
17
|
});
|
|
44
18
|
}
|
|
45
19
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposerPlainInput.js","names":[],"sources":["../../../src/components/ChatComposer/ChatComposerPlainInput.tsx"],"sourcesContent":["import { useImperativeHandle, useRef } from 'react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"ChatComposerPlainInput.js","names":[],"sources":["../../../src/components/ChatComposer/ChatComposerPlainInput.tsx"],"sourcesContent":["import { useImperativeHandle, useRef } from 'react';\n\nimport { useChatComposerContext } from './ChatComposerContext';\nimport type { ChatComposerInputProps } from './ChatComposerInput';\nimport { ChatComposerTextarea } from './ChatComposerTextarea';\n\ninterface ChatComposerPlainInputProps extends ChatComposerInputProps {\n minHeight: number;\n maxHeight: number;\n}\n\n/** Keeps the composer usable with plain Markdown text when the rich editor fails. */\nexport function ChatComposerPlainInput({\n ref,\n ...props\n}: ChatComposerPlainInputProps) {\n const composer = useChatComposerContext();\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const editable =\n !composer.disabled && !props.disabled && !(props.readOnly ?? false);\n\n useImperativeHandle(\n ref,\n () => ({\n focus: () => {\n if (editable) textareaRef.current?.focus();\n },\n }),\n [editable]\n );\n\n return <ChatComposerTextarea {...props} ref={textareaRef} />;\n}\n"],"mappings":";;;;;;AAYA,SAAgB,uBAAuB,EACrC,KACA,GAAG,SAC2B;CAC9B,MAAM,WAAW,uBAAuB;CACxC,MAAM,cAAc,OAA4B,IAAI;CACpD,MAAM,WACJ,CAAC,SAAS,YAAY,CAAC,MAAM,YAAY,EAAE,MAAM,YAAY;CAE/D,oBACE,YACO,EACL,aAAa;EACX,IAAI,UAAU,YAAY,SAAS,MAAM;CAC3C,EACF,IACA,CAAC,QAAQ,CACX;CAEA,OAAO,oBAAC,sBAAD;EAAsB,GAAI;EAAO,KAAK;CAAc,CAAA;AAC7D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef } from 'react';
|
|
2
|
+
import { Textarea } from '../Textarea/index.js';
|
|
3
|
+
export type ChatComposerTextareaProps = Omit<ComponentPropsWithRef<typeof Textarea>, 'variant' | 'rows' | 'resize' | 'autoResize' | 'label' | 'hintText' | 'isError' | 'leftDecorator' | 'rightDecorator'> & {
|
|
4
|
+
/** Height in px before the text grows. */
|
|
5
|
+
minHeight?: number;
|
|
6
|
+
/** Height in px the field grows to before it scrolls. */
|
|
7
|
+
maxHeight?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A plain-text message field for hosts that need the native textarea: its
|
|
11
|
+
* ref and selection, a `name` for form data, or their own key handling. Enter
|
|
12
|
+
* sends through the composer unless the host's `onKeyDown` prevents it;
|
|
13
|
+
* Shift+Enter adds a line.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ChatComposerTextarea({ ref, disabled, readOnly, size, minHeight, maxHeight, placeholder, 'aria-label': ariaLabel, style, onKeyDown, ...props }: ChatComposerTextareaProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
2
|
+
import { isComposerSubmitKey, useChatComposerContext } from "./ChatComposerContext.js";
|
|
3
|
+
import { Textarea } from "../Textarea/Textarea.js";
|
|
4
|
+
import { useImperativeHandle, useRef } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region packages/components/src/components/ChatComposer/ChatComposerTextarea.tsx
|
|
7
|
+
/**
|
|
8
|
+
* A plain-text message field for hosts that need the native textarea: its
|
|
9
|
+
* ref and selection, a `name` for form data, or their own key handling. Enter
|
|
10
|
+
* sends through the composer unless the host's `onKeyDown` prevents it;
|
|
11
|
+
* Shift+Enter adds a line.
|
|
12
|
+
*/
|
|
13
|
+
function ChatComposerTextarea({ ref, disabled = false, readOnly = false, size = "md", minHeight = 40, maxHeight = 240, placeholder = "Write a message…", "aria-label": ariaLabel = "Message", style, onKeyDown, ...props }) {
|
|
14
|
+
const composer = useChatComposerContext();
|
|
15
|
+
const textareaRef = useRef(null);
|
|
16
|
+
const isDisabled = composer.disabled || disabled;
|
|
17
|
+
const editable = !isDisabled && !readOnly;
|
|
18
|
+
useImperativeHandle(composer.inputFocusRef, () => () => {
|
|
19
|
+
if (!editable || !textareaRef.current) return false;
|
|
20
|
+
textareaRef.current.focus();
|
|
21
|
+
return true;
|
|
22
|
+
}, [editable]);
|
|
23
|
+
return /* @__PURE__ */ jsx(Textarea, {
|
|
24
|
+
...props,
|
|
25
|
+
ref: mergeRefs([textareaRef, ref]),
|
|
26
|
+
variant: "plain",
|
|
27
|
+
size,
|
|
28
|
+
rows: 1,
|
|
29
|
+
autoResize: true,
|
|
30
|
+
maxHeight,
|
|
31
|
+
placeholder,
|
|
32
|
+
disabled: isDisabled,
|
|
33
|
+
readOnly,
|
|
34
|
+
"aria-label": ariaLabel,
|
|
35
|
+
style: {
|
|
36
|
+
minHeight,
|
|
37
|
+
...style
|
|
38
|
+
},
|
|
39
|
+
onKeyDown: (event) => {
|
|
40
|
+
onKeyDown?.(event);
|
|
41
|
+
if (event.defaultPrevented || !composer.submit || !editable) return;
|
|
42
|
+
if (!isComposerSubmitKey(event.nativeEvent)) return;
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
composer.submit();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { ChatComposerTextarea };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=ChatComposerTextarea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatComposerTextarea.js","names":[],"sources":["../../../src/components/ChatComposer/ChatComposerTextarea.tsx"],"sourcesContent":["import { type ComponentPropsWithRef, useImperativeHandle, useRef } from 'react';\n\nimport { mergeRefs } from '../../utils/merge-refs';\nimport { Textarea } from '../Textarea';\nimport {\n isComposerSubmitKey,\n useChatComposerContext,\n} from './ChatComposerContext';\n\nexport type ChatComposerTextareaProps = Omit<\n ComponentPropsWithRef<typeof Textarea>,\n | 'variant'\n | 'rows'\n | 'resize'\n | 'autoResize'\n | 'label'\n | 'hintText'\n | 'isError'\n | 'leftDecorator'\n | 'rightDecorator'\n> & {\n /** Height in px before the text grows. */\n minHeight?: number;\n /** Height in px the field grows to before it scrolls. */\n maxHeight?: number;\n};\n\n/**\n * A plain-text message field for hosts that need the native textarea: its\n * ref and selection, a `name` for form data, or their own key handling. Enter\n * sends through the composer unless the host's `onKeyDown` prevents it;\n * Shift+Enter adds a line.\n */\nexport function ChatComposerTextarea({\n ref,\n disabled = false,\n readOnly = false,\n size = 'md',\n minHeight = 40,\n maxHeight = 240,\n placeholder = 'Write a message…',\n 'aria-label': ariaLabel = 'Message',\n style,\n onKeyDown,\n ...props\n}: ChatComposerTextareaProps) {\n const composer = useChatComposerContext();\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const isDisabled = composer.disabled || disabled;\n const editable = !isDisabled && !readOnly;\n\n useImperativeHandle(\n composer.inputFocusRef,\n () => () => {\n if (!editable || !textareaRef.current) return false;\n textareaRef.current.focus();\n return true;\n },\n [editable]\n );\n\n return (\n <Textarea\n {...props}\n ref={mergeRefs([textareaRef, ref])}\n variant=\"plain\"\n size={size}\n rows={1}\n autoResize\n maxHeight={maxHeight}\n placeholder={placeholder}\n disabled={isDisabled}\n readOnly={readOnly}\n aria-label={ariaLabel}\n style={{ minHeight, ...style }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || !composer.submit || !editable) return;\n if (!isComposerSubmitKey(event.nativeEvent)) return;\n event.preventDefault();\n composer.submit();\n }}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;AAiCA,SAAgB,qBAAqB,EACnC,KACA,WAAW,OACX,WAAW,OACX,OAAO,MACP,YAAY,IACZ,YAAY,KACZ,cAAc,oBACd,cAAc,YAAY,WAC1B,OACA,WACA,GAAG,SACyB;CAC5B,MAAM,WAAW,uBAAuB;CACxC,MAAM,cAAc,OAA4B,IAAI;CACpD,MAAM,aAAa,SAAS,YAAY;CACxC,MAAM,WAAW,CAAC,cAAc,CAAC;CAEjC,oBACE,SAAS,2BACG;EACV,IAAI,CAAC,YAAY,CAAC,YAAY,SAAS,OAAO;EAC9C,YAAY,QAAQ,MAAM;EAC1B,OAAO;CACT,GACA,CAAC,QAAQ,CACX;CAEA,OACE,oBAAC,UAAD;EACE,GAAI;EACJ,KAAK,UAAU,CAAC,aAAa,GAAG,CAAC;EACjC,SAAQ;EACF;EACN,MAAM;EACN,YAAA;EACW;EACE;EACb,UAAU;EACA;EACV,cAAY;EACZ,OAAO;GAAE;GAAW,GAAG;EAAM;EAC7B,YAAY,UAAU;GACpB,YAAY,KAAK;GACjB,IAAI,MAAM,oBAAoB,CAAC,SAAS,UAAU,CAAC,UAAU;GAC7D,IAAI,CAAC,oBAAoB,MAAM,WAAW,GAAG;GAC7C,MAAM,eAAe;GACrB,SAAS,OAAO;EAClB;CACD,CAAA;AAEL"}
|
|
@@ -2,6 +2,8 @@ export { ChatComposer, ChatComposerToolbar, ChatComposerAction, } from './ChatCo
|
|
|
2
2
|
export type { ChatComposerDrawerIntent, ChatComposerProps, ChatComposerToolbarProps, ChatComposerActionProps, } from './ChatComposer.js';
|
|
3
3
|
export { ChatComposerInput } from './ChatComposerInput.js';
|
|
4
4
|
export type { ChatComposerInputHandle, ChatComposerInputProps, } from './ChatComposerInput.js';
|
|
5
|
+
export { ChatComposerTextarea } from './ChatComposerTextarea.js';
|
|
6
|
+
export type { ChatComposerTextareaProps } from './ChatComposerTextarea.js';
|
|
5
7
|
export { ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerAttachment, } from './ChatComposerAttachments.js';
|
|
6
8
|
export type { ChatComposerAttachmentMenuProps, ChatComposerAttachmentsProps, ChatComposerAttachmentProps, } from './ChatComposerAttachments.js';
|
|
7
9
|
export { ChatComposerModelSelect } from './ChatComposerModelSelect.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChatComposerContext } from "./ChatComposerContext.js";
|
|
2
2
|
import { ChatComposer, ChatComposerAction, ChatComposerToolbar } from "./ChatComposer.js";
|
|
3
3
|
import { ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments } from "./ChatComposerAttachments.js";
|
|
4
|
+
import { ChatComposerTextarea } from "./ChatComposerTextarea.js";
|
|
4
5
|
import { ChatComposerInput } from "./ChatComposerInput.js";
|
|
5
6
|
import { ChatComposerModelSelect } from "./ChatComposerModelSelect.js";
|
|
6
|
-
export { ChatComposer, ChatComposerAction, ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerContext, ChatComposerInput, ChatComposerModelSelect, ChatComposerToolbar };
|
|
7
|
+
export { ChatComposer, ChatComposerAction, ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerContext, ChatComposerInput, ChatComposerModelSelect, ChatComposerTextarea, ChatComposerToolbar };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cn } from "../../utils/cn.js";
|
|
2
2
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../DropdownMenu/DropdownMenu.js";
|
|
3
3
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
4
|
-
import { useState } from "react";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
5
|
import { DotsThreeIcon } from "@phosphor-icons/react/dist/ssr/DotsThree";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region packages/components/src/components/ChatConversationList/ChatConversationListActions.tsx
|
|
@@ -11,12 +11,16 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
*/
|
|
12
12
|
function ChatConversationListActions({ title, disabled, children }) {
|
|
13
13
|
const [open, setOpen] = useState(false);
|
|
14
|
+
const focusTargetRef = useRef(null);
|
|
14
15
|
if (disabled && open) setOpen(false);
|
|
15
16
|
return /* @__PURE__ */ jsx("div", {
|
|
16
17
|
className: cn("pointer-events-none absolute inset-y-0 right-0 mr-space-3 flex shrink-0 items-center border-2 border-transparent opacity-0 group-focus-within/conversation:opacity-100 group-hover/conversation:opacity-100 [@media(hover:none)]:static [@media(hover:none)]:opacity-100", open && "opacity-100"),
|
|
17
18
|
children: /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
18
19
|
open,
|
|
19
|
-
onOpenChange:
|
|
20
|
+
onOpenChange: (next) => {
|
|
21
|
+
if (next) focusTargetRef.current = null;
|
|
22
|
+
setOpen(next);
|
|
23
|
+
},
|
|
20
24
|
children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
21
25
|
asChild: true,
|
|
22
26
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
@@ -36,6 +40,17 @@ function ChatConversationListActions({ title, disabled, children }) {
|
|
|
36
40
|
align: "end",
|
|
37
41
|
preventClickThrough: true,
|
|
38
42
|
onClick: (event) => event.stopPropagation(),
|
|
43
|
+
onBlur: (event) => {
|
|
44
|
+
const next = event.relatedTarget;
|
|
45
|
+
if (next instanceof HTMLElement && !event.currentTarget.contains(next)) focusTargetRef.current = next;
|
|
46
|
+
},
|
|
47
|
+
onCloseAutoFocus: (event) => {
|
|
48
|
+
const target = focusTargetRef.current;
|
|
49
|
+
focusTargetRef.current = null;
|
|
50
|
+
if (!target?.isConnected) return;
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
target.focus();
|
|
53
|
+
},
|
|
39
54
|
children
|
|
40
55
|
})]
|
|
41
56
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatConversationListActions.js","names":[],"sources":["../../../src/components/ChatConversationList/ChatConversationListActions.tsx"],"sourcesContent":["import { type ReactNode, useState } from 'react';\n\nimport { DotsThreeIcon } from '@phosphor-icons/react/dist/ssr/DotsThree';\n\nimport { cn } from '../../utils/cn';\nimport type { IconComponent } from '../../utils/icon-types';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from '../DropdownMenu';\nimport { IconButton } from '../IconButton';\n\ninterface ChatConversationListActionsProps {\n title: string;\n disabled: boolean;\n children: ReactNode;\n}\n\n/**\n * The three-dot menu for a row. It sits over the row's trailing slot and\n * appears on hover or keyboard focus; on touch it stays visible in the flow.\n */\nexport function ChatConversationListActions({\n title,\n disabled,\n children,\n}: ChatConversationListActionsProps) {\n const [open, setOpen] = useState(false);\n // Closes the menu when the row becomes disabled, so it can't reopen on its\n // own once the row is enabled again.\n if (disabled && open) setOpen(false);\n\n return (\n <div\n className={cn(\n 'pointer-events-none absolute inset-y-0 right-0 mr-space-3 flex shrink-0 items-center border-2 border-transparent opacity-0 group-focus-within/conversation:opacity-100 group-hover/conversation:opacity-100 [@media(hover:none)]:static [@media(hover:none)]:opacity-100',\n open && 'opacity-100'\n )}\n >\n <DropdownMenu
|
|
1
|
+
{"version":3,"file":"ChatConversationListActions.js","names":[],"sources":["../../../src/components/ChatConversationList/ChatConversationListActions.tsx"],"sourcesContent":["import { type ReactNode, useRef, useState } from 'react';\n\nimport { DotsThreeIcon } from '@phosphor-icons/react/dist/ssr/DotsThree';\n\nimport { cn } from '../../utils/cn';\nimport type { IconComponent } from '../../utils/icon-types';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from '../DropdownMenu';\nimport { IconButton } from '../IconButton';\n\ninterface ChatConversationListActionsProps {\n title: string;\n disabled: boolean;\n children: ReactNode;\n}\n\n/**\n * The three-dot menu for a row. It sits over the row's trailing slot and\n * appears on hover or keyboard focus; on touch it stays visible in the flow.\n */\nexport function ChatConversationListActions({\n title,\n disabled,\n children,\n}: ChatConversationListActionsProps) {\n const [open, setOpen] = useState(false);\n // Where an item tried to move focus, such as into an inline rename field or\n // confirmation. The open menu traps focus, so focus goes there once the menu\n // closes instead of back to the trigger.\n const focusTargetRef = useRef<HTMLElement | null>(null);\n // Closes the menu when the row becomes disabled, so it can't reopen on its\n // own once the row is enabled again.\n if (disabled && open) setOpen(false);\n\n return (\n <div\n className={cn(\n 'pointer-events-none absolute inset-y-0 right-0 mr-space-3 flex shrink-0 items-center border-2 border-transparent opacity-0 group-focus-within/conversation:opacity-100 group-hover/conversation:opacity-100 [@media(hover:none)]:static [@media(hover:none)]:opacity-100',\n open && 'opacity-100'\n )}\n >\n <DropdownMenu\n open={open}\n onOpenChange={(next) => {\n if (next) focusTargetRef.current = null;\n setOpen(next);\n }}\n >\n <DropdownMenuTrigger asChild>\n <IconButton\n // Lets the row's indicator hide while the menu is open, which\n // Radix marks with data-state=\"open\" on this trigger.\n data-conversation-actions=\"\"\n icon={DotsThreeIcon}\n iconWeight=\"regular\"\n label={`Actions for ${title}`}\n size=\"xs\"\n variant=\"plain\"\n color=\"secondary\"\n disabled={disabled}\n className={cn(\n 'pointer-events-none cursor-pointer transition-none disabled:cursor-not-allowed group-focus-within/conversation:pointer-events-auto group-hover/conversation:pointer-events-auto [@media(hover:none)]:pointer-events-auto',\n open && 'pointer-events-auto'\n )}\n tooltipProps={{ disabled: true }}\n // Keeps the click from reaching host handlers around the list.\n onClick={(event) => event.stopPropagation()}\n />\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"end\"\n preventClickThrough\n // The menu portals out, but React still bubbles its clicks through\n // the row to host handlers.\n onClick={(event) => event.stopPropagation()}\n // The trap moves focus back during blur, before focus can land\n // outside, so the intended target is only known here.\n onBlur={(event) => {\n const next = event.relatedTarget;\n if (\n next instanceof HTMLElement &&\n !event.currentTarget.contains(next)\n ) {\n focusTargetRef.current = next;\n }\n }}\n onCloseAutoFocus={(event) => {\n const target = focusTargetRef.current;\n focusTargetRef.current = null;\n if (!target?.isConnected) return;\n event.preventDefault();\n target.focus();\n }}\n >\n {children}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n );\n}\n\ninterface ChatConversationListActionItemProps {\n icon: IconComponent;\n label: string;\n /** Missing callbacks disable the item. */\n onSelect?: () => void;\n destructive?: boolean;\n}\n\n/** One of the default Rename, Pin, or Delete entries. */\nexport function ChatConversationListActionItem({\n icon: Icon,\n label,\n onSelect,\n destructive = false,\n}: ChatConversationListActionItemProps) {\n return (\n <DropdownMenuItem\n size=\"sm\"\n className={cn('gap-space-2', destructive && 'text-error-secondary')}\n disabled={!onSelect}\n onSelect={onSelect}\n >\n <Icon size={16} weight=\"regular\" aria-hidden />\n {label}\n </DropdownMenuItem>\n );\n}\n"],"mappings":";;;;;;;;;;;AAwBA,SAAgB,4BAA4B,EAC1C,OACA,UACA,YACmC;CACnC,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CAItC,MAAM,iBAAiB,OAA2B,IAAI;CAGtD,IAAI,YAAY,MAAM,QAAQ,KAAK;CAEnC,OACE,oBAAC,OAAD;EACE,WAAW,GACT,4QACA,QAAQ,aACV;EAEA,UAAA,qBAAC,cAAD;GACQ;GACN,eAAe,SAAS;IACtB,IAAI,MAAM,eAAe,UAAU;IACnC,QAAQ,IAAI;GACd;GALF,UAAA,CAOE,oBAAC,qBAAD;IAAqB,SAAA;IACnB,UAAA,oBAAC,YAAD;KAGE,6BAA0B;KAC1B,MAAM;KACN,YAAW;KACX,OAAO,eAAe;KACtB,MAAK;KACL,SAAQ;KACR,OAAM;KACI;KACV,WAAW,GACT,4NACA,QAAQ,qBACV;KACA,cAAc,EAAE,UAAU,KAAK;KAE/B,UAAU,UAAU,MAAM,gBAAgB;IAC3C,CAAA;GACkB,CAAA,GACrB,oBAAC,qBAAD;IACE,OAAM;IACN,qBAAA;IAGA,UAAU,UAAU,MAAM,gBAAgB;IAG1C,SAAS,UAAU;KACjB,MAAM,OAAO,MAAM;KACnB,IACE,gBAAgB,eAChB,CAAC,MAAM,cAAc,SAAS,IAAI,GAElC,eAAe,UAAU;IAE7B;IACA,mBAAmB,UAAU;KAC3B,MAAM,SAAS,eAAe;KAC9B,eAAe,UAAU;KACzB,IAAI,CAAC,QAAQ,aAAa;KAC1B,MAAM,eAAe;KACrB,OAAO,MAAM;IACf;IAEC;GACkB,CAAA,CACT;;CACX,CAAA;AAET;;AAWA,SAAgB,+BAA+B,EAC7C,MAAM,MACN,OACA,UACA,cAAc,SACwB;CACtC,OACE,qBAAC,kBAAD;EACE,MAAK;EACL,WAAW,GAAG,eAAe,eAAe,sBAAsB;EAClE,UAAU,CAAC;EACD;EAJZ,UAAA,CAME,oBAAC,MAAD;GAAM,MAAM;GAAI,QAAO;GAAU,eAAA;EAAa,CAAA,GAC7C,KACe;;AAEtB"}
|
|
@@ -9,6 +9,7 @@ import { LineChartVerticalMarkers } from "./LineChartVerticalMarkers.js";
|
|
|
9
9
|
import { useId, useRef } from "react";
|
|
10
10
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { animated, useReducedMotion, useSpring } from "@react-spring/web";
|
|
12
|
+
import { getStringWidth } from "@visx/text";
|
|
12
13
|
import { Group } from "@visx/group";
|
|
13
14
|
import { AxisBottom, AxisLeft, AxisRight } from "@visx/axis";
|
|
14
15
|
import { GridColumns, GridRows } from "@visx/grid";
|
|
@@ -175,11 +176,19 @@ var LineChartPlot = ({ width, height, innerWidth, innerHeight, chartMargin, xSca
|
|
|
175
176
|
hideAxisLine: true,
|
|
176
177
|
hideTicks: true,
|
|
177
178
|
tickFormat: (value) => formatXValue(value.valueOf()),
|
|
178
|
-
tickLabelProps: {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
tickLabelProps: (value) => {
|
|
180
|
+
const x = chartMargin.left + getXPosition(value.valueOf());
|
|
181
|
+
const labelWidth = Math.ceil(getStringWidth(formatXValue(value.valueOf()), {
|
|
182
|
+
fontSize: `12px`,
|
|
183
|
+
fontFamily: "Inter"
|
|
184
|
+
}) ?? 0);
|
|
185
|
+
return {
|
|
186
|
+
fill: "var(--text-tertiary)",
|
|
187
|
+
fontSize: 12,
|
|
188
|
+
textAnchor: "middle",
|
|
189
|
+
dx: Math.max(labelWidth / 2 - x, Math.min(0, width - x - labelWidth / 2)),
|
|
190
|
+
dy: "0.5em"
|
|
191
|
+
};
|
|
183
192
|
}
|
|
184
193
|
}),
|
|
185
194
|
axes.map((axis, index) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChartPlot.js","names":[],"sources":["../../../src/components/LineChart/LineChartPlot.tsx"],"sourcesContent":["import { useId, useRef, type AriaAttributes, type PointerEvent } from 'react';\n\nimport { animated, useReducedMotion, useSpring } from '@react-spring/web';\nimport { AxisBottom, AxisLeft, AxisRight } from '@visx/axis';\nimport { curveLinear } from '@visx/curve';\nimport { GridColumns, GridRows } from '@visx/grid';\nimport { Group } from '@visx/group';\nimport type { scaleBand, scaleLinear } from '@visx/scale';\nimport { Area, LinePath } from '@visx/shape';\n\nimport {\n getChartAxisLabelOffset,\n getSecondaryChartAxisOffset,\n} from '../../utils/chartAxisLayout';\nimport {\n CHART_DIMMED_OPACITY,\n CHART_DASHED_STROKE_DASHARRAY,\n CHART_TICK_FONT_SIZE,\n CHART_VALUE_AXIS_TICK_LENGTH,\n} from '../../utils/chartConstants';\nimport {\n getChartTickValues,\n getNearestChartValue,\n} from '../../utils/chartValues';\nimport { cn } from '../../utils/cn';\nimport { Tooltip } from '../Tooltip';\nimport { LINE_CHART_DEFAULT_TICK_COUNT } from './constants';\nimport type {\n LineChartDisplayAxis,\n LineChartDisplaySeries,\n LineChartInteractionDatum,\n LineChartSelectionRange,\n LineChartStackedSeries,\n LineChartVerticalMarker,\n LineChartYBand,\n} from './LineChart.types';\nimport { getLineSegments, getSelectionBounds } from './LineChart.utils';\nimport { LineChartVerticalMarkers } from './LineChartVerticalMarkers';\n\nconst defaultFormatValue = new Intl.NumberFormat('en-US', {\n maximumFractionDigits: 2,\n}).format;\n\nconst getInteractionDatum = (\n nearestX: number,\n series: readonly LineChartDisplaySeries[],\n xPosition: number,\n pointerX: number\n): LineChartInteractionDatum => ({\n x: nearestX,\n pointerX,\n xPosition,\n points: series.map((item) => ({\n seriesId: item.id,\n seriesLabel: item.label,\n color: item.color,\n value: item.points.find((point) => point.x === nearestX)?.y ?? null,\n })),\n});\n\ntype LineChartPlotProps = {\n width: number;\n height: number;\n innerWidth: number;\n innerHeight: number;\n chartMargin: { top: number; right: number; bottom: number; left: number };\n xScale:\n | ReturnType<typeof scaleLinear<number>>\n | ReturnType<typeof scaleBand<number>>;\n getXPosition: (value: number) => number;\n getXValue: (position: number) => number;\n getXRangePosition: (value: number) => number;\n uniqueXValues: readonly number[];\n axes: readonly LineChartDisplayAxis[];\n series: readonly LineChartDisplaySeries[];\n /** Replaces the series lines with areas when set. */\n stackedSeries?: readonly LineChartStackedSeries[];\n formatXValue: (value: number) => string;\n xTickCount?: number;\n xTickValues?: readonly number[];\n showPoints: boolean;\n connectNulls: boolean;\n showGridRows: boolean;\n showGridColumns: boolean;\n activeX?: number;\n activeLegendItemId?: string | null;\n selectionRange?: LineChartSelectionRange;\n yBands: readonly LineChartYBand[];\n verticalMarkers: readonly LineChartVerticalMarker[];\n shouldAnimate: boolean;\n isRendering: boolean;\n 'aria-describedby'?: AriaAttributes['aria-describedby'];\n 'aria-label': string;\n onDatumPointerDown?: (\n datum: LineChartInteractionDatum,\n event: PointerEvent<SVGSVGElement>\n ) => void;\n onDatumPointerMove?: (\n datum: LineChartInteractionDatum,\n event: PointerEvent<SVGSVGElement>\n ) => void;\n onDatumPointerOut?: () => void;\n onDatumPointerUp?: (\n datum: LineChartInteractionDatum,\n event: PointerEvent<SVGSVGElement>\n ) => void;\n};\n\nexport const LineChartPlot = ({\n width,\n height,\n innerWidth,\n innerHeight,\n chartMargin,\n xScale,\n getXPosition,\n getXValue,\n getXRangePosition,\n uniqueXValues,\n axes,\n series,\n stackedSeries,\n formatXValue,\n xTickCount,\n xTickValues,\n showPoints,\n connectNulls,\n showGridRows,\n showGridColumns,\n activeX,\n activeLegendItemId,\n selectionRange,\n yBands,\n verticalMarkers,\n shouldAnimate,\n isRendering,\n onDatumPointerDown,\n onDatumPointerMove,\n onDatumPointerOut,\n onDatumPointerUp,\n ...ariaProps\n}: LineChartPlotProps) => {\n const activePointerId = useRef<number | null>(null);\n const clipPathId = `line-chart-${useId().replace(/:/g, '')}`;\n const revealClipPathId = `${clipPathId}-reveal`;\n const axisById = new Map(axes.map((axis) => [axis.id, axis]));\n const primaryAxis = axes[0];\n const hasPointerInteraction =\n onDatumPointerDown != null ||\n onDatumPointerMove != null ||\n onDatumPointerUp != null;\n const resolvedXTickCount = xTickCount ?? (width < 480 ? 3 : 5);\n const resolvedXTickValues =\n xTickValues == null\n ? getChartTickValues(uniqueXValues, resolvedXTickCount)\n : Array.from(xTickValues);\n const activeXPosition = activeX == null ? null : getXPosition(activeX);\n const hasActiveX =\n activeXPosition != null &&\n activeXPosition >= 0 &&\n activeXPosition <= innerWidth;\n const canRender = isRendering && innerWidth > 0 && innerHeight > 0;\n const isReducedMotion = (useReducedMotion() ?? false) || !shouldAnimate;\n const hasRenderedSeries = canRender && series.length > 0;\n const getSeriesOpacity = (item: LineChartDisplaySeries) =>\n item.opacity *\n (activeLegendItemId != null && activeLegendItemId !== item.id\n ? CHART_DIMMED_OPACITY\n : 1);\n // Points and crosshair markers sit on the top edge of each stacked band.\n const markSeries: readonly LineChartDisplaySeries[] =\n stackedSeries?.map((item) => ({\n ...item,\n points: item.points.map(({ x, y, y1 }) => ({\n x,\n y: y == null ? null : y1,\n })),\n })) ?? series;\n const visibleSeriesKey = JSON.stringify(series.map((item) => item.id));\n const [animation] = useSpring(\n () => ({\n from: { progress: 0 },\n to: { progress: hasRenderedSeries ? 1 : 0 },\n reset: true,\n immediate: isReducedMotion,\n }),\n [visibleSeriesKey, hasRenderedSeries, isReducedMotion]\n );\n\n const getDatumFromPointer = (event: PointerEvent<SVGSVGElement>) => {\n if (uniqueXValues.length === 0 || innerWidth === 0) return null;\n const bounds = event.currentTarget.getBoundingClientRect();\n const rawX = event.clientX - bounds.left - chartMargin.left;\n // Keep an in-progress range selection at its endpoint through the gutter.\n const plotX =\n activePointerId.current === event.pointerId\n ? Math.max(0, Math.min(innerWidth, rawX))\n : rawX;\n const plotY = event.clientY - bounds.top - chartMargin.top;\n if (plotX < 0 || plotX > innerWidth || plotY < 0 || plotY > innerHeight)\n return null;\n const pointerX = getXValue(plotX);\n const nearestX = getNearestChartValue(uniqueXValues, plotX, getXPosition);\n if (nearestX == null) return null;\n return getInteractionDatum(\n nearestX,\n series,\n chartMargin.left + getXPosition(nearestX),\n pointerX\n );\n };\n\n const selectionStartX =\n selectionRange == null ? null : getXRangePosition(selectionRange.from);\n const selectionEndX =\n selectionRange == null ? null : getXRangePosition(selectionRange.to);\n const selectionBounds = getSelectionBounds(\n selectionStartX,\n selectionEndX,\n innerWidth\n );\n const handlePointerExit = () => {\n activePointerId.current = null;\n onDatumPointerOut?.();\n };\n const handlePointerMove = (event: PointerEvent<SVGSVGElement>) => {\n const datum = getDatumFromPointer(event);\n if (datum == null) handlePointerExit();\n else onDatumPointerMove?.(datum, event);\n };\n const handlePointerDown = (event: PointerEvent<SVGSVGElement>) => {\n const datum = getDatumFromPointer(event);\n if (datum == null || onDatumPointerDown == null) return;\n if (event.button === 0) activePointerId.current = event.pointerId;\n onDatumPointerDown(datum, event);\n };\n const handlePointerUp = (event: PointerEvent<SVGSVGElement>) => {\n const datum = getDatumFromPointer(event);\n if (datum == null) return handlePointerExit();\n activePointerId.current = null;\n onDatumPointerUp?.(datum, event);\n };\n\n return (\n <svg\n width={width}\n height={height}\n role=\"graphics-document group\"\n {...ariaProps}\n focusable=\"false\"\n className={cn(\n 'block size-full',\n hasPointerInteraction && 'cursor-crosshair'\n )}\n onPointerMove={handlePointerMove}\n onPointerDown={handlePointerDown}\n onPointerLeave={handlePointerExit}\n onPointerCancel={handlePointerExit}\n onPointerUp={handlePointerUp}\n >\n {canRender && (\n <Group left={chartMargin.left} top={chartMargin.top}>\n <defs>\n <clipPath id={clipPathId}>\n <rect width={innerWidth} height={innerHeight} />\n </clipPath>\n <clipPath id={revealClipPathId}>\n <animated.rect\n width={animation.progress.to(\n (progress) => progress * innerWidth\n )}\n height={innerHeight}\n />\n </clipPath>\n </defs>\n <g clipPath={`url(#${clipPathId})`}>\n {yBands.map((band) => {\n const axis =\n band.yAxisId == null ? primaryAxis : axisById.get(band.yAxisId);\n if (axis == null) return null;\n const domain = axis.scale.domain();\n const from = band.from ?? domain[0];\n const to = band.to ?? domain.at(-1);\n if (from == null || to == null) return null;\n const fromY = axis.scale(from);\n const toY = axis.scale(to);\n return (\n <rect\n key={band.id}\n width={innerWidth}\n height={Math.abs(toY - fromY)}\n y={Math.min(fromY, toY)}\n fill={band.color}\n fillOpacity={band.opacity ?? 0.12}\n />\n );\n })}\n </g>\n {showGridRows && primaryAxis != null && (\n <GridRows\n scale={primaryAxis.scale}\n width={innerWidth}\n numTicks={primaryAxis.tickCount ?? LINE_CHART_DEFAULT_TICK_COUNT}\n tickValues={\n primaryAxis.tickValues == null\n ? undefined\n : Array.from(primaryAxis.tickValues)\n }\n stroke=\"var(--border-subtle)\"\n strokeDasharray={CHART_DASHED_STROKE_DASHARRAY}\n />\n )}\n {showGridColumns && (\n <GridColumns\n scale={xScale}\n height={innerHeight}\n numTicks={resolvedXTickCount}\n tickValues={resolvedXTickValues}\n stroke=\"var(--border-subtle)\"\n strokeDasharray={CHART_DASHED_STROKE_DASHARRAY}\n />\n )}\n <LineChartVerticalMarkers\n verticalMarkers={verticalMarkers}\n innerWidth={innerWidth}\n innerHeight={innerHeight}\n getXPosition={getXPosition}\n />\n <AxisBottom\n scale={xScale}\n top={innerHeight}\n numTicks={resolvedXTickCount}\n tickValues={resolvedXTickValues}\n hideAxisLine\n hideTicks\n tickFormat={(value) => formatXValue(value.valueOf())}\n tickLabelProps={{\n fill: 'var(--text-tertiary)',\n fontSize: CHART_TICK_FONT_SIZE,\n textAnchor: 'middle',\n dy: '0.5em',\n }}\n />\n {axes.map((axis, index) => {\n const tickFormat = (value: { valueOf(): number }) =>\n (axis.formatValue ?? defaultFormatValue)(value.valueOf());\n const textAnchor: 'end' | 'start' = index === 0 ? 'end' : 'start';\n const tickValues =\n axis.tickValues == null ? undefined : Array.from(axis.tickValues);\n const axisProps = {\n scale: axis.scale,\n numTicks: axis.tickCount ?? LINE_CHART_DEFAULT_TICK_COUNT,\n tickValues,\n tickLength: CHART_VALUE_AXIS_TICK_LENGTH,\n hideAxisLine: true,\n hideTicks: true,\n tickFormat,\n tickLabelProps: {\n fill: 'var(--text-tertiary)',\n fontSize: CHART_TICK_FONT_SIZE,\n textAnchor,\n dx: index === 0 ? '-0.25em' : '0.25em',\n dy: '0.25em',\n },\n };\n return index === 0 ? (\n <AxisLeft key={axis.id} {...axisProps} />\n ) : (\n <AxisRight\n key={axis.id}\n {...axisProps}\n left={innerWidth + getSecondaryChartAxisOffset(axes, index)}\n />\n );\n })}\n <g clipPath={`url(#${clipPathId})`}>\n <g clipPath={`url(#${revealClipPathId})`}>\n {stackedSeries == null\n ? series.map((item) => {\n const axis = axisById.get(item.yAxisId);\n if (axis == null) return null;\n return (\n <g\n key={item.id}\n role=\"group\"\n aria-label={`${item['aria-label'] ?? item.id} series`}\n >\n {getLineSegments(item.points, connectNulls).map(\n (segment, index) => (\n <LinePath\n key={index}\n data={segment}\n curve={curveLinear}\n fill=\"none\"\n stroke={item.color}\n strokeWidth={item.strokeWidth}\n strokeDasharray={item.strokeDasharray}\n opacity={getSeriesOpacity(item)}\n className=\"transition-opacity duration-fast motion-reduce:transition-none\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n x={(point) => getXPosition(point.x)}\n y={(point) => axis.scale(point.y ?? 0)}\n />\n )\n )}\n </g>\n );\n })\n : stackedSeries.map((item) => {\n const axis = axisById.get(item.yAxisId);\n if (axis == null) return null;\n return (\n <g\n key={item.id}\n role=\"group\"\n aria-label={`${item['aria-label'] ?? item.id} series`}\n >\n <Area\n data={Array.from(item.points)}\n curve={curveLinear}\n fill={item.color}\n opacity={getSeriesOpacity(item)}\n className=\"transition-opacity duration-fast motion-reduce:transition-none\"\n x={(point) => getXPosition(point.x)}\n y0={(point) => axis.scale(point.y0)}\n y1={(point) => axis.scale(point.y1)}\n />\n </g>\n );\n })}\n {showPoints &&\n markSeries.flatMap((item) => {\n const axis = axisById.get(item.yAxisId);\n if (axis == null) return [];\n return item.points.flatMap((point, pointIndex) =>\n point.y == null\n ? []\n : [\n <circle\n key={`${item.id}-${point.x}-${pointIndex}`}\n cx={getXPosition(point.x)}\n cy={axis.scale(point.y)}\n r={2.5}\n fill={item.color}\n opacity={getSeriesOpacity(item)}\n className=\"transition-opacity duration-fast motion-reduce:transition-none\"\n />,\n ]\n );\n })}\n </g>\n {selectionBounds != null && (\n <g\n role=\"group\"\n aria-label={`Selected range from ${formatXValue(\n Math.min(selectionRange?.from ?? 0, selectionRange?.to ?? 0)\n )} to ${formatXValue(\n Math.max(selectionRange?.from ?? 0, selectionRange?.to ?? 0)\n )}`}\n >\n <rect\n aria-hidden=\"true\"\n x={selectionBounds.x}\n y={0}\n width={selectionBounds.width}\n height={innerHeight}\n fill=\"var(--bg-brand)\"\n fillOpacity={0.1}\n stroke=\"var(--border-brand)\"\n pointerEvents=\"none\"\n />\n </g>\n )}\n {hasActiveX && (\n <>\n <line\n x1={activeXPosition}\n x2={activeXPosition}\n y1={0}\n y2={innerHeight}\n stroke=\"currentColor\"\n strokeWidth={1}\n strokeDasharray={CHART_DASHED_STROKE_DASHARRAY}\n className=\"text-quaternary\"\n />\n {markSeries.flatMap((item) => {\n if (!item.showActiveMarker) return [];\n const axis = axisById.get(item.yAxisId);\n const point = item.points.find(\n (candidate) => candidate.x === activeX\n );\n if (axis == null || point?.y == null) return [];\n return [\n <circle\n key={`active-${item.id}`}\n cx={activeXPosition}\n cy={axis.scale(point.y)}\n r={3}\n fill={item.color}\n opacity={getSeriesOpacity(item)}\n className=\"transition-opacity duration-fast motion-reduce:transition-none\"\n stroke=\"var(--bg-surface-level-1)\"\n strokeWidth={1.5}\n />,\n ];\n })}\n </>\n )}\n </g>\n {hasPointerInteraction && (\n <rect width={innerWidth} height={innerHeight} fill=\"transparent\" />\n )}\n </Group>\n )}\n {canRender &&\n axes.map((axis, index) => {\n if (axis.label == null) return null;\n const x =\n index === 0\n ? chartMargin.left - getChartAxisLabelOffset(axis.thickness)\n : chartMargin.left +\n innerWidth +\n getSecondaryChartAxisOffset(axes, index) +\n getChartAxisLabelOffset(axis.thickness);\n const y = chartMargin.top + innerHeight / 2;\n return (\n <Tooltip title={axis.label} key={axis.id}>\n <text\n x={x}\n y={y}\n fill=\"var(--text-quaternary)\"\n fontSize={CHART_TICK_FONT_SIZE}\n fontWeight={500}\n textAnchor=\"middle\"\n transform={`rotate(-90, ${x}, ${y})`}\n >\n {axis.label}\n </text>\n </Tooltip>\n );\n })}\n </svg>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,IAAM,qBAAqB,IAAI,KAAK,aAAa,SAAS,EACxD,uBAAuB,EACzB,CAAC,CAAC,CAAC;AAEH,IAAM,uBACJ,UACA,QACA,WACA,cAC+B;CAC/B,GAAG;CACH;CACA;CACA,QAAQ,OAAO,KAAK,UAAU;EAC5B,UAAU,KAAK;EACf,aAAa,KAAK;EAClB,OAAO,KAAK;EACZ,OAAO,KAAK,OAAO,MAAM,UAAU,MAAM,MAAM,QAAQ,CAAC,EAAE,KAAK;CACjE,EAAE;AACJ;AAkDA,IAAa,iBAAiB,EAC5B,OACA,QACA,YACA,aACA,aACA,QACA,cACA,WACA,mBACA,eACA,MACA,QACA,eACA,cACA,YACA,aACA,YACA,cACA,cACA,iBACA,SACA,oBACA,gBACA,QACA,iBACA,eACA,aACA,oBACA,oBACA,mBACA,kBACA,GAAG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,IAAI,KAAK,SAAS,MAAM,OAAO;GAC/B,MAAM,IACJ,UAAU,IACN,YAAY,OAAO,wBAAwB,KAAK,SAAS,IACzD,YAAY,OACZ,aACA,4BAA4B,MAAM,KAAK,IACvC,wBAAwB,KAAK,SAAS;GAC5C,MAAM,IAAI,YAAY,MAAM,cAAc;GAC1C,OACE,oBAAC,SAAD;IAAS,OAAO,KAAK;IACnB,UAAA,oBAAC,QAAD;KACK;KACA;KACH,MAAK;KACL,UAAA;KACA,YAAY;KACZ,YAAW;KACX,WAAW,eAAe,EAAE,IAAI,EAAE;KAEjC,UAAA,KAAK;IACF,CAAA;GACC,GAZwB,KAAK,EAY7B;EAEb,CAAC,CACA;;AAET"}
|
|
1
|
+
{"version":3,"file":"LineChartPlot.js","names":[],"sources":["../../../src/components/LineChart/LineChartPlot.tsx"],"sourcesContent":["import { useId, useRef, type AriaAttributes, type PointerEvent } from 'react';\n\nimport { animated, useReducedMotion, useSpring } from '@react-spring/web';\nimport { AxisBottom, AxisLeft, AxisRight } from '@visx/axis';\nimport { curveLinear } from '@visx/curve';\nimport { GridColumns, GridRows } from '@visx/grid';\nimport { Group } from '@visx/group';\nimport type { scaleBand, scaleLinear } from '@visx/scale';\nimport { Area, LinePath } from '@visx/shape';\nimport { getStringWidth } from '@visx/text';\n\nimport {\n getChartAxisLabelOffset,\n getSecondaryChartAxisOffset,\n} from '../../utils/chartAxisLayout';\nimport {\n CHART_DIMMED_OPACITY,\n CHART_DASHED_STROKE_DASHARRAY,\n CHART_TICK_FONT_SIZE,\n CHART_VALUE_AXIS_TICK_LENGTH,\n} from '../../utils/chartConstants';\nimport {\n getChartTickValues,\n getNearestChartValue,\n} from '../../utils/chartValues';\nimport { cn } from '../../utils/cn';\nimport { Tooltip } from '../Tooltip';\nimport { LINE_CHART_DEFAULT_TICK_COUNT } from './constants';\nimport type {\n LineChartDisplayAxis,\n LineChartDisplaySeries,\n LineChartInteractionDatum,\n LineChartSelectionRange,\n LineChartStackedSeries,\n LineChartVerticalMarker,\n LineChartYBand,\n} from './LineChart.types';\nimport { getLineSegments, getSelectionBounds } from './LineChart.utils';\nimport { LineChartVerticalMarkers } from './LineChartVerticalMarkers';\n\nconst defaultFormatValue = new Intl.NumberFormat('en-US', {\n maximumFractionDigits: 2,\n}).format;\n\nconst getInteractionDatum = (\n nearestX: number,\n series: readonly LineChartDisplaySeries[],\n xPosition: number,\n pointerX: number\n): LineChartInteractionDatum => ({\n x: nearestX,\n pointerX,\n xPosition,\n points: series.map((item) => ({\n seriesId: item.id,\n seriesLabel: item.label,\n color: item.color,\n value: item.points.find((point) => point.x === nearestX)?.y ?? null,\n })),\n});\n\ntype LineChartPlotProps = {\n width: number;\n height: number;\n innerWidth: number;\n innerHeight: number;\n chartMargin: { top: number; right: number; bottom: number; left: number };\n xScale:\n | ReturnType<typeof scaleLinear<number>>\n | ReturnType<typeof scaleBand<number>>;\n getXPosition: (value: number) => number;\n getXValue: (position: number) => number;\n getXRangePosition: (value: number) => number;\n uniqueXValues: readonly number[];\n axes: readonly LineChartDisplayAxis[];\n series: readonly LineChartDisplaySeries[];\n /** Replaces the series lines with areas when set. */\n stackedSeries?: readonly LineChartStackedSeries[];\n formatXValue: (value: number) => string;\n xTickCount?: number;\n xTickValues?: readonly number[];\n showPoints: boolean;\n connectNulls: boolean;\n showGridRows: boolean;\n showGridColumns: boolean;\n activeX?: number;\n activeLegendItemId?: string | null;\n selectionRange?: LineChartSelectionRange;\n yBands: readonly LineChartYBand[];\n verticalMarkers: readonly LineChartVerticalMarker[];\n shouldAnimate: boolean;\n isRendering: boolean;\n 'aria-describedby'?: AriaAttributes['aria-describedby'];\n 'aria-label': string;\n onDatumPointerDown?: (\n datum: LineChartInteractionDatum,\n event: PointerEvent<SVGSVGElement>\n ) => void;\n onDatumPointerMove?: (\n datum: LineChartInteractionDatum,\n event: PointerEvent<SVGSVGElement>\n ) => void;\n onDatumPointerOut?: () => void;\n onDatumPointerUp?: (\n datum: LineChartInteractionDatum,\n event: PointerEvent<SVGSVGElement>\n ) => void;\n};\n\nexport const LineChartPlot = ({\n width,\n height,\n innerWidth,\n innerHeight,\n chartMargin,\n xScale,\n getXPosition,\n getXValue,\n getXRangePosition,\n uniqueXValues,\n axes,\n series,\n stackedSeries,\n formatXValue,\n xTickCount,\n xTickValues,\n showPoints,\n connectNulls,\n showGridRows,\n showGridColumns,\n activeX,\n activeLegendItemId,\n selectionRange,\n yBands,\n verticalMarkers,\n shouldAnimate,\n isRendering,\n onDatumPointerDown,\n onDatumPointerMove,\n onDatumPointerOut,\n onDatumPointerUp,\n ...ariaProps\n}: LineChartPlotProps) => {\n const activePointerId = useRef<number | null>(null);\n const clipPathId = `line-chart-${useId().replace(/:/g, '')}`;\n const revealClipPathId = `${clipPathId}-reveal`;\n const axisById = new Map(axes.map((axis) => [axis.id, axis]));\n const primaryAxis = axes[0];\n const hasPointerInteraction =\n onDatumPointerDown != null ||\n onDatumPointerMove != null ||\n onDatumPointerUp != null;\n const resolvedXTickCount = xTickCount ?? (width < 480 ? 3 : 5);\n const resolvedXTickValues =\n xTickValues == null\n ? getChartTickValues(uniqueXValues, resolvedXTickCount)\n : Array.from(xTickValues);\n const activeXPosition = activeX == null ? null : getXPosition(activeX);\n const hasActiveX =\n activeXPosition != null &&\n activeXPosition >= 0 &&\n activeXPosition <= innerWidth;\n const canRender = isRendering && innerWidth > 0 && innerHeight > 0;\n const isReducedMotion = (useReducedMotion() ?? false) || !shouldAnimate;\n const hasRenderedSeries = canRender && series.length > 0;\n const getSeriesOpacity = (item: LineChartDisplaySeries) =>\n item.opacity *\n (activeLegendItemId != null && activeLegendItemId !== item.id\n ? CHART_DIMMED_OPACITY\n : 1);\n // Points and crosshair markers sit on the top edge of each stacked band.\n const markSeries: readonly LineChartDisplaySeries[] =\n stackedSeries?.map((item) => ({\n ...item,\n points: item.points.map(({ x, y, y1 }) => ({\n x,\n y: y == null ? null : y1,\n })),\n })) ?? series;\n const visibleSeriesKey = JSON.stringify(series.map((item) => item.id));\n const [animation] = useSpring(\n () => ({\n from: { progress: 0 },\n to: { progress: hasRenderedSeries ? 1 : 0 },\n reset: true,\n immediate: isReducedMotion,\n }),\n [visibleSeriesKey, hasRenderedSeries, isReducedMotion]\n );\n\n const getDatumFromPointer = (event: PointerEvent<SVGSVGElement>) => {\n if (uniqueXValues.length === 0 || innerWidth === 0) return null;\n const bounds = event.currentTarget.getBoundingClientRect();\n const rawX = event.clientX - bounds.left - chartMargin.left;\n // Keep an in-progress range selection at its endpoint through the gutter.\n const plotX =\n activePointerId.current === event.pointerId\n ? Math.max(0, Math.min(innerWidth, rawX))\n : rawX;\n const plotY = event.clientY - bounds.top - chartMargin.top;\n if (plotX < 0 || plotX > innerWidth || plotY < 0 || plotY > innerHeight)\n return null;\n const pointerX = getXValue(plotX);\n const nearestX = getNearestChartValue(uniqueXValues, plotX, getXPosition);\n if (nearestX == null) return null;\n return getInteractionDatum(\n nearestX,\n series,\n chartMargin.left + getXPosition(nearestX),\n pointerX\n );\n };\n\n const selectionStartX =\n selectionRange == null ? null : getXRangePosition(selectionRange.from);\n const selectionEndX =\n selectionRange == null ? null : getXRangePosition(selectionRange.to);\n const selectionBounds = getSelectionBounds(\n selectionStartX,\n selectionEndX,\n innerWidth\n );\n const handlePointerExit = () => {\n activePointerId.current = null;\n onDatumPointerOut?.();\n };\n const handlePointerMove = (event: PointerEvent<SVGSVGElement>) => {\n const datum = getDatumFromPointer(event);\n if (datum == null) handlePointerExit();\n else onDatumPointerMove?.(datum, event);\n };\n const handlePointerDown = (event: PointerEvent<SVGSVGElement>) => {\n const datum = getDatumFromPointer(event);\n if (datum == null || onDatumPointerDown == null) return;\n if (event.button === 0) activePointerId.current = event.pointerId;\n onDatumPointerDown(datum, event);\n };\n const handlePointerUp = (event: PointerEvent<SVGSVGElement>) => {\n const datum = getDatumFromPointer(event);\n if (datum == null) return handlePointerExit();\n activePointerId.current = null;\n onDatumPointerUp?.(datum, event);\n };\n\n return (\n <svg\n width={width}\n height={height}\n role=\"graphics-document group\"\n {...ariaProps}\n focusable=\"false\"\n className={cn(\n 'block size-full',\n hasPointerInteraction && 'cursor-crosshair'\n )}\n onPointerMove={handlePointerMove}\n onPointerDown={handlePointerDown}\n onPointerLeave={handlePointerExit}\n onPointerCancel={handlePointerExit}\n onPointerUp={handlePointerUp}\n >\n {canRender && (\n <Group left={chartMargin.left} top={chartMargin.top}>\n <defs>\n <clipPath id={clipPathId}>\n <rect width={innerWidth} height={innerHeight} />\n </clipPath>\n <clipPath id={revealClipPathId}>\n <animated.rect\n width={animation.progress.to(\n (progress) => progress * innerWidth\n )}\n height={innerHeight}\n />\n </clipPath>\n </defs>\n <g clipPath={`url(#${clipPathId})`}>\n {yBands.map((band) => {\n const axis =\n band.yAxisId == null ? primaryAxis : axisById.get(band.yAxisId);\n if (axis == null) return null;\n const domain = axis.scale.domain();\n const from = band.from ?? domain[0];\n const to = band.to ?? domain.at(-1);\n if (from == null || to == null) return null;\n const fromY = axis.scale(from);\n const toY = axis.scale(to);\n return (\n <rect\n key={band.id}\n width={innerWidth}\n height={Math.abs(toY - fromY)}\n y={Math.min(fromY, toY)}\n fill={band.color}\n fillOpacity={band.opacity ?? 0.12}\n />\n );\n })}\n </g>\n {showGridRows && primaryAxis != null && (\n <GridRows\n scale={primaryAxis.scale}\n width={innerWidth}\n numTicks={primaryAxis.tickCount ?? LINE_CHART_DEFAULT_TICK_COUNT}\n tickValues={\n primaryAxis.tickValues == null\n ? undefined\n : Array.from(primaryAxis.tickValues)\n }\n stroke=\"var(--border-subtle)\"\n strokeDasharray={CHART_DASHED_STROKE_DASHARRAY}\n />\n )}\n {showGridColumns && (\n <GridColumns\n scale={xScale}\n height={innerHeight}\n numTicks={resolvedXTickCount}\n tickValues={resolvedXTickValues}\n stroke=\"var(--border-subtle)\"\n strokeDasharray={CHART_DASHED_STROKE_DASHARRAY}\n />\n )}\n <LineChartVerticalMarkers\n verticalMarkers={verticalMarkers}\n innerWidth={innerWidth}\n innerHeight={innerHeight}\n getXPosition={getXPosition}\n />\n <AxisBottom\n scale={xScale}\n top={innerHeight}\n numTicks={resolvedXTickCount}\n tickValues={resolvedXTickValues}\n hideAxisLine\n hideTicks\n tickFormat={(value) => formatXValue(value.valueOf())}\n tickLabelProps={(value) => {\n const x = chartMargin.left + getXPosition(value.valueOf());\n const labelWidth = Math.ceil(\n getStringWidth(formatXValue(value.valueOf()), {\n fontSize: `${CHART_TICK_FONT_SIZE}px`,\n fontFamily: 'Inter',\n }) ?? 0\n );\n return {\n fill: 'var(--text-tertiary)',\n fontSize: CHART_TICK_FONT_SIZE,\n textAnchor: 'middle',\n dx: Math.max(\n labelWidth / 2 - x,\n Math.min(0, width - x - labelWidth / 2)\n ),\n dy: '0.5em',\n };\n }}\n />\n {axes.map((axis, index) => {\n const tickFormat = (value: { valueOf(): number }) =>\n (axis.formatValue ?? defaultFormatValue)(value.valueOf());\n const textAnchor: 'end' | 'start' = index === 0 ? 'end' : 'start';\n const tickValues =\n axis.tickValues == null ? undefined : Array.from(axis.tickValues);\n const axisProps = {\n scale: axis.scale,\n numTicks: axis.tickCount ?? LINE_CHART_DEFAULT_TICK_COUNT,\n tickValues,\n tickLength: CHART_VALUE_AXIS_TICK_LENGTH,\n hideAxisLine: true,\n hideTicks: true,\n tickFormat,\n tickLabelProps: {\n fill: 'var(--text-tertiary)',\n fontSize: CHART_TICK_FONT_SIZE,\n textAnchor,\n dx: index === 0 ? '-0.25em' : '0.25em',\n dy: '0.25em',\n },\n };\n return index === 0 ? (\n <AxisLeft key={axis.id} {...axisProps} />\n ) : (\n <AxisRight\n key={axis.id}\n {...axisProps}\n left={innerWidth + getSecondaryChartAxisOffset(axes, index)}\n />\n );\n })}\n <g clipPath={`url(#${clipPathId})`}>\n <g clipPath={`url(#${revealClipPathId})`}>\n {stackedSeries == null\n ? series.map((item) => {\n const axis = axisById.get(item.yAxisId);\n if (axis == null) return null;\n return (\n <g\n key={item.id}\n role=\"group\"\n aria-label={`${item['aria-label'] ?? item.id} series`}\n >\n {getLineSegments(item.points, connectNulls).map(\n (segment, index) => (\n <LinePath\n key={index}\n data={segment}\n curve={curveLinear}\n fill=\"none\"\n stroke={item.color}\n strokeWidth={item.strokeWidth}\n strokeDasharray={item.strokeDasharray}\n opacity={getSeriesOpacity(item)}\n className=\"transition-opacity duration-fast motion-reduce:transition-none\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n x={(point) => getXPosition(point.x)}\n y={(point) => axis.scale(point.y ?? 0)}\n />\n )\n )}\n </g>\n );\n })\n : stackedSeries.map((item) => {\n const axis = axisById.get(item.yAxisId);\n if (axis == null) return null;\n return (\n <g\n key={item.id}\n role=\"group\"\n aria-label={`${item['aria-label'] ?? item.id} series`}\n >\n <Area\n data={Array.from(item.points)}\n curve={curveLinear}\n fill={item.color}\n opacity={getSeriesOpacity(item)}\n className=\"transition-opacity duration-fast motion-reduce:transition-none\"\n x={(point) => getXPosition(point.x)}\n y0={(point) => axis.scale(point.y0)}\n y1={(point) => axis.scale(point.y1)}\n />\n </g>\n );\n })}\n {showPoints &&\n markSeries.flatMap((item) => {\n const axis = axisById.get(item.yAxisId);\n if (axis == null) return [];\n return item.points.flatMap((point, pointIndex) =>\n point.y == null\n ? []\n : [\n <circle\n key={`${item.id}-${point.x}-${pointIndex}`}\n cx={getXPosition(point.x)}\n cy={axis.scale(point.y)}\n r={2.5}\n fill={item.color}\n opacity={getSeriesOpacity(item)}\n className=\"transition-opacity duration-fast motion-reduce:transition-none\"\n />,\n ]\n );\n })}\n </g>\n {selectionBounds != null && (\n <g\n role=\"group\"\n aria-label={`Selected range from ${formatXValue(\n Math.min(selectionRange?.from ?? 0, selectionRange?.to ?? 0)\n )} to ${formatXValue(\n Math.max(selectionRange?.from ?? 0, selectionRange?.to ?? 0)\n )}`}\n >\n <rect\n aria-hidden=\"true\"\n x={selectionBounds.x}\n y={0}\n width={selectionBounds.width}\n height={innerHeight}\n fill=\"var(--bg-brand)\"\n fillOpacity={0.1}\n stroke=\"var(--border-brand)\"\n pointerEvents=\"none\"\n />\n </g>\n )}\n {hasActiveX && (\n <>\n <line\n x1={activeXPosition}\n x2={activeXPosition}\n y1={0}\n y2={innerHeight}\n stroke=\"currentColor\"\n strokeWidth={1}\n strokeDasharray={CHART_DASHED_STROKE_DASHARRAY}\n className=\"text-quaternary\"\n />\n {markSeries.flatMap((item) => {\n if (!item.showActiveMarker) return [];\n const axis = axisById.get(item.yAxisId);\n const point = item.points.find(\n (candidate) => candidate.x === activeX\n );\n if (axis == null || point?.y == null) return [];\n return [\n <circle\n key={`active-${item.id}`}\n cx={activeXPosition}\n cy={axis.scale(point.y)}\n r={3}\n fill={item.color}\n opacity={getSeriesOpacity(item)}\n className=\"transition-opacity duration-fast motion-reduce:transition-none\"\n stroke=\"var(--bg-surface-level-1)\"\n strokeWidth={1.5}\n />,\n ];\n })}\n </>\n )}\n </g>\n {hasPointerInteraction && (\n <rect width={innerWidth} height={innerHeight} fill=\"transparent\" />\n )}\n </Group>\n )}\n {canRender &&\n axes.map((axis, index) => {\n if (axis.label == null) return null;\n const x =\n index === 0\n ? chartMargin.left - getChartAxisLabelOffset(axis.thickness)\n : chartMargin.left +\n innerWidth +\n getSecondaryChartAxisOffset(axes, index) +\n getChartAxisLabelOffset(axis.thickness);\n const y = chartMargin.top + innerHeight / 2;\n return (\n <Tooltip title={axis.label} key={axis.id}>\n <text\n x={x}\n y={y}\n fill=\"var(--text-quaternary)\"\n fontSize={CHART_TICK_FONT_SIZE}\n fontWeight={500}\n textAnchor=\"middle\"\n transform={`rotate(-90, ${x}, ${y})`}\n >\n {axis.label}\n </text>\n </Tooltip>\n );\n })}\n </svg>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwCA,IAAM,qBAAqB,IAAI,KAAK,aAAa,SAAS,EACxD,uBAAuB,EACzB,CAAC,CAAC,CAAC;AAEH,IAAM,uBACJ,UACA,QACA,WACA,cAC+B;CAC/B,GAAG;CACH;CACA;CACA,QAAQ,OAAO,KAAK,UAAU;EAC5B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,WAAU;MACX,CAAA,GACA,WAAW,SAAS,SAAS;OAC5B,IAAI,CAAC,KAAK,kBAAkB,OAAO,CAAC;OACpC,MAAM,OAAO,SAAS,IAAI,KAAK,OAAO;OACtC,MAAM,QAAQ,KAAK,OAAO,MACvB,cAAc,UAAU,MAAM,OACjC;OACA,IAAI,QAAQ,QAAQ,OAAO,KAAK,MAAM,OAAO,CAAC;OAC9C,OAAO,CACL,oBAAC,UAAD;QAEE,IAAI;QACJ,IAAI,KAAK,MAAM,MAAM,CAAC;QACtB,GAAG;QACH,MAAM,KAAK;QACX,SAAS,iBAAiB,IAAI;QAC9B,WAAU;QACV,QAAO;QACP,aAAa;OACd,GATM,UAAU,KAAK,IASrB,CACH;MACF,CAAC,CACD,EAAA,CAAA;KAEH;;IACF,yBACC,oBAAC,QAAD;KAAM,OAAO;KAAY,QAAQ;KAAa,MAAK;IAAe,CAAA;GAE/D;EAER,CAAA,GAAA,aACC,KAAK,KAAK,MAAM,UAAU;GACxB,IAAI,KAAK,SAAS,MAAM,OAAO;GAC/B,MAAM,IACJ,UAAU,IACN,YAAY,OAAO,wBAAwB,KAAK,SAAS,IACzD,YAAY,OACZ,aACA,4BAA4B,MAAM,KAAK,IACvC,wBAAwB,KAAK,SAAS;GAC5C,MAAM,IAAI,YAAY,MAAM,cAAc;GAC1C,OACE,oBAAC,SAAD;IAAS,OAAO,KAAK;IACnB,UAAA,oBAAC,QAAD;KACK;KACA;KACH,MAAK;KACL,UAAA;KACA,YAAY;KACZ,YAAW;KACX,WAAW,eAAe,EAAE,IAAI,EAAE;KAEjC,UAAA,KAAK;IACF,CAAA;GACC,GAZwB,KAAK,EAY7B;EAEb,CAAC,CACA;;AAET"}
|
|
@@ -28,8 +28,8 @@ export { StatusBadge } from './StatusBadge/index.js';
|
|
|
28
28
|
export type { StatusBadgeProps, StatusBadgeSize, StatusBadgeVariant, } from './StatusBadge/index.js';
|
|
29
29
|
export { Banner } from './Banner/Banner.js';
|
|
30
30
|
export type { BannerProps } from './Banner/Banner.js';
|
|
31
|
-
export { ChatComposer, ChatComposerAction, ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerContext, ChatComposerInput, ChatComposerModelSelect, ChatComposerToolbar, } from './ChatComposer/index.js';
|
|
32
|
-
export type { ChatComposerActionProps, ChatComposerAttachmentMenuProps, ChatComposerAttachmentProps, ChatComposerAttachmentsProps, ChatComposerContextValue, ChatComposerDrawerIntent, ChatComposerInputHandle, ChatComposerInputProps, ChatComposerModelSelectProps, ChatComposerProps, ChatComposerToolbarProps, } from './ChatComposer/index.js';
|
|
31
|
+
export { ChatComposer, ChatComposerAction, ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerContext, ChatComposerInput, ChatComposerModelSelect, ChatComposerTextarea, ChatComposerToolbar, } from './ChatComposer/index.js';
|
|
32
|
+
export type { ChatComposerActionProps, ChatComposerAttachmentMenuProps, ChatComposerAttachmentProps, ChatComposerAttachmentsProps, ChatComposerContextValue, ChatComposerDrawerIntent, ChatComposerInputHandle, ChatComposerInputProps, ChatComposerModelSelectProps, ChatComposerProps, ChatComposerTextareaProps, ChatComposerToolbarProps, } from './ChatComposer/index.js';
|
|
33
33
|
export { ChatConversation } from './ChatConversation/index.js';
|
|
34
34
|
export type { ChatConversationProps } from './ChatConversation/index.js';
|
|
35
35
|
export { ChatRichContent, ChatRichContentChoices, ChatRichContentFallback, } from './ChatRichContent/index.js';
|
package/dist/components/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import { ChatComposerContext } from "./ChatComposer/ChatComposerContext.js";
|
|
|
21
21
|
import { ChatComposer, ChatComposerAction, ChatComposerToolbar } from "./ChatComposer/ChatComposer.js";
|
|
22
22
|
import { ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments } from "./ChatComposer/ChatComposerAttachments.js";
|
|
23
23
|
import { Textarea } from "./Textarea/Textarea.js";
|
|
24
|
+
import { ChatComposerTextarea } from "./ChatComposer/ChatComposerTextarea.js";
|
|
24
25
|
import { ChatComposerInput } from "./ChatComposer/ChatComposerInput.js";
|
|
25
26
|
import { ChatComposerModelSelect } from "./ChatComposer/ChatComposerModelSelect.js";
|
|
26
27
|
import { ChatConversation } from "./ChatConversation/ChatConversation.js";
|
|
@@ -49,4 +50,4 @@ import { RadioCard } from "./RadioCard/RadioCard.js";
|
|
|
49
50
|
import { Slider } from "./Slider/Slider.js";
|
|
50
51
|
import { StatusBadge } from "./StatusBadge/StatusBadge.js";
|
|
51
52
|
import { Switch } from "./Switch/Switch.js";
|
|
52
|
-
export { Attachment, AttachmentList, Avatar, Badge, Banner, Breadcrumb, BreadcrumbLink, BreadcrumbPage, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, ChatComposer, ChatComposerAction, ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerContext, ChatComposerInput, ChatComposerModelSelect, ChatComposerToolbar, ChatConversation, ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatRichContent, ChatRichContentChoices, ChatRichContentFallback, ChatTurnDivider, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };
|
|
53
|
+
export { Attachment, AttachmentList, Avatar, Badge, Banner, Breadcrumb, BreadcrumbLink, BreadcrumbPage, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, ChatComposer, ChatComposerAction, ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerContext, ChatComposerInput, ChatComposerModelSelect, ChatComposerTextarea, ChatComposerToolbar, ChatConversation, ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatRichContent, ChatRichContentChoices, ChatRichContentFallback, ChatTurnDivider, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import { ChatComposerContext } from "./components/ChatComposer/ChatComposerConte
|
|
|
21
21
|
import { ChatComposer, ChatComposerAction, ChatComposerToolbar } from "./components/ChatComposer/ChatComposer.js";
|
|
22
22
|
import { ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments } from "./components/ChatComposer/ChatComposerAttachments.js";
|
|
23
23
|
import { Textarea } from "./components/Textarea/Textarea.js";
|
|
24
|
+
import { ChatComposerTextarea } from "./components/ChatComposer/ChatComposerTextarea.js";
|
|
24
25
|
import { ChatComposerInput } from "./components/ChatComposer/ChatComposerInput.js";
|
|
25
26
|
import { ChatComposerModelSelect } from "./components/ChatComposer/ChatComposerModelSelect.js";
|
|
26
27
|
import { ChatConversation } from "./components/ChatConversation/ChatConversation.js";
|
|
@@ -50,4 +51,4 @@ import { Slider } from "./components/Slider/Slider.js";
|
|
|
50
51
|
import { StatusBadge } from "./components/StatusBadge/StatusBadge.js";
|
|
51
52
|
import { Switch } from "./components/Switch/Switch.js";
|
|
52
53
|
import "./components/index.js";
|
|
53
|
-
export { Attachment, AttachmentList, Avatar, Badge, Banner, Breadcrumb, BreadcrumbLink, BreadcrumbPage, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, ChatComposer, ChatComposerAction, ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerContext, ChatComposerInput, ChatComposerModelSelect, ChatComposerToolbar, ChatConversation, ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatRichContent, ChatRichContentChoices, ChatRichContentFallback, ChatTurnDivider, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };
|
|
54
|
+
export { Attachment, AttachmentList, Avatar, Badge, Banner, Breadcrumb, BreadcrumbLink, BreadcrumbPage, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, ChatComposer, ChatComposerAction, ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerContext, ChatComposerInput, ChatComposerModelSelect, ChatComposerTextarea, ChatComposerToolbar, ChatConversation, ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatRichContent, ChatRichContentChoices, ChatRichContentFallback, ChatTurnDivider, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };
|
package/docs/DESIGN.md
CHANGED
|
@@ -209,10 +209,11 @@ only inside `ChatComposer`: `ChatComposerInput`, optional
|
|
|
209
209
|
|
|
210
210
|
Control the draft with `value`/`onChange` on `ChatComposerInput` and send from
|
|
211
211
|
`onSubmit`. Set `submitDisabled` when there is no text and no attachments, and
|
|
212
|
-
`disabled` to lock
|
|
212
|
+
`disabled` to lock writing and sending. Set `action="sending"` while a send is
|
|
213
213
|
pending and `action="stop"` with `onStop` during generation. Both block sending
|
|
214
|
-
and keep the input and attachments usable.
|
|
215
|
-
|
|
214
|
+
and keep the input and attachments usable. Stop stays available when the
|
|
215
|
+
composer is also `disabled`, so pass `disabled` to your own controls inside it
|
|
216
|
+
as well. Skip any state your app does not have.
|
|
216
217
|
|
|
217
218
|
Enter sends from a plain paragraph, Shift+Enter adds a line, and Ctrl/⌘+Enter
|
|
218
219
|
sends from any block. Without `onSubmit`, Enter only adds paragraphs. Three
|
|
@@ -222,6 +223,11 @@ load, the input switches to a plain textarea and reports the error to
|
|
|
222
223
|
`ErrorReporterContext` from
|
|
223
224
|
`@langchain/macaw-components/contexts/ErrorReporterContext`.
|
|
224
225
|
|
|
226
|
+
Use `ChatComposerTextarea` in place of `ChatComposerInput` for plain text when
|
|
227
|
+
the host relies on the native textarea: its ref and selection, a `name` in
|
|
228
|
+
form data, or its own key handling such as message history. Enter sends unless
|
|
229
|
+
the host's `onKeyDown` prevents it.
|
|
230
|
+
|
|
225
231
|
Validate files in `onFilesSelected`, which receives picked, dropped, and pasted
|
|
226
232
|
files. `accept` and `multiple` only configure the picker. Render accepted files
|
|
227
233
|
with `ChatComposerAttachment` inside `ChatComposerAttachments`, and set
|