Coder Social home page Coder Social logo

qonto / ember-phone-input Goto Github PK

View Code? Open in Web Editor NEW
26.0 26.0 32.0 24.48 MB

An Ember.js component to handle international phone numbers.

License: MIT License

JavaScript 25.60% HTML 4.45% Handlebars 0.84% CSS 1.54% TypeScript 67.57%
ember ember-addon input phone-number

ember-phone-input's People

Contributors

alexborovkov avatar anas7asia avatar ctjhoa avatar dannycalleri avatar dbendaou avatar dcyriller avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar eliasmelgaco avatar ember-tomster avatar evanlouden avatar hakilebara avatar jacojoubert avatar jfdnc avatar kiwiupover avatar lan0 avatar locks avatar m-jovan avatar mansona avatar michelegera avatar mrloop avatar nicolasgasco avatar renovate[bot] avatar samdemaeyer avatar turbo87 avatar vscav avatar vsergiu93 avatar zeppelin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-phone-input's Issues

Override styles

Is it possible to override the styles? I am not seeing any documentation on it and would love to be able to customize the look of this input. Thank you!

Number doesn't get formatted

I'm using ember octane, with ember-phone-input 2.0.7; when you enter a phone it doesn't get formatted, it stays visually as 3824234225 instead (382) 423-4225

Cannot read property 'destroy' of null

this._iti can be null, so destroy() method doesn't exist.

The issue origin probably comes from the didInsertElement because component's hooks aren't async.

didInsertElement() {
    this._super(...arguments);

    this._loadAndSetup(); // This is an async function
},
// ...
willDestroyElement() {
    this._iti.destroy();
    // ...
},

didInsertElement is not waiting the this._loadAndSetup() end, the willDestroyElement hook can be run before this._loadAndSetup() has finished.

Number in update action isn't consistent

Hi,

number parameter in the update action isn't in a consistent format.
This issue is exaggerated with separateDialCode option enabled.

The following examples are taken from https://qonto.github.io/ember-phone-input

  • With an incomplete french number -> number is formatted
    2020-07-24-123420_2355x1137_scrot

  • With a complete french number -> number is not formatted
    2020-07-24-123433_2312x1150_scrot

  • With a french number > valid number -> number is formatted
    2020-07-24-123453_2282x1193_scrot

You can also reproduce the issue with separateDialCode disabled but you have to type a number which has: length > valid number length.

I think update action should provide number in 2 versions (without formatting & with formatting).

Country code doesn't update on UI change after phone number is set

Great add-on. I have one issue, and maybe there's a good work-around.

If a user selects a country and then enters a phone number, the number and metadata arguments are passed to the action handler appropriately.

However, if a user selects an initial country, then enters their number, and then goes back and toggles their country selection to a different country, while the number argument updates in the action handler, the metaData argument will not. This could lead to a user accidentally saving their number with the wrong country code.

Example:
{{phone-input number=user.phoneNumber update=(action 'updatePhoneNumber')}}

    updatePhoneNumber(number, metaData) {
      console.log('number', number) // always logs the correct, updated number
      console.log('countryCode', metaData) // only logs first selection
    }

Am I missing something here?

Issues with pnpm

I use pnpm in within a workspace/monorepo, and when I run ember s I get:

Cannot find module 'intl-tel-input/package.json' from '/Users/machty/code/exc/fpr-ember/packages/@futureproofretail/shopper-app'

I am able to solve this by adding intl-tel-input as a dependency to my ember app. I could probably solve this some other pnpm-specific way, perhaps with shamefully-hoist.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: RepoCacheS3.read() - failure

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/lint.yml
  • actions/checkout v4
  • wyvox/action-setup-pnpm v3
  • actions/checkout v3
  • wyvox/action-setup-pnpm v3
.github/workflows/test.yml
  • actions/checkout v4
  • wyvox/action-setup-pnpm v3
  • actions/checkout v4
  • wyvox/action-setup-pnpm v3
  • actions/checkout v4
  • wyvox/action-setup-pnpm v3
npm
ember-phone-input/package.json
  • @ember/render-modifiers ^2.1.0
  • @embroider/addon-shim ^1.0.0
  • intl-tel-input ^18.0.0
  • rsvp ^4.8.5
  • @babel/core 7.23.6
  • @babel/eslint-parser 7.23.3
  • @babel/plugin-proposal-class-properties 7.18.6
  • @babel/plugin-proposal-decorators 7.23.6
  • @babel/plugin-syntax-decorators 7.23.3
  • @babel/preset-typescript 7.23.3
  • @embroider/addon-dev 4.1.1
  • @glimmer/component 1.1.2
  • @glint/core 1.2.1
  • @glint/environment-ember-loose 1.2.1
  • @glint/template 1.2.1
  • @qonto/eslint-config-typescript 1.0.0-rc.0
  • @rollup/plugin-babel 6.0.4
  • @tsconfig/ember 3.0.3
  • @types/intl-tel-input 18.1.4
  • @types/rsvp 4.0.8
  • @typescript-eslint/eslint-plugin 6.15.0
  • @typescript-eslint/parser 6.15.0
  • concurrently 8.2.2
  • ember-source 5.5.0
  • ember-template-lint 5.13.0
  • eslint 8.56.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-ember 11.12.0
  • eslint-plugin-node 11.1.0
  • eslint-plugin-prettier 5.1.1
  • prettier 3.1.1
  • rollup 4.9.1
  • rollup-plugin-copy 3.5.0
  • typescript 5.2.2
package.json
  • @release-it-plugins/lerna-changelog 6.0.0
  • @release-it-plugins/workspaces 4.0.0
  • concurrently 8.2.2
  • prettier 3.1.1
  • release-it 16.3.0
  • node >= 18
  • node 18.19.0
test-app/package.json
  • ember-phone-input 10.0.0-beta.0
  • @babel/eslint-parser 7.23.3
  • @ember/optional-features 2.0.0
  • @ember/string 3.1.1
  • @ember/test-helpers 3.2.1
  • @embroider/test-setup 3.0.2
  • @glimmer/component 1.1.2
  • @glimmer/tracking 1.1.2
  • @glint/core 1.2.1
  • @glint/environment-ember-loose 1.2.1
  • @glint/template 1.2.1
  • @qonto/eslint-config-typescript 1.0.0-rc.0
  • @tsconfig/ember 3.0.3
  • @types/qunit 2.19.9
  • @types/sinon 17.0.2
  • @typescript-eslint/eslint-plugin 6.15.0
  • @typescript-eslint/parser 6.15.0
  • broccoli-asset-rev 3.0.0
  • concurrently 8.2.2
  • ember-auto-import 2.7.1
  • ember-cli 4.12.2
  • ember-cli-app-version 6.0.1
  • ember-cli-babel 8.2.0
  • ember-cli-dependency-checker 3.3.2
  • ember-cli-deploy 2.0.0
  • ember-cli-deploy-build 3.0.0
  • ember-cli-deploy-git 1.3.4
  • ember-cli-deploy-git-ci 1.0.1
  • ember-cli-favicon 3.0.0
  • ember-cli-htmlbars 6.3.0
  • ember-cli-inject-live-reload 2.1.0
  • ember-cli-sri 2.1.1
  • ember-cli-terser 4.0.2
  • ember-cli-typescript 5.2.1
  • ember-data 5.3.0
  • ember-fetch 8.1.2
  • ember-load-initializers 2.1.2
  • ember-modifier 4.1.0
  • ember-page-title 8.1.0
  • ember-qunit 8.0.2
  • ember-resolver 11.0.1
  • ember-sinon-qunit 7.4.0
  • ember-source 5.5.0
  • ember-source-channel-url 3.0.0
  • ember-template-lint 5.13.0
  • ember-try 3.0.0
  • eslint 8.56.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-ember 11.12.0
  • eslint-plugin-n 16.5.0
  • eslint-plugin-node 11.1.0
  • eslint-plugin-prettier 5.1.1
  • eslint-plugin-qunit 7.3.4
  • file-loader 6.2.0
  • lerna-changelog 2.2.0
  • lint-to-the-future 2.0.0
  • lint-to-the-future-ember-template 1.2.0
  • lint-to-the-future-eslint 2.0.1
  • loader.js 4.7.0
  • npm-run-all 4.1.5
  • prettier 3.1.1
  • qunit 2.20.0
  • qunit-dom 3.0.0
  • release-it 16.3.0
  • release-it-lerna-changelog 5.0.0
  • sinon 17.0.1
  • tracked-built-ins 3.3.0
  • typescript 5.2.2
  • webpack 5.89.0
  • node >= 18

  • Check this box to trigger a request for Renovate to run again on this repository

Not compiling on Ember 5

Hi all! Probably I am missing something pretty obvious here, but for some reason, after installing ember-phone-input in a newly created ember app with Ember 5, my app is not compiling any more. I have the following error from ember-auto-import:

ERROR in ./node_modules/intl-tel-input/build/img/flags.png 1:0
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
 @ ./node_modules/css-loader/dist/cjs.js!./node_modules/ember-phone-input/dist/styles/styles.css 4:0-88 7:73-102
 @ ./node_modules/ember-phone-input/dist/styles/styles.css 2:12-81 9:17-24 13:15-29
 @ ./node_modules/ember-phone-input/dist/components/phone-input.js 1:368-397
 @ ../../../../../private/var/folders/z6/9q3xj7zn60n2xm64z68t868m0000gn/T/broccoli-69888Etfv1hkx9N2x/cache-238-webpack_bundler_ember_auto_import_webpack/app.cjs 20:144-195

Should I add any specific loader in my ember-cli-build.js file to be able to handle the flag.png files? Any recommendations?

Thanks!

Alejandro

Phone input doesn't update when its bound variable is set/cleared externally

When using this input, it's not possible to clear or reset the input. Example usage:

{{phone-input initialCountry="us" number=phone update=(action "phoneUpdated")}}

On form submit, I call this.set("phone", null), but the input field maintains its value. I couldn't find a way to clear it without resorting to jQuery.

Checklist to add an option

Here is a checklist to help you add a new option.

We've been adding options quite a few times in the past months. So, I'll write down the checklist here to help you either to implement the option or to review the changes.

Checklist:

Custom placeholder text

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected]
I noticed that there is feature enhancement already (#318), but here is the diff that works for me:

diff --git a/node_modules/ember-phone-input/addon/components/phone-input.js b/node_modules/ember-phone-input/addon/components/phone-input.js
index 40393b2..566ea48 100644
--- a/node_modules/ember-phone-input/addon/components/phone-input.js
+++ b/node_modules/ember-phone-input/addon/components/phone-input.js
@@ -98,6 +98,8 @@ export default Component.extend({
     */
     this.autoPlaceholder = this.autoPlaceholder || 'polite';
 
+    this.customPlaceholder = this.customPlaceholder || null;
+
     /**
       It will just be the first country in the list. Set the initial country by
       it's country code. Defaults to ''.
@@ -226,6 +228,7 @@ export default Component.extend({
     const {
       allowDropdown,
       autoPlaceholder,
+      customPlaceholder,
       initialCountry,
       onlyCountries,
       preferredCountries,
@@ -237,6 +240,7 @@ export default Component.extend({
       nationalMode: true,
       allowDropdown,
       autoPlaceholder,
+      customPlaceholder: customPlaceholder ? () => { return customPlaceholder } : null,
       initialCountry,
       onlyCountries,
       preferredCountries,

This issue body was partially generated by patch-package.

v9 upgrade cause a build error with classic build

ERROR in ./node_modules/intl-tel-input/build/img/flags.png 1:0
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
@ ./node_modules/css-loader/dist/cjs.js!./node_modules/intl-tel-input/build/css/intlTelInput.css 4:0-61 7:73-102
@ ./node_modules/intl-tel-input/build/css/intlTelInput.css 2:12-87 9:17-24 13:15-29
@ ./node_modules/ember-phone-input/dist/components/phone-input.js 1:144-194

ERROR in ./node_modules/intl-tel-input/build/img/[email protected] 1:0
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
@ ./node_modules/css-loader/dist/cjs.js!./node_modules/intl-tel-input/build/css/intlTelInput.css 5:0-64 8:73-102
@ ./node_modules/intl-tel-input/build/css/intlTelInput.css 2:12-87 9:17-24 13:15-29
@ ./node_modules/ember-phone-input/dist/components/phone-input.js 1:144-194

cleaning up...
Build Error (WebpackBundler)

webpack returned errors to ember-auto-import

v8 works just fine. Haven't tried with embroider.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.