Comparing version 0.0.4 to 0.1.0
@@ -6,3 +6,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl/core | ||
@@ -237,3 +237,3 @@ */ | ||
* | ||
* @example // lang ru | ||
* @example // lang uk | ||
* getName('Bill', 'Gates') // "Gates Bill" | ||
@@ -245,3 +245,3 @@ * | ||
export function getName(lang, firstName, lastName) { | ||
var lastNamePriority = ['ru']; | ||
var lastNamePriority = ['uk', 'ru']; | ||
@@ -248,0 +248,0 @@ if (lastNamePriority.indexOf(lang) !== -1) { |
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl/DOM | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl | ||
@@ -4,0 +4,0 @@ */ |
@@ -10,3 +10,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl/wrapper | ||
@@ -13,0 +13,0 @@ */ |
/* | ||
* Copyright 2019, Pentatonica.co | ||
* PIntl v0.0.4 | ||
* Copyright 2019-2024, Peculiar Ventures | ||
* Copyright 2018-2019, Pentatonica.co | ||
* PIntl v0.1.0 | ||
*/ | ||
@@ -21,3 +22,3 @@ | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl/core | ||
@@ -252,3 +253,3 @@ */ | ||
* | ||
* @example // lang ru | ||
* @example // lang uk | ||
* getName('Bill', 'Gates') // "Gates Bill" | ||
@@ -260,3 +261,3 @@ * | ||
function getName(lang, firstName, lastName) { | ||
var lastNamePriority = ['ru']; | ||
var lastNamePriority = ['uk', 'ru']; | ||
@@ -391,3 +392,3 @@ if (lastNamePriority.indexOf(lang) !== -1) { | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl/DOM | ||
@@ -486,3 +487,3 @@ */ | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl | ||
@@ -489,0 +490,0 @@ */ |
/* | ||
* Copyright 2019, Pentatonica.co | ||
* PIntl v0.0.4 | ||
* Copyright 2019-2024, Peculiar Ventures | ||
* Copyright 2018-2019, Pentatonica.co | ||
* PIntl v0.1.0 | ||
*/ | ||
@@ -13,3 +14,3 @@ | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl/core | ||
@@ -197,3 +198,3 @@ */ | ||
* | ||
* @example // lang ru | ||
* @example // lang uk | ||
* getName('Bill', 'Gates') // "Gates Bill" | ||
@@ -205,3 +206,3 @@ * | ||
function getName(lang, firstName, lastName) { | ||
const lastNamePriority = ['ru']; | ||
const lastNamePriority = ['uk', 'ru']; | ||
@@ -249,3 +250,3 @@ if (lastNamePriority.indexOf(lang) !== -1) { | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl/wrapper | ||
@@ -315,3 +316,3 @@ */ | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl/DOM | ||
@@ -405,3 +406,3 @@ */ | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl | ||
@@ -408,0 +409,0 @@ */ |
@@ -1,1 +0,1 @@ | ||
import{Component}from"react";import PropTypes from"prop-types";var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function getObjectKey(e,t){var r=t.split("."),n=e,o=!0,i=!1,a=void 0;try{for(var l,u=r[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){var c=l.value;if(!n)return"";n=n[c]}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}return n}function pickContextArgument(e,t){var r=function(e){return e},n="";switch(!0){case"string"==typeof t:r=function(e){return e===t};break;case"number"==typeof t:r=function(e){var r=/(\d+)..(\d+)/.exec(e),n=/(-?\d+)(\+|-)/.exec(e);return e==t||null!==r&&r[1]<=t&&r[2]>=t||null!==n&&("+"===n[2]?t>=n[1]:t<=n[1])}}var o=!0,i=!1,a=void 0;try{for(var l,u=Object.keys(e)[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){var c=l.value;if(r(c)){n=e[c];break}}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}return!n&&e._&&(n=e._),n}function pickContext(e,t){var r={};return Object.keys(e).forEach(function(n){var o=e[n];"object"===(void 0===o?"undefined":_typeof(o))?r[n]=pickContextArgument(o,t):r[n]=o}),r}function prepareTextMessage(e,t){if(void 0===t)return e;var r=e;if("object"!==(void 0===t?"undefined":_typeof(t)))return r.replace("{arg}",t);var n=String(r).match(/{\w+}(?!\\)/g),o=[];return n&&n.forEach(function(e){if(-1===o.indexOf(e)){o.push(e);var n=prepareTextMessage(t[/\w+/.exec(e)[0]],t);"string"!=typeof n||n||(n=""),r=r.replace(e,n)}}),r}function getText(e,t,r,n,o){if(t)return o?"{{"+r+"."+o+"}}":"{{"+r+"}}";var i=getObjectKey(e,r);if(i){if("object"===(void 0===i?"undefined":_typeof(i))){var a=pickContext(i,o);if(i.message){var l=_extends({},a,n,{context:o});return prepareTextMessage(i.message,l)}return prepareTextMessage(pickContextArgument(i,o),_extends({},n,{context:o}))}return prepareTextMessage(i,n)}return""}function getName(e,t,r){return-1!==["ru"].indexOf(e)?(r+" "+t).trim():(t+" "+r).trim()}function getDate(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},n=t;if("string"==typeof t){if(!t)return"";n=new Date(t)}return new Intl.DateTimeFormat(e,r).format(n)}var core=Object.freeze({getText:getText,getName:getName,getDate:getDate}),_createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var IntlWrapper=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return _inherits(t,Component),_createClass(t,[{key:"getChildContext",value:function(){return{intl:{getText:getText.bind(null,this.props.messages,this.props.inShell),getName:getName.bind(null,this.props.lang),getDate:getDate.bind(null,this.props.lang),lang:this.props.lang}}}},{key:"render",value:function(){return this.props.children}}]),t}();IntlWrapper.propTypes={children:PropTypes.oneOfType([PropTypes.node,PropTypes.object]),lang:PropTypes.string,messages:PropTypes.object,inShell:PropTypes.bool},IntlWrapper.defaultProps={children:null,lang:"en",messages:{},inShell:!1},IntlWrapper.childContextTypes={intl:PropTypes.object};var ATTRIBUTE_NAME="data-localization-id",ARG_NAME="data-localization-arg";function getTranslatableChildren(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.documentElement;return e?e.querySelectorAll("*["+ATTRIBUTE_NAME+"]"):[]}function getElementAttributes(e){return e instanceof HTMLElement?{id:e.getAttribute(ATTRIBUTE_NAME),arg:e.getAttribute(ARG_NAME)}:{}}function getChildElementCount(e){if(e.children)return e.children.length;if(void 0!==e.childElementCount)return e.childElementCount;for(var t=0,r=0;r<e.childNodes.length;r+=1)t+=1===e.nodeType?1:0;return t}function translateElement(e,t){var r=getElementAttributes(t);if(!r.id)return!1;var n=getText(e,!1,r.id);if(r.arg)return t.setAttribute(r.arg,n),!1;var o=document.createTextNode(n);return 0===getChildElementCount(t)?t.firstChild?t.replaceChild(o,t.firstChild):t.appendChild(o):t.insertBefore(o,t.firstChild),!0}function translateFragment(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.documentElement,r=getTranslatableChildren(t),n=r.length,o=0;o<n;o+=1)translateElement(e,r[o]);translateElement(e,t)}var dom=Object.freeze({translateFragment:translateFragment});export{core as IntlCore,dom as IntlDOM,IntlWrapper}; | ||
import{Component}from"react";import PropTypes from"prop-types";var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function getObjectKey(e,t){var r=t.split("."),n=e,o=!0,i=!1,a=void 0;try{for(var l,u=r[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){var c=l.value;if(!n)return"";n=n[c]}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}return n}function pickContextArgument(e,t){var r=function(e){return e},n="";switch(!0){case"string"==typeof t:r=function(e){return e===t};break;case"number"==typeof t:r=function(e){var r=/(\d+)..(\d+)/.exec(e),n=/(-?\d+)(\+|-)/.exec(e);return e==t||null!==r&&r[1]<=t&&r[2]>=t||null!==n&&("+"===n[2]?t>=n[1]:t<=n[1])}}var o=!0,i=!1,a=void 0;try{for(var l,u=Object.keys(e)[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){var c=l.value;if(r(c)){n=e[c];break}}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}return!n&&e._&&(n=e._),n}function pickContext(e,t){var r={};return Object.keys(e).forEach(function(n){var o=e[n];"object"===(void 0===o?"undefined":_typeof(o))?r[n]=pickContextArgument(o,t):r[n]=o}),r}function prepareTextMessage(e,t){if(void 0===t)return e;var r=e;if("object"!==(void 0===t?"undefined":_typeof(t)))return r.replace("{arg}",t);var n=String(r).match(/{\w+}(?!\\)/g),o=[];return n&&n.forEach(function(e){if(-1===o.indexOf(e)){o.push(e);var n=prepareTextMessage(t[/\w+/.exec(e)[0]],t);"string"!=typeof n||n||(n=""),r=r.replace(e,n)}}),r}function getText(e,t,r,n,o){if(t)return o?"{{"+r+"."+o+"}}":"{{"+r+"}}";var i=getObjectKey(e,r);if(i){if("object"===(void 0===i?"undefined":_typeof(i))){var a=pickContext(i,o);if(i.message){var l=_extends({},a,n,{context:o});return prepareTextMessage(i.message,l)}return prepareTextMessage(pickContextArgument(i,o),_extends({},n,{context:o}))}return prepareTextMessage(i,n)}return""}function getName(e,t,r){return-1!==["uk","ru"].indexOf(e)?(r+" "+t).trim():(t+" "+r).trim()}function getDate(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},n=t;if("string"==typeof t){if(!t)return"";n=new Date(t)}return new Intl.DateTimeFormat(e,r).format(n)}var core=Object.freeze({getText:getText,getName:getName,getDate:getDate}),_createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var IntlWrapper=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return _inherits(t,Component),_createClass(t,[{key:"getChildContext",value:function(){return{intl:{getText:getText.bind(null,this.props.messages,this.props.inShell),getName:getName.bind(null,this.props.lang),getDate:getDate.bind(null,this.props.lang),lang:this.props.lang}}}},{key:"render",value:function(){return this.props.children}}]),t}();IntlWrapper.propTypes={children:PropTypes.oneOfType([PropTypes.node,PropTypes.object]),lang:PropTypes.string,messages:PropTypes.object,inShell:PropTypes.bool},IntlWrapper.defaultProps={children:null,lang:"en",messages:{},inShell:!1},IntlWrapper.childContextTypes={intl:PropTypes.object};var ATTRIBUTE_NAME="data-localization-id",ARG_NAME="data-localization-arg";function getTranslatableChildren(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.documentElement;return e?e.querySelectorAll("*["+ATTRIBUTE_NAME+"]"):[]}function getElementAttributes(e){return e instanceof HTMLElement?{id:e.getAttribute(ATTRIBUTE_NAME),arg:e.getAttribute(ARG_NAME)}:{}}function getChildElementCount(e){if(e.children)return e.children.length;if(void 0!==e.childElementCount)return e.childElementCount;for(var t=0,r=0;r<e.childNodes.length;r+=1)t+=1===e.nodeType?1:0;return t}function translateElement(e,t){var r=getElementAttributes(t);if(!r.id)return!1;var n=getText(e,!1,r.id);if(r.arg)return t.setAttribute(r.arg,n),!1;var o=document.createTextNode(n);return 0===getChildElementCount(t)?t.firstChild?t.replaceChild(o,t.firstChild):t.appendChild(o):t.insertBefore(o,t.firstChild),!0}function translateFragment(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.documentElement,r=getTranslatableChildren(t),n=r.length,o=0;o<n;o+=1)translateElement(e,r[o]);translateElement(e,t)}var dom=Object.freeze({translateFragment:translateFragment});export{core as IntlCore,dom as IntlDOM,IntlWrapper}; |
/* | ||
* Copyright 2019, Pentatonica.co | ||
* PIntl v0.0.4 | ||
* Copyright 2019-2024, Peculiar Ventures | ||
* Copyright 2018-2019, Pentatonica.co | ||
* PIntl v0.1.0 | ||
*/ | ||
@@ -20,3 +21,3 @@ | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl/core | ||
@@ -251,3 +252,3 @@ */ | ||
* | ||
* @example // lang ru | ||
* @example // lang uk | ||
* getName('Bill', 'Gates') // "Gates Bill" | ||
@@ -259,3 +260,3 @@ * | ||
function getName(lang, firstName, lastName) { | ||
var lastNamePriority = ['ru']; | ||
var lastNamePriority = ['uk', 'ru']; | ||
@@ -390,3 +391,3 @@ if (lastNamePriority.indexOf(lang) !== -1) { | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl/DOM | ||
@@ -485,3 +486,3 @@ */ | ||
/** | ||
* @author Mihail Zachepilo <mihailzachepilo@gmail.com> | ||
* @author Mykhailo Zachepylo <mihailzachepilo@gmail.com> | ||
* @module PIntl | ||
@@ -488,0 +489,0 @@ */ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.PIntl={},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";n=n&&n.hasOwnProperty("default")?n.default:n;var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function i(e,t){var n=function(e){return e},r="";switch(!0){case"string"==typeof t:n=function(e){return e===t};break;case"number"==typeof t:n=function(e){var n=/(\d+)..(\d+)/.exec(e),r=/(-?\d+)(\+|-)/.exec(e);return e==t||null!==n&&n[1]<=t&&n[2]>=t||null!==r&&("+"===r[2]?t>=r[1]:t<=r[1])}}var o=!0,i=!1,u=void 0;try{for(var a,l=Object.keys(e)[Symbol.iterator]();!(o=(a=l.next()).done);o=!0){var c=a.value;if(n(c)){r=e[c];break}}}catch(e){i=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(i)throw u}}return!r&&e._&&(r=e._),r}function u(e,t){if(void 0===t)return e;var n=e;if("object"!==(void 0===t?"undefined":o(t)))return n.replace("{arg}",t);var r=String(n).match(/{\w+}(?!\\)/g),i=[];return r&&r.forEach(function(e){if(-1===i.indexOf(e)){i.push(e);var r=u(t[/\w+/.exec(e)[0]],t);"string"!=typeof r||r||(r=""),n=n.replace(e,r)}}),n}function a(e,t,n,a,l){if(t)return l?"{{"+n+"."+l+"}}":"{{"+n+"}}";var c=function(e,t){var n=t.split("."),r=e,o=!0,i=!1,u=void 0;try{for(var a,l=n[Symbol.iterator]();!(o=(a=l.next()).done);o=!0){var c=a.value;if(!r)return"";r=r[c]}}catch(e){i=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(i)throw u}}return r}(e,n);if(c){if("object"===(void 0===c?"undefined":o(c))){var f=function(e,t){var n={};return Object.keys(e).forEach(function(r){var u=e[r];"object"===(void 0===u?"undefined":o(u))?n[r]=i(u,t):n[r]=u}),n}(c,l);if(c.message){var s=r({},f,a,{context:l});return u(c.message,s)}return u(i(c,l),r({},a,{context:l}))}return u(c,a)}return""}function l(e,t,n){return-1!==["ru"].indexOf(e)?(n+" "+t).trim():(t+" "+n).trim()}function c(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},r=t;if("string"==typeof t){if(!t)return"";r=new Date(t)}return new Intl.DateTimeFormat(e,n).format(r)}var f=Object.freeze({getText:a,getName:l,getDate:c}),s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var p=function(e){function n(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(n.__proto__||Object.getPrototypeOf(n)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(n,t.Component),s(n,[{key:"getChildContext",value:function(){return{intl:{getText:a.bind(null,this.props.messages,this.props.inShell),getName:l.bind(null,this.props.lang),getDate:c.bind(null,this.props.lang),lang:this.props.lang}}}},{key:"render",value:function(){return this.props.children}}]),n}();p.propTypes={children:n.oneOfType([n.node,n.object]),lang:n.string,messages:n.object,inShell:n.bool},p.defaultProps={children:null,lang:"en",messages:{},inShell:!1},p.childContextTypes={intl:n.object};var d="data-localization-id",y="data-localization-arg";function h(e,t){var n=function(e){return e instanceof HTMLElement?{id:e.getAttribute(d),arg:e.getAttribute(y)}:{}}(t);if(!n.id)return!1;var r=a(e,!1,n.id);if(n.arg)return t.setAttribute(n.arg,r),!1;var o=document.createTextNode(r);return 0===function(e){if(e.children)return e.children.length;if(void 0!==e.childElementCount)return e.childElementCount;for(var t=0,n=0;n<e.childNodes.length;n+=1)t+=1===e.nodeType?1:0;return t}(t)?t.firstChild?t.replaceChild(o,t.firstChild):t.appendChild(o):t.insertBefore(o,t.firstChild),!0}var v=Object.freeze({translateFragment:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.documentElement,n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.documentElement;return e?e.querySelectorAll("*["+d+"]"):[]}(t),r=n.length,o=0;o<r;o+=1)h(e,n[o]);h(e,t)}});e.IntlCore=f,e.IntlDOM=v,e.IntlWrapper=p,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.PIntl={},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";n=n&&n.hasOwnProperty("default")?n.default:n;var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function i(e,t){var n=function(e){return e},r="";switch(!0){case"string"==typeof t:n=function(e){return e===t};break;case"number"==typeof t:n=function(e){var n=/(\d+)..(\d+)/.exec(e),r=/(-?\d+)(\+|-)/.exec(e);return e==t||null!==n&&n[1]<=t&&n[2]>=t||null!==r&&("+"===r[2]?t>=r[1]:t<=r[1])}}var o=!0,i=!1,u=void 0;try{for(var a,l=Object.keys(e)[Symbol.iterator]();!(o=(a=l.next()).done);o=!0){var c=a.value;if(n(c)){r=e[c];break}}}catch(e){i=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(i)throw u}}return!r&&e._&&(r=e._),r}function u(e,t){if(void 0===t)return e;var n=e;if("object"!==(void 0===t?"undefined":o(t)))return n.replace("{arg}",t);var r=String(n).match(/{\w+}(?!\\)/g),i=[];return r&&r.forEach(function(e){if(-1===i.indexOf(e)){i.push(e);var r=u(t[/\w+/.exec(e)[0]],t);"string"!=typeof r||r||(r=""),n=n.replace(e,r)}}),n}function a(e,t,n,a,l){if(t)return l?"{{"+n+"."+l+"}}":"{{"+n+"}}";var c=function(e,t){var n=t.split("."),r=e,o=!0,i=!1,u=void 0;try{for(var a,l=n[Symbol.iterator]();!(o=(a=l.next()).done);o=!0){var c=a.value;if(!r)return"";r=r[c]}}catch(e){i=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(i)throw u}}return r}(e,n);if(c){if("object"===(void 0===c?"undefined":o(c))){var f=function(e,t){var n={};return Object.keys(e).forEach(function(r){var u=e[r];"object"===(void 0===u?"undefined":o(u))?n[r]=i(u,t):n[r]=u}),n}(c,l);if(c.message){var s=r({},f,a,{context:l});return u(c.message,s)}return u(i(c,l),r({},a,{context:l}))}return u(c,a)}return""}function l(e,t,n){return-1!==["uk","ru"].indexOf(e)?(n+" "+t).trim():(t+" "+n).trim()}function c(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},r=t;if("string"==typeof t){if(!t)return"";r=new Date(t)}return new Intl.DateTimeFormat(e,n).format(r)}var f=Object.freeze({getText:a,getName:l,getDate:c}),s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var p=function(e){function n(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(n.__proto__||Object.getPrototypeOf(n)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(n,t.Component),s(n,[{key:"getChildContext",value:function(){return{intl:{getText:a.bind(null,this.props.messages,this.props.inShell),getName:l.bind(null,this.props.lang),getDate:c.bind(null,this.props.lang),lang:this.props.lang}}}},{key:"render",value:function(){return this.props.children}}]),n}();p.propTypes={children:n.oneOfType([n.node,n.object]),lang:n.string,messages:n.object,inShell:n.bool},p.defaultProps={children:null,lang:"en",messages:{},inShell:!1},p.childContextTypes={intl:n.object};var d="data-localization-id",y="data-localization-arg";function h(e,t){var n=function(e){return e instanceof HTMLElement?{id:e.getAttribute(d),arg:e.getAttribute(y)}:{}}(t);if(!n.id)return!1;var r=a(e,!1,n.id);if(n.arg)return t.setAttribute(n.arg,r),!1;var o=document.createTextNode(r);return 0===function(e){if(e.children)return e.children.length;if(void 0!==e.childElementCount)return e.childElementCount;for(var t=0,n=0;n<e.childNodes.length;n+=1)t+=1===e.nodeType?1:0;return t}(t)?t.firstChild?t.replaceChild(o,t.firstChild):t.appendChild(o):t.insertBefore(o,t.firstChild),!0}var v=Object.freeze({translateFragment:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.documentElement,n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.documentElement;return e?e.querySelectorAll("*["+d+"]"):[]}(t),r=n.length,o=0;o<r;o+=1)h(e,n[o]);h(e,t)}});e.IntlCore=f,e.IntlDOM=v,e.IntlWrapper=p,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -19,3 +19,3 @@ import * as React from 'react'; | ||
declare interface IntlCore { | ||
getName: (messages: Messages, inShell: boolean, id: string, args?: Args | null, context?: string | number) => string; | ||
getText: (messages: Messages, inShell: boolean, id: string, args?: Args | null, context?: string | number) => string; | ||
getName: (lang: string, firstName: string, lastName: string) => string; | ||
@@ -37,1 +37,3 @@ getDate: (lang: string, date: Date | string, format?: Intl.DateTimeFormatOptions) => string; | ||
declare const IntlWrapper: React.ComponentType<IntlWrapperProps>; | ||
declare const IntlCore: IntlCore; | ||
declare const IntlDOM: IntlDOM; |
{ | ||
"name": "lib-pintl", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"description": "PIntl - Library for internationalization of js applications", | ||
@@ -26,3 +26,3 @@ "main": "./dist/index.umd.js", | ||
"type": "git", | ||
"url": "git+https://github.com/pentatonica/lib-react-intl.git" | ||
"url": "git+https://github.com/PeculiarVentures/lib-pintl.git" | ||
}, | ||
@@ -35,10 +35,10 @@ "keywords": [ | ||
], | ||
"author": "Pentatonica.co", | ||
"author": "Peculiar Ventures", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/pentatonica/lib-react-intl/issues" | ||
"url": "https://github.com/PeculiarVentures/lib-pintl/issues" | ||
}, | ||
"homepage": "https://github.com/pentatonica/lib-react-intl#readme", | ||
"homepage": "https://github.com/PeculiarVentures/lib-pintl#readme", | ||
"peerDependencies": { | ||
"react": "^15.0.0 || ^16.0.0", | ||
"react": ">=15.0.0", | ||
"prop-types": "^15.5.4" | ||
@@ -45,0 +45,0 @@ }, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
64823
1608
1