Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions packages/elements/src/attachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,18 @@ export const AttachmentRemove = ({

export type AttachmentHoverCardProps = ComponentProps<typeof HoverCard>;

export const AttachmentHoverCard = ({
openDelay = 0,
closeDelay = 0,
...props
}: AttachmentHoverCardProps) => (
<HoverCard closeDelay={closeDelay} openDelay={openDelay} {...props} />
// Open/close with no delay. Radix's HoverCard takes these props; Base UI's
// PreviewCard — what `shadcn add` swaps in on a Base UI project — has neither,
// so naming them in a typed position fails to compile there. Spreading keeps the
// behaviour on Radix and is inert on Base UI. A caller's own props still win,
// since they spread last.
const NO_DELAY = {
closeDelay: 0,
openDelay: 0,
} as unknown as ComponentProps<typeof HoverCard>;

export const AttachmentHoverCard = (props: AttachmentHoverCardProps) => (
<HoverCard {...NO_DELAY} {...props} />
);

export type AttachmentHoverCardTriggerProps = ComponentProps<
Expand Down
12 changes: 11 additions & 1 deletion packages/elements/src/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ const useContextValue = () => {

export type ContextProps = ComponentProps<typeof HoverCard> & ContextSchema;

// Open/close with no delay. Radix's HoverCard takes these props; Base UI's
// PreviewCard — what `shadcn add` swaps in on a Base UI project — has neither,
// so naming them in a typed position fails to compile there. Spreading keeps the
// behaviour on Radix and is inert on Base UI. A caller's own props still win,
// since they spread last.
const NO_DELAY = {
closeDelay: 0,
openDelay: 0,
} as unknown as ComponentProps<typeof HoverCard>;

export const Context = ({
usedTokens,
maxTokens,
Expand All @@ -56,7 +66,7 @@ export const Context = ({

return (
<ContextContext.Provider value={contextValue}>
<HoverCard closeDelay={0} openDelay={0} {...props} />
<HoverCard {...NO_DELAY} {...props} />
</ContextContext.Provider>
);
};
Expand Down
12 changes: 11 additions & 1 deletion packages/elements/src/inline-citation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,18 @@ export const InlineCitationText = ({

export type InlineCitationCardProps = ComponentProps<typeof HoverCard>;

// Open/close with no delay. Radix's HoverCard takes these props; Base UI's
// PreviewCard — what `shadcn add` swaps in on a Base UI project — has neither,
// so naming them in a typed position fails to compile there. Spreading keeps the
// behaviour on Radix and is inert on Base UI. A caller's own props still win,
// since they spread last.
const NO_DELAY = {
closeDelay: 0,
openDelay: 0,
} as unknown as ComponentProps<typeof HoverCard>;

export const InlineCitationCard = (props: InlineCitationCardProps) => (
<HoverCard closeDelay={0} openDelay={0} {...props} />
<HoverCard {...NO_DELAY} {...props} />
);

export type InlineCitationCardTriggerProps = ComponentProps<typeof Badge> & {
Expand Down
18 changes: 12 additions & 6 deletions packages/elements/src/prompt-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1317,12 +1317,18 @@ export const PromptInputSelectValue = ({

export type PromptInputHoverCardProps = ComponentProps<typeof HoverCard>;

export const PromptInputHoverCard = ({
openDelay = 0,
closeDelay = 0,
...props
}: PromptInputHoverCardProps) => (
<HoverCard closeDelay={closeDelay} openDelay={openDelay} {...props} />
// Open/close with no delay. Radix's HoverCard takes these props; Base UI's
// PreviewCard — what `shadcn add` swaps in on a Base UI project — has neither,
// so naming them in a typed position fails to compile there. Spreading keeps the
// behaviour on Radix and is inert on Base UI. A caller's own props still win,
// since they spread last.
const NO_DELAY = {
closeDelay: 0,
openDelay: 0,
} as unknown as ComponentProps<typeof HoverCard>;

export const PromptInputHoverCard = (props: PromptInputHoverCardProps) => (
<HoverCard {...NO_DELAY} {...props} />
);

export type PromptInputHoverCardTriggerProps = ComponentProps<
Expand Down