MCPcopy
hub / github.com/untitleduico/react / ComboBoxValue

Function ComboBoxValue

components/base/select/combobox.tsx:37–106  ·  view source on GitHub ↗
({ size, shortcut, placeholder, shortcutClassName, icon: IconProp, ref, ...otherProps }: ComboBoxValueProps)

Source from the content-addressed store, hash-verified

35}
36
37const ComboBoxValue = ({ size, shortcut, placeholder, shortcutClassName, icon: IconProp, ref, ...otherProps }: ComboBoxValueProps) => {
38 const state = useContext(ComboBoxStateContext);
39
40 const value = state?.selectedItem?.value || null;
41 const inputValue = state?.inputValue || null;
42
43 const first = inputValue?.split(value?.supportingText)?.[0] || "";
44 const last = inputValue?.split(first)[1];
45
46 return (
47 <AriaGroup
48 ref={ref}
49 {...otherProps}
50 className={({ isFocusWithin, isDisabled }) =>
51 cx(
52 "relative flex w-full items-center gap-2 rounded-lg bg-primary shadow-xs ring-1 ring-primary outline-hidden transition-shadow duration-100 ease-linear ring-inset",
53 isDisabled && "cursor-not-allowed opacity-50",
54 isFocusWithin && "ring-2 ring-brand",
55
56 // Icon styles
57 "*:data-icon:shrink-0 *:data-icon:text-fg-quaternary",
58
59 sizes[size].root,
60 )
61 }
62 >
63 {isReactComponent(IconProp) ? (
64 <IconProp data-icon className="pointer-events-none" aria-hidden="true" />
65 ) : isValidElement(IconProp) ? (
66 IconProp
67 ) : (
68 <SearchLg data-icon className="pointer-events-none" aria-hidden="true" />
69 )}
70
71 <div className="relative flex w-full items-center">
72 {inputValue && (
73 <span className={cx("absolute top-1/2 z-0 inline-flex w-full -translate-y-1/2 truncate", sizes[size].textContainer)} aria-hidden="true">
74 <p className={cx("font-medium text-primary", sizes[size].text)}>{first}</p>
75 {last && <p className={cx("-ml-0.75 text-tertiary", sizes[size].text)}>{last}</p>}
76 </span>
77 )}
78
79 <AriaInput
80 placeholder={placeholder}
81 className={cx(
82 "z-10 w-full appearance-none bg-transparent text-transparent caret-alpha-black/90 placeholder:text-placeholder focus:outline-hidden disabled:cursor-not-allowed",
83 sizes[size].text,
84 )}
85 />
86 </div>
87
88 {shortcut && (
89 <div
90 className={cx(
91 "absolute inset-y-0.5 right-0.5 z-10 hidden items-center rounded-r-[inherit] bg-linear-to-r from-transparent to-bg-primary to-40% pl-8 md:flex",
92 sizes[size].shortcut,
93 shortcutClassName,
94 )}

Callers

nothing calls this directly

Calls 1

isReactComponentFunction · 0.90

Tested by

no test coverage detected