/
githubmirror
/
ionic
Обзор
Документация
Войти
/
githubmirror
/
ionic
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
core/src/components/datetime/utils/validate.ts
57 строк
2 KB
Brandy Smith
fix(config): allow LogLevel to work with isolatedModules and update all warns and errors to respect logLevel (#30350)
16 апр 2025, 19:23
Не верифицирован
16 апр 2025, 19:23
d52fca0
Код
Авторство
О чём код?
import { printIonWarning } from '@utils/logging'; import type { DatetimePresentation, FormatOptions } from '../datetime-interface'; /** * If a time zone is provided in the format options, the rendered text could * differ from what was selected in the Datetime, which could cause * confusion. */ export const warnIfTimeZoneProvided = (el: HTMLElement, formatOptions?: FormatOptions) => { if ( formatOptions?.date?.timeZone || formatOptions?.date?.timeZoneName || formatOptions?.time?.timeZone || formatOptions?.time?.timeZoneName ) { printIonWarning('[ion-datetime] - "timeZone" and "timeZoneName" are not supported in "formatOptions".', el); } }; export const checkForPresentationFormatMismatch = ( el: HTMLElement, presentation: DatetimePresentation, formatOptions?: FormatOptions ) => { // formatOptions is not required if (!formatOptions) return; // If formatOptions is provided, the date and/or time objects are required, depending on the presentation switch (presentation) { case 'date': case 'month-year': case 'month': case 'year': if (formatOptions.date === undefined) { printIonWarning( `[ion-datetime] - The '${presentation}' presentation requires a date object in formatOptions.`, el ); } break; case 'time': if (formatOptions.time === undefined) { printIonWarning(`[ion-datetime] - The 'time' presentation requires a time object in formatOptions.`, el); } break; case 'date-time': case 'time-date': if (formatOptions.date === undefined && formatOptions.time === undefined) { printIonWarning( `[ion-datetime] - The '${presentation}' presentation requires either a date or time object (or both) in formatOptions.`, el ); } break; } };