@ambiot/material-ui-phone-field
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -19,2 +19,40 @@ 'use strict'; | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var getCallingCode = function getCallingCode(iso) { | ||
@@ -77,15 +115,4 @@ try { | ||
for (var _iterator = isoCodes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref2; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref2 = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref2 = _i.value; | ||
} | ||
var isoCode = _ref2; | ||
for (var _iterator = _createForOfIteratorHelperLoose(isoCodes), _step; !(_step = _iterator()).done;) { | ||
var isoCode = _step.value; | ||
var callingCode = getCallingCode(isoCode); | ||
@@ -111,6 +138,6 @@ if (!callingCode) continue; | ||
} | ||
}, countriesAndCodes.map(function (_ref3) { | ||
var isoCode = _ref3[0], | ||
country = _ref3[1], | ||
callingCode = _ref3[2]; | ||
}, countriesAndCodes.map(function (_ref2) { | ||
var isoCode = _ref2[0], | ||
country = _ref2[1], | ||
callingCode = _ref2[2]; | ||
return React__default.createElement(MenuItem, { | ||
@@ -117,0 +144,0 @@ key: isoCode, |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("react"),t=e(r),n=require("@material-ui/core/styles"),a=e(require("clsx")),u=e(require("prop-types")),i=e(require("@material-ui/core/MenuItem")),o=e(require("@material-ui/core/FormControl")),l=e(require("@material-ui/core/Select")),c=e(require("i18n-iso-countries")),s=require("@material-ui/core"),f=require("libphonenumber-js"),g=function(e){try{return f.getCountryCallingCode(e)}catch(e){return}};function m(){for(var e={},r=0,t=Object.keys(c.getAlpha2Codes());r<t.length;r++){var n=t[r];if(f.isSupportedCountry(n)){var a=g(n);a&&(e[n]=a)}}return e}c.registerLocale(require("i18n-iso-countries/langs/en.json")),c.registerLocale(require("i18n-iso-countries/langs/ru.json"));var p=Object.keys(m());function y(e){var n=e.value,a=e.onChange,u=e.displayCountries,f=void 0===u?[]:u,m=e.language,p=void 0===m?"en":m,y=s.useTheme(),v=r.useMemo((function(){return c.getNames(p)}),[p]),h=r.useMemo((function(){return null!=f&&f.length?f:Object.keys(v)}),[f,v]),d=r.useMemo((function(){return function(e){return v[e]||e}}),[v]),C=r.useMemo((function(){var e=[],r=h,t=Array.isArray(r),n=0;for(r=t?r:r[Symbol.iterator]();;){var a;if(t){if(n>=r.length)break;a=r[n++]}else{if((n=r.next()).done)break;a=n.value}var u=a,i=g(u);i&&e.push([u.toUpperCase(),d(u),"+"+i])}return e}),[h,d]);return t.createElement(o,null,t.createElement(l,{value:n,onChange:a,displayEmpty:!0,renderValue:function(e){return t.createElement(s.Typography,null,e.length?"+"+g(e):"—")}},C.map((function(e){var r=e[0],n=e[2];return t.createElement(i,{key:r,value:r,style:{whiteSpace:"normal"}},t.createElement(s.Grid,{container:!0,spacing:1},t.createElement(s.Grid,{item:!0,xs:9},t.createElement(s.Typography,{variant:"body2",color:"textSecondary"},e[1])),t.createElement(s.Grid,{item:!0},t.createElement(s.Typography,{variant:"body2",style:{fontWeight:y.typography.fontWeightMedium}},n))))}))))}y.propTypes={value:u.string,onChange:u.func.isRequired,language:u.string};var v=n.makeStyles((function(){return n.createStyles({input:{lineHeight:"1.5",height:"auto"}})}));function h(e){var n=e.value,a=e.onChange,u=e.country,i=e.className,o=v(),l=function(e,r){if(!e)return"";if(!r)return e;var t=new f.AsYouType(r);t.input(e);var n=t.getNumber();return n?r?n.format("NATIONAL",{nationalPrefix:!1}):e:""}(n,u),c=r.useCallback((function(e){a(function(e,r){if(!e)return"";if(!r)return e;var t=new f.AsYouType(r);t.input(e);var n=t.getNumber();return n?r?f.parseDigits(n.format("NATIONAL",{nationalPrefix:!1})):e:""}(e.target.value,u))}),[a,u]);return t.createElement(s.TextField,{value:l,onChange:c,className:i,size:"medium",InputProps:{classes:{input:o.input}}})}var d=n.makeStyles((function(e){return n.createStyles({root:{display:"flex",alignContent:"center","& > *:first-child":{marginRight:e.spacing(2)}},fullWidth:{width:"100%"},field:{flex:1}})}));function C(e){if(!e)return"";var r=f.parsePhoneNumberFromString(e);return r&&r.country||""}exports.default=function(e){var n=e.value,u=e.onChange,i=e.defaultCountry,o=e.fullWidth,l=e.language,c=d(),s=r.useState(C(n)||i||""),f=s[0],m=s[1],v=r.useState(""),b=v[0],E=v[1],q=r.useCallback((function(e,r){u(function(e,r){if(!r.length)return"";if(!e.length)return r;var t=g(e);return t?"+"+t+r:r}(e,r))}),[u]),k=r.useCallback((function(e){var r=e.target.value;m(r),q(r,b)}),[m,q,b]),N=r.useCallback((function(e){E(e),q(f,e)}),[E,q,f]);return r.useEffect((function(){var e=C(n);e&&m(e)}),[n]),t.createElement("div",{className:a(c.root,o&&c.fullWidth)},t.createElement(y,{value:f||"",onChange:k,displayCountries:p,language:l}),t.createElement(h,{value:n,onChange:N,country:f,className:c.field}))}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("react"),t=e(r),n=require("@material-ui/core/styles"),a=e(require("clsx")),u=e(require("prop-types")),i=e(require("@material-ui/core/MenuItem")),o=e(require("@material-ui/core/FormControl")),l=e(require("@material-ui/core/Select")),c=e(require("i18n-iso-countries")),s=require("@material-ui/core"),f=require("libphonenumber-js");function m(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var g=function(e){try{return f.getCountryCallingCode(e)}catch(e){return}};function p(){for(var e={},r=0,t=Object.keys(c.getAlpha2Codes());r<t.length;r++){var n=t[r];if(f.isSupportedCountry(n)){var a=g(n);a&&(e[n]=a)}}return e}c.registerLocale(require("i18n-iso-countries/langs/en.json")),c.registerLocale(require("i18n-iso-countries/langs/ru.json"));var y=Object.keys(p());function v(e){var n=e.value,a=e.onChange,u=e.displayCountries,f=void 0===u?[]:u,p=e.language,y=void 0===p?"en":p,v=s.useTheme(),d=r.useMemo((function(){return c.getNames(y)}),[y]),h=r.useMemo((function(){return null!=f&&f.length?f:Object.keys(d)}),[f,d]),b=r.useMemo((function(){return function(e){return d[e]||e}}),[d]),C=r.useMemo((function(){for(var e,r=[],t=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return m(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?m(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(h);!(e=t()).done;){var n=e.value,a=g(n);a&&r.push([n.toUpperCase(),b(n),"+"+a])}return r}),[h,b]);return t.createElement(o,null,t.createElement(l,{value:n,onChange:a,displayEmpty:!0,renderValue:function(e){return t.createElement(s.Typography,null,e.length?"+"+g(e):"—")}},C.map((function(e){var r=e[0],n=e[2];return t.createElement(i,{key:r,value:r,style:{whiteSpace:"normal"}},t.createElement(s.Grid,{container:!0,spacing:1},t.createElement(s.Grid,{item:!0,xs:9},t.createElement(s.Typography,{variant:"body2",color:"textSecondary"},e[1])),t.createElement(s.Grid,{item:!0},t.createElement(s.Typography,{variant:"body2",style:{fontWeight:v.typography.fontWeightMedium}},n))))}))))}v.propTypes={value:u.string,onChange:u.func.isRequired,language:u.string};var d=n.makeStyles((function(){return n.createStyles({input:{lineHeight:"1.5",height:"auto"}})}));function h(e){var n=e.value,a=e.onChange,u=e.country,i=e.className,o=d(),l=function(e,r){if(!e)return"";if(!r)return e;var t=new f.AsYouType(r);t.input(e);var n=t.getNumber();return n?r?n.format("NATIONAL",{nationalPrefix:!1}):e:""}(n,u),c=r.useCallback((function(e){a(function(e,r){if(!e)return"";if(!r)return e;var t=new f.AsYouType(r);t.input(e);var n=t.getNumber();return n?r?f.parseDigits(n.format("NATIONAL",{nationalPrefix:!1})):e:""}(e.target.value,u))}),[a,u]);return t.createElement(s.TextField,{value:l,onChange:c,className:i,size:"medium",InputProps:{classes:{input:o.input}}})}var b=n.makeStyles((function(e){return n.createStyles({root:{display:"flex",alignContent:"center","& > *:first-child":{marginRight:e.spacing(2)}},fullWidth:{width:"100%"},field:{flex:1}})}));function C(e){if(!e)return"";var r=f.parsePhoneNumberFromString(e);return r&&r.country||""}exports.default=function(e){var n=e.value,u=e.onChange,i=e.defaultCountry,o=e.fullWidth,l=e.language,c=b(),s=r.useState(C(n)||i||""),f=s[0],m=s[1],p=r.useState(""),d=p[0],E=p[1],S=r.useCallback((function(e,r){u(function(e,r){if(!r.length)return"";if(!e.length)return r;var t=g(e);return t?"+"+t+r:r}(e,r))}),[u]),q=r.useCallback((function(e){var r=e.target.value;m(r),S(r,d)}),[m,S,d]),A=r.useCallback((function(e){E(e),S(f,e)}),[E,S,f]);return r.useEffect((function(){var e=C(n);e&&m(e)}),[n]),t.createElement("div",{className:a(c.root,o&&c.fullWidth)},t.createElement(v,{value:f||"",onChange:q,displayCountries:y,language:l}),t.createElement(h,{value:n,onChange:A,country:f,className:c.field}))}; | ||
//# sourceMappingURL=material-ui-phone-field.cjs.production.min.js.map |
@@ -12,2 +12,40 @@ import React, { useMemo, useCallback, useState, useEffect } from 'react'; | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var getCallingCode = function getCallingCode(iso) { | ||
@@ -70,15 +108,4 @@ try { | ||
for (var _iterator = isoCodes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref2; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref2 = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref2 = _i.value; | ||
} | ||
var isoCode = _ref2; | ||
for (var _iterator = _createForOfIteratorHelperLoose(isoCodes), _step; !(_step = _iterator()).done;) { | ||
var isoCode = _step.value; | ||
var callingCode = getCallingCode(isoCode); | ||
@@ -104,6 +131,6 @@ if (!callingCode) continue; | ||
} | ||
}, countriesAndCodes.map(function (_ref3) { | ||
var isoCode = _ref3[0], | ||
country = _ref3[1], | ||
callingCode = _ref3[2]; | ||
}, countriesAndCodes.map(function (_ref2) { | ||
var isoCode = _ref2[0], | ||
country = _ref2[1], | ||
callingCode = _ref2[2]; | ||
return React.createElement(MenuItem, { | ||
@@ -110,0 +137,0 @@ key: isoCode, |
{ | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"license": "MIT", | ||
@@ -16,3 +16,4 @@ "main": "dist/index.js", | ||
"build-storybook": "build-storybook", | ||
"prepare": "install-peers" | ||
"prepare": "install-peers", | ||
"release": "release-it" | ||
}, | ||
@@ -22,4 +23,4 @@ "peerDependencies": { | ||
"@material-ui/styles": "^4.0.0", | ||
"react": "^16.8.4", | ||
"react-dom": "^16.8.4" | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2" | ||
}, | ||
@@ -44,30 +45,31 @@ "husky": { | ||
"dependencies": { | ||
"clsx": "^1.1.0", | ||
"country-telephone-data": "^0.6.0", | ||
"i18n-iso-countries": "^5.0.0", | ||
"libphonenumber-js": "^1.7.46" | ||
"clsx": "^1.1.1", | ||
"country-telephone-data": "^0.6.3", | ||
"i18n-iso-countries": "^7.1.0", | ||
"libphonenumber-js": "^1.9.44" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.8.7", | ||
"@rollup/plugin-image": "^2.0.4", | ||
"@rollup/plugin-virtual": "^2.0.1", | ||
"@storybook/addon-actions": "^5.3.14", | ||
"@storybook/addon-links": "^5.3.14", | ||
"@storybook/addons": "^5.3.14", | ||
"@storybook/react": "^5.3.14", | ||
"@types/jest": "^25.1.4", | ||
"@types/react": "^16.9.23", | ||
"@types/react-dom": "^16.9.5", | ||
"babel-loader": "^8.0.6", | ||
"husky": "^4.2.3", | ||
"@babel/core": "^7.16.0", | ||
"@rollup/plugin-image": "^2.1.1", | ||
"@rollup/plugin-virtual": "^2.0.3", | ||
"@storybook/addon-actions": "^6.4.8", | ||
"@storybook/addon-links": "^6.4.8", | ||
"@storybook/addons": "^6.4.8", | ||
"@storybook/react": "^6.4.8", | ||
"@types/jest": "^27.0.3", | ||
"@types/react": "^17.0.37", | ||
"@types/react-dom": "^17.0.11", | ||
"babel-loader": "^8.2.3", | ||
"husky": "^7.0.4", | ||
"install-peers-cli": "^2.2.0", | ||
"rollup-plugin-copy": "^3.3.0", | ||
"rollup-plugin-copy-assets": "^2.0.1", | ||
"release-it": "*", | ||
"rollup-plugin-copy": "^3.4.0", | ||
"rollup-plugin-copy-assets": "^2.0.3", | ||
"rollup-plugin-svg": "^2.0.0", | ||
"rollup-plugin-typescript2": "^0.26.0", | ||
"ts-loader": "^6.2.1", | ||
"tsdx": "^0.12.3", | ||
"tslib": "^1.11.1", | ||
"typescript": "^3.8.3" | ||
"rollup-plugin-typescript2": "^0.31.1", | ||
"ts-loader": "^9.2.6", | ||
"tsdx": "^0.14.1", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.5.2" | ||
} | ||
} |
@@ -36,7 +36,7 @@ # Material-UI Phone Field | ||
2. Get inside the folder: `cd material-ui-phone-field` | ||
3. Install all the general dependencies: `yarn install` | ||
4. Run TSDX watcher using `yarn start` | ||
3. Install all the general dependencies: `npm install` | ||
4. Run TSDX watcher using `npm start` | ||
5. Open another terminal and get inside the `example` folder: `cd example` | ||
6. Install all dependencies needed to launch the example: `yarn install` | ||
7. Run `yarn start` to launch the example app | ||
6. Install all dependencies needed to launch the example: `npm install` | ||
7. Run `npm start` to launch the example app | ||
8. Library is located in `src`. Edit the code and watch the changes in the browser |
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
87428
693
22
15
+ Addedi18n-iso-countries@7.13.0(transitive)
+ Addedreact@17.0.2(transitive)
+ Addedreact-dom@17.0.2(transitive)
+ Addedscheduler@0.20.2(transitive)
- Removedi18n-iso-countries@5.5.0(transitive)
- Removedreact@16.14.0(transitive)
- Removedreact-dom@16.14.0(transitive)
- Removedscheduler@0.19.1(transitive)
Updatedclsx@^1.1.1
Updatedi18n-iso-countries@^7.1.0
Updatedlibphonenumber-js@^1.9.44