/
githubmirror
/
ionic
Обзор
Документация
Войти
/
githubmirror
/
ionic
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
core/src/components/input/input.utils.ts
34 строки
979 B
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 { printIonError } from '@utils/logging'; export const getCounterText = ( value: string | number | null | undefined, maxLength: number, counterFormatter?: (inputLength: number, maxLength: number) => string ) => { const valueLength = value == null ? 0 : value.toString().length; const defaultCounterText = defaultCounterFormatter(valueLength, maxLength); /** * If developers did not pass a custom formatter, * use the default one. */ if (counterFormatter === undefined) { return defaultCounterText; } /** * Otherwise, try to use the custom formatter * and fallback to the default formatter if * there was an error. */ try { return counterFormatter(valueLength, maxLength); } catch (e) { printIonError('[ion-input] - Exception in provided `counterFormatter`:', e); return defaultCounterText; } }; const defaultCounterFormatter = (length: number, maxlength: number) => { return `${length} / ${maxlength}`; };