@assistant-ui/react 0.10.20 → 0.10.21

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.
@@ -44,7 +44,7 @@ var ComposerPrimitiveInput = forwardRef(
44
44
  return c.text;
45
45
  });
46
46
  const Component = asChild ? Slot : TextareaAutosize;
47
- const isDisabled = useThread((t) => t.isDisabled) ?? disabledProp ?? false;
47
+ const isDisabled = Boolean(useThread((t) => t.isDisabled) || disabledProp);
48
48
  const textareaRef = useRef(null);
49
49
  const ref = useComposedRefs(forwardedRef, textareaRef);
50
50
  useEscapeKeydown((e) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/primitives/composer/ComposerInput.tsx"],"sourcesContent":["\"use client\";\n\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n ClipboardEvent,\n type KeyboardEvent,\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport TextareaAutosize, {\n type TextareaAutosizeProps,\n} from \"react-textarea-autosize\";\nimport {\n useComposer,\n useComposerRuntime,\n} from \"../../context/react/ComposerContext\";\nimport { useThread, useThreadRuntime } from \"../../context/react/ThreadContext\";\nimport { useEscapeKeydown } from \"@radix-ui/react-use-escape-keydown\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useThreadListItemRuntime } from \"../../context/react/ThreadListItemContext\";\n\nexport namespace ComposerPrimitiveInput {\n export type Element = HTMLTextAreaElement;\n export type Props = TextareaAutosizeProps & {\n asChild?: boolean | undefined;\n submitOnEnter?: boolean | undefined;\n cancelOnEscape?: boolean | undefined;\n unstable_focusOnRunStart?: boolean | undefined;\n unstable_focusOnScrollToBottom?: boolean | undefined;\n unstable_focusOnThreadSwitched?: boolean | undefined;\n addAttachmentOnPaste?: boolean | undefined;\n };\n}\n\nexport const ComposerPrimitiveInput = forwardRef<\n ComposerPrimitiveInput.Element,\n ComposerPrimitiveInput.Props\n>(\n (\n {\n autoFocus = false,\n asChild,\n disabled: disabledProp,\n onChange,\n onKeyDown,\n onPaste,\n submitOnEnter = true,\n cancelOnEscape = true,\n unstable_focusOnRunStart = true,\n unstable_focusOnScrollToBottom = true,\n unstable_focusOnThreadSwitched = true,\n addAttachmentOnPaste = true,\n ...rest\n },\n forwardedRef,\n ) => {\n const threadListItemRuntime = useThreadListItemRuntime();\n const threadRuntime = useThreadRuntime();\n const composerRuntime = useComposerRuntime();\n\n const value = useComposer((c) => {\n if (!c.isEditing) return \"\";\n return c.text;\n });\n\n const Component = asChild ? Slot : TextareaAutosize;\n\n const isDisabled = useThread((t) => t.isDisabled) ?? disabledProp ?? false;\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const ref = useComposedRefs(forwardedRef, textareaRef);\n\n useEscapeKeydown((e) => {\n if (!cancelOnEscape) return;\n\n if (composerRuntime.getState().canCancel) {\n composerRuntime.cancel();\n e.preventDefault();\n }\n });\n\n const handleKeyPress = (e: KeyboardEvent) => {\n if (isDisabled || !submitOnEnter) return;\n\n // ignore IME composition events\n if (e.nativeEvent.isComposing) return;\n\n if (e.key === \"Enter\" && e.shiftKey === false) {\n const { isRunning } = threadRuntime.getState();\n\n if (!isRunning) {\n e.preventDefault();\n\n textareaRef.current?.closest(\"form\")?.requestSubmit();\n }\n }\n };\n\n const handlePaste = async (e: ClipboardEvent<HTMLTextAreaElement>) => {\n if (!addAttachmentOnPaste) return;\n const threadCapabilities = threadRuntime.getState().capabilities;\n const files = Array.from(e.clipboardData?.files || []);\n\n if (threadCapabilities.attachments && files.length > 0) {\n try {\n e.preventDefault();\n await Promise.all(\n files.map((file) => composerRuntime.addAttachment(file)),\n );\n } catch (error) {\n console.error(\"Error adding attachment:\", error);\n }\n }\n };\n\n const autoFocusEnabled = autoFocus && !isDisabled;\n const focus = useCallback(() => {\n const textarea = textareaRef.current;\n if (!textarea || !autoFocusEnabled) return;\n\n textarea.focus({ preventScroll: true });\n textarea.setSelectionRange(textarea.value.length, textarea.value.length);\n }, [autoFocusEnabled]);\n\n useEffect(() => focus(), [focus]);\n\n useOnScrollToBottom(() => {\n if (composerRuntime.type === \"thread\" && unstable_focusOnScrollToBottom) {\n focus();\n }\n });\n\n useEffect(() => {\n if (composerRuntime.type !== \"thread\" || !unstable_focusOnRunStart)\n return undefined;\n\n return threadRuntime.unstable_on(\"run-start\", focus);\n }, [unstable_focusOnRunStart, focus, composerRuntime, threadRuntime]);\n\n useEffect(() => {\n if (composerRuntime.type !== \"thread\" || !unstable_focusOnThreadSwitched)\n return undefined;\n\n return threadListItemRuntime.unstable_on(\"switched-to\", focus);\n }, [\n unstable_focusOnThreadSwitched,\n focus,\n composerRuntime,\n threadListItemRuntime,\n ]);\n\n return (\n <Component\n name=\"input\"\n value={value}\n {...rest}\n ref={ref}\n disabled={isDisabled}\n onChange={composeEventHandlers(onChange, (e) => {\n if (!composerRuntime.getState().isEditing) return;\n return composerRuntime.setText(e.target.value);\n })}\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyPress)}\n onPaste={composeEventHandlers(onPaste, handlePaste)}\n />\n );\n },\n);\n\nComposerPrimitiveInput.displayName = \"ComposerPrimitive.Input\";\n"],"mappings":";;;AAEA,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,sBAEA;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,WAAW,wBAAwB;AAC5C,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,gCAAgC;AAoInC;AArHC,IAAM,yBAAyB;AAAA,EAIpC,CACE;AAAA,IACE,YAAY;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,2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ACpD;AAAA,EAEJ;AACF;AAEA,uBAAuB,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/primitives/composer/ComposerInput.tsx"],"sourcesContent":["\"use client\";\n\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n ClipboardEvent,\n type KeyboardEvent,\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport TextareaAutosize, {\n type TextareaAutosizeProps,\n} from \"react-textarea-autosize\";\nimport {\n useComposer,\n useComposerRuntime,\n} from \"../../context/react/ComposerContext\";\nimport { useThread, useThreadRuntime } from \"../../context/react/ThreadContext\";\nimport { useEscapeKeydown } from \"@radix-ui/react-use-escape-keydown\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useThreadListItemRuntime } from \"../../context/react/ThreadListItemContext\";\n\nexport namespace ComposerPrimitiveInput {\n export type Element = HTMLTextAreaElement;\n export type Props = TextareaAutosizeProps & {\n asChild?: boolean | undefined;\n submitOnEnter?: boolean | undefined;\n cancelOnEscape?: boolean | undefined;\n unstable_focusOnRunStart?: boolean | undefined;\n unstable_focusOnScrollToBottom?: boolean | undefined;\n unstable_focusOnThreadSwitched?: boolean | undefined;\n addAttachmentOnPaste?: boolean | undefined;\n };\n}\n\nexport const ComposerPrimitiveInput = forwardRef<\n ComposerPrimitiveInput.Element,\n ComposerPrimitiveInput.Props\n>(\n (\n {\n autoFocus = false,\n asChild,\n disabled: disabledProp,\n onChange,\n onKeyDown,\n onPaste,\n submitOnEnter = true,\n cancelOnEscape = true,\n unstable_focusOnRunStart = true,\n unstable_focusOnScrollToBottom = true,\n unstable_focusOnThreadSwitched = true,\n addAttachmentOnPaste = true,\n ...rest\n },\n forwardedRef,\n ) => {\n const threadListItemRuntime = useThreadListItemRuntime();\n const threadRuntime = useThreadRuntime();\n const composerRuntime = useComposerRuntime();\n\n const value = useComposer((c) => {\n if (!c.isEditing) return \"\";\n return c.text;\n });\n\n const Component = asChild ? Slot : TextareaAutosize;\n\n const isDisabled = Boolean(useThread((t) => t.isDisabled) || disabledProp);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const ref = useComposedRefs(forwardedRef, textareaRef);\n\n useEscapeKeydown((e) => {\n if (!cancelOnEscape) return;\n\n if (composerRuntime.getState().canCancel) {\n composerRuntime.cancel();\n e.preventDefault();\n }\n });\n\n const handleKeyPress = (e: KeyboardEvent) => {\n if (isDisabled || !submitOnEnter) return;\n\n // ignore IME composition events\n if (e.nativeEvent.isComposing) return;\n\n if (e.key === \"Enter\" && e.shiftKey === false) {\n const { isRunning } = threadRuntime.getState();\n\n if (!isRunning) {\n e.preventDefault();\n\n textareaRef.current?.closest(\"form\")?.requestSubmit();\n }\n }\n };\n\n const handlePaste = async (e: ClipboardEvent<HTMLTextAreaElement>) => {\n if (!addAttachmentOnPaste) return;\n const threadCapabilities = threadRuntime.getState().capabilities;\n const files = Array.from(e.clipboardData?.files || []);\n\n if (threadCapabilities.attachments && files.length > 0) {\n try {\n e.preventDefault();\n await Promise.all(\n files.map((file) => composerRuntime.addAttachment(file)),\n );\n } catch (error) {\n console.error(\"Error adding attachment:\", error);\n }\n }\n };\n\n const autoFocusEnabled = autoFocus && !isDisabled;\n const focus = useCallback(() => {\n const textarea = textareaRef.current;\n if (!textarea || !autoFocusEnabled) return;\n\n textarea.focus({ preventScroll: true });\n textarea.setSelectionRange(textarea.value.length, textarea.value.length);\n }, [autoFocusEnabled]);\n\n useEffect(() => focus(), [focus]);\n\n useOnScrollToBottom(() => {\n if (composerRuntime.type === \"thread\" && unstable_focusOnScrollToBottom) {\n focus();\n }\n });\n\n useEffect(() => {\n if (composerRuntime.type !== \"thread\" || !unstable_focusOnRunStart)\n return undefined;\n\n return threadRuntime.unstable_on(\"run-start\", focus);\n }, [unstable_focusOnRunStart, focus, composerRuntime, threadRuntime]);\n\n useEffect(() => {\n if (composerRuntime.type !== \"thread\" || !unstable_focusOnThreadSwitched)\n return undefined;\n\n return threadListItemRuntime.unstable_on(\"switched-to\", focus);\n }, [\n unstable_focusOnThreadSwitched,\n focus,\n composerRuntime,\n threadListItemRuntime,\n ]);\n\n return (\n <Component\n name=\"input\"\n value={value}\n {...rest}\n ref={ref}\n disabled={isDisabled}\n onChange={composeEventHandlers(onChange, (e) => {\n if (!composerRuntime.getState().isEditing) return;\n return composerRuntime.setText(e.target.value);\n })}\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyPress)}\n onPaste={composeEventHandlers(onPaste, handlePaste)}\n />\n );\n },\n);\n\nComposerPrimitiveInput.displayName = \"ComposerPrimitive.Input\";\n"],"mappings":";;;AAEA,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,sBAEA;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,WAAW,wBAAwB;AAC5C,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,gCAAgC;AAoInC;AArHC,IAAM,yBAAyB;AAAA,EAIpC,CACE;AAAA,IACE,YAAY;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,2BAA2B;AAAA,IAC3B,iCAAiC;AAAA,IACjC,iCAAiC;AAAA,IACjC,uBAAuB;AAAA,IACvB,GAAG;AAAA,EACL,GACA,iBACG;AACH,UAAM,wBAAwB,yBAAyB;AACvD,UAAM,gBAAgB,iBAAiB;AACvC,UAAM,kBAAkB,mBAAmB;AAE3C,UAAM,QAAQ,YAAY,CAAC,MAAM;AAC/B,UAAI,CAAC,EAAE,UAAW,QAAO;AACzB,aAAO,EAAE;AAAA,IACX,CAAC;AAED,UAAM,YAAY,UAAU,OAAO;AAEnC,UAAM,aAAa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AM;AAAA,IACzE,GAAG,CAAC,gBAAgB,CAAC;AAErB,cAAU,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC;AAEhC,wBAAoB,MAAM;AACxB,UAAI,gBAAgB,SAAS,YAAY,gCAAgC;AACvE,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AAED,cAAU,MAAM;AACd,UAAI,gBAAgB,SAAS,YAAY,CAAC;AACxC,eAAO;AAET,aAAO,cAAc,YAAY,aAAa,KAAK;AAAA,IACrD,GAAG,CAAC,0BAA0B,OAAO,iBAAiB,aAAa,CAAC;AAEpE,cAAU,MAAM;AACd,UAAI,gBAAgB,SAAS,YAAY,CAAC;AACxC,eAAO;AAET,aAAO,sBAAsB,YAAY,eAAe,KAAK;AAAA,IAC/D,GAAG;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL;AAAA,QACC,GAAG;AAAA,QACJ;AAAA,QACA,UAAU;AAAA,QACV,UAAU,qBAAqB,UAAU,CAAC,MAAM;AAC9C,cAAI,CAAC,gBAAgB,SAAS,EAAE,UAAW;AAC3C,iBAAO,gBAAgB,QAAQ,EAAE,OAAO,KAAK;AAAA,QAC/C,CAAC;AAAA,QACD,WAAW,qBAAqB,WAAW,cAAc;AAAA,QACzD,SAAS,qBAAqB,SAAS,WAAW;AAAA;AAAA,IACpD;AAAA,EAEJ;AACF;AAEA,uBAAuB,cAAc;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"RuntimeAdapterProvider.d.ts","sourceRoot":"","sources":["../../../src/runtimes/adapters/RuntimeAdapterProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC,CAAC;AAIF,kBAAU,sBAAsB,CAAC;IAC/B,KAAY,KAAK,GAAG;QAClB,QAAQ,EAAE,eAAe,CAAC;QAC1B,QAAQ,EAAE,SAAS,CAAC;KACrB,CAAC;CACH;AAED,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,sBAAsB,CAAC,KAAK,CAenE,CAAC;AAEF,eAAO,MAAM,kBAAkB,8BAG9B,CAAC"}
1
+ {"version":3,"file":"RuntimeAdapterProvider.d.ts","sourceRoot":"","sources":["../../../src/runtimes/adapters/RuntimeAdapterProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC,CAAC;AAIF,kBAAU,sBAAsB,CAAC;IAC/B,KAAY,KAAK,GAAG;QAClB,QAAQ,EAAE,eAAe,CAAC;QAC1B,QAAQ,EAAE,SAAS,CAAC;KACrB,CAAC;CACH;AAED,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,sBAAsB,CAAC,KAAK,CAenE,CAAC;AAEF,eAAO,MAAM,kBAAkB,8BAG9B,CAAC"}
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  // src/runtimes/adapters/RuntimeAdapterProvider.tsx
2
4
  import { createContext, useContext } from "react";
3
5
  import { jsx } from "react/jsx-runtime";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/adapters/RuntimeAdapterProvider.tsx"],"sourcesContent":["import { createContext, FC, ReactNode, useContext } from \"react\";\nimport { ThreadHistoryAdapter } from \"./thread-history/ThreadHistoryAdapter\";\nimport { ModelContextProvider } from \"../../model-context\";\n\nexport type RuntimeAdapters = {\n modelContext?: ModelContextProvider;\n history?: ThreadHistoryAdapter;\n};\n\nconst RuntimeAdaptersContext = createContext<RuntimeAdapters | null>(null);\n\nnamespace RuntimeAdapterProvider {\n export type Props = {\n adapters: RuntimeAdapters;\n children: ReactNode;\n };\n}\n\nexport const RuntimeAdapterProvider: FC<RuntimeAdapterProvider.Props> = ({\n adapters,\n children,\n}) => {\n const context = useContext(RuntimeAdaptersContext);\n return (\n <RuntimeAdaptersContext.Provider\n value={{\n ...context,\n ...adapters,\n }}\n >\n {children}\n </RuntimeAdaptersContext.Provider>\n );\n};\n\nexport const useRuntimeAdapters = () => {\n const adapters = useContext(RuntimeAdaptersContext);\n return adapters;\n};\n"],"mappings":";AAAA,SAAS,eAA8B,kBAAkB;AAwBrD;AAfJ,IAAM,yBAAyB,cAAsC,IAAI;AASlE,IAAM,yBAA2D,CAAC;AAAA,EACvE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,UAAU,WAAW,sBAAsB;AACjD,SACE;AAAA,IAAC,uBAAuB;AAAA,IAAvB;AAAA,MACC,OAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEO,IAAM,qBAAqB,MAAM;AACtC,QAAM,WAAW,WAAW,sBAAsB;AAClD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/runtimes/adapters/RuntimeAdapterProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, FC, ReactNode, useContext } from \"react\";\nimport { ThreadHistoryAdapter } from \"./thread-history/ThreadHistoryAdapter\";\nimport { ModelContextProvider } from \"../../model-context\";\n\nexport type RuntimeAdapters = {\n modelContext?: ModelContextProvider;\n history?: ThreadHistoryAdapter;\n};\n\nconst RuntimeAdaptersContext = createContext<RuntimeAdapters | null>(null);\n\nnamespace RuntimeAdapterProvider {\n export type Props = {\n adapters: RuntimeAdapters;\n children: ReactNode;\n };\n}\n\nexport const RuntimeAdapterProvider: FC<RuntimeAdapterProvider.Props> = ({\n adapters,\n children,\n}) => {\n const context = useContext(RuntimeAdaptersContext);\n return (\n <RuntimeAdaptersContext.Provider\n value={{\n ...context,\n ...adapters,\n }}\n >\n {children}\n </RuntimeAdaptersContext.Provider>\n );\n};\n\nexport const useRuntimeAdapters = () => {\n const adapters = useContext(RuntimeAdaptersContext);\n return adapters;\n};\n"],"mappings":";;;AAEA,SAAS,eAA8B,kBAAkB;AAwBrD;AAfJ,IAAM,yBAAyB,cAAsC,IAAI;AASlE,IAAM,yBAA2D,CAAC;AAAA,EACvE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,UAAU,WAAW,sBAAsB;AACjD,SACE;AAAA,IAAC,uBAAuB;AAAA,IAAvB;AAAA,MACC,OAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEO,IAAM,qBAAqB,MAAM;AACtC,QAAM,WAAW,WAAW,sBAAsB;AAClD,SAAO;AACT;","names":[]}