// ~/src/siteplane/components/native-select/native-select.tsx "use client"; import { Field as FieldPrimitive } from "@base-ui/react/field"; import type * as React from "react"; import { type SiteplaneControlSize, useResolvedControlSize, } from "../../system/provider/siteplane-ui-provider"; import { SelectCaretIcon } from "../../system/styles/select-caret"; import type { FormControlTriggerVariant } from "../../system/styles/surface"; import { cn } from "../../system/utils/cn"; import { slotClass } from "../../system/utils/slot-class"; import "./native-select.css"; export type NativeSelectProps = Omit< React.ComponentPropsWithoutRef<"select">, "size" > & React.RefAttributes & { /** * The control size, 36, 40, 44 and 48 px from sm to xl; unset, the * provider's. */ size?: SiteplaneControlSize | undefined; /** * The surface. `default` rests raised, as the Select trigger does. * `outline` rests transparent inside the hairline rim of an outline * Button, for a filter bar or a toolbar beside an inset search field, as * the Select trigger's `outline` does. Default: `default`. */ variant?: FormControlTriggerVariant | undefined; /** * `full` fills the container, like Input. `fit` is as wide as the value * and the caret, at the width the browser gives the select, that of its * widest option. Default: `full`. */ width?: "fit" | "full" | undefined; }; /** * The browser's own select on the field scale: the options open in the * platform's list, a phone's picker on a phone, and the value is a form * value. It looks like the Select trigger, with the same caret, sizes, * focus, invalid and disabled states (design-rework.css), so the two stand * side by side in a form. Its options are NativeSelectOption and * NativeSelectOptGroup children. * * In a Field it is the Field's control: FieldLabel names it, * FieldDescription and FieldError describe it, and the Field reads its value * and its validity. * * It stands on its own, the kit's one native select, which people choose on * purpose. It never sits inside another kit part: a select in an InputGroup * segment is the kit Select, a SelectTrigger with `variant="segment"` in a * bare InputGroupAddon (rulebook K3, Lukas, 2 November 2026). */ export function NativeSelect({ children, className, ref, size, style, variant = "default", width = "full", ...props }: NativeSelectProps): React.ReactElement { const resolvedSize = useResolvedControlSize(size); return ( ); } /** An option of a NativeSelect: the native `option`. */ export function NativeSelectOption({ className, ...props }: React.ComponentProps<"option">): React.ReactElement { return ( ); } // ~/src/siteplane/components/native-select/native-select.css @layer theme, base, components, siteplane, utilities; @layer siteplane { /* The wrapper is the control the eye sees: the Select trigger's field, its * sizes, rim, dome, hover, press, focus, invalid and disabled states come * from the select-trigger rules (design-rework.css), which name it beside * the trigger. These defaults lay it out: as wide as its container, as a * Select trigger is. */ :where(.sp-native-select-wrapper) { position: relative; display: inline-flex; width: 100%; min-width: 0; vertical-align: middle; /* The value's weight, which the select-trigger rules name for the * trigger's Button: the body weight. */ font-weight: var(--sp-rw-button-font-weight); } /* width="fit": as wide as the value and the caret, at the width the browser * gives the select, that of its widest option, as a fit Select trigger is * as wide as its value. */ :where(.sp-native-select-wrapper[data-width="fit"]) { width: fit-content; } /* The select fills the wrapper and draws nothing of its own: the browser's * arrow is off, and the value starts and ends where a Select trigger's does, * at the field's inline padding and 8 px before the caret (the * select-trigger rules name both). It acts as a button, so it shows the * pointer, and not-allowed while it is disabled (rulebook T8). */ :where(.sp-native-select) { flex: 1 1 auto; width: 100%; min-width: 0; height: auto; margin: 0; border: 0; border-radius: inherit; padding-block: 0; padding-inline: var(--sp-rw-select-value-start) var(--sp-rw-select-value-end); appearance: none; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-overflow: ellipsis; outline: none; cursor: pointer; } :where(.sp-native-select:disabled) { cursor: not-allowed; } /* The list is the platform's. Where the browser draws the options with the * select's colours, they take the system's canvas and text, so they stay * legible on a dark page whose select is transparent. */ :where(.sp-native-select-option), :where(.sp-native-select-optgroup) { background-color: Canvas; color: CanvasText; } } // ~/src/siteplane/components/native-select/index.ts export * from "./native-select";