Sha256: 24f04cf931d981bc34b54ad57ade0fc936cd22867d83b0eff213bce162dcc042

Contents?: true

Size: 986 Bytes

Versions: 36

Compression:

Stored size: 986 Bytes

Contents

import ApplicationController from "satis/controllers/application_controller"
import {debounce} from "satis/utils"
import * as dummy1 from "intl-tel-input"
import * as dummy2 from "intl-tel-input-utils"

export default class PhoneNumberController extends ApplicationController {
  static targets = ["input", "hiddenInput"]

  initialize() {
    super.initialize()
    this.change = debounce(this.change, 500).bind(this)
  }

  connect() {
    super.connect()
    this.instance = intlTelInput(this.inputTarget, {
      initialCountry: "nl",
      formatOnInit: true,
      preferredCountries: ["nl", "de", "gb", "fr", "us", "es", "be", "se"],
      nationalMode: false,
      utilsScript: intlTelInputUtils,
      dropdownContainer: document.body,
    })
  }

  change(event) {
    this.hiddenInputTarget.value = this.instance.getNumber(intlTelInputUtils.numberFormat.INTERNATIONAL)
    this.inputTarget.value = this.instance.getNumber(intlTelInputUtils.numberFormat.INTERNATIONAL)
  }
}

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
satis-2.1.43 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.42 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.41 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.40 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.39 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.38 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.37 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.36 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.35 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.33 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.31 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.30 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.29 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.28 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.27 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.26 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.24 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.23 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.22 app/javascript/satis/controllers/phone_number_controller.js
satis-2.1.21 app/javascript/satis/controllers/phone_number_controller.js