Skip to content

Commit eff8f06

Browse files
refactor: update Combobox and Spinner components to use Element type for chipsRef and improve Spinner props handling (#600)
1 parent 07b4c77 commit eff8f06

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

apps/ui/public/r/combobox.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

apps/ui/public/r/spinner.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"files": [
66
{
77
"path": "registry/default/ui/spinner.tsx",
8-
"content": "import { Loader2Icon } from \"lucide-react\";\n\nimport { cn } from \"@/registry/default/lib/utils\";\n\nfunction Spinner({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <Loader2Icon\n aria-label=\"Loading\"\n className={cn(\"animate-spin\", className)}\n role=\"status\"\n {...props}\n />\n );\n}\n\nexport { Spinner };\n",
8+
"content": "import { cn } from \"@coss/ui/lib/utils\";\nimport { Loader2Icon } from \"lucide-react\";\n\nfunction Spinner({\n className,\n ...props\n}: React.ComponentProps<typeof Loader2Icon>) {\n return (\n <Loader2Icon\n aria-label=\"Loading\"\n className={cn(\"animate-spin\", className)}\n role=\"status\"\n {...props}\n />\n );\n}\n\nexport { Spinner };\n",
99
"type": "registry:ui"
1010
}
1111
]

apps/ui/registry/default/ui/combobox.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Input } from "@/registry/default/ui/input";
99
import { ScrollArea } from "@/registry/default/ui/scroll-area";
1010

1111
const ComboboxContext = React.createContext<{
12-
chipsRef: React.RefObject<HTMLDivElement | null> | null;
12+
chipsRef: React.RefObject<Element | null> | null;
1313
multiple: boolean;
1414
}>({
1515
chipsRef: null,
@@ -24,7 +24,7 @@ type ComboboxRootProps<
2424
function Combobox<ItemValue, Multiple extends boolean | undefined = false>(
2525
props: ComboboxPrimitive.Root.Props<ItemValue, Multiple>,
2626
) {
27-
const chipsRef = React.useRef<HTMLDivElement | null>(null);
27+
const chipsRef = React.useRef<Element | null>(null);
2828
return (
2929
<ComboboxContext.Provider value={{ chipsRef, multiple: !!props.multiple }}>
3030
<ComboboxPrimitive.Root
@@ -309,7 +309,7 @@ function ComboboxChips({ className, ...props }: ComboboxPrimitive.Chips.Props) {
309309
className,
310310
)}
311311
data-slot="combobox-chips"
312-
ref={chipsRef}
312+
ref={chipsRef as React.Ref<HTMLDivElement> | null}
313313
{...props}
314314
/>
315315
);

apps/ui/registry/default/ui/spinner.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { cn } from "@coss/ui/lib/utils";
12
import { Loader2Icon } from "lucide-react";
23

3-
import { cn } from "@/registry/default/lib/utils";
4-
5-
function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
4+
function Spinner({
5+
className,
6+
...props
7+
}: React.ComponentProps<typeof Loader2Icon>) {
68
return (
79
<Loader2Icon
810
aria-label="Loading"

packages/ui/src/components/combobox.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Input } from "@coss/ui/components/input";
99
import { ScrollArea } from "@coss/ui/components/scroll-area";
1010

1111
const ComboboxContext = React.createContext<{
12-
chipsRef: React.RefObject<HTMLDivElement | null> | null;
12+
chipsRef: React.RefObject<Element | null> | null;
1313
multiple: boolean;
1414
}>({
1515
chipsRef: null,
@@ -24,7 +24,7 @@ type ComboboxRootProps<
2424
function Combobox<ItemValue, Multiple extends boolean | undefined = false>(
2525
props: ComboboxPrimitive.Root.Props<ItemValue, Multiple>,
2626
) {
27-
const chipsRef = React.useRef<HTMLDivElement | null>(null);
27+
const chipsRef = React.useRef<Element | null>(null);
2828
return (
2929
<ComboboxContext.Provider value={{ chipsRef, multiple: !!props.multiple }}>
3030
<ComboboxPrimitive.Root
@@ -309,7 +309,7 @@ function ComboboxChips({ className, ...props }: ComboboxPrimitive.Chips.Props) {
309309
className,
310310
)}
311311
data-slot="combobox-chips"
312-
ref={chipsRef}
312+
ref={chipsRef as React.Ref<HTMLDivElement> | null}
313313
{...props}
314314
/>
315315
);

packages/ui/src/components/spinner.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { Loader2Icon } from "lucide-react";
2-
31
import { cn } from "@coss/ui/lib/utils";
2+
import { Loader2Icon } from "lucide-react";
43

5-
function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
4+
function Spinner({
5+
className,
6+
...props
7+
}: React.ComponentProps<typeof Loader2Icon>) {
68
return (
79
<Loader2Icon
810
aria-label="Loading"

0 commit comments

Comments
 (0)