UEA-PRODEM
This commit is contained in:
+1
-1
@@ -243,7 +243,7 @@ export function DayPicker(initialProps) {
|
||||
formatters,
|
||||
};
|
||||
return (React.createElement(dayPickerContext.Provider, { value: contextValue },
|
||||
React.createElement(components.Root, { rootRef: props.animate ? rootElRef : undefined, className: className, style: style, dir: props.dir, id: props.id, lang: props.lang, nonce: props.nonce, title: props.title, role: props.role, "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], ...dataAttributes },
|
||||
React.createElement(components.Root, { rootRef: props.animate ? rootElRef : undefined, className: className, style: style, dir: props.dir, id: props.id, lang: props.lang ?? locale.code, nonce: props.nonce, title: props.title, role: props.role, "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], ...dataAttributes },
|
||||
React.createElement(components.Months, { className: classNames[UI.Months], style: styles?.[UI.Months] },
|
||||
!props.hideNavigation && !navLayout && (React.createElement(components.Nav, { "data-animated-nav": props.animate ? "true" : undefined, className: classNames[UI.Nav], style: styles?.[UI.Nav], "aria-label": labelNav(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth: previousMonth, nextMonth: nextMonth })),
|
||||
months.map((calendarMonth, displayIndex) => {
|
||||
|
||||
+42
-35
@@ -66,7 +66,7 @@ export declare enum UI {
|
||||
/** The dropdown with the years. */
|
||||
YearsDropdown = "years_dropdown"
|
||||
}
|
||||
/** Enum representing flags for the {@link UI.Day} element. */
|
||||
/** Enum representing flags for the {@link UI | UI.Day} element. */
|
||||
export declare enum DayFlag {
|
||||
/** The day is disabled. */
|
||||
disabled = "disabled",
|
||||
@@ -80,8 +80,8 @@ export declare enum DayFlag {
|
||||
today = "today"
|
||||
}
|
||||
/**
|
||||
* Enum representing selection states that can be applied to the {@link UI.Day}
|
||||
* element in selection mode.
|
||||
* Enum representing selection states that can be applied to the
|
||||
* {@link UI | UI.Day} element in selection mode.
|
||||
*/
|
||||
export declare enum SelectionState {
|
||||
/** The day is at the end of a selected range. */
|
||||
@@ -131,40 +131,42 @@ export declare enum Animation {
|
||||
export type DeprecatedUI<T extends CSSProperties | string> = {
|
||||
/**
|
||||
* This element was applied to the style of any button in DayPicker and it is
|
||||
* replaced by {@link UI.PreviousMonthButton} and {@link UI.NextMonthButton}.
|
||||
* replaced by {@link UI | UI.PreviousMonthButton} and
|
||||
* {@link UI | UI.NextMonthButton}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
button: T;
|
||||
/**
|
||||
* This element was resetting the style of any button in DayPicker and it is
|
||||
* replaced by {@link UI.PreviousMonthButton} and {@link UI.NextMonthButton}.
|
||||
* replaced by {@link UI | UI.PreviousMonthButton} and
|
||||
* {@link UI | UI.NextMonthButton}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
button_reset: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.MonthCaption}.
|
||||
* This element has been renamed to {@link UI | UI.MonthCaption}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
caption: T;
|
||||
/**
|
||||
* This element has been removed. Captions are styled via
|
||||
* {@link UI.MonthCaption}.
|
||||
* {@link UI | UI.MonthCaption}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
caption_between: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.Dropdowns}.
|
||||
* This element has been renamed to {@link UI | UI.Dropdowns}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
caption_dropdowns: T;
|
||||
/**
|
||||
* This element has been removed. Captions are styled via
|
||||
* {@link UI.MonthCaption}.
|
||||
* {@link UI | UI.MonthCaption}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
@@ -176,74 +178,78 @@ export type DeprecatedUI<T extends CSSProperties | string> = {
|
||||
*/
|
||||
caption_start: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.Day}.
|
||||
* This element has been renamed to {@link UI | UI.Day}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
cell: T;
|
||||
/**
|
||||
* This element has been renamed to {@link DayFlag.disabled}.
|
||||
* This element has been renamed to {@link DayFlag | DayFlag.disabled}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
day_disabled: T;
|
||||
/**
|
||||
* This element has been renamed to {@link DayFlag.hidden}.
|
||||
* This element has been renamed to {@link DayFlag | DayFlag.hidden}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
day_hidden: T;
|
||||
/**
|
||||
* This element has been renamed to {@link DayFlag.outside}.
|
||||
* This element has been renamed to {@link DayFlag | DayFlag.outside}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
day_outside: T;
|
||||
/**
|
||||
* This element has been renamed to {@link SelectionState.range_end}.
|
||||
* This element has been renamed to
|
||||
* {@link SelectionState | SelectionState.range_end}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
day_range_end: T;
|
||||
/**
|
||||
* This element has been renamed to {@link SelectionState.range_middle}.
|
||||
* This element has been renamed to
|
||||
* {@link SelectionState | SelectionState.range_middle}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
day_range_middle: T;
|
||||
/**
|
||||
* This element has been renamed to {@link SelectionState.range_start}.
|
||||
* This element has been renamed to
|
||||
* {@link SelectionState | SelectionState.range_start}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
day_range_start: T;
|
||||
/**
|
||||
* This element has been renamed to {@link SelectionState.selected}.
|
||||
* This element has been renamed to
|
||||
* {@link SelectionState | SelectionState.selected}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
day_selected: T;
|
||||
/**
|
||||
* This element has been renamed to {@link DayFlag.today}.
|
||||
* This element has been renamed to {@link DayFlag | DayFlag.today}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
day_today: T;
|
||||
/**
|
||||
* This element has been removed. The dropdown icon is now {@link UI.Chevron}
|
||||
* inside a {@link UI.CaptionLabel}.
|
||||
* This element has been removed. The dropdown icon is now
|
||||
* {@link UI | UI.Chevron} inside a {@link UI | UI.CaptionLabel}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
dropdown_icon: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.MonthsDropdown}.
|
||||
* This element has been renamed to {@link UI | UI.MonthsDropdown}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
dropdown_month: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.YearsDropdown}.
|
||||
* This element has been renamed to {@link UI | UI.YearsDropdown}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
@@ -255,13 +261,13 @@ export type DeprecatedUI<T extends CSSProperties | string> = {
|
||||
*/
|
||||
head: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.Weekday}.
|
||||
* This element has been renamed to {@link UI | UI.Weekday}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
head_cell: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.Weekdays}.
|
||||
* This element has been renamed to {@link UI | UI.Weekdays}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
@@ -275,51 +281,52 @@ export type DeprecatedUI<T extends CSSProperties | string> = {
|
||||
multiple_months: T;
|
||||
/**
|
||||
* This element has been removed. To style the navigation buttons, use
|
||||
* {@link UI.PreviousMonthButton} and {@link UI.NextMonthButton}.
|
||||
* {@link UI | UI.PreviousMonthButton} and {@link UI | UI.NextMonthButton}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
nav_button: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.NextMonthButton}.
|
||||
* This element has been renamed to {@link UI | UI.NextMonthButton}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
nav_button_next: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.PreviousMonthButton}.
|
||||
* This element has been renamed to {@link UI | UI.PreviousMonthButton}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
nav_button_previous: T;
|
||||
/**
|
||||
* This element has been removed. The dropdown icon is now {@link UI.Chevron}
|
||||
* inside a {@link UI.NextMonthButton} or a {@link UI.PreviousMonthButton}.
|
||||
* This element has been removed. The dropdown icon is now
|
||||
* {@link UI | UI.Chevron} inside a {@link UI | UI.NextMonthButton} or a
|
||||
* {@link UI | UI.PreviousMonthButton}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
nav_icon: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.Week}.
|
||||
* This element has been renamed to {@link UI | UI.Week}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
row: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.MonthGrid}.
|
||||
* This element has been renamed to {@link UI | UI.MonthGrid}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
table: T;
|
||||
/**
|
||||
* This element has been renamed to {@link UI.Weeks}.
|
||||
* This element has been renamed to {@link UI | UI.Weeks}.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
tbody: T;
|
||||
/**
|
||||
* This element has been removed. The {@link UI.Footer} is now a single element
|
||||
* below the months.
|
||||
* This element has been removed. The {@link UI | UI.Footer} is now a single
|
||||
* element below the months.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
@@ -332,7 +339,7 @@ export type DeprecatedUI<T extends CSSProperties | string> = {
|
||||
*/
|
||||
vhidden: T;
|
||||
/**
|
||||
* This element has been renamed. Use {@link UI.WeekNumber} instead.
|
||||
* This element has been renamed. Use {@link UI | UI.WeekNumber} instead.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
|
||||
+3
-3
@@ -66,7 +66,7 @@ export var UI;
|
||||
/** The dropdown with the years. */
|
||||
UI["YearsDropdown"] = "years_dropdown";
|
||||
})(UI || (UI = {}));
|
||||
/** Enum representing flags for the {@link UI.Day} element. */
|
||||
/** Enum representing flags for the {@link UI | UI.Day} element. */
|
||||
export var DayFlag;
|
||||
(function (DayFlag) {
|
||||
/** The day is disabled. */
|
||||
@@ -81,8 +81,8 @@ export var DayFlag;
|
||||
DayFlag["today"] = "today";
|
||||
})(DayFlag || (DayFlag = {}));
|
||||
/**
|
||||
* Enum representing selection states that can be applied to the {@link UI.Day}
|
||||
* element in selection mode.
|
||||
* Enum representing selection states that can be applied to the
|
||||
* {@link UI | UI.Day} element in selection mode.
|
||||
*/
|
||||
export var SelectionState;
|
||||
(function (SelectionState) {
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ export const jaHira = {
|
||||
}
|
||||
return label;
|
||||
},
|
||||
labelNav: "ナビゲーションバー",
|
||||
labelNav: "なびげえしょんばあ",
|
||||
labelWeekNumberHeader: "しゅうばんごう",
|
||||
labelWeekday: (date, options, dateLib) => (dateLib ?? new DateLib(options)).format(date, "cccc"),
|
||||
},
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ export const se = {
|
||||
const lib = dateLib ?? new DateLib(options);
|
||||
let label = lib.format(date, "PPPP");
|
||||
if (modifiers.today)
|
||||
label = `Ođđaid, ${label}`;
|
||||
label = `Odne, ${label}`;
|
||||
if (modifiers.selected)
|
||||
label = `${label}, válljejuvvon`;
|
||||
return label;
|
||||
@@ -23,7 +23,7 @@ export const se = {
|
||||
const lib = dateLib ?? new DateLib(options);
|
||||
let label = lib.format(date, "PPPP");
|
||||
if (modifiers?.today) {
|
||||
label = `Ođđaid, ${label}`;
|
||||
label = `Odne, ${label}`;
|
||||
}
|
||||
return label;
|
||||
},
|
||||
|
||||
+9
-1
@@ -34,7 +34,15 @@ export function DayPicker(props) {
|
||||
noonSafe,
|
||||
overrides: dateLibProp,
|
||||
});
|
||||
return (React.createElement(DayPickerComponent, { ...restProps, locale: localeProp ?? faIR, numerals: numerals ?? "arabext", dir: dir ?? "rtl", dateLib: dateLib }));
|
||||
const locale = localeProp ?? faIR;
|
||||
return (React.createElement(DayPickerComponent, { ...restProps, locale: locale, numerals: numerals ?? "arabext", dir: dir ?? "rtl", dateLib: dateLib, formatters: {
|
||||
formatWeekdayName: (date, _options, lib) => {
|
||||
const activeLib = lib ?? dateLib;
|
||||
const isPersian = activeLib.options.locale?.code?.startsWith("fa");
|
||||
return activeLib.format(date, isPersian ? "ccccc" : "cccccc");
|
||||
},
|
||||
...props.formatters,
|
||||
} }));
|
||||
}
|
||||
/**
|
||||
* Returns the date library used in the Persian calendar.
|
||||
|
||||
+22
-4
@@ -11,15 +11,33 @@ import { rangeIncludesDate } from "../utils/rangeIncludesDate.js";
|
||||
* range, and a function to check if a date is within the range.
|
||||
*/
|
||||
export function useRange(props, dateLib) {
|
||||
const { disabled, excludeDisabled, selected: initiallySelected, required, onSelect, } = props;
|
||||
const { disabled, excludeDisabled, resetOnSelect, selected: initiallySelected, required, onSelect, } = props;
|
||||
const [internallySelected, setSelected] = useControlledValue(initiallySelected, onSelect ? initiallySelected : undefined);
|
||||
const selected = !onSelect ? internallySelected : initiallySelected;
|
||||
const isSelected = (date) => selected && rangeIncludesDate(selected, date, false, dateLib);
|
||||
const select = (triggerDate, modifiers, e) => {
|
||||
const { min, max } = props;
|
||||
const newRange = triggerDate
|
||||
? addToRange(triggerDate, selected, min, max, required, dateLib)
|
||||
: undefined;
|
||||
let newRange;
|
||||
if (triggerDate) {
|
||||
const selectedFrom = selected?.from;
|
||||
const selectedTo = selected?.to;
|
||||
const hasFullRange = !!selectedFrom && !!selectedTo;
|
||||
const isClickingSingleDayRange = !!selectedFrom &&
|
||||
!!selectedTo &&
|
||||
dateLib.isSameDay(selectedFrom, selectedTo) &&
|
||||
dateLib.isSameDay(triggerDate, selectedFrom);
|
||||
if (resetOnSelect && (hasFullRange || !selected?.from)) {
|
||||
if (!required && isClickingSingleDayRange) {
|
||||
newRange = undefined;
|
||||
}
|
||||
else {
|
||||
newRange = { from: triggerDate, to: undefined };
|
||||
}
|
||||
}
|
||||
else {
|
||||
newRange = addToRange(triggerDate, selected, min, max, required, dateLib);
|
||||
}
|
||||
}
|
||||
if (excludeDisabled && disabled && newRange?.from && newRange.to) {
|
||||
if (rangeContainsModifiers({ from: newRange.from, to: newRange.to }, disabled, dateLib)) {
|
||||
// if a disabled days is found, the range is reset
|
||||
|
||||
+27
-3
@@ -399,7 +399,12 @@ export interface PropsBase {
|
||||
nonce?: HTMLDivElement["nonce"];
|
||||
/** Add a `title` attribute to the container element. */
|
||||
title?: HTMLDivElement["title"];
|
||||
/** Add the language tag to the container element. */
|
||||
/**
|
||||
* Add the language tag to the container element.
|
||||
*
|
||||
* When omitted, DayPicker uses the active locale code (`locale.code`).
|
||||
* Set this prop to override the language tag.
|
||||
*/
|
||||
lang?: HTMLDivElement["lang"];
|
||||
/**
|
||||
* The locale object used to localize dates. Pass a locale from
|
||||
@@ -654,9 +659,18 @@ export interface PropsRangeRequired {
|
||||
/**
|
||||
* When `true`, the range will reset when including a disabled day.
|
||||
*
|
||||
* @since V9.0.2
|
||||
* @since 9.0.2
|
||||
*/
|
||||
excludeDisabled?: boolean | undefined;
|
||||
/**
|
||||
* When `true`, clicking a day starts a new range if there is no current start
|
||||
* date or if a range is already complete. In those cases, the clicked day
|
||||
* becomes the start of the new range.
|
||||
*
|
||||
* @since 9.14
|
||||
* @see https://daypicker.dev/selections/range-mode#reset-selection
|
||||
*/
|
||||
resetOnSelect?: boolean | undefined;
|
||||
/** The selected range. */
|
||||
selected: DateRange | undefined;
|
||||
/** Event handler when a range is selected. */
|
||||
@@ -685,10 +699,20 @@ export interface PropsRange {
|
||||
/**
|
||||
* When `true`, the range will reset when including a disabled day.
|
||||
*
|
||||
* @since V9.0.2
|
||||
* @since 9.0.2
|
||||
* @see https://daypicker.dev/docs/selection-modes#exclude-disabled
|
||||
*/
|
||||
excludeDisabled?: boolean | undefined;
|
||||
/**
|
||||
* When `true`, clicking a day starts a new range if there is no current start
|
||||
* date or if a range is already complete. In those cases, the clicked day
|
||||
* becomes the start of the new range. When `required` is `false`, clicking
|
||||
* the same day of a single-day range clears the selection.
|
||||
*
|
||||
* @since 9.14
|
||||
* @see https://daypicker.dev/selections/range-mode#reset-selection
|
||||
*/
|
||||
resetOnSelect?: boolean | undefined;
|
||||
/** The selected range. */
|
||||
selected?: DateRange | undefined;
|
||||
/** Event handler when the selection changes. */
|
||||
|
||||
Reference in New Issue
Block a user