From 42216cd6606e2d9993975cfff50d188da08f2b34 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 25 Mar 2026 00:10:04 +0000 Subject: [PATCH] Add locale switcher to DatePicker demo Co-authored-by: Jay Mantri --- src/app/page.tsx | 122 ++++++++++++++++++++++++++++++----------------- 1 file changed, 79 insertions(+), 43 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 8e74d6c..1f56ffa 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1612,6 +1612,84 @@ function DrawerDemo() { ); } +const LOCALES = [ + { code: 'en-US', label: 'English (US)', weekStart: 0 as const }, + { code: 'en-GB', label: 'English (UK)', weekStart: 1 as const }, + { code: 'fr-FR', label: 'French', weekStart: 1 as const }, + { code: 'de-DE', label: 'German', weekStart: 1 as const }, + { code: 'es-ES', label: 'Spanish', weekStart: 1 as const }, + { code: 'pt-BR', label: 'Portuguese (BR)', weekStart: 0 as const }, + { code: 'ja-JP', label: 'Japanese', weekStart: 0 as const }, + { code: 'ko-KR', label: 'Korean', weekStart: 0 as const }, + { code: 'zh-CN', label: 'Chinese (CN)', weekStart: 1 as const }, + { code: 'ar-SA', label: 'Arabic (SA)', weekStart: 0 as const }, +]; + +function LocalizedDatePicker() { + const [localeCode, setLocaleCode] = React.useState(LOCALES[0].code); + const [value, setValue] = React.useState(null); + const [mode, setMode] = React.useState<'single' | 'range'>('range'); + const [includeTime, setIncludeTime] = React.useState(false); + const locale = LOCALES.find((l) => l.code === localeCode) ?? LOCALES[0]; + + return ( +
+
+

Localized

+ { if (v) setLocaleCode(v); }}> + + + + + + + + + {LOCALES.map((l) => ( + + {l.label} + + ))} + + + + + +
+ + + + + + + { + setMode(v ? 'range' : 'single'); + setValue(null); + }} + /> + + + + + + + + + +
+ ); +} + function DatePickerDemo() { const [singleDate, setSingleDate] = React.useState(null); const [rangeValue, setRangeValue] = React.useState(null); @@ -1662,49 +1740,7 @@ function DatePickerDemo() { -
-

French (locale)

- - - - - - - { - setMode(v ? 'range' : 'single'); - setRangeValue(null); - }} - /> - - - - - - - - - -
+ ); }