@samline/date 2.1.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/vue/index.ts","../../src/core/date.ts","../../src/core/locales.ts"],"sourcesContent":["import { computed, ref } from 'vue'\n\nimport {\n createDateFormatter,\n getSupportedLocales,\n type DateFormatterConfig,\n type DateParsingOptions,\n type GetDateOptions,\n type LocaleInput,\n type SupportedLocale\n} from '../index.js'\n\nexport type UseDateFormatterOptions = DateFormatterConfig\n\nexport const useDateFormatter = (options?: UseDateFormatterOptions) => {\n const formatter = createDateFormatter(options)\n const locale = ref<SupportedLocale>(formatter.getCurrentLocale())\n\n const setLocale = async (nextLocale: LocaleInput) => {\n await formatter.setLocale(nextLocale)\n locale.value = formatter.getCurrentLocale()\n }\n\n return {\n locale,\n currentLocale: computed(() => locale.value),\n getDate: (props?: GetDateOptions) => formatter.getDate(props),\n parseDate: (props: DateParsingOptions) => formatter.parseDate(props),\n isValidDate: (props: DateParsingOptions) => formatter.isValidDate(props),\n getSupportedLocales,\n ready: formatter.ready,\n setLocale\n }\n}\n","import customParseFormat from 'dayjs/plugin/customParseFormat.js'\nimport dayjs from 'dayjs'\nimport type { Dayjs } from 'dayjs'\n\nimport { ensureLocaleLoaded, resolveLocale, SUPPORTED_LOCALES, type LocaleInput, type SupportedLocale } from './locales.js'\n\ndayjs.extend(customParseFormat)\ndayjs.locale('en')\n\nexport type DateValue = string | number | Date\n\ntype DateInputOptions = {\n input?: string | readonly string[]\n locale?: LocaleInput\n strict?: boolean\n}\n\nexport type DateParsingOptions = DateInputOptions & {\n date: DateValue\n}\n\nexport type GetDateOptions = DateInputOptions & {\n date?: DateValue\n output?: string\n invalid?: string\n}\n\nexport type DateFormatterConfig = {\n locale?: LocaleInput\n strict?: boolean\n invalid?: string\n}\n\ntype ResolvedDateFormatterConfig = {\n locale: SupportedLocale\n strict: boolean\n invalid: string\n}\n\nexport type DateFormatter = {\n getDate: (props?: GetDateOptions) => string\n parseDate: (props: DateParsingOptions) => ParseDateResult\n isValidDate: (props: DateParsingOptions) => boolean\n getSupportedLocales: () => readonly SupportedLocale[]\n getCurrentLocale: () => SupportedLocale\n setLocale: (locale: LocaleInput) => Promise<void>\n ready: Promise<void>\n}\n\nexport type ParseDateSuccess = {\n isValid: true\n locale: SupportedLocale\n date: Date\n iso: string\n timestamp: number\n format: (output?: string) => string\n}\n\nexport type ParseDateFailure = {\n isValid: false\n locale: SupportedLocale\n date: null\n iso: null\n timestamp: null\n error: string\n}\n\nexport type ParseDateResult = ParseDateSuccess | ParseDateFailure\n\nconst DEFAULT_FORMAT = 'YYYY-MM-DD'\nconst DEFAULT_LOCALE: SupportedLocale = 'en'\nconst DEFAULT_INVALID_DATE = 'Invalid Date'\nconst DEFAULT_STRICT = true\n\nconst createResolvedConfig = (\n locale: SupportedLocale,\n config?: DateFormatterConfig\n): ResolvedDateFormatterConfig => ({\n locale,\n strict: config?.strict ?? DEFAULT_STRICT,\n invalid: config?.invalid ?? DEFAULT_INVALID_DATE\n})\n\nconst getInvalidDateText = (config?: DateFormatterConfig, props?: GetDateOptions): string => {\n return props?.invalid ?? config?.invalid ?? DEFAULT_INVALID_DATE\n}\n\nconst getTargetLocale = (currentLocale: SupportedLocale, props?: GetDateOptions): SupportedLocale => {\n if (!props?.locale) {\n return currentLocale\n }\n\n return resolveLocaleOrThrow(props.locale)\n}\n\nconst getHelperLocale = <T extends { locale?: LocaleInput }>(\n config?: DateFormatterConfig,\n props?: T\n): SupportedLocale => {\n if (props?.locale) {\n return resolveLocaleOrThrow(props.locale)\n }\n\n if (config?.locale) {\n return resolveLocaleOrThrow(config.locale)\n }\n\n return DEFAULT_LOCALE\n}\n\nconst parseDateValue = (\n value: DateValue,\n input: DateParsingOptions['input'],\n locale: SupportedLocale,\n strict: boolean\n): Dayjs => {\n if (!input) {\n return dayjs(value).locale(locale)\n }\n\n if (typeof input === 'string') {\n return dayjs(value, input, locale, strict).locale(locale)\n }\n\n return dayjs(value, [...input], locale, strict).locale(locale)\n}\n\nconst createFormatterParseDate = (getConfig: () => ResolvedDateFormatterConfig) => {\n return (props: DateParsingOptions): ParseDateResult => {\n const config = getConfig()\n const locale = getTargetLocale(config.locale, props)\n const parsed = parseDateValue(props.date, props.input, locale, props.strict ?? config.strict)\n\n if (!parsed.isValid()) {\n return {\n isValid: false,\n locale,\n date: null,\n iso: null,\n timestamp: null,\n error: getInvalidDateText(config, props)\n }\n }\n\n return {\n isValid: true,\n locale,\n date: parsed.toDate(),\n iso: parsed.toISOString(),\n timestamp: parsed.valueOf(),\n format: (output = DEFAULT_FORMAT) => parsed.format(output)\n }\n }\n}\n\nconst createFormatterIsValidDate = (parseDate: (props: DateParsingOptions) => ParseDateResult) => {\n return (props: DateParsingOptions): boolean => parseDate(props).isValid\n}\n\nconst createFormatterGetDate = (getConfig: () => ResolvedDateFormatterConfig) => {\n const parseDate = createFormatterParseDate(getConfig)\n\n return (props?: GetDateOptions): string => {\n const config = getConfig()\n const locale = getTargetLocale(config.locale, props)\n const output = props?.output ?? DEFAULT_FORMAT\n\n if (!props) {\n return dayjs().locale(locale).format(DEFAULT_FORMAT)\n }\n\n if (props.date === undefined) {\n return dayjs().locale(locale).format(output)\n }\n\n const parsed = parseDate({\n date: props.date,\n input: props.input,\n locale: props.locale,\n strict: props.strict\n })\n\n if (!parsed.isValid) {\n return props.invalid ?? parsed.error\n }\n\n return parsed.format(output)\n }\n}\n\nfunction resolveLocaleOrThrow(locale: LocaleInput): SupportedLocale {\n const resolvedLocale = resolveLocale(locale)\n\n if (!resolvedLocale) {\n throw new Error(\n `Unsupported locale: ${locale}. The package tries an exact locale match first and then falls back to the base locale.`\n )\n }\n\n return resolvedLocale\n}\n\nexport const getSupportedLocales = (): readonly SupportedLocale[] => SUPPORTED_LOCALES\n\nexport const getDate = async (props?: GetDateOptions, config?: DateFormatterConfig): Promise<string> => {\n const locale = getHelperLocale(config, props)\n const formatter = createDateFormatter({ ...config, locale })\n\n await formatter.ready\n\n return formatter.getDate(props)\n}\n\nexport const parseDate = async (\n props: DateParsingOptions,\n config?: DateFormatterConfig\n): Promise<ParseDateResult> => {\n const locale = getHelperLocale(config, props)\n const formatter = createDateFormatter({ ...config, locale })\n\n await formatter.ready\n\n return formatter.parseDate(props)\n}\n\nexport const isValidDate = async (\n props: DateParsingOptions,\n config?: DateFormatterConfig\n): Promise<boolean> => {\n const locale = getHelperLocale(config, props)\n const formatter = createDateFormatter({ ...config, locale })\n\n await formatter.ready\n\n return formatter.isValidDate(props)\n}\n\nexport const createDateFormatter = (config?: DateFormatterConfig): DateFormatter => {\n let currentLocale = config?.locale ? resolveLocaleOrThrow(config.locale) : DEFAULT_LOCALE\n\n const getConfig = (): ResolvedDateFormatterConfig => createResolvedConfig(currentLocale, config)\n\n const ready = ensureLocaleLoaded(currentLocale)\n const parseDate = createFormatterParseDate(getConfig)\n\n return {\n getDate: createFormatterGetDate(getConfig),\n parseDate,\n isValidDate: createFormatterIsValidDate(parseDate),\n getSupportedLocales,\n getCurrentLocale: () => currentLocale,\n setLocale: async (locale: LocaleInput) => {\n const resolvedLocale = resolveLocaleOrThrow(locale)\n\n await ensureLocaleLoaded(resolvedLocale)\n currentLocale = resolvedLocale\n },\n ready\n }\n}\n","export const SUPPORTED_LOCALES = [\n 'en',\n 'es',\n 'es-mx',\n 'fr',\n 'pt',\n 'pt-br',\n 'de',\n 'it',\n 'ja'\n] as const\n\nexport type SupportedLocale = (typeof SUPPORTED_LOCALES)[number]\nexport type LocaleInput = string\n\nconst loadedLocales = new Set<SupportedLocale>(['en'])\n\nconst localeLoaders: Record<SupportedLocale, (() => Promise<unknown>) | null> = {\n en: null,\n es: () => import('dayjs/locale/es.js'),\n 'es-mx': () => import('dayjs/locale/es-mx.js'),\n fr: () => import('dayjs/locale/fr.js'),\n pt: () => import('dayjs/locale/pt.js'),\n 'pt-br': () => import('dayjs/locale/pt-br.js'),\n de: () => import('dayjs/locale/de.js'),\n it: () => import('dayjs/locale/it.js'),\n ja: () => import('dayjs/locale/ja.js')\n}\n\nconst normalizeLocale = (locale: string): string => {\n return locale.trim().toLowerCase().replace(/_/g, '-')\n}\n\nconst asSupportedLocale = (locale: string): SupportedLocale | null => {\n if (!SUPPORTED_LOCALES.includes(locale as SupportedLocale)) {\n return null\n }\n\n return locale as SupportedLocale\n}\n\nexport const isSupportedLocale = (locale: string): boolean => {\n return resolveLocale(locale) !== null\n}\n\nexport const resolveLocale = (locale: LocaleInput): SupportedLocale | null => {\n const normalizedLocale = normalizeLocale(locale)\n const exactLocale = asSupportedLocale(normalizedLocale)\n\n if (exactLocale) {\n return exactLocale\n }\n\n const [baseLocale] = normalizedLocale.split('-')\n\n if (!baseLocale) {\n return null\n }\n\n return asSupportedLocale(baseLocale)\n}\n\nexport const markLocaleAsLoaded = (locale: SupportedLocale): void => {\n loadedLocales.add(locale)\n}\n\nexport const ensureLocaleLoaded = async (locale: SupportedLocale): Promise<void> => {\n if (loadedLocales.has(locale)) {\n return\n }\n\n const load = localeLoaders[locale]\n\n if (!load) {\n loadedLocales.add(locale)\n return\n }\n\n await load()\n loadedLocales.add(locale)\n}\n"],"mappings":";AAAA,SAAS,UAAU,WAAW;;;ACA9B,OAAO,uBAAuB;AAC9B,OAAO,WAAW;;;ACDX,IAAM,oBAAoB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKA,IAAM,gBAAgB,oBAAI,IAAqB,CAAC,IAAI,CAAC;AAErD,IAAM,gBAA0E;AAAA,EAC9E,IAAI;AAAA,EACJ,IAAI,MAAM,OAAO,oBAAoB;AAAA,EACrC,SAAS,MAAM,OAAO,uBAAuB;AAAA,EAC7C,IAAI,MAAM,OAAO,oBAAoB;AAAA,EACrC,IAAI,MAAM,OAAO,oBAAoB;AAAA,EACrC,SAAS,MAAM,OAAO,uBAAuB;AAAA,EA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BAAmB,CAAC,YAAsC;AACrE,QAAM,YAAY,oBAAoB,OAAO;AAC7C,QAAM,SAAS,IAAqB,UAAU,iBAAiB,CAAC;AAEhE,QAAM,YAAY,OAAO,eAA4B;AACnD,UAAM,UAAU,UAAU,UAAU;AACpC,WAAO,QAAQ,UAAU,iBAAiB;AAAA,EAC5C;AAEA,SAAO;AAAA,IACL;AAAA,IACA,eAAe,SAAS,MAAM,OAAO,KAAK;AAAA,IAC1C,SAAS,CAAC,UAA2B,UAAU,QAAQ,KAAK;AAAA,IAC5D,WAAW,CAAC,UAA8B,UAAU,UAAU,KAAK;AAAA,IACnE,aAAa,CAAC,UAA8B,UAAU,YAAY,KAAK;AAAA,IACvE;AAAA,IACA,OAAO,UAAU;AAAA,IACjB;AAAA,EACF;AACF;","names":["parseDate","parseDate"]}
1
+ {"version":3,"sources":["../../src/vue/index.ts","../../src/core/date.ts","../../src/core/locales.ts"],"sourcesContent":["import { computed, ref } from 'vue'\n\nimport {\n createDateFormatter,\n getSupportedLocales,\n type CreateDateChainOptions,\n type DateChain,\n type DateFormatterConfig,\n type DateParsingOptions,\n type GetDateOptions,\n type LocaleInput,\n type SupportedLocale\n} from '../index.js'\n\nexport type UseDateFormatterOptions = DateFormatterConfig\n\nexport const useDateFormatter = (options?: UseDateFormatterOptions) => {\n const formatter = createDateFormatter(options)\n const locale = ref<SupportedLocale>(formatter.getCurrentLocale())\n\n const setLocale = async (nextLocale: LocaleInput) => {\n await formatter.setLocale(nextLocale)\n locale.value = formatter.getCurrentLocale()\n }\n\n return {\n locale,\n currentLocale: computed(() => locale.value),\n createDateChain: (props?: CreateDateChainOptions): DateChain => formatter.createDateChain(props),\n getDate: (props?: GetDateOptions) => formatter.getDate(props),\n parseDate: (props: DateParsingOptions) => formatter.parseDate(props),\n isValidDate: (props: DateParsingOptions) => formatter.isValidDate(props),\n getSupportedLocales,\n ready: formatter.ready,\n setLocale\n }\n}\n","import customParseFormat from 'dayjs/plugin/customParseFormat.js'\nimport dayjs from 'dayjs'\nimport type { Dayjs } from 'dayjs'\n\nimport {\n ensureLocaleLoaded,\n isLocaleLoaded,\n resolveLocale,\n SUPPORTED_LOCALES,\n type LocaleInput,\n type SupportedLocale\n} from './locales.js'\n\ndayjs.extend(customParseFormat)\ndayjs.locale('en')\n\nexport type DateValue = string | number | Date\n\ntype DateInputOptions = {\n input?: string | readonly string[]\n locale?: LocaleInput\n strict?: boolean\n}\n\nexport type DateParsingOptions = DateInputOptions & {\n date: DateValue\n}\n\nexport type GetDateOptions = DateInputOptions & {\n date?: DateValue\n output?: string\n invalid?: string\n}\n\nexport type CreateDateChainOptions = DateInputOptions & {\n date?: DateValue\n invalid?: string\n}\n\nexport type DateFormatterConfig = {\n locale?: LocaleInput\n strict?: boolean\n invalid?: string\n}\n\nexport type DateChainManipulateUnit =\n | 'millisecond'\n | 'second'\n | 'minute'\n | 'hour'\n | 'day'\n | 'week'\n | 'month'\n | 'year'\n\nexport type DateChainBoundaryUnit =\n | 'year'\n | 'month'\n | 'week'\n | 'day'\n | 'hour'\n | 'minute'\n | 'second'\n\nexport type DateChainCompareUnit = DateChainBoundaryUnit | 'millisecond'\n\nexport type DateChainSetUnit =\n | 'year'\n | 'month'\n | 'day'\n | 'hour'\n | 'minute'\n | 'second'\n | 'millisecond'\n\ntype ResolvedDateFormatterConfig = {\n locale: SupportedLocale\n strict: boolean\n invalid: string\n}\n\nexport type DateChainSuccessState = {\n isValid: true\n locale: SupportedLocale\n date: Date\n iso: string\n timestamp: number\n}\n\nexport type DateChainFailureState = {\n isValid: false\n locale: SupportedLocale\n date: null\n iso: null\n timestamp: null\n error: string\n}\n\nexport type DateChainState = DateChainSuccessState | DateChainFailureState\n\nexport type DateChain = {\n ready: Promise<void>\n add: (value: number, unit: DateChainManipulateUnit) => DateChain\n subtract: (value: number, unit: DateChainManipulateUnit) => DateChain\n set: (unit: DateChainSetUnit, value: number) => DateChain\n startOf: (unit: DateChainBoundaryUnit) => DateChain\n endOf: (unit: DateChainBoundaryUnit) => DateChain\n format: (output?: string) => string\n toDate: () => Date | null\n toISOString: () => string | null\n toTimestamp: () => number | null\n isValid: () => boolean\n isBefore: (other: DateChainComparable, unit?: DateChainCompareUnit) => boolean\n isAfter: (other: DateChainComparable, unit?: DateChainCompareUnit) => boolean\n isSame: (other: DateChainComparable, unit?: DateChainCompareUnit) => boolean\n toState: () => DateChainState\n}\n\nexport type DateChainComparable = DateValue | DateChain\n\nexport type DateFormatter = {\n getDate: (props?: GetDateOptions) => string\n parseDate: (props: DateParsingOptions) => ParseDateResult\n isValidDate: (props: DateParsingOptions) => boolean\n createDateChain: (props?: CreateDateChainOptions) => DateChain\n getSupportedLocales: () => readonly SupportedLocale[]\n getCurrentLocale: () => SupportedLocale\n setLocale: (locale: LocaleInput) => Promise<void>\n ready: Promise<void>\n}\n\nexport type ParseDateSuccess = {\n isValid: true\n locale: SupportedLocale\n date: Date\n iso: string\n timestamp: number\n format: (output?: string) => string\n}\n\nexport type ParseDateFailure = {\n isValid: false\n locale: SupportedLocale\n date: null\n iso: null\n timestamp: null\n error: string\n}\n\nexport type ParseDateResult = ParseDateSuccess | ParseDateFailure\n\ntype InternalDateChainState = {\n locale: SupportedLocale\n invalid: string\n current: Dayjs | null\n ready: boolean\n error: string | null\n}\n\nconst DEFAULT_FORMAT = 'YYYY-MM-DD'\nconst DEFAULT_LOCALE: SupportedLocale = 'en'\nconst DEFAULT_INVALID_DATE = 'Invalid Date'\nconst DEFAULT_STRICT = true\n\nconst createResolvedConfig = (\n locale: SupportedLocale,\n config?: DateFormatterConfig\n): ResolvedDateFormatterConfig => ({\n locale,\n strict: config?.strict ?? DEFAULT_STRICT,\n invalid: config?.invalid ?? DEFAULT_INVALID_DATE\n})\n\nconst getInvalidDateText = <T>(config?: DateFormatterConfig, props?: T): string => {\n if (typeof props === 'object' && props !== null && 'invalid' in props) {\n const invalid = (props as { invalid?: string }).invalid\n\n if (invalid !== undefined) {\n return invalid\n }\n }\n\n return config?.invalid ?? DEFAULT_INVALID_DATE\n}\n\nconst getTargetLocale = <T extends { locale?: LocaleInput }>(\n currentLocale: SupportedLocale,\n props?: T\n): SupportedLocale => {\n if (!props?.locale) {\n return currentLocale\n }\n\n return resolveLocaleOrThrow(props.locale)\n}\n\nconst getHelperLocale = <T extends { locale?: LocaleInput }>(\n config?: DateFormatterConfig,\n props?: T\n): SupportedLocale => {\n if (props?.locale) {\n return resolveLocaleOrThrow(props.locale)\n }\n\n if (config?.locale) {\n return resolveLocaleOrThrow(config.locale)\n }\n\n return DEFAULT_LOCALE\n}\n\nconst parseDateValue = (\n value: DateValue,\n input: DateParsingOptions['input'],\n locale: SupportedLocale,\n strict: boolean\n): Dayjs => {\n if (!input) {\n return dayjs(value).locale(locale)\n }\n\n if (typeof input === 'string') {\n return dayjs(value, input, locale, strict).locale(locale)\n }\n\n return dayjs(value, [...input], locale, strict).locale(locale)\n}\n\nconst getCurrentDayjs = (locale: SupportedLocale): Dayjs => {\n return dayjs().locale(locale)\n}\n\nconst createParseSuccess = (parsed: Dayjs, locale: SupportedLocale): ParseDateSuccess => {\n return {\n isValid: true,\n locale,\n date: parsed.toDate(),\n iso: parsed.toISOString(),\n timestamp: parsed.valueOf(),\n format: (output = DEFAULT_FORMAT) => parsed.format(output)\n }\n}\n\nconst createParseFailure = (locale: SupportedLocale, error: string): ParseDateFailure => {\n return {\n isValid: false,\n locale,\n date: null,\n iso: null,\n timestamp: null,\n error\n }\n}\n\nconst createDateChainSuccessState = (parsed: Dayjs, locale: SupportedLocale): DateChainSuccessState => {\n return {\n isValid: true,\n locale,\n date: parsed.toDate(),\n iso: parsed.toISOString(),\n timestamp: parsed.valueOf()\n }\n}\n\nconst createDateChainFailureState = (locale: SupportedLocale, error: string): DateChainFailureState => {\n return {\n isValid: false,\n locale,\n date: null,\n iso: null,\n timestamp: null,\n error\n }\n}\n\nconst mapChainSetUnit = (unit: DateChainSetUnit): 'year' | 'month' | 'date' | 'hour' | 'minute' | 'second' | 'millisecond' => {\n if (unit === 'day') {\n return 'date'\n }\n\n return unit\n}\n\nconst createReadyError = (): Error => {\n return new Error('Date chain is not ready. Await chain.ready before using it with locales that may need to load.')\n}\n\nconst assertDateChainReady = (state: InternalDateChainState): void => {\n if (!state.ready) {\n throw createReadyError()\n }\n}\n\nconst getComparableDayjs = (value: DateChainComparable): Dayjs | null => {\n if (typeof value === 'object' && value !== null && 'toState' in value) {\n const state = value.toState()\n\n if (!state.isValid) {\n return null\n }\n\n return dayjs(state.date)\n }\n\n const comparable = dayjs(value)\n\n if (!comparable.isValid()) {\n return null\n }\n\n return comparable\n}\n\nconst createDateChainApi = (state: InternalDateChainState, ready: Promise<void>): DateChain => {\n const applyMutation = (transform: (current: Dayjs) => Dayjs): DateChain => {\n assertDateChainReady(state)\n\n if (state.current) {\n state.current = transform(state.current)\n }\n\n return chain\n }\n\n const compare = (\n other: DateChainComparable,\n comparator: (current: Dayjs, comparable: Dayjs) => boolean\n ): boolean => {\n assertDateChainReady(state)\n\n if (!state.current) {\n return false\n }\n\n const comparable = getComparableDayjs(other)\n\n if (!comparable) {\n return false\n }\n\n return comparator(state.current, comparable)\n }\n\n const chain: DateChain = {\n ready,\n add: (value, unit) => applyMutation((current) => current.add(value, unit)),\n subtract: (value, unit) => applyMutation((current) => current.subtract(value, unit)),\n set: (unit, value) => applyMutation((current) => current.set(mapChainSetUnit(unit), value)),\n startOf: (unit) => applyMutation((current) => current.startOf(unit)),\n endOf: (unit) => applyMutation((current) => current.endOf(unit)),\n format: (output = DEFAULT_FORMAT) => {\n assertDateChainReady(state)\n\n if (!state.current) {\n return state.invalid\n }\n\n return state.current.format(output)\n },\n toDate: () => {\n assertDateChainReady(state)\n\n return state.current ? state.current.toDate() : null\n },\n toISOString: () => {\n assertDateChainReady(state)\n\n return state.current ? state.current.toISOString() : null\n },\n toTimestamp: () => {\n assertDateChainReady(state)\n\n return state.current ? state.current.valueOf() : null\n },\n isValid: () => {\n assertDateChainReady(state)\n\n return state.current !== null\n },\n isBefore: (other, unit) => compare(other, (current, comparable) => current.isBefore(comparable, unit)),\n isAfter: (other, unit) => compare(other, (current, comparable) => current.isAfter(comparable, unit)),\n isSame: (other, unit) => compare(other, (current, comparable) => current.isSame(comparable, unit)),\n toState: () => {\n assertDateChainReady(state)\n\n if (!state.current) {\n return createDateChainFailureState(state.locale, state.error ?? state.invalid)\n }\n\n return createDateChainSuccessState(state.current, state.locale)\n }\n }\n\n return chain\n}\n\nconst createDateChainState = (\n locale: SupportedLocale,\n invalid: string,\n getInitialDate: () => Dayjs\n): { state: InternalDateChainState; ready: Promise<void> } => {\n const state: InternalDateChainState = {\n locale,\n invalid,\n current: null,\n ready: false,\n error: invalid\n }\n\n const initialize = () => {\n const parsed = getInitialDate()\n\n state.ready = true\n\n if (!parsed.isValid()) {\n state.current = null\n state.error = invalid\n return\n }\n\n state.current = parsed\n state.error = null\n }\n\n if (isLocaleLoaded(locale)) {\n initialize()\n\n return {\n state,\n ready: Promise.resolve()\n }\n }\n\n return {\n state,\n ready: ensureLocaleLoaded(locale).then(() => {\n initialize()\n })\n }\n}\n\nconst createDateChainFromResolvedConfig = (\n props: CreateDateChainOptions | undefined,\n config: ResolvedDateFormatterConfig\n): DateChain => {\n const locale = getTargetLocale(config.locale, props)\n const invalid = getInvalidDateText(config, props)\n const strict = props?.strict ?? config.strict\n const getInitialDate = () => {\n if (props?.date === undefined) {\n return getCurrentDayjs(locale)\n }\n\n return parseDateValue(props.date, props.input, locale, strict)\n }\n\n const { state, ready } = createDateChainState(locale, invalid, getInitialDate)\n\n return createDateChainApi(state, ready)\n}\n\nconst createFormatterParseDate = (getConfig: () => ResolvedDateFormatterConfig) => {\n return (props: DateParsingOptions): ParseDateResult => {\n const config = getConfig()\n const locale = getTargetLocale(config.locale, props)\n const parsed = parseDateValue(props.date, props.input, locale, props.strict ?? config.strict)\n\n if (!parsed.isValid()) {\n return createParseFailure(locale, getInvalidDateText(config, props))\n }\n\n return createParseSuccess(parsed, locale)\n }\n}\n\nconst createFormatterIsValidDate = (parseDate: (props: DateParsingOptions) => ParseDateResult) => {\n return (props: DateParsingOptions): boolean => parseDate(props).isValid\n}\n\nconst createFormatterGetDate = (getConfig: () => ResolvedDateFormatterConfig) => {\n const parseDate = createFormatterParseDate(getConfig)\n\n return (props?: GetDateOptions): string => {\n const config = getConfig()\n const locale = getTargetLocale(config.locale, props)\n const output = props?.output ?? DEFAULT_FORMAT\n\n if (!props) {\n return getCurrentDayjs(locale).format(DEFAULT_FORMAT)\n }\n\n if (props.date === undefined) {\n return getCurrentDayjs(locale).format(output)\n }\n\n const parsed = parseDate({\n date: props.date,\n input: props.input,\n locale: props.locale,\n strict: props.strict\n })\n\n if (!parsed.isValid) {\n return props.invalid ?? parsed.error\n }\n\n return parsed.format(output)\n }\n}\n\nconst createFormatterCreateDateChain = (getConfig: () => ResolvedDateFormatterConfig) => {\n return (props?: CreateDateChainOptions): DateChain => {\n return createDateChainFromResolvedConfig(props, getConfig())\n }\n}\n\nfunction resolveLocaleOrThrow(locale: LocaleInput): SupportedLocale {\n const resolvedLocale = resolveLocale(locale)\n\n if (!resolvedLocale) {\n throw new Error(\n `Unsupported locale: ${locale}. The package tries an exact locale match first and then falls back to the base locale.`\n )\n }\n\n return resolvedLocale\n}\n\nexport const getSupportedLocales = (): readonly SupportedLocale[] => SUPPORTED_LOCALES\n\nexport const createDateChain = (props?: CreateDateChainOptions, config?: DateFormatterConfig): DateChain => {\n const locale = getHelperLocale(config, props)\n\n return createDateChainFromResolvedConfig(props, createResolvedConfig(locale, config))\n}\n\nexport const getDate = async (props?: GetDateOptions, config?: DateFormatterConfig): Promise<string> => {\n const locale = getHelperLocale(config, props)\n const formatter = createDateFormatter({ ...config, locale })\n\n await formatter.ready\n\n return formatter.getDate(props)\n}\n\nexport const parseDate = async (\n props: DateParsingOptions,\n config?: DateFormatterConfig\n): Promise<ParseDateResult> => {\n const locale = getHelperLocale(config, props)\n const formatter = createDateFormatter({ ...config, locale })\n\n await formatter.ready\n\n return formatter.parseDate(props)\n}\n\nexport const isValidDate = async (\n props: DateParsingOptions,\n config?: DateFormatterConfig\n): Promise<boolean> => {\n const locale = getHelperLocale(config, props)\n const formatter = createDateFormatter({ ...config, locale })\n\n await formatter.ready\n\n return formatter.isValidDate(props)\n}\n\nexport const createDateFormatter = (config?: DateFormatterConfig): DateFormatter => {\n let currentLocale = config?.locale ? resolveLocaleOrThrow(config.locale) : DEFAULT_LOCALE\n\n const getConfig = (): ResolvedDateFormatterConfig => createResolvedConfig(currentLocale, config)\n\n const ready = ensureLocaleLoaded(currentLocale)\n const parseDate = createFormatterParseDate(getConfig)\n\n return {\n getDate: createFormatterGetDate(getConfig),\n parseDate,\n isValidDate: createFormatterIsValidDate(parseDate),\n createDateChain: createFormatterCreateDateChain(getConfig),\n getSupportedLocales,\n getCurrentLocale: () => currentLocale,\n setLocale: async (locale: LocaleInput) => {\n const resolvedLocale = resolveLocaleOrThrow(locale)\n\n await ensureLocaleLoaded(resolvedLocale)\n currentLocale = resolvedLocale\n },\n ready\n }\n}\n","export const SUPPORTED_LOCALES = [\n 'en',\n 'es',\n 'es-mx',\n 'fr',\n 'pt',\n 'pt-br',\n 'de',\n 'it',\n 'ja'\n] as const\n\nexport type SupportedLocale = (typeof SUPPORTED_LOCALES)[number]\nexport type LocaleInput = string\n\nconst loadedLocales = new Set<SupportedLocale>(['en'])\n\nconst localeLoaders: Record<SupportedLocale, (() => Promise<unknown>) | null> = {\n en: null,\n es: () => import('dayjs/locale/es.js'),\n 'es-mx': () => import('dayjs/locale/es-mx.js'),\n fr: () => import('dayjs/locale/fr.js'),\n pt: () => import('dayjs/locale/pt.js'),\n 'pt-br': () => import('dayjs/locale/pt-br.js'),\n de: () => import('dayjs/locale/de.js'),\n it: () => import('dayjs/locale/it.js'),\n ja: () => import('dayjs/locale/ja.js')\n}\n\nconst normalizeLocale = (locale: string): string => {\n return locale.trim().toLowerCase().replace(/_/g, '-')\n}\n\nconst asSupportedLocale = (locale: string): SupportedLocale | null => {\n if (!SUPPORTED_LOCALES.includes(locale as SupportedLocale)) {\n return null\n }\n\n return locale as SupportedLocale\n}\n\nexport const isSupportedLocale = (locale: string): boolean => {\n return resolveLocale(locale) !== null\n}\n\nexport const resolveLocale = (locale: LocaleInput): SupportedLocale | null => {\n const normalizedLocale = normalizeLocale(locale)\n const exactLocale = asSupportedLocale(normalizedLocale)\n\n if (exactLocale) {\n return exactLocale\n }\n\n const [baseLocale] = normalizedLocale.split('-')\n\n if (!baseLocale) {\n return null\n }\n\n return asSupportedLocale(baseLocale)\n}\n\nexport const markLocaleAsLoaded = (locale: SupportedLocale): void => {\n loadedLocales.add(locale)\n}\n\nexport const isLocaleLoaded = (locale: SupportedLocale): boolean => {\n return loadedLocales.has(locale)\n}\n\nexport const ensureLocaleLoaded = async (locale: SupportedLocale): Promise<void> => {\n if (loadedLocales.has(locale)) {\n return\n }\n\n const load = localeLoaders[locale]\n\n if (!load) {\n loadedLocales.add(locale)\n return\n }\n\n await load()\n loadedLocales.add(locale)\n}\n"],"mappings":";AAAA,SAAS,UAAU,WAAW;;;ACA9B,OAAO,uBAAuB;AAC9B,OAAO,WAAW;;;ACDX,IAAM,oBAAoB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKA,IAAM,gBAAgB,oBAAI,IAAqB,CAAC,IAAI,CAAC;AAErD,IAAM,gBAA0E;AAAA,EAC9E,IAAI;AAAA,EACJ,IAAI,MAAM,OAAO,oBAAoB;AAAA,EACrC,SAAS,MAAM,OAAO,uBAAuB;AAAA,EAC7C,IAAI,MAAM,OAAO,oBAAoB;AAAA,EACrC,IAAI,MAAM,OAAO,oBAAoB;AAAA,EACrC,SAAS,MAAM,OAAO,uBAAuB;AAAA,EAC7C,IAAI,MAAM,OAAO,oBAAoB;AAAA,EACrC,IAAI,MAAM,OAAO,oBAAoB;AAAA,EACrC,IAAI,MAAM,OAAO,oBAAoB;AACvC;AAEA,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parseDate"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samline/date",
3
- "version": "2.1.2",
3
+ "version": "2.2.0",
4
4
  "description": "Format and localize dates with Day.js through a small multi-entrypoint API.",
5
5
  "type": "module",
6
6
  "license": "MIT",