Comparing version 0.3.1 to 0.3.2
# Changelog | ||
## 0.3.2 | ||
- Fix: Export `IntlErrorCode` for JavaScript users. | ||
## 0.3.1 | ||
- Fix: Return a stable function reference for `t`. |
@@ -1,2 +0,2 @@ | ||
export declare const enum IntlErrorCode { | ||
export declare enum IntlErrorCode { | ||
MISSING_MESSAGE = "MISSING_MESSAGE", | ||
@@ -3,0 +3,0 @@ MISSING_FORMAT = "MISSING_FORMAT", |
@@ -160,2 +160,10 @@ 'use strict'; | ||
(function (IntlErrorCode) { | ||
IntlErrorCode["MISSING_MESSAGE"] = "MISSING_MESSAGE"; | ||
IntlErrorCode["MISSING_FORMAT"] = "MISSING_FORMAT"; | ||
IntlErrorCode["INSUFFICIENT_PATH"] = "INSUFFICIENT_PATH"; | ||
IntlErrorCode["INVALID_MESSAGE"] = "INVALID_MESSAGE"; | ||
IntlErrorCode["FORMATTING_ERROR"] = "FORMATTING_ERROR"; | ||
})(exports.IntlErrorCode || (exports.IntlErrorCode = {})); | ||
var IntlError = /*#__PURE__*/function (_Error) { | ||
@@ -276,5 +284,3 @@ _inheritsLoose(IntlError, _Error); | ||
} catch (error) { | ||
var intlError = new IntlError("MISSING_MESSAGE" | ||
/* MISSING_MESSAGE */ | ||
, error.message); | ||
var intlError = new IntlError(exports.IntlErrorCode.MISSING_MESSAGE, error.message); | ||
onError(intlError); | ||
@@ -325,11 +331,7 @@ return intlError; | ||
} catch (error) { | ||
return getFallbackFromError("MISSING_MESSAGE" | ||
/* MISSING_MESSAGE */ | ||
, error.message); | ||
return getFallbackFromError(exports.IntlErrorCode.MISSING_MESSAGE, error.message); | ||
} | ||
if (typeof message === 'object') { | ||
return getFallbackFromError("INSUFFICIENT_PATH" | ||
/* INSUFFICIENT_PATH */ | ||
, "Insufficient path specified for `" + key + "` in `" + namespace + "`." ); | ||
return getFallbackFromError(exports.IntlErrorCode.INSUFFICIENT_PATH, "Insufficient path specified for `" + key + "` in `" + namespace + "`." ); | ||
} | ||
@@ -340,5 +342,3 @@ | ||
} catch (error) { | ||
return getFallbackFromError("INVALID_MESSAGE" | ||
/* INVALID_MESSAGE */ | ||
, error.message); | ||
return getFallbackFromError(exports.IntlErrorCode.INVALID_MESSAGE, error.message); | ||
} | ||
@@ -362,5 +362,3 @@ | ||
} catch (error) { | ||
return getFallbackFromError("FORMATTING_ERROR" | ||
/* FORMATTING_ERROR */ | ||
, error.message); | ||
return getFallbackFromError(exports.IntlErrorCode.FORMATTING_ERROR, error.message); | ||
} | ||
@@ -420,12 +418,10 @@ }, [getMessageFallback, globalFormats, locale, messagesOrError, namespace, onError]); | ||
function resolveFormatOrOptions(typeFormats, formatOrOptions) { | ||
var format; | ||
var options; | ||
if (typeof formatOrOptions === 'string') { | ||
var formatName = formatOrOptions; | ||
format = typeFormats == null ? void 0 : typeFormats[formatName]; | ||
options = typeFormats == null ? void 0 : typeFormats[formatName]; | ||
if (!format) { | ||
var error = new IntlError("MISSING_FORMAT" | ||
/* MISSING_FORMAT */ | ||
, "Format `" + formatName + "` is not available. You can configure it on the provider or provide custom options." ); | ||
if (!options) { | ||
var error = new IntlError(exports.IntlErrorCode.MISSING_FORMAT, "Format `" + formatName + "` is not available. You can configure it on the provider or provide custom options." ); | ||
onError(error); | ||
@@ -435,13 +431,13 @@ throw error; | ||
} else { | ||
format = formatOrOptions; | ||
options = formatOrOptions; | ||
} | ||
return format; | ||
return options; | ||
} | ||
function getFormattedValue(value, formatOrOptions, typeFormats, formatter) { | ||
var format; | ||
var options; | ||
try { | ||
format = resolveFormatOrOptions(typeFormats, formatOrOptions); | ||
options = resolveFormatOrOptions(typeFormats, formatOrOptions); | ||
} catch (error) { | ||
@@ -452,7 +448,5 @@ return String(value); | ||
try { | ||
return formatter(format); | ||
return formatter(options); | ||
} catch (error) { | ||
onError(new IntlError("FORMATTING_ERROR" | ||
/* FORMATTING_ERROR */ | ||
, error.message)); | ||
onError(new IntlError(exports.IntlErrorCode.FORMATTING_ERROR, error.message)); | ||
return String(value); | ||
@@ -463,4 +457,4 @@ } | ||
function formatDateTime(value, formatOrOptions) { | ||
return getFormattedValue(value, formatOrOptions, _extends({}, formats == null ? void 0 : formats.dateTime), function (format) { | ||
return new Intl.DateTimeFormat(locale, format).format(value); | ||
return getFormattedValue(value, formatOrOptions, _extends({}, formats == null ? void 0 : formats.dateTime), function (options) { | ||
return new Intl.DateTimeFormat(locale, options).format(value); | ||
}); | ||
@@ -470,4 +464,4 @@ } | ||
function formatNumber(value, formatOrOptions) { | ||
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.number, function (format) { | ||
return new Intl.NumberFormat(locale, format).format(value); | ||
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.number, function (options) { | ||
return new Intl.NumberFormat(locale, options).format(value); | ||
}); | ||
@@ -490,5 +484,3 @@ } | ||
} catch (error) { | ||
onError(new IntlError("FORMATTING_ERROR" | ||
/* FORMATTING_ERROR */ | ||
, error.message)); | ||
onError(new IntlError(exports.IntlErrorCode.FORMATTING_ERROR, error.message)); | ||
return String(date); | ||
@@ -495,0 +487,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=r(t),n=r(require("intl-messageformat"));function o(){return(o=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r}).apply(this,arguments)}function u(r){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function a(r,t){return(a=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r})(r,t)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(r){return!1}}function c(r,t,e){return(c=i()?Reflect.construct:function(r,t,e){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(r,n));return e&&a(o,e.prototype),o}).apply(null,arguments)}function f(r){var t="function"==typeof Map?new Map:void 0;return(f=function(r){if(null===r||-1===Function.toString.call(r).indexOf("[native code]"))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,e)}function e(){return c(r,arguments,u(this).constructor)}return e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),a(e,r)})(r)}var l=t.createContext(void 0);function s(r){return[r.namespace,r.key].filter((function(r){return null!=r})).join(".")}var v=function(r){var t,e;function n(t,e){var n,o=t;return e&&(o+=": "+e),(n=r.call(this,o)||this).code=t,e&&(n.originalMessage=e),n}return e=r,(t=n).prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e,n}(f(Error));function p(){var r=t.useContext(l);if(!r)throw new Error(void 0);return r}function m(r,t,e){var n=r;return t.split(".").forEach((function(r){var t=n[r];if(null==r||null==t)throw new Error(void 0);n=t})),n}exports.IntlError=v,exports.IntlProvider=function(r){var t=r.children,n=r.onError,u=void 0===n?console.error:n,a=r.getMessageFallback,i=void 0===a?s:a,c=function(r,t){if(null==r)return{};var e,n,o={},u=Object.keys(r);for(n=0;n<u.length;n++)t.indexOf(e=u[n])>=0||(o[e]=r[e]);return o}(r,["children","onError","getMessageFallback"]);return e.createElement(l.Provider,{value:o({},c,{onError:u,getMessageFallback:i})},t)},exports.useIntl=function(){var r=p(),t=r.formats,e=r.locale,n=r.onError;function u(r,t,e,o){var u;try{u=function(r,t){var e;if("string"==typeof t){if(!(e=null==r?void 0:r[t])){var o=new v("MISSING_FORMAT",void 0);throw n(o),o}}else e=t;return e}(e,t)}catch(t){return String(r)}try{return o(u)}catch(t){return n(new v("FORMATTING_ERROR",t.message)),String(r)}}return{formatDateTime:function(r,n){return u(r,n,o({},null==t?void 0:t.dateTime),(function(t){return new Intl.DateTimeFormat(e,t).format(r)}))},formatNumber:function(r,n){return u(r,n,null==t?void 0:t.number,(function(t){return new Intl.NumberFormat(e,t).format(r)}))},formatRelativeTime:function(r,t){var o=r instanceof Date?r:new Date(r),u=t instanceof Date?t:new Date(t),a=function(r){var t,e,n=Math.abs(r);return n<60?(e="second",t=Math.round(r)):n<3600?(e="minute",t=Math.round(r/60)):n<86400?(e="hour",t=Math.round(r/3600)):n<604800?(e="day",t=Math.round(r/86400)):n<2628e3?(e="week",t=Math.round(r/604800)):n<31536e3?(e="month",t=Math.round(r/2628e3)):(e="year",t=Math.round(r/31536e3)),{value:t,unit:e}}((o.getTime()-u.getTime())/1e3),i=a.unit,c=a.value;try{return new Intl.RelativeTimeFormat(e,{numeric:"auto"}).format(c,i)}catch(t){return n(new v("FORMATTING_ERROR",t.message)),String(r)}}}},exports.useTranslations=function(r){var e=p(),u=e.formats,a=e.getMessageFallback,i=e.locale,c=e.messages,f=e.onError,l=t.useRef({}),s=t.useMemo((function(){try{var t=r?m(c,r):c;if(!t)throw new Error(void 0);return t}catch(r){var e=new v("MISSING_MESSAGE",r.message);return f(e),e}}),[c,r,f]);return t.useCallback((function(e,c,p){var d,y=l.current;function h(t,n){var o=new v(t,n);return f(o),a({error:o,key:e,namespace:r})}if(s instanceof v)return a({error:s,key:e,namespace:r});var g,b=s;if(null!=(d=y[i])&&d[e])g=y[i][e];else{var w;try{w=m(b,e)}catch(r){return h("MISSING_MESSAGE",r.message)}if("object"==typeof w)return h("INSUFFICIENT_PATH",void 0);try{g=new n(w,i,function(r){return o({},r,{date:null==r?void 0:r.dateTime,time:null==r?void 0:r.dateTime})}(o({},u,p)))}catch(r){return h("INVALID_MESSAGE",r.message)}y[i]||(y[i]={}),y[i][e]=g}try{var E=g.format(function(r){if(!r)return r;var e={};return Object.keys(r).forEach((function(n){var o=r[n];e[n]="function"==typeof o?function(r){var e=o(r);return t.isValidElement(e)?t.cloneElement(e,{key:e.key||n+String(r)}):e}:o})),e}(c));if(null==E)throw new Error(void 0);return E}catch(r){return h("FORMATTING_ERROR",r.message)}}),[a,u,i,s,r,f])}; | ||
"use strict";function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=r(t),n=r(require("intl-messageformat"));function o(){return(o=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r}).apply(this,arguments)}function u(r){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function a(r,t){return(a=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r})(r,t)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(r){return!1}}function c(r,t,e){return(c=i()?Reflect.construct:function(r,t,e){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(r,n));return e&&a(o,e.prototype),o}).apply(null,arguments)}function f(r){var t="function"==typeof Map?new Map:void 0;return(f=function(r){if(null===r||-1===Function.toString.call(r).indexOf("[native code]"))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,e)}function e(){return c(r,arguments,u(this).constructor)}return e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),a(e,r)})(r)}var l,s=t.createContext(void 0);function p(r){return[r.namespace,r.key].filter((function(r){return null!=r})).join(".")}(l=exports.IntlErrorCode||(exports.IntlErrorCode={})).MISSING_MESSAGE="MISSING_MESSAGE",l.MISSING_FORMAT="MISSING_FORMAT",l.INSUFFICIENT_PATH="INSUFFICIENT_PATH",l.INVALID_MESSAGE="INVALID_MESSAGE",l.FORMATTING_ERROR="FORMATTING_ERROR";var v=function(r){var t,e;function n(t,e){var n,o=t;return e&&(o+=": "+e),(n=r.call(this,o)||this).code=t,e&&(n.originalMessage=e),n}return e=r,(t=n).prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e,n}(f(Error));function d(){var r=t.useContext(s);if(!r)throw new Error(void 0);return r}function I(r,t,e){var n=r;return t.split(".").forEach((function(r){var t=n[r];if(null==r||null==t)throw new Error(void 0);n=t})),n}exports.IntlError=v,exports.IntlProvider=function(r){var t=r.children,n=r.onError,u=void 0===n?console.error:n,a=r.getMessageFallback,i=void 0===a?p:a,c=function(r,t){if(null==r)return{};var e,n,o={},u=Object.keys(r);for(n=0;n<u.length;n++)t.indexOf(e=u[n])>=0||(o[e]=r[e]);return o}(r,["children","onError","getMessageFallback"]);return e.createElement(s.Provider,{value:o({},c,{onError:u,getMessageFallback:i})},t)},exports.useIntl=function(){var r=d(),t=r.formats,e=r.locale,n=r.onError;function u(r,t,e,o){var u;try{u=function(r,t){var e;if("string"==typeof t){if(!(e=null==r?void 0:r[t])){var o=new v(exports.IntlErrorCode.MISSING_FORMAT,void 0);throw n(o),o}}else e=t;return e}(e,t)}catch(t){return String(r)}try{return o(u)}catch(t){return n(new v(exports.IntlErrorCode.FORMATTING_ERROR,t.message)),String(r)}}return{formatDateTime:function(r,n){return u(r,n,o({},null==t?void 0:t.dateTime),(function(t){return new Intl.DateTimeFormat(e,t).format(r)}))},formatNumber:function(r,n){return u(r,n,null==t?void 0:t.number,(function(t){return new Intl.NumberFormat(e,t).format(r)}))},formatRelativeTime:function(r,t){var o=r instanceof Date?r:new Date(r),u=t instanceof Date?t:new Date(t),a=function(r){var t,e,n=Math.abs(r);return n<60?(e="second",t=Math.round(r)):n<3600?(e="minute",t=Math.round(r/60)):n<86400?(e="hour",t=Math.round(r/3600)):n<604800?(e="day",t=Math.round(r/86400)):n<2628e3?(e="week",t=Math.round(r/604800)):n<31536e3?(e="month",t=Math.round(r/2628e3)):(e="year",t=Math.round(r/31536e3)),{value:t,unit:e}}((o.getTime()-u.getTime())/1e3),i=a.unit,c=a.value;try{return new Intl.RelativeTimeFormat(e,{numeric:"auto"}).format(c,i)}catch(t){return n(new v(exports.IntlErrorCode.FORMATTING_ERROR,t.message)),String(r)}}}},exports.useTranslations=function(r){var e=d(),u=e.formats,a=e.getMessageFallback,i=e.locale,c=e.messages,f=e.onError,l=t.useRef({}),s=t.useMemo((function(){try{var t=r?I(c,r):c;if(!t)throw new Error(void 0);return t}catch(r){var e=new v(exports.IntlErrorCode.MISSING_MESSAGE,r.message);return f(e),e}}),[c,r,f]);return t.useCallback((function(e,c,p){var d,E=l.current;function m(t,n){var o=new v(t,n);return f(o),a({error:o,key:e,namespace:r})}if(s instanceof v)return a({error:s,key:e,namespace:r});var y,h=s;if(null!=(d=E[i])&&d[e])y=E[i][e];else{var M;try{M=I(h,e)}catch(r){return m(exports.IntlErrorCode.MISSING_MESSAGE,r.message)}if("object"==typeof M)return m(exports.IntlErrorCode.INSUFFICIENT_PATH,void 0);try{y=new n(M,i,function(r){return o({},r,{date:null==r?void 0:r.dateTime,time:null==r?void 0:r.dateTime})}(o({},u,p)))}catch(r){return m(exports.IntlErrorCode.INVALID_MESSAGE,r.message)}E[i]||(E[i]={}),E[i][e]=y}try{var S=y.format(function(r){if(!r)return r;var e={};return Object.keys(r).forEach((function(n){var o=r[n];e[n]="function"==typeof o?function(r){var e=o(r);return t.isValidElement(e)?t.cloneElement(e,{key:e.key||n+String(r)}):e}:o})),e}(c));if(null==S)throw new Error(void 0);return S}catch(r){return m(exports.IntlErrorCode.FORMATTING_ERROR,r.message)}}),[a,u,i,s,r,f])}; | ||
//# sourceMappingURL=use-intl.cjs.production.min.js.map |
@@ -153,2 +153,12 @@ import React, { createContext, useContext, useRef, useMemo, useCallback, isValidElement, cloneElement } from 'react'; | ||
var IntlErrorCode; | ||
(function (IntlErrorCode) { | ||
IntlErrorCode["MISSING_MESSAGE"] = "MISSING_MESSAGE"; | ||
IntlErrorCode["MISSING_FORMAT"] = "MISSING_FORMAT"; | ||
IntlErrorCode["INSUFFICIENT_PATH"] = "INSUFFICIENT_PATH"; | ||
IntlErrorCode["INVALID_MESSAGE"] = "INVALID_MESSAGE"; | ||
IntlErrorCode["FORMATTING_ERROR"] = "FORMATTING_ERROR"; | ||
})(IntlErrorCode || (IntlErrorCode = {})); | ||
var IntlError = /*#__PURE__*/function (_Error) { | ||
@@ -269,5 +279,3 @@ _inheritsLoose(IntlError, _Error); | ||
} catch (error) { | ||
var intlError = new IntlError("MISSING_MESSAGE" | ||
/* MISSING_MESSAGE */ | ||
, error.message); | ||
var intlError = new IntlError(IntlErrorCode.MISSING_MESSAGE, error.message); | ||
onError(intlError); | ||
@@ -318,11 +326,7 @@ return intlError; | ||
} catch (error) { | ||
return getFallbackFromError("MISSING_MESSAGE" | ||
/* MISSING_MESSAGE */ | ||
, error.message); | ||
return getFallbackFromError(IntlErrorCode.MISSING_MESSAGE, error.message); | ||
} | ||
if (typeof message === 'object') { | ||
return getFallbackFromError("INSUFFICIENT_PATH" | ||
/* INSUFFICIENT_PATH */ | ||
, process.env.NODE_ENV !== "production" ? "Insufficient path specified for `" + key + "` in `" + namespace + "`." : undefined); | ||
return getFallbackFromError(IntlErrorCode.INSUFFICIENT_PATH, process.env.NODE_ENV !== "production" ? "Insufficient path specified for `" + key + "` in `" + namespace + "`." : undefined); | ||
} | ||
@@ -333,5 +337,3 @@ | ||
} catch (error) { | ||
return getFallbackFromError("INVALID_MESSAGE" | ||
/* INVALID_MESSAGE */ | ||
, error.message); | ||
return getFallbackFromError(IntlErrorCode.INVALID_MESSAGE, error.message); | ||
} | ||
@@ -355,5 +357,3 @@ | ||
} catch (error) { | ||
return getFallbackFromError("FORMATTING_ERROR" | ||
/* FORMATTING_ERROR */ | ||
, error.message); | ||
return getFallbackFromError(IntlErrorCode.FORMATTING_ERROR, error.message); | ||
} | ||
@@ -413,12 +413,10 @@ }, [getMessageFallback, globalFormats, locale, messagesOrError, namespace, onError]); | ||
function resolveFormatOrOptions(typeFormats, formatOrOptions) { | ||
var format; | ||
var options; | ||
if (typeof formatOrOptions === 'string') { | ||
var formatName = formatOrOptions; | ||
format = typeFormats == null ? void 0 : typeFormats[formatName]; | ||
options = typeFormats == null ? void 0 : typeFormats[formatName]; | ||
if (!format) { | ||
var error = new IntlError("MISSING_FORMAT" | ||
/* MISSING_FORMAT */ | ||
, process.env.NODE_ENV !== "production" ? "Format `" + formatName + "` is not available. You can configure it on the provider or provide custom options." : undefined); | ||
if (!options) { | ||
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); | ||
onError(error); | ||
@@ -428,13 +426,13 @@ throw error; | ||
} else { | ||
format = formatOrOptions; | ||
options = formatOrOptions; | ||
} | ||
return format; | ||
return options; | ||
} | ||
function getFormattedValue(value, formatOrOptions, typeFormats, formatter) { | ||
var format; | ||
var options; | ||
try { | ||
format = resolveFormatOrOptions(typeFormats, formatOrOptions); | ||
options = resolveFormatOrOptions(typeFormats, formatOrOptions); | ||
} catch (error) { | ||
@@ -445,7 +443,5 @@ return String(value); | ||
try { | ||
return formatter(format); | ||
return formatter(options); | ||
} catch (error) { | ||
onError(new IntlError("FORMATTING_ERROR" | ||
/* FORMATTING_ERROR */ | ||
, error.message)); | ||
onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message)); | ||
return String(value); | ||
@@ -456,4 +452,4 @@ } | ||
function formatDateTime(value, formatOrOptions) { | ||
return getFormattedValue(value, formatOrOptions, _extends({}, formats == null ? void 0 : formats.dateTime), function (format) { | ||
return new Intl.DateTimeFormat(locale, format).format(value); | ||
return getFormattedValue(value, formatOrOptions, _extends({}, formats == null ? void 0 : formats.dateTime), function (options) { | ||
return new Intl.DateTimeFormat(locale, options).format(value); | ||
}); | ||
@@ -463,4 +459,4 @@ } | ||
function formatNumber(value, formatOrOptions) { | ||
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.number, function (format) { | ||
return new Intl.NumberFormat(locale, format).format(value); | ||
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.number, function (options) { | ||
return new Intl.NumberFormat(locale, options).format(value); | ||
}); | ||
@@ -483,5 +479,3 @@ } | ||
} catch (error) { | ||
onError(new IntlError("FORMATTING_ERROR" | ||
/* FORMATTING_ERROR */ | ||
, error.message)); | ||
onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message)); | ||
return String(date); | ||
@@ -498,3 +492,3 @@ } | ||
export { IntlError, IntlProvider, useIntl, useTranslations }; | ||
export { IntlError, IntlErrorCode, IntlProvider, useIntl, useTranslations }; | ||
//# sourceMappingURL=use-intl.esm.js.map |
{ | ||
"name": "use-intl", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "author": "Jan Amann <jan@amann.me>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125079
1389
240
27
1
112