Files
zeekay 16c4453cc1 feat: sync with upstream shadcn/ui (through [email protected])
Squash merge of shadcn-ui/ui main branch into hanzo/ui, bringing in:
- [email protected] through [email protected] releases
- New apps/v4 directory structure
- Registry system improvements and MCP server
- Framework support (Vue, Svelte, React Native)
- New templates (vite-app, monorepo-next, laravel)
- Zod 4 compatibility (scoped override for zod@>4)
- Test fixture corrections for alias resolution

All 867 merge conflicts resolved preserving Hanzo customizations.
1020/1020 shadcn tests pass.
2026-02-09 10:44:26 -08:00

134 lines
3.2 KiB
TypeScript

"use client"
import * as React from "react"
import {
Combobox,
ComboboxChip,
ComboboxChips,
ComboboxChipsInput,
ComboboxContent,
ComboboxEmpty,
ComboboxItem,
ComboboxList,
ComboboxValue,
useComboboxAnchor,
} from "@/examples/base/ui-rtl/combobox"
import { Field, FieldLabel } from "@/examples/base/ui-rtl/field"
import {
useTranslation,
type Translations,
} from "@/components/language-selector"
const categories = [
"technology",
"design",
"business",
"marketing",
"education",
"health",
] as const
const translations: Translations = {
en: {
dir: "ltr",
values: {
label: "Categories",
placeholder: "Add categories",
empty: "No categories found.",
technology: "Technology",
design: "Design",
business: "Business",
marketing: "Marketing",
education: "Education",
health: "Health",
},
},
ar: {
dir: "rtl",
values: {
label: "الفئات",
placeholder: "أضف فئات",
empty: "لم يتم العثور على فئات.",
technology: "التكنولوجيا",
design: "التصميم",
business: "الأعمال",
marketing: "التسويق",
education: "التعليم",
health: "الصحة",
},
},
he: {
dir: "rtl",
values: {
label: "קטגוריות",
placeholder: "הוסף קטגוריות",
empty: "לא נמצאו קטגוריות.",
technology: "טכנולוגיה",
design: "עיצוב",
business: "עסקים",
marketing: "שיווק",
education: "חינוך",
health: "בריאות",
},
},
}
export function ComboboxRtl() {
const { dir, t, language } = useTranslation(translations, "ar")
const anchor = useComboboxAnchor()
const categoryLabels: Record<string, string> = {
technology: t.technology,
design: t.design,
business: t.business,
marketing: t.marketing,
education: t.education,
health: t.health,
}
return (
<Field className="mx-auto w-full max-w-xs">
<FieldLabel>{t.label}</FieldLabel>
<Combobox
multiple
autoHighlight
items={categories}
defaultValue={[categories[0]]}
itemToStringValue={(item: (typeof categories)[number]) =>
categoryLabels[item] || item
}
>
<ComboboxChips ref={anchor}>
<ComboboxValue>
{(values) => (
<React.Fragment>
{values.map((value: string) => (
<ComboboxChip key={value}>
{categoryLabels[value] || value}
</ComboboxChip>
))}
<ComboboxChipsInput placeholder={t.placeholder} />
</React.Fragment>
)}
</ComboboxValue>
</ComboboxChips>
<ComboboxContent
anchor={anchor}
dir={dir}
data-lang={dir === "rtl" ? language : undefined}
>
<ComboboxEmpty>{t.empty}</ComboboxEmpty>
<ComboboxList>
{(item) => (
<ComboboxItem key={item} value={item}>
{categoryLabels[item] || item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</Field>
)
}