date picker

This commit is contained in:
estifanos
2026-07-28 07:25:19 +00:00
parent 31ab6ae260
commit cdec4c435b
2 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
/* Restyle the react-day-picker month/year dropdown caption to match Mantine
inputs — the library ships it as bare text + an invisible <select>, with
no border/box affordance and a hardcoded blue chevron. */
.amharic-daypicker {
--rdp-accent-color: var(--mantine-primary-color-filled);
}
.amharic-daypicker .rdp-dropdowns {
gap: 0.375rem;
}
.amharic-daypicker .rdp-dropdown_root {
border: 1px solid var(--mantine-color-default-border);
border-radius: var(--mantine-radius-sm);
background-color: var(--mantine-color-body);
padding: 0.25rem 0.5rem;
}
.amharic-daypicker .rdp-dropdown_root:hover {
background-color: var(--mantine-color-default-hover);
}
.amharic-daypicker .rdp-caption_label {
gap: 0.25rem;
font-size: var(--mantine-font-size-sm);
font-weight: 500;
color: var(--mantine-color-text);
}
.amharic-daypicker .rdp-chevron {
width: 12px;
height: 12px;
fill: var(--mantine-color-dimmed);
}
.amharic-daypicker .rdp-month_caption {
font-size: inherit;
font-weight: 600;
}

View File

@@ -6,6 +6,7 @@ import { DayPicker as GregorianDayPicker } from '@daypicker/react';
import { IconCalendarEvent } from '@tabler/icons-react'; import { IconCalendarEvent } from '@tabler/icons-react';
import { EthDateTime } from 'ethiopian-calendar-date-converter'; import { EthDateTime } from 'ethiopian-calendar-date-converter';
import '@daypicker/react/dist/style.css'; import '@daypicker/react/dist/style.css';
import './AmharicDatePicker.css';
const EC_MONTHS_AM = [ const EC_MONTHS_AM = [
'መስከረም', 'ጥቅምት', 'ኅዳር', 'ታህሳስ', 'ጥር', 'የካቲት', 'መስከረም', 'ጥቅምት', 'ኅዳር', 'ታህሳስ', 'ጥር', 'የካቲት',
@@ -59,6 +60,8 @@ export function toEthiopicDateLabel(date: Date): string {
} }
} }
const YEAR_DROPDOWN_END = new Date(new Date().getFullYear() + 50, 11, 31);
export interface AmharicDatePickerProps { export interface AmharicDatePickerProps {
label?: string; label?: string;
value?: Date | null; value?: Date | null;
@@ -129,9 +132,11 @@ export function AmharicDatePicker({
<Popover.Dropdown p="md"> <Popover.Dropdown p="md">
{calendarType === 'AMH' ? ( {calendarType === 'AMH' ? (
<EthiopicDayPicker <EthiopicDayPicker
className="amharic-daypicker"
mode="single" mode="single"
selected={value ?? undefined} selected={value ?? undefined}
defaultMonth={value ?? undefined} defaultMonth={value ?? undefined}
endMonth={YEAR_DROPDOWN_END}
numerals="latn" numerals="latn"
captionLayout="dropdown" captionLayout="dropdown"
formatters={ETH_FORMATTERS} formatters={ETH_FORMATTERS}
@@ -142,9 +147,11 @@ export function AmharicDatePicker({
/> />
) : ( ) : (
<GregorianDayPicker <GregorianDayPicker
className="amharic-daypicker"
mode="single" mode="single"
selected={value ?? undefined} selected={value ?? undefined}
defaultMonth={value ?? undefined} defaultMonth={value ?? undefined}
endMonth={YEAR_DROPDOWN_END}
captionLayout="dropdown" captionLayout="dropdown"
onSelect={(date: Date | undefined) => { onSelect={(date: Date | undefined) => {
onChange?.(date ?? null); onChange?.(date ?? null);