diff --git a/README.md b/README.md index 9b13672..7073397 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ Wordpress plugin for entering and validating international telephone numbers bas IP Lookup Change default country depends on user IP -* **Separate Dial Code** -Separate Dial Code +* **Show Selected Dial Code** +Show Selected Dial Code Display the country dial code next to the selected flag so it's not part of the typed number. Note that this will disable National Mode because technically we are dealing with international numbers, but with the dial code separated. diff --git a/admin/ninja-forms-fields/class-spn-field.php b/admin/ninja-forms-fields/class-spn-field.php index 16ddead..fcd9b67 100644 --- a/admin/ninja-forms-fields/class-spn-field.php +++ b/admin/ninja-forms-fields/class-spn-field.php @@ -68,19 +68,19 @@ protected function add_options() { ); /** - * Add toggle Separate Dial Code + * Add toggle Show Selected Dial Code * Display the country dial code next to the selected flag so it's not part of the typed number. * Note that this will disable nationalMode because technically we are dealing with international numbers, but with the dial code separated. * * @since 1.0.0 */ - $this->_settings['separate_dial_code'] = array( - 'name' => 'separate_dial_code', + $this->_settings['show_selected_dial_code'] = array( + 'name' => 'show_selected_dial_code', 'type' => 'toggle', - 'label' => esc_html__( 'Separate Dial Code', 'ninja-forms-spn-addon' ), + 'label' => esc_html__( 'Show Selected Dial Code', 'ninja-forms-spn-addon' ), 'width' => 'full', 'group' => 'restrictions', - 'help' => esc_html__( 'Display the country dial code next to the selected flag so it\'s not part of the typed number. Note that this will disable nationalMode because technically we are dealing with international numbers, but with the dial code separated.', 'ninja-forms-spn-addon' ), + 'help' => wp_kses_post( __( 'Display the country dial code next to the selected flag. Play with this option on Storybook (using the React component).', 'ninja-forms-spn-addon' ) ), 'value' => false, ); diff --git a/dist/public/spn-front-main.min.js b/dist/public/spn-front-main.min.js index 27b66e2..29ced8b 100644 --- a/dist/public/spn-front-main.min.js +++ b/dist/public/spn-front-main.min.js @@ -1 +1 @@ -(()=>{"use strict";var t,e={788:(t,e,n)=>{var r=["al","ad","at","by","be","ba","bg","hr","cz","dk","ee","fo","fi","fr","de","gi","gr","va","hu","is","ie","it","lv","li","lt","lu","mk","mt","md","mc","me","nl","no","pl","pt","ro","ru","sm","rs","sk","si","es","se","ch","ua","gb"],o=n(692),i=n(603),a=n(183);function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function l(t){return function(t){if(Array.isArray(t))return f(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return f(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0)){var e=t.data,n=document.body,r=this;new MutationObserver((function(t,n){var o,i=h(t);try{for(i.s();!(o=i.n()).done;){var a=o.value;if("childList"===a.type&&a.addedNodes.length>0&&"NF-FIELDS-WRAP"===a.target.tagName){var u=r._getNFNode(e.form_id);u&&new d(u).init(),n.disconnect()}}}catch(t){i.e(t)}finally{i.f()}})).observe(n,{childList:!0,subtree:!0})}}},{key:"_getNFNode",value:function(t){return o("#nf-form-".concat(t,"-cont"))}},{key:"_listenTo",value:function(t,e,n){t.on(e,n.bind(this))}}])&&w(e.prototype,n),r&&w(e,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function k(t){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(t)}function C(t,e){for(var n=0;n{if(!n){var a=1/0;for(c=0;c=i)&&Object.keys(r.O).every((t=>r.O[t](n[l])))?n.splice(l--,1):(u=!1,i0&&t[c-1][2]>i;c--)t[c]=t[c-1];t[c]=[n,o,i]},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t={792:0};r.O.j=e=>0===t[e];var e=(e,n)=>{var o,i,[a,u,l]=n,f=0;if(a.some((e=>0!==t[e]))){for(o in u)r.o(u,o)&&(r.m[o]=u[o]);if(l)var c=l(r)}for(e&&e(n);fr(788)));o=r.O(o)})(); \ No newline at end of file +(()=>{"use strict";var t,e={788:(t,e,n)=>{var r=["al","ad","at","by","be","ba","bg","hr","cz","dk","ee","fo","fi","fr","de","gi","gr","va","hu","is","ie","it","lv","li","lt","lu","mk","mt","md","mc","me","nl","no","pl","pt","ro","ru","sm","rs","sk","si","es","se","ch","ua","gb"],o=n(692),i=n(603),a=n(183);function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function l(t){return function(t){if(Array.isArray(t))return f(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return f(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0)){var e=t.data,n=document.body,r=this;new MutationObserver((function(t,n){var o,i=h(t);try{for(i.s();!(o=i.n()).done;){var a=o.value;if("childList"===a.type&&a.addedNodes.length>0&&"NF-FIELDS-WRAP"===a.target.tagName){var u=r._getNFNode(e.form_id);u&&new d(u).init(),n.disconnect()}}}catch(t){i.e(t)}finally{i.f()}})).observe(n,{childList:!0,subtree:!0})}}},{key:"_getNFNode",value:function(t){return o("#nf-form-".concat(t,"-cont"))}},{key:"_listenTo",value:function(t,e,n){t.on(e,n.bind(this))}}])&&w(e.prototype,n),r&&w(e,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function k(t){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(t)}function C(t,e){for(var n=0;n{if(!n){var a=1/0;for(c=0;c=i)&&Object.keys(r.O).every((t=>r.O[t](n[l])))?n.splice(l--,1):(u=!1,i0&&t[c-1][2]>i;c--)t[c]=t[c-1];t[c]=[n,o,i]},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t={792:0};r.O.j=e=>0===t[e];var e=(e,n)=>{var o,i,[a,u,l]=n,f=0;if(a.some((e=>0!==t[e]))){for(o in u)r.o(u,o)&&(r.m[o]=u[o]);if(l)var c=l(r)}for(e&&e(n);fr(788)));o=r.O(o)})(); \ No newline at end of file diff --git a/public/js/modules/ITIInitializer.js b/public/js/modules/ITIInitializer.js index 694a1a0..a6c8850 100644 --- a/public/js/modules/ITIInitializer.js +++ b/public/js/modules/ITIInitializer.js @@ -57,7 +57,7 @@ class IntlTelInputInitializer { const allowDropdown = Boolean($input.data('allow-dropdown')) const nationalMode = Boolean($input.data('national-mode')) const autoHideDialCode = Boolean($input.data('auto-hide-dial-code')) - const separateDialCode = Boolean($input.data('separate-dial-code')) + const showSelectedDialCode = Boolean($input.data('show-selected-dial-code')) const formatOnDisplay = Boolean($input.data('format-on-display')) return { @@ -69,7 +69,7 @@ class IntlTelInputInitializer { autoHideDialCode, excludeCountries, allowIpLookUp, - separateDialCode, + showSelectedDialCode, formatOnDisplay } } @@ -89,7 +89,7 @@ class IntlTelInputInitializer { autoHideDialCode: dataAttributes.autoHideDialCode, excludeCountries: dataAttributes.excludeCountries, geoIpLookup: dataAttributes.allowIpLookUp, - separateDialCode: dataAttributes.separateDialCode, + showSelectedDialCode: dataAttributes.showSelectedDialCode, formatOnDisplay: dataAttributes.formatOnDisplay, utilsScript: intlTelInputUtils }) diff --git a/public/ninja-forms-fields/templates/fields-spn.html b/public/ninja-forms-fields/templates/fields-spn.html index 4bd6b8b..f3f1318 100644 --- a/public/ninja-forms-fields/templates/fields-spn.html +++ b/public/ninja-forms-fields/templates/fields-spn.html @@ -37,8 +37,8 @@ data-allow-ip-lookup="{{{ data.allow_ip_lookup }}}" <# } #> - <# if( data.separate_dial_code ){ #> - data-separate-dial-code="{{{ data.separate_dial_code }}}" + <# if( data.show_selected_dial_code ){ #> + data-show-selected-dial-code="{{{ data.show_selected_dial_code }}}" <# } #> data-default-country="{{{ data.default_country }}}"