use-intl 2.17.4 → 2.17.5-alpha.1
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.
- package/dist/_virtual/use-intl.esm.js +102 -0
- package/dist/_virtual/use-intl.esm.js.map +1 -0
- package/dist/core/AbstractIntlMessages.d.ts +9 -10
- package/dist/core/DateTimeFormatOptions.d.ts +73 -75
- package/dist/core/Formats.d.ts +8 -11
- package/dist/core/IntlConfig.d.ts +54 -60
- package/dist/core/IntlError.d.ts +13 -15
- package/dist/core/NumberFormatOptions.d.ts +2 -2
- package/dist/core/TimeZone.d.ts +2 -3
- package/dist/core/TranslationValues.d.ts +5 -7
- package/dist/core/convertFormatsToIntlMessageFormat.d.ts +11 -16
- package/dist/core/createBaseTranslator.d.ts +26 -32
- package/dist/core/createFormatter.d.ts +19 -21
- package/dist/core/createIntl.d.ts +7 -15
- package/dist/core/createTranslator.d.ts +48 -57
- package/dist/core/createTranslatorImpl.d.ts +14 -25
- package/dist/core/defaults.d.ts +11 -14
- package/dist/core/index.d.ts +9 -17
- package/dist/core/resolveNamespace.d.ts +5 -7
- package/dist/core/use-intl.esm.js +33 -0
- package/dist/core/use-intl.esm.js.map +1 -0
- package/dist/core/use-intl.esm10.js +32 -0
- package/dist/core/use-intl.esm10.js.map +1 -0
- package/dist/core/use-intl.esm2.js +138 -0
- package/dist/core/use-intl.esm2.js.map +1 -0
- package/dist/core/use-intl.esm3.js +14 -0
- package/dist/core/use-intl.esm3.js.map +1 -0
- package/dist/core/use-intl.esm4.js +37 -0
- package/dist/core/use-intl.esm4.js.map +1 -0
- package/dist/core/use-intl.esm5.js +15 -0
- package/dist/core/use-intl.esm5.js.map +1 -0
- package/dist/core/use-intl.esm6.js +53 -0
- package/dist/core/use-intl.esm6.js.map +1 -0
- package/dist/core/use-intl.esm7.js +28 -0
- package/dist/core/use-intl.esm7.js.map +1 -0
- package/dist/core/use-intl.esm8.js +10 -0
- package/dist/core/use-intl.esm8.js.map +1 -0
- package/dist/core/use-intl.esm9.js +191 -0
- package/dist/core/use-intl.esm9.js.map +1 -0
- package/dist/core/utils/MessageKeys.d.ts +5 -7
- package/dist/core/utils/NamespaceKeys.d.ts +5 -7
- package/dist/core/utils/NestedKeyOf.d.ts +4 -5
- package/dist/core/utils/NestedValueOf.d.ts +2 -3
- package/dist/core/validateMessages.d.ts +3 -6
- package/dist/index.d.ts +2 -25
- package/dist/index.js +8 -2
- package/dist/react/IntlContext.d.ts +4 -13
- package/dist/react/IntlProvider.d.ts +7 -16
- package/dist/react/getInitializedConfig.d.ts +13 -24
- package/dist/react/index.d.ts +8 -21
- package/dist/react/use-intl.esm.js +16 -0
- package/dist/react/use-intl.esm.js.map +1 -0
- package/dist/react/use-intl.esm10.js +6 -0
- package/dist/react/use-intl.esm10.js.map +1 -0
- package/dist/react/use-intl.esm11.js +13 -0
- package/dist/react/use-intl.esm11.js.map +1 -0
- package/dist/react/use-intl.esm12.js +43 -0
- package/dist/react/use-intl.esm12.js.map +1 -0
- package/dist/react/use-intl.esm2.js +8 -0
- package/dist/react/use-intl.esm2.js.map +1 -0
- package/dist/react/use-intl.esm3.js +26 -0
- package/dist/react/use-intl.esm3.js.map +1 -0
- package/dist/react/use-intl.esm4.js +8 -0
- package/dist/react/use-intl.esm4.js.map +1 -0
- package/dist/react/{useNow.d.mts → use-intl.esm5.js} +42 -21
- package/dist/react/use-intl.esm5.js.map +1 -0
- package/dist/react/use-intl.esm6.js +24 -0
- package/dist/react/use-intl.esm6.js.map +1 -0
- package/dist/react/use-intl.esm7.js +30 -0
- package/dist/react/use-intl.esm7.js.map +1 -0
- package/dist/react/use-intl.esm8.js +8 -0
- package/dist/react/use-intl.esm8.js.map +1 -0
- package/dist/react/use-intl.esm9.js +29 -0
- package/dist/react/use-intl.esm9.js.map +1 -0
- package/dist/react/useFormatter.d.ts +6 -12
- package/dist/react/useIntl.d.ts +6 -12
- package/dist/react/useIntlContext.d.ts +1 -13
- package/dist/react/useLocale.d.ts +1 -3
- package/dist/react/useMessages.d.ts +1 -5
- package/dist/react/useNow.d.ts +23 -24
- package/dist/react/useTimeZone.d.ts +1 -5
- package/dist/react/useTranslations.d.ts +44 -50
- package/dist/react/useTranslationsImpl.d.ts +8 -16
- package/dist/src/core/AbstractIntlMessages.d.ts +1 -2
- package/dist/src/core/AbstractIntlMessages.js +1 -1
- package/dist/src/core/AbstractIntlMessages.js.map +1 -1
- package/dist/src/core/DateTimeFormatOptions.d.ts +2 -4
- package/dist/src/core/DateTimeFormatOptions.js +2 -1
- package/dist/src/core/DateTimeFormatOptions.js.map +1 -1
- package/dist/src/core/Formats.d.ts +3 -6
- package/dist/src/core/Formats.js +1 -1
- package/dist/src/core/Formats.js.map +1 -1
- package/dist/src/core/IntlConfig.d.ts +6 -12
- package/dist/src/core/IntlConfig.js +1 -1
- package/dist/src/core/IntlConfig.js.map +1 -1
- package/dist/src/core/IntlError.d.ts +2 -4
- package/dist/src/core/IntlError.js +22 -1
- package/dist/src/core/IntlError.js.map +1 -1
- package/dist/src/core/NumberFormatOptions.d.ts +2 -2
- package/dist/src/core/NumberFormatOptions.js +1 -1
- package/dist/src/core/NumberFormatOptions.js.map +1 -1
- package/dist/src/core/TimeZone.d.ts +1 -2
- package/dist/src/core/TimeZone.js +1 -1
- package/dist/src/core/TimeZone.js.map +1 -1
- package/dist/src/core/TranslationValues.d.ts +3 -5
- package/dist/src/core/TranslationValues.js +1 -1
- package/dist/src/core/TranslationValues.js.map +1 -1
- package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +4 -9
- package/dist/src/core/convertFormatsToIntlMessageFormat.js +30 -1
- package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +1 -1
- package/dist/src/core/createBaseTranslator.d.ts +11 -17
- package/dist/src/core/createBaseTranslator.js +205 -1
- package/dist/src/core/createBaseTranslator.js.map +1 -1
- package/dist/src/core/createFormatter.d.ts +7 -9
- package/dist/src/core/createFormatter.js +128 -1
- package/dist/src/core/createFormatter.js.map +1 -1
- package/dist/src/core/createIntl.d.ts +4 -12
- package/dist/src/core/createIntl.js +10 -1
- package/dist/src/core/createIntl.js.map +1 -1
- package/dist/src/core/createTranslator.d.ts +9 -18
- package/dist/src/core/createTranslator.js +23 -1
- package/dist/src/core/createTranslator.js.map +1 -1
- package/dist/src/core/createTranslatorImpl.d.ts +9 -20
- package/dist/src/core/createTranslatorImpl.js +42 -1
- package/dist/src/core/createTranslatorImpl.js.map +1 -1
- package/dist/src/core/defaults.d.ts +3 -6
- package/dist/src/core/defaults.js +10 -1
- package/dist/src/core/defaults.js.map +1 -1
- package/dist/src/core/index.d.ts +9 -17
- package/dist/src/core/index.js +5 -1
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/core/resolveNamespace.d.ts +1 -3
- package/dist/src/core/resolveNamespace.js +9 -1
- package/dist/src/core/resolveNamespace.js.map +1 -1
- package/dist/src/core/utils/MessageKeys.d.ts +2 -4
- package/dist/src/core/utils/MessageKeys.js +1 -1
- package/dist/src/core/utils/MessageKeys.js.map +1 -1
- package/dist/src/core/utils/NamespaceKeys.d.ts +2 -4
- package/dist/src/core/utils/NamespaceKeys.js +1 -1
- package/dist/src/core/utils/NamespaceKeys.js.map +1 -1
- package/dist/src/core/utils/NestedKeyOf.d.ts +1 -2
- package/dist/src/core/utils/NestedKeyOf.js +1 -1
- package/dist/src/core/utils/NestedKeyOf.js.map +1 -1
- package/dist/src/core/utils/NestedValueOf.d.ts +1 -2
- package/dist/src/core/utils/NestedValueOf.js +1 -1
- package/dist/src/core/utils/NestedValueOf.js.map +1 -1
- package/dist/src/core/validateMessages.d.ts +3 -6
- package/dist/src/core/validateMessages.js +25 -3
- package/dist/src/core/validateMessages.js.map +1 -1
- package/dist/src/index.d.ts +2 -25
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/react/IntlContext.d.ts +4 -13
- package/dist/src/react/IntlContext.js +3 -1
- package/dist/src/react/IntlContext.js.map +1 -1
- package/dist/src/react/IntlProvider.d.ts +3 -12
- package/dist/src/react/IntlProvider.js +6 -1
- package/dist/src/react/IntlProvider.js.map +1 -1
- package/dist/src/react/getInitializedConfig.d.ts +5 -16
- package/dist/src/react/getInitializedConfig.js +20 -1
- package/dist/src/react/getInitializedConfig.js.map +1 -1
- package/dist/src/react/index.d.ts +8 -21
- package/dist/src/react/index.js +9 -1
- package/dist/src/react/index.js.map +1 -1
- package/dist/src/react/useFormatter.d.ts +3 -9
- package/dist/src/react/useFormatter.js +13 -1
- package/dist/src/react/useFormatter.js.map +1 -1
- package/dist/src/react/useIntl.d.ts +3 -9
- package/dist/src/react/useIntl.js +19 -1
- package/dist/src/react/useIntl.js.map +1 -1
- package/dist/src/react/useIntlContext.d.ts +1 -13
- package/dist/src/react/useIntlContext.js +11 -1
- package/dist/src/react/useIntlContext.js.map +1 -1
- package/dist/src/react/useLocale.d.ts +1 -3
- package/dist/src/react/useLocale.js +4 -1
- package/dist/src/react/useLocale.js.map +1 -1
- package/dist/src/react/useMessages.d.ts +1 -5
- package/dist/src/react/useMessages.js +4 -1
- package/dist/src/react/useMessages.js.map +1 -1
- package/dist/src/react/useNow.d.ts +2 -3
- package/dist/src/react/useNow.js +39 -1
- package/dist/src/react/useNow.js.map +1 -1
- package/dist/src/react/useTimeZone.d.ts +1 -5
- package/dist/src/react/useTimeZone.js +4 -1
- package/dist/src/react/useTimeZone.js.map +1 -1
- package/dist/src/react/useTranslations.d.ts +7 -13
- package/dist/src/react/useTranslations.js +20 -1
- package/dist/src/react/useTranslations.js.map +1 -1
- package/dist/src/react/useTranslationsImpl.d.ts +6 -14
- package/dist/src/react/useTranslationsImpl.js +34 -1
- package/dist/src/react/useTranslationsImpl.js.map +1 -1
- package/dist/use-intl.cjs.development.js +821 -0
- package/dist/use-intl.cjs.development.js.map +1 -0
- package/dist/use-intl.cjs.production.min.js +2 -0
- package/dist/use-intl.cjs.production.min.js.map +1 -0
- package/dist/use-intl.esm.js +13 -0
- package/dist/use-intl.esm.js.map +1 -0
- package/package.json +24 -11
- package/dist/core/AbstractIntlMessages.d.mts +0 -10
- package/dist/core/AbstractIntlMessages.js +0 -2
- package/dist/core/AbstractIntlMessages.js.map +0 -1
- package/dist/core/AbstractIntlMessages.mjs +0 -1
- package/dist/core/AbstractIntlMessages.mjs.map +0 -1
- package/dist/core/DateTimeFormatOptions.d.mts +0 -75
- package/dist/core/DateTimeFormatOptions.js +0 -2
- package/dist/core/DateTimeFormatOptions.js.map +0 -1
- package/dist/core/DateTimeFormatOptions.mjs +0 -1
- package/dist/core/DateTimeFormatOptions.mjs.map +0 -1
- package/dist/core/Formats.d.mts +0 -11
- package/dist/core/Formats.js +0 -2
- package/dist/core/Formats.js.map +0 -1
- package/dist/core/Formats.mjs +0 -1
- package/dist/core/Formats.mjs.map +0 -1
- package/dist/core/IntlConfig.d.mts +0 -60
- package/dist/core/IntlConfig.js +0 -2
- package/dist/core/IntlConfig.js.map +0 -1
- package/dist/core/IntlConfig.mjs +0 -1
- package/dist/core/IntlConfig.mjs.map +0 -1
- package/dist/core/IntlError.d.mts +0 -15
- package/dist/core/IntlError.js +0 -2
- package/dist/core/IntlError.js.map +0 -1
- package/dist/core/IntlError.mjs +0 -2
- package/dist/core/IntlError.mjs.map +0 -1
- package/dist/core/NumberFormatOptions.d.mts +0 -2
- package/dist/core/NumberFormatOptions.js +0 -2
- package/dist/core/NumberFormatOptions.js.map +0 -1
- package/dist/core/NumberFormatOptions.mjs +0 -2
- package/dist/core/NumberFormatOptions.mjs.map +0 -1
- package/dist/core/TimeZone.d.mts +0 -3
- package/dist/core/TimeZone.js +0 -2
- package/dist/core/TimeZone.js.map +0 -1
- package/dist/core/TimeZone.mjs +0 -1
- package/dist/core/TimeZone.mjs.map +0 -1
- package/dist/core/TranslationValues.d.mts +0 -7
- package/dist/core/TranslationValues.js +0 -2
- package/dist/core/TranslationValues.js.map +0 -1
- package/dist/core/TranslationValues.mjs +0 -1
- package/dist/core/TranslationValues.mjs.map +0 -1
- package/dist/core/convertFormatsToIntlMessageFormat.d.mts +0 -16
- package/dist/core/convertFormatsToIntlMessageFormat.js +0 -2
- package/dist/core/convertFormatsToIntlMessageFormat.js.map +0 -1
- package/dist/core/convertFormatsToIntlMessageFormat.mjs +0 -2
- package/dist/core/convertFormatsToIntlMessageFormat.mjs.map +0 -1
- package/dist/core/createBaseTranslator.d.mts +0 -32
- package/dist/core/createBaseTranslator.js +0 -2
- package/dist/core/createBaseTranslator.js.map +0 -1
- package/dist/core/createBaseTranslator.mjs +0 -2
- package/dist/core/createBaseTranslator.mjs.map +0 -1
- package/dist/core/createFormatter.d.mts +0 -21
- package/dist/core/createFormatter.js +0 -2
- package/dist/core/createFormatter.js.map +0 -1
- package/dist/core/createFormatter.mjs +0 -2
- package/dist/core/createFormatter.mjs.map +0 -1
- package/dist/core/createIntl.d.mts +0 -15
- package/dist/core/createIntl.js +0 -2
- package/dist/core/createIntl.js.map +0 -1
- package/dist/core/createIntl.mjs +0 -2
- package/dist/core/createIntl.mjs.map +0 -1
- package/dist/core/createTranslator.d.mts +0 -57
- package/dist/core/createTranslator.js +0 -2
- package/dist/core/createTranslator.js.map +0 -1
- package/dist/core/createTranslator.mjs +0 -2
- package/dist/core/createTranslator.mjs.map +0 -1
- package/dist/core/createTranslatorImpl.d.mts +0 -25
- package/dist/core/createTranslatorImpl.js +0 -2
- package/dist/core/createTranslatorImpl.js.map +0 -1
- package/dist/core/createTranslatorImpl.mjs +0 -2
- package/dist/core/createTranslatorImpl.mjs.map +0 -1
- package/dist/core/defaults.d.mts +0 -14
- package/dist/core/defaults.js +0 -2
- package/dist/core/defaults.js.map +0 -1
- package/dist/core/defaults.mjs +0 -2
- package/dist/core/defaults.mjs.map +0 -1
- package/dist/core/index.d.mts +0 -17
- package/dist/core/index.js +0 -2
- package/dist/core/index.js.map +0 -1
- package/dist/core/index.mjs +0 -2
- package/dist/core/index.mjs.map +0 -1
- package/dist/core/resolveNamespace.d.mts +0 -7
- package/dist/core/resolveNamespace.js +0 -2
- package/dist/core/resolveNamespace.js.map +0 -1
- package/dist/core/resolveNamespace.mjs +0 -2
- package/dist/core/resolveNamespace.mjs.map +0 -1
- package/dist/core/utils/MessageKeys.d.mts +0 -7
- package/dist/core/utils/MessageKeys.js +0 -2
- package/dist/core/utils/MessageKeys.js.map +0 -1
- package/dist/core/utils/MessageKeys.mjs +0 -1
- package/dist/core/utils/MessageKeys.mjs.map +0 -1
- package/dist/core/utils/NamespaceKeys.d.mts +0 -7
- package/dist/core/utils/NamespaceKeys.js +0 -2
- package/dist/core/utils/NamespaceKeys.js.map +0 -1
- package/dist/core/utils/NamespaceKeys.mjs +0 -1
- package/dist/core/utils/NamespaceKeys.mjs.map +0 -1
- package/dist/core/utils/NestedKeyOf.d.mts +0 -5
- package/dist/core/utils/NestedKeyOf.js +0 -2
- package/dist/core/utils/NestedKeyOf.js.map +0 -1
- package/dist/core/utils/NestedKeyOf.mjs +0 -1
- package/dist/core/utils/NestedKeyOf.mjs.map +0 -1
- package/dist/core/utils/NestedValueOf.d.mts +0 -3
- package/dist/core/utils/NestedValueOf.js +0 -2
- package/dist/core/utils/NestedValueOf.js.map +0 -1
- package/dist/core/utils/NestedValueOf.mjs +0 -1
- package/dist/core/utils/NestedValueOf.mjs.map +0 -1
- package/dist/core/validateMessages.d.mts +0 -6
- package/dist/core/validateMessages.js +0 -34
- package/dist/core/validateMessages.js.map +0 -1
- package/dist/core/validateMessages.mjs +0 -34
- package/dist/core/validateMessages.mjs.map +0 -1
- package/dist/index.d.mts +0 -25
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +0 -1
- package/dist/react/IntlContext.d.mts +0 -13
- package/dist/react/IntlContext.js +0 -2
- package/dist/react/IntlContext.js.map +0 -1
- package/dist/react/IntlContext.mjs +0 -2
- package/dist/react/IntlContext.mjs.map +0 -1
- package/dist/react/IntlProvider.d.mts +0 -16
- package/dist/react/IntlProvider.js +0 -2
- package/dist/react/IntlProvider.js.map +0 -1
- package/dist/react/IntlProvider.mjs +0 -2
- package/dist/react/IntlProvider.mjs.map +0 -1
- package/dist/react/getInitializedConfig.d.mts +0 -24
- package/dist/react/getInitializedConfig.js +0 -2
- package/dist/react/getInitializedConfig.js.map +0 -1
- package/dist/react/getInitializedConfig.mjs +0 -2
- package/dist/react/getInitializedConfig.mjs.map +0 -1
- package/dist/react/index.d.mts +0 -21
- package/dist/react/index.js +0 -2
- package/dist/react/index.js.map +0 -1
- package/dist/react/index.mjs +0 -2
- package/dist/react/index.mjs.map +0 -1
- package/dist/react/useFormatter.d.mts +0 -12
- package/dist/react/useFormatter.js +0 -2
- package/dist/react/useFormatter.js.map +0 -1
- package/dist/react/useFormatter.mjs +0 -2
- package/dist/react/useFormatter.mjs.map +0 -1
- package/dist/react/useIntl.d.mts +0 -12
- package/dist/react/useIntl.js +0 -2
- package/dist/react/useIntl.js.map +0 -1
- package/dist/react/useIntl.mjs +0 -2
- package/dist/react/useIntl.mjs.map +0 -1
- package/dist/react/useIntlContext.d.mts +0 -13
- package/dist/react/useIntlContext.js +0 -2
- package/dist/react/useIntlContext.js.map +0 -1
- package/dist/react/useIntlContext.mjs +0 -2
- package/dist/react/useIntlContext.mjs.map +0 -1
- package/dist/react/useLocale.d.mts +0 -3
- package/dist/react/useLocale.js +0 -2
- package/dist/react/useLocale.js.map +0 -1
- package/dist/react/useLocale.mjs +0 -2
- package/dist/react/useLocale.mjs.map +0 -1
- package/dist/react/useMessages.d.mts +0 -5
- package/dist/react/useMessages.js +0 -2
- package/dist/react/useMessages.js.map +0 -1
- package/dist/react/useMessages.mjs +0 -2
- package/dist/react/useMessages.mjs.map +0 -1
- package/dist/react/useNow.js +0 -2
- package/dist/react/useNow.js.map +0 -1
- package/dist/react/useNow.mjs +0 -2
- package/dist/react/useNow.mjs.map +0 -1
- package/dist/react/useTimeZone.d.mts +0 -5
- package/dist/react/useTimeZone.js +0 -2
- package/dist/react/useTimeZone.js.map +0 -1
- package/dist/react/useTimeZone.mjs +0 -2
- package/dist/react/useTimeZone.mjs.map +0 -1
- package/dist/react/useTranslations.d.mts +0 -50
- package/dist/react/useTranslations.js +0 -2
- package/dist/react/useTranslations.js.map +0 -1
- package/dist/react/useTranslations.mjs +0 -2
- package/dist/react/useTranslations.mjs.map +0 -1
- package/dist/react/useTranslationsImpl.d.mts +0 -16
- package/dist/react/useTranslationsImpl.js +0 -2
- package/dist/react/useTranslationsImpl.js.map +0 -1
- package/dist/react/useTranslationsImpl.mjs +0 -2
- package/dist/react/useTranslationsImpl.mjs.map +0 -1
- package/dist/src/core/AbstractIntlMessages.d.mts +0 -10
- package/dist/src/core/AbstractIntlMessages.mjs +0 -1
- package/dist/src/core/AbstractIntlMessages.mjs.map +0 -1
- package/dist/src/core/DateTimeFormatOptions.d.mts +0 -75
- package/dist/src/core/DateTimeFormatOptions.mjs +0 -1
- package/dist/src/core/DateTimeFormatOptions.mjs.map +0 -1
- package/dist/src/core/Formats.d.mts +0 -11
- package/dist/src/core/Formats.mjs +0 -1
- package/dist/src/core/Formats.mjs.map +0 -1
- package/dist/src/core/IntlConfig.d.mts +0 -60
- package/dist/src/core/IntlConfig.mjs +0 -1
- package/dist/src/core/IntlConfig.mjs.map +0 -1
- package/dist/src/core/IntlError.d.mts +0 -15
- package/dist/src/core/IntlError.mjs +0 -2
- package/dist/src/core/IntlError.mjs.map +0 -1
- package/dist/src/core/NumberFormatOptions.d.mts +0 -2
- package/dist/src/core/NumberFormatOptions.mjs +0 -2
- package/dist/src/core/NumberFormatOptions.mjs.map +0 -1
- package/dist/src/core/TimeZone.d.mts +0 -3
- package/dist/src/core/TimeZone.mjs +0 -1
- package/dist/src/core/TimeZone.mjs.map +0 -1
- package/dist/src/core/TranslationValues.d.mts +0 -7
- package/dist/src/core/TranslationValues.mjs +0 -1
- package/dist/src/core/TranslationValues.mjs.map +0 -1
- package/dist/src/core/convertFormatsToIntlMessageFormat.d.mts +0 -16
- package/dist/src/core/convertFormatsToIntlMessageFormat.mjs +0 -2
- package/dist/src/core/convertFormatsToIntlMessageFormat.mjs.map +0 -1
- package/dist/src/core/createBaseTranslator.d.mts +0 -32
- package/dist/src/core/createBaseTranslator.mjs +0 -2
- package/dist/src/core/createBaseTranslator.mjs.map +0 -1
- package/dist/src/core/createFormatter.d.mts +0 -21
- package/dist/src/core/createFormatter.mjs +0 -2
- package/dist/src/core/createFormatter.mjs.map +0 -1
- package/dist/src/core/createIntl.d.mts +0 -15
- package/dist/src/core/createIntl.mjs +0 -2
- package/dist/src/core/createIntl.mjs.map +0 -1
- package/dist/src/core/createTranslator.d.mts +0 -57
- package/dist/src/core/createTranslator.mjs +0 -2
- package/dist/src/core/createTranslator.mjs.map +0 -1
- package/dist/src/core/createTranslatorImpl.d.mts +0 -25
- package/dist/src/core/createTranslatorImpl.mjs +0 -2
- package/dist/src/core/createTranslatorImpl.mjs.map +0 -1
- package/dist/src/core/defaults.d.mts +0 -14
- package/dist/src/core/defaults.mjs +0 -2
- package/dist/src/core/defaults.mjs.map +0 -1
- package/dist/src/core/index.d.mts +0 -17
- package/dist/src/core/index.mjs +0 -2
- package/dist/src/core/index.mjs.map +0 -1
- package/dist/src/core/resolveNamespace.d.mts +0 -7
- package/dist/src/core/resolveNamespace.mjs +0 -2
- package/dist/src/core/resolveNamespace.mjs.map +0 -1
- package/dist/src/core/utils/MessageKeys.d.mts +0 -7
- package/dist/src/core/utils/MessageKeys.mjs +0 -1
- package/dist/src/core/utils/MessageKeys.mjs.map +0 -1
- package/dist/src/core/utils/NamespaceKeys.d.mts +0 -7
- package/dist/src/core/utils/NamespaceKeys.mjs +0 -1
- package/dist/src/core/utils/NamespaceKeys.mjs.map +0 -1
- package/dist/src/core/utils/NestedKeyOf.d.mts +0 -5
- package/dist/src/core/utils/NestedKeyOf.mjs +0 -1
- package/dist/src/core/utils/NestedKeyOf.mjs.map +0 -1
- package/dist/src/core/utils/NestedValueOf.d.mts +0 -3
- package/dist/src/core/utils/NestedValueOf.mjs +0 -1
- package/dist/src/core/utils/NestedValueOf.mjs.map +0 -1
- package/dist/src/core/validateMessages.d.mts +0 -6
- package/dist/src/core/validateMessages.mjs +0 -34
- package/dist/src/core/validateMessages.mjs.map +0 -1
- package/dist/src/index.d.mts +0 -25
- package/dist/src/index.mjs +0 -2
- package/dist/src/index.mjs.map +0 -1
- package/dist/src/react/IntlContext.d.mts +0 -13
- package/dist/src/react/IntlContext.mjs +0 -2
- package/dist/src/react/IntlContext.mjs.map +0 -1
- package/dist/src/react/IntlProvider.d.mts +0 -16
- package/dist/src/react/IntlProvider.mjs +0 -2
- package/dist/src/react/IntlProvider.mjs.map +0 -1
- package/dist/src/react/getInitializedConfig.d.mts +0 -24
- package/dist/src/react/getInitializedConfig.mjs +0 -2
- package/dist/src/react/getInitializedConfig.mjs.map +0 -1
- package/dist/src/react/index.d.mts +0 -21
- package/dist/src/react/index.mjs +0 -2
- package/dist/src/react/index.mjs.map +0 -1
- package/dist/src/react/useFormatter.d.mts +0 -12
- package/dist/src/react/useFormatter.mjs +0 -2
- package/dist/src/react/useFormatter.mjs.map +0 -1
- package/dist/src/react/useIntl.d.mts +0 -12
- package/dist/src/react/useIntl.mjs +0 -2
- package/dist/src/react/useIntl.mjs.map +0 -1
- package/dist/src/react/useIntlContext.d.mts +0 -13
- package/dist/src/react/useIntlContext.mjs +0 -2
- package/dist/src/react/useIntlContext.mjs.map +0 -1
- package/dist/src/react/useLocale.d.mts +0 -3
- package/dist/src/react/useLocale.mjs +0 -2
- package/dist/src/react/useLocale.mjs.map +0 -1
- package/dist/src/react/useMessages.d.mts +0 -5
- package/dist/src/react/useMessages.mjs +0 -2
- package/dist/src/react/useMessages.mjs.map +0 -1
- package/dist/src/react/useNow.d.mts +0 -24
- package/dist/src/react/useNow.mjs +0 -2
- package/dist/src/react/useNow.mjs.map +0 -1
- package/dist/src/react/useTimeZone.d.mts +0 -5
- package/dist/src/react/useTimeZone.mjs +0 -2
- package/dist/src/react/useTimeZone.mjs.map +0 -1
- package/dist/src/react/useTranslations.d.mts +0 -50
- package/dist/src/react/useTranslations.mjs +0 -2
- package/dist/src/react/useTranslations.mjs.map +0 -1
- package/dist/src/react/useTranslationsImpl.d.mts +0 -16
- package/dist/src/react/useTranslationsImpl.mjs +0 -2
- package/dist/src/react/useTranslationsImpl.mjs.map +0 -1
|
@@ -1,32 +1,26 @@
|
|
|
1
|
-
import IntlMessageFormat from 'intl-messageformat';
|
|
2
|
-
import { ReactElement, ReactNodeArray } from 'react';
|
|
3
|
-
import AbstractIntlMessages from './AbstractIntlMessages
|
|
4
|
-
import Formats from './Formats
|
|
5
|
-
import { InitializedIntlConfig } from './IntlConfig
|
|
6
|
-
import IntlError from './IntlError
|
|
7
|
-
import TranslationValues, { RichTranslationValues } from './TranslationValues
|
|
8
|
-
import MessageKeys from './utils/MessageKeys
|
|
9
|
-
import NestedKeyOf from './utils/NestedKeyOf
|
|
10
|
-
import NestedValueOf from './utils/NestedValueOf
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<TargetKey extends MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
|
|
28
|
-
rich: (key: string, values?: RichTranslationValues, formats?: Partial<Formats>) => string | ReactElement | ReactNodeArray;
|
|
29
|
-
raw(key: string): any;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export { CreateBaseTranslatorProps, createBaseTranslator as default, getMessagesOrError };
|
|
1
|
+
import IntlMessageFormat from 'intl-messageformat';
|
|
2
|
+
import { ReactElement, ReactNodeArray } from 'react';
|
|
3
|
+
import AbstractIntlMessages from './AbstractIntlMessages';
|
|
4
|
+
import Formats from './Formats';
|
|
5
|
+
import { InitializedIntlConfig } from './IntlConfig';
|
|
6
|
+
import IntlError from './IntlError';
|
|
7
|
+
import TranslationValues, { RichTranslationValues } from './TranslationValues';
|
|
8
|
+
import MessageKeys from './utils/MessageKeys';
|
|
9
|
+
import NestedKeyOf from './utils/NestedKeyOf';
|
|
10
|
+
import NestedValueOf from './utils/NestedValueOf';
|
|
11
|
+
export declare function getMessagesOrError<Messages extends AbstractIntlMessages>({ messages, namespace, onError }: {
|
|
12
|
+
messages: Messages;
|
|
13
|
+
namespace?: string;
|
|
14
|
+
onError?(error: IntlError): void;
|
|
15
|
+
}): AbstractIntlMessages | IntlError;
|
|
16
|
+
export type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {
|
|
17
|
+
cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;
|
|
18
|
+
defaultTranslationValues?: RichTranslationValues;
|
|
19
|
+
namespace?: string;
|
|
20
|
+
messagesOrError: Messages | IntlError;
|
|
21
|
+
};
|
|
22
|
+
export default function createBaseTranslator<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ cachedFormatsByLocale, defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, messagesOrError, namespace, onError, timeZone }: CreateBaseTranslatorProps<Messages>): {
|
|
23
|
+
<TargetKey extends MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
|
|
24
|
+
rich: (key: string, values?: RichTranslationValues, formats?: Partial<Formats>) => string | ReactElement | ReactNodeArray;
|
|
25
|
+
raw(key: string): any;
|
|
26
|
+
};
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import DateTimeFormatOptions from './DateTimeFormatOptions
|
|
2
|
-
import Formats from './Formats
|
|
3
|
-
import IntlError from './IntlError
|
|
4
|
-
import
|
|
5
|
-
import TimeZone from './TimeZone
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export { createFormatter as default };
|
|
1
|
+
import DateTimeFormatOptions from './DateTimeFormatOptions';
|
|
2
|
+
import Formats from './Formats';
|
|
3
|
+
import IntlError from './IntlError';
|
|
4
|
+
import NumberFormatOptions from './NumberFormatOptions';
|
|
5
|
+
import TimeZone from './TimeZone';
|
|
6
|
+
type Props = {
|
|
7
|
+
locale: string;
|
|
8
|
+
timeZone?: TimeZone;
|
|
9
|
+
onError?(error: IntlError): void;
|
|
10
|
+
formats?: Partial<Formats>;
|
|
11
|
+
now?: Date;
|
|
12
|
+
};
|
|
13
|
+
export default function createFormatter({ formats, locale, now: globalNow, onError, timeZone }: Props): {
|
|
14
|
+
dateTime: (value: Date | number, formatOrOptions?: string | DateTimeFormatOptions) => string;
|
|
15
|
+
number: (value: number | bigint, formatOrOptions?: string | NumberFormatOptions) => string;
|
|
16
|
+
relativeTime: (date: number | Date, now?: number | Date) => string;
|
|
17
|
+
list: (value: Iterable<string>, formatOrOptions?: string | Intl.ListFormatOptions) => string;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/** @deprecated Switch to `createFormatter` */
|
|
9
|
-
declare function createIntl(...args: Parameters<typeof createFormatter>): {
|
|
10
|
-
formatDateTime: (value: number | Date, formatOrOptions?: string | DateTimeFormatOptions | undefined) => string;
|
|
11
|
-
formatNumber: (value: number | bigint, formatOrOptions?: string | _formatjs_ecma402_abstract_types_number.NumberFormatOptions | undefined) => string;
|
|
12
|
-
formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { createIntl as default };
|
|
1
|
+
import createFormatter from './createFormatter';
|
|
2
|
+
/** @deprecated Switch to `createFormatter` */
|
|
3
|
+
export default function createIntl(...args: Parameters<typeof createFormatter>): {
|
|
4
|
+
formatDateTime: (value: number | Date, formatOrOptions?: string | import("./DateTimeFormatOptions").default | undefined) => string;
|
|
5
|
+
formatNumber: (value: number | bigint, formatOrOptions?: string | import("@formatjs/ecma402-abstract/types/number").NumberFormatOptions | undefined) => string;
|
|
6
|
+
formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
|
|
7
|
+
};
|
|
@@ -1,57 +1,48 @@
|
|
|
1
|
-
import Formats from './Formats
|
|
2
|
-
import IntlConfig from './IntlConfig
|
|
3
|
-
import TranslationValues from './TranslationValues
|
|
4
|
-
import { CoreRichTranslationValues } from './createTranslatorImpl
|
|
5
|
-
import MessageKeys from './utils/MessageKeys
|
|
6
|
-
import NamespaceKeys from './utils/NamespaceKeys
|
|
7
|
-
import NestedKeyOf from './utils/NestedKeyOf
|
|
8
|
-
import NestedValueOf from './utils/NestedValueOf
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
NestedKey
|
|
50
|
-
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
51
|
-
'!': IntlMessages;
|
|
52
|
-
}, [
|
|
53
|
-
NestedKey
|
|
54
|
-
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export { createTranslator as default };
|
|
1
|
+
import Formats from './Formats';
|
|
2
|
+
import IntlConfig from './IntlConfig';
|
|
3
|
+
import TranslationValues from './TranslationValues';
|
|
4
|
+
import { CoreRichTranslationValues } from './createTranslatorImpl';
|
|
5
|
+
import MessageKeys from './utils/MessageKeys';
|
|
6
|
+
import NamespaceKeys from './utils/NamespaceKeys';
|
|
7
|
+
import NestedKeyOf from './utils/NestedKeyOf';
|
|
8
|
+
import NestedValueOf from './utils/NestedValueOf';
|
|
9
|
+
/**
|
|
10
|
+
* Translates messages from the given namespace by using the ICU syntax.
|
|
11
|
+
* See https://formatjs.io/docs/core-concepts/icu-syntax.
|
|
12
|
+
*
|
|
13
|
+
* If no namespace is provided, all available messages are returned.
|
|
14
|
+
* The namespace can also indicate nesting by using a dot
|
|
15
|
+
* (e.g. `namespace.Component`).
|
|
16
|
+
*/
|
|
17
|
+
export default function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {
|
|
18
|
+
messages: NonNullable<IntlConfig<IntlMessages>['messages']>;
|
|
19
|
+
namespace?: NestedKey;
|
|
20
|
+
}): {
|
|
21
|
+
<TargetKey extends MessageKeys<NestedValueOf<{
|
|
22
|
+
'!': IntlMessages;
|
|
23
|
+
}, [
|
|
24
|
+
NestedKey
|
|
25
|
+
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
26
|
+
'!': IntlMessages;
|
|
27
|
+
}, [
|
|
28
|
+
NestedKey
|
|
29
|
+
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
|
|
30
|
+
rich<TargetKey extends MessageKeys<NestedValueOf<{
|
|
31
|
+
'!': IntlMessages;
|
|
32
|
+
}, [
|
|
33
|
+
NestedKey
|
|
34
|
+
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
35
|
+
'!': IntlMessages;
|
|
36
|
+
}, [
|
|
37
|
+
NestedKey
|
|
38
|
+
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: CoreRichTranslationValues, formats?: Partial<Formats>): string;
|
|
39
|
+
raw<TargetKey extends MessageKeys<NestedValueOf<{
|
|
40
|
+
'!': IntlMessages;
|
|
41
|
+
}, [
|
|
42
|
+
NestedKey
|
|
43
|
+
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
44
|
+
'!': IntlMessages;
|
|
45
|
+
}, [
|
|
46
|
+
NestedKey
|
|
47
|
+
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
|
|
48
|
+
};
|
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type CreateTranslatorImplProps<Messages> = Omit<InitializedIntlConfig, 'messages'> & {
|
|
16
|
-
namespace: string;
|
|
17
|
-
messages: Messages;
|
|
18
|
-
};
|
|
19
|
-
declare function createTranslatorImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ getMessageFallback, messages, namespace, onError, ...rest }: CreateTranslatorImplProps<Messages>, namespacePrefix: string): {
|
|
20
|
-
(key: MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>, values?: TranslationValues | undefined, formats?: Partial<Formats> | undefined): string;
|
|
21
|
-
rich(key: string, values: CoreRichTranslationValues, formats?: Partial<Formats> | undefined): string;
|
|
22
|
-
raw: (key: string) => any;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export { CoreRichTranslationValues, CreateTranslatorImplProps, createTranslatorImpl as default };
|
|
1
|
+
import AbstractIntlMessages from './AbstractIntlMessages';
|
|
2
|
+
import { InitializedIntlConfig } from './IntlConfig';
|
|
3
|
+
import { TranslationValue } from './TranslationValues';
|
|
4
|
+
import NestedKeyOf from './utils/NestedKeyOf';
|
|
5
|
+
export type CoreRichTranslationValues = Record<string, TranslationValue | ((chunks: string) => string)>;
|
|
6
|
+
export type CreateTranslatorImplProps<Messages> = Omit<InitializedIntlConfig, 'messages'> & {
|
|
7
|
+
namespace: string;
|
|
8
|
+
messages: Messages;
|
|
9
|
+
};
|
|
10
|
+
export default function createTranslatorImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ getMessageFallback, messages, namespace, onError, ...rest }: CreateTranslatorImplProps<Messages>, namespacePrefix: string): {
|
|
11
|
+
(key: import("./utils/MessageKeys").default<import("./utils/NestedValueOf").default<Messages, NestedKey>, NestedKeyOf<import("./utils/NestedValueOf").default<Messages, NestedKey>>>, values?: import("./TranslationValues").default | undefined, formats?: Partial<import("./Formats").default> | undefined): string;
|
|
12
|
+
rich(key: string, values: CoreRichTranslationValues, formats?: Partial<import("./Formats").default> | undefined): string;
|
|
13
|
+
raw: (key: string) => any;
|
|
14
|
+
};
|
package/dist/core/defaults.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import IntlError from './IntlError
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
declare function defaultOnError(error: IntlError): void;
|
|
13
|
-
|
|
14
|
-
export { defaultGetMessageFallback, defaultOnError };
|
|
1
|
+
import IntlError from './IntlError';
|
|
2
|
+
/**
|
|
3
|
+
* Contains defaults that are used for all entry points into the core.
|
|
4
|
+
* See also `InitializedIntlConfiguration`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function defaultGetMessageFallback(props: {
|
|
7
|
+
error: IntlError;
|
|
8
|
+
key: string;
|
|
9
|
+
namespace?: string;
|
|
10
|
+
}): string;
|
|
11
|
+
export declare function defaultOnError(error: IntlError): void;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
export { default as AbstractIntlMessages } from './AbstractIntlMessages
|
|
2
|
-
export {
|
|
3
|
-
export { default as Formats } from './Formats
|
|
4
|
-
export { default as DateTimeFormatOptions } from './DateTimeFormatOptions
|
|
5
|
-
export { NumberFormatOptions } from '
|
|
6
|
-
export { default as IntlError, IntlErrorCode } from './IntlError
|
|
7
|
-
export { default as createTranslator } from './createTranslator
|
|
8
|
-
export { default as createFormatter } from './createFormatter
|
|
9
|
-
export { default as createIntl } from './createIntl
|
|
10
|
-
import 'react';
|
|
11
|
-
import './TimeZone.js';
|
|
12
|
-
import './IntlConfig.js';
|
|
13
|
-
import './createTranslatorImpl.js';
|
|
14
|
-
import './utils/MessageKeys.js';
|
|
15
|
-
import './utils/NestedValueOf.js';
|
|
16
|
-
import './utils/NestedKeyOf.js';
|
|
17
|
-
import './utils/NamespaceKeys.js';
|
|
1
|
+
export type { default as AbstractIntlMessages } from './AbstractIntlMessages';
|
|
2
|
+
export type { default as TranslationValues, RichTranslationValues } from './TranslationValues';
|
|
3
|
+
export type { default as Formats } from './Formats';
|
|
4
|
+
export type { default as DateTimeFormatOptions } from './DateTimeFormatOptions';
|
|
5
|
+
export type { default as NumberFormatOptions } from './NumberFormatOptions';
|
|
6
|
+
export { default as IntlError, IntlErrorCode } from './IntlError';
|
|
7
|
+
export { default as createTranslator } from './createTranslator';
|
|
8
|
+
export { default as createFormatter } from './createFormatter';
|
|
9
|
+
export { default as createIntl } from './createIntl';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* For the strictly typed messages to work we have to wrap the namespace into
|
|
3
|
-
* a mandatory prefix. See https://stackoverflow.com/a/71529575/343045
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { resolveNamespace as default };
|
|
1
|
+
/**
|
|
2
|
+
* For the strictly typed messages to work we have to wrap the namespace into
|
|
3
|
+
* a mandatory prefix. See https://stackoverflow.com/a/71529575/343045
|
|
4
|
+
*/
|
|
5
|
+
export default function resolveNamespace(namespace: string, namespacePrefix: string): string | undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { inheritsLoose as _inheritsLoose, wrapNativeSuper as _wrapNativeSuper } from '../_virtual/use-intl.esm.js';
|
|
2
|
+
|
|
3
|
+
var IntlErrorCode;
|
|
4
|
+
(function (IntlErrorCode) {
|
|
5
|
+
IntlErrorCode["MISSING_MESSAGE"] = "MISSING_MESSAGE";
|
|
6
|
+
IntlErrorCode["MISSING_FORMAT"] = "MISSING_FORMAT";
|
|
7
|
+
IntlErrorCode["INSUFFICIENT_PATH"] = "INSUFFICIENT_PATH";
|
|
8
|
+
IntlErrorCode["INVALID_MESSAGE"] = "INVALID_MESSAGE";
|
|
9
|
+
IntlErrorCode["INVALID_KEY"] = "INVALID_KEY";
|
|
10
|
+
IntlErrorCode["FORMATTING_ERROR"] = "FORMATTING_ERROR";
|
|
11
|
+
})(IntlErrorCode || (IntlErrorCode = {}));
|
|
12
|
+
var IntlError = /*#__PURE__*/function (_Error) {
|
|
13
|
+
_inheritsLoose(IntlError, _Error);
|
|
14
|
+
function IntlError(code, originalMessage) {
|
|
15
|
+
var _this;
|
|
16
|
+
var message = code;
|
|
17
|
+
if (originalMessage) {
|
|
18
|
+
message += ': ' + originalMessage;
|
|
19
|
+
}
|
|
20
|
+
_this = _Error.call(this, message) || this;
|
|
21
|
+
_this.code = void 0;
|
|
22
|
+
_this.originalMessage = void 0;
|
|
23
|
+
_this.code = code;
|
|
24
|
+
if (originalMessage) {
|
|
25
|
+
_this.originalMessage = originalMessage;
|
|
26
|
+
}
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
return IntlError;
|
|
30
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
31
|
+
|
|
32
|
+
export { IntlErrorCode, IntlError as default };
|
|
33
|
+
//# sourceMappingURL=use-intl.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-intl.esm.js","sources":["../../src/core/IntlError.tsx"],"sourcesContent":["export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR'\n}\n\nexport default class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n"],"names":["IntlErrorCode","IntlError","_Error","_inheritsLoose","code","originalMessage","_this","message","call","_wrapNativeSuper","Error"],"mappings":";;IAAYA,cAOX;AAPD,CAAA,UAAYA,aAAa,EAAA;AACvBA,EAAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnCA,EAAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,gBAAiC,CAAA;AACjCA,EAAAA,aAAA,CAAA,mBAAA,CAAA,GAAA,mBAAuC,CAAA;AACvCA,EAAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnCA,EAAAA,aAAA,CAAA,aAAA,CAAA,GAAA,aAA2B,CAAA;AAC3BA,EAAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC,CAAA;AACvC,CAAC,EAPWA,aAAa,KAAbA,aAAa,GAOxB,EAAA,CAAA,CAAA,CAAA;AAEoBC,IAAAA,SAAU,0BAAAC,MAAA,EAAA;EAAAC,cAAA,CAAAF,SAAA,EAAAC,MAAA,CAAA,CAAA;AAI7B,EAAA,SAAAD,SAAYG,CAAAA,IAAmB,EAAEC,eAAwB,EAAA;AAAA,IAAA,IAAAC,KAAA,CAAA;IACvD,IAAIC,OAAO,GAAWH,IAAI,CAAA;AAC1B,IAAA,IAAIC,eAAe,EAAE;MACnBE,OAAO,IAAI,IAAI,GAAGF,eAAe,CAAA;AAClC,KAAA;AACDC,IAAAA,KAAA,GAAAJ,MAAA,CAAAM,IAAA,CAAA,IAAA,EAAMD,OAAO,CAAC,IAAA,IAAA,CAAA;AAACD,IAAAA,KAAA,CARDF,IAAI,GAAA,KAAA,CAAA,CAAA;AAAAE,IAAAA,KAAA,CACJD,eAAe,GAAA,KAAA,CAAA,CAAA;IAS7BC,KAAA,CAAKF,IAAI,GAAGA,IAAI,CAAA;AAChB,IAAA,IAAIC,eAAe,EAAE;MACnBC,KAAA,CAAKD,eAAe,GAAGA,eAAe,CAAA;AACvC,KAAA;AAAA,IAAA,OAAAC,KAAA,CAAA;AACH,GAAA;AAAC,EAAA,OAAAL,SAAA,CAAA;AAAA,CAAAQ,eAAAA,gBAAA,CAfoCC,KAAK,CAAA;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { extends as _extends } from '../_virtual/use-intl.esm.js';
|
|
2
|
+
|
|
3
|
+
function setTimeZoneInFormats(formats, timeZone) {
|
|
4
|
+
if (!formats) return formats;
|
|
5
|
+
// The only way to set a time zone with `intl-messageformat` is to merge it into the formats
|
|
6
|
+
// https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15
|
|
7
|
+
return Object.keys(formats).reduce(function (acc, key) {
|
|
8
|
+
acc[key] = _extends({
|
|
9
|
+
timeZone: timeZone
|
|
10
|
+
}, formats[key]);
|
|
11
|
+
return acc;
|
|
12
|
+
}, {});
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `intl-messageformat` uses separate keys for `date` and `time`, but there's
|
|
16
|
+
* only one native API: `Intl.DateTimeFormat`. Additionally you might want to
|
|
17
|
+
* include both a time and a date in a value, therefore the separation doesn't
|
|
18
|
+
* seem so useful. We offer a single `dateTime` namespace instead, but we have
|
|
19
|
+
* to convert the format before `intl-messageformat` can be used.
|
|
20
|
+
*/
|
|
21
|
+
function convertFormatsToIntlMessageFormat(formats, timeZone) {
|
|
22
|
+
var formatsWithTimeZone = timeZone ? _extends({}, formats, {
|
|
23
|
+
dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)
|
|
24
|
+
}) : formats;
|
|
25
|
+
return _extends({}, formatsWithTimeZone, {
|
|
26
|
+
date: formatsWithTimeZone == null ? void 0 : formatsWithTimeZone.dateTime,
|
|
27
|
+
time: formatsWithTimeZone == null ? void 0 : formatsWithTimeZone.dateTime
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { convertFormatsToIntlMessageFormat as default };
|
|
32
|
+
//# sourceMappingURL=use-intl.esm10.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-intl.esm10.js","sources":["../../src/core/convertFormatsToIntlMessageFormat.tsx"],"sourcesContent":["import {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport TimeZone from './TimeZone';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: TimeZone\n) {\n if (!formats) return formats;\n\n // The only way to set a time zone with `intl-messageformat` is to merge it into the formats\n // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15\n return Object.keys(formats).reduce(\n (acc: Record<string, DateTimeFormatOptions>, key) => {\n acc[key] = {\n timeZone,\n ...formats[key]\n };\n return acc;\n },\n {}\n );\n}\n\n/**\n * `intl-messageformat` uses separate keys for `date` and `time`, but there's\n * only one native API: `Intl.DateTimeFormat`. Additionally you might want to\n * include both a time and a date in a value, therefore the separation doesn't\n * seem so useful. We offer a single `dateTime` namespace instead, but we have\n * to convert the format before `intl-messageformat` can be used.\n */\nexport default function convertFormatsToIntlMessageFormat(\n formats: Partial<Formats>,\n timeZone?: TimeZone\n): Partial<IntlFormats> {\n const formatsWithTimeZone = timeZone\n ? {...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)}\n : formats;\n\n return {\n ...formatsWithTimeZone,\n date: formatsWithTimeZone?.dateTime,\n time: formatsWithTimeZone?.dateTime\n };\n}\n"],"names":["setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","key","_extends","convertFormatsToIntlMessageFormat","formatsWithTimeZone","dateTime","date","time"],"mappings":";;AAKA,SAASA,oBAAoBA,CAC3BC,OAA0D,EAC1DC,QAAkB,EAAA;AAElB,EAAA,IAAI,CAACD,OAAO,EAAE,OAAOA,OAAO,CAAA;AAE5B;AACA;AACA,EAAA,OAAOE,MAAM,CAACC,IAAI,CAACH,OAAO,CAAC,CAACI,MAAM,CAChC,UAACC,GAA0C,EAAEC,GAAG,EAAI;AAClDD,IAAAA,GAAG,CAACC,GAAG,CAAC,GAAAC,QAAA,CAAA;AACNN,MAAAA,QAAQ,EAARA,QAAAA;AAAQ,KAAA,EACLD,OAAO,CAACM,GAAG,CAAC,CAChB,CAAA;AACD,IAAA,OAAOD,GAAG,CAAA;GACX,EACD,EAAE,CACH,CAAA;AACH,CAAA;AAEA;;;;;;AAMG;AACW,SAAUG,iCAAiCA,CACvDR,OAAyB,EACzBC,QAAmB,EAAA;AAEnB,EAAA,IAAMQ,mBAAmB,GAAGR,QAAQ,GAAAM,QAAA,KAC5BP,OAAO,EAAA;AAAEU,IAAAA,QAAQ,EAAEX,oBAAoB,CAACC,OAAO,CAACU,QAAQ,EAAET,QAAQ,CAAA;AAAC,GAAA,CAAA,GACvED,OAAO,CAAA;EAEX,OAAAO,QAAA,KACKE,mBAAmB,EAAA;AACtBE,IAAAA,IAAI,EAAEF,mBAAmB,IAAnBA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,mBAAmB,CAAEC,QAAQ;AACnCE,IAAAA,IAAI,EAAEH,mBAAmB,IAAnBA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,mBAAmB,CAAEC,QAAAA;AAAQ,GAAA,CAAA,CAAA;AAEvC;;;;"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { extends as _extends } from '../_virtual/use-intl.esm.js';
|
|
2
|
+
import IntlError, { IntlErrorCode } from './use-intl.esm.js';
|
|
3
|
+
import { defaultOnError } from './use-intl.esm5.js';
|
|
4
|
+
|
|
5
|
+
var MINUTE = 60;
|
|
6
|
+
var HOUR = MINUTE * 60;
|
|
7
|
+
var DAY = HOUR * 24;
|
|
8
|
+
var WEEK = DAY * 7;
|
|
9
|
+
var MONTH = DAY * (365 / 12); // Approximation
|
|
10
|
+
var YEAR = DAY * 365;
|
|
11
|
+
function getRelativeTimeFormatConfig(seconds) {
|
|
12
|
+
var absValue = Math.abs(seconds);
|
|
13
|
+
var value, unit;
|
|
14
|
+
// We have to round the resulting values, as `Intl.RelativeTimeFormat`
|
|
15
|
+
// will include fractions like '2.1 hours ago'.
|
|
16
|
+
if (absValue < MINUTE) {
|
|
17
|
+
unit = 'second';
|
|
18
|
+
value = Math.round(seconds);
|
|
19
|
+
} else if (absValue < HOUR) {
|
|
20
|
+
unit = 'minute';
|
|
21
|
+
value = Math.round(seconds / MINUTE);
|
|
22
|
+
} else if (absValue < DAY) {
|
|
23
|
+
unit = 'hour';
|
|
24
|
+
value = Math.round(seconds / HOUR);
|
|
25
|
+
} else if (absValue < WEEK) {
|
|
26
|
+
unit = 'day';
|
|
27
|
+
value = Math.round(seconds / DAY);
|
|
28
|
+
} else if (absValue < MONTH) {
|
|
29
|
+
unit = 'week';
|
|
30
|
+
value = Math.round(seconds / WEEK);
|
|
31
|
+
} else if (absValue < YEAR) {
|
|
32
|
+
unit = 'month';
|
|
33
|
+
value = Math.round(seconds / MONTH);
|
|
34
|
+
} else {
|
|
35
|
+
unit = 'year';
|
|
36
|
+
value = Math.round(seconds / YEAR);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
value: value,
|
|
40
|
+
unit: unit
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function createFormatter(_ref) {
|
|
44
|
+
var formats = _ref.formats,
|
|
45
|
+
locale = _ref.locale,
|
|
46
|
+
globalNow = _ref.now,
|
|
47
|
+
_ref$onError = _ref.onError,
|
|
48
|
+
onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
|
|
49
|
+
timeZone = _ref.timeZone;
|
|
50
|
+
function resolveFormatOrOptions(typeFormats, formatOrOptions) {
|
|
51
|
+
var options;
|
|
52
|
+
if (typeof formatOrOptions === 'string') {
|
|
53
|
+
var formatName = formatOrOptions;
|
|
54
|
+
options = typeFormats == null ? void 0 : typeFormats[formatName];
|
|
55
|
+
if (!options) {
|
|
56
|
+
var error = new IntlError(IntlErrorCode.MISSING_FORMAT, process.env.NODE_ENV !== 'production' ? "Format `" + formatName + "` is not available. You can configure it on the provider or provide custom options." : undefined);
|
|
57
|
+
onError(error);
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
options = formatOrOptions;
|
|
62
|
+
}
|
|
63
|
+
return options;
|
|
64
|
+
}
|
|
65
|
+
function getFormattedValue(value, formatOrOptions, typeFormats, formatter) {
|
|
66
|
+
var options;
|
|
67
|
+
try {
|
|
68
|
+
options = resolveFormatOrOptions(typeFormats, formatOrOptions);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
return String(value);
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
return formatter(options);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
|
|
76
|
+
return String(value);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function dateTime( /** If a number is supplied, this is interpreted as a UTC timestamp. */
|
|
80
|
+
value,
|
|
81
|
+
/** If a time zone is supplied, the `value` is converted to that time zone.
|
|
82
|
+
* Otherwise the user time zone will be used. */
|
|
83
|
+
formatOrOptions) {
|
|
84
|
+
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.dateTime, function (options) {
|
|
85
|
+
var _options;
|
|
86
|
+
if (timeZone && !((_options = options) != null && _options.timeZone)) {
|
|
87
|
+
options = _extends({}, options, {
|
|
88
|
+
timeZone: timeZone
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return new Intl.DateTimeFormat(locale, options).format(value);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function number(value, formatOrOptions) {
|
|
95
|
+
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.number, function (options) {
|
|
96
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function relativeTime( /** The date time that needs to be formatted. */
|
|
100
|
+
date, /** The reference point in time to which `date` will be formatted in relation to. */
|
|
101
|
+
now) {
|
|
102
|
+
try {
|
|
103
|
+
if (!now) {
|
|
104
|
+
if (globalNow) {
|
|
105
|
+
now = globalNow;
|
|
106
|
+
} else {
|
|
107
|
+
throw new Error(process.env.NODE_ENV !== 'production' ? "The `now` parameter wasn't provided and there was no global fallback configured on the provider." : undefined);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
var dateDate = date instanceof Date ? date : new Date(date);
|
|
111
|
+
var nowDate = now instanceof Date ? now : new Date(now);
|
|
112
|
+
var seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;
|
|
113
|
+
var _getRelativeTimeForma = getRelativeTimeFormatConfig(seconds),
|
|
114
|
+
unit = _getRelativeTimeForma.unit,
|
|
115
|
+
value = _getRelativeTimeForma.value;
|
|
116
|
+
return new Intl.RelativeTimeFormat(locale, {
|
|
117
|
+
numeric: 'auto'
|
|
118
|
+
}).format(value, unit);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
|
|
121
|
+
return String(date);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function list(value, formatOrOptions) {
|
|
125
|
+
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.list, function (options) {
|
|
126
|
+
return new Intl.ListFormat(locale, options).format(value);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
dateTime: dateTime,
|
|
131
|
+
number: number,
|
|
132
|
+
relativeTime: relativeTime,
|
|
133
|
+
list: list
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { createFormatter as default };
|
|
138
|
+
//# sourceMappingURL=use-intl.esm2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-intl.esm2.js","sources":["../../src/core/createFormatter.tsx"],"sourcesContent":["import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport TimeZone from './TimeZone';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n function list(\n value: Iterable<string>,\n formatOrOptions?: string | Intl.ListFormatOptions\n ) {\n return getFormattedValue(value, formatOrOptions, formats?.list, (options) =>\n new Intl.ListFormat(locale, options).format(value)\n );\n }\n\n return {dateTime, number, relativeTime, list};\n}\n"],"names":["MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","Math","abs","value","unit","round","createFormatter","_ref","formats","locale","globalNow","now","_ref$onError","onError","defaultOnError","timeZone","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","error","IntlError","IntlErrorCode","MISSING_FORMAT","process","env","NODE_ENV","undefined","getFormattedValue","formatter","String","FORMATTING_ERROR","message","dateTime","_options","_extends","Intl","DateTimeFormat","format","number","NumberFormat","relativeTime","date","Error","dateDate","Date","nowDate","getTime","_getRelativeTimeForma","RelativeTimeFormat","numeric","list","ListFormat"],"mappings":";;;;AAOA,IAAMA,MAAM,GAAG,EAAE,CAAA;AACjB,IAAMC,IAAI,GAAGD,MAAM,GAAG,EAAE,CAAA;AACxB,IAAME,GAAG,GAAGD,IAAI,GAAG,EAAE,CAAA;AACrB,IAAME,IAAI,GAAGD,GAAG,GAAG,CAAC,CAAA;AACpB,IAAME,KAAK,GAAGF,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC,CAAC;AAC/B,IAAMG,IAAI,GAAGH,GAAG,GAAG,GAAG,CAAA;AAEtB,SAASI,2BAA2BA,CAACC,OAAe,EAAA;AAClD,EAAA,IAAMC,QAAQ,GAAGC,IAAI,CAACC,GAAG,CAACH,OAAO,CAAC,CAAA;EAClC,IAAII,KAAK,EAAEC,IAAiC,CAAA;AAE5C;AACA;EAEA,IAAIJ,QAAQ,GAAGR,MAAM,EAAE;AACrBY,IAAAA,IAAI,GAAG,QAAQ,CAAA;AACfD,IAAAA,KAAK,GAAGF,IAAI,CAACI,KAAK,CAACN,OAAO,CAAC,CAAA;AAC5B,GAAA,MAAM,IAAIC,QAAQ,GAAGP,IAAI,EAAE;AAC1BW,IAAAA,IAAI,GAAG,QAAQ,CAAA;IACfD,KAAK,GAAGF,IAAI,CAACI,KAAK,CAACN,OAAO,GAAGP,MAAM,CAAC,CAAA;AACrC,GAAA,MAAM,IAAIQ,QAAQ,GAAGN,GAAG,EAAE;AACzBU,IAAAA,IAAI,GAAG,MAAM,CAAA;IACbD,KAAK,GAAGF,IAAI,CAACI,KAAK,CAACN,OAAO,GAAGN,IAAI,CAAC,CAAA;AACnC,GAAA,MAAM,IAAIO,QAAQ,GAAGL,IAAI,EAAE;AAC1BS,IAAAA,IAAI,GAAG,KAAK,CAAA;IACZD,KAAK,GAAGF,IAAI,CAACI,KAAK,CAACN,OAAO,GAAGL,GAAG,CAAC,CAAA;AAClC,GAAA,MAAM,IAAIM,Q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.esm2.js';
|
|
2
|
+
|
|
3
|
+
/** @deprecated Switch to `createFormatter` */
|
|
4
|
+
function createIntl() {
|
|
5
|
+
var formatter = createFormatter.apply(void 0, arguments);
|
|
6
|
+
return {
|
|
7
|
+
formatDateTime: formatter.dateTime,
|
|
8
|
+
formatNumber: formatter.number,
|
|
9
|
+
formatRelativeTime: formatter.relativeTime
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { createIntl as default };
|
|
14
|
+
//# sourceMappingURL=use-intl.esm3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-intl.esm3.js","sources":["../../src/core/createIntl.tsx"],"sourcesContent":["import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n"],"names":["createIntl","formatter","createFormatter","apply","arguments","formatDateTime","dateTime","formatNumber","number","formatRelativeTime","relativeTime"],"mappings":";;AAEA;AACc,SAAUA,UAAUA,GACW;AAE3C,EAAA,IAAMC,SAAS,GAAGC,eAAe,CAAAC,KAAA,CAAA,KAAA,CAAA,EAAAC,SAAQ,CAAC,CAAA;EAC1C,OAAO;IACLC,cAAc,EAAEJ,SAAS,CAACK,QAAQ;IAClCC,YAAY,EAAEN,SAAS,CAACO,MAAM;IAC9BC,kBAAkB,EAAER,SAAS,CAACS,YAAAA;GAC/B,CAAA;AACH;;;;"}
|