diff --git a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx index 663e4174dd445..7523ae8602eef 100644 --- a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx +++ b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx @@ -15,6 +15,7 @@ import { DateField } from '../DateField'; import { extractValidationProps } from '../internals/utils/validation/extractValidationProps'; import { renderDateViewCalendar } from '../dateViewRenderers'; import { resolveDateFormat } from '../internals/utils/date-utils'; +import { buildGetOpenDialogAriaText } from '../locales/utils/getPickersLocalization'; type DesktopDatePickerComponent = (< TDate extends PickerValidDate, @@ -91,8 +92,12 @@ const DesktopDatePicker = React.forwardRef(function DesktopDatePicker< props, valueManager: singleItemValueManager, valueType: 'date', - getOpenDialogAriaText: - props.localeText?.openDatePickerDialogue ?? translations.openDatePickerDialogue, + getOpenDialogAriaText: buildGetOpenDialogAriaText({ + utils, + formatKey: 'fullDate', + contextTranslation: translations.openDatePickerDialogue, + propsTranslation: translations.openDatePickerDialogue, + }), validator: validateDate, }); diff --git a/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx b/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx index 08342cd65fa6c..43bf71d59e024 100644 --- a/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx +++ b/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx @@ -41,6 +41,7 @@ import { DefaultizedProps } from '../internals/models/helpers'; import { UsePickerViewsProps } from '../internals/hooks/usePicker/usePickerViews'; import { isInternalTimeView } from '../internals/utils/time-utils'; import { isDatePickerView } from '../internals/utils/date-utils'; +import { buildGetOpenDialogAriaText } from '../locales/utils/getPickersLocalization'; const rendererInterceptor = function rendererInterceptor< TDate extends PickerValidDate, @@ -226,8 +227,12 @@ const DesktopDateTimePicker = React.forwardRef(function DesktopDateTimePicker< props, valueManager: singleItemValueManager, valueType: 'date-time', - getOpenDialogAriaText: - props.localeText?.openDatePickerDialogue ?? translations.openDatePickerDialogue, + getOpenDialogAriaText: buildGetOpenDialogAriaText({ + utils, + formatKey: 'fullDate', + contextTranslation: translations.openDatePickerDialogue, + propsTranslation: translations.openDatePickerDialogue, + }), validator: validateDateTime, rendererInterceptor, }); diff --git a/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx b/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx index 516f63d636aa1..af779d515d540 100644 --- a/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx +++ b/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx @@ -21,6 +21,7 @@ import { TimeViewWithMeridiem } from '../internals/models'; import { resolveTimeFormat } from '../internals/utils/time-utils'; import { resolveTimeViewsResponse } from '../internals/utils/date-time-utils'; import { TimeView, PickerValidDate } from '../models'; +import { buildGetOpenDialogAriaText } from '../locales/utils/getPickersLocalization'; type DesktopTimePickerComponent = (< TDate extends PickerValidDate, @@ -129,8 +130,12 @@ const DesktopTimePicker = React.forwardRef(function DesktopTimePicker< props, valueManager: singleItemValueManager, valueType: 'time', - getOpenDialogAriaText: - props.localeText?.openTimePickerDialogue ?? translations.openTimePickerDialogue, + getOpenDialogAriaText: buildGetOpenDialogAriaText({ + utils, + formatKey: 'fullTime', + contextTranslation: translations.openDatePickerDialogue, + propsTranslation: translations.openDatePickerDialogue, + }), validator: validateTime, }); diff --git a/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx b/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx index 15b1b45d76154..d180c8e95b9e1 100644 --- a/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx +++ b/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx @@ -14,6 +14,7 @@ import { extractValidationProps } from '../internals/utils/validation/extractVal import { singleItemValueManager } from '../internals/utils/valueManagers'; import { renderDateViewCalendar } from '../dateViewRenderers'; import { resolveDateFormat } from '../internals/utils/date-utils'; +import { buildGetOpenDialogAriaText } from '../locales/utils/getPickersLocalization'; type MobileDatePickerComponent = (< TDate extends PickerValidDate, @@ -88,8 +89,12 @@ const MobileDatePicker = React.forwardRef(function MobileDatePicker< props, valueManager: singleItemValueManager, valueType: 'date', - getOpenDialogAriaText: - props.localeText?.openDatePickerDialogue ?? translations.openDatePickerDialogue, + getOpenDialogAriaText: buildGetOpenDialogAriaText({ + utils, + formatKey: 'fullDate', + contextTranslation: translations.openDatePickerDialogue, + propsTranslation: translations.openDatePickerDialogue, + }), validator: validateDate, }); diff --git a/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx b/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx index 5f92e1939cb96..b76f39774b69b 100644 --- a/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx +++ b/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx @@ -18,6 +18,7 @@ import { extractValidationProps } from '../internals/utils/validation/extractVal import { renderDateViewCalendar } from '../dateViewRenderers'; import { renderTimeViewClock } from '../timeViewRenderers'; import { resolveDateTimeFormat } from '../internals/utils/date-time-utils'; +import { buildGetOpenDialogAriaText } from '../locales/utils/getPickersLocalization'; type MobileDateTimePickerComponent = (< TDate extends PickerValidDate, @@ -103,8 +104,12 @@ const MobileDateTimePicker = React.forwardRef(function MobileDateTimePicker< props, valueManager: singleItemValueManager, valueType: 'date-time', - getOpenDialogAriaText: - props.localeText?.openDatePickerDialogue ?? translations.openDatePickerDialogue, + getOpenDialogAriaText: buildGetOpenDialogAriaText({ + utils, + formatKey: 'fullDate', + contextTranslation: translations.openDatePickerDialogue, + propsTranslation: translations.openDatePickerDialogue, + }), validator: validateDateTime, }); diff --git a/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx b/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx index f4af4c984ddb8..0ba145569faf5 100644 --- a/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx +++ b/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx @@ -14,6 +14,7 @@ import { useMobilePicker } from '../internals/hooks/useMobilePicker'; import { extractValidationProps } from '../internals/utils/validation/extractValidationProps'; import { renderTimeViewClock } from '../timeViewRenderers'; import { resolveTimeFormat } from '../internals/utils/time-utils'; +import { buildGetOpenDialogAriaText } from '../locales/utils/getPickersLocalization'; type MobileTimePickerComponent = (< TDate extends PickerValidDate, @@ -92,8 +93,12 @@ const MobileTimePicker = React.forwardRef(function MobileTimePicker< props, valueManager: singleItemValueManager, valueType: 'time', - getOpenDialogAriaText: - props.localeText?.openTimePickerDialogue ?? translations.openTimePickerDialogue, + getOpenDialogAriaText: buildGetOpenDialogAriaText({ + utils, + formatKey: 'fullTime', + contextTranslation: translations.openDatePickerDialogue, + propsTranslation: translations.openDatePickerDialogue, + }), validator: validateTime, }); diff --git a/packages/x-date-pickers/src/internals/hooks/useDesktopPicker/useDesktopPicker.tsx b/packages/x-date-pickers/src/internals/hooks/useDesktopPicker/useDesktopPicker.tsx index 9a2bb45a81cc4..97fb108f87334 100644 --- a/packages/x-date-pickers/src/internals/hooks/useDesktopPicker/useDesktopPicker.tsx +++ b/packages/x-date-pickers/src/internals/hooks/useDesktopPicker/useDesktopPicker.tsx @@ -11,7 +11,6 @@ import { UseDesktopPickerProps, UseDesktopPickerSlotProps, } from './useDesktopPicker.types'; -import { useUtils } from '../useUtils'; import { usePicker } from '../usePicker'; import { LocalizationProvider } from '../../../LocalizationProvider'; import { PickersLayout } from '../../../PickersLayout'; @@ -67,7 +66,6 @@ export const useDesktopPicker = < reduceAnimations, } = props; - const utils = useUtils(); const containerRef = React.useRef(null); const fieldRef = React.useRef>(null); @@ -113,7 +111,7 @@ export const useDesktopPicker = < additionalProps: { disabled: disabled || readOnly, onClick: open ? actions.onClose : actions.onOpen, - 'aria-label': getOpenDialogAriaText(pickerFieldProps.value, utils), + 'aria-label': getOpenDialogAriaText(pickerFieldProps.value), edge: inputAdornmentProps.position, }, ownerState: props, diff --git a/packages/x-date-pickers/src/internals/hooks/useDesktopPicker/useDesktopPicker.types.ts b/packages/x-date-pickers/src/internals/hooks/useDesktopPicker/useDesktopPicker.types.ts index c9cc83019e06d..257b0e8cd3f07 100644 --- a/packages/x-date-pickers/src/internals/hooks/useDesktopPicker/useDesktopPicker.types.ts +++ b/packages/x-date-pickers/src/internals/hooks/useDesktopPicker/useDesktopPicker.types.ts @@ -151,5 +151,5 @@ export interface UseDesktopPickerParams< 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor' > { props: TExternalProps; - getOpenDialogAriaText: (date: TDate | null, utils: MuiPickersAdapter) => string; + getOpenDialogAriaText: (date: TDate | null) => string; } diff --git a/packages/x-date-pickers/src/internals/hooks/useMobilePicker/useMobilePicker.tsx b/packages/x-date-pickers/src/internals/hooks/useMobilePicker/useMobilePicker.tsx index b98cf417300b3..15b31e4fc63a2 100644 --- a/packages/x-date-pickers/src/internals/hooks/useMobilePicker/useMobilePicker.tsx +++ b/packages/x-date-pickers/src/internals/hooks/useMobilePicker/useMobilePicker.tsx @@ -10,7 +10,6 @@ import { } from './useMobilePicker.types'; import { usePicker } from '../usePicker'; import { onSpaceOrEnter } from '../../utils/utils'; -import { useUtils } from '../useUtils'; import { LocalizationProvider } from '../../../LocalizationProvider'; import { PickersLayout } from '../../../PickersLayout'; import { InferError } from '../useValidation'; @@ -63,7 +62,6 @@ export const useMobilePicker = < localeText, } = props; - const utils = useUtils(); const fieldRef = React.useRef>(null); const labelId = useId(); @@ -128,7 +126,7 @@ export const useMobilePicker = < // TODO: Move to `useSlotProps` when https://github.com/mui/material-ui/pull/35088 will be merged fieldProps.inputProps = { ...fieldProps.inputProps, - 'aria-label': getOpenDialogAriaText(pickerFieldProps.value, utils), + 'aria-label': getOpenDialogAriaText(pickerFieldProps.value), } as typeof fieldProps.inputProps; const slotsForField = { diff --git a/packages/x-date-pickers/src/internals/hooks/useMobilePicker/useMobilePicker.types.ts b/packages/x-date-pickers/src/internals/hooks/useMobilePicker/useMobilePicker.types.ts index d741a588e9e56..6f022317be6ac 100644 --- a/packages/x-date-pickers/src/internals/hooks/useMobilePicker/useMobilePicker.types.ts +++ b/packages/x-date-pickers/src/internals/hooks/useMobilePicker/useMobilePicker.types.ts @@ -112,5 +112,5 @@ export interface UseMobilePickerParams< 'valueManager' | 'valueType' | 'validator' > { props: TExternalProps; - getOpenDialogAriaText: (date: TDate | null, utils: MuiPickersAdapter) => string; + getOpenDialogAriaText: (date: TDate | null) => string; } diff --git a/packages/x-date-pickers/src/locales/beBY.ts b/packages/x-date-pickers/src/locales/beBY.ts index b178d543d92a0..b7844e1962786 100644 --- a/packages/x-date-pickers/src/locales/beBY.ts +++ b/packages/x-date-pickers/src/locales/beBY.ts @@ -60,13 +60,13 @@ const beBYPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Абраць дату, абрана дата ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Абраць дату, абрана дата ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Абраць дату', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Абраць час, абрыны час ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Абраць час, абрыны час ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Абраць час', // fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/caES.ts b/packages/x-date-pickers/src/locales/caES.ts index a20b33f90f2ee..52a78a9807e29 100644 --- a/packages/x-date-pickers/src/locales/caES.ts +++ b/packages/x-date-pickers/src/locales/caES.ts @@ -59,13 +59,13 @@ const caESPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Tria la data, la data triada és ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Tria la data, la data triada és ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Tria la data', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Tria l'hora, l'hora triada és ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Tria l'hora, l'hora triada és ${formattedTime ?? utils.format(value, 'fullTime')}` : "Tria l'hora", fieldClearLabel: 'Netega el valor', diff --git a/packages/x-date-pickers/src/locales/csCZ.ts b/packages/x-date-pickers/src/locales/csCZ.ts index 50d61430a2b93..221009b29c66e 100644 --- a/packages/x-date-pickers/src/locales/csCZ.ts +++ b/packages/x-date-pickers/src/locales/csCZ.ts @@ -60,13 +60,13 @@ const csCZPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Vyberte datum, vybrané datum je ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Vyberte datum, vybrané datum je ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Vyberte datum', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Vyberte čas, vybraný čas je ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Vyberte čas, vybraný čas je ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Vyberte čas', // fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/daDK.ts b/packages/x-date-pickers/src/locales/daDK.ts index 80b81cc54a47f..8b600b3949b09 100644 --- a/packages/x-date-pickers/src/locales/daDK.ts +++ b/packages/x-date-pickers/src/locales/daDK.ts @@ -60,13 +60,13 @@ const daDKPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Vælg dato, valgte dato er ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Vælg dato, valgte dato er ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Vælg dato', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Vælg tidspunkt, valgte tidspunkt er ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Vælg tidspunkt, valgte tidspunkt er ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Vælg tidspunkt', fieldClearLabel: 'ryd felt', diff --git a/packages/x-date-pickers/src/locales/deDE.ts b/packages/x-date-pickers/src/locales/deDE.ts index 185963fd7486f..9ed2ff930adb1 100644 --- a/packages/x-date-pickers/src/locales/deDE.ts +++ b/packages/x-date-pickers/src/locales/deDE.ts @@ -60,13 +60,13 @@ const deDEPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Datum auswählen, gewähltes Datum ist ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Datum auswählen, gewähltes Datum ist ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Datum auswählen', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Uhrzeit auswählen, gewählte Uhrzeit ist ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Uhrzeit auswählen, gewählte Uhrzeit ist ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Uhrzeit auswählen', fieldClearLabel: 'Wert leeren', diff --git a/packages/x-date-pickers/src/locales/elGR.ts b/packages/x-date-pickers/src/locales/elGR.ts index 90143fdbff0d5..84251cd8fe64a 100644 --- a/packages/x-date-pickers/src/locales/elGR.ts +++ b/packages/x-date-pickers/src/locales/elGR.ts @@ -59,13 +59,13 @@ const elGRPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Επιλέξτε ημερομηνία, η επιλεγμένη ημερομηνία είναι ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Επιλέξτε ημερομηνία, η επιλεγμένη ημερομηνία είναι ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Επιλέξτε ημερομηνία', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Επιλέξτε ώρα, η επιλεγμένη ώρα είναι ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Επιλέξτε ώρα, η επιλεγμένη ώρα είναι ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Επιλέξτε ώρα', // fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/enUS.ts b/packages/x-date-pickers/src/locales/enUS.ts index 39cf369f9a36e..7038b0dd87dfd 100644 --- a/packages/x-date-pickers/src/locales/enUS.ts +++ b/packages/x-date-pickers/src/locales/enUS.ts @@ -55,13 +55,13 @@ const enUSPickers: PickersLocaleText = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Choose date, selected date is ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Choose date, selected date is ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Choose date', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Choose time, selected time is ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Choose time, selected time is ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Choose time', fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/esES.ts b/packages/x-date-pickers/src/locales/esES.ts index f66c4c3848c98..7359c97bd3597 100644 --- a/packages/x-date-pickers/src/locales/esES.ts +++ b/packages/x-date-pickers/src/locales/esES.ts @@ -59,13 +59,13 @@ const esESPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Elige fecha, la fecha elegida es ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Elige fecha, la fecha elegida es ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Elige fecha', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Elige hora, la hora elegida es ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Elige hora, la hora elegida es ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Elige hora', fieldClearLabel: 'Limpiar valor', diff --git a/packages/x-date-pickers/src/locales/eu.ts b/packages/x-date-pickers/src/locales/eu.ts index c65709ab678ee..2d49dbaac2df4 100644 --- a/packages/x-date-pickers/src/locales/eu.ts +++ b/packages/x-date-pickers/src/locales/eu.ts @@ -59,13 +59,13 @@ const euPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Data aukeratu, aukeratutako data ${utils.format(value, 'fullDate')} da` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Data aukeratu, aukeratutako data ${formattedDate ?? utils.format(value, 'fullDate')} da` : 'Data aukeratu', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Ordua aukeratu, aukeratutako ordua ${utils.format(value, 'fullTime')} da` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Ordua aukeratu, aukeratutako ordua ${formattedTime ?? utils.format(value, 'fullTime')} da` : 'Ordua aukeratu', fieldClearLabel: 'Balioa garbitu', diff --git a/packages/x-date-pickers/src/locales/faIR.ts b/packages/x-date-pickers/src/locales/faIR.ts index d28ebb837dd52..fc0882999f42c 100644 --- a/packages/x-date-pickers/src/locales/faIR.ts +++ b/packages/x-date-pickers/src/locales/faIR.ts @@ -59,13 +59,13 @@ const faIRPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `تاریخ را انتخاب کنید، تاریخ انتخاب شده ${utils.format(value, 'fullDate')} می‌باشد` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `تاریخ را انتخاب کنید، تاریخ انتخاب شده ${formattedDate ?? utils.format(value, 'fullDate')} می‌باشد` : 'تاریخ را انتخاب کنید', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `ساعت را انتخاب کنید، ساعت انتخاب شده ${utils.format(value, 'fullTime')} می‌باشد` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `ساعت را انتخاب کنید، ساعت انتخاب شده ${formattedTime ?? utils.format(value, 'fullTime')} می‌باشد` : 'ساعت را انتخاب کنید', fieldClearLabel: 'پاک کردن مقدار', diff --git a/packages/x-date-pickers/src/locales/fiFI.ts b/packages/x-date-pickers/src/locales/fiFI.ts index 0b2c5772db2c0..a72dc6e322174 100644 --- a/packages/x-date-pickers/src/locales/fiFI.ts +++ b/packages/x-date-pickers/src/locales/fiFI.ts @@ -59,13 +59,13 @@ const fiFIPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Valitse päivä, valittu päivä on ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Valitse päivä, valittu päivä on ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Valitse päivä', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Valitse aika, valittu aika on ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Valitse aika, valittu aika on ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Valitse aika', fieldClearLabel: 'Tyhjennä arvo', diff --git a/packages/x-date-pickers/src/locales/frFR.ts b/packages/x-date-pickers/src/locales/frFR.ts index 05c5e3efe89bf..8af0cc7422f5e 100644 --- a/packages/x-date-pickers/src/locales/frFR.ts +++ b/packages/x-date-pickers/src/locales/frFR.ts @@ -59,13 +59,13 @@ const frFRPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Choisir la date, la date sélectionnée est ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Choisir la date, la date sélectionnée est ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Choisir la date', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Choisir l'heure, l'heure sélectionnée est ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, formattedTime) => + formattedTime + ? `Choisir l'heure, l'heure sélectionnée est ${formattedTime ?? utils.format(value, 'fullTime')}` : "Choisir l'heure", fieldClearLabel: 'Effacer la valeur', diff --git a/packages/x-date-pickers/src/locales/heIL.ts b/packages/x-date-pickers/src/locales/heIL.ts index cb588abaf3494..04e1cb85cb231 100644 --- a/packages/x-date-pickers/src/locales/heIL.ts +++ b/packages/x-date-pickers/src/locales/heIL.ts @@ -59,13 +59,13 @@ const heILPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `בחירת תאריך, התאריך שנבחר הוא ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `בחירת תאריך, התאריך שנבחר הוא ${formattedDate ?? utils.format(value, 'fullDate')}` : 'בחירת תאריך', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `בחירת שעה, השעה שנבחרה היא ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `בחירת שעה, השעה שנבחרה היא ${formattedTime ?? utils.format(value, 'fullTime')}` : 'בחירת שעה', fieldClearLabel: 'נקה ערך', diff --git a/packages/x-date-pickers/src/locales/huHU.ts b/packages/x-date-pickers/src/locales/huHU.ts index 2738f681e3c74..fd554647d979d 100644 --- a/packages/x-date-pickers/src/locales/huHU.ts +++ b/packages/x-date-pickers/src/locales/huHU.ts @@ -60,13 +60,13 @@ const huHUPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Válasszon dátumot, a kiválasztott dátum: ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Válasszon dátumot, a kiválasztott dátum: ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Válasszon dátumot', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Válasszon időt, a kiválasztott idő: ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Válasszon időt, a kiválasztott idő: ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Válasszon időt', fieldClearLabel: 'Tartalom ürítése', diff --git a/packages/x-date-pickers/src/locales/isIS.ts b/packages/x-date-pickers/src/locales/isIS.ts index 9e6be431be086..2313daf7ffcde 100644 --- a/packages/x-date-pickers/src/locales/isIS.ts +++ b/packages/x-date-pickers/src/locales/isIS.ts @@ -59,13 +59,13 @@ const isISPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Velja dagsetningu, valin dagsetning er ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Velja dagsetningu, valin dagsetning er ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Velja dagsetningu', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Velja tíma, valinn tími er ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Velja tíma, valinn tími er ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Velja tíma', // fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/itIT.ts b/packages/x-date-pickers/src/locales/itIT.ts index 46e19c0b96b1e..6cee47294cd29 100644 --- a/packages/x-date-pickers/src/locales/itIT.ts +++ b/packages/x-date-pickers/src/locales/itIT.ts @@ -59,13 +59,13 @@ const itITPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Scegli la data, la data selezionata è ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Scegli la data, la data selezionata è ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Scegli la data', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Scegli l'ora, l'ora selezionata è ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Scegli l'ora, l'ora selezionata è ${formattedTime ?? utils.format(value, 'fullTime')}` : "Scegli l'ora", fieldClearLabel: 'Cancella valore', diff --git a/packages/x-date-pickers/src/locales/jaJP.ts b/packages/x-date-pickers/src/locales/jaJP.ts index 6220e261c23ba..10b6816c3cd8c 100644 --- a/packages/x-date-pickers/src/locales/jaJP.ts +++ b/packages/x-date-pickers/src/locales/jaJP.ts @@ -60,13 +60,13 @@ const jaJPPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `日付を選択してください。選択した日付は ${utils.format(value, 'fullDate')} です` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `日付を選択してください。選択した日付は ${formattedDate ?? utils.format(value, 'fullDate')} です` : '日付を選択してください', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `時間を選択してください。選択した時間は ${utils.format(value, 'fullTime')} です` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `時間を選択してください。選択した時間は ${formattedTime ?? utils.format(value, 'fullTime')} です` : '時間を選択してください', fieldClearLabel: 'クリア', diff --git a/packages/x-date-pickers/src/locales/koKR.ts b/packages/x-date-pickers/src/locales/koKR.ts index c298cc71010ba..f0a7fdd3d938e 100644 --- a/packages/x-date-pickers/src/locales/koKR.ts +++ b/packages/x-date-pickers/src/locales/koKR.ts @@ -59,13 +59,13 @@ const koKRPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `날짜를 선택하세요. 현재 선택된 날짜는 ${utils.format(value, 'fullDate')}입니다.` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `날짜를 선택하세요. 현재 선택된 날짜는 ${formattedDate ?? utils.format(value, 'fullDate')}입니다.` : '날짜를 선택하세요', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `시간을 선택하세요. 현재 선택된 시간은 ${utils.format(value, 'fullTime')}입니다.` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `시간을 선택하세요. 현재 선택된 시간은 ${formattedTime ?? utils.format(value, 'fullTime')}입니다.` : '시간을 선택하세요', fieldClearLabel: '지우기', diff --git a/packages/x-date-pickers/src/locales/kzKZ.ts b/packages/x-date-pickers/src/locales/kzKZ.ts index eefb19d00bf71..46a95c39dae5c 100644 --- a/packages/x-date-pickers/src/locales/kzKZ.ts +++ b/packages/x-date-pickers/src/locales/kzKZ.ts @@ -60,13 +60,13 @@ const kzKZPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Күнді таңдаңыз, таңдалған күн ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Күнді таңдаңыз, таңдалған күн ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Күнді таңдаңыз', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Уақытты таңдаңыз, таңдалған уақыт ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Уақытты таңдаңыз, таңдалған уақыт ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Уақытты таңдаңыз', // fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/mk.ts b/packages/x-date-pickers/src/locales/mk.ts index 1a7eca9c3d21f..27aff8961d5d9 100644 --- a/packages/x-date-pickers/src/locales/mk.ts +++ b/packages/x-date-pickers/src/locales/mk.ts @@ -53,13 +53,13 @@ const mkPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Избери датум, избраниот датум е ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Избери датум, избраниот датум е ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Избери датум', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Избери време, избраното време е ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Избери време, избраното време е ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Избери време', fieldClearLabel: 'Избриши', diff --git a/packages/x-date-pickers/src/locales/nbNO.ts b/packages/x-date-pickers/src/locales/nbNO.ts index 3ac5c0e73bbb9..7874b8af299a8 100644 --- a/packages/x-date-pickers/src/locales/nbNO.ts +++ b/packages/x-date-pickers/src/locales/nbNO.ts @@ -59,13 +59,13 @@ const nbNOPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Velg dato, valgt dato er ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Velg dato, valgt dato er ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Velg dato', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Velg tid, valgt tid er ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Velg tid, valgt tid er ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Velg tid', // fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/nlNL.ts b/packages/x-date-pickers/src/locales/nlNL.ts index d1caa93adba3b..026ad2a72ace9 100644 --- a/packages/x-date-pickers/src/locales/nlNL.ts +++ b/packages/x-date-pickers/src/locales/nlNL.ts @@ -59,13 +59,13 @@ const nlNLPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Kies datum, geselecteerde datum is ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Kies datum, geselecteerde datum is ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Kies datum', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Kies tijd, geselecteerde tijd is ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Kies tijd, geselecteerde tijd is ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Kies tijd', fieldClearLabel: 'Wissen', diff --git a/packages/x-date-pickers/src/locales/nnNO.ts b/packages/x-date-pickers/src/locales/nnNO.ts index 8603b926a464f..52f71cf1a6d9a 100644 --- a/packages/x-date-pickers/src/locales/nnNO.ts +++ b/packages/x-date-pickers/src/locales/nnNO.ts @@ -59,13 +59,13 @@ const nnNOPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Vel dato, vald dato er ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Vel dato, vald dato er ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Vel dato', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Vel tid, vald tid er ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Vel tid, vald tid er ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Vel tid', fieldClearLabel: 'Fjern verdi', diff --git a/packages/x-date-pickers/src/locales/plPL.ts b/packages/x-date-pickers/src/locales/plPL.ts index c338bbaee0885..9f91aaf6ca4dd 100644 --- a/packages/x-date-pickers/src/locales/plPL.ts +++ b/packages/x-date-pickers/src/locales/plPL.ts @@ -59,13 +59,13 @@ const plPLPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => + openDatePickerDialogue: (value, utils, formattedDate) => value != null && utils.isValid(value) - ? `Wybierz datę, obecnie wybrana data to ${utils.format(value, 'fullDate')}` + ? `Wybierz datę, obecnie wybrana data to ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Wybierz datę', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Wybierz czas, obecnie wybrany czas to ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Wybierz czas, obecnie wybrany czas to ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Wybierz czas', // fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/ptBR.ts b/packages/x-date-pickers/src/locales/ptBR.ts index 0e6385db76286..bb6b3c6e53c39 100644 --- a/packages/x-date-pickers/src/locales/ptBR.ts +++ b/packages/x-date-pickers/src/locales/ptBR.ts @@ -59,13 +59,13 @@ const ptBRPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Escolha uma data, data selecionada ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Escolha uma data, data selecionada ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Escolha uma data', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Escolha uma hora, hora selecionada ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Escolha uma hora, hora selecionada ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Escolha uma hora', // fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/roRO.ts b/packages/x-date-pickers/src/locales/roRO.ts index 1b84639c2b9d0..52fc7f29636d7 100644 --- a/packages/x-date-pickers/src/locales/roRO.ts +++ b/packages/x-date-pickers/src/locales/roRO.ts @@ -60,13 +60,13 @@ const roROPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Selectați data, data selectată este ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Selectați data, data selectată este ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Selectați data', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Selectați ora, ora selectată este ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Selectați ora, ora selectată este ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Selectați ora', fieldClearLabel: 'Golire conținut', diff --git a/packages/x-date-pickers/src/locales/ruRU.ts b/packages/x-date-pickers/src/locales/ruRU.ts index c91b2a4a594ee..a2185b970493c 100644 --- a/packages/x-date-pickers/src/locales/ruRU.ts +++ b/packages/x-date-pickers/src/locales/ruRU.ts @@ -60,13 +60,13 @@ const ruRUPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Выберите дату, выбрана дата ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Выберите дату, выбрана дата ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Выберите дату', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Выберите время, выбрано время ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Выберите время, выбрано время ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Выберите время', fieldClearLabel: 'Очистить значение', diff --git a/packages/x-date-pickers/src/locales/skSK.ts b/packages/x-date-pickers/src/locales/skSK.ts index 65bec28a01169..d970b833cae8d 100644 --- a/packages/x-date-pickers/src/locales/skSK.ts +++ b/packages/x-date-pickers/src/locales/skSK.ts @@ -60,13 +60,13 @@ const skSKPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Vyberte dátum, vybraný dátum je ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Vyberte dátum, vybraný dátum je ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Vyberte dátum', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Vyberte čas, vybraný čas je ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Vyberte čas, vybraný čas je ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Vyberte čas', // fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/svSE.ts b/packages/x-date-pickers/src/locales/svSE.ts index f2a8465c30e88..13d38404d7c69 100644 --- a/packages/x-date-pickers/src/locales/svSE.ts +++ b/packages/x-date-pickers/src/locales/svSE.ts @@ -59,13 +59,13 @@ const svSEPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Välj datum, valt datum är ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Välj datum, valt datum är ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Välj datum', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Välj tid, vald tid är ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Välj tid, vald tid är ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Välj tid', fieldClearLabel: 'Rensa värde', diff --git a/packages/x-date-pickers/src/locales/trTR.ts b/packages/x-date-pickers/src/locales/trTR.ts index c2335b0677fd7..0353b1f535e8b 100644 --- a/packages/x-date-pickers/src/locales/trTR.ts +++ b/packages/x-date-pickers/src/locales/trTR.ts @@ -59,13 +59,13 @@ const trTRPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Tarih seçin, seçilen tarih: ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Tarih seçin, seçilen tarih: ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Tarih seç', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Saat seçin, seçilen saat: ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Saat seçin, seçilen saat: ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Saat seç', // fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/ukUA.ts b/packages/x-date-pickers/src/locales/ukUA.ts index 2742d5dad70a1..d37aec89ec198 100644 --- a/packages/x-date-pickers/src/locales/ukUA.ts +++ b/packages/x-date-pickers/src/locales/ukUA.ts @@ -59,13 +59,13 @@ const ukUAPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Оберіть дату, обрана дата ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Оберіть дату, обрана дата ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Оберіть дату', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Оберіть час, обраний час ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Оберіть час, обраний час ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Оберіть час', fieldClearLabel: 'Очистити дані', diff --git a/packages/x-date-pickers/src/locales/urPK.ts b/packages/x-date-pickers/src/locales/urPK.ts index 125bd4fafbb9c..12835bbe400de 100644 --- a/packages/x-date-pickers/src/locales/urPK.ts +++ b/packages/x-date-pickers/src/locales/urPK.ts @@ -59,13 +59,13 @@ const urPKPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `تاریخ منتخب کریں، منتخب شدہ تاریخ ہے ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `تاریخ منتخب کریں، منتخب شدہ تاریخ ہے ${formattedDate ?? utils.format(value, 'fullDate')}` : 'تاریخ منتخب کریں', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `وقت منتخب کریں، منتخب شدہ وقت ہے ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `وقت منتخب کریں، منتخب شدہ وقت ہے ${formattedTime ?? utils.format(value, 'fullTime')}` : 'وقت منتخب کریں', // fieldClearLabel: 'Clear value', diff --git a/packages/x-date-pickers/src/locales/utils/getPickersLocalization.ts b/packages/x-date-pickers/src/locales/utils/getPickersLocalization.ts index 34b925b3773e9..89531125bea6e 100644 --- a/packages/x-date-pickers/src/locales/utils/getPickersLocalization.ts +++ b/packages/x-date-pickers/src/locales/utils/getPickersLocalization.ts @@ -1,3 +1,4 @@ +import { AdapterFormats, MuiPickersAdapter, PickerValidDate } from '../../models'; import { PickersLocaleText } from './pickersLocaleTextApi'; export const getPickersLocalization = (pickersTranslations: Partial>) => { @@ -11,3 +12,28 @@ export const getPickersLocalization = (pickersTranslations: Partial(params: { + utils: MuiPickersAdapter; + formatKey: keyof AdapterFormats; + contextTranslation: ( + date: TDate | null, + utils: MuiPickersAdapter, + formattedValue: string | null, + ) => string; + propsTranslation: ( + date: TDate | null, + utils: MuiPickersAdapter, + formattedValue: string | null, + ) => string; +}) => { + const { utils, formatKey, contextTranslation, propsTranslation } = params; + + return (value: TDate | null) => { + const formattedValue = + value !== null && utils.isValid(value) ? utils.formatByString(value, formatKey) : null; + const translation = propsTranslation ?? contextTranslation; + + return translation(value, utils, formattedValue); + }; +}; diff --git a/packages/x-date-pickers/src/locales/utils/pickersLocaleTextApi.ts b/packages/x-date-pickers/src/locales/utils/pickersLocaleTextApi.ts index 9b6d77349cc8e..075013b75c61b 100644 --- a/packages/x-date-pickers/src/locales/utils/pickersLocaleTextApi.ts +++ b/packages/x-date-pickers/src/locales/utils/pickersLocaleTextApi.ts @@ -70,8 +70,28 @@ export interface PickersComponentAgnosticLocaleText string; // Open picker labels - openDatePickerDialogue: (date: TDate | null, utils: MuiPickersAdapter) => string; - openTimePickerDialogue: (date: TDate | null, utils: MuiPickersAdapter) => string; + openDatePickerDialogue: ( + /** + * @deprecated Use `formattedTime` instead + */ + date: TDate | null, + /** + * @deprecated Use `formattedTime` instead + */ + utils: MuiPickersAdapter, + formattedDate: string | null, + ) => string; + openTimePickerDialogue: ( + /** + * @deprecated Use `formattedTime` instead + */ + date: TDate | null, + /** + * @deprecated Use `formattedTime` instead + */ + utils: MuiPickersAdapter, + formattedTime: string | null, + ) => string; // Clear button label fieldClearLabel: string; diff --git a/packages/x-date-pickers/src/locales/viVN.ts b/packages/x-date-pickers/src/locales/viVN.ts index 6e269490c20a0..cc4669935bcf0 100644 --- a/packages/x-date-pickers/src/locales/viVN.ts +++ b/packages/x-date-pickers/src/locales/viVN.ts @@ -59,13 +59,13 @@ const viVNPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Chọn ngày, ngày đã chọn là ${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `Chọn ngày, ngày đã chọn là ${formattedDate ?? utils.format(value, 'fullDate')}` : 'Chọn ngày', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `Chọn giờ, giờ đã chọn là ${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `Chọn giờ, giờ đã chọn là ${formattedTime ?? utils.format(value, 'fullTime')}` : 'Chọn giờ', fieldClearLabel: 'Xóa giá trị', diff --git a/packages/x-date-pickers/src/locales/zhCN.ts b/packages/x-date-pickers/src/locales/zhCN.ts index d105f8fa52631..24d596781670b 100644 --- a/packages/x-date-pickers/src/locales/zhCN.ts +++ b/packages/x-date-pickers/src/locales/zhCN.ts @@ -57,13 +57,13 @@ const zhCNPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `选择日期,已选择${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `选择日期,已选择${formattedDate ?? utils.format(value, 'fullDate')}` : '选择日期', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `选择时间,已选择${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `选择时间,已选择${formattedTime ?? utils.format(value, 'fullTime')}` : '选择时间', fieldClearLabel: '清除', diff --git a/packages/x-date-pickers/src/locales/zhHK.ts b/packages/x-date-pickers/src/locales/zhHK.ts index 9fb72b4769c59..4a484876acd71 100644 --- a/packages/x-date-pickers/src/locales/zhHK.ts +++ b/packages/x-date-pickers/src/locales/zhHK.ts @@ -57,13 +57,13 @@ const zhHKPickers: Partial> = { calendarWeekNumberText: (weekNumber) => `${weekNumber}`, // Open picker labels - openDatePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `選擇日期,已選擇${utils.format(value, 'fullDate')}` + openDatePickerDialogue: (value, utils, formattedDate) => + formattedDate || (value !== null && utils.isValid(value)) + ? `選擇日期,已選擇${formattedDate ?? utils.format(value, 'fullDate')}` : '選擇日期', - openTimePickerDialogue: (value, utils) => - value !== null && utils.isValid(value) - ? `選擇時間,已選擇${utils.format(value, 'fullTime')}` + openTimePickerDialogue: (value, utils, formattedTime) => + formattedTime || (value !== null && utils.isValid(value)) + ? `選擇時間,已選擇${formattedTime ?? utils.format(value, 'fullTime')}` : '選擇時間', fieldClearLabel: '清除',