Skip to content
Myr

client-owner.tsx

This file

Path

apps/web/src/features/import/client-owner.tsx

54 lines · 1.5 KiB · TypeScript

Last changed by

Merge build/comments-web-features into mainoscabrielbefore adoption74bfc72

History of this file

Take it

Merge build/1411-web-import into mainoscabrielbefore adoption059c75c

lines 1–54why, one step back
1import type { Owner } from "@repo/protocol/ids";
2import { ClientOnly } from "@tanstack/react-router";3import { ChevronDown } from "lucide-react";4import { lazy, Suspense } from "react";56export interface OwnerSelectProps {7 readonly choices: readonly Owner[];8 readonly labelledBy: string;9 readonly describedBy: string;10 readonly onChange: (value: Owner) => void;11 readonly value: Owner | undefined;12}1314export const TRIGGER =15 "tablet:text-ui tablet:h-9 h-11 w-full max-w-sm text-base";1617const SelectLater = import.meta.env.SSR18 ? undefined19 : lazy(() => import("./owner-select.tsx"));2021const StandIn = ({ describedBy, labelledBy, value }: OwnerSelectProps) => (22 <>23 <button24 aria-describedby={describedBy}25 aria-labelledby={labelledBy}26 className={`border-input flex items-center justify-between gap-1.5 border bg-transparent py-2 pr-2 pl-2.5 ${TRIGGER}`}27 data-slot="select-trigger"28 disabled29 type="button"30 >31 {value}32 <ChevronDown33 aria-hidden="true"34 className="text-muted-foreground size-4"35 strokeWidth={1.75}36 />37 </button>38 <input name="owner" type="hidden" value={value ?? ""} />39 </>40);4142export const ClientOwnerSelect = (props: OwnerSelectProps) => {43 const fallback = <StandIn {...props} />;4445 return SelectLater === undefined ? (46 fallback47 ) : (48 <ClientOnly fallback={fallback}>49 <Suspense fallback={fallback}>50 <SelectLater {...props} />51 </Suspense>52 </ClientOnly>53 );54};