DatePicker
Genel görünümimport { CalendarSystem, DatePicker, DatePickerFooter, DatePreset, DateRange, DateRangePicker } from '@nili/ui';Bu, kütüphanenin kendi genel görünüm sayfası — canlı olarak render ediliyor. Üstten dili veya temayı değiştirin, o da değişir.
Temel
defaultValue ile denetimsiz ya da value artı onChange ile denetimli. Takvim Farsça yerel ayarda varsayılan olarak Celali, diğerlerinde Miladi olur — hangisi olduğunu söylemeniz seyrek gerekir.
import { DatePicker } from "@nili/ui"
export function Example() {
const [date, setDate] = useState<Date | null>(new Date())
return <DatePicker value={date} onChange={setDate} />
}Takvim sistemleri
calendar Celali (Hicri Şemsi) ya da Miladi’yi dayatır; locale ay adlarını, gün adlarını ve rakamları belirler. allowCalendarSwitch başlığa bir anahtar koyar; kullanıcı kendisi değiştirir.
import { DatePicker } from "@nili/ui"
export function Example() {
return (
<>
<DatePicker calendar="jalali" locale="fa" />
<DatePicker calendar="gregorian" locale="en" />
{/* let the user pick */}
<DatePicker
allowCalendarSwitch
labels={{ calendarSwitch: "Change calendar", jalali: "شمسی", gregorian: "میلادی" }}
/>
</>
)
}Sınırlar, devre dışı günler ve işaretler
minDate ve maxDate aralığı kırpar; gerisini isDateDisabled halleder — hafta sonları, tatiller, odanın zaten dolu olduğu günler. markedDates Figma’nın işaret noktasını alır.
import { DatePicker } from "@nili/ui"
export function Example() {
return (
<DatePicker
minDate={new Date()}
maxDate={addDays(60)}
markedDates={[addDays(3), addDays(10)]}
isDateDisabled={(date) => date.getDay() === 5}
/>
)
}Alt bilgi
footer serbest bir yuvadır; DatePickerFooter genelde içine konan Figma satırıdır. Seçici bir açılır katmandayken ve seçim yalnızca Uygula’ya basınca geçerli olmalıyken kullanın.
import { DatePicker, DatePickerFooter, Button } from "@nili/ui"
export function Example() {
return (
<DatePicker
footer={
<DatePickerFooter>
<Button appearance="stroke" size="xs">Cancel</Button>
<Button size="xs">Apply</Button>
</DatePickerFooter>
}
/>
)
}Tarih aralığı seçici
Bir yerine iki tarih. presets, Figma’nın Period Range’idir — kısayol sütunu. Her aralık { from, to }’dur ve kullanıcı seçimin ortasındayken iki uçtan biri null olabilir.
import { DateRangePicker } from "@nili/ui"
export function Example() {
const [range, setRange] = useState({ from: new Date(), to: null })
return (
<DateRangePicker
value={range}
onChange={setRange}
presets={[
{ label: "Last 7 days", range: () => ({ from: addDays(-7), to: new Date() }) },
{ label: "Last 30 days", range: () => ({ from: addDays(-30), to: new Date() }) },
{ label: "This month", range: () => ({ from: startOfMonth(), to: new Date() }) },
]}
/>
)
}CalendarBase
dahiliDiğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| calendar | jalali | gregorian | — | `'jalali'` (Solar Hijri — Shamsi, also called Jalali) or `'gregorian'`. Defaults to Jalali under a Persian locale and Gregorian otherwise. |
| locale | string | — | BCP-47 tag for month names, weekday names and numerals. |
| allowCalendarSwitch | boolean | — | Let the user switch calendars from a toggle in the header. |
| minDate | Date | — | |
| maxDate | Date | — | |
| markedDates | Date[] | — | Days that get a marker dot — Figma's "Marked" state. |
| isDateDisabled | (date: Date) => boolean | — | |
| labels | { previousMonth?: string; nextMonth?: string; calendarSwitch?: string; jalali?: string; gregorian?: string; } | — |
CalendarGrid
dahiliDiğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| calendar* | jalali | gregorian | — | |
| locale* | string | — | |
| cursor* | { year: number; month: number } | — | |
| isSelected* | (date: Date) => boolean | — | |
| isInRange | (date: Date) => boolean | — | |
| rangeEdge | (date: Date) => 'start' | 'end' | 'both' | 'none' | — | |
| isDisabled* | (date: Date) => boolean | — | |
| isMarked* | (date: Date) => boolean | — | |
| onSelect* | (date: Date) => void | — | |
| onHover | (date: Date | null) => void | — |
CalendarToggle
dahiliDatePicker
extends CalendarBaseProps, Omit<ComponentPropsWithoutRef<'div'>, 'onChange' | 'defaultValue'>
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| footer | ReactNode | — | Figma footer — typically `<DatePickerFooter>` with Cancel / Apply. |
| value | Date | null | — | |
| defaultValue | Date | null | — | |
| onChange | (date: Date | null) => void | — | |
| calendar | jalali | gregorian | — | `'jalali'` (Solar Hijri — Shamsi, also called Jalali) or `'gregorian'`. Defaults to Jalali under a Persian locale and Gregorian otherwise. |
| locale | string | en | BCP-47 tag for month names, weekday names and numerals. |
| allowCalendarSwitch | boolean | false | Let the user switch calendars from a toggle in the header. |
| minDate | Date | — | |
| maxDate | Date | — | |
| markedDates | Date[] | — | Days that get a marker dot — Figma's "Marked" state. |
| isDateDisabled | (date: Date) => boolean | — | |
| labels | { previousMonth?: string; nextMonth?: string; calendarSwitch?: string; jalali?: string; gregorian?: string; } | — |
DatePickerFooter
DateRangePicker
extends CalendarBaseProps, Omit<ComponentPropsWithoutRef<'div'>, 'onChange' | 'defaultValue'>
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| value | DateRange | — | |
| defaultValue | DateRange | — | |
| onChange | (range: DateRange) => void | — | |
| presets | DatePreset[] | — | Shortcut column — Figma's "Period Range". |
| footer | ReactNode | — | |
| calendar | jalali | gregorian | — | `'jalali'` (Solar Hijri — Shamsi, also called Jalali) or `'gregorian'`. Defaults to Jalali under a Persian locale and Gregorian otherwise. |
| locale | string | en | BCP-47 tag for month names, weekday names and numerals. |
| allowCalendarSwitch | boolean | false | Let the user switch calendars from a toggle in the header. |
| minDate | Date | — | |
| maxDate | Date | — | |
| markedDates | Date[] | — | Days that get a marker dot — Figma's "Marked" state. |
| isDateDisabled | (date: Date) => boolean | — | |
| labels | { previousMonth?: string; nextMonth?: string; calendarSwitch?: string; jalali?: string; gregorian?: string; } | — |
DateSelector
dahiliDayCell
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| outside | 'true' | 'false' | false | |
| selected | 'true' | 'false' | false | |
| inRange | 'true' | 'false' | false | |
| rangeEdge | start | end | both | none | none | |
| today | 'true' | 'false' | false | |
| marked | 'true' | 'false' | false |
DayLabel
dahiliHeader
dahiliDiğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| calendar* | jalali | gregorian | — | |
| locale* | string | — | |
| cursor* | { year: number; month: number } | — | |
| onStep* | (delta: number) => void | — | |
| allowCalendarSwitch* | boolean | — | |
| onCalendarChange* | (system: CalendarSystem) => void | — | |
| labels* | NonNullable<DatePickerProps['labels']> | — |
PeriodRange
dahiliPeriodRangeItem
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| selected | 'true' | 'false' | false |