منتقي التاريخ واجهة البرمجة
الخصائص والفتحات والنصوص والتنسيق في منتقي التاريخ من slotsmith.
الفتحات
في DatePicker عدد 15 من الفتحات. مرّر بديلًا لأي منها في components، وكل فتحة لا تمرّرها تبقى على بديلها الافتراضي. فتحات العناصر تستقبل خصائص DOM فيناسبها عنصر المكتبة كما هو، وفتحات الأدوات تستقبل خصائص مسمّاة وتحتاج عادة إلى بضعة أسطر من المحوّل.
| الاسم | النوع | الخصائص التي تستقبلها | البديل الافتراضي | سمات data-* |
|---|---|---|---|---|
Root | <element> | خصائص DOM:
| مصدر البديل |
|
Trigger | <element> | خصائص DOM:
| مصدر البديل |
|
Input | <element> | خصائص DOM:
| مصدر البديل |
|
Toggle | <element> | خصائص DOM:
| مصدر البديل |
|
Value | {widget} |
| مصدر البديل | — |
Icon | {widget} |
| مصدر البديل | — |
Clear | {widget} |
| مصدر البديل | — |
Popup | <element> | خصائص DOM:
| مصدر البديل |
|
Calendar | <element> | خصائص DOM:
| مصدر البديل | — |
Caption | {widget} |
| مصدر البديل | — |
Nav | {widget} |
| مصدر البديل | — |
Weekday | {widget} |
| مصدر البديل | — |
Day | <element> | خصائص DOM:
| مصدر البديل |
|
DayContent | {widget} |
| مصدر البديل | — |
Footer | {widget} |
| مصدر البديل | — |
الخصائص
كل خصائص DatePicker مجمّعة كما في توثيق المكتبة. الحالة المتحكَّم بها تأتي أزواجًا: مرّر القيمة مع معالج تغييرها، أو القيمة الابتدائية وحدها لتبقى الحالة داخل المكوّن.
| الاسم | النوع | الافتراضي | الوصف |
|---|---|---|---|
| Value and mode | |||
modesingle mode | "single" | — | One date. The default mode. |
modeمطلوبةmultiple mode | "multiple" | — | Any number of dates, toggled one click at a time. |
modeمطلوبةrange mode | "range" | — | A start and an end: the first click sets the start, the second the end. |
valuesingle mode | ISODate | | — | The picked date, or |
valuemultiple mode | ISODate | — | The picked dates. |
valuerange mode | DateRange | | — | The picked range. Either end may be missing while picking. |
defaultsingle mode | ISODate | | — | The picked date while uncontrolled. |
defaultmultiple mode | ISODate | — | The picked dates while uncontrolled. |
defaultrange mode | DateRange | | — | The picked range while uncontrolled. |
onsingle mode | ( | — | The new date, or |
onmultiple mode | ( | — | The new dates, sorted, always an array. |
onrange mode | ( | — | The new range, or |
clearable | boolean | true | Whether the clear control is offered. Defaults to |
close | boolean |
| Whether picking closes the popup. Defaults to |
value | DateValueFormat |
| How the days the picker exchanges with you are written: |
time | string | the browser's own | The time zone the calendar works in: an IANA name such as |
name | string | — | The form field name. The root then holds a hidden input of that name per picked day, written as |
| Calendar | |||
locale | LocaleInput | the provider's, then | The language: a locale object, or a BCP 47 tag. A tag formats dates and names with |
week | WeekStart | the locale's own first day | The first column of the grid. Defaults to the locale's own first day. |
weekday | "narrow" | | narrow | How long the column headers are. |
presets | DatePickerPreset | — | Shortcuts shown under the grid. A date preset in range mode picks that one day. |
| Bounds | |||
min | ISODate | — | Nothing before this date can be picked, and the calendar does not page past it. |
max | ISODate | — | Nothing after this date can be picked, and the calendar does not page past it. |
disabled | ( | — | Blocks individual dates — weekends, holidays, days already booked. They stay focusable. |
| Open state | |||
open | boolean | — | Whether the popup is open. |
default | boolean | — | Whether the popup starts open. |
on | ( | — | Told when the popup opens or closes. |
disabled | boolean | — | Disables the whole control. Separate from |
invalid | boolean | — | The value failed validation. Sets |
on | ( | — | Told when focus leaves the whole control, for form libraries. |
| Display | |||
trigger | DatePickerTriggerKind | — | What opens the calendar. |
open | boolean | false | With the |
placeholder | string | — | Shown when nothing is picked. With the |
format | Intl. | { | How the trigger formats a date. Defaults to |
placement | PopupPlacement | bottom | Which side of the trigger the popup prefers. Defaults to |
popup | number | 4 | Gap between trigger and popup, in pixels. Defaults to 4. |
portal | PortalTarget | false | Renders the popup in a portal: |
| Slots and labels | |||
components | Partial< | — | Replace any part; the rest fall back to |
labels | Partial< | — | Override any string. Wins over |
slot | DatePickerSlotProps | — | Extra DOM props for the element parts. |
تُمرَّر أي خاصية أخرى إلى العنصر الجذر <div>.
النصوص واللغات
كل نص يعرضه DatePicker أو يعلنه، مع قيمته الافتراضية بالإنجليزية. مرّر labels لتغيير بعضها في مكوّن واحد، أو locale لتحويل كل النصوص إلى لغة أخرى. العرض أدناه يفعل الأمرين.
| المفتاح | النوع | الافتراضي بالإنجليزية | الوصف |
|---|---|---|---|
placeholder | string | "Pick a date" | Trigger text when nothing is picked, and the trigger's default accessible name. |
clear | string | "Clear date" | Accessible name for the clear control. |
open | string | "Open calendar" | Accessible name for the calendar button beside the text field. |
previous | string | "Previous month" | Accessible name for the previous-month control. |
next | string | "Next month" | Accessible name for the next-month control. |
today | string | "Go to today" | Label for the control that jumps to today's month without picking it — a navigation verb, not the bare word "today", so it reads apart from the presets. |
month | string | "Month" | Accessible name for the month dropdown. |
year | string | "Year" | Accessible name for the year dropdown. |
dialog | string | "Choose a date" | Accessible name for the popup. |
count | ( | count(يطبع | Multiple mode: how the trigger summarises more than two dates. |
range | ( | rangeStart(يطبع | Range mode, when only the start is picked. Receives the formatted start. |
range | ( | range(يطبع | Range mode, when both ends are picked. Receives both formatted ends. |
import { DatePicker } from "slotsmith/date-picker";
import { de } from "slotsmith/locales/de";
export default function Labels() {
return (
<DatePicker
mode="multiple"
// Every string in German, from the ready-made pack; month and weekday names come from Intl…
locale={de}
// …except these two, replaced for this picker only.
labels={{ openCalendar: "Kalender zeigen", today: "Heute anzeigen" }}
aria-label="Urlaubstage"
/>
);
}حزم اللغات الجاهزة ودعم الكتابة من اليمين إلى اليسار واللغة على مستوى التطبيق موضّحة في صفحة اللغات.
التنسيق
أسماء الأصناف التي تضعها البدائل الافتراضية في DatePicker على عناصرها، والمتغيرات التي يقرؤها ملف تنسيقه. اضبط متغيرًا على المكوّن أو على أي عنصر يحيط به لتغيير مظهره، واستهدف الصنف فقط لما لا يغطيه متغير.
| الصنف | الفتحة |
|---|---|
.sdp | |
.sdp__header | — |
.sdp__cell | — |
.sdp__weekdays | — |
.sdp__columnheader | — |
.sdp__week | — |
.sdp__chevron | — |
.sdp__icon | |
.sdp__today-icon | — |
.sdp__clear | |
.sdp__caption | |
.sdp__select | — |
.sdp__nav | |
.sdp__weekday | |
.sdp__footer | |
.sdp__preset | — |
.sdp__preset--today | — |
.sdp__today | — |
.sdp__trigger | |
.sdp__input | |
.sdp__toggle | |
.sdp__value | |
.sdp__value--empty | — |
.sdp__popup | |
.sdp__calendar | |
.sdp__day |
| المتغير | الطبقة |
|---|---|
--sdp-accent | هذا المكوّن |
--sdp-border | هذا المكوّن |
--sdp-cell | هذا المكوّن |
--sdp-danger | هذا المكوّن |
--sdp-font-size | هذا المكوّن |
--sdp-gap | هذا المكوّن |
--sdp-hover | هذا المكوّن |
--sdp-muted | هذا المكوّن |
--sdp-on-accent | هذا المكوّن |
--sdp-radius | هذا المكوّن |
--sdp-surface | هذا المكوّن |
--sdp-text | هذا المكوّن |
--ss-accent | مشترك بين كل المكوّنات |
--ss-border | مشترك بين كل المكوّنات |
--ss-danger | مشترك بين كل المكوّنات |
--ss-font-size | مشترك بين كل المكوّنات |
--ss-hover | مشترك بين كل المكوّنات |
--ss-muted | مشترك بين كل المكوّنات |
--ss-on-accent | مشترك بين كل المكوّنات |
--ss-radius | مشترك بين كل المكوّنات |
--ss-surface | مشترك بين كل المكوّنات |
--ss-text | مشترك بين كل المكوّنات |
تنتقل كل المتغيرات إلى قيمها الداكنة تحت .dark, [data-theme="dark"]، على الصفحة أو على أي عنصر يحيط بالمكوّن.