MCPcopy Create free account
hub / github.com/arctic-cli/interface / ComboboxInput

Function ComboboxInput

packages/web/components/ui/combobox.tsx:38–119  ·  view source on GitHub ↗
({
  className,
  showTrigger = true,
  showClear = false,
  startAddon,
  size,
  ...props
}: Omit<ComboboxPrimitive.Input.Props, "size"> & {
  showTrigger?: boolean;
  showClear?: boolean;
  startAddon?: React.ReactNode;
  size?: "sm" | "default" | "lg" | number;
  ref?: React.Ref<HTMLInputElement>;
})

Source from the content-addressed store, hash-verified

36}
37
38function ComboboxInput({
39 className,
40 showTrigger = true,
41 showClear = false,
42 startAddon,
43 size,
44 ...props
45}: Omit<ComboboxPrimitive.Input.Props, "size"> & {
46 showTrigger?: boolean;
47 showClear?: boolean;
48 startAddon?: React.ReactNode;
49 size?: "sm" | "default" | "lg" | number;
50 ref?: React.Ref<HTMLInputElement>;
51}) {
52 const { multiple } = React.useContext(ComboboxContext);
53 const sizeValue = (size ?? "default") as "sm" | "default" | "lg" | number;
54
55 // multiple mode
56 if (multiple) {
57 return (
58 <ComboboxPrimitive.Input
59 className={cn(
60 "min-w-12 flex-1 text-base outline-none sm:text-sm [[data-slot=combobox-chip]+&]:ps-0.5",
61 sizeValue === "sm" ? "ps-1.5" : "ps-2",
62 className,
63 )}
64 data-size={typeof sizeValue === "string" ? sizeValue : undefined}
65 data-slot="combobox-input"
66 size={typeof sizeValue === "number" ? sizeValue : undefined}
67 {...props}
68 />
69 );
70 }
71
72 // single mode
73 return (
74 <div className="relative w-full has-disabled:opacity-64">
75 {startAddon && (
76 <div
77 aria-hidden="true"
78 className="[&_svg]:-mx-0.5 pointer-events-none absolute inset-y-0 start-px z-10 flex items-center ps-[calc(--spacing(3)-1px)] opacity-80 has-[+[data-size=sm]]:ps-[calc(--spacing(2.5)-1px)] [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4"
79 data-slot="combobox-start-addon"
80 >
81 {startAddon}
82 </div>
83 )}
84 <ComboboxPrimitive.Input
85 className={cn(
86 startAddon &&
87 "data-[size=sm]:*:data-[slot=combobox-input]:ps-[calc(--spacing(7.5)-1px)] *:data-[slot=combobox-input]:ps-[calc(--spacing(8.5)-1px)] sm:data-[size=sm]:*:data-[slot=combobox-input]:ps-[calc(--spacing(7)-1px)] sm:*:data-[slot=combobox-input]:ps-[calc(--spacing(8)-1px)]",
88 sizeValue === "sm"
89 ? "has-[+[data-slot=combobox-trigger],+[data-slot=combobox-clear]]:*:data-[slot=combobox-input]:pe-6.5"
90 : "has-[+[data-slot=combobox-trigger],+[data-slot=combobox-clear]]:*:data-[slot=combobox-input]:pe-7",
91 className,
92 )}
93 data-slot="combobox-input"
94 render={<Input className="has-disabled:opacity-100" size={sizeValue} />}
95 {...props}

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected