@assistant-ui/react-markdown 0.2.5 → 0.2.7

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/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
- import { ComponentType, FC } from 'react';
2
+ import { ElementType, ComponentType, ForwardRefExoticComponent, RefAttributes, ElementRef, ComponentPropsWithoutRef, FC } from 'react';
3
3
  import { Options } from 'react-markdown';
4
- import { TextContentPartProps } from '@assistant-ui/react';
4
+ import { Primitive } from '@radix-ui/react-primitive';
5
5
 
6
6
  type PreComponent = NonNullable<NonNullable<Options["components"]>["pre"]>;
7
7
  type CodeComponent = NonNullable<NonNullable<Options["components"]>["code"]>;
@@ -18,7 +18,11 @@ type SyntaxHighlighterProps = {
18
18
  code: string;
19
19
  };
20
20
 
21
+ type MarkdownTextPrimitiveElement = ElementRef<typeof Primitive.div>;
22
+ type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
21
23
  type MarkdownTextPrimitiveProps = Omit<Options, "components" | "children"> & {
24
+ containerProps?: Omit<PrimitiveDivProps, "children" | "asChild">;
25
+ containerComponent?: ElementType;
22
26
  components?: NonNullable<Options["components"]> & {
23
27
  SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;
24
28
  CodeHeader?: ComponentType<CodeHeaderProps>;
@@ -29,12 +33,12 @@ type MarkdownTextPrimitiveProps = Omit<Options, "components" | "children"> & {
29
33
  };
30
34
  smooth?: boolean;
31
35
  };
32
- declare const MarkdownTextPrimitive: FC<MarkdownTextPrimitiveProps>;
36
+ declare const MarkdownTextPrimitive: ForwardRefExoticComponent<MarkdownTextPrimitiveProps> & RefAttributes<MarkdownTextPrimitiveElement>;
33
37
 
34
38
  declare const useIsMarkdownCodeBlock: () => boolean;
35
39
 
36
40
  type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;
37
- declare const makeMarkdownText: ({ className, components: userComponents, ...rest }?: MakeMarkdownTextProps) => react.NamedExoticComponent<TextContentPartProps>;
41
+ declare const makeMarkdownText: ({ className, components: userComponents, ...rest }?: MakeMarkdownTextProps) => react.NamedExoticComponent<{}>;
38
42
 
39
43
  declare const CodeHeader: FC<CodeHeaderProps>;
40
44
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
- import { ComponentType, FC } from 'react';
2
+ import { ElementType, ComponentType, ForwardRefExoticComponent, RefAttributes, ElementRef, ComponentPropsWithoutRef, FC } from 'react';
3
3
  import { Options } from 'react-markdown';
4
- import { TextContentPartProps } from '@assistant-ui/react';
4
+ import { Primitive } from '@radix-ui/react-primitive';
5
5
 
6
6
  type PreComponent = NonNullable<NonNullable<Options["components"]>["pre"]>;
7
7
  type CodeComponent = NonNullable<NonNullable<Options["components"]>["code"]>;
@@ -18,7 +18,11 @@ type SyntaxHighlighterProps = {
18
18
  code: string;
19
19
  };
20
20
 
21
+ type MarkdownTextPrimitiveElement = ElementRef<typeof Primitive.div>;
22
+ type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
21
23
  type MarkdownTextPrimitiveProps = Omit<Options, "components" | "children"> & {
24
+ containerProps?: Omit<PrimitiveDivProps, "children" | "asChild">;
25
+ containerComponent?: ElementType;
22
26
  components?: NonNullable<Options["components"]> & {
23
27
  SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;
24
28
  CodeHeader?: ComponentType<CodeHeaderProps>;
@@ -29,12 +33,12 @@ type MarkdownTextPrimitiveProps = Omit<Options, "components" | "children"> & {
29
33
  };
30
34
  smooth?: boolean;
31
35
  };
32
- declare const MarkdownTextPrimitive: FC<MarkdownTextPrimitiveProps>;
36
+ declare const MarkdownTextPrimitive: ForwardRefExoticComponent<MarkdownTextPrimitiveProps> & RefAttributes<MarkdownTextPrimitiveElement>;
33
37
 
34
38
  declare const useIsMarkdownCodeBlock: () => boolean;
35
39
 
36
40
  type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;
37
- declare const makeMarkdownText: ({ className, components: userComponents, ...rest }?: MakeMarkdownTextProps) => react.NamedExoticComponent<TextContentPartProps>;
41
+ declare const makeMarkdownText: ({ className, components: userComponents, ...rest }?: MakeMarkdownTextProps) => react.NamedExoticComponent<{}>;
38
42
 
39
43
  declare const CodeHeader: FC<CodeHeaderProps>;
40
44
 
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ module.exports = __toCommonJS(src_exports);
40
40
 
41
41
  // src/primitives/MarkdownText.tsx
42
42
  var import_react4 = require("@assistant-ui/react");
43
+ var import_react5 = require("react");
43
44
  var import_react_markdown = __toESM(require("react-markdown"));
44
45
 
45
46
  // src/overrides/PreOverride.tsx
@@ -159,58 +160,73 @@ var CodeOverride = ({
159
160
  };
160
161
 
161
162
  // src/primitives/MarkdownText.tsx
163
+ var import_classnames2 = __toESM(require("classnames"));
162
164
  var import_jsx_runtime5 = require("react/jsx-runtime");
163
165
  var { useSmooth } = import_react4.INTERNAL;
164
- var MarkdownTextPrimitive = ({
165
- smooth = true,
166
- components: userComponents,
167
- ...rest
168
- }) => {
169
- const {
170
- part: { text }
171
- } = (0, import_react4.useContentPartText)();
172
- const smoothText = useSmooth(text, smooth);
173
- const {
174
- pre = DefaultPre,
175
- code = DefaultCode,
176
- SyntaxHighlighter = DefaultCodeBlockContent,
177
- CodeHeader: CodeHeader2 = DefaultCodeHeader,
178
- by_language,
179
- ...componentsRest
180
- } = userComponents ?? {};
181
- const components = {
182
- ...componentsRest,
183
- pre: PreOverride,
184
- code: (0, import_react_use_callback_ref2.useCallbackRef)((props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
185
- CodeOverride,
166
+ var MarkdownTextPrimitive = (0, import_react5.forwardRef)(
167
+ ({
168
+ components: userComponents,
169
+ className,
170
+ containerProps,
171
+ containerComponent: Container = "div",
172
+ ...rest
173
+ }, forwardedRef, smooth = true) => {
174
+ const {
175
+ part: { text },
176
+ status
177
+ } = useSmooth((0, import_react4.useContentPartText)(), smooth);
178
+ const {
179
+ pre = DefaultPre,
180
+ code = DefaultCode,
181
+ SyntaxHighlighter = DefaultCodeBlockContent,
182
+ CodeHeader: CodeHeader2 = DefaultCodeHeader,
183
+ by_language,
184
+ ...componentsRest
185
+ } = userComponents ?? {};
186
+ const components = {
187
+ ...componentsRest,
188
+ pre: PreOverride,
189
+ code: (0, import_react_use_callback_ref2.useCallbackRef)((props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
190
+ CodeOverride,
191
+ {
192
+ components: {
193
+ Pre: pre,
194
+ Code: code,
195
+ SyntaxHighlighter,
196
+ CodeHeader: CodeHeader2,
197
+ by_language
198
+ },
199
+ ...props
200
+ }
201
+ ))
202
+ };
203
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
204
+ Container,
186
205
  {
187
- components: {
188
- Pre: pre,
189
- Code: code,
190
- SyntaxHighlighter,
191
- CodeHeader: CodeHeader2,
192
- by_language
193
- },
194
- ...props
206
+ "data-status": status.type,
207
+ ...containerProps,
208
+ className: (0, import_classnames2.default)(className, containerProps?.className),
209
+ ref: forwardedRef,
210
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_markdown.default, { components, ...rest, children: text })
195
211
  }
196
- ))
197
- };
198
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_markdown.default, { components, ...rest, children: smoothText });
199
- };
212
+ );
213
+ }
214
+ );
215
+ MarkdownTextPrimitive.displayName = "MarkdownTextPrimitive";
200
216
 
201
217
  // src/ui/markdown-text.tsx
202
- var import_react7 = require("react");
218
+ var import_react8 = require("react");
203
219
 
204
220
  // src/ui/code-header.tsx
205
221
  var import_lucide_react = require("lucide-react");
206
- var import_react6 = require("@assistant-ui/react");
222
+ var import_react7 = require("@assistant-ui/react");
207
223
 
208
224
  // src/ui/useCopyToClipboard.tsx
209
- var import_react5 = require("react");
225
+ var import_react6 = require("react");
210
226
  var useCopyToClipboard = ({
211
227
  copiedDuration = 3e3
212
228
  } = {}) => {
213
- const [isCopied, setIsCopied] = (0, import_react5.useState)(false);
229
+ const [isCopied, setIsCopied] = (0, import_react6.useState)(false);
214
230
  const copyToClipboard = (value) => {
215
231
  if (!value) return;
216
232
  navigator.clipboard.writeText(value).then(() => {
@@ -223,13 +239,13 @@ var useCopyToClipboard = ({
223
239
 
224
240
  // src/ui/code-header.tsx
225
241
  var import_jsx_runtime6 = require("react/jsx-runtime");
226
- var { TooltipIconButton } = import_react6.INTERNAL;
242
+ var { TooltipIconButton } = import_react7.INTERNAL;
227
243
  var CodeHeader = ({ language, code }) => {
228
244
  const {
229
245
  strings: {
230
246
  code: { header: { copy: { tooltip = "Copy" } = {} } = {} } = {}
231
247
  } = {}
232
- } = (0, import_react6.useThreadConfig)();
248
+ } = (0, import_react7.useThreadConfig)();
233
249
  const { isCopied, copyToClipboard } = useCopyToClipboard();
234
250
  const onCopy = () => {
235
251
  if (!code || isCopied) return;
@@ -245,8 +261,10 @@ var CodeHeader = ({ language, code }) => {
245
261
  };
246
262
 
247
263
  // src/ui/markdown-text.tsx
248
- var import_classnames2 = __toESM(require("classnames"));
264
+ var import_classnames3 = __toESM(require("classnames"));
265
+ var import_react9 = require("@assistant-ui/react");
249
266
  var import_jsx_runtime7 = require("react/jsx-runtime");
267
+ var { withSmoothContextProvider, useSmoothStatus } = import_react9.INTERNAL;
250
268
  var makeMarkdownText = ({
251
269
  className,
252
270
  components: userComponents,
@@ -256,24 +274,23 @@ var makeMarkdownText = ({
256
274
  ...userComponents,
257
275
  CodeHeader: userComponents?.CodeHeader ?? CodeHeader
258
276
  };
259
- const MarkdownTextImpl = ({ status }) => {
277
+ const MarkdownTextImpl = () => {
278
+ const status = useSmoothStatus();
260
279
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
261
- "div",
280
+ MarkdownTextPrimitive,
262
281
  {
263
- className: (0, import_classnames2.default)(
282
+ components,
283
+ ...rest,
284
+ className: (0, import_classnames3.default)(
264
285
  "aui-md-root",
265
- status.type === "running" && "aui-md-in-progress",
286
+ status.type === "running" && "aui-md-running",
266
287
  className
267
- ),
268
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MarkdownTextPrimitive, { components, ...rest })
288
+ )
269
289
  }
270
290
  );
271
291
  };
272
292
  MarkdownTextImpl.displayName = "MarkdownText";
273
- return (0, import_react7.memo)(
274
- MarkdownTextImpl,
275
- (prev, next) => prev.status.type === next.status.type
276
- );
293
+ return (0, import_react8.memo)(withSmoothContextProvider(MarkdownTextImpl), () => true);
277
294
  };
278
295
  // Annotate the CommonJS export names for ESM import in node:
279
296
  0 && (module.exports = {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/primitives/MarkdownText.tsx","../src/overrides/PreOverride.tsx","../src/overrides/defaultComponents.tsx","../src/overrides/CodeOverride.tsx","../src/overrides/CodeBlock.tsx","../src/overrides/withDefaults.tsx","../src/ui/markdown-text.tsx","../src/ui/code-header.tsx","../src/ui/useCopyToClipboard.tsx"],"sourcesContent":["export {\n MarkdownTextPrimitive,\n type MarkdownTextPrimitiveProps,\n} from \"./primitives/MarkdownText\";\n\nexport type {\n CodeHeaderProps,\n SyntaxHighlighterProps,\n} from \"./overrides/types\";\n\nexport { useIsMarkdownCodeBlock } from \"./overrides/PreOverride\";\n\nexport {\n makeMarkdownText,\n type MakeMarkdownTextProps,\n} from \"./ui/markdown-text\";\n\nexport { CodeHeader } from \"./ui/code-header\";\n","\"use client\";\n\nimport { INTERNAL, useContentPartText } from \"@assistant-ui/react\";\nimport type { ComponentType, FC } from \"react\";\nimport ReactMarkdown, { type Options } from \"react-markdown\";\nimport { SyntaxHighlighterProps, CodeHeaderProps } from \"../overrides/types\";\nimport { PreOverride } from \"../overrides/PreOverride\";\nimport {\n DefaultPre,\n DefaultCode,\n DefaultCodeBlockContent,\n DefaultCodeHeader,\n} from \"../overrides/defaultComponents\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { CodeOverride } from \"../overrides/CodeOverride\";\n\nconst { useSmooth } = INTERNAL;\n\nexport type MarkdownTextPrimitiveProps = Omit<\n Options,\n \"components\" | \"children\"\n> & {\n components?: NonNullable<Options[\"components\"]> & {\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n CodeHeader?: ComponentType<CodeHeaderProps>;\n by_language?: Record<\n string,\n {\n CodeHeader?: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n }\n >;\n };\n smooth?: boolean;\n};\nexport const MarkdownTextPrimitive: FC<MarkdownTextPrimitiveProps> = ({\n smooth = true,\n components: userComponents,\n ...rest\n}) => {\n const {\n part: { text },\n } = useContentPartText();\n const smoothText = useSmooth(text, smooth); // TODO loading indicator disappears before smooth animation ends\n\n const {\n pre = DefaultPre,\n code = DefaultCode,\n SyntaxHighlighter = DefaultCodeBlockContent,\n CodeHeader = DefaultCodeHeader,\n by_language,\n ...componentsRest\n } = userComponents ?? {};\n const components: typeof userComponents = {\n ...componentsRest,\n pre: PreOverride,\n code: useCallbackRef((props) => (\n <CodeOverride\n components={{\n Pre: pre,\n Code: code,\n SyntaxHighlighter,\n CodeHeader,\n by_language,\n }}\n {...props}\n />\n )),\n };\n\n return (\n <ReactMarkdown components={components} {...rest}>\n {smoothText}\n </ReactMarkdown>\n );\n};\n","import { createContext, ComponentPropsWithoutRef, useContext } from \"react\";\nimport { PreComponent } from \"./types\";\n\nexport const PreContext = createContext<Omit<\n ComponentPropsWithoutRef<PreComponent>,\n \"children\"\n> | null>(null);\n\nexport const useIsMarkdownCodeBlock = () => {\n return useContext(PreContext) !== null;\n};\n\nexport const PreOverride: PreComponent = ({ children, ...rest }) => {\n return <PreContext.Provider value={rest}>{children}</PreContext.Provider>;\n};\n","import type { ComponentType, ReactNode } from \"react\";\nimport { PreComponent, CodeComponent, CodeHeaderProps } from \"./types\";\n\nexport const DefaultPre: PreComponent = ({ node, ...rest }) => (\n <pre {...rest} />\n);\n\nexport const DefaultCode: CodeComponent = ({ node, ...rest }) => (\n <code {...rest} />\n);\n\nexport const DefaultCodeBlockContent: ComponentType<{\n components: { Pre: PreComponent; Code: CodeComponent };\n code: string | ReactNode | undefined;\n}> = ({ components: { Pre, Code }, code }) => (\n <Pre>\n <Code>{code}</Code>\n </Pre>\n);\n\nexport const DefaultCodeHeader: ComponentType<CodeHeaderProps> = () => null;\n","import { ComponentPropsWithoutRef, ComponentType, FC, useContext } from \"react\";\nimport { PreContext } from \"./PreOverride\";\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultCodeBlock } from \"./CodeBlock\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { withDefaultProps } from \"./withDefaults\";\nimport { DefaultCodeBlockContent } from \"./defaultComponents\";\n\nconst CodeBlockOverride: FC<CodeOverrideProps> = ({\n components: {\n Pre,\n Code,\n SyntaxHighlighter: FallbackSyntaxHighlighter,\n CodeHeader: FallbackCodeHeader,\n by_language = {},\n },\n children,\n ...codeProps\n}) => {\n const preProps = useContext(PreContext)!;\n const getPreProps = withDefaultProps<any>(preProps);\n const WrappedPre: PreComponent = useCallbackRef((props) => (\n <Pre {...getPreProps(props)} />\n ));\n\n const getCodeProps = withDefaultProps<any>(codeProps);\n const WrappedCode: CodeComponent = useCallbackRef((props) => (\n <Code {...getCodeProps(props)} />\n ));\n\n const language = /language-(\\w+)/.exec(codeProps.className || \"\")?.[1] ?? \"\";\n\n // if the code content is not string (due to rehype plugins), return a default code block\n if (typeof children !== \"string\") {\n return (\n <DefaultCodeBlockContent\n components={{ Pre: WrappedPre, Code: WrappedCode }}\n code={children}\n />\n );\n }\n\n const SyntaxHighlighter: ComponentType<SyntaxHighlighterProps> =\n by_language[language]?.SyntaxHighlighter ?? FallbackSyntaxHighlighter;\n\n const CodeHeader: ComponentType<CodeHeaderProps> =\n by_language[language]?.CodeHeader ?? FallbackCodeHeader;\n\n return (\n <DefaultCodeBlock\n components={{\n Pre: WrappedPre,\n Code: WrappedCode,\n SyntaxHighlighter,\n CodeHeader,\n }}\n language={language || \"unknown\"}\n code={children}\n />\n );\n};\n\nexport type CodeOverrideProps = ComponentPropsWithoutRef<CodeComponent> & {\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n by_language?: Record<\n string,\n {\n CodeHeader?: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n }\n >;\n };\n};\n\nexport const CodeOverride: FC<CodeOverrideProps> = ({\n components,\n ...props\n}) => {\n const preProps = useContext(PreContext);\n if (!preProps) return <components.Code {...(props as any)} />;\n return <CodeBlockOverride components={components} {...props} />;\n};\n","import { ComponentType, FC, useMemo } from \"react\";\n\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultCodeBlockContent } from \"./defaultComponents\";\n\nexport type CodeBlockProps = {\n language: string;\n code: string;\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n };\n};\n\nexport const DefaultCodeBlock: FC<CodeBlockProps> = ({\n components: { Pre, Code, SyntaxHighlighter, CodeHeader },\n language,\n code,\n}) => {\n const components = useMemo(() => ({ Pre, Code }), [Pre, Code]);\n\n const SH = !!language ? SyntaxHighlighter : DefaultCodeBlockContent;\n\n return (\n <>\n <CodeHeader language={language} code={code} />\n <SH\n components={components}\n language={language ?? \"unknown\"}\n code={code}\n />\n </>\n );\n};\n","import classNames from \"classnames\";\n\nexport const withDefaultProps =\n <TProps extends { className?: string | undefined }>({\n className,\n ...defaultProps\n }: Partial<TProps>) =>\n ({ className: classNameProp, ...props }: TProps) => {\n return {\n className: classNames(className, classNameProp),\n ...defaultProps,\n ...props,\n } as TProps;\n };\n","import { TextContentPartProps } from \"@assistant-ui/react\";\nimport { FC, memo } from \"react\";\nimport { CodeHeader } from \"./code-header\";\nimport classNames from \"classnames\";\nimport {\n MarkdownTextPrimitive,\n MarkdownTextPrimitiveProps,\n} from \"../primitives/MarkdownText\";\n\nexport type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;\n\nexport const makeMarkdownText = ({\n className,\n components: userComponents,\n ...rest\n}: MakeMarkdownTextProps = {}) => {\n const components = {\n ...userComponents,\n CodeHeader: userComponents?.CodeHeader ?? CodeHeader,\n };\n\n const MarkdownTextImpl: FC<TextContentPartProps> = ({ status }) => {\n return (\n <div\n className={classNames(\n \"aui-md-root\",\n status.type === \"running\" && \"aui-md-in-progress\",\n className,\n )}\n >\n <MarkdownTextPrimitive components={components} {...rest} />\n </div>\n );\n };\n MarkdownTextImpl.displayName = \"MarkdownText\";\n\n return memo(\n MarkdownTextImpl,\n (prev, next) => prev.status.type === next.status.type,\n );\n};\n","import { FC } from \"react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { useThreadConfig, INTERNAL } from \"@assistant-ui/react\";\n\nimport { CodeHeaderProps } from \"../overrides/types\";\nimport { useCopyToClipboard } from \"./useCopyToClipboard\";\n\nconst { TooltipIconButton } = INTERNAL;\n\nexport const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const {\n strings: {\n code: { header: { copy: { tooltip = \"Copy\" } = {} } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root\">\n <span className=\"aui-code-header-language\">{language}</span>\n <TooltipIconButton tooltip={tooltip} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n","import { useState } from \"react\";\nimport { UseActionBarCopyProps } from \"@assistant-ui/react\";\n\nexport type useCopyToClipboardProps = UseActionBarCopyProps;\n\nexport const useCopyToClipboard = ({\n copiedDuration = 3000,\n}: useCopyToClipboardProps = {}) => {\n const [isCopied, setIsCopied] = useState<boolean>(false);\n\n const copyToClipboard = (value: string) => {\n if (!value) return;\n\n navigator.clipboard.writeText(value).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), copiedDuration);\n });\n };\n\n return { isCopied, copyToClipboard };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAAA,gBAA6C;AAE7C,4BAA4C;;;ACJ5C,mBAAoE;AAa3D;AAVF,IAAM,iBAAa,4BAGhB,IAAI;AAEP,IAAM,yBAAyB,MAAM;AAC1C,aAAO,yBAAW,UAAU,MAAM;AACpC;AAEO,IAAM,cAA4B,CAAC,EAAE,UAAU,GAAG,KAAK,MAAM;AAClE,SAAO,4CAAC,WAAW,UAAX,EAAoB,OAAO,MAAO,UAAS;AACrD;;;ACVE,IAAAC,sBAAA;AADK,IAAM,aAA2B,CAAC,EAAE,MAAM,GAAG,KAAK,MACvD,6CAAC,SAAK,GAAG,MAAM;AAGV,IAAM,cAA6B,CAAC,EAAE,MAAM,GAAG,KAAK,MACzD,6CAAC,UAAM,GAAG,MAAM;AAGX,IAAM,0BAGR,CAAC,EAAE,YAAY,EAAE,KAAK,KAAK,GAAG,KAAK,MACtC,6CAAC,OACC,uDAAC,QAAM,gBAAK,GACd;AAGK,IAAM,oBAAoD,MAAM;;;AFPvE,IAAAC,iCAA+B;;;AGb/B,IAAAC,gBAAwE;;;ACAxE,IAAAC,gBAA2C;AA+BvC,IAAAC,sBAAA;AAVG,IAAM,mBAAuC,CAAC;AAAA,EACnD,YAAY,EAAE,KAAK,MAAM,mBAAmB,YAAAC,YAAW;AAAA,EACvD;AAAA,EACA;AACF,MAAM;AACJ,QAAM,iBAAa,uBAAQ,OAAO,EAAE,KAAK,KAAK,IAAI,C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AAAA,IACH,YAAY,gBAAgB,cAAc;AAAA,EAC5C;AAEA,QAAM,mBAA6C,CAAC,EAAE,OAAO,MAAM;AACjE,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,mBAAAC;AAAA,UACT;AAAA,UACA,OAAO,SAAS,aAAa;AAAA,UAC7B;AAAA,QACF;AAAA,QAEA,uDAAC,yBAAsB,YAAyB,GAAG,MAAM;AAAA;AAAA,IAC3D;AAAA,EAEJ;AACA,mBAAiB,cAAc;AAE/B,aAAO;AAAA,IACL;AAAA,IACA,CAAC,MAAM,SAAS,KAAK,OAAO,SAAS,KAAK,OAAO;AAAA,EACnD;AACF;","names":["import_react","import_jsx_runtime","import_react_use_callback_ref","import_react","import_react","import_jsx_runtime","CodeHeader","classNames","import_jsx_runtime","CodeHeader","import_jsx_runtime","CodeHeader","ReactMarkdown","import_react","import_react","import_react","import_jsx_runtime","import_classnames","import_jsx_runtime","classNames"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/primitives/MarkdownText.tsx","../src/overrides/PreOverride.tsx","../src/overrides/defaultComponents.tsx","../src/overrides/CodeOverride.tsx","../src/overrides/CodeBlock.tsx","../src/overrides/withDefaults.tsx","../src/ui/markdown-text.tsx","../src/ui/code-header.tsx","../src/ui/useCopyToClipboard.tsx"],"sourcesContent":["export {\n MarkdownTextPrimitive,\n type MarkdownTextPrimitiveProps,\n} from \"./primitives/MarkdownText\";\n\nexport type {\n CodeHeaderProps,\n SyntaxHighlighterProps,\n} from \"./overrides/types\";\n\nexport { useIsMarkdownCodeBlock } from \"./overrides/PreOverride\";\n\nexport {\n makeMarkdownText,\n type MakeMarkdownTextProps,\n} from \"./ui/markdown-text\";\n\nexport { CodeHeader } from \"./ui/code-header\";\n","\"use client\";\n\nimport { INTERNAL, useContentPartText } from \"@assistant-ui/react\";\nimport {\n ElementRef,\n ElementType,\n forwardRef,\n ForwardRefExoticComponent,\n RefAttributes,\n type ComponentPropsWithoutRef,\n type ComponentType,\n} from \"react\";\nimport ReactMarkdown, { type Options } from \"react-markdown\";\nimport { SyntaxHighlighterProps, CodeHeaderProps } from \"../overrides/types\";\nimport { PreOverride } from \"../overrides/PreOverride\";\nimport {\n DefaultPre,\n DefaultCode,\n DefaultCodeBlockContent,\n DefaultCodeHeader,\n} from \"../overrides/defaultComponents\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { CodeOverride } from \"../overrides/CodeOverride\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport classNames from \"classnames\";\n\nconst { useSmooth } = INTERNAL;\n\ntype MarkdownTextPrimitiveElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport type MarkdownTextPrimitiveProps = Omit<\n Options,\n \"components\" | \"children\"\n> & {\n containerProps?: Omit<PrimitiveDivProps, \"children\" | \"asChild\">;\n containerComponent?: ElementType;\n components?: NonNullable<Options[\"components\"]> & {\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n CodeHeader?: ComponentType<CodeHeaderProps>;\n by_language?: Record<\n string,\n {\n CodeHeader?: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n }\n >;\n };\n smooth?: boolean;\n};\n\nexport const MarkdownTextPrimitive: ForwardRefExoticComponent<MarkdownTextPrimitiveProps> &\n RefAttributes<MarkdownTextPrimitiveElement> = forwardRef<\n MarkdownTextPrimitiveElement,\n MarkdownTextPrimitiveProps\n>(\n (\n {\n components: userComponents,\n className,\n containerProps,\n containerComponent: Container = \"div\",\n ...rest\n },\n forwardedRef,\n smooth = true,\n ) => {\n const {\n part: { text },\n status,\n } = useSmooth(useContentPartText(), smooth);\n\n const {\n pre = DefaultPre,\n code = DefaultCode,\n SyntaxHighlighter = DefaultCodeBlockContent,\n CodeHeader = DefaultCodeHeader,\n by_language,\n ...componentsRest\n } = userComponents ?? {};\n const components: typeof userComponents = {\n ...componentsRest,\n pre: PreOverride,\n code: useCallbackRef((props) => (\n <CodeOverride\n components={{\n Pre: pre,\n Code: code,\n SyntaxHighlighter,\n CodeHeader,\n by_language,\n }}\n {...props}\n />\n )),\n };\n\n return (\n <Container\n data-status={status.type}\n {...containerProps}\n className={classNames(className, containerProps?.className)}\n ref={forwardedRef}\n >\n <ReactMarkdown components={components} {...rest}>\n {text}\n </ReactMarkdown>\n </Container>\n );\n },\n);\n\nMarkdownTextPrimitive.displayName = \"MarkdownTextPrimitive\";\n","import { createContext, ComponentPropsWithoutRef, useContext } from \"react\";\nimport { PreComponent } from \"./types\";\n\nexport const PreContext = createContext<Omit<\n ComponentPropsWithoutRef<PreComponent>,\n \"children\"\n> | null>(null);\n\nexport const useIsMarkdownCodeBlock = () => {\n return useContext(PreContext) !== null;\n};\n\nexport const PreOverride: PreComponent = ({ children, ...rest }) => {\n return <PreContext.Provider value={rest}>{children}</PreContext.Provider>;\n};\n","import type { ComponentType, ReactNode } from \"react\";\nimport { PreComponent, CodeComponent, CodeHeaderProps } from \"./types\";\n\nexport const DefaultPre: PreComponent = ({ node, ...rest }) => (\n <pre {...rest} />\n);\n\nexport const DefaultCode: CodeComponent = ({ node, ...rest }) => (\n <code {...rest} />\n);\n\nexport const DefaultCodeBlockContent: ComponentType<{\n components: { Pre: PreComponent; Code: CodeComponent };\n code: string | ReactNode | undefined;\n}> = ({ components: { Pre, Code }, code }) => (\n <Pre>\n <Code>{code}</Code>\n </Pre>\n);\n\nexport const DefaultCodeHeader: ComponentType<CodeHeaderProps> = () => null;\n","import { ComponentPropsWithoutRef, ComponentType, FC, useContext } from \"react\";\nimport { PreContext } from \"./PreOverride\";\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultCodeBlock } from \"./CodeBlock\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { withDefaultProps } from \"./withDefaults\";\nimport { DefaultCodeBlockContent } from \"./defaultComponents\";\n\nconst CodeBlockOverride: FC<CodeOverrideProps> = ({\n components: {\n Pre,\n Code,\n SyntaxHighlighter: FallbackSyntaxHighlighter,\n CodeHeader: FallbackCodeHeader,\n by_language = {},\n },\n children,\n ...codeProps\n}) => {\n const preProps = useContext(PreContext)!;\n const getPreProps = withDefaultProps<any>(preProps);\n const WrappedPre: PreComponent = useCallbackRef((props) => (\n <Pre {...getPreProps(props)} />\n ));\n\n const getCodeProps = withDefaultProps<any>(codeProps);\n const WrappedCode: CodeComponent = useCallbackRef((props) => (\n <Code {...getCodeProps(props)} />\n ));\n\n const language = /language-(\\w+)/.exec(codeProps.className || \"\")?.[1] ?? \"\";\n\n // if the code content is not string (due to rehype plugins), return a default code block\n if (typeof children !== \"string\") {\n return (\n <DefaultCodeBlockContent\n components={{ Pre: WrappedPre, Code: WrappedCode }}\n code={children}\n />\n );\n }\n\n const SyntaxHighlighter: ComponentType<SyntaxHighlighterProps> =\n by_language[language]?.SyntaxHighlighter ?? FallbackSyntaxHighlighter;\n\n const CodeHeader: ComponentType<CodeHeaderProps> =\n by_language[language]?.CodeHeader ?? FallbackCodeHeader;\n\n return (\n <DefaultCodeBlock\n components={{\n Pre: WrappedPre,\n Code: WrappedCode,\n SyntaxHighlighter,\n CodeHeader,\n }}\n language={language || \"unknown\"}\n code={children}\n />\n );\n};\n\nexport type CodeOverrideProps = ComponentPropsWithoutRef<CodeComponent> & {\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n by_language?: Record<\n string,\n {\n CodeHeader?: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n }\n >;\n };\n};\n\nexport const CodeOverride: FC<CodeOverrideProps> = ({\n components,\n ...props\n}) => {\n const preProps = useContext(PreContext);\n if (!preProps) return <components.Code {...(props as any)} />;\n return <CodeBlockOverride components={components} {...props} />;\n};\n","import { ComponentType, FC, useMemo } from \"react\";\n\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultCodeBlockContent } from \"./defaultComponents\";\n\nexport type CodeBlockProps = {\n language: string;\n code: string;\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n };\n};\n\nexport const DefaultCodeBlock: FC<CodeBlockProps> = ({\n components: { Pre, Code, SyntaxHighlighter, CodeHeader },\n language,\n code,\n}) => {\n const components = useMemo(() => ({ Pre, Code }), [Pre, Code]);\n\n const SH = !!language ? SyntaxHighlighter : DefaultCodeBlockContent;\n\n return (\n <>\n <CodeHeader language={language} code={code} />\n <SH\n components={components}\n language={language ?? \"unknown\"}\n code={code}\n />\n </>\n );\n};\n","import classNames from \"classnames\";\n\nexport const withDefaultProps =\n <TProps extends { className?: string | undefined }>({\n className,\n ...defaultProps\n }: Partial<TProps>) =>\n ({ className: classNameProp, ...props }: TProps) => {\n return {\n className: classNames(className, classNameProp),\n ...defaultProps,\n ...props,\n } as TProps;\n };\n","import { FC, memo } from \"react\";\nimport { CodeHeader } from \"./code-header\";\nimport classNames from \"classnames\";\nimport {\n MarkdownTextPrimitive,\n MarkdownTextPrimitiveProps,\n} from \"../primitives/MarkdownText\";\nimport { INTERNAL } from \"@assistant-ui/react\";\n\nconst { withSmoothContextProvider, useSmoothStatus } = INTERNAL;\n\nexport type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;\n\nexport const makeMarkdownText = ({\n className,\n components: userComponents,\n ...rest\n}: MakeMarkdownTextProps = {}) => {\n const components = {\n ...userComponents,\n CodeHeader: userComponents?.CodeHeader ?? CodeHeader,\n };\n\n const MarkdownTextImpl: FC = () => {\n const status = useSmoothStatus();\n return (\n <MarkdownTextPrimitive\n components={components}\n {...rest}\n className={classNames(\n \"aui-md-root\",\n status.type === \"running\" && \"aui-md-running\",\n className,\n )}\n />\n );\n };\n MarkdownTextImpl.displayName = \"MarkdownText\";\n\n return memo(withSmoothContextProvider(MarkdownTextImpl), () => true);\n};\n","import { FC } from \"react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { INTERNAL, useThreadConfig } from \"@assistant-ui/react\";\n\nimport { CodeHeaderProps } from \"../overrides/types\";\nimport { useCopyToClipboard } from \"./useCopyToClipboard\";\n\nconst { TooltipIconButton } = INTERNAL;\n\nexport const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const {\n strings: {\n code: { header: { copy: { tooltip = \"Copy\" } = {} } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root\">\n <span className=\"aui-code-header-language\">{language}</span>\n <TooltipIconButton tooltip={tooltip} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n","import { useState } from \"react\";\nimport { UseActionBarCopyProps } from \"@assistant-ui/react\";\n\nexport type useCopyToClipboardProps = UseActionBarCopyProps;\n\nexport const useCopyToClipboard = ({\n copiedDuration = 3000,\n}: useCopyToClipboardProps = {}) => {\n const [isCopied, setIsCopied] = useState<boolean>(false);\n\n const copyToClipboard = (value: string) => {\n if (!value) return;\n\n navigator.clipboard.writeText(value).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), copiedDuration);\n });\n };\n\n return { isCopied, copyToClipboard };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAAA,gBAA6C;AAC7C,IAAAA,gBAQO;AACP,4BAA4C;;;ACZ5C,mBAAoE;AAa3D;AAVF,IAAM,iBAAa,4BAGhB,IAAI;AAEP,IAAM,yBAAyB,MAAM;AAC1C,aAAO,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A,QACJ,eAAW,mBAAAC;AAAA,UACT;AAAA,UACA,OAAO,SAAS,aAAa;AAAA,UAC7B;AAAA,QACF;AAAA;AAAA,IACF;AAAA,EAEJ;AACA,mBAAiB,cAAc;AAE/B,aAAO,oBAAK,0BAA0B,gBAAgB,GAAG,MAAM,IAAI;AACrE;","names":["import_react","import_jsx_runtime","import_react_use_callback_ref","import_react","import_react","import_jsx_runtime","CodeHeader","classNames","import_jsx_runtime","CodeHeader","import_classnames","import_jsx_runtime","CodeHeader","classNames","ReactMarkdown","import_react","import_react","import_react","import_jsx_runtime","import_classnames","import_react","import_jsx_runtime","classNames"]}
package/dist/index.mjs CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  // src/primitives/MarkdownText.tsx
4
4
  import { INTERNAL, useContentPartText } from "@assistant-ui/react";
5
+ import {
6
+ forwardRef
7
+ } from "react";
5
8
  import ReactMarkdown from "react-markdown";
6
9
 
7
10
  // src/overrides/PreOverride.tsx
@@ -121,51 +124,66 @@ var CodeOverride = ({
121
124
  };
122
125
 
123
126
  // src/primitives/MarkdownText.tsx
127
+ import classNames2 from "classnames";
124
128
  import { jsx as jsx5 } from "react/jsx-runtime";
125
129
  var { useSmooth } = INTERNAL;
126
- var MarkdownTextPrimitive = ({
127
- smooth = true,
128
- components: userComponents,
129
- ...rest
130
- }) => {
131
- const {
132
- part: { text }
133
- } = useContentPartText();
134
- const smoothText = useSmooth(text, smooth);
135
- const {
136
- pre = DefaultPre,
137
- code = DefaultCode,
138
- SyntaxHighlighter = DefaultCodeBlockContent,
139
- CodeHeader: CodeHeader2 = DefaultCodeHeader,
140
- by_language,
141
- ...componentsRest
142
- } = userComponents ?? {};
143
- const components = {
144
- ...componentsRest,
145
- pre: PreOverride,
146
- code: useCallbackRef2((props) => /* @__PURE__ */ jsx5(
147
- CodeOverride,
130
+ var MarkdownTextPrimitive = forwardRef(
131
+ ({
132
+ components: userComponents,
133
+ className,
134
+ containerProps,
135
+ containerComponent: Container = "div",
136
+ ...rest
137
+ }, forwardedRef, smooth = true) => {
138
+ const {
139
+ part: { text },
140
+ status
141
+ } = useSmooth(useContentPartText(), smooth);
142
+ const {
143
+ pre = DefaultPre,
144
+ code = DefaultCode,
145
+ SyntaxHighlighter = DefaultCodeBlockContent,
146
+ CodeHeader: CodeHeader2 = DefaultCodeHeader,
147
+ by_language,
148
+ ...componentsRest
149
+ } = userComponents ?? {};
150
+ const components = {
151
+ ...componentsRest,
152
+ pre: PreOverride,
153
+ code: useCallbackRef2((props) => /* @__PURE__ */ jsx5(
154
+ CodeOverride,
155
+ {
156
+ components: {
157
+ Pre: pre,
158
+ Code: code,
159
+ SyntaxHighlighter,
160
+ CodeHeader: CodeHeader2,
161
+ by_language
162
+ },
163
+ ...props
164
+ }
165
+ ))
166
+ };
167
+ return /* @__PURE__ */ jsx5(
168
+ Container,
148
169
  {
149
- components: {
150
- Pre: pre,
151
- Code: code,
152
- SyntaxHighlighter,
153
- CodeHeader: CodeHeader2,
154
- by_language
155
- },
156
- ...props
170
+ "data-status": status.type,
171
+ ...containerProps,
172
+ className: classNames2(className, containerProps?.className),
173
+ ref: forwardedRef,
174
+ children: /* @__PURE__ */ jsx5(ReactMarkdown, { components, ...rest, children: text })
157
175
  }
158
- ))
159
- };
160
- return /* @__PURE__ */ jsx5(ReactMarkdown, { components, ...rest, children: smoothText });
161
- };
176
+ );
177
+ }
178
+ );
179
+ MarkdownTextPrimitive.displayName = "MarkdownTextPrimitive";
162
180
 
163
181
  // src/ui/markdown-text.tsx
164
182
  import { memo } from "react";
165
183
 
166
184
  // src/ui/code-header.tsx
167
185
  import { CheckIcon, CopyIcon } from "lucide-react";
168
- import { useThreadConfig, INTERNAL as INTERNAL2 } from "@assistant-ui/react";
186
+ import { INTERNAL as INTERNAL2, useThreadConfig } from "@assistant-ui/react";
169
187
 
170
188
  // src/ui/useCopyToClipboard.tsx
171
189
  import { useState } from "react";
@@ -207,8 +225,10 @@ var CodeHeader = ({ language, code }) => {
207
225
  };
208
226
 
209
227
  // src/ui/markdown-text.tsx
210
- import classNames2 from "classnames";
228
+ import classNames3 from "classnames";
229
+ import { INTERNAL as INTERNAL3 } from "@assistant-ui/react";
211
230
  import { jsx as jsx7 } from "react/jsx-runtime";
231
+ var { withSmoothContextProvider, useSmoothStatus } = INTERNAL3;
212
232
  var makeMarkdownText = ({
213
233
  className,
214
234
  components: userComponents,
@@ -218,24 +238,23 @@ var makeMarkdownText = ({
218
238
  ...userComponents,
219
239
  CodeHeader: userComponents?.CodeHeader ?? CodeHeader
220
240
  };
221
- const MarkdownTextImpl = ({ status }) => {
241
+ const MarkdownTextImpl = () => {
242
+ const status = useSmoothStatus();
222
243
  return /* @__PURE__ */ jsx7(
223
- "div",
244
+ MarkdownTextPrimitive,
224
245
  {
225
- className: classNames2(
246
+ components,
247
+ ...rest,
248
+ className: classNames3(
226
249
  "aui-md-root",
227
- status.type === "running" && "aui-md-in-progress",
250
+ status.type === "running" && "aui-md-running",
228
251
  className
229
- ),
230
- children: /* @__PURE__ */ jsx7(MarkdownTextPrimitive, { components, ...rest })
252
+ )
231
253
  }
232
254
  );
233
255
  };
234
256
  MarkdownTextImpl.displayName = "MarkdownText";
235
- return memo(
236
- MarkdownTextImpl,
237
- (prev, next) => prev.status.type === next.status.type
238
- );
257
+ return memo(withSmoothContextProvider(MarkdownTextImpl), () => true);
239
258
  };
240
259
  export {
241
260
  CodeHeader,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/primitives/MarkdownText.tsx","../src/overrides/PreOverride.tsx","../src/overrides/defaultComponents.tsx","../src/overrides/CodeOverride.tsx","../src/overrides/CodeBlock.tsx","../src/overrides/withDefaults.tsx","../src/ui/markdown-text.tsx","../src/ui/code-header.tsx","../src/ui/useCopyToClipboard.tsx"],"sourcesContent":["\"use client\";\n\nimport { INTERNAL, useContentPartText } from \"@assistant-ui/react\";\nimport type { ComponentType, FC } from \"react\";\nimport ReactMarkdown, { type Options } from \"react-markdown\";\nimport { SyntaxHighlighterProps, CodeHeaderProps } from \"../overrides/types\";\nimport { PreOverride } from \"../overrides/PreOverride\";\nimport {\n DefaultPre,\n DefaultCode,\n DefaultCodeBlockContent,\n DefaultCodeHeader,\n} from \"../overrides/defaultComponents\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { CodeOverride } from \"../overrides/CodeOverride\";\n\nconst { useSmooth } = INTERNAL;\n\nexport type MarkdownTextPrimitiveProps = Omit<\n Options,\n \"components\" | \"children\"\n> & {\n components?: NonNullable<Options[\"components\"]> & {\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n CodeHeader?: ComponentType<CodeHeaderProps>;\n by_language?: Record<\n string,\n {\n CodeHeader?: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n }\n >;\n };\n smooth?: boolean;\n};\nexport const MarkdownTextPrimitive: FC<MarkdownTextPrimitiveProps> = ({\n smooth = true,\n components: userComponents,\n ...rest\n}) => {\n const {\n part: { text },\n } = useContentPartText();\n const smoothText = useSmooth(text, smooth); // TODO loading indicator disappears before smooth animation ends\n\n const {\n pre = DefaultPre,\n code = DefaultCode,\n SyntaxHighlighter = DefaultCodeBlockContent,\n CodeHeader = DefaultCodeHeader,\n by_language,\n ...componentsRest\n } = userComponents ?? {};\n const components: typeof userComponents = {\n ...componentsRest,\n pre: PreOverride,\n code: useCallbackRef((props) => (\n <CodeOverride\n components={{\n Pre: pre,\n Code: code,\n SyntaxHighlighter,\n CodeHeader,\n by_language,\n }}\n {...props}\n />\n )),\n };\n\n return (\n <ReactMarkdown components={components} {...rest}>\n {smoothText}\n </ReactMarkdown>\n );\n};\n","import { createContext, ComponentPropsWithoutRef, useContext } from \"react\";\nimport { PreComponent } from \"./types\";\n\nexport const PreContext = createContext<Omit<\n ComponentPropsWithoutRef<PreComponent>,\n \"children\"\n> | null>(null);\n\nexport const useIsMarkdownCodeBlock = () => {\n return useContext(PreContext) !== null;\n};\n\nexport const PreOverride: PreComponent = ({ children, ...rest }) => {\n return <PreContext.Provider value={rest}>{children}</PreContext.Provider>;\n};\n","import type { ComponentType, ReactNode } from \"react\";\nimport { PreComponent, CodeComponent, CodeHeaderProps } from \"./types\";\n\nexport const DefaultPre: PreComponent = ({ node, ...rest }) => (\n <pre {...rest} />\n);\n\nexport const DefaultCode: CodeComponent = ({ node, ...rest }) => (\n <code {...rest} />\n);\n\nexport const DefaultCodeBlockContent: ComponentType<{\n components: { Pre: PreComponent; Code: CodeComponent };\n code: string | ReactNode | undefined;\n}> = ({ components: { Pre, Code }, code }) => (\n <Pre>\n <Code>{code}</Code>\n </Pre>\n);\n\nexport const DefaultCodeHeader: ComponentType<CodeHeaderProps> = () => null;\n","import { ComponentPropsWithoutRef, ComponentType, FC, useContext } from \"react\";\nimport { PreContext } from \"./PreOverride\";\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultCodeBlock } from \"./CodeBlock\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { withDefaultProps } from \"./withDefaults\";\nimport { DefaultCodeBlockContent } from \"./defaultComponents\";\n\nconst CodeBlockOverride: FC<CodeOverrideProps> = ({\n components: {\n Pre,\n Code,\n SyntaxHighlighter: FallbackSyntaxHighlighter,\n CodeHeader: FallbackCodeHeader,\n by_language = {},\n },\n children,\n ...codeProps\n}) => {\n const preProps = useContext(PreContext)!;\n const getPreProps = withDefaultProps<any>(preProps);\n const WrappedPre: PreComponent = useCallbackRef((props) => (\n <Pre {...getPreProps(props)} />\n ));\n\n const getCodeProps = withDefaultProps<any>(codeProps);\n const WrappedCode: CodeComponent = useCallbackRef((props) => (\n <Code {...getCodeProps(props)} />\n ));\n\n const language = /language-(\\w+)/.exec(codeProps.className || \"\")?.[1] ?? \"\";\n\n // if the code content is not string (due to rehype plugins), return a default code block\n if (typeof children !== \"string\") {\n return (\n <DefaultCodeBlockContent\n components={{ Pre: WrappedPre, Code: WrappedCode }}\n code={children}\n />\n );\n }\n\n const SyntaxHighlighter: ComponentType<SyntaxHighlighterProps> =\n by_language[language]?.SyntaxHighlighter ?? FallbackSyntaxHighlighter;\n\n const CodeHeader: ComponentType<CodeHeaderProps> =\n by_language[language]?.CodeHeader ?? FallbackCodeHeader;\n\n return (\n <DefaultCodeBlock\n components={{\n Pre: WrappedPre,\n Code: WrappedCode,\n SyntaxHighlighter,\n CodeHeader,\n }}\n language={language || \"unknown\"}\n code={children}\n />\n );\n};\n\nexport type CodeOverrideProps = ComponentPropsWithoutRef<CodeComponent> & {\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n by_language?: Record<\n string,\n {\n CodeHeader?: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n }\n >;\n };\n};\n\nexport const CodeOverride: FC<CodeOverrideProps> = ({\n components,\n ...props\n}) => {\n const preProps = useContext(PreContext);\n if (!preProps) return <components.Code {...(props as any)} />;\n return <CodeBlockOverride components={components} {...props} />;\n};\n","import { ComponentType, FC, useMemo } from \"react\";\n\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultCodeBlockContent } from \"./defaultComponents\";\n\nexport type CodeBlockProps = {\n language: string;\n code: string;\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n };\n};\n\nexport const DefaultCodeBlock: FC<CodeBlockProps> = ({\n components: { Pre, Code, SyntaxHighlighter, CodeHeader },\n language,\n code,\n}) => {\n const components = useMemo(() => ({ Pre, Code }), [Pre, Code]);\n\n const SH = !!language ? SyntaxHighlighter : DefaultCodeBlockContent;\n\n return (\n <>\n <CodeHeader language={language} code={code} />\n <SH\n components={components}\n language={language ?? \"unknown\"}\n code={code}\n />\n </>\n );\n};\n","import classNames from \"classnames\";\n\nexport const withDefaultProps =\n <TProps extends { className?: string | undefined }>({\n className,\n ...defaultProps\n }: Partial<TProps>) =>\n ({ className: classNameProp, ...props }: TProps) => {\n return {\n className: classNames(className, classNameProp),\n ...defaultProps,\n ...props,\n } as TProps;\n };\n","import { TextContentPartProps } from \"@assistant-ui/react\";\nimport { FC, memo } from \"react\";\nimport { CodeHeader } from \"./code-header\";\nimport classNames from \"classnames\";\nimport {\n MarkdownTextPrimitive,\n MarkdownTextPrimitiveProps,\n} from \"../primitives/MarkdownText\";\n\nexport type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;\n\nexport const makeMarkdownText = ({\n className,\n components: userComponents,\n ...rest\n}: MakeMarkdownTextProps = {}) => {\n const components = {\n ...userComponents,\n CodeHeader: userComponents?.CodeHeader ?? CodeHeader,\n };\n\n const MarkdownTextImpl: FC<TextContentPartProps> = ({ status }) => {\n return (\n <div\n className={classNames(\n \"aui-md-root\",\n status.type === \"running\" && \"aui-md-in-progress\",\n className,\n )}\n >\n <MarkdownTextPrimitive components={components} {...rest} />\n </div>\n );\n };\n MarkdownTextImpl.displayName = \"MarkdownText\";\n\n return memo(\n MarkdownTextImpl,\n (prev, next) => prev.status.type === next.status.type,\n );\n};\n","import { FC } from \"react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { useThreadConfig, INTERNAL } from \"@assistant-ui/react\";\n\nimport { CodeHeaderProps } from \"../overrides/types\";\nimport { useCopyToClipboard } from \"./useCopyToClipboard\";\n\nconst { TooltipIconButton } = INTERNAL;\n\nexport const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const {\n strings: {\n code: { header: { copy: { tooltip = \"Copy\" } = {} } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root\">\n <span className=\"aui-code-header-language\">{language}</span>\n <TooltipIconButton tooltip={tooltip} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n","import { useState } from \"react\";\nimport { UseActionBarCopyProps } from \"@assistant-ui/react\";\n\nexport type useCopyToClipboardProps = UseActionBarCopyProps;\n\nexport const useCopyToClipboard = ({\n copiedDuration = 3000,\n}: useCopyToClipboardProps = {}) => {\n const [isCopied, setIsCopied] = useState<boolean>(false);\n\n const copyToClipboard = (value: string) => {\n if (!value) return;\n\n navigator.clipboard.writeText(value).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), copiedDuration);\n });\n };\n\n return { isCopied, copyToClipboard };\n};\n"],"mappings":";;;AAEA,SAAS,UAAU,0BAA0B;AAE7C,OAAO,mBAAqC;;;ACJ5C,SAAS,eAAyC,kBAAkB;AAa3D;AAVF,IAAM,aAAa,cAGhB,IAAI;AAEP,IAAM,yBAAyB,MAAM;AAC1C,SAAO,WAAW,UAAU,MAAM;AACpC;AAEO,IAAM,cAA4B,CAAC,EAAE,UAAU,GAAG,KAAK,MAAM;AAClE,SAAO,oBAAC,WAAW,UAAX,EAAoB,OAAO,MAAO,UAAS;AACrD;;;ACVE,gBAAAA,YAAA;AADK,IAAM,aAA2B,CAAC,EAAE,MAAM,GAAG,KAAK,MACvD,gBAAAA,KAAC,SAAK,GAAG,MAAM;AAGV,IAAM,cAA6B,CAAC,EAAE,MAAM,GAAG,KAAK,MACzD,gBAAAA,KAAC,UAAM,GAAG,MAAM;AAGX,IAAM,0BAGR,CAAC,EAAE,YAAY,EAAE,KAAK,KAAK,GAAG,KAAK,MACtC,gBAAAA,KAAC,OACC,0BAAAA,KAAC,QAAM,gBAAK,GACd;AAGK,IAAM,oBAAoD,MAAM;;;AFPvE,SAAS,kBAAAC,uBAAsB;;;AGb/B,SAAsD,cAAAC,mBAAkB;;;ACAxE,SAA4B,eAAe;AA+BvC,mBACE,OAAAC,MADF;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AS,QAC3C;AAAA,OAAC,YAAY,gBAAAD,KAAC,YAAS;AAAA,MACvB,YAAY,gBAAAA,KAAC,aAAU;AAAA,OAC1B;AAAA,KACF;AAEJ;;;AD5BA,OAAOG,iBAAgB;AA2Bf,gBAAAC,YAAA;AAnBD,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,IAA2B,CAAC,MAAM;AAChC,QAAM,aAAa;AAAA,IACjB,GAAG;AAAA,IACH,YAAY,gBAAgB,cAAc;AAAA,EAC5C;AAEA,QAAM,mBAA6C,CAAC,EAAE,OAAO,MAAM;AACjE,WACE,gBAAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAWC;AAAA,UACT;AAAA,UACA,OAAO,SAAS,aAAa;AAAA,UAC7B;AAAA,QACF;AAAA,QAEA,0BAAAD,KAAC,yBAAsB,YAAyB,GAAG,MAAM;AAAA;AAAA,IAC3D;AAAA,EAEJ;AACA,mBAAiB,cAAc;AAE/B,SAAO;AAAA,IACL;AAAA,IACA,CAAC,MAAM,SAAS,KAAK,OAAO,SAAS,KAAK,OAAO;AAAA,EACnD;AACF;","names":["jsx","useCallbackRef","useContext","jsx","CodeHeader","jsx","useContext","CodeHeader","jsx","CodeHeader","useCallbackRef","INTERNAL","jsx","jsxs","INTERNAL","classNames","jsx","classNames"]}
1
+ {"version":3,"sources":["../src/primitives/MarkdownText.tsx","../src/overrides/PreOverride.tsx","../src/overrides/defaultComponents.tsx","../src/overrides/CodeOverride.tsx","../src/overrides/CodeBlock.tsx","../src/overrides/withDefaults.tsx","../src/ui/markdown-text.tsx","../src/ui/code-header.tsx","../src/ui/useCopyToClipboard.tsx"],"sourcesContent":["\"use client\";\n\nimport { INTERNAL, useContentPartText } from \"@assistant-ui/react\";\nimport {\n ElementRef,\n ElementType,\n forwardRef,\n ForwardRefExoticComponent,\n RefAttributes,\n type ComponentPropsWithoutRef,\n type ComponentType,\n} from \"react\";\nimport ReactMarkdown, { type Options } from \"react-markdown\";\nimport { SyntaxHighlighterProps, CodeHeaderProps } from \"../overrides/types\";\nimport { PreOverride } from \"../overrides/PreOverride\";\nimport {\n DefaultPre,\n DefaultCode,\n DefaultCodeBlockContent,\n DefaultCodeHeader,\n} from \"../overrides/defaultComponents\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { CodeOverride } from \"../overrides/CodeOverride\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport classNames from \"classnames\";\n\nconst { useSmooth } = INTERNAL;\n\ntype MarkdownTextPrimitiveElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport type MarkdownTextPrimitiveProps = Omit<\n Options,\n \"components\" | \"children\"\n> & {\n containerProps?: Omit<PrimitiveDivProps, \"children\" | \"asChild\">;\n containerComponent?: ElementType;\n components?: NonNullable<Options[\"components\"]> & {\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n CodeHeader?: ComponentType<CodeHeaderProps>;\n by_language?: Record<\n string,\n {\n CodeHeader?: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n }\n >;\n };\n smooth?: boolean;\n};\n\nexport const MarkdownTextPrimitive: ForwardRefExoticComponent<MarkdownTextPrimitiveProps> &\n RefAttributes<MarkdownTextPrimitiveElement> = forwardRef<\n MarkdownTextPrimitiveElement,\n MarkdownTextPrimitiveProps\n>(\n (\n {\n components: userComponents,\n className,\n containerProps,\n containerComponent: Container = \"div\",\n ...rest\n },\n forwardedRef,\n smooth = true,\n ) => {\n const {\n part: { text },\n status,\n } = useSmooth(useContentPartText(), smooth);\n\n const {\n pre = DefaultPre,\n code = DefaultCode,\n SyntaxHighlighter = DefaultCodeBlockContent,\n CodeHeader = DefaultCodeHeader,\n by_language,\n ...componentsRest\n } = userComponents ?? {};\n const components: typeof userComponents = {\n ...componentsRest,\n pre: PreOverride,\n code: useCallbackRef((props) => (\n <CodeOverride\n components={{\n Pre: pre,\n Code: code,\n SyntaxHighlighter,\n CodeHeader,\n by_language,\n }}\n {...props}\n />\n )),\n };\n\n return (\n <Container\n data-status={status.type}\n {...containerProps}\n className={classNames(className, containerProps?.className)}\n ref={forwardedRef}\n >\n <ReactMarkdown components={components} {...rest}>\n {text}\n </ReactMarkdown>\n </Container>\n );\n },\n);\n\nMarkdownTextPrimitive.displayName = \"MarkdownTextPrimitive\";\n","import { createContext, ComponentPropsWithoutRef, useContext } from \"react\";\nimport { PreComponent } from \"./types\";\n\nexport const PreContext = createContext<Omit<\n ComponentPropsWithoutRef<PreComponent>,\n \"children\"\n> | null>(null);\n\nexport const useIsMarkdownCodeBlock = () => {\n return useContext(PreContext) !== null;\n};\n\nexport const PreOverride: PreComponent = ({ children, ...rest }) => {\n return <PreContext.Provider value={rest}>{children}</PreContext.Provider>;\n};\n","import type { ComponentType, ReactNode } from \"react\";\nimport { PreComponent, CodeComponent, CodeHeaderProps } from \"./types\";\n\nexport const DefaultPre: PreComponent = ({ node, ...rest }) => (\n <pre {...rest} />\n);\n\nexport const DefaultCode: CodeComponent = ({ node, ...rest }) => (\n <code {...rest} />\n);\n\nexport const DefaultCodeBlockContent: ComponentType<{\n components: { Pre: PreComponent; Code: CodeComponent };\n code: string | ReactNode | undefined;\n}> = ({ components: { Pre, Code }, code }) => (\n <Pre>\n <Code>{code}</Code>\n </Pre>\n);\n\nexport const DefaultCodeHeader: ComponentType<CodeHeaderProps> = () => null;\n","import { ComponentPropsWithoutRef, ComponentType, FC, useContext } from \"react\";\nimport { PreContext } from \"./PreOverride\";\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultCodeBlock } from \"./CodeBlock\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { withDefaultProps } from \"./withDefaults\";\nimport { DefaultCodeBlockContent } from \"./defaultComponents\";\n\nconst CodeBlockOverride: FC<CodeOverrideProps> = ({\n components: {\n Pre,\n Code,\n SyntaxHighlighter: FallbackSyntaxHighlighter,\n CodeHeader: FallbackCodeHeader,\n by_language = {},\n },\n children,\n ...codeProps\n}) => {\n const preProps = useContext(PreContext)!;\n const getPreProps = withDefaultProps<any>(preProps);\n const WrappedPre: PreComponent = useCallbackRef((props) => (\n <Pre {...getPreProps(props)} />\n ));\n\n const getCodeProps = withDefaultProps<any>(codeProps);\n const WrappedCode: CodeComponent = useCallbackRef((props) => (\n <Code {...getCodeProps(props)} />\n ));\n\n const language = /language-(\\w+)/.exec(codeProps.className || \"\")?.[1] ?? \"\";\n\n // if the code content is not string (due to rehype plugins), return a default code block\n if (typeof children !== \"string\") {\n return (\n <DefaultCodeBlockContent\n components={{ Pre: WrappedPre, Code: WrappedCode }}\n code={children}\n />\n );\n }\n\n const SyntaxHighlighter: ComponentType<SyntaxHighlighterProps> =\n by_language[language]?.SyntaxHighlighter ?? FallbackSyntaxHighlighter;\n\n const CodeHeader: ComponentType<CodeHeaderProps> =\n by_language[language]?.CodeHeader ?? FallbackCodeHeader;\n\n return (\n <DefaultCodeBlock\n components={{\n Pre: WrappedPre,\n Code: WrappedCode,\n SyntaxHighlighter,\n CodeHeader,\n }}\n language={language || \"unknown\"}\n code={children}\n />\n );\n};\n\nexport type CodeOverrideProps = ComponentPropsWithoutRef<CodeComponent> & {\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n by_language?: Record<\n string,\n {\n CodeHeader?: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n }\n >;\n };\n};\n\nexport const CodeOverride: FC<CodeOverrideProps> = ({\n components,\n ...props\n}) => {\n const preProps = useContext(PreContext);\n if (!preProps) return <components.Code {...(props as any)} />;\n return <CodeBlockOverride components={components} {...props} />;\n};\n","import { ComponentType, FC, useMemo } from \"react\";\n\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultCodeBlockContent } from \"./defaultComponents\";\n\nexport type CodeBlockProps = {\n language: string;\n code: string;\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n };\n};\n\nexport const DefaultCodeBlock: FC<CodeBlockProps> = ({\n components: { Pre, Code, SyntaxHighlighter, CodeHeader },\n language,\n code,\n}) => {\n const components = useMemo(() => ({ Pre, Code }), [Pre, Code]);\n\n const SH = !!language ? SyntaxHighlighter : DefaultCodeBlockContent;\n\n return (\n <>\n <CodeHeader language={language} code={code} />\n <SH\n components={components}\n language={language ?? \"unknown\"}\n code={code}\n />\n </>\n );\n};\n","import classNames from \"classnames\";\n\nexport const withDefaultProps =\n <TProps extends { className?: string | undefined }>({\n className,\n ...defaultProps\n }: Partial<TProps>) =>\n ({ className: classNameProp, ...props }: TProps) => {\n return {\n className: classNames(className, classNameProp),\n ...defaultProps,\n ...props,\n } as TProps;\n };\n","import { FC, memo } from \"react\";\nimport { CodeHeader } from \"./code-header\";\nimport classNames from \"classnames\";\nimport {\n MarkdownTextPrimitive,\n MarkdownTextPrimitiveProps,\n} from \"../primitives/MarkdownText\";\nimport { INTERNAL } from \"@assistant-ui/react\";\n\nconst { withSmoothContextProvider, useSmoothStatus } = INTERNAL;\n\nexport type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;\n\nexport const makeMarkdownText = ({\n className,\n components: userComponents,\n ...rest\n}: MakeMarkdownTextProps = {}) => {\n const components = {\n ...userComponents,\n CodeHeader: userComponents?.CodeHeader ?? CodeHeader,\n };\n\n const MarkdownTextImpl: FC = () => {\n const status = useSmoothStatus();\n return (\n <MarkdownTextPrimitive\n components={components}\n {...rest}\n className={classNames(\n \"aui-md-root\",\n status.type === \"running\" && \"aui-md-running\",\n className,\n )}\n />\n );\n };\n MarkdownTextImpl.displayName = \"MarkdownText\";\n\n return memo(withSmoothContextProvider(MarkdownTextImpl), () => true);\n};\n","import { FC } from \"react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { INTERNAL, useThreadConfig } from \"@assistant-ui/react\";\n\nimport { CodeHeaderProps } from \"../overrides/types\";\nimport { useCopyToClipboard } from \"./useCopyToClipboard\";\n\nconst { TooltipIconButton } = INTERNAL;\n\nexport const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const {\n strings: {\n code: { header: { copy: { tooltip = \"Copy\" } = {} } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root\">\n <span className=\"aui-code-header-language\">{language}</span>\n <TooltipIconButton tooltip={tooltip} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n","import { useState } from \"react\";\nimport { UseActionBarCopyProps } from \"@assistant-ui/react\";\n\nexport type useCopyToClipboardProps = UseActionBarCopyProps;\n\nexport const useCopyToClipboard = ({\n copiedDuration = 3000,\n}: useCopyToClipboardProps = {}) => {\n const [isCopied, setIsCopied] = useState<boolean>(false);\n\n const copyToClipboard = (value: string) => {\n if (!value) return;\n\n navigator.clipboard.writeText(value).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), copiedDuration);\n });\n };\n\n return { isCopied, copyToClipboard };\n};\n"],"mappings":";;;AAEA,SAAS,UAAU,0BAA0B;AAC7C;AAAA,EAGE;AAAA,OAKK;AACP,OAAO,mBAAqC;;;ACZ5C,SAAS,eAAyC,kBAAkB;AAa3D;AAVF,IAAM,aAAa,cAGhB,IAAI;AAEP,IAAM,yBAAyB,MAAM;AAC1C,SAAO,WAAW,UAAU,MAAM;AACpC;AAEO,IAAM,cAA4B,CAAC,EAAE,UAAU,GAAG,KA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M,mBAAuB,MAAM;AACjC,UAAM,SAAS,gBAAgB;AAC/B,WACE,gBAAAC;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACC,GAAG;AAAA,QACJ,WAAWC;AAAA,UACT;AAAA,UACA,OAAO,SAAS,aAAa;AAAA,UAC7B;AAAA,QACF;AAAA;AAAA,IACF;AAAA,EAEJ;AACA,mBAAiB,cAAc;AAE/B,SAAO,KAAK,0BAA0B,gBAAgB,GAAG,MAAM,IAAI;AACrE;","names":["jsx","useCallbackRef","useContext","jsx","CodeHeader","jsx","useContext","CodeHeader","classNames","jsx","CodeHeader","useCallbackRef","INTERNAL","jsx","jsxs","INTERNAL","classNames","INTERNAL","jsx","classNames"]}
@@ -4,12 +4,12 @@
4
4
  opacity: .5;
5
5
  }
6
6
  }
7
- :where(.aui-md-in-progress:empty)::after,
8
- :where(.aui-md-in-progress > :not(ol):not(ul):not(pre):last-child)::after,
9
- :where(.aui-md-in-progress > pre:last-child code)::after,
10
- :where(.aui-md-in-progress > :is(ol, ul):last-child > li:last-child:not(:has(* > li)))::after,
11
- :where(.aui-md-in-progress > :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child:not(:has(* > li)))::after,
12
- :where(.aui-md-in-progress > :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child)::after {
7
+ :where(.aui-md-running):empty::after,
8
+ :where(.aui-md-running) > :where(:not(ol):not(ul):not(pre)):last-child::after,
9
+ :where(.aui-md-running) > pre:last-child code::after,
10
+ :where(.aui-md-running) > :where(:is(ol, ul):last-child) > :where(li:last-child:not(:has(* > li)))::after,
11
+ :where(.aui-md-running) > :where(:is(ol, ul):last-child) > :where(li:last-child) > :where(:is(ol, ul):last-child) > :where(li:last-child:not(:has(* > li)))::after,
12
+ :where(.aui-md-running) > :where(:is(ol, ul):last-child) > :where(li:last-child) > :where(:is(ol, ul):last-child) > :where(li:last-child) > :where(:is(ol, ul):last-child) > :where(li:last-child)::after {
13
13
  animation: aui-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
14
14
  font-family:
15
15
  ui-sans-serif,
@@ -22,23 +22,23 @@
22
22
  --aui-content: "\25cf";
23
23
  content: var(--aui-content);
24
24
  }
25
- :where(.aui-md-in-progress:empty):where([dir=ltr], [dir=ltr] *)::after,
26
- :where(.aui-md-in-progress > :not(ol):not(ul):not(pre):last-child):where([dir=ltr], [dir=ltr] *)::after,
27
- :where(.aui-md-in-progress > pre:last-child code):where([dir=ltr], [dir=ltr] *)::after,
28
- :where(.aui-md-in-progress > :is(ol, ul):last-child > li:last-child:not(:has(* > li))):where([dir=ltr], [dir=ltr] *)::after,
29
- :where(.aui-md-in-progress > :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child:not(:has(* > li))):where([dir=ltr], [dir=ltr] *)::after,
30
- :where(.aui-md-in-progress > :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child):where([dir=ltr], [dir=ltr] *)::after {
25
+ :where(.aui-md-running):empty:where([dir=ltr], [dir=ltr] *)::after,
26
+ :where(.aui-md-running) > :where(:not(ol):not(ul):not(pre)):last-child:where([dir=ltr], [dir=ltr] *)::after,
27
+ :where(.aui-md-running) > pre:last-child code:where([dir=ltr], [dir=ltr] *)::after,
28
+ :where(.aui-md-running) > :where(:is(ol, ul):last-child) > :where(li:last-child:not(:has(* > li))):where([dir=ltr], [dir=ltr] *)::after,
29
+ :where(.aui-md-running) > :where(:is(ol, ul):last-child) > :where(li:last-child) > :where(:is(ol, ul):last-child) > :where(li:last-child:not(:has(* > li))):where([dir=ltr], [dir=ltr] *)::after,
30
+ :where(.aui-md-running) > :where(:is(ol, ul):last-child) > :where(li:last-child) > :where(:is(ol, ul):last-child) > :where(li:last-child) > :where(:is(ol, ul):last-child) > :where(li:last-child):where([dir=ltr], [dir=ltr] *)::after {
31
31
  margin-left: 0.25rem;
32
32
  }
33
- :where(.aui-md-in-progress:empty):where([dir=rtl], [dir=rtl] *)::after,
34
- :where(.aui-md-in-progress > :not(ol):not(ul):not(pre):last-child):where([dir=rtl], [dir=rtl] *)::after,
35
- :where(.aui-md-in-progress > pre:last-child code):where([dir=rtl], [dir=rtl] *)::after,
36
- :where(.aui-md-in-progress > :is(ol, ul):last-child > li:last-child:not(:has(* > li))):where([dir=rtl], [dir=rtl] *)::after,
37
- :where(.aui-md-in-progress > :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child:not(:has(* > li))):where([dir=rtl], [dir=rtl] *)::after,
38
- :where(.aui-md-in-progress > :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child):where([dir=rtl], [dir=rtl] *)::after {
33
+ :where(.aui-md-running):empty:where([dir=rtl], [dir=rtl] *)::after,
34
+ :where(.aui-md-running) > :where(:not(ol):not(ul):not(pre)):last-child:where([dir=rtl], [dir=rtl] *)::after,
35
+ :where(.aui-md-running) > pre:last-child code:where([dir=rtl], [dir=rtl] *)::after,
36
+ :where(.aui-md-running) > :where(:is(ol, ul):last-child) > :where(li:last-child:not(:has(* > li))):where([dir=rtl], [dir=rtl] *)::after,
37
+ :where(.aui-md-running) > :where(:is(ol, ul):last-child) > :where(li:last-child) > :where(:is(ol, ul):last-child) > :where(li:last-child:not(:has(* > li))):where([dir=rtl], [dir=rtl] *)::after,
38
+ :where(.aui-md-running) > :where(:is(ol, ul):last-child) > :where(li:last-child) > :where(:is(ol, ul):last-child) > :where(li:last-child) > :where(:is(ol, ul):last-child) > :where(li:last-child):where([dir=rtl], [dir=rtl] *)::after {
39
39
  margin-right: 0.25rem;
40
40
  }
41
- :where(.aui-md-root) h1 {
41
+ .aui-md-root h1 {
42
42
  margin-bottom: 2rem;
43
43
  scroll-margin: 5rem;
44
44
  font-size: 2.25rem;
@@ -46,10 +46,10 @@
46
46
  font-weight: 800;
47
47
  letter-spacing: -0.025em;
48
48
  }
49
- :where(.aui-md-root) h1:last-child {
49
+ .aui-md-root h1:last-child {
50
50
  margin-bottom: 0px;
51
51
  }
52
- :where(.aui-md-root) h2 {
52
+ .aui-md-root h2 {
53
53
  margin-bottom: 1rem;
54
54
  margin-top: 2rem;
55
55
  scroll-margin: 5rem;
@@ -58,13 +58,13 @@
58
58
  font-weight: 600;
59
59
  letter-spacing: -0.025em;
60
60
  }
61
- :where(.aui-md-root) h2:first-child {
61
+ .aui-md-root h2:first-child {
62
62
  margin-top: 0px;
63
63
  }
64
- :where(.aui-md-root) h2:last-child {
64
+ .aui-md-root h2:last-child {
65
65
  margin-bottom: 0px;
66
66
  }
67
- :where(.aui-md-root) h3 {
67
+ .aui-md-root h3 {
68
68
  margin-bottom: 1rem;
69
69
  margin-top: 1.5rem;
70
70
  scroll-margin: 5rem;
@@ -73,13 +73,13 @@
73
73
  font-weight: 600;
74
74
  letter-spacing: -0.025em;
75
75
  }
76
- :where(.aui-md-root) h3:first-child {
76
+ .aui-md-root h3:first-child {
77
77
  margin-top: 0px;
78
78
  }
79
- :where(.aui-md-root) h3:last-child {
79
+ .aui-md-root h3:last-child {
80
80
  margin-bottom: 0px;
81
81
  }
82
- :where(.aui-md-root) h4 {
82
+ .aui-md-root h4 {
83
83
  margin-bottom: 1rem;
84
84
  margin-top: 1.5rem;
85
85
  scroll-margin: 5rem;
@@ -88,82 +88,82 @@
88
88
  font-weight: 600;
89
89
  letter-spacing: -0.025em;
90
90
  }
91
- :where(.aui-md-root) h4:first-child {
91
+ .aui-md-root h4:first-child {
92
92
  margin-top: 0px;
93
93
  }
94
- :where(.aui-md-root) h4:last-child {
94
+ .aui-md-root h4:last-child {
95
95
  margin-bottom: 0px;
96
96
  }
97
- :where(.aui-md-root) h5 {
97
+ .aui-md-root h5 {
98
98
  margin-top: 1rem;
99
99
  margin-bottom: 1rem;
100
100
  font-size: 1.125rem;
101
101
  line-height: 1.75rem;
102
102
  font-weight: 600;
103
103
  }
104
- :where(.aui-md-root) h5:first-child {
104
+ .aui-md-root h5:first-child {
105
105
  margin-top: 0px;
106
106
  }
107
- :where(.aui-md-root) h5:last-child {
107
+ .aui-md-root h5:last-child {
108
108
  margin-bottom: 0px;
109
109
  }
110
- :where(.aui-md-root) h6 {
110
+ .aui-md-root h6 {
111
111
  margin-top: 1rem;
112
112
  margin-bottom: 1rem;
113
113
  font-weight: 600;
114
114
  }
115
- :where(.aui-md-root) h6:first-child {
115
+ .aui-md-root h6:first-child {
116
116
  margin-top: 0px;
117
117
  }
118
- :where(.aui-md-root) h6:last-child {
118
+ .aui-md-root h6:last-child {
119
119
  margin-bottom: 0px;
120
120
  }
121
- :where(.aui-md-root) p {
121
+ .aui-md-root p {
122
122
  margin-bottom: 1.25rem;
123
123
  margin-top: 1.25rem;
124
124
  line-height: 1.75rem;
125
125
  }
126
- :where(.aui-md-root) p:first-child {
126
+ .aui-md-root p:first-child {
127
127
  margin-top: 0px;
128
128
  }
129
- :where(.aui-md-root) p:last-child {
129
+ .aui-md-root p:last-child {
130
130
  margin-bottom: 0px;
131
131
  }
132
- :where(.aui-md-root) a {
132
+ .aui-md-root a {
133
133
  font-weight: 500;
134
134
  color: hsl(var(--aui-primary));
135
135
  text-decoration-line: underline;
136
136
  text-underline-offset: 4px;
137
137
  }
138
- :where(.aui-md-root) blockquote {
138
+ .aui-md-root blockquote {
139
139
  border-left-width: 2px;
140
140
  padding-left: 1.5rem;
141
141
  font-style: italic;
142
142
  }
143
- :where(.aui-md-root) ul {
143
+ .aui-md-root ul {
144
144
  margin-top: 1.25rem;
145
145
  margin-bottom: 1.25rem;
146
146
  margin-left: 1.5rem;
147
147
  list-style-type: disc;
148
148
  }
149
- :where(.aui-md-root) ul > li {
149
+ .aui-md-root ul > li {
150
150
  margin-top: 0.5rem;
151
151
  }
152
- :where(.aui-md-root) ol {
152
+ .aui-md-root ol {
153
153
  margin-top: 1.25rem;
154
154
  margin-bottom: 1.25rem;
155
155
  margin-left: 1.5rem;
156
156
  list-style-type: decimal;
157
157
  }
158
- :where(.aui-md-root) ol > li {
158
+ .aui-md-root ol > li {
159
159
  margin-top: 0.5rem;
160
160
  }
161
- :where(.aui-md-root) hr {
161
+ .aui-md-root hr {
162
162
  margin-top: 1.25rem;
163
163
  margin-bottom: 1.25rem;
164
164
  border-bottom-width: 1px;
165
165
  }
166
- :where(.aui-md-root) table {
166
+ .aui-md-root table {
167
167
  margin-top: 1.25rem;
168
168
  margin-bottom: 1.25rem;
169
169
  width: 100%;
@@ -173,7 +173,7 @@
173
173
  border-spacing: var(--aui-border-spacing-x) var(--aui-border-spacing-y);
174
174
  overflow-y: auto;
175
175
  }
176
- :where(.aui-md-root) th {
176
+ .aui-md-root th {
177
177
  background-color: hsl(var(--aui-muted));
178
178
  padding-left: 1rem;
179
179
  padding-right: 1rem;
@@ -182,19 +182,19 @@
182
182
  text-align: left;
183
183
  font-weight: 700;
184
184
  }
185
- :where(.aui-md-root) th:first-child {
185
+ .aui-md-root th:first-child {
186
186
  border-top-left-radius: var(--aui-radius);
187
187
  }
188
- :where(.aui-md-root) th:last-child {
188
+ .aui-md-root th:last-child {
189
189
  border-top-right-radius: var(--aui-radius);
190
190
  }
191
- :where(.aui-md-root) th[align=center] {
191
+ .aui-md-root th[align=center] {
192
192
  text-align: center;
193
193
  }
194
- :where(.aui-md-root) th[align=right] {
194
+ .aui-md-root th[align=right] {
195
195
  text-align: right;
196
196
  }
197
- :where(.aui-md-root) td {
197
+ .aui-md-root td {
198
198
  border-bottom-width: 1px;
199
199
  border-left-width: 1px;
200
200
  padding-left: 1rem;
@@ -203,35 +203,35 @@
203
203
  padding-bottom: 0.5rem;
204
204
  text-align: left;
205
205
  }
206
- :where(.aui-md-root) td:last-child {
206
+ .aui-md-root td:last-child {
207
207
  border-right-width: 1px;
208
208
  }
209
- :where(.aui-md-root) td[align=center] {
209
+ .aui-md-root td[align=center] {
210
210
  text-align: center;
211
211
  }
212
- :where(.aui-md-root) td[align=right] {
212
+ .aui-md-root td[align=right] {
213
213
  text-align: right;
214
214
  }
215
- :where(.aui-md-root) tr {
215
+ .aui-md-root tr {
216
216
  margin: 0px;
217
217
  border-bottom-width: 1px;
218
218
  padding: 0px;
219
219
  }
220
- :where(.aui-md-root) tr:first-child {
220
+ .aui-md-root tr:first-child {
221
221
  border-top-width: 1px;
222
222
  }
223
- :where(.aui-md-root) tr:last-child > td:first-child {
223
+ .aui-md-root tr:last-child > td:first-child {
224
224
  border-bottom-left-radius: var(--aui-radius);
225
225
  }
226
- :where(.aui-md-root) tr:last-child > td:last-child {
226
+ .aui-md-root tr:last-child > td:last-child {
227
227
  border-bottom-right-radius: var(--aui-radius);
228
228
  }
229
- :where(.aui-md-root) sup > a {
229
+ .aui-md-root sup > a {
230
230
  font-size: 0.75rem;
231
231
  line-height: 1rem;
232
232
  text-decoration-line: none;
233
233
  }
234
- :where(.aui-md-root) pre {
234
+ .aui-md-root pre {
235
235
  overflow-x: auto;
236
236
  border-bottom-right-radius: var(--aui-radius);
237
237
  border-bottom-left-radius: var(--aui-radius);
@@ -240,8 +240,8 @@
240
240
  --aui-text-opacity: 1;
241
241
  color: rgb(255 255 255 / var(--aui-text-opacity));
242
242
  }
243
- :where(.aui-md-root) > code,
244
- :where(.aui-md-root) :not(:where(pre)) code {
243
+ .aui-md-root > code,
244
+ .aui-md-root :not(:where(pre)) code {
245
245
  border-radius: 0.25rem;
246
246
  border-width: 1px;
247
247
  background-color: hsl(var(--aui-muted));
@@ -1,107 +1,100 @@
1
- /* in progress indicator */
2
- :where(.aui-md-in-progress:empty)::after,
3
- :where(.aui-md-in-progress > :not(ol):not(ul):not(pre):last-child)::after,
4
- :where(.aui-md-in-progress > pre:last-child code)::after,
5
- :where(
6
- .aui-md-in-progress
7
- > :is(ol, ul):last-child
8
- > li:last-child:not(:has(* > li))
9
- )::after,
10
- :where(
11
- .aui-md-in-progress
12
- > :is(ol, ul):last-child
13
- > li:last-child
14
- > :is(ol, ul):last-child
15
- > li:last-child:not(:has(* > li))
16
- )::after,
17
- :where(
18
- .aui-md-in-progress
19
- > :is(ol, ul):last-child
20
- > li:last-child
21
- > :is(ol, ul):last-child
22
- > li:last-child
23
- > :is(ol, ul):last-child
24
- > li:last-child
25
- )::after {
1
+ /* running indicator */
2
+ :where(.aui-md-running):empty::after,
3
+ :where(.aui-md-running) > :where(:not(ol):not(ul):not(pre)):last-child::after,
4
+ :where(.aui-md-running) > pre:last-child code::after,
5
+ :where(.aui-md-running)
6
+ > :where(:is(ol, ul):last-child)
7
+ > :where(li:last-child:not(:has(* > li)))::after,
8
+ :where(.aui-md-running)
9
+ > :where(:is(ol, ul):last-child)
10
+ > :where(li:last-child)
11
+ > :where(:is(ol, ul):last-child)
12
+ > :where(li:last-child:not(:has(* > li)))::after,
13
+ :where(.aui-md-running)
14
+ > :where(:is(ol, ul):last-child)
15
+ > :where(li:last-child)
16
+ > :where(:is(ol, ul):last-child)
17
+ > :where(li:last-child)
18
+ > :where(:is(ol, ul):last-child)
19
+ > :where(li:last-child)::after {
26
20
  @apply animate-pulse font-sans content-['\25CF'] ltr:ml-1 rtl:mr-1;
27
21
  }
28
-
29
22
  /* typography */
30
23
 
31
- :where(.aui-md-root) h1 {
24
+ .aui-md-root h1 {
32
25
  @apply mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0;
33
26
  }
34
27
 
35
- :where(.aui-md-root) h2 {
28
+ .aui-md-root h2 {
36
29
  @apply mb-4 mt-8 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0;
37
30
  }
38
31
 
39
- :where(.aui-md-root) h3 {
32
+ .aui-md-root h3 {
40
33
  @apply mb-4 mt-6 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0;
41
34
  }
42
35
 
43
- :where(.aui-md-root) h4 {
36
+ .aui-md-root h4 {
44
37
  @apply mb-4 mt-6 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0;
45
38
  }
46
39
 
47
- :where(.aui-md-root) h5 {
40
+ .aui-md-root h5 {
48
41
  @apply my-4 text-lg font-semibold first:mt-0 last:mb-0;
49
42
  }
50
43
 
51
- :where(.aui-md-root) h6 {
44
+ .aui-md-root h6 {
52
45
  @apply my-4 font-semibold first:mt-0 last:mb-0;
53
46
  }
54
47
 
55
- :where(.aui-md-root) p {
48
+ .aui-md-root p {
56
49
  @apply mb-5 mt-5 leading-7 first:mt-0 last:mb-0;
57
50
  }
58
51
 
59
- :where(.aui-md-root) a {
52
+ .aui-md-root a {
60
53
  @apply text-aui-primary font-medium underline underline-offset-4;
61
54
  }
62
55
 
63
- :where(.aui-md-root) blockquote {
56
+ .aui-md-root blockquote {
64
57
  @apply border-l-2 pl-6 italic;
65
58
  }
66
59
 
67
- :where(.aui-md-root) ul {
60
+ .aui-md-root ul {
68
61
  @apply my-5 ml-6 list-disc [&>li]:mt-2;
69
62
  }
70
63
 
71
- :where(.aui-md-root) ol {
64
+ .aui-md-root ol {
72
65
  @apply my-5 ml-6 list-decimal [&>li]:mt-2;
73
66
  }
74
67
 
75
- :where(.aui-md-root) hr {
68
+ .aui-md-root hr {
76
69
  @apply my-5 border-b;
77
70
  }
78
71
 
79
- :where(.aui-md-root) table {
72
+ .aui-md-root table {
80
73
  @apply my-5 w-full border-separate border-spacing-0 overflow-y-auto;
81
74
  }
82
75
 
83
- :where(.aui-md-root) th {
76
+ .aui-md-root th {
84
77
  @apply bg-aui-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [&[align=center]]:text-center [&[align=right]]:text-right;
85
78
  }
86
79
 
87
- :where(.aui-md-root) td {
80
+ .aui-md-root td {
88
81
  @apply border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right;
89
82
  }
90
83
 
91
- :where(.aui-md-root) tr {
84
+ .aui-md-root tr {
92
85
  @apply m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg;
93
86
  }
94
87
 
95
- :where(.aui-md-root) sup {
88
+ .aui-md-root sup {
96
89
  @apply [&>a]:text-xs [&>a]:no-underline;
97
90
  }
98
91
 
99
- :where(.aui-md-root) pre {
92
+ .aui-md-root pre {
100
93
  @apply overflow-x-auto rounded-b-lg bg-black p-4 text-white;
101
94
  }
102
95
 
103
- :where(.aui-md-root) > code,
104
- :where(.aui-md-root) :not(:where(pre)) code {
96
+ .aui-md-root > code,
97
+ .aui-md-root :not(:where(pre)) code {
105
98
  @apply bg-aui-muted rounded border font-semibold;
106
99
  }
107
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/react-markdown",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -37,13 +37,14 @@
37
37
  ],
38
38
  "sideEffects": false,
39
39
  "dependencies": {
40
+ "@radix-ui/react-primitive": "^2.0.0",
40
41
  "@radix-ui/react-use-callback-ref": "^1.1.0",
41
42
  "classnames": "^2.5.1",
42
- "lucide-react": "^0.414.0",
43
+ "lucide-react": "^0.416.0",
43
44
  "react-markdown": "^9.0.1"
44
45
  },
45
46
  "peerDependencies": {
46
- "@assistant-ui/react": "^0.5.9",
47
+ "@assistant-ui/react": "^0.5.22",
47
48
  "@types/react": "*",
48
49
  "react": "^18",
49
50
  "tailwindcss": "^3.4.4"
@@ -61,10 +62,10 @@
61
62
  "autoprefixer": "^10.4.19",
62
63
  "eslint": "^8",
63
64
  "eslint-config-next": "14.2.5",
64
- "postcss": "^8.4.39",
65
- "tailwindcss": "^3.4.6",
65
+ "postcss": "^8.4.40",
66
+ "tailwindcss": "^3.4.7",
66
67
  "tailwindcss-animate": "^1.0.7",
67
- "tsup": "8.2.2",
68
+ "tsup": "8.2.3",
68
69
  "tsx": "^4.16.2",
69
70
  "@assistant-ui/tailwindcss-transformer": "^0.1.0",
70
71
  "@assistant-ui/tsconfig": "0.0.0"