Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(quill): forward refs from every element-rendering primitive (#116903)

Adam Leith1b8bbf47fa32
diff --git a/frontend/src/layout/scenes/components/SceneMenuBar.tsx b/frontend/src/layout/scenes/components/SceneMenuBar.tsx
index 704a895b390e..5f629127fd19 100644
--- a/frontend/src/layout/scenes/components/SceneMenuBar.tsx
+++ b/frontend/src/layout/scenes/components/SceneMenuBar.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
import posthog from 'posthog-js'
-import { Children, ComponentProps, MouseEvent, ReactNode, useContext, useEffect } from 'react'
+import { Children, ComponentProps, ReactNode, useContext, useEffect } from 'react'
import { createPortal } from 'react-dom'
import { IconExternal, IconGear, IconSidePanel, IconSparkles } from '@posthog/icons'
@@ -349,7 +349,7 @@ export function SceneMenuBarItem({
onClick,
...props
}: SceneMenuBarItemProps): JSX.Element {
- const handleClick = (e: MouseEvent<HTMLDivElement>): void => {
+ const handleClick: NonNullable<SceneMenuBarItemProps['onClick']> = (e) => {
const dataAttr = (props as Record<string, unknown>)['data-attr']
captureSceneMenuBar('scene menu bar item clicked', {
item: typeof dataAttr === 'string' ? dataAttr : typeof children === 'string' ? children : undefined,
diff --git a/frontend/src/lib/components/AgentPromptButton/AgentPromptButton.tsx b/frontend/src/lib/components/AgentPromptButton/AgentPromptButton.tsx
index 097238592cca..36b00fb35532 100644
--- a/frontend/src/lib/components/AgentPromptButton/AgentPromptButton.tsx
+++ b/frontend/src/lib/components/AgentPromptButton/AgentPromptButton.tsx
@@ -54,6 +54,14 @@ export type AgentPromptDestination =
/** Quill button sizes, minus the icon-only variants (the dropdown trigger derives those automatically). */
type AgentPromptButtonSize = Exclude<NonNullable<QuillButtonProps['size']>, 'icon' | 'icon-xs' | 'icon-sm' | 'icon-lg'>
+const ICON_SIZE: Record<AgentPromptButtonSize, QuillButtonProps['size']> = {
+ default: 'icon',
+ xs: 'icon-xs',
+ sm: 'icon-sm',
+ lg: 'icon-lg',
+ row: 'icon',
+}
+
export interface AgentPromptButtonProps {
actions: AgentPromptAction[]
/**
@@ -372,7 +380,7 @@ export function AgentPromptButton({
<DropdownMenuTrigger asChild>
<QuillButton
variant={variant}
- size={size === 'default' ? 'icon' : `icon-${size}`}
+ size={ICON_SIZE[size]}
className="border-0"
aria-label={
agentSelectionMode === 'run' ? 'Open prompt in an agent' : 'Choose prompt and destination'
diff --git a/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsx b/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsx
index 491af766261f..c83614f601a2 100644
--- a/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsx
@@ -184,7 +184,7 @@ interface AutocompleteCtx {
/** Currently controlled value from the orchestrator (raw, no item context). */
value: TaxonomicFilterValue | undefined
/** Ref to the search input — Input attaches it on mount. */
- inputRef: RefObject<HTMLInputElement | null>
+ inputRef: RefObject<HTMLInputElement>
/** Move focus to the search input. */
focusInput: () => void
/** Label for the default Trigger button when no entry is selected. */
@@ -346,7 +346,7 @@ export function Root({
const [hasMenuTrigger, setHasMenuTrigger] = useState(false)
const triggerRef = useRef<HTMLElement | null>(null)
const seededRef = useRef(false)
- const inputRef = useRef<HTMLInputElement | null>(null)
+ const inputRef = useRef<HTMLInputElement>(null)
const focusInput = useCallback((): void => {
inputRef.current?.focus()
}, [])
@@ -1388,7 +1388,7 @@ function Header({ rootTitle, subTitle, className }: TaxonomicAutocompleteHeaderP
{isSub && (
<Button
type="button"
- variant="ghost"
+ variant="default"
size="icon-sm"
aria-label="Back"
onClick={() => ctx.cancelPending()}
diff --git a/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx b/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx
index 415fdfab6e4d..d2c0abb04ded 100644
--- a/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx
+++ b/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx
@@ -318,7 +318,7 @@ function InsightSceneMenuBarInner({ insightLogicProps }: { insightLogicProps: In
<SceneMenuBarSubMenu label="Export">
<SceneMenuBarItem
disabled={(canCaptureImage && isCapturingImage) || !!pngExportDisabledReason}
- tooltip={pngExportDisabledReason}
+ tooltip={pngExportDisabledReason ?? undefined}
onClick={() =>
canCaptureImage
? downloadImage(captureTarget)
@@ -450,7 +450,7 @@ function InsightSceneMenuBarInner({ insightLogicProps }: { insightLogicProps: In
{showMetalytics && (
<Button
type="button"
- variant="ghost"
+ variant="default"
size="sm"
left
onClick={() => openSidePanel(SidePanelTab.Activity, 'metalytics')}
diff --git a/frontend/src/scenes/toolbar-launch/ToolbarAuthorizedUrls.tsx b/frontend/src/scenes/toolbar-launch/ToolbarAuthorizedUrls.tsx
index 6cad737ba1b0..eb62d399d41f 100644
--- a/frontend/src/scenes/toolbar-launch/ToolbarAuthorizedUrls.tsx
+++ b/frontend/src/scenes/toolbar-launch/ToolbarAuthorizedUrls.tsx
@@ -134,7 +134,7 @@ export function ToolbarAuthorizedUrls({ canEdit }: { canEdit: boolean }): JSX.El
<Button
variant="outline"
loading={suggestionsLoading}
- onClick={loadSuggestions}
+ onClick={() => loadSuggestions()}
data-attr="authorized-url-list-fetch-suggestions"
>
<IconRefresh />
@@ -312,7 +312,7 @@ export function ToolbarAuthorizedUrls({ canEdit }: { canEdit: boolean }): JSX.El
variant="link-muted"
size="sm"
loading={suggestionsLoading}
- onClick={loadSuggestions}
+ onClick={() => loadSuggestions()}
data-attr="authorized-url-list-fetch-suggestions"
className="w-fit"
>
diff --git a/packages/quill/AGENTS.md b/packages/quill/AGENTS.md
index ec9fee9bf903..3b4555376eb2 100644
--- a/packages/quill/AGENTS.md
+++ b/packages/quill/AGENTS.md
@@ -80,18 +80,15 @@ className={cn(baseClasses, conditional && 'extra-class', className)}
Every component root sets `data-slot="component-name"`.
This enables parent-based styling via `has-data-[slot=...]` and `*:data-[slot=...]`.
-### 5. `forwardRef` for render prop targets
+### 5. `forwardRef` on every element-rendering primitive
-Any component used as a `render={<Component />}` target in Base UI **must** use `React.forwardRef`.
-React 18 does not forward refs to function components — Base UI's render prop passes refs.
+Every primitive that renders a DOM element **must** use `React.forwardRef` and pass the ref to that element.
+React 18 drops a ref passed to a plain function component, and Base UI's `render` prop and trigger anchoring depend on that ref.
+Exceptions: components that render no element of their own (`Root`, `Portal`, `Sub`, `Provider`), and the `Resizable*` panels, which take the library's own `elementRef` prop.
-Components that need `forwardRef`:
-
-- `Button`, `Input`, `Chip`, `ChipClose`
-- `InputGroup`, `InputGroupInput`, `InputGroupButton`
-- `ComboboxTrigger`
-- `TooltipTrigger`, `DropdownMenuTrigger`, `PopoverTrigger`, `DialogTrigger`, `DrawerTrigger`
-- Any component passed to Base UI's `render` prop
+When forwardRef wraps a props type from a private module of a dependency, annotate the const with `React.ForwardRefExoticComponent<...>` (see `QuestionnaireChoice`).
+Otherwise the emitted `.d.ts` imports that module by path, consumers cannot resolve it, and the props become `any`.
+The primitives build fails on such a path.
### 6. Composition hierarchy
diff --git a/packages/quill/packages/components/src/metric.tsx b/packages/quill/packages/components/src/metric.tsx
index 0ef8d5d6bef3..372cbe32281f 100644
--- a/packages/quill/packages/components/src/metric.tsx
+++ b/packages/quill/packages/components/src/metric.tsx
@@ -200,7 +200,10 @@ function MetricInner({
className,
dataAttr,
children,
-}: Omit<MetricBaseProps, 'onError'> & { data?: number[]; series?: Series[] }): React.ReactElement | null {
+}: Omit<MetricBaseProps, 'onError'> & {
+ data?: number[]
+ series?: Series[]
+}): React.ReactElement | null {
const sparklineData = data != null && data.length > 0 && theme != null ? data : null
const lastIndex = sparklineData ? sparklineData.length - 1 : -1
@@ -323,24 +326,37 @@ function MetricInner({
}
/** Header row: title on the left, change pill (or anything) on the right. */
-export function MetricHeader({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div className={cn('flex items-start justify-between gap-2', className)} {...props} />
-}
+export const MetricHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function MetricHeader(
+ { className, ...props },
+ ref
+) {
+ return <div ref={ref} className={cn('flex items-start justify-between gap-2', className)} {...props} />
+})
-export function MetricTitle({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div className={cn('text-sm font-medium', className)} {...props} />
-}
+export const MetricTitle = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function MetricTitle(
+ { className, ...props },
+ ref
+) {
+ return <div ref={ref} className={cn('text-sm font-medium', className)} {...props} />
+})
/** Headline number. Follows the hovered sparkline point; pass `children` to render your own, or a
* `text-*` class to resize it (cn lets your size win over the default `text-4xl`). */
-export function MetricValue({ className, children, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+export const MetricValue = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function MetricValue(
+ { className, children, ...props },
+ ref
+) {
const { headlineDisplay } = useMetric('MetricValue')
return (
- <div className={cn('min-w-0 truncate text-4xl font-bold tracking-tight tabular-nums', className)} {...props}>
+ <div
+ ref={ref}
+ className={cn('min-w-0 truncate text-4xl font-bold tracking-tight tabular-nums', className)}
+ {...props}
+ >
{children ?? headlineDisplay}
</div>
)
-}
+})
/** Change pill — a `Badge` (success/destructive by `goodDirection`, or the root's custom
* `positiveColor`/`negativeColor`) with a directional chevron. Renders nothing when there is no
@@ -358,7 +374,10 @@ export function MetricDelta({ className }: { className?: string }): React.ReactE
// Dynamic user-configured colors can't be Tailwind classes; inline style wins over the variant.
style={
change.colors != null
- ? { background: change.colors.background, color: change.colors.foreground }
+ ? {
+ background: change.colors.background,
+ color: change.colors.foreground,
+ }
: undefined
}
data-attr="metric-change-pill"
@@ -370,11 +389,10 @@ export function MetricDelta({ className }: { className?: string }): React.ReactE
if (change.tooltip == null) {
return badge
}
- // Badge isn't a forwardRef component, so it can't be the `render` target — anchor on a span.
return (
<TooltipProvider>
<Tooltip>
- <TooltipTrigger render={<span className="inline-flex" />}>{badge}</TooltipTrigger>
+ <TooltipTrigger render={badge} />
<TooltipContent>{change.tooltip}</TooltipContent>
</Tooltip>
</TooltipProvider>
@@ -382,22 +400,21 @@ export function MetricDelta({ className }: { className?: string }): React.ReactE
}
/** Caption under the headline. Renders nothing when empty; pass `children` to override. */
-export function MetricSubtitle({
- className,
- children,
- ...props
-}: React.ComponentProps<'div'>): React.ReactElement | null {
+export const MetricSubtitle = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function MetricSubtitle(
+ { className, children, ...props },
+ ref
+) {
const { subtitle } = useMetric('MetricSubtitle')
const content = children ?? subtitle
if (content == null || content === '') {
return null
}
return (
- <div className={cn('text-sm opacity-60', className)} data-attr="metric-subtitle" {...props}>
+ <div ref={ref} className={cn('text-sm opacity-60', className)} data-attr="metric-subtitle" {...props}>
{content}
</div>
)
-}
+})
/** Sparkline, bled out to the card edges. Renders nothing when no series was supplied to the root. */
export function MetricSparkline({
diff --git a/packages/quill/packages/primitives/AGENTS.md b/packages/quill/packages/primitives/AGENTS.md
index 80f8c7655a7c..eb28b3c40444 100644
--- a/packages/quill/packages/primitives/AGENTS.md
+++ b/packages/quill/packages/primitives/AGENTS.md
@@ -45,7 +45,7 @@ Only use the self-closing pattern when you need full control over the element an
Base UI automatically merges event handlers, aria attributes, and `data-*` state onto the rendered element.
-The `Tooltip`, `DropdownMenu`, `Popover`, `Dialog` and `Drawer` triggers forward refs, so one can render another: `<TooltipTrigger render={<DropdownMenuTrigger render={<Button />} />}>` works in either order.
+Every primitive that renders an element forwards its ref, so any of them can be a `render` target and triggers nest in either order: `<TooltipTrigger render={<DropdownMenuTrigger render={<Button />} />}>`.
---
@@ -651,8 +651,6 @@ const [tooltip] = React.useState(() => createTooltipHandle<string>())
</TooltipProvider>
```
-On React 18, put the trigger inside a component's `render` (`<IconStackItem render={<TooltipTrigger … />} />`), not the other way round, because the trigger needs a ref that a plain function component drops.
-
### Radio Group
```tsx
diff --git a/packages/quill/packages/primitives/src/accordion.tsx b/packages/quill/packages/primitives/src/accordion.tsx
index 3c2f9564671f..ee3859f58f2d 100644
--- a/packages/quill/packages/primitives/src/accordion.tsx
+++ b/packages/quill/packages/primitives/src/accordion.tsx
@@ -5,31 +5,42 @@ import * as React from 'react'
import './accordion.css'
import { cn } from './lib/utils'
-function Accordion({ className, ...props }: AccordionPrimitive.Root.Props): React.ReactElement {
- return (
- <AccordionPrimitive.Root
- data-slot="accordion"
- className={cn('quill-accordion flex w-full flex-col', className)}
- {...props}
- />
- )
-}
+const Accordion = React.forwardRef<React.ComponentRef<typeof AccordionPrimitive.Root>, AccordionPrimitive.Root.Props>(
+ function Accordion({ className, ...props }, ref) {
+ return (
+ <AccordionPrimitive.Root
+ ref={ref}
+ data-slot="accordion"
+ className={cn('quill-accordion flex w-full flex-col', className)}
+ {...props}
+ />
+ )
+ }
+)
-function AccordionItem({ className, ...props }: AccordionPrimitive.Item.Props): React.ReactElement {
+const AccordionItem = React.forwardRef<
+ React.ComponentRef<typeof AccordionPrimitive.Item>,
+ AccordionPrimitive.Item.Props
+>(function AccordionItem({ className, ...props }, ref) {
return (
<AccordionPrimitive.Item
+ ref={ref}
data-quill
data-slot="accordion-item"
className={cn('quill-accordion__item', className)}
{...props}
/>
)
-}
+})
-function AccordionTrigger({ className, children, ...props }: AccordionPrimitive.Trigger.Props): React.ReactElement {
+const AccordionTrigger = React.forwardRef<
+ React.ComponentRef<typeof AccordionPrimitive.Trigger>,
+ AccordionPrimitive.Trigger.Props
+>(function AccordionTrigger({ className, children, ...props }, ref) {
return (
<AccordionPrimitive.Header className="flex">
<AccordionPrimitive.Trigger
+ ref={ref}
data-slot="accordion-trigger"
className={cn(
'quill-accordion__trigger group/accordion-trigger relative flex flex-1 items-start justify-between gap-6',
@@ -51,14 +62,17 @@ function AccordionTrigger({ className, children, ...props }: AccordionPrimitive.
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
)
-}
+})
-function AccordionContent({ className, children, ...props }: AccordionPrimitive.Panel.Props): React.ReactElement {
+const AccordionContent = React.forwardRef<
+ React.ComponentRef<typeof AccordionPrimitive.Panel>,
+ AccordionPrimitive.Panel.Props
+>(function AccordionContent({ className, children, ...props }, ref) {
return (
- <AccordionPrimitive.Panel data-slot="accordion-content" className="quill-accordion__panel" {...props}>
+ <AccordionPrimitive.Panel ref={ref} data-slot="accordion-content" className="quill-accordion__panel" {...props}>
<div className={cn('quill-accordion__panel-content', className)}>{children}</div>
</AccordionPrimitive.Panel>
)
-}
+})
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger }
diff --git a/packages/quill/packages/primitives/src/alert-dialog.tsx b/packages/quill/packages/primitives/src/alert-dialog.tsx
index 9da1b3e5357d..b6c432d111f2 100644
--- a/packages/quill/packages/primitives/src/alert-dialog.tsx
+++ b/packages/quill/packages/primitives/src/alert-dialog.tsx
@@ -18,21 +18,31 @@ function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props): React.React
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
}
-function AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props): React.ReactElement {
- return <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
-}
+const AlertDialogTrigger = React.forwardRef<
+ React.ComponentRef<typeof AlertDialogPrimitive.Trigger>,
+ AlertDialogPrimitive.Trigger.Props
+>(function AlertDialogTrigger({ ...props }, ref) {
+ return <AlertDialogPrimitive.Trigger ref={ref} data-slot="alert-dialog-trigger" {...props} />
+})
function AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props): React.ReactElement {
return <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
}
-function AlertDialogClose({ ...props }: AlertDialogPrimitive.Close.Props): React.ReactElement {
- return <AlertDialogPrimitive.Close data-slot="alert-dialog-close" {...props} />
-}
+const AlertDialogClose = React.forwardRef<
+ React.ComponentRef<typeof AlertDialogPrimitive.Close>,
+ AlertDialogPrimitive.Close.Props
+>(function AlertDialogClose({ ...props }, ref) {
+ return <AlertDialogPrimitive.Close ref={ref} data-slot="alert-dialog-close" {...props} />
+})
-function AlertDialogOverlay({ className, ...props }: AlertDialogPrimitive.Backdrop.Props): React.ReactElement {
+const AlertDialogOverlay = React.forwardRef<
+ React.ComponentRef<typeof AlertDialogPrimitive.Backdrop>,
+ AlertDialogPrimitive.Backdrop.Props
+>(function AlertDialogOverlay({ className, ...props }, ref) {
return (
<AlertDialogPrimitive.Backdrop
+ ref={ref}
data-quill
data-quill-portal="modal-overlay"
data-slot="alert-dialog-overlay"
@@ -40,18 +50,22 @@ function AlertDialogOverlay({ className, ...props }: AlertDialogPrimitive.Backdr
{...props}
/>
)
-}
+})
/*
* Unlike DialogContent there is deliberately no `showCloseButton` — an alert
* dialog must be resolved through one of its actions (or Esc), so an X would
* just be an ambiguous third option.
*/
-function AlertDialogContent({ className, children, ...props }: AlertDialogPrimitive.Popup.Props): React.ReactElement {
+const AlertDialogContent = React.forwardRef<
+ React.ComponentRef<typeof AlertDialogPrimitive.Popup>,
+ AlertDialogPrimitive.Popup.Props
+>(function AlertDialogContent({ className, children, ...props }, ref) {
return (
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Popup
+ ref={ref}
data-quill
data-quill-portal="modal-content"
data-slot="alert-dialog-content"
@@ -62,47 +76,63 @@ function AlertDialogContent({ className, children, ...props }: AlertDialogPrimit
</AlertDialogPrimitive.Popup>
</AlertDialogPortal>
)
-}
+})
-function AlertDialogTitle({ className, ...props }: AlertDialogPrimitive.Title.Props): React.ReactElement {
+const AlertDialogTitle = React.forwardRef<
+ React.ComponentRef<typeof AlertDialogPrimitive.Title>,
+ AlertDialogPrimitive.Title.Props
+>(function AlertDialogTitle({ className, ...props }, ref) {
return (
<AlertDialogPrimitive.Title
+ ref={ref}
data-slot="alert-dialog-title"
className={cn('quill-dialog__title', className)}
{...props}
/>
)
-}
+})
-function AlertDialogDescription({ className, ...props }: AlertDialogPrimitive.Description.Props): React.ReactElement {
+const AlertDialogDescription = React.forwardRef<
+ React.ComponentRef<typeof AlertDialogPrimitive.Description>,
+ AlertDialogPrimitive.Description.Props
+>(function AlertDialogDescription({ className, ...props }, ref) {
return (
<AlertDialogPrimitive.Description
+ ref={ref}
data-slot="alert-dialog-description"
className={cn('quill-dialog__description', className)}
{...props}
/>
)
-}
+})
-function AlertDialogHeader({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const AlertDialogHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function AlertDialogHeader(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="alert-dialog-header"
className={cn('quill-dialog__header flex flex-col gap-1', className)}
{...props}
/>
)
-}
+})
-function AlertDialogFooter({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const AlertDialogFooter = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function AlertDialogFooter(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="alert-dialog-footer"
className={cn('quill-dialog__footer flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className)}
{...props}
/>
)
-}
+})
export {
AlertDialog,
diff --git a/packages/quill/packages/primitives/src/autocomplete.tsx b/packages/quill/packages/primitives/src/autocomplete.tsx
index 4d836a3dd81e..c6273d8fcfe0 100644
--- a/packages/quill/packages/primitives/src/autocomplete.tsx
+++ b/packages/quill/packages/primitives/src/autocomplete.tsx
@@ -56,9 +56,13 @@ const AutocompleteTrigger = React.forwardRef<HTMLButtonElement, AutocompletePrim
)
AutocompleteTrigger.displayName = 'AutocompleteTrigger'
-function AutocompleteClear({ className, ...props }: AutocompletePrimitive.Clear.Props): React.ReactElement {
+const AutocompleteClear = React.forwardRef<
+ React.ComponentRef<typeof AutocompletePrimitive.Clear>,
+ AutocompletePrimitive.Clear.Props
+>(function AutocompleteClear({ className, ...props }, ref) {
return (
<AutocompletePrimitive.Clear
+ ref={ref}
data-slot="autocomplete-clear"
render={<InputGroupButton size="icon-xs" />}
className={cn(className)}
@@ -67,21 +71,20 @@ function AutocompleteClear({ className, ...props }: AutocompletePrimitive.Clear.
<XIcon className="pointer-events-none" />
</AutocompletePrimitive.Clear>
)
-}
+})
-function AutocompleteInput({
- className,
- children,
- disabled = false,
- showSearchIcon = true,
- showClear = false,
- ...props
-}: AutocompletePrimitive.Input.Props & {
- /** Render the leading search icon (default true). */
- showSearchIcon?: boolean
- /** Render the trailing clear button (default false). */
- showClear?: boolean
-}): React.ReactElement {
+const AutocompleteInput = React.forwardRef<
+ React.ComponentRef<typeof AutocompletePrimitive.Input>,
+ AutocompletePrimitive.Input.Props & {
+ /** Render the leading search icon (default true). */
+ showSearchIcon?: boolean
+ /** Render the trailing clear button (default false). */
+ showClear?: boolean
+ }
+>(function AutocompleteInput(
+ { className, children, disabled = false, showSearchIcon = true, showClear = false, ...props },
+ ref
+) {
const anchorRef = React.useContext(AutocompleteAnchorContext)
return (
<div data-slot="autocomplete-input-group-wrapper">
@@ -91,12 +94,8 @@ function AutocompleteInput({
<SearchIcon />
</InputGroupAddon>
)}
- <AutocompletePrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />
- {children ? (
- <InputGroupAddon align="inline-end">
- {children}
- </InputGroupAddon>
- ) : null}
+ <AutocompletePrimitive.Input ref={ref} render={<InputGroupInput disabled={disabled} />} {...props} />
+ {children ? <InputGroupAddon align="inline-end">{children}</InputGroupAddon> : null}
{showClear && (
<InputGroupAddon align="inline-end">
<AutocompleteClear disabled={disabled} />
@@ -110,21 +109,16 @@ function AutocompleteInput({
/>
</div>
)
-}
+})
-function AutocompleteContent({
- className,
- side = 'bottom',
- sideOffset = 6,
- align = 'start',
- alignOffset = 0,
- anchor: anchorProp,
- ...props
-}: AutocompletePrimitive.Popup.Props &
- Pick<
- AutocompletePrimitive.Positioner.Props,
- 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'
- >): React.ReactElement {
+const AutocompleteContent = React.forwardRef<
+ React.ComponentRef<typeof AutocompletePrimitive.Popup>,
+ AutocompletePrimitive.Popup.Props &
+ Pick<AutocompletePrimitive.Positioner.Props, 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'>
+>(function AutocompleteContent(
+ { className, side = 'bottom', sideOffset = 6, align = 'start', alignOffset = 0, anchor: anchorProp, ...props },
+ ref
+) {
const contextAnchor = React.useContext(AutocompleteAnchorContext)
const anchor = anchorProp ?? contextAnchor
return (
@@ -140,6 +134,7 @@ function AutocompleteContent({
className="isolate"
>
<AutocompletePrimitive.Popup
+ ref={ref}
data-slot="autocomplete-content"
className={cn('quill-autocomplete__content group/autocomplete-content', className)}
{...props}
@@ -147,26 +142,32 @@ function AutocompleteContent({
</AutocompletePrimitive.Positioner>
</AutocompletePrimitive.Portal>
)
-}
+})
-function AutocompleteList({ className, ...props }: AutocompletePrimitive.List.Props): React.ReactElement {
+const AutocompleteList = React.forwardRef<
+ React.ComponentRef<typeof AutocompletePrimitive.List>,
+ AutocompletePrimitive.List.Props
+>(function AutocompleteList({ className, ...props }, ref) {
return (
<AutocompletePrimitive.List
+ ref={ref}
data-slot="autocomplete-list"
- className={cn('quill-autocomplete__list scroll-mask-t-2 scroll-mask-b-4 scroll-pb-4 scroll-pt-6 empty:hidden', className)}
+ className={cn(
+ 'quill-autocomplete__list scroll-mask-t-2 scroll-mask-b-4 scroll-pb-4 scroll-pt-6 empty:hidden',
+ className
+ )}
{...props}
/>
)
-}
+})
-function AutocompleteItem({
- className,
- children,
- title,
- ...props
-}: AutocompletePrimitive.Item.Props & { title?: string }): React.ReactElement {
+const AutocompleteItem = React.forwardRef<
+ React.ComponentRef<typeof AutocompletePrimitive.Item>,
+ AutocompletePrimitive.Item.Props & { title?: string }
+>(function AutocompleteItem({ className, children, title, ...props }, ref) {
return (
<AutocompletePrimitive.Item
+ ref={ref}
data-slot="autocomplete-item"
className={cn('quill-autocomplete__item', className)}
title={title ?? (typeof children === 'string' ? children : undefined)}
@@ -183,51 +184,70 @@ function AutocompleteItem({
<span className="flex items-center gap-1.5 min-w-0 truncate">{children}</span>
</AutocompletePrimitive.Item>
)
-}
+})
-function AutocompleteGroup({ className, ...props }: AutocompletePrimitive.Group.Props): React.ReactElement {
- return <AutocompletePrimitive.Group data-slot="autocomplete-group" className={cn('pb-1', className)} {...props} />
-}
+const AutocompleteGroup = React.forwardRef<
+ React.ComponentRef<typeof AutocompletePrimitive.Group>,
+ AutocompletePrimitive.Group.Props
+>(function AutocompleteGroup({ className, ...props }, ref) {
+ return (
+ <AutocompletePrimitive.Group
+ ref={ref}
+ data-slot="autocomplete-group"
+ className={cn('pb-1', className)}
+ {...props}
+ />
+ )
+})
-function AutocompleteLabel({ className, ...props }: AutocompletePrimitive.GroupLabel.Props): React.ReactElement {
+const AutocompleteLabel = React.forwardRef<
+ React.ComponentRef<typeof AutocompletePrimitive.GroupLabel>,
+ AutocompletePrimitive.GroupLabel.Props
+>(function AutocompleteLabel({ className, ...props }, ref) {
return (
<AutocompletePrimitive.GroupLabel
+ ref={ref}
data-slot="autocomplete-label"
className={cn('quill-autocomplete__label mb-1 -mx-1 w-[calc(100%+var(--spacing)*2)]', className)}
render={<MenuLabel />}
{...props}
/>
)
-}
+})
function AutocompleteCollection({ ...props }: AutocompletePrimitive.Collection.Props): React.ReactElement {
return <AutocompletePrimitive.Collection data-slot="autocomplete-collection" {...props} />
}
-function AutocompleteEmpty({ className, ...props }: AutocompletePrimitive.Empty.Props): React.ReactElement {
+const AutocompleteEmpty = React.forwardRef<
+ React.ComponentRef<typeof AutocompletePrimitive.Empty>,
+ AutocompletePrimitive.Empty.Props
+>(function AutocompleteEmpty({ className, ...props }, ref) {
// Base UI renders the children only when nothing matches, so `empty:hidden` is the whole visibility rule.
return (
<AutocompletePrimitive.Empty
+ ref={ref}
data-slot="autocomplete-empty"
className={cn('empty:hidden', className)}
render={<MenuEmpty />}
{...props}
/>
)
-}
+})
-function AutocompleteSeparator({
- className,
- ...props
-}: AutocompletePrimitive.Separator.Props): React.ReactElement {
+const AutocompleteSeparator = React.forwardRef<
+ React.ComponentRef<typeof AutocompletePrimitive.Separator>,
+ AutocompletePrimitive.Separator.Props
+>(function AutocompleteSeparator({ className, ...props }, ref) {
return (
<AutocompletePrimitive.Separator
+ ref={ref}
data-slot="autocomplete-separator"
className={cn('quill-autocomplete__separator my-0', className)}
{...props}
/>
)
-}
+})
/**
* Walks `useFilteredItems` output and returns the total leaf count.
@@ -257,20 +277,18 @@ function countAutocompleteLeaves(items: unknown): number {
* MUST be rendered inside `<Autocomplete>` — `useFilteredItems` reads from
* Autocomplete's Root context and will throw if no provider is mounted.
*/
-function AutocompleteStatus({
- className,
- children,
- emptyContent,
- ...props
-}: Omit<AutocompletePrimitive.Status.Props, 'children'> & {
- /**
- * Override the default "{count} results" rendering. Pass a function to
- * receive the count; pass a node to render statically.
- */
- children?: React.ReactNode | ((count: number) => React.ReactNode)
- /** Rendered when the filtered count is zero. */
- emptyContent?: React.ReactNode
-}): React.ReactElement {
+const AutocompleteStatus = React.forwardRef<
+ React.ComponentRef<typeof AutocompletePrimitive.Status>,
+ Omit<AutocompletePrimitive.Status.Props, 'children'> & {
+ /**
+ * Override the default "{count} results" rendering. Pass a function to
+ * receive the count; pass a node to render statically.
+ */
+ children?: React.ReactNode | ((count: number) => React.ReactNode)
+ /** Rendered when the filtered count is zero. */
+ emptyContent?: React.ReactNode
+ }
+>(function AutocompleteStatus({ className, children, emptyContent, ...props }, ref) {
const filtered = AutocompletePrimitive.useFilteredItems<unknown>()
const count = countAutocompleteLeaves(filtered)
@@ -287,14 +305,18 @@ function AutocompleteStatus({
return (
<AutocompletePrimitive.Status
+ ref={ref}
data-slot="autocomplete-status"
- className={cn('quill-autocomplete__status bg-card border-b border-border text-xs text-muted-foreground px-2 py-1.5 empty:hidden', className)}
+ className={cn(
+ 'quill-autocomplete__status bg-card border-b border-border text-xs text-muted-foreground px-2 py-1.5 empty:hidden',
+ className
+ )}
{...props}
>
{content}
</AutocompletePrimitive.Status>
)
-}
+})
/**
* Hook returning the anchor ref so consumers (e.g. an external trigger)
diff --git a/packages/quill/packages/primitives/src/avatar.tsx b/packages/quill/packages/primitives/src/avatar.tsx
index 555f2ab7f4ff..c177a3ba12c4 100644
--- a/packages/quill/packages/primitives/src/avatar.tsx
+++ b/packages/quill/packages/primitives/src/avatar.tsx
@@ -56,18 +56,21 @@ const AvatarFallback = React.forwardRef<HTMLSpanElement, React.ComponentProps<ty
// `reverse` anchors the pile to its right edge and spreads left instead (and puts
// the rightmost avatar on top). `size` forwards to any Avatar child that doesn't
// set its own, and tunes the stacked overlap so small and default piles look right.
-function AvatarGroup({
- className,
- stacked = false,
- reverse = false,
- size = 'default',
- children,
- style,
- ...props
-}: React.ComponentProps<'div'> & { stacked?: boolean; reverse?: boolean; size?: AvatarSize }): React.ReactElement {
+const AvatarGroup = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & {
+ stacked?: boolean
+ reverse?: boolean
+ size?: AvatarSize
+ }
+>(function AvatarGroup(
+ { className, stacked = false, reverse = false, size = 'default', children, style, ...props },
+ ref
+) {
const items = React.Children.toArray(children)
return (
<div
+ ref={ref}
data-quill
data-slot="avatar-group"
data-stacked={stacked ? '' : undefined}
@@ -76,7 +79,12 @@ function AvatarGroup({
className={cn('quill-avatar-group', className)}
// Count drives the z-order and the reverse spread math; declared last so
// a caller's `style` can't clobber it.
- style={{ ...style, '--avatar-count': items.length } as React.CSSProperties}
+ style={
+ {
+ ...style,
+ '--avatar-count': items.length,
+ } as React.CSSProperties
+ }
{...props}
>
{items.map((child, index) => {
@@ -102,7 +110,7 @@ function AvatarGroup({
})}
</div>
)
-}
+})
Avatar.displayName = 'Avatar'
AvatarImage.displayName = 'AvatarImage'
diff --git a/packages/quill/packages/primitives/src/badge.tsx b/packages/quill/packages/primitives/src/badge.tsx
index 882347b3a381..36e8f313dd43 100644
--- a/packages/quill/packages/primitives/src/badge.tsx
+++ b/packages/quill/packages/primitives/src/badge.tsx
@@ -25,27 +25,25 @@ const badgeVariants = cva(
}
)
-function Badge({
- className,
- variant = 'default',
- render,
- ...props
-}: useRender.ComponentProps<'span'> & VariantProps<typeof badgeVariants>): React.ReactElement {
- return useRender({
- defaultTagName: 'span',
- props: mergeProps<'span'>(
- {
- 'data-quill': '',
- className: cn(badgeVariants({ variant }), className),
- } as Omit<React.ComponentProps<'span'>, 'ref'>,
- props
- ),
- render,
- state: {
- slot: 'badge',
- variant,
- },
- })
-}
+const Badge = React.forwardRef<HTMLSpanElement, useRender.ComponentProps<'span'> & VariantProps<typeof badgeVariants>>(
+ function Badge({ className, variant = 'default', render, ...props }, ref) {
+ return useRender({
+ ref,
+ defaultTagName: 'span',
+ props: mergeProps<'span'>(
+ {
+ 'data-quill': '',
+ className: cn(badgeVariants({ variant }), className),
+ } as Omit<React.ComponentProps<'span'>, 'ref'>,
+ props
+ ),
+ render,
+ state: {
+ slot: 'badge',
+ variant,
+ },
+ })
+ }
+)
export { Badge, badgeVariants }
diff --git a/packages/quill/packages/primitives/src/button-group.tsx b/packages/quill/packages/primitives/src/button-group.tsx
index ec1fc6e7b60b..423578f3049d 100644
--- a/packages/quill/packages/primitives/src/button-group.tsx
+++ b/packages/quill/packages/primitives/src/button-group.tsx
@@ -19,13 +19,13 @@ const buttonGroupVariants = cva('quill-button-group', {
},
})
-function ButtonGroup({
- className,
- orientation = 'horizontal',
- ...props
-}: React.ComponentProps<'div'> & VariantProps<typeof buttonGroupVariants>): React.ReactElement {
+const ButtonGroup = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & VariantProps<typeof buttonGroupVariants>
+>(function ButtonGroup({ className, orientation = 'horizontal', ...props }, ref) {
return (
<div
+ ref={ref}
role="group"
data-quill
data-slot="button-group"
@@ -34,10 +34,14 @@ function ButtonGroup({
{...props}
/>
)
-}
+})
-function ButtonGroupText({ className, render, ...props }: useRender.ComponentProps<'div'>): React.ReactElement {
+const ButtonGroupText = React.forwardRef<HTMLDivElement, useRender.ComponentProps<'div'>>(function ButtonGroupText(
+ { className, render, ...props },
+ ref
+) {
return useRender({
+ ref,
defaultTagName: 'div',
props: mergeProps<'div'>(
{
@@ -50,21 +54,21 @@ function ButtonGroupText({ className, render, ...props }: useRender.ComponentPro
slot: 'button-group-text',
},
})
-}
+})
-function ButtonGroupSeparator({
- className,
- orientation = 'vertical',
- ...props
-}: React.ComponentProps<typeof Separator>): React.ReactElement {
+const ButtonGroupSeparator = React.forwardRef<
+ React.ComponentRef<typeof Separator>,
+ React.ComponentProps<typeof Separator>
+>(function ButtonGroupSeparator({ className, orientation = 'vertical', ...props }, ref) {
return (
<Separator
+ ref={ref}
data-slot="button-group-separator"
orientation={orientation}
className={cn('quill-button-group__separator', className)}
{...props}
/>
)
-}
+})
export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants }
diff --git a/packages/quill/packages/primitives/src/card-group.tsx b/packages/quill/packages/primitives/src/card-group.tsx
index b2a4cd63bc0f..60cd4abbeaac 100644
--- a/packages/quill/packages/primitives/src/card-group.tsx
+++ b/packages/quill/packages/primitives/src/card-group.tsx
@@ -2,20 +2,19 @@ import * as React from 'react'
import { cn } from './lib/utils'
-function CardGroup({
- className,
- size = 'default',
- ...props
-}: React.ComponentProps<'div'> & { size?: 'default' | 'sm' }): React.ReactElement {
- return (
- <div
- data-quill
- data-slot="card-group"
- data-size={size}
- className={cn('quill-card-group group/card-group', className)}
- {...props}
- />
- )
-}
+const CardGroup = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'> & { size?: 'default' | 'sm' }>(
+ function CardGroup({ className, size = 'default', ...props }, ref) {
+ return (
+ <div
+ ref={ref}
+ data-quill
+ data-slot="card-group"
+ data-size={size}
+ className={cn('quill-card-group group/card-group', className)}
+ {...props}
+ />
+ )
+ }
+)
export { CardGroup }
diff --git a/packages/quill/packages/primitives/src/card.tsx b/packages/quill/packages/primitives/src/card.tsx
index 332dbc7c6f32..1c87855049f9 100644
--- a/packages/quill/packages/primitives/src/card.tsx
+++ b/packages/quill/packages/primitives/src/card.tsx
@@ -4,14 +4,13 @@ import * as React from 'react'
import { cn } from './lib/utils'
-function Card({
- className,
- size = 'default',
- flush = false,
- ...props
-}: React.ComponentProps<'div'> & { size?: 'default' | 'sm'; flush?: boolean }): React.ReactElement {
+const Card = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & { size?: 'default' | 'sm'; flush?: boolean }
+>(function Card({ className, size = 'default', flush = false, ...props }, ref) {
return (
<div
+ ref={ref}
data-quill
data-slot="card"
data-size={size}
@@ -20,31 +19,55 @@ function Card({
{...props}
/>
)
-}
+})
-function CardHeader({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="card-header" className={cn('quill-card__header group/card-header', className)} {...props} />
-}
+const CardHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function CardHeader(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div
+ ref={ref}
+ data-slot="card-header"
+ className={cn('quill-card__header group/card-header', className)}
+ {...props}
+ />
+ )
+})
const CardTitle = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(({ className, ...props }, ref) => (
<div ref={ref} data-slot="card-title" className={cn('quill-card__title', className)} {...props} />
))
CardTitle.displayName = 'CardTitle'
-function CardDescription({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="card-description" className={cn('quill-card__description', className)} {...props} />
-}
+const CardDescription = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function CardDescription(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div ref={ref} data-slot="card-description" className={cn('quill-card__description', className)} {...props} />
+ )
+})
-function CardAction({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="card-action" className={cn('quill-card__action', className)} {...props} />
-}
+const CardAction = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function CardAction(
+ { className, ...props },
+ ref
+) {
+ return <div ref={ref} data-slot="card-action" className={cn('quill-card__action', className)} {...props} />
+})
-function CardContent({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="card-content" className={cn('quill-card__content', className)} {...props} />
-}
+const CardContent = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function CardContent(
+ { className, ...props },
+ ref
+) {
+ return <div ref={ref} data-slot="card-content" className={cn('quill-card__content', className)} {...props} />
+})
-function CardFooter({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="card-footer" className={cn('quill-card__footer', className)} {...props} />
-}
+const CardFooter = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function CardFooter(
+ { className, ...props },
+ ref
+) {
+ return <div ref={ref} data-slot="card-footer" className={cn('quill-card__footer', className)} {...props} />
+})
export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent }
diff --git a/packages/quill/packages/primitives/src/chat/chat-bubble.tsx b/packages/quill/packages/primitives/src/chat/chat-bubble.tsx
index d691a33d6bdd..e100ef6b94b8 100644
--- a/packages/quill/packages/primitives/src/chat/chat-bubble.tsx
+++ b/packages/quill/packages/primitives/src/chat/chat-bubble.tsx
@@ -14,9 +14,20 @@ import { cn } from '../lib/utils'
* restyle per product. Assistant turns use `variant="ghost"` (transparent, full-width); user turns
* use a filled variant.
*/
-function ChatBubbleGroup({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-quill data-slot="bubble-group" className={cn('quill-chat-bubble-group', className)} {...props} />
-}
+const ChatBubbleGroup = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ChatBubbleGroup(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div
+ ref={ref}
+ data-quill
+ data-slot="bubble-group"
+ className={cn('quill-chat-bubble-group', className)}
+ {...props}
+ />
+ )
+})
const bubbleVariants = cva('quill-chat-bubble', {
variants: {
@@ -35,14 +46,13 @@ const bubbleVariants = cva('quill-chat-bubble', {
},
})
-function ChatBubble({
- variant = 'default',
- align = 'start',
- className,
- ...props
-}: React.ComponentProps<'div'> & VariantProps<typeof bubbleVariants> & { align?: 'start' | 'end' }): React.ReactElement {
+const ChatBubble = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & VariantProps<typeof bubbleVariants> & { align?: 'start' | 'end' }
+>(function ChatBubble({ variant = 'default', align = 'start', className, ...props }, ref) {
return (
<div
+ ref={ref}
data-quill
data-slot="bubble"
data-variant={variant}
@@ -51,10 +61,14 @@ function ChatBubble({
{...props}
/>
)
-}
+})
-function ChatBubbleContent({ className, render, ...props }: useRender.ComponentProps<'div'>): React.ReactElement {
+const ChatBubbleContent = React.forwardRef<HTMLDivElement, useRender.ComponentProps<'div'>>(function ChatBubbleContent(
+ { className, render, ...props },
+ ref
+) {
return useRender({
+ ref,
defaultTagName: 'div',
props: mergeProps<'div'>(
{
@@ -68,16 +82,18 @@ function ChatBubbleContent({ className, render, ...props }: useRender.ComponentP
slot: 'bubble-content',
},
})
-}
+})
-function ChatBubbleReactions({
- side = 'bottom',
- align = 'end',
- className,
- ...props
-}: React.ComponentProps<'div'> & { align?: 'start' | 'end'; side?: 'top' | 'bottom' }): React.ReactElement {
+const ChatBubbleReactions = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & {
+ align?: 'start' | 'end'
+ side?: 'top' | 'bottom'
+ }
+>(function ChatBubbleReactions({ side = 'bottom', align = 'end', className, ...props }, ref) {
return (
<div
+ ref={ref}
data-slot="bubble-reactions"
data-align={align}
data-side={side}
@@ -85,6 +101,6 @@ function ChatBubbleReactions({
{...props}
/>
)
-}
+})
export { ChatBubbleGroup, ChatBubble, ChatBubbleContent, ChatBubbleReactions, bubbleVariants }
diff --git a/packages/quill/packages/primitives/src/chat/chat-globe.tsx b/packages/quill/packages/primitives/src/chat/chat-globe.tsx
index 2314dcd07e20..cd6a399a7d3c 100644
--- a/packages/quill/packages/primitives/src/chat/chat-globe.tsx
+++ b/packages/quill/packages/primitives/src/chat/chat-globe.tsx
@@ -43,11 +43,15 @@ const DURATION = '7.2s'
const STARTS = ['0s', '-1.2s', '-2.4s', '-3.6s', '-4.8s', '-6s']
const EASE_IN_OUT = '0.42 0 0.58 1'
-function ChatGlobe({ className, ...props }: React.ComponentProps<'svg'>): React.ReactElement {
+const ChatGlobe = React.forwardRef<SVGSVGElement, React.ComponentProps<'svg'>>(function ChatGlobe(
+ { className, ...props },
+ ref
+) {
const reducedMotion = useReducedMotion()
return (
<svg
+ ref={ref}
data-quill
data-slot="globe"
viewBox={VIEW_BOX}
@@ -99,6 +103,6 @@ function ChatGlobe({ className, ...props }: React.ComponentProps<'svg'>): React.
)}
</svg>
)
-}
+})
export { ChatGlobe }
diff --git a/packages/quill/packages/primitives/src/chat/chat-marker.tsx b/packages/quill/packages/primitives/src/chat/chat-marker.tsx
index db9c5826bae0..e807081de537 100644
--- a/packages/quill/packages/primitives/src/chat/chat-marker.tsx
+++ b/packages/quill/packages/primitives/src/chat/chat-marker.tsx
@@ -61,26 +61,34 @@ type ChatMarkerProps = useRender.ComponentProps<'div'> &
onOpenChange?: (open: boolean) => void
}
-function ChatMarker({ body, ...props }: ChatMarkerProps): React.ReactElement {
+const ChatMarker = React.forwardRef<HTMLDivElement, ChatMarkerProps>(function ChatMarker({ body, ...props }, ref) {
// Every value React renders as nothing means there's nothing to disclose. `body == null` alone
// would miss `body={items.length > 0 && <List />}`, the usual way to pass one conditionally, and
// give the row a chevron that opens onto an empty panel.
const hasBody = body != null && body !== false && body !== ''
- return hasBody ? <ChatMarkerCollapsible body={body} {...props} /> : <ChatMarkerFlat {...props} />
-}
+ return hasBody ? (
+ <ChatMarkerCollapsible ref={ref} body={body} {...props} />
+ ) : (
+ <ChatMarkerFlat ref={ref} {...props} />
+ )
+})
-function ChatMarkerFlat({
- className,
- variant = 'default',
- status,
- render,
- // `body`/collapse props are accepted by ChatMarker but inert in the flat path.
- defaultOpen: _defaultOpen,
- open: _open,
- onOpenChange: _onOpenChange,
- ...props
-}: ChatMarkerProps): React.ReactElement {
+const ChatMarkerFlat = React.forwardRef<HTMLDivElement, ChatMarkerProps>(function ChatMarkerFlat(
+ {
+ className,
+ variant = 'default',
+ status,
+ render,
+ // `body`/collapse props are accepted by ChatMarker but inert in the flat path.
+ defaultOpen: _defaultOpen,
+ open: _open,
+ onOpenChange: _onOpenChange,
+ ...props
+ },
+ ref
+) {
const row = useRender({
+ ref,
defaultTagName: 'div',
props: mergeProps<'div'>(
{
@@ -101,23 +109,16 @@ function ChatMarkerFlat({
})
return <ChatMarkerContext.Provider value={status}>{row}</ChatMarkerContext.Provider>
-}
+})
-function ChatMarkerCollapsible({
- className,
- variant = 'default',
- status,
- body,
- defaultOpen,
- open,
- onOpenChange,
- children,
- render,
- ...props
-}: ChatMarkerProps): React.ReactElement {
+const ChatMarkerCollapsible = React.forwardRef<HTMLDivElement, ChatMarkerProps>(function ChatMarkerCollapsible(
+ { className, variant = 'default', status, body, defaultOpen, open, onOpenChange, children, render, ...props },
+ ref
+) {
return (
<ChatMarkerContext.Provider value={status}>
<CollapsiblePrimitive.Root
+ ref={ref}
data-quill
data-slot="marker"
data-variant={variant}
@@ -152,33 +153,44 @@ function ChatMarkerCollapsible({
</CollapsiblePrimitive.Root>
</ChatMarkerContext.Provider>
)
-}
+})
-function ChatMarkerIcon({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+const ChatMarkerIcon = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(function ChatMarkerIcon(
+ { className, ...props },
+ ref
+) {
return (
<span
+ ref={ref}
data-slot="marker-icon"
aria-hidden="true"
className={cn('quill-chat-marker__icon', className)}
{...props}
/>
)
-}
+})
-function ChatMarkerContent({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+const ChatMarkerContent = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(function ChatMarkerContent(
+ { className, ...props },
+ ref
+) {
const status = React.useContext(ChatMarkerContext)
return (
<span
+ ref={ref}
data-slot="marker-content"
className={cn('quill-chat-marker__content', status === 'running' && 'quill-shimmer', className)}
{...props}
/>
)
-}
+})
/** The argument a call acted on — a query, a path, a command. Quoted, and kept once it settles. */
-function ChatMarkerValue({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return <span data-slot="marker-value" className={cn('quill-chat-marker__value', className)} {...props} />
-}
+const ChatMarkerValue = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(function ChatMarkerValue(
+ { className, ...props },
+ ref
+) {
+ return <span ref={ref} data-slot="marker-value" className={cn('quill-chat-marker__value', className)} {...props} />
+})
export { ChatMarker, ChatMarkerIcon, ChatMarkerContent, ChatMarkerValue, markerVariants, type ChatMarkerStatus }
diff --git a/packages/quill/packages/primitives/src/chat/chat-message-scroller.tsx b/packages/quill/packages/primitives/src/chat/chat-message-scroller.tsx
index 27de180cc864..d75be9b849a8 100644
--- a/packages/quill/packages/primitives/src/chat/chat-message-scroller.tsx
+++ b/packages/quill/packages/primitives/src/chat/chat-message-scroller.tsx
@@ -25,85 +25,85 @@ function ChatMessageScrollerProvider(
return <MessageScrollerPrimitive.Provider {...props} />
}
-function ChatMessageScroller({
- className,
- ...props
-}: React.ComponentProps<typeof MessageScrollerPrimitive.Root>): React.ReactElement {
+const ChatMessageScroller = React.forwardRef<
+ React.ComponentRef<typeof MessageScrollerPrimitive.Root>,
+ React.ComponentProps<typeof MessageScrollerPrimitive.Root>
+>(function ChatMessageScroller({ className, ...props }, ref) {
return (
<MessageScrollerPrimitive.Root
+ ref={ref}
data-quill
data-slot="chat-message-scroller"
className={cn('quill-chat-message-scroller group/chat-message-scroller', className)}
{...props}
/>
)
-}
+})
-function ChatMessageScrollerViewport({
- className,
- ...props
-}: React.ComponentProps<typeof MessageScrollerPrimitive.Viewport>): React.ReactElement {
+const ChatMessageScrollerViewport = React.forwardRef<
+ React.ComponentRef<typeof MessageScrollerPrimitive.Viewport>,
+ React.ComponentProps<typeof MessageScrollerPrimitive.Viewport>
+>(function ChatMessageScrollerViewport({ className, ...props }, ref) {
return (
<MessageScrollerPrimitive.Viewport
+ ref={ref}
data-slot="chat-message-scroller-viewport"
className={cn('quill-chat-message-scroller__viewport', className)}
{...props}
/>
)
-}
+})
type ChatMessageScrollerContentProps = React.ComponentProps<typeof MessageScrollerPrimitive.Content> & {
/** Row spacing: `dense` 0.5rem, `default` 1rem, `loose` 1.5rem. */
density?: 'dense' | 'default' | 'loose'
}
-function ChatMessageScrollerContent({
- className,
- density = 'default',
- ...props
-}: ChatMessageScrollerContentProps): React.ReactElement {
+const ChatMessageScrollerContent = React.forwardRef<
+ React.ComponentRef<typeof MessageScrollerPrimitive.Content>,
+ ChatMessageScrollerContentProps
+>(function ChatMessageScrollerContent({ className, density = 'default', ...props }, ref) {
return (
<MessageScrollerPrimitive.Content
+ ref={ref}
data-slot="chat-message-scroller-content"
data-density={density}
className={cn('quill-chat-message-scroller__content', className)}
{...props}
/>
)
-}
+})
/**
* One transcript row. `scrollAnchor` marks turn boundaries (the engine pins anchored rows near the
* viewport top on new turns). Off-screen size estimate is tuned in `chat-message-scroller.css`.
*/
-function ChatMessageScrollerItem({
- className,
- scrollAnchor = false,
- ...props
-}: React.ComponentProps<typeof MessageScrollerPrimitive.Item>): React.ReactElement {
+const ChatMessageScrollerItem = React.forwardRef<
+ React.ComponentRef<typeof MessageScrollerPrimitive.Item>,
+ React.ComponentProps<typeof MessageScrollerPrimitive.Item>
+>(function ChatMessageScrollerItem({ className, scrollAnchor = false, ...props }, ref) {
return (
<MessageScrollerPrimitive.Item
+ ref={ref}
data-slot="chat-message-scroller-item"
scrollAnchor={scrollAnchor}
className={cn('quill-chat-message-scroller__item', className)}
{...props}
/>
)
-}
+})
/**
* Scroll-to-edge control. The engine toggles `data-active` from imperative scroll tracking;
* visibility/animation is pure CSS off that attribute.
*/
-function ChatMessageScrollerButton({
- direction = 'end',
- className,
- children,
- render,
- ...props
-}: React.ComponentProps<typeof MessageScrollerPrimitive.Button>): React.ReactElement {
+const ChatMessageScrollerButton = React.forwardRef<
+ React.ComponentRef<typeof MessageScrollerPrimitive.Button>,
+ React.ComponentProps<typeof MessageScrollerPrimitive.Button>
+>(function ChatMessageScrollerButton({ direction = 'end', className, children, render, ...props }, ref) {
return (
<MessageScrollerPrimitive.Button
+ ref={ref}
data-slot="chat-message-scroller-button"
data-direction={direction}
direction={direction}
@@ -119,7 +119,7 @@ function ChatMessageScrollerButton({
)}
</MessageScrollerPrimitive.Button>
)
-}
+})
export {
ChatMessageScrollerProvider,
diff --git a/packages/quill/packages/primitives/src/chat/chat-message.tsx b/packages/quill/packages/primitives/src/chat/chat-message.tsx
index a6a99bd337a5..4558b3235d0c 100644
--- a/packages/quill/packages/primitives/src/chat/chat-message.tsx
+++ b/packages/quill/packages/primitives/src/chat/chat-message.tsx
@@ -10,41 +10,76 @@ import { cn } from '../lib/utils'
*
* Anatomy: ChatMessage > [ChatMessageAvatar] + ChatMessageContent > [Header] + Bubble + [Footer]
*/
-function ChatMessageGroup({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-quill data-slot="message-group" className={cn('quill-chat-message-group', className)} {...props} />
-}
-
-function ChatMessage({
- className,
- align = 'start',
- ...props
-}: React.ComponentProps<'div'> & { align?: 'start' | 'end' }): React.ReactElement {
+const ChatMessageGroup = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ChatMessageGroup(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-quill
- data-slot="message"
- data-align={align}
- className={cn('quill-chat-message', className)}
+ data-slot="message-group"
+ className={cn('quill-chat-message-group', className)}
{...props}
/>
)
-}
+})
-function ChatMessageAvatar({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="message-avatar" className={cn('quill-chat-message__avatar', className)} {...props} />
-}
+const ChatMessage = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'> & { align?: 'start' | 'end' }>(
+ function ChatMessage({ className, align = 'start', ...props }, ref) {
+ return (
+ <div
+ ref={ref}
+ data-quill
+ data-slot="message"
+ data-align={align}
+ className={cn('quill-chat-message', className)}
+ {...props}
+ />
+ )
+ }
+)
-function ChatMessageContent({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="message-content" className={cn('quill-chat-message__content', className)} {...props} />
-}
+const ChatMessageAvatar = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ChatMessageAvatar(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div ref={ref} data-slot="message-avatar" className={cn('quill-chat-message__avatar', className)} {...props} />
+ )
+})
-function ChatMessageHeader({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="message-header" className={cn('quill-chat-message__header', className)} {...props} />
-}
+const ChatMessageContent = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ChatMessageContent(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div
+ ref={ref}
+ data-slot="message-content"
+ className={cn('quill-chat-message__content', className)}
+ {...props}
+ />
+ )
+})
-function ChatMessageFooter({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="message-footer" className={cn('quill-chat-message__footer', className)} {...props} />
-}
+const ChatMessageHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ChatMessageHeader(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div ref={ref} data-slot="message-header" className={cn('quill-chat-message__header', className)} {...props} />
+ )
+})
+
+const ChatMessageFooter = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ChatMessageFooter(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div ref={ref} data-slot="message-footer" className={cn('quill-chat-message__footer', className)} {...props} />
+ )
+})
export {
ChatMessageGroup,
diff --git a/packages/quill/packages/primitives/src/chat/chat-source.tsx b/packages/quill/packages/primitives/src/chat/chat-source.tsx
index 6fe3e6e5512f..94be1e0fb0a2 100644
--- a/packages/quill/packages/primitives/src/chat/chat-source.tsx
+++ b/packages/quill/packages/primitives/src/chat/chat-source.tsx
@@ -27,24 +27,32 @@ const STATUS_ICON: Record<ChatSourceStatus, React.ReactElement> = {
done: <CircleCheckIcon />,
}
-function ChatSourceList({ className, ...props }: React.ComponentProps<'ul'>): React.ReactElement {
- return <ul data-quill data-slot="source-list" className={cn('quill-chat-source-list', className)} {...props} />
-}
+const ChatSourceList = React.forwardRef<HTMLUListElement, React.ComponentProps<'ul'>>(function ChatSourceList(
+ { className, ...props },
+ ref
+) {
+ return (
+ <ul
+ ref={ref}
+ data-quill
+ data-slot="source-list"
+ className={cn('quill-chat-source-list', className)}
+ {...props}
+ />
+ )
+})
type ChatSourceProps = useRender.ComponentProps<'a'> & {
status?: ChatSourceStatus
href?: string
}
-function ChatSource({
- status = 'pending',
- className,
- children,
- href,
- render,
- ...props
-}: ChatSourceProps): React.ReactElement {
+const ChatSource = React.forwardRef<HTMLElement, ChatSourceProps>(function ChatSource(
+ { status = 'pending', className, children, href, render, ...props },
+ ref
+) {
const row = useRender({
+ ref,
defaultTagName: href == null ? 'span' : 'a',
props: mergeProps<'a'>(
{
@@ -73,14 +81,20 @@ function ChatSource({
{row}
</li>
)
-}
+})
-function ChatSourceTitle({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return <span data-slot="source-title" className={cn('quill-chat-source__title', className)} {...props} />
-}
+const ChatSourceTitle = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(function ChatSourceTitle(
+ { className, ...props },
+ ref
+) {
+ return <span ref={ref} data-slot="source-title" className={cn('quill-chat-source__title', className)} {...props} />
+})
-function ChatSourceUrl({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return <span data-slot="source-url" className={cn('quill-chat-source__url', className)} {...props} />
-}
+const ChatSourceUrl = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(function ChatSourceUrl(
+ { className, ...props },
+ ref
+) {
+ return <span ref={ref} data-slot="source-url" className={cn('quill-chat-source__url', className)} {...props} />
+})
export { ChatSourceList, ChatSource, ChatSourceTitle, ChatSourceUrl, type ChatSourceStatus }
diff --git a/packages/quill/packages/primitives/src/chat/chat-stream.tsx b/packages/quill/packages/primitives/src/chat/chat-stream.tsx
index 8efa7c256002..0e5138d9e43a 100644
--- a/packages/quill/packages/primitives/src/chat/chat-stream.tsx
+++ b/packages/quill/packages/primitives/src/chat/chat-stream.tsx
@@ -25,8 +25,12 @@ type ChatStreamProps = React.ComponentProps<'div'> & {
pinned?: boolean
}
-function ChatStream({ pinned = false, className, children, onScroll, ...props }: ChatStreamProps): React.ReactElement {
+const ChatStream = React.forwardRef<HTMLDivElement, ChatStreamProps>(function ChatStream(
+ { pinned = false, className, children, onScroll, ...props },
+ ref
+) {
const viewportRef = React.useRef<HTMLDivElement>(null)
+ React.useImperativeHandle(ref, () => viewportRef.current as HTMLDivElement, [])
const streamRef = React.useRef<HTMLDivElement>(null)
/*
@@ -160,11 +164,14 @@ function ChatStream({ pinned = false, className, children, onScroll, ...props }:
</div>
</div>
)
-}
+})
/** One line of output. Reveals itself as it arrives, while the stream is pinned. */
-function ChatStreamLine({ className, ...props }: React.ComponentProps<'p'>): React.ReactElement {
- return <p data-slot="stream-line" className={cn('quill-chat-stream__line', className)} {...props} />
-}
+const ChatStreamLine = React.forwardRef<HTMLParagraphElement, React.ComponentProps<'p'>>(function ChatStreamLine(
+ { className, ...props },
+ ref
+) {
+ return <p ref={ref} data-slot="stream-line" className={cn('quill-chat-stream__line', className)} {...props} />
+})
export { ChatStream, ChatStreamLine }
diff --git a/packages/quill/packages/primitives/src/chat/chat-task-list.tsx b/packages/quill/packages/primitives/src/chat/chat-task-list.tsx
index 88c0a2f783c9..24060aa69433 100644
--- a/packages/quill/packages/primitives/src/chat/chat-task-list.tsx
+++ b/packages/quill/packages/primitives/src/chat/chat-task-list.tsx
@@ -62,28 +62,31 @@ type ChatTaskListProps = React.ComponentProps<typeof CollapsiblePrimitive.Root>
total: number
}
-function ChatTaskList({ value, total, className, ...props }: ChatTaskListProps): React.ReactElement {
- const context = React.useMemo(() => ({ value, total }), [value, total])
+const ChatTaskList = React.forwardRef<React.ComponentRef<typeof CollapsiblePrimitive.Root>, ChatTaskListProps>(
+ function ChatTaskList({ value, total, className, ...props }, ref) {
+ const context = React.useMemo(() => ({ value, total }), [value, total])
- return (
- <ChatTaskListContext.Provider value={context}>
- <CollapsiblePrimitive.Root
- data-quill
- data-slot="task-list"
- className={cn('quill-chat-task-list', className)}
- {...props}
- />
- </ChatTaskListContext.Provider>
- )
-}
+ return (
+ <ChatTaskListContext.Provider value={context}>
+ <CollapsiblePrimitive.Root
+ ref={ref}
+ data-quill
+ data-slot="task-list"
+ className={cn('quill-chat-task-list', className)}
+ {...props}
+ />
+ </ChatTaskListContext.Provider>
+ )
+ }
+)
-function ChatTaskListTrigger({
- className,
- children,
- ...props
-}: React.ComponentProps<typeof CollapsiblePrimitive.Trigger>): React.ReactElement {
+const ChatTaskListTrigger = React.forwardRef<
+ React.ComponentRef<typeof CollapsiblePrimitive.Trigger>,
+ React.ComponentProps<typeof CollapsiblePrimitive.Trigger>
+>(function ChatTaskListTrigger({ className, children, ...props }, ref) {
return (
<CollapsiblePrimitive.Trigger
+ ref={ref}
data-slot="task-list-trigger"
className={cn('quill-chat-row', 'quill-chat-row--interactive', 'quill-chat-task-list__trigger', className)}
{...props}
@@ -91,7 +94,7 @@ function ChatTaskListTrigger({
{children}
</CollapsiblePrimitive.Trigger>
)
-}
+})
/**
* The header's at-a-glance state: a list before anything starts, a ring that fills as steps land, a
@@ -102,36 +105,39 @@ function ChatTaskListTrigger({
* rest; the chevron only matters once you've reached for it, so it doesn't need to sit there
* permanently taking up the row.
*/
-function ChatTaskListProgress({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- const { value, total } = useChatTaskListContext('ChatTaskListProgress')
- const done = total > 0 && value >= total
+const ChatTaskListProgress = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(
+ function ChatTaskListProgress({ className, ...props }, ref) {
+ const { value, total } = useChatTaskListContext('ChatTaskListProgress')
+ const done = total > 0 && value >= total
- return (
- <span
- data-slot="task-list-progress"
- aria-hidden="true"
- className={cn('quill-chat-swap', 'quill-chat-task-list__progress', className)}
- {...props}
- >
+ return (
<span
- data-slot="task-list-progress-icon"
- data-status={done ? 'done' : undefined}
- className={cn('quill-chat-bullet', 'quill-chat-swap__icon')}
+ ref={ref}
+ data-slot="task-list-progress"
+ aria-hidden="true"
+ className={cn('quill-chat-swap', 'quill-chat-task-list__progress', className)}
+ {...props}
>
- {/* No steps yet, or no plan at all: a list, not a ring of nothing. Guarding `total`
+ <span
+ data-slot="task-list-progress-icon"
+ data-status={done ? 'done' : undefined}
+ className={cn('quill-chat-bullet', 'quill-chat-swap__icon')}
+ >
+ {/* No steps yet, or no plan at all: a list, not a ring of nothing. Guarding `total`
here also keeps the ring's percentage from dividing by zero. */}
- {value <= 0 || total <= 0 ? (
- <ListIcon />
- ) : done ? (
- <CircleCheckIcon />
- ) : (
- <ProgressRing value={value} total={total} />
- )}
+ {value <= 0 || total <= 0 ? (
+ <ListIcon />
+ ) : done ? (
+ <CircleCheckIcon />
+ ) : (
+ <ProgressRing value={value} total={total} />
+ )}
+ </span>
+ <ChevronRightIcon aria-hidden="true" className={cn('quill-chat-chevron', 'quill-chat-swap__chevron')} />
</span>
- <ChevronRightIcon aria-hidden="true" className={cn('quill-chat-chevron', 'quill-chat-swap__chevron')} />
- </span>
- )
-}
+ )
+ }
+)
function ProgressRing({ value, total }: { value: number; total: number }): React.ReactElement {
// `pathLength` renormalizes the circle to 100 user units, so the arc is the percentage itself —
@@ -165,20 +171,33 @@ function ProgressRing({ value, total }: { value: number; total: number }): React
)
}
-function ChatTaskListLabel({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return <span data-slot="task-list-label" className={cn('quill-chat-task-list__label', className)} {...props} />
-}
+const ChatTaskListLabel = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(function ChatTaskListLabel(
+ { className, ...props },
+ ref
+) {
+ return (
+ <span
+ ref={ref}
+ data-slot="task-list-label"
+ className={cn('quill-chat-task-list__label', className)}
+ {...props}
+ />
+ )
+})
/**
* `2/5`, where each digit rolls to its successor. The rolling glyphs are decorative — the real value
* goes to screen readers once, as text, instead of announcing a half-rolled pair.
*/
-function ChatTaskListCount({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+const ChatTaskListCount = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(function ChatTaskListCount(
+ { className, ...props },
+ ref
+) {
const { value, total } = useChatTaskListContext('ChatTaskListCount')
const shown = `${Math.min(Math.max(value, 0), total)}/${total}`
return (
- <span data-slot="task-list-count" className={cn('quill-chat-task-list__count', className)} {...props}>
+ <span ref={ref} data-slot="task-list-count" className={cn('quill-chat-task-list__count', className)} {...props}>
<span className="sr-only">
{Math.min(Math.max(value, 0), total)} of {total} done
</span>
@@ -191,7 +210,7 @@ function ChatTaskListCount({ className, ...props }: React.ComponentProps<'span'>
</span>
</span>
)
-}
+})
const ROLL_MS = 250
@@ -228,18 +247,26 @@ function RollingChar({ char }: { char: string }): React.ReactElement {
)
}
-function ChatTaskListContent({ className, children, ...props }: React.ComponentProps<'ol'>): React.ReactElement {
+const ChatTaskListContent = React.forwardRef<HTMLOListElement, React.ComponentProps<'ol'>>(function ChatTaskListContent(
+ { className, children, ...props },
+ ref
+) {
return (
<CollapsiblePrimitive.Panel
data-slot="task-list-panel"
className={cn('quill-chat-collapse', 'quill-chat-rail', 'quill-chat-task-list__panel')}
>
- <ol data-slot="task-list-items" className={cn('quill-chat-task-list__items', className)} {...props}>
+ <ol
+ ref={ref}
+ data-slot="task-list-items"
+ className={cn('quill-chat-task-list__items', className)}
+ {...props}
+ >
{children}
</ol>
</CollapsiblePrimitive.Panel>
)
-}
+})
type ChatTaskProps = React.ComponentProps<'li'> & {
status?: ChatTaskStatus
@@ -247,15 +274,13 @@ type ChatTaskProps = React.ComponentProps<'li'> & {
truncate?: boolean
}
-function ChatTask({
- status = 'pending',
- truncate = false,
- className,
- children,
- ...props
-}: ChatTaskProps): React.ReactElement {
+const ChatTask = React.forwardRef<HTMLLIElement, ChatTaskProps>(function ChatTask(
+ { status = 'pending', truncate = false, className, children, ...props },
+ ref
+) {
return (
<li
+ ref={ref}
data-slot="task"
data-status={status}
className={cn('quill-chat-task', truncate && 'quill-chat-task--truncate', className)}
@@ -274,12 +299,15 @@ function ChatTask({
</span>
</li>
)
-}
+})
/** What the step produced: a duration, an exit code, the line that explains a failure. */
-function ChatTaskDetail({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return <span data-slot="task-detail" className={cn('quill-chat-task__detail', className)} {...props} />
-}
+const ChatTaskDetail = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(function ChatTaskDetail(
+ { className, ...props },
+ ref
+) {
+ return <span ref={ref} data-slot="task-detail" className={cn('quill-chat-task__detail', className)} {...props} />
+})
export {
ChatTaskList,
diff --git a/packages/quill/packages/primitives/src/chat/questionnaire.tsx b/packages/quill/packages/primitives/src/chat/questionnaire.tsx
index e8c8221d7bc2..c37f257b8ce3 100644
--- a/packages/quill/packages/primitives/src/chat/questionnaire.tsx
+++ b/packages/quill/packages/primitives/src/chat/questionnaire.tsx
@@ -31,103 +31,113 @@ import { cn } from '../lib/utils'
* native radios and checkboxes under an invisible overlay, which is what keeps arrow-key roving and
* form participation working while the whole row stays the hit target.
*/
-function Questionnaire({
- className,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Root>): React.ReactElement {
+const Questionnaire = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Root>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Root>
+>(function Questionnaire({ className, ...props }, ref) {
return (
<QuestionnairePrimitive.Root
+ ref={ref}
data-quill
data-slot="questionnaire"
className={cn('quill-questionnaire', className)}
{...props}
/>
)
-}
+})
/** `Question 2 of 5` by default; pass children to word it differently. */
-function QuestionnaireProgress({
- className,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Progress>): React.ReactElement {
+const QuestionnaireProgress = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Progress>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Progress>
+>(function QuestionnaireProgress({ className, ...props }, ref) {
return (
<QuestionnairePrimitive.Progress
+ ref={ref}
data-slot="questionnaire-progress"
className={cn('quill-questionnaire__progress', className)}
{...props}
/>
)
-}
+})
/**
* One question. `name` is the key its answer arrives under and must be unique in the root. Only the
* active item is rendered visibly — the engine hides and inerts the rest, so all of them can stay
* mounted and keep their answers.
*/
-function QuestionnaireItem({
- className,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Item>): React.ReactElement {
+const QuestionnaireItem = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Item>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Item>
+>(function QuestionnaireItem({ className, ...props }, ref) {
return (
<QuestionnairePrimitive.Item
+ ref={ref}
data-slot="questionnaire-item"
className={cn('quill-questionnaire__item', className)}
{...props}
/>
)
-}
+})
-function QuestionnaireTitle({
- className,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Title>): React.ReactElement {
+const QuestionnaireTitle = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Title>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Title>
+>(function QuestionnaireTitle({ className, ...props }, ref) {
return (
<QuestionnairePrimitive.Title
+ ref={ref}
data-slot="questionnaire-title"
className={cn('quill-questionnaire__title', className)}
{...props}
/>
)
-}
+})
-function QuestionnaireDescription({
- className,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Description>): React.ReactElement {
+const QuestionnaireDescription = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Description>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Description>
+>(function QuestionnaireDescription({ className, ...props }, ref) {
return (
<QuestionnairePrimitive.Description
+ ref={ref}
data-slot="questionnaire-description"
className={cn('quill-questionnaire__description', className)}
{...props}
/>
)
-}
+})
-function QuestionnaireChoices({
- className,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Choices>): React.ReactElement {
+const QuestionnaireChoices = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Choices>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Choices>
+>(function QuestionnaireChoices({ className, ...props }, ref) {
return (
<QuestionnairePrimitive.Choices
+ ref={ref}
data-slot="questionnaire-choices"
className={cn('quill-questionnaire__choices', className)}
{...props}
/>
)
-}
+})
/**
* One fixed answer. The row assembles its own parts — the overlaid control, the indicator, the label
* children, and the shortcut key — so a caller only writes the answer's text. The indicator draws
* itself off the row's `data-type`: a dot for a radio, a check for a checkbox.
*/
-function QuestionnaireChoice({
- children,
- className,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Choice>): React.ReactElement {
+// Annotated so the emitted .d.ts names the public `typeof` instead of the package's private props chunk.
+const QuestionnaireChoice: React.ForwardRefExoticComponent<
+ React.ComponentPropsWithoutRef<typeof QuestionnairePrimitive.Choice> &
+ React.RefAttributes<React.ComponentRef<typeof QuestionnairePrimitive.Choice>>
+> = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Choice>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Choice>
+>(function QuestionnaireChoice({ children, className, ...props }, ref) {
return (
<QuestionnairePrimitive.Choice
+ ref={ref}
data-slot="questionnaire-choice"
className={cn('quill-questionnaire__choice', className)}
{...props}
@@ -165,18 +175,21 @@ function QuestionnaireChoice({
/>
</QuestionnairePrimitive.Choice>
)
-}
+})
/** The muted second line of an answer — what picking it means. */
-function QuestionnaireChoiceDescription({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return (
- <span
- data-slot="questionnaire-choice-description"
- className={cn('quill-questionnaire__choice-description', className)}
- {...props}
- />
- )
-}
+const QuestionnaireChoiceDescription = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(
+ function QuestionnaireChoiceDescription({ className, ...props }, ref) {
+ return (
+ <span
+ ref={ref}
+ data-slot="questionnaire-choice-description"
+ className={cn('quill-questionnaire__choice-description', className)}
+ {...props}
+ />
+ )
+ }
+)
/**
* A freeform answer alongside the fixed ones. It takes its `name` from the item, so it competes with
@@ -187,14 +200,18 @@ function QuestionnaireChoiceDescription({ className, ...props }: React.Component
* rather than a field that happens to sit under the answers. The indicator takes its shape from the
* choices beside it — round for radios, square for checkboxes.
*/
-function QuestionnaireInput({
- className,
- render,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Input>): React.ReactElement {
+// Annotated so the emitted .d.ts names the public `typeof` instead of the package's private props chunk.
+const QuestionnaireInput: React.ForwardRefExoticComponent<
+ React.ComponentPropsWithoutRef<typeof QuestionnairePrimitive.Input> &
+ React.RefAttributes<React.ComponentRef<typeof QuestionnairePrimitive.Input>>
+> = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Input>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Input>
+>(function QuestionnaireInput({ className, render, ...props }, ref) {
return (
<div data-slot="questionnaire-input-wrapper" className="quill-questionnaire__input-wrapper">
<QuestionnairePrimitive.Input
+ ref={ref}
data-slot="questionnaire-input"
className={className}
render={
@@ -229,37 +246,44 @@ function QuestionnaireInput({
/>
</div>
)
-}
+})
/** The engine's own message by default; pass children for a question-specific one. */
-function QuestionnaireError({
- className,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Error>): React.ReactElement {
+const QuestionnaireError = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Error>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Error>
+>(function QuestionnaireError({ className, ...props }, ref) {
return (
<QuestionnairePrimitive.Error
+ ref={ref}
data-slot="questionnaire-error"
className={cn('quill-questionnaire__error', className)}
{...props}
/>
)
-}
+})
/** Layout only — the row Previous, Skip, and Next/Submit sit in. It holds no state. */
-function QuestionnaireActions({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return (
- <div data-slot="questionnaire-actions" className={cn('quill-questionnaire__actions', className)} {...props} />
- )
-}
+const QuestionnaireActions = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
+ function QuestionnaireActions({ className, ...props }, ref) {
+ return (
+ <div
+ ref={ref}
+ data-slot="questionnaire-actions"
+ className={cn('quill-questionnaire__actions', className)}
+ {...props}
+ />
+ )
+ }
+)
-function QuestionnairePrevious({
- children,
- className,
- render,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Previous>): React.ReactElement {
+const QuestionnairePrevious = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Previous>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Previous>
+>(function QuestionnairePrevious({ children, className, render, ...props }, ref) {
return (
<QuestionnairePrimitive.Previous
+ ref={ref}
data-slot="questionnaire-previous"
className={cn('quill-questionnaire__previous', className)}
render={render ?? <Button variant="outline" />}
@@ -268,16 +292,15 @@ function QuestionnairePrevious({
{children ?? 'Previous'}
</QuestionnairePrimitive.Previous>
)
-}
+})
-function QuestionnaireSkip({
- children,
- className,
- render,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Skip>): React.ReactElement {
+const QuestionnaireSkip = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Skip>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Skip>
+>(function QuestionnaireSkip({ children, className, render, ...props }, ref) {
return (
<QuestionnairePrimitive.Skip
+ ref={ref}
data-slot="questionnaire-skip"
className={cn('quill-questionnaire__skip', className)}
render={render ?? <Button variant="outline" />}
@@ -286,7 +309,7 @@ function QuestionnaireSkip({
{children ?? 'Skip'}
</QuestionnairePrimitive.Skip>
)
-}
+})
type AdvanceRender = React.ComponentProps<typeof QuestionnairePrimitive.Submit>['render']
@@ -306,14 +329,13 @@ function disabledUntilAnswered(render: AdvanceRender): NonNullable<AdvanceRender
}
}
-function QuestionnaireNext({
- children,
- className,
- render,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Next>): React.ReactElement {
+const QuestionnaireNext = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Next>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Next>
+>(function QuestionnaireNext({ children, className, render, ...props }, ref) {
return (
<QuestionnairePrimitive.Next
+ ref={ref}
data-slot="questionnaire-next"
className={cn('quill-questionnaire__next', className)}
render={disabledUntilAnswered(render)}
@@ -322,16 +344,15 @@ function QuestionnaireNext({
{children ?? 'Next'}
</QuestionnairePrimitive.Next>
)
-}
+})
-function QuestionnaireSubmit({
- children,
- className,
- render,
- ...props
-}: React.ComponentProps<typeof QuestionnairePrimitive.Submit>): React.ReactElement {
+const QuestionnaireSubmit = React.forwardRef<
+ React.ComponentRef<typeof QuestionnairePrimitive.Submit>,
+ React.ComponentProps<typeof QuestionnairePrimitive.Submit>
+>(function QuestionnaireSubmit({ children, className, render, ...props }, ref) {
return (
<QuestionnairePrimitive.Submit
+ ref={ref}
data-slot="questionnaire-submit"
className={cn('quill-questionnaire__submit', className)}
render={disabledUntilAnswered(render)}
@@ -340,7 +361,7 @@ function QuestionnaireSubmit({
{children ?? 'Submit'}
</QuestionnairePrimitive.Submit>
)
-}
+})
export {
Questionnaire,
diff --git a/packages/quill/packages/primitives/src/chat/thread-item.tsx b/packages/quill/packages/primitives/src/chat/thread-item.tsx
index 6881741eb175..4f10f8671116 100644
--- a/packages/quill/packages/primitives/src/chat/thread-item.tsx
+++ b/packages/quill/packages/primitives/src/chat/thread-item.tsx
@@ -30,31 +30,85 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../too
* ThreadItemReplies > AvatarGroup + ThreadItemRepliesLabel + ThreadItemRepliesMeta
* ThreadItemActions > ThreadItemAction(...)
*/
-function ThreadItemGroup({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const ThreadItemGroup = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ThreadItemGroup(
+ { className, ...props },
+ ref
+) {
return (
- <div data-quill data-slot="thread-item-group" className={cn('quill-thread-item-group', className)} {...props} />
+ <div
+ ref={ref}
+ data-quill
+ data-slot="thread-item-group"
+ className={cn('quill-thread-item-group', className)}
+ {...props}
+ />
)
-}
+})
-function ThreadItem({ className, ...props }: React.ComponentProps<'article'>): React.ReactElement {
- return <article data-quill data-slot="thread-item" className={cn('quill-thread-item', className)} {...props} />
-}
+const ThreadItem = React.forwardRef<HTMLElement, React.ComponentProps<'article'>>(function ThreadItem(
+ { className, ...props },
+ ref
+) {
+ return (
+ <article
+ ref={ref}
+ data-quill
+ data-slot="thread-item"
+ className={cn('quill-thread-item', className)}
+ {...props}
+ />
+ )
+})
-function ThreadItemGutter({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="thread-item-gutter" className={cn('quill-thread-item__gutter', className)} {...props} />
-}
+const ThreadItemGutter = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ThreadItemGutter(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div
+ ref={ref}
+ data-slot="thread-item-gutter"
+ className={cn('quill-thread-item__gutter', className)}
+ {...props}
+ />
+ )
+})
-function ThreadItemContent({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="thread-item-content" className={cn('quill-thread-item__content', className)} {...props} />
-}
+const ThreadItemContent = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ThreadItemContent(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div
+ ref={ref}
+ data-slot="thread-item-content"
+ className={cn('quill-thread-item__content', className)}
+ {...props}
+ />
+ )
+})
-function ThreadItemHeader({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="thread-item-header" className={cn('quill-thread-item__header', className)} {...props} />
-}
+const ThreadItemHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ThreadItemHeader(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div
+ ref={ref}
+ data-slot="thread-item-header"
+ className={cn('quill-thread-item__header', className)}
+ {...props}
+ />
+ )
+})
/** Author name. Renders a `span` by default; pass `render={<button />}` to make it a profile trigger. */
-function ThreadItemAuthor({ className, render, ...props }: useRender.ComponentProps<'span'>): React.ReactElement {
+const ThreadItemAuthor = React.forwardRef<HTMLSpanElement, useRender.ComponentProps<'span'>>(function ThreadItemAuthor(
+ { className, render, ...props },
+ ref
+) {
return useRender({
+ ref,
defaultTagName: 'span',
props: mergeProps<'span'>(
{
@@ -68,43 +122,62 @@ function ThreadItemAuthor({ className, render, ...props }: useRender.ComponentPr
slot: 'thread-item-author',
},
})
-}
+})
/** Semantic `<time>` — pass `dateTime` so assistive tech gets the machine-readable value. */
-function ThreadItemTimestamp({ className, ...props }: React.ComponentProps<'time'>): React.ReactElement {
+const ThreadItemTimestamp = React.forwardRef<HTMLTimeElement, React.ComponentProps<'time'>>(
+ function ThreadItemTimestamp({ className, ...props }, ref) {
+ return (
+ <time
+ ref={ref}
+ data-slot="thread-item-timestamp"
+ className={cn('quill-thread-item__timestamp', className)}
+ {...props}
+ />
+ )
+ }
+)
+
+const ThreadItemBody = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ThreadItemBody(
+ { className, ...props },
+ ref
+) {
return (
- <time data-slot="thread-item-timestamp" className={cn('quill-thread-item__timestamp', className)} {...props} />
+ <div ref={ref} data-slot="thread-item-body" className={cn('quill-thread-item__body', className)} {...props} />
)
-}
-
-function ThreadItemBody({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="thread-item-body" className={cn('quill-thread-item__body', className)} {...props} />
-}
+})
/**
* Inline @mention pill inside {@link ThreadItemBody}. Renders a `span` by default; pass
* `render={<button type="button" />}` (or `<a />`) when clicking it should open a profile.
*/
-function ThreadItemMention({ className, render, ...props }: useRender.ComponentProps<'span'>): React.ReactElement {
- return useRender({
- defaultTagName: 'span',
- props: mergeProps<'span'>(
- {
- 'data-slot': 'thread-item-mention',
- className: cn('quill-thread-item__mention', className),
- } as Omit<React.ComponentProps<'span'>, 'ref'>,
- props
- ),
- render,
- state: {
- slot: 'thread-item-mention',
- },
- })
-}
+const ThreadItemMention = React.forwardRef<HTMLSpanElement, useRender.ComponentProps<'span'>>(
+ function ThreadItemMention({ className, render, ...props }, ref) {
+ return useRender({
+ ref,
+ defaultTagName: 'span',
+ props: mergeProps<'span'>(
+ {
+ 'data-slot': 'thread-item-mention',
+ className: cn('quill-thread-item__mention', className),
+ } as Omit<React.ComponentProps<'span'>, 'ref'>,
+ props
+ ),
+ render,
+ state: {
+ slot: 'thread-item-mention',
+ },
+ })
+ }
+)
/** Inline link inside {@link ThreadItemBody} — primary color, underline on hover. */
-function ThreadItemLink({ className, render, ...props }: useRender.ComponentProps<'a'>): React.ReactElement {
+const ThreadItemLink = React.forwardRef<HTMLAnchorElement, useRender.ComponentProps<'a'>>(function ThreadItemLink(
+ { className, render, ...props },
+ ref
+) {
return useRender({
+ ref,
defaultTagName: 'a',
props: mergeProps<'a'>(
{
@@ -118,19 +191,19 @@ function ThreadItemLink({ className, render, ...props }: useRender.ComponentProp
slot: 'thread-item-link',
},
})
-}
+})
/**
* Collapsible attachment (image/file preview) — a Base UI Collapsible, open by default. The
* trigger carries the filename and a rotating chevron; keyboard/AT get `aria-expanded` for free.
*/
-function ThreadItemAttachment({
- className,
- defaultOpen = true,
- ...props
-}: CollapsiblePrimitive.Root.Props): React.ReactElement {
+const ThreadItemAttachment = React.forwardRef<
+ React.ComponentRef<typeof CollapsiblePrimitive.Root>,
+ CollapsiblePrimitive.Root.Props
+>(function ThreadItemAttachment({ className, defaultOpen = true, ...props }, ref) {
return (
<CollapsiblePrimitive.Root
+ ref={ref}
data-quill
data-slot="thread-item-attachment"
defaultOpen={defaultOpen}
@@ -138,16 +211,16 @@ function ThreadItemAttachment({
{...props}
/>
)
-}
+})
/** Filename row that toggles the attachment preview. Children become the visible label. */
-function ThreadItemAttachmentTrigger({
- children,
- className,
- ...props
-}: CollapsiblePrimitive.Trigger.Props): React.ReactElement {
+const ThreadItemAttachmentTrigger = React.forwardRef<
+ React.ComponentRef<typeof CollapsiblePrimitive.Trigger>,
+ CollapsiblePrimitive.Trigger.Props
+>(function ThreadItemAttachmentTrigger({ children, className, ...props }, ref) {
return (
<CollapsiblePrimitive.Trigger
+ ref={ref}
data-slot="thread-item-attachment-trigger"
className={cn('quill-thread-item__attachment-trigger', className)}
{...props}
@@ -156,15 +229,15 @@ function ThreadItemAttachmentTrigger({
<ChevronDownIcon data-chevron="down" className="pointer-events-none shrink-0" />
</CollapsiblePrimitive.Trigger>
)
-}
+})
-function ThreadItemAttachmentContent({
- children,
- className,
- ...props
-}: CollapsiblePrimitive.Panel.Props): React.ReactElement {
+const ThreadItemAttachmentContent = React.forwardRef<
+ React.ComponentRef<typeof CollapsiblePrimitive.Panel>,
+ CollapsiblePrimitive.Panel.Props
+>(function ThreadItemAttachmentContent({ children, className, ...props }, ref) {
return (
<CollapsiblePrimitive.Panel
+ ref={ref}
data-slot="thread-item-attachment-content"
className="quill-thread-item__attachment-panel"
{...props}
@@ -172,31 +245,30 @@ function ThreadItemAttachmentContent({
<div className={cn('quill-thread-item__attachment-panel-content', className)}>{children}</div>
</CollapsiblePrimitive.Panel>
)
-}
+})
/** Framed image preview. `alt` is required — describe the image (empty `alt=""` only if purely decorative). */
-function ThreadItemAttachmentImage({
- className,
- alt,
- ...props
-}: React.ComponentProps<'img'> & { alt: string }): React.ReactElement {
- return (
- <img
- alt={alt}
- data-slot="thread-item-attachment-image"
- className={cn('quill-thread-item__attachment-image', className)}
- {...props}
- />
- )
-}
+const ThreadItemAttachmentImage = React.forwardRef<HTMLImageElement, React.ComponentProps<'img'> & { alt: string }>(
+ function ThreadItemAttachmentImage({ className, alt, ...props }, ref) {
+ return (
+ <img
+ ref={ref}
+ alt={alt}
+ data-slot="thread-item-attachment-image"
+ className={cn('quill-thread-item__attachment-image', className)}
+ {...props}
+ />
+ )
+ }
+)
-function ThreadItemReactions({
- className,
- 'aria-label': ariaLabel = 'Reactions',
- ...props
-}: React.ComponentProps<'div'>): React.ReactElement {
+const ThreadItemReactions = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ThreadItemReactions(
+ { className, 'aria-label': ariaLabel = 'Reactions', ...props },
+ ref
+) {
return (
<div
+ ref={ref}
role="group"
aria-label={ariaLabel}
data-slot="thread-item-reactions"
@@ -204,7 +276,7 @@ function ThreadItemReactions({
{...props}
/>
)
-}
+})
/**
* A reaction pill — a Base UI Toggle, so `pressed`/`onPressedChange` and `aria-pressed` come for
@@ -227,16 +299,19 @@ const ThreadItemReaction = React.forwardRef<HTMLButtonElement, TogglePrimitive.P
})
/** Decorative emoji glyph inside a reaction — hidden from the accessible name. */
-function ThreadItemReactionEmoji({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return (
- <span
- aria-hidden="true"
- data-slot="thread-item-reaction-emoji"
- className={cn('quill-thread-item__reaction-emoji', className)}
- {...props}
- />
- )
-}
+const ThreadItemReactionEmoji = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(
+ function ThreadItemReactionEmoji({ className, ...props }, ref) {
+ return (
+ <span
+ ref={ref}
+ aria-hidden="true"
+ data-slot="thread-item-reaction-emoji"
+ className={cn('quill-thread-item__reaction-emoji', className)}
+ {...props}
+ />
+ )
+ }
+)
const ThreadItemActionsContext = React.createContext(false)
@@ -247,15 +322,15 @@ const ThreadItemActionsContext = React.createContext(false)
* its own `TooltipProvider`, so {@link ThreadItemAction} tooltips work without app-root setup and
* moving between adjacent actions shares the provider's warm-up delay.
*/
-function ThreadItemActions({
- className,
- 'aria-label': ariaLabel = 'Message actions',
- ...props
-}: ToolbarPrimitive.Root.Props): React.ReactElement {
+const ThreadItemActions = React.forwardRef<
+ React.ComponentRef<typeof ToolbarPrimitive.Root>,
+ ToolbarPrimitive.Root.Props
+>(function ThreadItemActions({ className, 'aria-label': ariaLabel = 'Message actions', ...props }, ref) {
return (
<ThreadItemActionsContext.Provider value={true}>
<TooltipProvider>
<ToolbarPrimitive.Root
+ ref={ref}
aria-label={ariaLabel}
data-slot="thread-item-actions"
className={cn('quill-thread-item__actions', className)}
@@ -264,7 +339,7 @@ function ThreadItemActions({
</TooltipProvider>
</ThreadItemActionsContext.Provider>
)
-}
+})
/**
* One icon action: a Button wrapped in a Tooltip. `label` is both the accessible name
@@ -298,36 +373,46 @@ const ThreadItemAction = React.forwardRef<
* Reply summary row — a Button (variant `default`: transparent at rest, fill on hover), stretched
* to the content column. Opens the thread on click; pass `render={<a />}` for a link.
*/
-function ThreadItemReplies({ className, ...props }: ButtonProps): React.ReactElement {
+const ThreadItemReplies = React.forwardRef<React.ComponentRef<typeof Button>, ButtonProps>(function ThreadItemReplies(
+ { className, ...props },
+ ref
+) {
return (
<Button
+ ref={ref}
data-slot="thread-item-replies"
left
className={cn('quill-thread-item__replies', className)}
{...props}
/>
)
-}
+})
-function ThreadItemRepliesLabel({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return (
- <span
- data-slot="thread-item-replies-label"
- className={cn('quill-thread-item__replies-label', className)}
- {...props}
- />
- )
-}
+const ThreadItemRepliesLabel = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(
+ function ThreadItemRepliesLabel({ className, ...props }, ref) {
+ return (
+ <span
+ ref={ref}
+ data-slot="thread-item-replies-label"
+ className={cn('quill-thread-item__replies-label', className)}
+ {...props}
+ />
+ )
+ }
+)
-function ThreadItemRepliesMeta({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return (
- <span
- data-slot="thread-item-replies-meta"
- className={cn('quill-thread-item__replies-meta', className)}
- {...props}
- />
- )
-}
+const ThreadItemRepliesMeta = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(
+ function ThreadItemRepliesMeta({ className, ...props }, ref) {
+ return (
+ <span
+ ref={ref}
+ data-slot="thread-item-replies-meta"
+ className={cn('quill-thread-item__replies-meta', className)}
+ {...props}
+ />
+ )
+ }
+)
export {
ThreadItemGroup,
diff --git a/packages/quill/packages/primitives/src/checkbox.tsx b/packages/quill/packages/primitives/src/checkbox.tsx
index 8796def05e69..95e4ca90876c 100644
--- a/packages/quill/packages/primitives/src/checkbox.tsx
+++ b/packages/quill/packages/primitives/src/checkbox.tsx
@@ -31,13 +31,13 @@ const checkIconVariants = cva('', {
},
})
-function CheckboxIndicator({
- checked,
- className,
- size = 'default',
-}: { checked?: boolean; className?: string } & VariantProps<typeof checkboxIndicatorVariants>): React.ReactElement {
+const CheckboxIndicator = React.forwardRef<
+ HTMLSpanElement,
+ { checked?: boolean; className?: string } & VariantProps<typeof checkboxIndicatorVariants>
+>(function CheckboxIndicator({ checked, className, size = 'default' }, ref) {
return (
<span
+ ref={ref}
data-slot="checkbox-indicator"
className={cn(
checkboxIndicatorVariants({ size }),
@@ -48,7 +48,7 @@ function CheckboxIndicator({
{checked && <CheckIcon className={checkIconVariants({ size })} />}
</span>
)
-}
+})
const checkboxVariants = cva('quill-checkbox peer flex shrink-0 items-center justify-center', {
variants: {
@@ -62,13 +62,13 @@ const checkboxVariants = cva('quill-checkbox peer flex shrink-0 items-center jus
},
})
-function Checkbox({
- className,
- size = 'default',
- ...props
-}: CheckboxPrimitive.Root.Props & VariantProps<typeof checkboxVariants>): React.ReactElement {
+const Checkbox = React.forwardRef<
+ React.ComponentRef<typeof CheckboxPrimitive.Root>,
+ CheckboxPrimitive.Root.Props & VariantProps<typeof checkboxVariants>
+>(function Checkbox({ className, size = 'default', ...props }, ref) {
return (
<CheckboxPrimitive.Root
+ ref={ref}
data-quill
data-slot="checkbox"
className={cn(checkboxVariants({ size }), className)}
@@ -86,6 +86,6 @@ function Checkbox({
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
)
-}
+})
export { Checkbox, CheckboxIndicator }
diff --git a/packages/quill/packages/primitives/src/chip.tsx b/packages/quill/packages/primitives/src/chip.tsx
index b57a60411516..8e48fd875614 100644
--- a/packages/quill/packages/primitives/src/chip.tsx
+++ b/packages/quill/packages/primitives/src/chip.tsx
@@ -55,11 +55,11 @@ const ChipClose = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeo
)
ChipClose.displayName = 'ChipClose'
-function ChipGroup({
- className,
- ...props
-}: React.ComponentProps<typeof ButtonGroup> & VariantProps<typeof buttonGroupVariants>): React.ReactElement {
- return <ButtonGroup data-slot="chip-group" className={cn('flex-wrap gap-0', className)} {...props} />
-}
+const ChipGroup = React.forwardRef<
+ React.ComponentRef<typeof ButtonGroup>,
+ React.ComponentProps<typeof ButtonGroup> & VariantProps<typeof buttonGroupVariants>
+>(function ChipGroup({ className, ...props }, ref) {
+ return <ButtonGroup ref={ref} data-slot="chip-group" className={cn('flex-wrap gap-0', className)} {...props} />
+})
export { Chip, ChipClose, ChipGroup }
diff --git a/packages/quill/packages/primitives/src/collapsible.tsx b/packages/quill/packages/primitives/src/collapsible.tsx
index fb02ea76814f..becf14ce07e3 100644
--- a/packages/quill/packages/primitives/src/collapsible.tsx
+++ b/packages/quill/packages/primitives/src/collapsible.tsx
@@ -15,64 +15,69 @@ type CollapsibleProps = CollapsiblePrimitive.Root.Props & {
variant?: CollapsibleVariant
}
-function Collapsible({ variant = 'default', className, ...props }: CollapsibleProps): React.ReactElement {
- return (
- <CollapsibleVariantContext.Provider value={variant}>
- <CollapsiblePrimitive.Root
- data-quill
- data-slot="collapsible"
- data-variant={variant}
- className={cn(
- 'group/collapsible',
- variant === 'default' && 'quill-collapsible--variant-default',
- className
- )}
- {...props}
- />
- </CollapsibleVariantContext.Provider>
- )
-}
+const Collapsible = React.forwardRef<React.ComponentRef<typeof CollapsiblePrimitive.Root>, CollapsibleProps>(
+ function Collapsible({ variant = 'default', className, ...props }, ref) {
+ return (
+ <CollapsibleVariantContext.Provider value={variant}>
+ <CollapsiblePrimitive.Root
+ ref={ref}
+ data-quill
+ data-slot="collapsible"
+ data-variant={variant}
+ className={cn(
+ 'group/collapsible',
+ variant === 'default' && 'quill-collapsible--variant-default',
+ className
+ )}
+ {...props}
+ />
+ </CollapsibleVariantContext.Provider>
+ )
+ }
+)
/**
* Row container for the icon-only trigger pattern: the trigger toggles, while
* siblings (a link, trailing count, actions) stay independently interactive.
* Use `ms-auto` on trailing content so it stays end-aligned in RTL.
*/
-function CollapsibleHeader({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const CollapsibleHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function CollapsibleHeader(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="collapsible-header"
className={cn('quill-collapsible__header flex w-full items-center gap-1.5', className)}
{...props}
/>
)
-}
+})
-function CollapsibleTrigger({
- children,
- className,
- iconOnly = false,
- icon,
- ...props
-}: CollapsiblePrimitive.Trigger.Props & {
- /**
- * Renders the trigger as a compact icon button (just the chevron) instead
- * of a full-width row — pair with `CollapsibleHeader` so the rest of the
- * row can hold independently clickable content. `children` become the
- * trigger's screen-reader-only label.
- */
- iconOnly?: boolean
- /**
- * Optional rest icon for `iconOnly` mode: shown instead of the chevron
- * until the surrounding `CollapsibleHeader` row is hovered or the trigger
- * is focused, then swaps to the chevron (Finder/VS Code tree pattern).
- */
- icon?: React.ReactNode
-}): React.ReactElement {
+const CollapsibleTrigger = React.forwardRef<
+ React.ComponentRef<typeof CollapsiblePrimitive.Trigger>,
+ CollapsiblePrimitive.Trigger.Props & {
+ /**
+ * Renders the trigger as a compact icon button (just the chevron) instead
+ * of a full-width row — pair with `CollapsibleHeader` so the rest of the
+ * row can hold independently clickable content. `children` become the
+ * trigger's screen-reader-only label.
+ */
+ iconOnly?: boolean
+ /**
+ * Optional rest icon for `iconOnly` mode: shown instead of the chevron
+ * until the surrounding `CollapsibleHeader` row is hovered or the trigger
+ * is focused, then swaps to the chevron (Finder/VS Code tree pattern).
+ */
+ icon?: React.ReactNode
+ }
+>(function CollapsibleTrigger({ children, className, iconOnly = false, icon, ...props }, ref) {
const variant = React.useContext(CollapsibleVariantContext)
if (iconOnly) {
return (
<CollapsiblePrimitive.Trigger
+ ref={ref}
data-slot="collapsible-trigger"
data-variant={variant}
className={cn(
@@ -118,6 +123,7 @@ function CollapsibleTrigger({
)
return (
<CollapsiblePrimitive.Trigger
+ ref={ref}
data-slot="collapsible-trigger"
data-variant={variant}
className={cn(
@@ -133,13 +139,21 @@ function CollapsibleTrigger({
{variant === 'default' && chevrons}
</CollapsiblePrimitive.Trigger>
)
-}
+})
-function CollapsibleContent({ children, className, ...props }: CollapsiblePrimitive.Panel.Props): React.ReactElement {
+const CollapsibleContent = React.forwardRef<
+ React.ComponentRef<typeof CollapsiblePrimitive.Panel>,
+ CollapsiblePrimitive.Panel.Props
+>(function CollapsibleContent({ children, className, ...props }, ref) {
const variant = React.useContext(CollapsibleVariantContext)
return (
- <CollapsiblePrimitive.Panel data-slot="collapsible-content" className="quill-collapsible__panel" {...props}>
+ <CollapsiblePrimitive.Panel
+ ref={ref}
+ data-slot="collapsible-content"
+ className="quill-collapsible__panel"
+ {...props}
+ >
<div
className={cn(
'quill-collapsible__panel-content',
@@ -151,6 +165,6 @@ function CollapsibleContent({ children, className, ...props }: CollapsiblePrimit
</div>
</CollapsiblePrimitive.Panel>
)
-}
+})
export { Collapsible, CollapsibleHeader, CollapsibleTrigger, CollapsibleContent }
diff --git a/packages/quill/packages/primitives/src/combobox.tsx b/packages/quill/packages/primitives/src/combobox.tsx
index 9c5e50b300d0..18a165e77576 100644
--- a/packages/quill/packages/primitives/src/combobox.tsx
+++ b/packages/quill/packages/primitives/src/combobox.tsx
@@ -46,9 +46,13 @@ const ComboboxTrigger = React.forwardRef<HTMLButtonElement, ComboboxPrimitive.Tr
)
ComboboxTrigger.displayName = 'ComboboxTrigger'
-function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props): React.ReactElement {
+const ComboboxClear = React.forwardRef<
+ React.ComponentRef<typeof ComboboxPrimitive.Clear>,
+ ComboboxPrimitive.Clear.Props
+>(function ComboboxClear({ className, ...props }, ref) {
return (
<ComboboxPrimitive.Clear
+ ref={ref}
data-slot="combobox-clear"
render={<InputGroupButton size="icon-xs" />}
className={cn(className)}
@@ -57,24 +61,23 @@ function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props):
<XIcon className="pointer-events-none" />
</ComboboxPrimitive.Clear>
)
-}
+})
-function ComboboxInput({
- className,
- children,
- disabled = false,
- showTrigger = true,
- showClear = false,
- ...props
-}: ComboboxPrimitive.Input.Props & {
- showTrigger?: boolean
- showClear?: boolean
-}): React.ReactElement {
+const ComboboxInput = React.forwardRef<
+ React.ComponentRef<typeof ComboboxPrimitive.Input>,
+ ComboboxPrimitive.Input.Props & {
+ showTrigger?: boolean
+ showClear?: boolean
+ }
+>(function ComboboxInput(
+ { className, children, disabled = false, showTrigger = true, showClear = false, ...props },
+ ref
+) {
const anchorRef = React.useContext(ComboboxAnchorContext)
return (
<div data-slot="combobox-input-group-wrapper">
<InputGroup ref={anchorRef} className={cn('w-auto', className)}>
- <ComboboxPrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />
+ <ComboboxPrimitive.Input ref={ref} render={<InputGroupInput disabled={disabled} />} {...props} />
<InputGroupAddon align="inline-end">
{showTrigger && (
<InputGroupButton
@@ -91,21 +94,16 @@ function ComboboxInput({
</InputGroup>
</div>
)
-}
+})
-function ComboboxContent({
- className,
- side = 'bottom',
- sideOffset = 6,
- align = 'start',
- alignOffset = 0,
- anchor: anchorProp,
- ...props
-}: ComboboxPrimitive.Popup.Props &
- Pick<
- ComboboxPrimitive.Positioner.Props,
- 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'
- >): React.ReactElement {
+const ComboboxContent = React.forwardRef<
+ React.ComponentRef<typeof ComboboxPrimitive.Popup>,
+ ComboboxPrimitive.Popup.Props &
+ Pick<ComboboxPrimitive.Positioner.Props, 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'>
+>(function ComboboxContent(
+ { className, side = 'bottom', sideOffset = 6, align = 'start', alignOffset = 0, anchor: anchorProp, ...props },
+ ref
+) {
const contextAnchor = React.useContext(ComboboxAnchorContext)
const anchor = anchorProp ?? contextAnchor
return (
@@ -121,6 +119,7 @@ function ComboboxContent({
className="isolate"
>
<ComboboxPrimitive.Popup
+ ref={ref}
data-slot="combobox-content"
data-chips={!!anchor}
className={cn('quill-combobox__content group/combobox-content', className)}
@@ -129,36 +128,38 @@ function ComboboxContent({
</ComboboxPrimitive.Positioner>
</ComboboxPrimitive.Portal>
)
-}
+})
-function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props): React.ReactElement {
- return (
- <ComboboxPrimitive.List
- data-slot="combobox-list"
- // `scroll-mask-t-4` always (top fade for items scrolling out of view).
- // Bottom fade is conditional: if a `ComboboxListFooter` is rendered,
- // the footer's own `quill-scroll-fade-top` pseudo handles the bottom
- // fade (and only when content is actually hidden below, via
- // container scroll-state). Otherwise, fall back to plugin's
- // `scroll-mask-b-4` for the same behavior on lists without a footer.
- className={cn(
- 'quill-combobox__list scroll-mask-t-4 scroll-py-4',
- 'not-has-[[data-slot=combobox-list-footer]]:scroll-mask-b-4',
- className
- )}
- {...props}
- />
- )
-}
+const ComboboxList = React.forwardRef<React.ComponentRef<typeof ComboboxPrimitive.List>, ComboboxPrimitive.List.Props>(
+ function ComboboxList({ className, ...props }, ref) {
+ return (
+ <ComboboxPrimitive.List
+ ref={ref}
+ data-slot="combobox-list"
+ // `scroll-mask-t-4` always (top fade for items scrolling out of view).
+ // Bottom fade is conditional: if a `ComboboxListFooter` is rendered,
+ // the footer's own `quill-scroll-fade-top` pseudo handles the bottom
+ // fade (and only when content is actually hidden below, via
+ // container scroll-state). Otherwise, fall back to plugin's
+ // `scroll-mask-b-4` for the same behavior on lists without a footer.
+ className={cn(
+ 'quill-combobox__list scroll-mask-t-4 scroll-py-4',
+ 'not-has-[[data-slot=combobox-list-footer]]:scroll-mask-b-4',
+ className
+ )}
+ {...props}
+ />
+ )
+ }
+)
-function ComboboxItem({
- className,
- children,
- title,
- ...props
-}: ComboboxPrimitive.Item.Props & { title?: string }): React.ReactElement {
+const ComboboxItem = React.forwardRef<
+ React.ComponentRef<typeof ComboboxPrimitive.Item>,
+ ComboboxPrimitive.Item.Props & { title?: string }
+>(function ComboboxItem({ className, children, title, ...props }, ref) {
return (
<ComboboxPrimitive.Item
+ ref={ref}
data-slot="combobox-item"
className={cn('quill-combobox__item', className)}
title={title ?? (typeof children === 'string' ? children : undefined)}
@@ -176,74 +177,88 @@ function ComboboxItem({
</ComboboxPrimitive.ItemIndicator>
</ComboboxPrimitive.Item>
)
-}
+})
-function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props): React.ReactElement {
- return <ComboboxPrimitive.Group data-slot="combobox-group" className={cn(className)} {...props} />
-}
+const ComboboxGroup = React.forwardRef<
+ React.ComponentRef<typeof ComboboxPrimitive.Group>,
+ ComboboxPrimitive.Group.Props
+>(function ComboboxGroup({ className, ...props }, ref) {
+ return <ComboboxPrimitive.Group ref={ref} data-slot="combobox-group" className={cn(className)} {...props} />
+})
-function ComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props): React.ReactElement {
+const ComboboxLabel = React.forwardRef<
+ React.ComponentRef<typeof ComboboxPrimitive.GroupLabel>,
+ ComboboxPrimitive.GroupLabel.Props
+>(function ComboboxLabel({ className, ...props }, ref) {
return (
<ComboboxPrimitive.GroupLabel
+ ref={ref}
data-slot="combobox-label"
className={className}
render={<MenuLabel />}
{...props}
/>
)
-}
+})
function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props): React.ReactElement {
return <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />
}
-function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props): React.ReactElement {
+const ComboboxEmpty = React.forwardRef<
+ React.ComponentRef<typeof ComboboxPrimitive.Empty>,
+ ComboboxPrimitive.Empty.Props
+>(function ComboboxEmpty({ className, ...props }, ref) {
// Base UI renders the children only when nothing matches, so `empty:hidden` is the whole visibility rule.
return (
<ComboboxPrimitive.Empty
+ ref={ref}
data-slot="combobox-empty"
className={cn('empty:hidden', className)}
render={<MenuEmpty />}
{...props}
/>
)
-}
+})
-function ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props): React.ReactElement {
+const ComboboxSeparator = React.forwardRef<
+ React.ComponentRef<typeof ComboboxPrimitive.Separator>,
+ ComboboxPrimitive.Separator.Props
+>(function ComboboxSeparator({ className, ...props }, ref) {
return (
<ComboboxPrimitive.Separator
+ ref={ref}
data-slot="combobox-separator"
className={cn('quill-combobox__separator', className)}
{...props}
/>
)
-}
+})
-function ComboboxChips({
- className,
- ...props
-}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props): React.ReactElement {
+const ComboboxChips = React.forwardRef<
+ React.ComponentRef<typeof ComboboxPrimitive.Chips>,
+ React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props
+>(function ComboboxChips({ className, ...props }, ref) {
return (
<ComboboxPrimitive.Chips
+ ref={ref}
data-slot="combobox-chips"
className={cn('quill-combobox__chips flex flex-wrap items-center gap-1 py-1', className)}
{...props}
/>
)
-}
+})
-function ComboboxChip({
- className,
- children,
- title,
- showRemove = true,
- ...props
-}: ComboboxPrimitive.Chip.Props & {
- showRemove?: boolean
- title?: string
-}): React.ReactElement {
+const ComboboxChip = React.forwardRef<
+ React.ComponentRef<typeof ComboboxPrimitive.Chip>,
+ ComboboxPrimitive.Chip.Props & {
+ showRemove?: boolean
+ title?: string
+ }
+>(function ComboboxChip({ className, children, title, showRemove = true, ...props }, ref) {
return (
<ComboboxPrimitive.Chip
+ ref={ref}
render={<Chip title={title ?? (typeof children === 'string' ? children : undefined)} />}
data-slot="combobox-chip"
className={cn(className)}
@@ -257,19 +272,26 @@ function ComboboxChip({
)}
</ComboboxPrimitive.Chip>
)
-}
+})
-function ComboboxChipsInput({ className, ...props }: ComboboxPrimitive.Input.Props): React.ReactElement {
+const ComboboxChipsInput = React.forwardRef<
+ React.ComponentRef<typeof ComboboxPrimitive.Input>,
+ ComboboxPrimitive.Input.Props
+>(function ComboboxChipsInput({ className, ...props }, ref) {
return (
<ComboboxPrimitive.Input
+ ref={ref}
data-slot="combobox-chip-input"
className={cn('quill-combobox__chips-input', className)}
{...props}
/>
)
-}
+})
-function ComboboxListFooter({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const ComboboxListFooter = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ComboboxListFooter(
+ { className, ...props },
+ ref
+) {
return (
<div
data-slot="combobox-list-footer"
@@ -279,10 +301,10 @@ function ComboboxListFooter({ className, ...props }: React.ComponentProps<'div'>
// area, mirroring `scroll-mask-b` without fading the footer itself.
className={cn('quill-combobox__list-footer quill-scroll-fade-top', className)}
>
- <div className="p-1" {...props} />
+ <div ref={ref} className="p-1" {...props} />
</div>
)
-}
+})
function useComboboxAnchor(): React.RefObject<HTMLDivElement> {
const contextRef = React.useContext(ComboboxAnchorContext)
diff --git a/packages/quill/packages/primitives/src/context-menu.tsx b/packages/quill/packages/primitives/src/context-menu.tsx
index 80bb976ac895..1eb8d7b14da7 100644
--- a/packages/quill/packages/primitives/src/context-menu.tsx
+++ b/packages/quill/packages/primitives/src/context-menu.tsx
@@ -18,26 +18,28 @@ function ContextMenuPortal({ ...props }: ContextMenuPrimitive.Portal.Props): Rea
return <ContextMenuPrimitive.Portal data-slot="context-menu-portal" {...props} />
}
-function ContextMenuTrigger({ className, ...props }: ContextMenuPrimitive.Trigger.Props): React.ReactElement {
+const ContextMenuTrigger = React.forwardRef<
+ React.ComponentRef<typeof ContextMenuPrimitive.Trigger>,
+ ContextMenuPrimitive.Trigger.Props
+>(function ContextMenuTrigger({ className, ...props }, ref) {
return (
<ContextMenuPrimitive.Trigger
+ ref={ref}
data-slot="context-menu-trigger"
className={cn('select-none', className)}
{...props}
/>
)
-}
+})
-function ContextMenuContent({
- className,
- align = 'start',
- alignOffset = 4,
- side = 'inline-end',
- sideOffset = 0,
- children,
- ...props
-}: ContextMenuPrimitive.Popup.Props &
- Pick<ContextMenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>): React.ReactElement {
+const ContextMenuContent = React.forwardRef<
+ React.ComponentRef<typeof ContextMenuPrimitive.Popup>,
+ ContextMenuPrimitive.Popup.Props &
+ Pick<ContextMenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>
+>(function ContextMenuContent(
+ { className, align = 'start', alignOffset = 4, side = 'inline-end', sideOffset = 0, children, ...props },
+ ref
+) {
return (
<ContextMenuPrimitive.Portal>
<ContextMenuPrimitive.Positioner
@@ -50,6 +52,7 @@ function ContextMenuContent({
sideOffset={sideOffset}
>
<ContextMenuPrimitive.Popup
+ ref={ref}
data-slot="context-menu-content"
className={cn('quill-menu__content', className)}
{...props}
@@ -59,41 +62,42 @@ function ContextMenuContent({
</ContextMenuPrimitive.Positioner>
</ContextMenuPrimitive.Portal>
)
-}
+})
-function ContextMenuGroup({ ...props }: ContextMenuPrimitive.Group.Props): React.ReactElement {
- return <ContextMenuPrimitive.Group data-slot="context-menu-group" {...props} />
-}
+const ContextMenuGroup = React.forwardRef<
+ React.ComponentRef<typeof ContextMenuPrimitive.Group>,
+ ContextMenuPrimitive.Group.Props
+>(function ContextMenuGroup({ ...props }, ref) {
+ return <ContextMenuPrimitive.Group ref={ref} data-slot="context-menu-group" {...props} />
+})
-function ContextMenuLabel({
- className,
- inset,
- ...props
-}: ContextMenuPrimitive.GroupLabel.Props & {
- inset?: boolean
-}): React.ReactElement {
+const ContextMenuLabel = React.forwardRef<
+ React.ComponentRef<typeof ContextMenuPrimitive.GroupLabel>,
+ ContextMenuPrimitive.GroupLabel.Props & {
+ inset?: boolean
+ }
+>(function ContextMenuLabel({ className, inset, ...props }, ref) {
return (
<ContextMenuPrimitive.GroupLabel
+ ref={ref}
data-slot="context-menu-label"
data-inset={inset}
className={cn('px-2 py-1.5 text-xs text-muted-foreground', inset && 'quill-menu-item--inset', className)}
{...props}
/>
)
-}
+})
-function ContextMenuItem({
- className,
- inset,
- variant = 'default',
- children,
- ...props
-}: ContextMenuPrimitive.Item.Props & {
- inset?: boolean
- variant?: 'default' | 'destructive'
-}): React.ReactElement {
+const ContextMenuItem = React.forwardRef<
+ React.ComponentRef<typeof ContextMenuPrimitive.Item>,
+ ContextMenuPrimitive.Item.Props & {
+ inset?: boolean
+ variant?: 'default' | 'destructive'
+ }
+>(function ContextMenuItem({ className, inset, variant = 'default', children, ...props }, ref) {
return (
<ContextMenuPrimitive.Item
+ ref={ref}
data-slot="context-menu-item"
data-inset={inset}
data-variant={variant}
@@ -111,22 +115,21 @@ function ContextMenuItem({
{children}
</ContextMenuPrimitive.Item>
)
-}
+})
function ContextMenuSub({ ...props }: ContextMenuPrimitive.SubmenuRoot.Props): React.ReactElement {
return <ContextMenuPrimitive.SubmenuRoot data-slot="context-menu-sub" {...props} />
}
-function ContextMenuSubTrigger({
- className,
- inset,
- children,
- ...props
-}: ContextMenuPrimitive.SubmenuTrigger.Props & {
- inset?: boolean
-}): React.ReactElement {
+const ContextMenuSubTrigger = React.forwardRef<
+ React.ComponentRef<typeof ContextMenuPrimitive.SubmenuTrigger>,
+ ContextMenuPrimitive.SubmenuTrigger.Props & {
+ inset?: boolean
+ }
+>(function ContextMenuSubTrigger({ className, inset, children, ...props }, ref) {
return (
<ContextMenuPrimitive.SubmenuTrigger
+ ref={ref}
data-slot="context-menu-sub-trigger"
data-inset={inset}
className={cn(
@@ -144,18 +147,18 @@ function ContextMenuSubTrigger({
<ChevronRightIcon className="rtl:rotate-180 ms-auto" />
</ContextMenuPrimitive.SubmenuTrigger>
)
-}
+})
-function ContextMenuSubContent({
- className,
- align = 'start',
- alignOffset = -3,
- side = 'inline-end',
- sideOffset = 0,
- ...props
-}: React.ComponentProps<typeof ContextMenuContent>): React.ReactElement {
+const ContextMenuSubContent = React.forwardRef<
+ React.ComponentRef<typeof ContextMenuContent>,
+ React.ComponentProps<typeof ContextMenuContent>
+>(function ContextMenuSubContent(
+ { className, align = 'start', alignOffset = -3, side = 'inline-end', sideOffset = 0, ...props },
+ ref
+) {
return (
<ContextMenuContent
+ ref={ref}
data-slot="context-menu-sub-content"
className={cn('quill-menu__sub-content w-auto', className)}
align={align}
@@ -165,19 +168,17 @@ function ContextMenuSubContent({
{...props}
/>
)
-}
+})
-function ContextMenuCheckboxItem({
- className,
- children,
- checked,
- inset,
- ...props
-}: ContextMenuPrimitive.CheckboxItem.Props & {
- inset?: boolean
-}): React.ReactElement {
+const ContextMenuCheckboxItem = React.forwardRef<
+ React.ComponentRef<typeof ContextMenuPrimitive.CheckboxItem>,
+ ContextMenuPrimitive.CheckboxItem.Props & {
+ inset?: boolean
+ }
+>(function ContextMenuCheckboxItem({ className, children, checked, inset, ...props }, ref) {
return (
<ContextMenuPrimitive.CheckboxItem
+ ref={ref}
data-slot="context-menu-checkbox-item"
data-inset={inset}
className={cn(
@@ -200,22 +201,24 @@ function ContextMenuCheckboxItem({
{children}
</ContextMenuPrimitive.CheckboxItem>
)
-}
+})
-function ContextMenuRadioGroup({ ...props }: ContextMenuPrimitive.RadioGroup.Props): React.ReactElement {
- return <ContextMenuPrimitive.RadioGroup data-slot="context-menu-radio-group" {...props} />
-}
+const ContextMenuRadioGroup = React.forwardRef<
+ React.ComponentRef<typeof ContextMenuPrimitive.RadioGroup>,
+ ContextMenuPrimitive.RadioGroup.Props
+>(function ContextMenuRadioGroup({ ...props }, ref) {
+ return <ContextMenuPrimitive.RadioGroup ref={ref} data-slot="context-menu-radio-group" {...props} />
+})
-function ContextMenuRadioItem({
- className,
- children,
- inset,
- ...props
-}: ContextMenuPrimitive.RadioItem.Props & {
- inset?: boolean
-}): React.ReactElement {
+const ContextMenuRadioItem = React.forwardRef<
+ React.ComponentRef<typeof ContextMenuPrimitive.RadioItem>,
+ ContextMenuPrimitive.RadioItem.Props & {
+ inset?: boolean
+ }
+>(function ContextMenuRadioItem({ className, children, inset, ...props }, ref) {
return (
<ContextMenuPrimitive.RadioItem
+ ref={ref}
data-slot="context-menu-radio-item"
data-inset={inset}
className={cn(
@@ -237,21 +240,34 @@ function ContextMenuRadioItem({
{children}
</ContextMenuPrimitive.RadioItem>
)
-}
+})
-function ContextMenuSeparator({ className, ...props }: ContextMenuPrimitive.Separator.Props): React.ReactElement {
+const ContextMenuSeparator = React.forwardRef<
+ React.ComponentRef<typeof ContextMenuPrimitive.Separator>,
+ ContextMenuPrimitive.Separator.Props
+>(function ContextMenuSeparator({ className, ...props }, ref) {
return (
<ContextMenuPrimitive.Separator
+ ref={ref}
data-slot="context-menu-separator"
className={cn('quill-menu__separator', className)}
{...props}
/>
)
-}
+})
-function ContextMenuShortcut({ className, ...props }: React.ComponentProps<typeof Kbd>): React.ReactElement {
- return <Kbd data-slot="context-menu-shortcut" className={cn('quill-menu__shortcut', className)} {...props} />
-}
+const ContextMenuShortcut = React.forwardRef<React.ComponentRef<typeof Kbd>, React.ComponentProps<typeof Kbd>>(
+ function ContextMenuShortcut({ className, ...props }, ref) {
+ return (
+ <Kbd
+ ref={ref}
+ data-slot="context-menu-shortcut"
+ className={cn('quill-menu__shortcut', className)}
+ {...props}
+ />
+ )
+ }
+)
export {
ContextMenu,
diff --git a/packages/quill/packages/primitives/src/dialog.tsx b/packages/quill/packages/primitives/src/dialog.tsx
index 20291311a1a8..b174ccc33188 100644
--- a/packages/quill/packages/primitives/src/dialog.tsx
+++ b/packages/quill/packages/primitives/src/dialog.tsx
@@ -14,24 +14,29 @@ function Dialog({ ...props }: DialogPrimitive.Root.Props): React.ReactElement {
return <DialogPrimitive.Root data-slot="dialog" {...props} />
}
-const DialogTrigger = React.forwardRef<HTMLButtonElement, DialogPrimitive.Trigger.Props>(function DialogTrigger(
- props,
- ref
-) {
- return <DialogPrimitive.Trigger ref={ref} data-slot="dialog-trigger" {...props} />
-})
+const DialogTrigger = React.forwardRef<HTMLButtonElement, DialogPrimitive.Trigger.Props>(
+ function DialogTrigger(props, ref) {
+ return <DialogPrimitive.Trigger ref={ref} data-slot="dialog-trigger" {...props} />
+ }
+)
function DialogPortal({ ...props }: DialogPrimitive.Portal.Props): React.ReactElement {
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
}
-function DialogClose({ ...props }: DialogPrimitive.Close.Props): React.ReactElement {
- return <DialogPrimitive.Close data-slot="dialog-close focus-visible:z-10" {...props} />
-}
+const DialogClose = React.forwardRef<React.ComponentRef<typeof DialogPrimitive.Close>, DialogPrimitive.Close.Props>(
+ function DialogClose({ ...props }, ref) {
+ return <DialogPrimitive.Close ref={ref} data-slot="dialog-close focus-visible:z-10" {...props} />
+ }
+)
-function DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props): React.ReactElement {
+const DialogOverlay = React.forwardRef<
+ React.ComponentRef<typeof DialogPrimitive.Backdrop>,
+ DialogPrimitive.Backdrop.Props
+>(function DialogOverlay({ className, ...props }, ref) {
return (
<DialogPrimitive.Backdrop
+ ref={ref}
data-quill
data-quill-portal="modal-overlay"
data-slot="dialog-overlay"
@@ -39,33 +44,30 @@ function DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props):
{...props}
/>
)
-}
+})
-function DialogContent({
- className,
- children,
- showCloseButton = true,
- nested = false,
- size,
- ...props
-}: DialogPrimitive.Popup.Props & {
- showCloseButton?: boolean
- nested?: boolean
- /**
- * Width variant. Defaults to the standard ~24rem dialog width
- * (Quill's existing media-query clamp at ≥640px viewports).
- * - `'wide'`: clamps to `min(72rem, calc(100vw - 3rem))` for
- * content that needs horizontal breathing room (data tables,
- * side-by-side editors, etc.).
- * - `'full'`: drops the desktop clamp entirely and grows to
- * `calc(100vw - 3rem)`.
- */
- size?: 'wide' | 'full'
-}): React.ReactElement {
+const DialogContent = React.forwardRef<
+ React.ComponentRef<typeof DialogPrimitive.Popup>,
+ DialogPrimitive.Popup.Props & {
+ showCloseButton?: boolean
+ nested?: boolean
+ /**
+ * Width variant. Defaults to the standard ~24rem dialog width
+ * (Quill's existing media-query clamp at ≥640px viewports).
+ * - `'wide'`: clamps to `min(72rem, calc(100vw - 3rem))` for
+ * content that needs horizontal breathing room (data tables,
+ * side-by-side editors, etc.).
+ * - `'full'`: drops the desktop clamp entirely and grows to
+ * `calc(100vw - 3rem)`.
+ */
+ size?: 'wide' | 'full'
+ }
+>(function DialogContent({ className, children, showCloseButton = true, nested = false, size, ...props }, ref) {
return (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Popup
+ ref={ref}
data-quill
data-quill-portal="modal-content"
data-slot="dialog-content"
@@ -86,22 +88,31 @@ function DialogContent({
</DialogPrimitive.Popup>
</DialogPortal>
)
-}
+})
-function DialogHeader({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="dialog-header" className={cn('quill-dialog__header flex flex-col gap-1', className)} {...props} />
-}
+const DialogHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function DialogHeader(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div
+ ref={ref}
+ data-slot="dialog-header"
+ className={cn('quill-dialog__header flex flex-col gap-1', className)}
+ {...props}
+ />
+ )
+})
-function DialogFooter({
- className,
- showCloseButton = false,
- children,
- ...props
-}: React.ComponentProps<'div'> & {
- showCloseButton?: boolean
-}): React.ReactElement {
+const DialogFooter = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & {
+ showCloseButton?: boolean
+ }
+>(function DialogFooter({ className, showCloseButton = false, children, ...props }, ref) {
return (
<div
+ ref={ref}
data-slot="dialog-footer"
className={cn('quill-dialog__footer flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className)}
{...props}
@@ -112,23 +123,20 @@ function DialogFooter({
)}
</div>
)
-}
+})
-function DialogBody({
- className,
- render,
- children,
- viewportClassName,
- ...props
-}: useRender.ComponentProps<'div'> & {
- /**
- * Class applied to the inner ScrollArea viewport (`data-slot="scroll-area-viewport"`),
- * the element that actually scrolls. For example, `viewportClassName="p-0"` drops the
- * default body padding for full-bleed content. Ignored when a custom `render` is
- * supplied (set `viewportClassName` on your own `<ScrollArea>` there instead).
- */
- viewportClassName?: string
-}): React.ReactElement {
+const DialogBody = React.forwardRef<
+ HTMLDivElement,
+ useRender.ComponentProps<'div'> & {
+ /**
+ * Class applied to the inner ScrollArea viewport (`data-slot="scroll-area-viewport"`),
+ * the element that actually scrolls. For example, `viewportClassName="p-0"` drops the
+ * default body padding for full-bleed content. Ignored when a custom `render` is
+ * supplied (set `viewportClassName` on your own `<ScrollArea>` there instead).
+ */
+ viewportClassName?: string
+ }
+>(function DialogBody({ className, render, children, viewportClassName, ...props }, ref) {
/*
* Default render = `<ScrollArea>` so consumers get scroll shadows
* (and edge-overflow data attrs) for free. The scroll-area-aware
@@ -153,6 +161,7 @@ function DialogBody({
/>
)
return useRender({
+ ref,
defaultTagName: 'div',
props: mergeProps<'div'>(
{
@@ -164,21 +173,34 @@ function DialogBody({
render: effectiveRender,
state: { slot: 'dialog-body' },
})
-}
+})
-function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props): React.ReactElement {
- return <DialogPrimitive.Title data-slot="dialog-title" className={cn('quill-dialog__title', className)} {...props} />
-}
+const DialogTitle = React.forwardRef<React.ComponentRef<typeof DialogPrimitive.Title>, DialogPrimitive.Title.Props>(
+ function DialogTitle({ className, ...props }, ref) {
+ return (
+ <DialogPrimitive.Title
+ ref={ref}
+ data-slot="dialog-title"
+ className={cn('quill-dialog__title', className)}
+ {...props}
+ />
+ )
+ }
+)
-function DialogDescription({ className, ...props }: DialogPrimitive.Description.Props): React.ReactElement {
+const DialogDescription = React.forwardRef<
+ React.ComponentRef<typeof DialogPrimitive.Description>,
+ DialogPrimitive.Description.Props
+>(function DialogDescription({ className, ...props }, ref) {
return (
<DialogPrimitive.Description
+ ref={ref}
data-slot="dialog-description"
className={cn('quill-dialog__description', className)}
{...props}
/>
)
-}
+})
export {
Dialog,
diff --git a/packages/quill/packages/primitives/src/dot.tsx b/packages/quill/packages/primitives/src/dot.tsx
index 35d5b4598b07..9946f38434fc 100644
--- a/packages/quill/packages/primitives/src/dot.tsx
+++ b/packages/quill/packages/primitives/src/dot.tsx
@@ -23,29 +23,27 @@ const dotVariants = cva('quill-dot relative inline-flex p-0.5 shrink-0 items-cen
},
})
-function Dot({
- className,
- variant = 'default',
- pulse = false,
- ...props
-}: React.ComponentProps<'span'> & VariantProps<typeof dotVariants>): React.ReactElement {
- return (
- <span
- data-quill
- data-slot="dot"
- className={cn(dotVariants({ variant, pulse }), className)}
- {...props}
- >
- {pulse && (
- <span
- aria-hidden
- data-slot="dot-pulse"
- className="quill-dot__pulse pointer-events-none absolute inset-px"
- />
- )}
- <span data-slot="dot-inner" className="quill-dot__inner" />
- </span>
- )
-}
+const Dot = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'> & VariantProps<typeof dotVariants>>(
+ function Dot({ className, variant = 'default', pulse = false, ...props }, ref) {
+ return (
+ <span
+ ref={ref}
+ data-quill
+ data-slot="dot"
+ className={cn(dotVariants({ variant, pulse }), className)}
+ {...props}
+ >
+ {pulse && (
+ <span
+ aria-hidden
+ data-slot="dot-pulse"
+ className="quill-dot__pulse pointer-events-none absolute inset-px"
+ />
+ )}
+ <span data-slot="dot-inner" className="quill-dot__inner" />
+ </span>
+ )
+ }
+)
export { Dot, dotVariants }
diff --git a/packages/quill/packages/primitives/src/drawer.tsx b/packages/quill/packages/primitives/src/drawer.tsx
index 04d23c5ce4ac..5a017211bd39 100644
--- a/packages/quill/packages/primitives/src/drawer.tsx
+++ b/packages/quill/packages/primitives/src/drawer.tsx
@@ -8,24 +8,29 @@ function Drawer({ ...props }: DrawerPrimitive.Root.Props): React.ReactElement {
return <DrawerPrimitive.Root data-slot="drawer" {...props} />
}
-const DrawerTrigger = React.forwardRef<HTMLButtonElement, DrawerPrimitive.Trigger.Props>(function DrawerTrigger(
- props,
- ref
-) {
- return <DrawerPrimitive.Trigger ref={ref} data-slot="drawer-trigger" {...props} />
-})
+const DrawerTrigger = React.forwardRef<HTMLButtonElement, DrawerPrimitive.Trigger.Props>(
+ function DrawerTrigger(props, ref) {
+ return <DrawerPrimitive.Trigger ref={ref} data-slot="drawer-trigger" {...props} />
+ }
+)
function DrawerPortal({ ...props }: DrawerPrimitive.Portal.Props): React.ReactElement {
return <DrawerPrimitive.Portal data-slot="drawer-portal" {...props} />
}
-function DrawerClose({ ...props }: DrawerPrimitive.Close.Props): React.ReactElement {
- return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />
-}
+const DrawerClose = React.forwardRef<React.ComponentRef<typeof DrawerPrimitive.Close>, DrawerPrimitive.Close.Props>(
+ function DrawerClose({ ...props }, ref) {
+ return <DrawerPrimitive.Close ref={ref} data-slot="drawer-close" {...props} />
+ }
+)
-function DrawerBackdrop({ className, ...props }: DrawerPrimitive.Backdrop.Props): React.ReactElement {
+const DrawerBackdrop = React.forwardRef<
+ React.ComponentRef<typeof DrawerPrimitive.Backdrop>,
+ DrawerPrimitive.Backdrop.Props
+>(function DrawerBackdrop({ className, ...props }, ref) {
return (
<DrawerPrimitive.Backdrop
+ ref={ref}
data-quill
data-quill-portal="drawer-backdrop"
data-slot="drawer-backdrop"
@@ -33,88 +38,104 @@ function DrawerBackdrop({ className, ...props }: DrawerPrimitive.Backdrop.Props)
{...props}
/>
)
-}
+})
-function DrawerContent({
- className,
- children,
- ...props
-}: DrawerPrimitive.Popup.Props): React.ReactElement {
- return (
- <DrawerPortal>
- <DrawerBackdrop />
- <DrawerPrimitive.Viewport
- data-quill
- data-quill-portal="drawer-viewport"
- data-slot="drawer-viewport"
- className="quill-drawer__viewport"
- >
- <DrawerPrimitive.Popup
+const DrawerContent = React.forwardRef<React.ComponentRef<typeof DrawerPrimitive.Popup>, DrawerPrimitive.Popup.Props>(
+ function DrawerContent({ className, children, ...props }, ref) {
+ return (
+ <DrawerPortal>
+ <DrawerBackdrop />
+ <DrawerPrimitive.Viewport
data-quill
- data-slot="drawer-content"
- className={cn('quill-drawer__content group/drawer-content flex h-auto flex-col', className)}
- {...props}
+ data-quill-portal="drawer-viewport"
+ data-slot="drawer-viewport"
+ className="quill-drawer__viewport"
>
- <DrawerHandle />
- <div className="w-full max-w-[32rem] mx-auto">
- {children}
- </div>
- </DrawerPrimitive.Popup>
- </DrawerPrimitive.Viewport>
- </DrawerPortal>
- )
-}
+ <DrawerPrimitive.Popup
+ ref={ref}
+ data-quill
+ data-slot="drawer-content"
+ className={cn('quill-drawer__content group/drawer-content flex h-auto flex-col', className)}
+ {...props}
+ >
+ <DrawerHandle />
+ <div className="w-full max-w-[32rem] mx-auto">{children}</div>
+ </DrawerPrimitive.Popup>
+ </DrawerPrimitive.Viewport>
+ </DrawerPortal>
+ )
+ }
+)
-function DrawerHandle({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const DrawerHandle = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function DrawerHandle(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="drawer-handle"
aria-hidden="true"
className={cn('quill-drawer__handle', className)}
{...props}
/>
)
-}
+})
-function DrawerHeader({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const DrawerHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function DrawerHeader(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="drawer-header"
className={cn('quill-drawer__header flex flex-col gap-1 p-4', className)}
{...props}
/>
)
-}
+})
-function DrawerFooter({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const DrawerFooter = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function DrawerFooter(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="drawer-footer"
className={cn('quill-drawer__footer mt-auto flex flex-col gap-2 p-4', className)}
{...props}
/>
)
-}
+})
-function DrawerTitle({ className, ...props }: DrawerPrimitive.Title.Props): React.ReactElement {
- return (
- <DrawerPrimitive.Title
- data-slot="drawer-title"
- className={cn('quill-drawer__title', className)}
- {...props}
- />
- )
-}
+const DrawerTitle = React.forwardRef<React.ComponentRef<typeof DrawerPrimitive.Title>, DrawerPrimitive.Title.Props>(
+ function DrawerTitle({ className, ...props }, ref) {
+ return (
+ <DrawerPrimitive.Title
+ ref={ref}
+ data-slot="drawer-title"
+ className={cn('quill-drawer__title', className)}
+ {...props}
+ />
+ )
+ }
+)
-function DrawerDescription({ className, ...props }: DrawerPrimitive.Description.Props): React.ReactElement {
+const DrawerDescription = React.forwardRef<
+ React.ComponentRef<typeof DrawerPrimitive.Description>,
+ DrawerPrimitive.Description.Props
+>(function DrawerDescription({ className, ...props }, ref) {
return (
<DrawerPrimitive.Description
+ ref={ref}
data-slot="drawer-description"
className={cn('quill-drawer__description', className)}
{...props}
/>
)
-}
+})
export {
Drawer,
diff --git a/packages/quill/packages/primitives/src/dropdown-menu.tsx b/packages/quill/packages/primitives/src/dropdown-menu.tsx
index 197bf5ec7051..2dc4ef012383 100644
--- a/packages/quill/packages/primitives/src/dropdown-menu.tsx
+++ b/packages/quill/packages/primitives/src/dropdown-menu.tsx
@@ -19,27 +19,20 @@ function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props): React.Rea
return <MenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
}
-const DropdownMenuTrigger = React.forwardRef<HTMLButtonElement, MenuPrimitive.Trigger.Props>(function DropdownMenuTrigger(
- props,
+const DropdownMenuTrigger = React.forwardRef<HTMLButtonElement, MenuPrimitive.Trigger.Props>(
+ function DropdownMenuTrigger(props, ref) {
+ return <MenuPrimitive.Trigger ref={ref} data-slot="dropdown-menu-trigger" {...props} />
+ }
+)
+
+const DropdownMenuContent = React.forwardRef<
+ React.ComponentRef<typeof MenuPrimitive.Popup>,
+ MenuPrimitive.Popup.Props &
+ Pick<MenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'anchor'>
+>(function DropdownMenuContent(
+ { align = 'start', alignOffset = 0, side = 'bottom', sideOffset = 4, className, anchor, children, ...props },
ref
) {
- return <MenuPrimitive.Trigger ref={ref} data-slot="dropdown-menu-trigger" {...props} />
-})
-
-function DropdownMenuContent({
- align = 'start',
- alignOffset = 0,
- side = 'bottom',
- sideOffset = 4,
- className,
- anchor,
- children,
- ...props
-}: MenuPrimitive.Popup.Props &
- Pick<
- MenuPrimitive.Positioner.Props,
- 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'anchor'
- >): React.ReactElement {
return (
<MenuPrimitive.Portal>
<MenuPrimitive.Positioner
@@ -53,6 +46,7 @@ function DropdownMenuContent({
anchor={anchor}
>
<MenuPrimitive.Popup
+ ref={ref}
data-slot="dropdown-menu-content"
className={cn('quill-menu__content w-(--anchor-width)', className)}
{...props}
@@ -62,21 +56,23 @@ function DropdownMenuContent({
</MenuPrimitive.Positioner>
</MenuPrimitive.Portal>
)
-}
+})
-function DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props): React.ReactElement {
- return <MenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
-}
+const DropdownMenuGroup = React.forwardRef<React.ComponentRef<typeof MenuPrimitive.Group>, MenuPrimitive.Group.Props>(
+ function DropdownMenuGroup({ ...props }, ref) {
+ return <MenuPrimitive.Group ref={ref} data-slot="dropdown-menu-group" {...props} />
+ }
+)
-function DropdownMenuLabel({
- className,
- inset,
- ...props
-}: MenuPrimitive.GroupLabel.Props & {
- inset?: boolean
-}): React.ReactElement {
+const DropdownMenuLabel = React.forwardRef<
+ React.ComponentRef<typeof MenuPrimitive.GroupLabel>,
+ MenuPrimitive.GroupLabel.Props & {
+ inset?: boolean
+ }
+>(function DropdownMenuLabel({ className, inset, ...props }, ref) {
return (
<MenuPrimitive.GroupLabel
+ ref={ref}
data-slot="dropdown-menu-label"
data-inset={inset}
className={cn(inset && 'quill-menu-item--inset', className)}
@@ -84,19 +80,18 @@ function DropdownMenuLabel({
{...props}
/>
)
-}
+})
-function DropdownMenuItem({
- className,
- inset,
- variant = 'default',
- ...props
-}: MenuPrimitive.Item.Props & {
- inset?: boolean
- variant?: 'default' | 'destructive'
-}): React.ReactElement {
+const DropdownMenuItem = React.forwardRef<
+ React.ComponentRef<typeof MenuPrimitive.Item>,
+ MenuPrimitive.Item.Props & {
+ inset?: boolean
+ variant?: 'default' | 'destructive'
+ }
+>(function DropdownMenuItem({ className, inset, variant = 'default', ...props }, ref) {
return (
<MenuPrimitive.Item
+ ref={ref}
data-slot="dropdown-menu-item"
data-inset={inset}
data-variant={variant}
@@ -112,22 +107,21 @@ function DropdownMenuItem({
{...props}
/>
)
-}
+})
function DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props): React.ReactElement {
return <MenuPrimitive.SubmenuRoot data-slot="dropdown-menu-sub" {...props} />
}
-function DropdownMenuSubTrigger({
- className,
- inset,
- children,
- ...props
-}: MenuPrimitive.SubmenuTrigger.Props & {
- inset?: boolean
-}): React.ReactElement {
+const DropdownMenuSubTrigger = React.forwardRef<
+ React.ComponentRef<typeof MenuPrimitive.SubmenuTrigger>,
+ MenuPrimitive.SubmenuTrigger.Props & {
+ inset?: boolean
+ }
+>(function DropdownMenuSubTrigger({ className, inset, children, ...props }, ref) {
return (
<MenuPrimitive.SubmenuTrigger
+ ref={ref}
data-slot="dropdown-menu-sub-trigger"
data-inset={inset}
className={cn(
@@ -145,18 +139,18 @@ function DropdownMenuSubTrigger({
<ChevronRightIcon className="rtl:rotate-180 ms-auto" />
</MenuPrimitive.SubmenuTrigger>
)
-}
+})
-function DropdownMenuSubContent({
- align = 'start',
- alignOffset = -3,
- side = 'inline-end',
- sideOffset = 0,
- className,
- ...props
-}: React.ComponentProps<typeof DropdownMenuContent>): React.ReactElement {
+const DropdownMenuSubContent = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuContent>,
+ React.ComponentProps<typeof DropdownMenuContent>
+>(function DropdownMenuSubContent(
+ { align = 'start', alignOffset = -3, side = 'inline-end', sideOffset = 0, className, ...props },
+ ref
+) {
return (
<DropdownMenuContent
+ ref={ref}
data-slot="dropdown-menu-sub-content"
className={cn('quill-menu__sub-content w-auto', className)}
align={align}
@@ -166,19 +160,17 @@ function DropdownMenuSubContent({
{...props}
/>
)
-}
+})
-function DropdownMenuCheckboxItem({
- className,
- children,
- checked,
- inset,
- ...props
-}: MenuPrimitive.CheckboxItem.Props & {
- inset?: boolean
-}): React.ReactElement {
+const DropdownMenuCheckboxItem = React.forwardRef<
+ React.ComponentRef<typeof MenuPrimitive.CheckboxItem>,
+ MenuPrimitive.CheckboxItem.Props & {
+ inset?: boolean
+ }
+>(function DropdownMenuCheckboxItem({ className, children, checked, inset, ...props }, ref) {
return (
<MenuPrimitive.CheckboxItem
+ ref={ref}
data-slot="dropdown-menu-checkbox-item"
data-inset={inset}
className={cn(
@@ -204,22 +196,24 @@ function DropdownMenuCheckboxItem({
{children}
</MenuPrimitive.CheckboxItem>
)
-}
+})
-function DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props): React.ReactElement {
- return <MenuPrimitive.RadioGroup data-slot="dropdown-menu-radio-group" {...props} />
-}
+const DropdownMenuRadioGroup = React.forwardRef<
+ React.ComponentRef<typeof MenuPrimitive.RadioGroup>,
+ MenuPrimitive.RadioGroup.Props
+>(function DropdownMenuRadioGroup({ ...props }, ref) {
+ return <MenuPrimitive.RadioGroup ref={ref} data-slot="dropdown-menu-radio-group" {...props} />
+})
-function DropdownMenuRadioItem({
- className,
- children,
- inset,
- ...props
-}: MenuPrimitive.RadioItem.Props & {
- inset?: boolean
-}): React.ReactElement {
+const DropdownMenuRadioItem = React.forwardRef<
+ React.ComponentRef<typeof MenuPrimitive.RadioItem>,
+ MenuPrimitive.RadioItem.Props & {
+ inset?: boolean
+ }
+>(function DropdownMenuRadioItem({ className, children, inset, ...props }, ref) {
return (
<MenuPrimitive.RadioItem
+ ref={ref}
data-slot="dropdown-menu-radio-item"
data-inset={inset}
className={cn(
@@ -244,17 +238,21 @@ function DropdownMenuRadioItem({
{children}
</MenuPrimitive.RadioItem>
)
-}
+})
-function DropdownMenuSeparator({ className, ...props }: MenuPrimitive.Separator.Props): React.ReactElement {
+const DropdownMenuSeparator = React.forwardRef<
+ React.ComponentRef<typeof MenuPrimitive.Separator>,
+ MenuPrimitive.Separator.Props
+>(function DropdownMenuSeparator({ className, ...props }, ref) {
return (
<MenuPrimitive.Separator
+ ref={ref}
data-slot="dropdown-menu-separator"
className={cn('quill-menu__separator', className)}
{...props}
/>
)
-}
+})
/**
* Tri-state for a select-all action over a list of selectable values.
@@ -378,9 +376,18 @@ function DropdownMenuSelectAll<T>({
)
}
-function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<typeof Kbd>): React.ReactElement {
- return <Kbd data-slot="dropdown-menu-shortcut" className={cn('quill-menu__shortcut', className)} {...props} />
-}
+const DropdownMenuShortcut = React.forwardRef<React.ComponentRef<typeof Kbd>, React.ComponentProps<typeof Kbd>>(
+ function DropdownMenuShortcut({ className, ...props }, ref) {
+ return (
+ <Kbd
+ ref={ref}
+ data-slot="dropdown-menu-shortcut"
+ className={cn('quill-menu__shortcut', className)}
+ {...props}
+ />
+ )
+ }
+)
export {
DropdownMenu,
diff --git a/packages/quill/packages/primitives/src/empty.tsx b/packages/quill/packages/primitives/src/empty.tsx
index 0a120a26a824..aa0d7a0bc3bc 100644
--- a/packages/quill/packages/primitives/src/empty.tsx
+++ b/packages/quill/packages/primitives/src/empty.tsx
@@ -4,9 +4,13 @@ import * as React from 'react'
import './empty.css'
import { cn } from './lib/utils'
-function Empty({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const Empty = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function Empty(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-quill
data-slot="empty"
className={cn(
@@ -16,17 +20,21 @@ function Empty({ className, ...props }: React.ComponentProps<'div'>): React.Reac
{...props}
/>
)
-}
+})
-function EmptyHeader({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const EmptyHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function EmptyHeader(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="empty-header"
className={cn('flex max-w-sm flex-col items-center gap-1', className)}
{...props}
/>
)
-}
+})
const emptyMediaVariants = cva('quill-empty__media flex shrink-0 items-center justify-center', {
variants: {
@@ -40,37 +48,49 @@ const emptyMediaVariants = cva('quill-empty__media flex shrink-0 items-center ju
},
})
-function EmptyMedia({
- className,
- variant = 'default',
- ...props
-}: React.ComponentProps<'div'> & VariantProps<typeof emptyMediaVariants>): React.ReactElement {
+const EmptyMedia = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & VariantProps<typeof emptyMediaVariants>
+>(function EmptyMedia({ className, variant = 'default', ...props }, ref) {
return (
<div
+ ref={ref}
data-slot="empty-icon"
data-variant={variant}
className={cn(emptyMediaVariants({ variant, className }))}
{...props}
/>
)
-}
+})
-function EmptyTitle({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="empty-title" className={cn('quill-empty__title', className)} {...props} />
-}
+const EmptyTitle = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function EmptyTitle(
+ { className, ...props },
+ ref
+) {
+ return <div ref={ref} data-slot="empty-title" className={cn('quill-empty__title', className)} {...props} />
+})
-function EmptyDescription({ className, ...props }: React.ComponentProps<'p'>): React.ReactElement {
- return <div data-slot="empty-description" className={cn('quill-empty__description', className)} {...props} />
-}
+const EmptyDescription = React.forwardRef<HTMLDivElement, React.ComponentProps<'p'>>(function EmptyDescription(
+ { className, ...props },
+ ref
+) {
+ return (
+ <div ref={ref} data-slot="empty-description" className={cn('quill-empty__description', className)} {...props} />
+ )
+})
-function EmptyContent({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const EmptyContent = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function EmptyContent(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="empty-content"
className={cn('quill-empty__content flex w-full max-w-sm min-w-0 flex-col items-center gap-2', className)}
{...props}
/>
)
-}
+})
export { Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent, EmptyMedia }
diff --git a/packages/quill/packages/primitives/src/field.tsx b/packages/quill/packages/primitives/src/field.tsx
index d2b57a88066b..6a13b589fabd 100644
--- a/packages/quill/packages/primitives/src/field.tsx
+++ b/packages/quill/packages/primitives/src/field.tsx
@@ -7,9 +7,13 @@ import { Label } from './label'
import { cn } from './lib/utils'
import { Separator } from './separator'
-function FieldSet({ className, ...props }: React.ComponentProps<'fieldset'>): React.ReactElement {
+const FieldSet = React.forwardRef<HTMLFieldSetElement, React.ComponentProps<'fieldset'>>(function FieldSet(
+ { className, ...props },
+ ref
+) {
return (
<fieldset
+ ref={ref}
data-slot="field-set"
className={cn(
'quill-field-set flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',
@@ -18,26 +22,30 @@ function FieldSet({ className, ...props }: React.ComponentProps<'fieldset'>): Re
{...props}
/>
)
-}
+})
-function FieldLegend({
- className,
- variant = 'legend',
- ...props
-}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }): React.ReactElement {
+const FieldLegend = React.forwardRef<
+ HTMLLegendElement,
+ React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }
+>(function FieldLegend({ className, variant = 'legend', ...props }, ref) {
return (
<legend
+ ref={ref}
data-slot="field-legend"
data-variant={variant}
className={cn('quill-field-legend', className)}
{...props}
/>
)
-}
+})
-function FieldGroup({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const FieldGroup = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function FieldGroup(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="field-group"
className={cn(
'group/field-group @container/field-group flex w-full flex-col gap-4 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4',
@@ -46,7 +54,7 @@ function FieldGroup({ className, ...props }: React.ComponentProps<'div'>): React
{...props}
/>
)
-}
+})
const fieldVariants = cva('quill-field group/field flex w-full gap-x-2 gap-y-1', {
variants: {
@@ -63,72 +71,91 @@ const fieldVariants = cva('quill-field group/field flex w-full gap-x-2 gap-y-1',
},
})
-function Field({
- className,
- orientation = 'vertical',
- ...props
-}: React.ComponentProps<'div'> & VariantProps<typeof fieldVariants>): React.ReactElement {
- return (
- <div
- role="group"
- data-quill
- data-slot="field"
- data-orientation={orientation}
- className={cn(fieldVariants({ orientation }), className)}
- {...props}
- />
- )
-}
+const Field = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'> & VariantProps<typeof fieldVariants>>(
+ function Field({ className, orientation = 'vertical', ...props }, ref) {
+ return (
+ <div
+ ref={ref}
+ role="group"
+ data-quill
+ data-slot="field"
+ data-orientation={orientation}
+ className={cn(fieldVariants({ orientation }), className)}
+ {...props}
+ />
+ )
+ }
+)
-function FieldContent({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const FieldContent = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function FieldContent(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="field-content"
className={cn('quill-field__content group/field-content flex flex-1 flex-col gap-0.5', className)}
{...props}
/>
)
-}
+})
-function FieldLabel({ className, ...props }: React.ComponentProps<typeof Label>): React.ReactElement {
- return (
- <Label
- data-slot="field-label"
- className={cn('quill-field__label group/field-label peer/field-label flex w-fit gap-2', className)}
- {...props}
- />
- )
-}
+const FieldLabel = React.forwardRef<React.ComponentRef<typeof Label>, React.ComponentProps<typeof Label>>(
+ function FieldLabel({ className, ...props }, ref) {
+ return (
+ <Label
+ ref={ref}
+ data-slot="field-label"
+ className={cn('quill-field__label group/field-label peer/field-label flex w-fit gap-2', className)}
+ {...props}
+ />
+ )
+ }
+)
-function FieldTitle({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const FieldTitle = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function FieldTitle(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="field-label"
className={cn('quill-field__title flex w-fit items-center gap-2', className)}
{...props}
/>
)
-}
+})
-function FieldDescription({ className, ...props }: React.ComponentProps<'p'>): React.ReactElement {
+const FieldDescription = React.forwardRef<HTMLParagraphElement, React.ComponentProps<'p'>>(function FieldDescription(
+ { className, ...props },
+ ref
+) {
return (
<p
+ ref={ref}
data-slot="field-description"
className={cn('quill-field__description last:mt-0 nth-last-2:mt-0', className)}
{...props}
/>
)
-}
+})
-function FieldSeparator({
- children,
- className,
- ...props
-}: React.ComponentProps<'div'> & {
- children?: React.ReactNode
-}): React.ReactElement {
+const FieldSeparator = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & {
+ children?: React.ReactNode
+ }
+>(function FieldSeparator({ children, className, ...props }, ref) {
return (
- <div data-slot="field-separator" data-content={!!children} className={cn('quill-field__separator', className)} {...props}>
+ <div
+ ref={ref}
+ data-slot="field-separator"
+ data-content={!!children}
+ className={cn('quill-field__separator', className)}
+ {...props}
+ >
<Separator className="absolute inset-0 top-1/2" />
{children && (
<span className="quill-field__separator-content" data-slot="field-separator-content">
@@ -137,16 +164,14 @@ function FieldSeparator({
)}
</div>
)
-}
+})
-function FieldError({
- className,
- children,
- errors,
- ...props
-}: React.ComponentProps<'div'> & {
- errors?: Array<{ message?: string } | undefined>
-}): React.ReactElement | null {
+const FieldError = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & {
+ errors?: Array<{ message?: string } | undefined>
+ }
+>(function FieldError({ className, children, errors, ...props }, ref) {
const content = useMemo(() => {
if (children) {
return children
@@ -174,11 +199,11 @@ function FieldError({
}
return (
- <div role="alert" data-slot="field-error" className={cn('quill-field__error', className)} {...props}>
+ <div ref={ref} role="alert" data-slot="field-error" className={cn('quill-field__error', className)} {...props}>
{content}
</div>
)
-}
+})
export {
Field,
diff --git a/packages/quill/packages/primitives/src/heading.tsx b/packages/quill/packages/primitives/src/heading.tsx
index cbabf9b2f2d7..9a69e9bb6a95 100644
--- a/packages/quill/packages/primitives/src/heading.tsx
+++ b/packages/quill/packages/primitives/src/heading.tsx
@@ -22,13 +22,12 @@ const headingVariants = cva('text-foreground font-semibold text-balance', {
},
})
-function Heading({
- className,
- size = 'lg',
- render,
- ...props
-}: useRender.ComponentProps<'h2'> & VariantProps<typeof headingVariants>): React.ReactElement {
+const Heading = React.forwardRef<
+ HTMLHeadingElement,
+ useRender.ComponentProps<'h2'> & VariantProps<typeof headingVariants>
+>(function Heading({ className, size = 'lg', render, ...props }, ref) {
return useRender({
+ ref,
defaultTagName: 'h2',
props: mergeProps<'h2'>(
{
@@ -43,6 +42,6 @@ function Heading({
size,
},
})
-}
+})
export { Heading, headingVariants }
diff --git a/packages/quill/packages/primitives/src/highlight.tsx b/packages/quill/packages/primitives/src/highlight.tsx
index 132c18ce8dd7..87d490684dbc 100644
--- a/packages/quill/packages/primitives/src/highlight.tsx
+++ b/packages/quill/packages/primitives/src/highlight.tsx
@@ -51,15 +51,10 @@ interface HighlightProps extends Omit<useRender.ComponentProps<'mark'>, 'color'>
delay?: number
}
-function Highlight({
- className,
- color = 'orange',
- animate = false,
- duration,
- delay = 0,
- render,
- ...props
-}: HighlightProps): React.ReactElement {
+const Highlight = React.forwardRef<HTMLElement, HighlightProps>(function Highlight(
+ { className, color = 'orange', animate = false, duration, delay = 0, render, ...props },
+ ref
+) {
const elementRef = React.useRef<HTMLElement>(null)
const reducedMotion = useReducedMotion()
const strokes = animate && !reducedMotion
@@ -73,7 +68,11 @@ function Highlight({
}
// Re-arm when `animate` turns back on after an earlier stroke.
setStroke(WAITING)
- const draw = (): void => setStroke({ phase: 'drawing', durationMs: strokeDuration(element.textContent ?? '') })
+ const draw = (): void =>
+ setStroke({
+ phase: 'drawing',
+ durationMs: strokeDuration(element.textContent ?? ''),
+ })
if (typeof IntersectionObserver === 'undefined') {
draw()
return
@@ -90,7 +89,7 @@ function Highlight({
return useRender({
defaultTagName: 'mark',
- ref: elementRef,
+ ref: [elementRef, ref],
props: mergeProps<'mark'>(
{
'data-quill': '',
@@ -117,7 +116,7 @@ function Highlight({
phase: stroke.phase,
},
})
-}
+})
export { Highlight, highlightVariants }
export type { HighlightColor, HighlightProps }
diff --git a/packages/quill/packages/primitives/src/icon-stack.tsx b/packages/quill/packages/primitives/src/icon-stack.tsx
index 5480cb2a6929..fbf393cef22e 100644
--- a/packages/quill/packages/primitives/src/icon-stack.tsx
+++ b/packages/quill/packages/primitives/src/icon-stack.tsx
@@ -5,14 +5,23 @@ import * as React from 'react'
import './icon-stack.css'
import { cn } from './lib/utils'
-function IconStack({ className, children, style, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+const IconStack = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(function IconStack(
+ { className, children, style, ...props },
+ ref
+) {
const items = React.Children.toArray(children)
return (
<span
+ ref={ref}
data-quill
data-slot="icon-stack"
className={cn('quill-icon-stack', className)}
- style={{ ...style, '--icon-stack-count': items.length } as React.CSSProperties}
+ style={
+ {
+ ...style,
+ '--icon-stack-count': items.length,
+ } as React.CSSProperties
+ }
{...props}
>
{items.map((child, index) => (
@@ -26,23 +35,25 @@ function IconStack({ className, children, style, ...props }: React.ComponentProp
))}
</span>
)
-}
+})
-function IconStackItem({
- className,
- color,
- active = false,
- style,
- render,
- ...props
-}: useRender.ComponentProps<'span'> & { color?: string; active?: boolean }): React.ReactElement {
+const IconStackItem = React.forwardRef<
+ HTMLSpanElement,
+ useRender.ComponentProps<'span'> & { color?: string; active?: boolean }
+>(function IconStackItem({ className, color, active = false, style, render, ...props }, ref) {
return useRender({
+ ref,
defaultTagName: 'span',
props: mergeProps<'span'>(
{
'aria-hidden': render ? undefined : true,
className: cn('quill-icon-stack__item', className),
- style: color ? ({ ...style, '--icon-stack-color': color } as React.CSSProperties) : style,
+ style: color
+ ? ({
+ ...style,
+ '--icon-stack-color': color,
+ } as React.CSSProperties)
+ : style,
},
props
),
@@ -53,6 +64,6 @@ function IconStackItem({
colored: !!color,
},
})
-}
+})
export { IconStack, IconStackItem }
diff --git a/packages/quill/packages/primitives/src/input-group.tsx b/packages/quill/packages/primitives/src/input-group.tsx
index c6002ea73631..c63d9699a55f 100644
--- a/packages/quill/packages/primitives/src/input-group.tsx
+++ b/packages/quill/packages/primitives/src/input-group.tsx
@@ -39,13 +39,13 @@ const inputGroupAddonVariants = cva(
}
)
-function InputGroupAddon({
- className,
- align = 'inline-start',
- ...props
-}: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>): React.ReactElement {
+const InputGroupAddon = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>
+>(function InputGroupAddon({ className, align = 'inline-start', ...props }, ref) {
return (
<div
+ ref={ref}
role="group"
data-slot="input-group-addon"
data-align={align}
@@ -59,7 +59,7 @@ function InputGroupAddon({
{...props}
/>
)
-}
+})
const inputGroupButtonVariants = cva('quill-input-group__button flex items-center gap-2', {
variants: {
@@ -95,9 +95,12 @@ const InputGroupButton = React.forwardRef<
})
InputGroupButton.displayName = 'InputGroupButton'
-function InputGroupText({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return <span className={cn('quill-input-group__text flex items-end gap-2', className)} {...props} />
-}
+const InputGroupText = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(function InputGroupText(
+ { className, ...props },
+ ref
+) {
+ return <span ref={ref} className={cn('quill-input-group__text flex items-end gap-2', className)} {...props} />
+})
const InputGroupInput = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
({ className, ...props }, ref) => {
@@ -113,40 +116,41 @@ const InputGroupInput = React.forwardRef<HTMLInputElement, React.ComponentProps<
)
InputGroupInput.displayName = 'InputGroupInput'
-function InputGroupTextarea({ className, ...props }: React.ComponentProps<'textarea'>): React.ReactElement {
- return (
- <Textarea
- data-slot="input-group-control"
- className={cn('quill-input-group__control quill-input-group__control--textarea', className)}
- {...props}
- />
- )
-}
+const InputGroupTextarea = React.forwardRef<React.ComponentRef<typeof Textarea>, React.ComponentProps<'textarea'>>(
+ function InputGroupTextarea({ className, ...props }, ref) {
+ return (
+ <Textarea
+ ref={ref}
+ data-slot="input-group-control"
+ className={cn('quill-input-group__control quill-input-group__control--textarea', className)}
+ {...props}
+ />
+ )
+ }
+)
interface InputGroupNumberInputProps extends Omit<NumberField.Root.Props, 'className' | 'children'> {
className?: string
inputRef?: React.Ref<HTMLInputElement>
}
-function InputGroupNumberInput({
- className,
- inputRef,
- ...rootProps
-}: InputGroupNumberInputProps): React.ReactElement {
- return (
- <NumberField.Root {...rootProps}>
- <NumberField.ScrubArea data-slot="input-group-scrub-area" className="cursor-ew-resize">
- <NumberField.Input
- ref={inputRef}
- data-slot="input-group-control"
- className={cn(
- 'quill-input-group__control h-8 w-full min-w-0 px-2 py-0.5 text-[length:var(--text-ui,0.8125rem)] tabular-nums text-center outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
- className
- )}
- />
- </NumberField.ScrubArea>
- </NumberField.Root>
- )
-}
+const InputGroupNumberInput = React.forwardRef<React.ComponentRef<typeof NumberField.Root>, InputGroupNumberInputProps>(
+ function InputGroupNumberInput({ className, inputRef, ...rootProps }, ref) {
+ return (
+ <NumberField.Root ref={ref} {...rootProps}>
+ <NumberField.ScrubArea data-slot="input-group-scrub-area" className="cursor-ew-resize">
+ <NumberField.Input
+ ref={inputRef}
+ data-slot="input-group-control"
+ className={cn(
+ 'quill-input-group__control h-8 w-full min-w-0 px-2 py-0.5 text-[length:var(--text-ui,0.8125rem)] tabular-nums text-center outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
+ className
+ )}
+ />
+ </NumberField.ScrubArea>
+ </NumberField.Root>
+ )
+ }
+)
export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupText, InputGroupInput, InputGroupNumberInput, InputGroupTextarea }
diff --git a/packages/quill/packages/primitives/src/item.tsx b/packages/quill/packages/primitives/src/item.tsx
index 018d4b681075..1c597c3019a4 100644
--- a/packages/quill/packages/primitives/src/item.tsx
+++ b/packages/quill/packages/primitives/src/item.tsx
@@ -9,31 +9,38 @@ import { cn } from './lib/utils'
import { RadioIndicator } from './radio-group'
import { Separator } from './separator'
-function ItemGroup({
- className,
- combined = false,
- ...props
-}: React.ComponentProps<'div'> & { combined?: boolean }): React.ReactElement {
- return (
- <div
- role="list"
- data-slot="item-group"
- data-combined={combined ? '' : undefined}
- className={cn(
- 'quill-item-group group/item-group flex w-full flex-col',
- combined ? 'gap-0' : 'gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2',
- className
- )}
- {...props}
- />
- )
-}
+const ItemGroup = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'> & { combined?: boolean }>(
+ function ItemGroup({ className, combined = false, ...props }, ref) {
+ return (
+ <div
+ ref={ref}
+ role="list"
+ data-slot="item-group"
+ data-combined={combined ? '' : undefined}
+ className={cn(
+ 'quill-item-group group/item-group flex w-full flex-col',
+ combined ? 'gap-0' : 'gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2',
+ className
+ )}
+ {...props}
+ />
+ )
+ }
+)
-function ItemSeparator({ className, ...props }: React.ComponentProps<typeof Separator>): React.ReactElement {
- return (
- <Separator data-slot="item-separator" orientation="horizontal" className={cn('my-2', className)} {...props} />
- )
-}
+const ItemSeparator = React.forwardRef<React.ComponentRef<typeof Separator>, React.ComponentProps<typeof Separator>>(
+ function ItemSeparator({ className, ...props }, ref) {
+ return (
+ <Separator
+ ref={ref}
+ data-slot="item-separator"
+ orientation="horizontal"
+ className={cn('my-2', className)}
+ {...props}
+ />
+ )
+ }
+)
const itemVariants = cva(
'quill-item item group/item flex w-full flex-wrap items-center',
@@ -68,35 +75,30 @@ const itemVariants = cva(
}
)
-function Item({
- className,
- variant = 'default',
- size = 'default',
- tone = 'default',
- role,
- render,
- ...props
-}: useRender.ComponentProps<'div'> & VariantProps<typeof itemVariants>): React.ReactElement {
- return useRender({
- defaultTagName: 'div',
- props: mergeProps<'div'>(
- {
- 'data-quill': '',
- 'data-tone': tone && tone !== 'default' ? tone : undefined,
- className: cn(itemVariants({ variant, size, tone, className })),
- role: variant === 'pressable' ? 'link' : undefined,
- } as Omit<React.ComponentProps<'div'>, 'ref'>,
- props
- ),
- render,
- state: {
- slot: 'item',
- variant,
- size,
- tone,
- },
- })
-}
+const Item = React.forwardRef<HTMLDivElement, useRender.ComponentProps<'div'> & VariantProps<typeof itemVariants>>(
+ function Item({ className, variant = 'default', size = 'default', tone = 'default', role, render, ...props }, ref) {
+ return useRender({
+ ref,
+ defaultTagName: 'div',
+ props: mergeProps<'div'>(
+ {
+ 'data-quill': '',
+ 'data-tone': tone && tone !== 'default' ? tone : undefined,
+ className: cn(itemVariants({ variant, size, tone, className })),
+ role: variant === 'pressable' ? 'link' : undefined,
+ } as Omit<React.ComponentProps<'div'>, 'ref'>,
+ props
+ ),
+ render,
+ state: {
+ slot: 'item',
+ variant,
+ size,
+ tone,
+ },
+ })
+ }
+)
const ItemMenuItem = React.forwardRef<
HTMLButtonElement,
@@ -199,20 +201,20 @@ const itemMediaVariants = cva('quill-item__media flex shrink-0 items-center just
},
})
-function ItemMedia({
- className,
- variant = 'default',
- ...props
-}: React.ComponentProps<'div'> & VariantProps<typeof itemMediaVariants>): React.ReactElement {
+const ItemMedia = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & VariantProps<typeof itemMediaVariants>
+>(function ItemMedia({ className, variant = 'default', ...props }, ref) {
return (
<div
+ ref={ref}
data-slot="item-media"
data-variant={variant}
className={cn(itemMediaVariants({ variant, className }))}
{...props}
/>
)
-}
+})
const itemContentVariants = cva('quill-item__content flex flex-1 flex-col gap-1', {
variants: {
@@ -226,45 +228,68 @@ const itemContentVariants = cva('quill-item__content flex flex-1 flex-col gap-1'
},
})
-function ItemContent({
- className,
- variant = 'default',
- ...props
-}: React.ComponentProps<'div'> & VariantProps<typeof itemContentVariants>): React.ReactElement {
- return <div data-slot="item-content" className={cn(itemContentVariants({ variant, className }))} {...props} />
-}
+const ItemContent = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<'div'> & VariantProps<typeof itemContentVariants>
+>(function ItemContent({ className, variant = 'default', ...props }, ref) {
+ return (
+ <div
+ ref={ref}
+ data-slot="item-content"
+ className={cn(itemContentVariants({ variant, className }))}
+ {...props}
+ />
+ )
+})
-function ItemTitle({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="item-title" className={cn('quill-item__title gap-2', className)} {...props} />
-}
+const ItemTitle = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ItemTitle(
+ { className, ...props },
+ ref
+) {
+ return <div ref={ref} data-slot="item-title" className={cn('quill-item__title gap-2', className)} {...props} />
+})
-function ItemDescription({ className, ...props }: React.ComponentProps<'p'>): React.ReactElement {
- return <p data-slot="item-description" className={cn('quill-item__description', className)} {...props} />
-}
+const ItemDescription = React.forwardRef<HTMLParagraphElement, React.ComponentProps<'p'>>(function ItemDescription(
+ { className, ...props },
+ ref
+) {
+ return <p ref={ref} data-slot="item-description" className={cn('quill-item__description', className)} {...props} />
+})
-function ItemActions({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="item-actions" className={cn('flex items-center gap-2', className)} {...props} />
-}
+const ItemActions = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ItemActions(
+ { className, ...props },
+ ref
+) {
+ return <div ref={ref} data-slot="item-actions" className={cn('flex items-center gap-2', className)} {...props} />
+})
-function ItemHeader({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const ItemHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ItemHeader(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="item-header"
className={cn('flex basis-full items-center justify-between gap-2', className)}
{...props}
/>
)
-}
+})
-function ItemFooter({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const ItemFooter = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function ItemFooter(
+ { className, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
data-slot="item-footer"
className={cn('flex basis-full items-center justify-between gap-2', className)}
{...props}
/>
)
-}
+})
export {
Item,
diff --git a/packages/quill/packages/primitives/src/kbd.tsx b/packages/quill/packages/primitives/src/kbd.tsx
index 44e1aee7729d..ba3afc6592b5 100644
--- a/packages/quill/packages/primitives/src/kbd.tsx
+++ b/packages/quill/packages/primitives/src/kbd.tsx
@@ -4,9 +4,10 @@ import { buttonVariants } from './button'
import './kbd.css'
import { cn } from './lib/utils'
-function Kbd({ className, ...props }: React.ComponentProps<'kbd'>): React.ReactElement {
+const Kbd = React.forwardRef<HTMLElement, React.ComponentProps<'kbd'>>(function Kbd({ className, ...props }, ref) {
return (
<kbd
+ ref={ref}
data-quill
data-slot="kbd"
className={cn(
@@ -17,20 +18,29 @@ function Kbd({ className, ...props }: React.ComponentProps<'kbd'>): React.ReactE
{...props}
/>
)
-}
+})
-function KbdText({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+const KbdText = React.forwardRef<HTMLElement, React.ComponentProps<'span'>>(function KbdText(
+ { className, ...props },
+ ref
+) {
return (
<kbd
+ ref={ref}
data-slot="kbd-text"
className={cn('quill-kbd-text inline-flex w-fit items-center justify-center gap-1', className)}
{...props}
/>
)
-}
+})
-function KbdGroup({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <kbd data-slot="kbd-group" className={cn('inline-flex items-center gap-1', className)} {...props} />
-}
+const KbdGroup = React.forwardRef<HTMLElement, React.ComponentProps<'div'>>(function KbdGroup(
+ { className, ...props },
+ ref
+) {
+ return (
+ <kbd ref={ref} data-slot="kbd-group" className={cn('inline-flex items-center gap-1', className)} {...props} />
+ )
+})
export { Kbd, KbdGroup, KbdText }
diff --git a/packages/quill/packages/primitives/src/label.tsx b/packages/quill/packages/primitives/src/label.tsx
index 7f4f3456f85c..93c715fd6b80 100644
--- a/packages/quill/packages/primitives/src/label.tsx
+++ b/packages/quill/packages/primitives/src/label.tsx
@@ -3,15 +3,19 @@ import * as React from 'react'
import './label.css'
import { cn } from './lib/utils'
-function Label({ className, ...props }: React.ComponentProps<'label'>): React.ReactElement {
+const Label = React.forwardRef<HTMLLabelElement, React.ComponentProps<'label'>>(function Label(
+ { className, ...props },
+ ref
+) {
return (
<label
+ ref={ref}
data-quill
data-slot="label"
className={cn('quill-label flex items-center gap-2', className)}
{...props}
/>
)
-}
+})
export { Label }
diff --git a/packages/quill/packages/primitives/src/menu-empty.tsx b/packages/quill/packages/primitives/src/menu-empty.tsx
index 758c6f79be0d..96055b9df220 100644
--- a/packages/quill/packages/primitives/src/menu-empty.tsx
+++ b/packages/quill/packages/primitives/src/menu-empty.tsx
@@ -3,9 +3,13 @@ import * as React from 'react'
import { buttonVariants } from './button'
import { cn } from './lib/utils'
-function MenuEmpty({ className, children, ...props }: React.ComponentProps<'div'>): React.ReactElement {
+const MenuEmpty = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function MenuEmpty(
+ { className, children, ...props },
+ ref
+) {
return (
<div
+ ref={ref}
{...props}
data-slot="menu-empty"
role="status"
@@ -15,6 +19,6 @@ function MenuEmpty({ className, children, ...props }: React.ComponentProps<'div'
{children}
</div>
)
-}
+})
export { MenuEmpty }
diff --git a/packages/quill/packages/primitives/src/menu-label.tsx b/packages/quill/packages/primitives/src/menu-label.tsx
index 9904ad7e5827..a723e4f99424 100644
--- a/packages/quill/packages/primitives/src/menu-label.tsx
+++ b/packages/quill/packages/primitives/src/menu-label.tsx
@@ -7,8 +7,12 @@ import './menu-label.css'
// Section label for menus/lists. Defaults to a <div>; pass render=<label /> to
// bind it to a control.
-function MenuLabel({ className, render, ...props }: useRender.ComponentProps<'div'>): React.ReactElement {
+const MenuLabel = React.forwardRef<HTMLDivElement, useRender.ComponentProps<'div'>>(function MenuLabel(
+ { className, render, ...props },
+ ref
+) {
return useRender({
+ ref,
defaultTagName: 'div',
props: mergeProps<'div'>(
{
@@ -20,6 +24,6 @@ function MenuLabel({ className, render, ...props }: useRender.ComponentProps<'di
),
render,
})
-}
+})
export { MenuLabel }
diff --git a/packages/quill/packages/primitives/src/menubar.tsx b/packages/quill/packages/primitives/src/menubar.tsx
index ab6102a945e6..e5fd456e4a61 100644
--- a/packages/quill/packages/primitives/src/menubar.tsx
+++ b/packages/quill/packages/primitives/src/menubar.tsx
@@ -23,48 +23,57 @@ import {
} from './dropdown-menu'
import { cn } from './lib/utils'
-function Menubar({ className, ...props }: MenubarPrimitive.Props): React.ReactElement {
+const Menubar = React.forwardRef<React.ComponentRef<typeof MenubarPrimitive>, MenubarPrimitive.Props>(function Menubar(
+ { className, ...props },
+ ref
+) {
return (
<MenubarPrimitive
+ ref={ref}
data-quill
data-slot="menubar"
className={cn('quill-menubar flex items-center', className)}
{...props}
/>
)
-}
+})
function MenubarMenu({ ...props }: React.ComponentProps<typeof DropdownMenu>): React.ReactElement {
return <DropdownMenu data-slot="menubar-menu" {...props} />
}
-function MenubarGroup({ ...props }: React.ComponentProps<typeof DropdownMenuGroup>): React.ReactElement {
- return <DropdownMenuGroup data-slot="menubar-group" {...props} />
-}
+const MenubarGroup = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuGroup>,
+ React.ComponentProps<typeof DropdownMenuGroup>
+>(function MenubarGroup({ ...props }, ref) {
+ return <DropdownMenuGroup ref={ref} data-slot="menubar-group" {...props} />
+})
function MenubarPortal({ ...props }: React.ComponentProps<typeof DropdownMenuPortal>): React.ReactElement {
return <DropdownMenuPortal data-slot="menubar-portal" {...props} />
}
-function MenubarTrigger({ className, ...props }: React.ComponentProps<typeof DropdownMenuTrigger>): React.ReactElement {
+const MenubarTrigger = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuTrigger>,
+ React.ComponentProps<typeof DropdownMenuTrigger>
+>(function MenubarTrigger({ className, ...props }, ref) {
return (
<DropdownMenuTrigger
+ ref={ref}
data-slot="menubar-trigger"
className={cn('quill-menubar__trigger flex items-center outline-hidden select-none', className)}
{...props}
/>
)
-}
+})
-function MenubarContent({
- className,
- align = 'start',
- alignOffset = -4,
- sideOffset = 8,
- ...props
-}: React.ComponentProps<typeof DropdownMenuContent>): React.ReactElement {
+const MenubarContent = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuContent>,
+ React.ComponentProps<typeof DropdownMenuContent>
+>(function MenubarContent({ className, align = 'start', alignOffset = -4, sideOffset = 8, ...props }, ref) {
return (
<DropdownMenuContent
+ ref={ref}
data-slot="menubar-content"
align={align}
alignOffset={alignOffset}
@@ -73,99 +82,104 @@ function MenubarContent({
{...props}
/>
)
-}
+})
-function MenubarItem({
- className,
- inset,
- variant = 'default',
- ...props
-}: React.ComponentProps<typeof DropdownMenuItem>): React.ReactElement {
+const MenubarItem = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuItem>,
+ React.ComponentProps<typeof DropdownMenuItem>
+>(function MenubarItem({ className, inset, variant = 'default', ...props }, ref) {
return (
<DropdownMenuItem
+ ref={ref}
data-slot="menubar-item"
data-inset={inset}
variant={variant}
- className={cn(
- 'group/menubar-item min-h-7 gap-2 rounded-sm px-2 py-1 data-disabled:opacity-50',
- className
- )}
+ className={cn('group/menubar-item min-h-7 gap-2 rounded-sm px-2 py-1 data-disabled:opacity-50', className)}
{...props}
/>
)
-}
+})
// Explicit Base UI props, not `ComponentProps<typeof ...>`, so inline `onCheckedChange` callbacks keep their parameter type.
-function MenubarCheckboxItem({
- ...props
-}: MenuPrimitive.CheckboxItem.Props & { inset?: boolean }): React.ReactElement {
- return <DropdownMenuCheckboxItem data-slot="menubar-checkbox-item" {...props} />
-}
-
-function MenubarRadioGroup({ ...props }: React.ComponentProps<typeof DropdownMenuRadioGroup>): React.ReactElement {
- return <DropdownMenuRadioGroup data-slot="menubar-radio-group" {...props} />
-}
-
-function MenubarRadioItem({ ...props }: MenuPrimitive.RadioItem.Props & { inset?: boolean }): React.ReactElement {
- return <DropdownMenuRadioItem data-slot="menubar-radio-item" {...props} />
-}
-
-function MenubarLabel({
- className,
- inset,
- ...props
-}: React.ComponentProps<typeof DropdownMenuLabel> & {
- inset?: boolean
-}): React.ReactElement {
+const MenubarCheckboxItem = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuCheckboxItem>,
+ MenuPrimitive.CheckboxItem.Props & { inset?: boolean }
+>(function MenubarCheckboxItem({ ...props }, ref) {
+ return <DropdownMenuCheckboxItem ref={ref} data-slot="menubar-checkbox-item" {...props} />
+})
+
+const MenubarRadioGroup = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuRadioGroup>,
+ React.ComponentProps<typeof DropdownMenuRadioGroup>
+>(function MenubarRadioGroup({ ...props }, ref) {
+ return <DropdownMenuRadioGroup ref={ref} data-slot="menubar-radio-group" {...props} />
+})
+
+const MenubarRadioItem = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuRadioItem>,
+ MenuPrimitive.RadioItem.Props & { inset?: boolean }
+>(function MenubarRadioItem({ ...props }, ref) {
+ return <DropdownMenuRadioItem ref={ref} data-slot="menubar-radio-item" {...props} />
+})
+
+const MenubarLabel = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuLabel>,
+ React.ComponentProps<typeof DropdownMenuLabel> & {
+ inset?: boolean
+ }
+>(function MenubarLabel({ className, inset, ...props }, ref) {
return (
<DropdownMenuLabel
+ ref={ref}
data-slot="menubar-label"
data-inset={inset}
className={cn('px-2 py-1.5 text-xs text-muted-foreground', inset && 'quill-menu-item--inset', className)}
{...props}
/>
)
-}
+})
-function MenubarSeparator({
- className,
- ...props
-}: React.ComponentProps<typeof DropdownMenuSeparator>): React.ReactElement {
+const MenubarSeparator = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuSeparator>,
+ React.ComponentProps<typeof DropdownMenuSeparator>
+>(function MenubarSeparator({ className, ...props }, ref) {
return (
<DropdownMenuSeparator
+ ref={ref}
data-slot="menubar-separator"
className={cn('quill-menu__separator', className)}
{...props}
/>
)
-}
+})
-function MenubarShortcut({
- className,
- ...props
-}: React.ComponentProps<typeof DropdownMenuShortcut>): React.ReactElement {
+const MenubarShortcut = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuShortcut>,
+ React.ComponentProps<typeof DropdownMenuShortcut>
+>(function MenubarShortcut({ className, ...props }, ref) {
return (
<DropdownMenuShortcut
+ ref={ref}
data-slot="menubar-shortcut"
className={cn('quill-menu__shortcut', className)}
{...props}
/>
)
-}
+})
function MenubarSub({ ...props }: React.ComponentProps<typeof DropdownMenuSub>): React.ReactElement {
return <DropdownMenuSub data-slot="menubar-sub" {...props} />
}
-function MenubarSubTrigger({
- className,
- inset,
- ...props
-}: React.ComponentProps<typeof DropdownMenuSubTrigger> & {
- inset?: boolean
-}): React.ReactElement {
+const MenubarSubTrigger = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuSubTrigger>,
+ React.ComponentProps<typeof DropdownMenuSubTrigger> & {
+ inset?: boolean
+ }
+>(function MenubarSubTrigger({ className, inset, ...props }, ref) {
return (
<DropdownMenuSubTrigger
+ ref={ref}
data-slot="menubar-sub-trigger"
data-inset={inset}
className={cn(
@@ -176,14 +190,14 @@ function MenubarSubTrigger({
{...props}
/>
)
-}
-
-function MenubarSubContent({
- className,
- ...props
-}: React.ComponentProps<typeof DropdownMenuSubContent>): React.ReactElement {
- return <DropdownMenuSubContent data-slot="menubar-sub-content" className={className} {...props} />
-}
+})
+
+const MenubarSubContent = React.forwardRef<
+ React.ComponentRef<typeof DropdownMenuSubContent>,
+ React.ComponentProps<typeof DropdownMenuSubContent>
+>(function MenubarSubContent({ className, ...props }, ref) {
+ return <DropdownMenuSubContent ref={ref} data-slot="menubar-sub-content" className={className} {...props} />
+})
export {
Menubar,
diff --git a/packages/quill/packages/primitives/src/number-field.tsx b/packages/quill/packages/primitives/src/number-field.tsx
index eea816cae63d..a99dbfaf9bb9 100644
--- a/packages/quill/packages/primitives/src/number-field.tsx
+++ b/packages/quill/packages/primitives/src/number-field.tsx
@@ -5,32 +5,34 @@ import * as React from 'react'
import { cn } from './lib/utils'
import './number-field.css'
-function NumberFieldRoot({
- className,
- ...props
-}: NumberFieldPrimitive.Root.Props): React.ReactElement {
+const NumberFieldRoot = React.forwardRef<
+ React.ComponentRef<typeof NumberFieldPrimitive.Root>,
+ NumberFieldPrimitive.Root.Props
+>(function NumberFieldRoot({ className, ...props }, ref) {
return (
<NumberFieldPrimitive.Root
+ ref={ref}
data-quill
data-slot="number-field"
className={cn('flex flex-col gap-1', className)}
{...props}
/>
)
-}
+})
-function NumberFieldGroup({
- className,
- ...props
-}: NumberFieldPrimitive.Group.Props): React.ReactElement {
+const NumberFieldGroup = React.forwardRef<
+ React.ComponentRef<typeof NumberFieldPrimitive.Group>,
+ NumberFieldPrimitive.Group.Props
+>(function NumberFieldGroup({ className, ...props }, ref) {
return (
<NumberFieldPrimitive.Group
+ ref={ref}
data-slot="number-field-group"
className={cn('quill-number-field__group flex items-center', className)}
{...props}
/>
)
-}
+})
const NumberFieldInput = React.forwardRef<HTMLInputElement, NumberFieldPrimitive.Input.Props>(
({ className, ...props }, ref) => {
@@ -46,13 +48,13 @@ const NumberFieldInput = React.forwardRef<HTMLInputElement, NumberFieldPrimitive
)
NumberFieldInput.displayName = 'NumberFieldInput'
-function NumberFieldIncrement({
- className,
- children,
- ...props
-}: NumberFieldPrimitive.Increment.Props): React.ReactElement {
+const NumberFieldIncrement = React.forwardRef<
+ React.ComponentRef<typeof NumberFieldPrimitive.Increment>,
+ NumberFieldPrimitive.Increment.Props
+>(function NumberFieldIncrement({ className, children, ...props }, ref) {
return (
<NumberFieldPrimitive.Increment
+ ref={ref}
data-slot="number-field-increment"
className={cn('quill-number-field__increment flex items-center justify-center', className)}
{...props}
@@ -60,15 +62,15 @@ function NumberFieldIncrement({
{children ?? <ChevronUpIcon className="size-3.5" />}
</NumberFieldPrimitive.Increment>
)
-}
+})
-function NumberFieldDecrement({
- className,
- children,
- ...props
-}: NumberFieldPrimitive.Decrement.Props): React.ReactElement {
+const NumberFieldDecrement = React.forwardRef<
+ React.ComponentRef<typeof NumberFieldPrimitive.Decrement>,
+ NumberFieldPrimitive.Decrement.Props
+>(function NumberFieldDecrement({ className, children, ...props }, ref) {
return (
<NumberFieldPrimitive.Decrement
+ ref={ref}
data-slot="number-field-decrement"
className={cn('quill-number-field__decrement flex items-center justify-center', className)}
{...props}
@@ -76,33 +78,35 @@ function NumberFieldDecrement({
{children ?? <ChevronDownIcon className="size-3.5" />}
</NumberFieldPrimitive.Decrement>
)
-}
+})
-function NumberFieldScrubArea({
- className,
- ...props
-}: NumberFieldPrimitive.ScrubArea.Props): React.ReactElement {
+const NumberFieldScrubArea = React.forwardRef<
+ React.ComponentRef<typeof NumberFieldPrimitive.ScrubArea>,
+ NumberFieldPrimitive.ScrubArea.Props
+>(function NumberFieldScrubArea({ className, ...props }, ref) {
return (
<NumberFieldPrimitive.ScrubArea
+ ref={ref}
data-slot="number-field-scrub-area"
className={cn('cursor-ew-resize', className)}
{...props}
/>
)
-}
+})
-function NumberFieldScrubAreaCursor({
- className,
- ...props
-}: NumberFieldPrimitive.ScrubAreaCursor.Props): React.ReactElement {
+const NumberFieldScrubAreaCursor = React.forwardRef<
+ React.ComponentRef<typeof NumberFieldPrimitive.ScrubAreaCursor>,
+ NumberFieldPrimitive.ScrubAreaCursor.Props
+>(function NumberFieldScrubAreaCursor({ className, ...props }, ref) {
return (
<NumberFieldPrimitive.ScrubAreaCursor
+ ref={ref}
data-slot="number-field-scrub-area-cursor"
className={cn(className)}
{...props}
/>
)
-}
+})
export {
NumberFieldRoot,
diff --git a/packages/quill/packages/primitives/src/pagination.tsx b/packages/quill/packages/primitives/src/pagination.tsx
index 9e4541140d7f..df996a2cba9a 100644
--- a/packages/quill/packages/primitives/src/pagination.tsx
+++ b/packages/quill/packages/primitives/src/pagination.tsx
@@ -12,9 +12,13 @@ import { cn } from './lib/utils'
* on the buttons. Use {@link getPaginationRange} to build a first/last + sibling
* window with ellipses for large page counts.
*/
-function Pagination({ className, ...props }: React.ComponentProps<'nav'>): React.ReactElement {
+const Pagination = React.forwardRef<HTMLElement, React.ComponentProps<'nav'>>(function Pagination(
+ { className, ...props },
+ ref
+) {
return (
<nav
+ ref={ref}
aria-label="Pagination"
data-quill
data-slot="pagination"
@@ -22,7 +26,7 @@ function Pagination({ className, ...props }: React.ComponentProps<'nav'>): React
{...props}
/>
)
-}
+})
const PaginationContent = React.forwardRef<HTMLUListElement, React.ComponentProps<'ul'>>(function PaginationContent(
{ className, ...props },
@@ -103,9 +107,13 @@ const PaginationNext = React.forwardRef<HTMLButtonElement, Omit<PaginationButton
}
)
-function PaginationEllipsis({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+const PaginationEllipsis = React.forwardRef<HTMLSpanElement, React.ComponentProps<'span'>>(function PaginationEllipsis(
+ { className, ...props },
+ ref
+) {
return (
<span
+ ref={ref}
aria-hidden
data-slot="pagination-ellipsis"
className={cn('quill-pagination__ellipsis', className)}
@@ -115,7 +123,7 @@ function PaginationEllipsis({ className, ...props }: React.ComponentProps<'span'
<span className="sr-only">More pages</span>
</span>
)
-}
+})
type PaginationRangeItem = number | 'ellipsis'
diff --git a/packages/quill/packages/primitives/src/popover.tsx b/packages/quill/packages/primitives/src/popover.tsx
index ea8f7e666bbf..621d6bf233a3 100644
--- a/packages/quill/packages/primitives/src/popover.tsx
+++ b/packages/quill/packages/primitives/src/popover.tsx
@@ -8,41 +8,53 @@ function Popover({ ...props }: PopoverPrimitive.Root.Props): React.ReactElement
return <PopoverPrimitive.Root data-slot="popover" {...props} />
}
-const PopoverTrigger = React.forwardRef<HTMLButtonElement, PopoverPrimitive.Trigger.Props>(function PopoverTrigger(
- props,
- ref
-) {
- return <PopoverPrimitive.Trigger ref={ref} data-slot="popover-trigger" {...props} />
-})
+const PopoverTrigger = React.forwardRef<HTMLButtonElement, PopoverPrimitive.Trigger.Props>(
+ function PopoverTrigger(props, ref) {
+ return <PopoverPrimitive.Trigger ref={ref} data-slot="popover-trigger" {...props} />
+ }
+)
-function PopoverArrow({ className, ...props }: PopoverPrimitive.Arrow.Props): React.ReactElement {
- return (
- <PopoverPrimitive.Arrow data-slot="popover-arrow" className={cn('quill-popover__arrow', className)} {...props} />
- )
-}
+const PopoverArrow = React.forwardRef<React.ComponentRef<typeof PopoverPrimitive.Arrow>, PopoverPrimitive.Arrow.Props>(
+ function PopoverArrow({ className, ...props }, ref) {
+ return (
+ <PopoverPrimitive.Arrow
+ ref={ref}
+ data-slot="popover-arrow"
+ className={cn('quill-popover__arrow', className)}
+ {...props}
+ />
+ )
+ }
+)
-function PopoverContent({
- className,
- align = 'center',
- alignOffset = 0,
- side = 'bottom',
- arrow = false,
- // the arrow tip juts ~7px past the popup, so it needs a wider gap than a flush popover to clear the trigger
- sideOffset = arrow ? 9 : 4,
- arrowPadding,
- collisionAvoidance,
- container,
- children,
- ...props
-}: PopoverPrimitive.Popup.Props &
- Pick<
- PopoverPrimitive.Positioner.Props,
- 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'arrowPadding' | 'collisionAvoidance'
- > &
- Pick<PopoverPrimitive.Portal.Props, 'container'> & {
- /** Renders a pointer connecting the popover to its trigger. */
- arrow?: boolean
- }): React.ReactElement {
+const PopoverContent = React.forwardRef<
+ React.ComponentRef<typeof PopoverPrimitive.Popup>,
+ PopoverPrimitive.Popup.Props &
+ Pick<
+ PopoverPrimitive.Positioner.Props,
+ 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'arrowPadding' | 'collisionAvoidance'
+ > &
+ Pick<PopoverPrimitive.Portal.Props, 'container'> & {
+ /** Renders a pointer connecting the popover to its trigger. */
+ arrow?: boolean
+ }
+>(function PopoverContent(
+ {
+ className,
+ align = 'center',
+ alignOffset = 0,
+ side = 'bottom',
+ arrow = false,
+ // the arrow tip juts ~7px past the popup, so it needs a wider gap than a flush popover to clear the trigger
+ sideOffset = arrow ? 9 : 4,
+ arrowPadding,
+ collisionAvoidance,
+ container,
+ children,
+ ...props
+ },
+ ref
+) {
/*
* `container` opt-in lets consumers mount the popover inside a
* specific DOM subtree instead of `document.body`. Useful when
@@ -66,11 +78,9 @@ function PopoverContent({
className="isolate"
>
<PopoverPrimitive.Popup
+ ref={ref}
data-slot="popover-content"
- className={cn(
- 'quill-popover__content flex flex-col gap-4',
- className
- )}
+ className={cn('quill-popover__content flex flex-col gap-4', className)}
{...props}
>
{arrow && <PopoverArrow />}
@@ -79,30 +89,42 @@ function PopoverContent({
</PopoverPrimitive.Positioner>
</PopoverPrimitive.Portal>
)
-}
-
-function PopoverHeader({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return <div data-slot="popover-header" className={cn('flex flex-col gap-1 text-xs', className)} {...props} />
-}
+})
-function PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props): React.ReactElement {
+const PopoverHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function PopoverHeader(
+ { className, ...props },
+ ref
+) {
return (
- <PopoverPrimitive.Title
- data-slot="popover-title"
- className={cn('quill-popover__title', className)}
- {...props}
- />
+ <div ref={ref} data-slot="popover-header" className={cn('flex flex-col gap-1 text-xs', className)} {...props} />
)
-}
+})
+
+const PopoverTitle = React.forwardRef<React.ComponentRef<typeof PopoverPrimitive.Title>, PopoverPrimitive.Title.Props>(
+ function PopoverTitle({ className, ...props }, ref) {
+ return (
+ <PopoverPrimitive.Title
+ ref={ref}
+ data-slot="popover-title"
+ className={cn('quill-popover__title', className)}
+ {...props}
+ />
+ )
+ }
+)
-function PopoverDescription({ className, ...props }: PopoverPrimitive.Description.Props): React.ReactElement {
+const PopoverDescription = React.forwardRef<
+ React.ComponentRef<typeof PopoverPrimitive.Description>,
+ PopoverPrimitive.Description.Props
+>(function PopoverDescription({ className, ...props }, ref) {
return (
<PopoverPrimitive.Description
+ ref={ref}
data-slot="popover-description"
className={cn('quill-popover__description', className)}
{...props}
/>
)
-}
+})
export { Popover, PopoverArrow, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger }
diff --git a/packages/quill/packages/primitives/src/progress.tsx b/packages/quill/packages/primitives/src/progress.tsx
index b58ec9726ff5..0ed6eccd511a 100644
--- a/packages/quill/packages/primitives/src/progress.tsx
+++ b/packages/quill/packages/primitives/src/progress.tsx
@@ -22,15 +22,13 @@ const progressIndicatorVariants = cva('quill-progress__indicator', {
type ProgressVariantProps = VariantProps<typeof progressIndicatorVariants>
-function Progress({
- className,
- children,
- value,
- variant = 'default',
- ...props
-}: ProgressPrimitive.Root.Props & ProgressVariantProps): React.ReactElement {
+const Progress = React.forwardRef<
+ React.ComponentRef<typeof ProgressPrimitive.Root>,
+ ProgressPrimitive.Root.Props & ProgressVariantProps
+>(function Progress({ className, children, value, variant = 'default', ...props }, ref) {
return (
<ProgressPrimitive.Root
+ ref={ref}
value={value}
data-quill
data-slot="progress"
@@ -44,51 +42,63 @@ function Progress({
</ProgressTrack>
</ProgressPrimitive.Root>
)
-}
+})
-function ProgressTrack({ className, ...props }: ProgressPrimitive.Track.Props): React.ReactElement {
+const ProgressTrack = React.forwardRef<
+ React.ComponentRef<typeof ProgressPrimitive.Track>,
+ ProgressPrimitive.Track.Props
+>(function ProgressTrack({ className, ...props }, ref) {
return (
<ProgressPrimitive.Track
+ ref={ref}
className={cn('quill-progress__track relative flex items-center', className)}
data-slot="progress-track"
{...props}
/>
)
-}
+})
-function ProgressIndicator({
- className,
- variant = 'default',
- ...props
-}: ProgressPrimitive.Indicator.Props & ProgressVariantProps): React.ReactElement {
+const ProgressIndicator = React.forwardRef<
+ React.ComponentRef<typeof ProgressPrimitive.Indicator>,
+ ProgressPrimitive.Indicator.Props & ProgressVariantProps
+>(function ProgressIndicator({ className, variant = 'default', ...props }, ref) {
return (
<ProgressPrimitive.Indicator
+ ref={ref}
data-slot="progress-indicator"
data-variant={variant}
className={cn(progressIndicatorVariants({ variant }), className)}
{...props}
/>
)
-}
+})
-function ProgressLabel({ className, ...props }: ProgressPrimitive.Label.Props): React.ReactElement {
+const ProgressLabel = React.forwardRef<
+ React.ComponentRef<typeof ProgressPrimitive.Label>,
+ ProgressPrimitive.Label.Props
+>(function ProgressLabel({ className, ...props }, ref) {
return (
<ProgressPrimitive.Label
+ ref={ref}
className={cn('quill-progress__label', className)}
data-slot="progress-label"
{...props}
/>
)
-}
+})
-function ProgressValue({ className, ...props }: ProgressPrimitive.Value.Props): React.ReactElement {
+const ProgressValue = React.forwardRef<
+ React.ComponentRef<typeof ProgressPrimitive.Value>,
+ ProgressPrimitive.Value.Props
+>(function ProgressValue({ className, ...props }, ref) {
return (
<ProgressPrimitive.Value
+ ref={ref}
className={cn('quill-progress__value ms-auto', className)}
data-slot="progress-value"
{...props}
/>
)
-}
+})
export { Progress, ProgressTrack, ProgressIndicator, ProgressLabel, ProgressValue, progressIndicatorVariants }
diff --git a/packages/quill/packages/primitives/src/radio-group.tsx b/packages/quill/packages/primitives/src/radio-group.tsx
index 815c7020cc78..847dce5810e2 100644
--- a/packages/quill/packages/primitives/src/radio-group.tsx
+++ b/packages/quill/packages/primitives/src/radio-group.tsx
@@ -30,31 +30,34 @@ const radioDotVariants = cva('quill-radio-dot', {
},
})
-function RadioIndicator({
- checked,
- className,
- size = 'default',
-}: { checked?: boolean; className?: string } & VariantProps<typeof radioIndicatorVariants>): React.ReactElement {
+const RadioIndicator = React.forwardRef<
+ HTMLSpanElement,
+ { checked?: boolean; className?: string } & VariantProps<typeof radioIndicatorVariants>
+>(function RadioIndicator({ checked, className, size = 'default' }, ref) {
return (
<span
+ ref={ref}
data-slot="radio-indicator"
className={cn(radioIndicatorVariants({ size }), checked && 'quill-radio-indicator--checked', className)}
>
{checked && <span className={radioDotVariants({ size })} />}
</span>
)
-}
+})
-function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props): React.ReactElement {
- return (
- <RadioGroupPrimitive
- data-quill
- data-slot="radio-group"
- className={cn('grid w-full gap-3', className)}
- {...props}
- />
- )
-}
+const RadioGroup = React.forwardRef<React.ComponentRef<typeof RadioGroupPrimitive>, RadioGroupPrimitive.Props>(
+ function RadioGroup({ className, ...props }, ref) {
+ return (
+ <RadioGroupPrimitive
+ ref={ref}
+ data-quill
+ data-slot="radio-group"
+ className={cn('grid w-full gap-3', className)}
+ {...props}
+ />
+ )
+ }
+)
const radioGroupItemVariants = cva('quill-radio group/radio-group-item peer', {
variants: {
@@ -80,13 +83,13 @@ const radioGroupItemIndicatorVariants = cva('quill-radio__indicator', {
},
})
-function RadioGroupItem({
- className,
- size = 'default',
- ...props
-}: RadioPrimitive.Root.Props & VariantProps<typeof radioGroupItemVariants>): React.ReactElement {
+const RadioGroupItem = React.forwardRef<
+ React.ComponentRef<typeof RadioPrimitive.Root>,
+ RadioPrimitive.Root.Props & VariantProps<typeof radioGroupItemVariants>
+>(function RadioGroupItem({ className, size = 'default', ...props }, ref) {
return (
<RadioPrimitive.Root
+ ref={ref}
data-slot="radio-group-item"
className={cn(radioGroupItemVariants({ size }), className)}
{...props}
@@ -99,6 +102,6 @@ function RadioGroupItem({
</RadioPrimitive.Indicator>
</RadioPrimitive.Root>
)
-}
+})
export { RadioGroup, RadioGroupItem, RadioIndicator }
diff --git a/packages/quill/packages/primitives/src/scroll-area.tsx b/packages/quill/packages/primitives/src/scroll-area.tsx
index bb1409cdb9d0..2a1771c35754 100644
--- a/packages/quill/packages/primitives/src/scroll-area.tsx
+++ b/packages/quill/packages/primitives/src/scroll-area.tsx
@@ -182,22 +182,28 @@ if (typeof document !== 'undefined' && !document.getElementById(SCROLL_SHADOWS_S
document.head.appendChild(styleEl)
}
-function ScrollArea({
- className,
- children,
- scrollShadows = true,
- hideScrollbars = false,
- alwaysShowScrollbars = false,
- showScrollToButton,
- viewportClassName,
- ...props
-}: ScrollAreaPrimitive.Root.Props & {
- scrollShadows?: boolean
- hideScrollbars?: boolean
- alwaysShowScrollbars?: boolean
- showScrollToButton?: ShowScrollToButton
- viewportClassName?: string
-}): React.ReactElement {
+const ScrollArea = React.forwardRef<
+ React.ComponentRef<typeof ScrollAreaPrimitive.Root>,
+ ScrollAreaPrimitive.Root.Props & {
+ scrollShadows?: boolean
+ hideScrollbars?: boolean
+ alwaysShowScrollbars?: boolean
+ showScrollToButton?: ShowScrollToButton
+ viewportClassName?: string
+ }
+>(function ScrollArea(
+ {
+ className,
+ children,
+ scrollShadows = true,
+ hideScrollbars = false,
+ alwaysShowScrollbars = false,
+ showScrollToButton,
+ viewportClassName,
+ ...props
+ },
+ ref
+) {
const viewportRef = React.useRef<HTMLDivElement | null>(null)
const edges = resolveEdges(showScrollToButton)
// `typeof process` (vs `process.env.NODE_ENV` directly) avoids the
@@ -217,6 +223,7 @@ function ScrollArea({
}
return (
<ScrollAreaPrimitive.Root
+ ref={ref}
data-quill
data-slot="scroll-area"
// Just to keep around so we know it's a scroll area in case we merge props with another component
@@ -228,7 +235,7 @@ function ScrollArea({
<ScrollAreaPrimitive.Viewport
ref={viewportRef}
data-slot="scroll-area-viewport"
- className={cn("quill-scroll-area__viewport", viewportClassName)}
+ className={cn('quill-scroll-area__viewport', viewportClassName)}
>
{children}
</ScrollAreaPrimitive.Viewport>
@@ -244,16 +251,15 @@ function ScrollArea({
))}
</ScrollAreaPrimitive.Root>
)
-}
+})
-function ScrollBar({
- className,
- orientation = 'vertical',
- alwaysVisible = false,
- ...props
-}: ScrollAreaPrimitive.Scrollbar.Props & { alwaysVisible?: boolean }): React.ReactElement {
+const ScrollBar = React.forwardRef<
+ React.ComponentRef<typeof ScrollAreaPrimitive.Scrollbar>,
+ ScrollAreaPrimitive.Scrollbar.Props & { alwaysVisible?: boolean }
+>(function ScrollBar({ className, orientation = 'vertical', alwaysVisible = false, ...props }, ref) {
return (
<ScrollAreaPrimitive.Scrollbar
+ ref={ref}
data-slot="scroll-area-scrollbar"
data-orientation={orientation}
orientation={orientation}
@@ -267,6 +273,6 @@ function ScrollBar({
<ScrollAreaPrimitive.Thumb data-slot="scroll-area-thumb" className="quill-scroll-area__thumb" />
</ScrollAreaPrimitive.Scrollbar>
)
-}
+})
export { ScrollArea, ScrollBar }
diff --git a/packages/quill/packages/primitives/src/select.tsx b/packages/quill/packages/primitives/src/select.tsx
index a5d6accf1a74..7a4315c1d37e 100644
--- a/packages/quill/packages/primitives/src/select.tsx
+++ b/packages/quill/packages/primitives/src/select.tsx
@@ -10,32 +10,48 @@ import { MenuLabel } from './menu-label'
const Select = SelectPrimitive.Root
-function SelectGroup({ className, ...props }: SelectPrimitive.Group.Props): React.ReactElement {
- return (
- <SelectPrimitive.Group data-slot="select-group" className={cn('quill-select__group', className)} {...props} />
- )
-}
+const SelectGroup = React.forwardRef<React.ComponentRef<typeof SelectPrimitive.Group>, SelectPrimitive.Group.Props>(
+ function SelectGroup({ className, ...props }, ref) {
+ return (
+ <SelectPrimitive.Group
+ ref={ref}
+ data-slot="select-group"
+ className={cn('quill-select__group', className)}
+ {...props}
+ />
+ )
+ }
+)
-function SelectValue({ className, ...props }: SelectPrimitive.Value.Props): React.ReactElement {
- return (
- <SelectPrimitive.Value data-slot="select-value" className={cn('quill-select__value', className)} {...props} />
- )
-}
+const SelectValue = React.forwardRef<React.ComponentRef<typeof SelectPrimitive.Value>, SelectPrimitive.Value.Props>(
+ function SelectValue({ className, ...props }, ref) {
+ return (
+ <SelectPrimitive.Value
+ ref={ref}
+ data-slot="select-value"
+ className={cn('quill-select__value', className)}
+ {...props}
+ />
+ )
+ }
+)
-function SelectTriggerIcon({ className, ...props }: React.ComponentProps<typeof ChevronDownIcon>): React.ReactElement {
- return <ChevronDownIcon className={cn('quill-select__icon', className)} {...props} />
-}
+const SelectTriggerIcon = React.forwardRef<
+ React.ComponentRef<typeof ChevronDownIcon>,
+ React.ComponentProps<typeof ChevronDownIcon>
+>(function SelectTriggerIcon({ className, ...props }, ref) {
+ return <ChevronDownIcon ref={ref} className={cn('quill-select__icon', className)} {...props} />
+})
-function SelectTrigger({
- className,
- size = 'default',
- children,
- ...props
-}: SelectPrimitive.Trigger.Props & {
- size?: 'sm' | 'default'
-}): React.ReactElement {
+const SelectTrigger = React.forwardRef<
+ React.ComponentRef<typeof SelectPrimitive.Trigger>,
+ SelectPrimitive.Trigger.Props & {
+ size?: 'sm' | 'default'
+ }
+>(function SelectTrigger({ className, size = 'default', children, ...props }, ref) {
return (
<SelectPrimitive.Trigger
+ ref={ref}
data-slot="select-trigger"
data-size={size}
className={cn(
@@ -49,28 +65,31 @@ function SelectTrigger({
<SelectPrimitive.Icon render={<SelectTriggerIcon />} />
</SelectPrimitive.Trigger>
)
-}
+})
-function SelectContent({
- className,
- children,
- popupSibling,
- side = 'bottom',
- sideOffset = 4,
- align = 'center',
- alignOffset = 0,
- alignItemWithTrigger = true,
- ...props
-}: SelectPrimitive.Popup.Props & {
- /**
- * Rendered in the positioner as the popup's sibling, escaping the popup's overflow and scroll
- * mask. Use position: absolute — in-flow content here resizes the box the positioner measures.
- */
- popupSibling?: React.ReactNode
-} & Pick<
- SelectPrimitive.Positioner.Props,
- 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'
- >): React.ReactElement {
+const SelectContent = React.forwardRef<
+ React.ComponentRef<typeof SelectPrimitive.Popup>,
+ SelectPrimitive.Popup.Props & {
+ /**
+ * Rendered in the positioner as the popup's sibling, escaping the popup's overflow and scroll
+ * mask. Use position: absolute — in-flow content here resizes the box the positioner measures.
+ */
+ popupSibling?: React.ReactNode
+ } & Pick<SelectPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'>
+>(function SelectContent(
+ {
+ className,
+ children,
+ popupSibling,
+ side = 'bottom',
+ sideOffset = 4,
+ align = 'center',
+ alignOffset = 0,
+ alignItemWithTrigger = true,
+ ...props
+ },
+ ref
+) {
return (
<SelectPrimitive.Portal>
<SelectPrimitive.Positioner
@@ -85,6 +104,7 @@ function SelectContent({
>
{popupSibling}
<SelectPrimitive.Popup
+ ref={ref}
data-slot="select-content"
data-align-trigger={alignItemWithTrigger}
className={cn('quill-select__content', className)}
@@ -99,52 +119,69 @@ function SelectContent({
</SelectPrimitive.Positioner>
</SelectPrimitive.Portal>
)
-}
+})
-function SelectGroupLabel({ className, ...props }: SelectPrimitive.GroupLabel.Props): React.ReactElement {
+const SelectGroupLabel = React.forwardRef<
+ React.ComponentRef<typeof SelectPrimitive.GroupLabel>,
+ SelectPrimitive.GroupLabel.Props
+>(function SelectGroupLabel({ className, ...props }, ref) {
return (
- <SelectPrimitive.GroupLabel data-slot="select-label" className={className} render={<MenuLabel />} {...props} />
+ <SelectPrimitive.GroupLabel
+ ref={ref}
+ data-slot="select-label"
+ className={className}
+ render={<MenuLabel />}
+ {...props}
+ />
)
-}
+})
-function SelectItem({ className, children, ...props }: SelectPrimitive.Item.Props): React.ReactElement {
- return (
- <SelectPrimitive.Item
- data-slot="select-item"
- className={cn(
- 'quill-select__item group/select-item flex w-full cursor-default items-center gap-2 select-none',
- className
- )}
- {...props}
- >
- <SelectPrimitive.ItemText className="flex flex-1 shrink-0 gap-2 whitespace-nowrap">
- {children}
- </SelectPrimitive.ItemText>
- <SelectPrimitive.ItemIndicator
- render={<span className="pointer-events-none absolute end-2 flex items-center justify-center" />}
+const SelectItem = React.forwardRef<React.ComponentRef<typeof SelectPrimitive.Item>, SelectPrimitive.Item.Props>(
+ function SelectItem({ className, children, ...props }, ref) {
+ return (
+ <SelectPrimitive.Item
+ ref={ref}
+ data-slot="select-item"
+ className={cn(
+ 'quill-select__item group/select-item flex w-full cursor-default items-center gap-2 select-none',
+ className
+ )}
+ {...props}
>
- <CheckIcon className="pointer-events-none" />
- </SelectPrimitive.ItemIndicator>
- </SelectPrimitive.Item>
- )
-}
+ <SelectPrimitive.ItemText className="flex flex-1 shrink-0 gap-2 whitespace-nowrap">
+ {children}
+ </SelectPrimitive.ItemText>
+ <SelectPrimitive.ItemIndicator
+ render={<span className="pointer-events-none absolute end-2 flex items-center justify-center" />}
+ >
+ <CheckIcon className="pointer-events-none" />
+ </SelectPrimitive.ItemIndicator>
+ </SelectPrimitive.Item>
+ )
+ }
+)
-function SelectSeparator({ className, ...props }: SelectPrimitive.Separator.Props): React.ReactElement {
+const SelectSeparator = React.forwardRef<
+ React.ComponentRef<typeof SelectPrimitive.Separator>,
+ SelectPrimitive.Separator.Props
+>(function SelectSeparator({ className, ...props }, ref) {
return (
<SelectPrimitive.Separator
+ ref={ref}
data-slot="select-separator"
className={cn('quill-select__separator', className)}
{...props}
/>
)
-}
+})
-function SelectScrollUpButton({
- className,
- ...props
-}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>): React.ReactElement {
+const SelectScrollUpButton = React.forwardRef<
+ React.ComponentRef<typeof SelectPrimitive.ScrollUpArrow>,
+ React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>
+>(function SelectScrollUpButton({ className, ...props }, ref) {
return (
<SelectPrimitive.ScrollUpArrow
+ ref={ref}
data-slot="select-scroll-up-button"
className={cn('quill-select__scroll-button quill-select__scroll-button--up', className)}
render={<Button variant="outline" size="icon-sm" />}
@@ -153,14 +190,15 @@ function SelectScrollUpButton({
<ChevronUpIcon />
</SelectPrimitive.ScrollUpArrow>
)
-}
+})
-function SelectScrollDownButton({
- className,
- ...props
-}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>): React.ReactElement {
+const SelectScrollDownButton = React.forwardRef<
+ React.ComponentRef<typeof SelectPrimitive.ScrollDownArrow>,
+ React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>
+>(function SelectScrollDownButton({ className, ...props }, ref) {
return (
<SelectPrimitive.ScrollDownArrow
+ ref={ref}
data-slot="select-scroll-down-button"
className={cn('quill-select__scroll-button quill-select__scroll-button--down', className)}
render={<Button variant="outline" size="icon-sm" />}
@@ -169,7 +207,7 @@ function SelectScrollDownButton({
<ChevronDownIcon />
</SelectPrimitive.ScrollDownArrow>
)
-}
+})
export {
Select,
diff --git a/packages/quill/packages/primitives/src/separator.tsx b/packages/quill/packages/primitives/src/separator.tsx
index 12be8cfe859e..f1235adaea21 100644
--- a/packages/quill/packages/primitives/src/separator.tsx
+++ b/packages/quill/packages/primitives/src/separator.tsx
@@ -4,16 +4,19 @@ import * as React from 'react'
import './separator.css'
import { cn } from './lib/utils'
-function Separator({ className, orientation = 'horizontal', ...props }: SeparatorPrimitive.Props): React.ReactElement {
- return (
- <SeparatorPrimitive
- data-quill
- data-slot="separator"
- orientation={orientation}
- className={cn('quill-separator shrink-0', className)}
- {...props}
- />
- )
-}
+const Separator = React.forwardRef<React.ComponentRef<typeof SeparatorPrimitive>, SeparatorPrimitive.Props>(
+ function Separator({ className, orientation = 'horizontal', ...props }, ref) {
+ return (
+ <SeparatorPrimitive
+ ref={ref}
+ data-quill
+ data-slot="separator"
+ orientation={orientation}
+ className={cn('quill-separator shrink-0', className)}
+ {...props}
+ />
+ )
+ }
+)
export { Separator }
diff --git a/packages/quill/packages/primitives/src/skeleton-text.tsx b/packages/quill/packages/primitives/src/skeleton-text.tsx
index 60cb65b0695c..435b9ce0c1c7 100644
--- a/packages/quill/packages/primitives/src/skeleton-text.tsx
+++ b/packages/quill/packages/primitives/src/skeleton-text.tsx
@@ -10,7 +10,10 @@ type SkeletonTextProps = {
maxWidth?: number // %
}
-function SkeletonText({ lines = 3, className, minWidth = 60, maxWidth = 100 }: SkeletonTextProps): React.ReactElement {
+const SkeletonText = React.forwardRef<HTMLDivElement, SkeletonTextProps>(function SkeletonText(
+ { lines = 3, className, minWidth = 60, maxWidth = 100 },
+ ref
+) {
// stable random widths per render (no layout shift on re-render)
const widths = React.useMemo(() => {
return Array.from({ length: lines }).map((_, i) => {
@@ -27,7 +30,7 @@ function SkeletonText({ lines = 3, className, minWidth = 60, maxWidth = 100 }: S
}, [lines, minWidth, maxWidth])
return (
- <div data-quill className={cn('flex flex-col', className)}>
+ <div ref={ref} data-quill className={cn('flex flex-col', className)}>
{widths.map((w, i) => (
<span
key={i}
@@ -49,6 +52,6 @@ function SkeletonText({ lines = 3, className, minWidth = 60, maxWidth = 100 }: S
))}
</div>
)
-}
+})
export { SkeletonText }
diff --git a/packages/quill/packages/primitives/src/skeleton.tsx b/packages/quill/packages/primitives/src/skeleton.tsx
index b26a7cd784a7..9b61a520cf47 100644
--- a/packages/quill/packages/primitives/src/skeleton.tsx
+++ b/packages/quill/packages/primitives/src/skeleton.tsx
@@ -3,15 +3,11 @@ import * as React from 'react'
import './skeleton.css'
import { cn } from './lib/utils'
-function Skeleton({ className, ...props }: React.ComponentProps<'div'>): React.ReactElement {
- return (
- <div
- data-quill
- data-slot="skeleton"
- className={cn('quill-skeleton', className)}
- {...props}
- />
- )
-}
+const Skeleton = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(function Skeleton(
+ { className, ...props },
+ ref
+) {
+ return <div ref={ref} data-quill data-slot="skeleton" className={cn('quill-skeleton', className)} {...props} />
+})
export { Skeleton }
diff --git a/packages/quill/packages/primitives/src/slider.tsx b/packages/quill/packages/primitives/src/slider.tsx
index f3e68edabe3e..18b826b18d3e 100644
--- a/packages/quill/packages/primitives/src/slider.tsx
+++ b/packages/quill/packages/primitives/src/slider.tsx
@@ -4,45 +4,41 @@ import * as React from 'react'
import { cn } from './lib/utils'
import './slider.css'
-function Slider({
- className,
- defaultValue,
- value,
- min = 0,
- max = 100,
- ...props
-}: SliderPrimitive.Root.Props): React.ReactElement {
- const _values = React.useMemo(
- () => (Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max]),
- [value, defaultValue, min, max]
- )
+const Slider = React.forwardRef<React.ComponentRef<typeof SliderPrimitive.Root>, SliderPrimitive.Root.Props>(
+ function Slider({ className, defaultValue, value, min = 0, max = 100, ...props }, ref) {
+ const _values = React.useMemo(
+ () => (Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max]),
+ [value, defaultValue, min, max]
+ )
- return (
- <SliderPrimitive.Root
- data-quill
- data-slot="slider"
- className={cn('quill-slider', className)}
- defaultValue={defaultValue}
- value={value}
- min={min}
- max={max}
- thumbAlignment="edge"
- {...props}
- >
- <SliderPrimitive.Control className="quill-slider__control">
- <SliderPrimitive.Track data-slot="slider-track" className="quill-slider__track">
- <SliderPrimitive.Indicator data-slot="slider-range" className="quill-slider__range" />
- </SliderPrimitive.Track>
- {Array.from({ length: _values.length }, (_, index) => (
- <SliderPrimitive.Thumb
- data-slot="slider-thumb"
- key={index}
- className="quill-slider__thumb flex items-center justify-center"
- />
- ))}
- </SliderPrimitive.Control>
- </SliderPrimitive.Root>
- )
-}
+ return (
+ <SliderPrimitive.Root
+ ref={ref}
+ data-quill
+ data-slot="slider"
+ className={cn('quill-slider', className)}
+ defaultValue={defaultValue}
+ value={value}
+ min={min}
+ max={max}
+ thumbAlignment="edge"
+ {...props}
+ >
+ <SliderPrimitive.Control className="quill-slider__control">
+ <SliderPrimitive.Track data-slot="slider-track" className="quill-slider__track">
+ <SliderPrimitive.Indicator data-slot="slider-range" className="quill-slider__range" />
+ </SliderPrimitive.Track>
+ {Array.from({ length: _values.length }, (_, index) => (
+ <SliderPrimitive.Thumb
+ data-slot="slider-thumb"
+ key={index}
+ className="quill-slider__thumb flex items-center justify-center"
+ />
+ ))}
+ </SliderPrimitive.Control>
+ </SliderPrimitive.Root>
+ )
+ }
+)
export { Slider }
diff --git a/packages/quill/packages/primitives/src/spinner.tsx b/packages/quill/packages/primitives/src/spinner.tsx
index c920e7b6f509..cfa917c77272 100644
--- a/packages/quill/packages/primitives/src/spinner.tsx
+++ b/packages/quill/packages/primitives/src/spinner.tsx
@@ -4,10 +4,20 @@ import * as React from 'react'
import './spinner.css'
import { cn } from './lib/utils'
-function Spinner({ className, ...props }: React.ComponentProps<'svg'>): React.ReactElement {
+const Spinner = React.forwardRef<React.ComponentRef<typeof Loader2Icon>, React.ComponentProps<'svg'>>(function Spinner(
+ { className, ...props },
+ ref
+) {
return (
- <Loader2Icon data-quill role="status" aria-label="Loading" className={cn('quill-spinner', className)} {...props} />
+ <Loader2Icon
+ ref={ref}
+ data-quill
+ role="status"
+ aria-label="Loading"
+ className={cn('quill-spinner', className)}
+ {...props}
+ />
)
-}
+})
export { Spinner }
diff --git a/packages/quill/packages/primitives/src/switch.tsx b/packages/quill/packages/primitives/src/switch.tsx
index 99800610205d..33339c0b9edd 100644
--- a/packages/quill/packages/primitives/src/switch.tsx
+++ b/packages/quill/packages/primitives/src/switch.tsx
@@ -4,15 +4,15 @@ import * as React from 'react'
import './switch.css'
import { cn } from './lib/utils'
-function Switch({
- className,
- size = 'default',
- ...props
-}: SwitchPrimitive.Root.Props & {
- size?: 'sm' | 'default'
-}): React.ReactElement {
+const Switch = React.forwardRef<
+ React.ComponentRef<typeof SwitchPrimitive.Root>,
+ SwitchPrimitive.Root.Props & {
+ size?: 'sm' | 'default'
+ }
+>(function Switch({ className, size = 'default', ...props }, ref) {
return (
<SwitchPrimitive.Root
+ ref={ref}
data-quill
data-slot="switch"
data-size={size}
@@ -22,6 +22,6 @@ function Switch({
<SwitchPrimitive.Thumb data-slot="switch-thumb" className="quill-switch__thumb" />
</SwitchPrimitive.Root>
)
-}
+})
export { Switch }
diff --git a/packages/quill/packages/primitives/src/tabs.tsx b/packages/quill/packages/primitives/src/tabs.tsx
index f429593de63d..b4e31f05287e 100644
--- a/packages/quill/packages/primitives/src/tabs.tsx
+++ b/packages/quill/packages/primitives/src/tabs.tsx
@@ -7,16 +7,20 @@ import * as React from 'react'
import { Button } from './button'
import { cn } from './lib/utils'
-function Tabs({ className, orientation = 'horizontal', ...props }: TabsPrimitive.Root.Props): React.ReactElement {
+const Tabs = React.forwardRef<React.ComponentRef<typeof TabsPrimitive.Root>, TabsPrimitive.Root.Props>(function Tabs(
+ { className, orientation = 'horizontal', ...props },
+ ref
+) {
return (
<TabsPrimitive.Root
+ ref={ref}
data-slot="tabs"
data-orientation={orientation}
className={cn('group/tabs flex gap-2 data-[orientation=horizontal]:flex-col', className)}
{...props}
/>
)
-}
+})
const tabsListVariants = cva(
'quill-tabs__list group/tabs-list inline-flex w-fit items-center justify-center relative',
@@ -45,13 +49,13 @@ const tabsIndicatorVariants = cva('quill-tabs__indicator', {
},
})
-function TabsList({
- className,
- variant = 'default',
- ...props
-}: TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>): React.ReactElement {
+const TabsList = React.forwardRef<
+ React.ComponentRef<typeof TabsPrimitive.List>,
+ TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>
+>(function TabsList({ className, variant = 'default', ...props }, ref) {
return (
<TabsPrimitive.List
+ ref={ref}
data-quill
data-slot="tabs-list"
data-variant={variant}
@@ -62,24 +66,36 @@ function TabsList({
<TabsPrimitive.Indicator className={tabsIndicatorVariants({ variant })} />
</TabsPrimitive.List>
)
-}
+})
-function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props): React.ReactElement {
- return (
- <TabsPrimitive.Tab
- data-slot="tabs-trigger"
- className={cn(
- 'quill-tabs__trigger inline-flex items-center justify-center gap-1.5 whitespace-nowrap',
- className
- )}
- {...props}
- render={(props) => <Button {...props} />}
- />
- )
-}
+const TabsTrigger = React.forwardRef<React.ComponentRef<typeof TabsPrimitive.Tab>, TabsPrimitive.Tab.Props>(
+ function TabsTrigger({ className, ...props }, ref) {
+ return (
+ <TabsPrimitive.Tab
+ ref={ref}
+ data-slot="tabs-trigger"
+ className={cn(
+ 'quill-tabs__trigger inline-flex items-center justify-center gap-1.5 whitespace-nowrap',
+ className
+ )}
+ {...props}
+ render={(props) => <Button {...props} />}
+ />
+ )
+ }
+)
-function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props): React.ReactElement {
- return <TabsPrimitive.Panel data-slot="tabs-content" className={cn('quill-tabs__panel', className)} {...props} />
-}
+const TabsContent = React.forwardRef<React.ComponentRef<typeof TabsPrimitive.Panel>, TabsPrimitive.Panel.Props>(
+ function TabsContent({ className, ...props }, ref) {
+ return (
+ <TabsPrimitive.Panel
+ ref={ref}
+ data-slot="tabs-content"
+ className={cn('quill-tabs__panel', className)}
+ {...props}
+ />
+ )
+ }
+)
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }
diff --git a/packages/quill/packages/primitives/src/text.tsx b/packages/quill/packages/primitives/src/text.tsx
index df752c12084c..7b3251246da1 100644
--- a/packages/quill/packages/primitives/src/text.tsx
+++ b/packages/quill/packages/primitives/src/text.tsx
@@ -33,31 +33,27 @@ const textVariants = cva('', {
},
})
-function Text({
- className,
- size = 'base',
- variant = 'default',
- weight = 'normal',
- render,
- ...props
-}: useRender.ComponentProps<'p'> & VariantProps<typeof textVariants>): React.ReactElement {
- return useRender({
- defaultTagName: 'p',
- props: mergeProps<'p'>(
- {
- 'data-quill': '',
- className: cn(textVariants({ size, variant, weight }), className),
- } as Omit<React.ComponentProps<'p'>, 'ref'>,
- props
- ),
- render,
- state: {
- slot: 'text',
- size,
- variant,
- weight,
- },
- })
-}
+const Text = React.forwardRef<HTMLParagraphElement, useRender.ComponentProps<'p'> & VariantProps<typeof textVariants>>(
+ function Text({ className, size = 'base', variant = 'default', weight = 'normal', render, ...props }, ref) {
+ return useRender({
+ ref,
+ defaultTagName: 'p',
+ props: mergeProps<'p'>(
+ {
+ 'data-quill': '',
+ className: cn(textVariants({ size, variant, weight }), className),
+ } as Omit<React.ComponentProps<'p'>, 'ref'>,
+ props
+ ),
+ render,
+ state: {
+ slot: 'text',
+ size,
+ variant,
+ weight,
+ },
+ })
+ }
+)
export { Text, textVariants }
diff --git a/packages/quill/packages/primitives/src/textarea.tsx b/packages/quill/packages/primitives/src/textarea.tsx
index 073f38078e99..d168bbe629c7 100644
--- a/packages/quill/packages/primitives/src/textarea.tsx
+++ b/packages/quill/packages/primitives/src/textarea.tsx
@@ -3,15 +3,19 @@ import * as React from 'react'
import './textarea.css'
import { cn } from './lib/utils'
-function Textarea({ className, ...props }: React.ComponentProps<'textarea'>): React.ReactElement {
+const Textarea = React.forwardRef<HTMLTextAreaElement, React.ComponentProps<'textarea'>>(function Textarea(
+ { className, ...props },
+ ref
+) {
return (
<textarea
+ ref={ref}
data-quill
data-slot="textarea"
className={cn('quill-textarea flex', className)}
{...props}
/>
)
-}
+})
export { Textarea }
diff --git a/packages/quill/packages/primitives/src/toggle-group.tsx b/packages/quill/packages/primitives/src/toggle-group.tsx
index 0c265f3983b0..0e2f3c9aa8e9 100644
--- a/packages/quill/packages/primitives/src/toggle-group.tsx
+++ b/packages/quill/packages/primitives/src/toggle-group.tsx
@@ -20,21 +20,17 @@ const ToggleGroupContext = React.createContext<
orientation: 'horizontal',
})
-function ToggleGroup({
- className,
- variant,
- size,
- spacing = 0,
- orientation = 'horizontal',
- children,
- ...props
-}: ToggleGroupPrimitive.Props &
- VariantProps<typeof toggleVariants> & {
- spacing?: number
- orientation?: 'horizontal' | 'vertical'
- }): React.ReactElement {
+const ToggleGroup = React.forwardRef<
+ React.ComponentRef<typeof ToggleGroupPrimitive>,
+ ToggleGroupPrimitive.Props &
+ VariantProps<typeof toggleVariants> & {
+ spacing?: number
+ orientation?: 'horizontal' | 'vertical'
+ }
+>(function ToggleGroup({ className, variant, size, spacing = 0, orientation = 'horizontal', children, ...props }, ref) {
return (
<ToggleGroupPrimitive
+ ref={ref}
data-quill
data-slot="toggle-group"
data-variant={variant}
@@ -53,19 +49,17 @@ function ToggleGroup({
</ToggleGroupContext.Provider>
</ToggleGroupPrimitive>
)
-}
+})
-function ToggleGroupItem({
- className,
- children,
- variant = 'default',
- size = 'default',
- ...props
-}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>): React.ReactElement {
+const ToggleGroupItem = React.forwardRef<
+ React.ComponentRef<typeof TogglePrimitive>,
+ TogglePrimitive.Props & VariantProps<typeof toggleVariants>
+>(function ToggleGroupItem({ className, children, variant = 'default', size = 'default', ...props }, ref) {
const context = React.useContext(ToggleGroupContext)
return (
<TogglePrimitive
+ ref={ref}
data-slot="toggle-group-item"
data-variant={context.variant || variant}
data-size={context.size || size}
@@ -84,6 +78,6 @@ function ToggleGroupItem({
{children}
</TogglePrimitive>
)
-}
+})
export { ToggleGroup, ToggleGroupItem }
diff --git a/packages/quill/packages/primitives/src/toggle.tsx b/packages/quill/packages/primitives/src/toggle.tsx
index 82224fab56a9..6e32454ef484 100644
--- a/packages/quill/packages/primitives/src/toggle.tsx
+++ b/packages/quill/packages/primitives/src/toggle.tsx
@@ -27,20 +27,19 @@ const toggleVariants = cva(
}
)
-function Toggle({
- className,
- variant = 'default',
- size = 'default',
- ...props
-}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>): React.ReactElement {
+const Toggle = React.forwardRef<
+ React.ComponentRef<typeof TogglePrimitive>,
+ TogglePrimitive.Props & VariantProps<typeof toggleVariants>
+>(function Toggle({ className, variant = 'default', size = 'default', ...props }, ref) {
return (
<TogglePrimitive
+ ref={ref}
data-quill
data-slot="toggle"
className={cn(toggleVariants({ variant, size, className }))}
{...props}
/>
)
-}
+})
export { Toggle, toggleVariants }
diff --git a/packages/quill/packages/primitives/src/tooltip.tsx b/packages/quill/packages/primitives/src/tooltip.tsx
index 486343246c6e..893080a66aec 100644
--- a/packages/quill/packages/primitives/src/tooltip.tsx
+++ b/packages/quill/packages/primitives/src/tooltip.tsx
@@ -39,16 +39,14 @@ const TooltipTrigger = React.forwardRef(function TooltipTrigger(
return <TooltipPrimitive.Trigger ref={ref} data-slot="tooltip-trigger" {...props} />
}) as <Payload>(props: TooltipPrimitive.Trigger.Props<Payload>) => React.ReactElement
-function TooltipContent({
- className,
- side = 'top',
- sideOffset = 4,
- align = 'center',
- alignOffset = 0,
- children,
- ...props
-}: TooltipPrimitive.Popup.Props &
- Pick<TooltipPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>): React.ReactElement {
+const TooltipContent = React.forwardRef<
+ React.ComponentRef<typeof TooltipPrimitive.Popup>,
+ TooltipPrimitive.Popup.Props &
+ Pick<TooltipPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>
+>(function TooltipContent(
+ { className, side = 'top', sideOffset = 4, align = 'center', alignOffset = 0, children, ...props },
+ ref
+) {
const glide = React.useContext(TooltipGlideContext)
return (
<TooltipPrimitive.Portal>
@@ -63,6 +61,7 @@ function TooltipContent({
className="quill-tooltip__positioner isolate"
>
<TooltipPrimitive.Popup
+ ref={ref}
data-slot="tooltip-content"
className={cn('quill-tooltip__content inline-flex items-center gap-1.5', className)}
{...props}
@@ -73,6 +72,6 @@ function TooltipContent({
</TooltipPrimitive.Positioner>
</TooltipPrimitive.Portal>
)
-}
+})
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider, createTooltipHandle }
diff --git a/packages/quill/packages/primitives/vite.config.ts b/packages/quill/packages/primitives/vite.config.ts
index 552adea141a4..acb4304970ac 100644
--- a/packages/quill/packages/primitives/vite.config.ts
+++ b/packages/quill/packages/primitives/vite.config.ts
@@ -11,6 +11,18 @@ export default defineConfig({
dts({
tsconfigPath: resolve(__dirname, 'tsconfig.build.json'),
exclude: ['src/**/*.stories.tsx', 'src/**/*.stories.ts'],
+ // An inferred type that names a dependency's private module emits an import path consumers
+ // cannot resolve, and their types silently become `any`. Fail the build instead.
+ afterBuild: (emittedFiles) => {
+ const unresolvable = [...emittedFiles]
+ .filter(([, content]) => content.includes("import('node_modules"))
+ .map(([file]) => file)
+ if (unresolvable.length > 0) {
+ throw new Error(
+ `Declarations import from node_modules by path. Annotate the export with a public type:\n${unresolvable.join('\n')}`
+ )
+ }
+ },
}),
],
build: {
diff --git a/packages/quill/packages/quill/package.json b/packages/quill/packages/quill/package.json
index 259a6f574e92..3a8de7283513 100644
--- a/packages/quill/packages/quill/package.json
+++ b/packages/quill/packages/quill/package.json
@@ -56,6 +56,7 @@
"@posthog/quill-components": "workspace:*",
"@posthog/quill-primitives": "workspace:*",
"@posthog/quill-tokens": "workspace:*",
+ "@types/react": "catalog:",
"tsx": "^4.19.0",
"vite": "catalog:",
"vite-plugin-dts": "^4.5.4"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3073662690fa..921066682e06 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -2296,6 +2296,9 @@ importers:
'@posthog/quill-tokens':
specifier: workspace:*
version: link:../tokens
+ '@types/react':
+ specifier: 18.3.27
+ version: 18.3.27
tsx:
specifier: ^4.19.0
version: 4.20.5
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/insights/ExceptionBandTable.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/insights/ExceptionBandTable.tsx
index bab26ecb25ba..a3fd7429b362 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/insights/ExceptionBandTable.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/insights/ExceptionBandTable.tsx
@@ -9,6 +9,9 @@ import {
TableHeader,
TableRow,
Text,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
} from 'lib/ui/quill'
import { humanFriendlyLargeNumber } from 'lib/utils/numbers'
@@ -45,17 +48,23 @@ function BandLabel({
)
}
return (
- <Button
- variant="default"
- size="sm"
- className="h-6 w-full min-w-0 justify-start gap-1.5 px-1.5 text-xs"
- data-attr="error-tracking-insights-band-filter"
- tooltip="Filter this tab down to it"
- onClick={() => onSelectBand(band.filters as BandFilter[])}
- >
- {swatch}
- <span className="truncate">{band.label}</span>
- </Button>
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ variant="default"
+ size="sm"
+ className="h-6 w-full min-w-0 justify-start gap-1.5 px-1.5 text-xs"
+ data-attr="error-tracking-insights-band-filter"
+ onClick={() => onSelectBand(band.filters as BandFilter[])}
+ />
+ }
+ >
+ {swatch}
+ <span className="truncate">{band.label}</span>
+ </TooltipTrigger>
+ <TooltipContent>Filter this tab down to it</TooltipContent>
+ </Tooltip>
)
}
diff --git a/services/mcp/src/ui-apps/components/AppWrapper.tsx b/services/mcp/src/ui-apps/components/AppWrapper.tsx
index d315179477ce..48f71f6ade84 100644
--- a/services/mcp/src/ui-apps/components/AppWrapper.tsx
+++ b/services/mcp/src/ui-apps/components/AppWrapper.tsx
@@ -53,7 +53,7 @@ function ExpandButton({
return (
<Button
- variant="ghost"
+ variant="default"
size="icon-xs"
onClick={handleToggle}
title={isFullscreen ? 'Exit fullscreen' : 'Expand'}