feat(app): polish select-v2 component (#30446)
Co-authored-by: Brendan Allan <git@brendonovich.dev>
This commit is contained in:
co-authored by
Brendan Allan
parent
2538c0d083
commit
134a5c818a
@@ -53,8 +53,8 @@ export type SelectV2Props<T> = Omit<
|
||||
groupBy?: (x: T) => string
|
||||
onSelect?: (value: T | null) => void
|
||||
onHighlight?: (value: T | undefined) => void | (() => void)
|
||||
/** Match TextInput v2 height. */
|
||||
appearance?: "base" | "large"
|
||||
/** `base` / `large` match text-input-v2; `inline` is a compact settings-row trigger. */
|
||||
appearance?: "base" | "large" | "inline"
|
||||
invalid?: boolean
|
||||
numeric?: boolean
|
||||
children?: (item: T) => JSX.Element
|
||||
@@ -80,8 +80,16 @@ export function SelectV2<T>(props: SelectV2Props<T>) {
|
||||
"numeric",
|
||||
"disabled",
|
||||
"valueClass",
|
||||
"placement",
|
||||
"gutter",
|
||||
"sameWidth",
|
||||
"flip",
|
||||
"slide",
|
||||
"fitViewport",
|
||||
])
|
||||
|
||||
const inline = () => (local.appearance ?? "base") === "inline"
|
||||
|
||||
const state: { key?: string; cleanup?: void | (() => void) } = {}
|
||||
|
||||
const stop = () => {
|
||||
@@ -115,8 +123,12 @@ export function SelectV2<T>(props: SelectV2Props<T>) {
|
||||
multiple={false}
|
||||
disabled={local.disabled}
|
||||
data-component="select-v2-root"
|
||||
gutter={6}
|
||||
placement="bottom-start"
|
||||
placement={local.placement ?? (inline() ? "bottom-end" : "bottom-start")}
|
||||
gutter={local.gutter ?? 4}
|
||||
sameWidth={local.sameWidth ?? !inline()}
|
||||
flip={local.flip ?? true}
|
||||
slide={local.slide ?? true}
|
||||
fitViewport={local.fitViewport ?? false}
|
||||
value={local.current}
|
||||
options={grouped()}
|
||||
optionValue={(x) => (local.value ? local.value(x) : String(x as string))}
|
||||
|
||||
Reference in New Issue
Block a user