intl-tel-input 27.1.3 → 27.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4571,7 +4571,7 @@ var intlTelInput = Object.assign(
4571
4571
  attachUtils,
4572
4572
  startedLoadingUtils: false,
4573
4573
  startedLoadingAutoCountry: false,
4574
- version: "27.1.3"
4574
+ version: "27.2.0"
4575
4575
  }
4576
4576
  );
4577
4577
  var intlTelInput_default = intlTelInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-tel-input",
3
- "version": "27.1.3",
3
+ "version": "27.2.0",
4
4
  "description": "A JavaScript plugin for entering and validating international telephone numbers",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/react/README.md CHANGED
@@ -3,3 +3,11 @@
3
3
  A React component for the [intl-tel-input](https://github.com/jackocnr/intl-tel-input) JavaScript plugin. View the [source code](https://github.com/jackocnr/intl-tel-input/blob/master/react/src/IntlTelInput.tsx).
4
4
 
5
5
  [Explore docs »](https://intl-tel-input.com/docs/react-component)
6
+
7
+ ## Running the demos locally
8
+
9
+ 1. Initialise the submodules: `git submodule update --init --recursive`
10
+ 2. Install dependencies: `npm install`
11
+ 3. Build: `npm run build`
12
+
13
+ You can then open `react/demo/validation/index.html` in your browser to try the validation demo. View the full list of [available demos](https://github.com/jackocnr/intl-tel-input/tree/master/react/demo).
@@ -2,6 +2,8 @@ import intlTelInput, { Iti } from "intl-tel-input";
2
2
  import React from "react";
3
3
  export { intlTelInput };
4
4
  type InputProps = Omit<React.ComponentPropsWithoutRef<"input">, "onInput">;
5
+ export type StrictRejectSource = "key" | "paste";
6
+ export type StrictRejectReason = "invalid" | "max-length";
5
7
  export type IntlTelInputRef = {
6
8
  getInstance: () => Iti | null;
7
9
  getInput: () => HTMLInputElement | null;
@@ -11,6 +13,9 @@ declare const IntlTelInput: React.ForwardRefExoticComponent<Partial<import("intl
11
13
  onChangeCountry?: (iso2: string) => void;
12
14
  onChangeValidity?: (isValid: boolean) => void;
13
15
  onChangeErrorCode?: (errorCode: number | null) => void;
16
+ onOpenCountryDropdown?: () => void;
17
+ onCloseCountryDropdown?: () => void;
18
+ onStrictReject?: (source: StrictRejectSource, rejectedInput: string, reason: StrictRejectReason) => void;
14
19
  usePreciseValidation?: boolean;
15
20
  inputProps?: InputProps;
16
21
  disabled?: boolean | undefined;
@@ -4541,7 +4541,7 @@ var intlTelInput = Object.assign(
4541
4541
  attachUtils,
4542
4542
  startedLoadingUtils: false,
4543
4543
  startedLoadingAutoCountry: false,
4544
- version: "27.1.3"
4544
+ version: "27.2.0"
4545
4545
  }
4546
4546
  );
4547
4547
  var intlTelInput_default = intlTelInput;
@@ -4564,6 +4564,9 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
4564
4564
  onChangeCountry = noop,
4565
4565
  onChangeValidity = noop,
4566
4566
  onChangeErrorCode = noop,
4567
+ onOpenCountryDropdown,
4568
+ onCloseCountryDropdown,
4569
+ onStrictReject,
4567
4570
  usePreciseValidation = false,
4568
4571
  inputProps = {},
4569
4572
  disabled = void 0,
@@ -4578,6 +4581,12 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
4578
4581
  const lastEmittedValidityRef = useRef(void 0);
4579
4582
  const lastEmittedErrorCodeRef = useRef(void 0);
4580
4583
  const pendingUpdateRef = useRef(false);
4584
+ const onOpenCountryDropdownRef = useRef(onOpenCountryDropdown);
4585
+ const onCloseCountryDropdownRef = useRef(onCloseCountryDropdown);
4586
+ const onStrictRejectRef = useRef(onStrictReject);
4587
+ onOpenCountryDropdownRef.current = onOpenCountryDropdown;
4588
+ onCloseCountryDropdownRef.current = onCloseCountryDropdown;
4589
+ onStrictRejectRef.current = onStrictReject;
4581
4590
  useImperativeHandle(ref, () => ({
4582
4591
  getInstance: () => itiRef.current,
4583
4592
  getInput: () => inputRef.current
@@ -4628,10 +4637,24 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
4628
4637
  usePreciseValidation
4629
4638
  ]);
4630
4639
  useEffect(() => {
4631
- if (inputRef.current) {
4632
- itiRef.current = intlTelInput_default(inputRef.current, initOptions);
4633
- }
4640
+ const inputEl = inputRef.current;
4641
+ if (!inputEl) {
4642
+ return void 0;
4643
+ }
4644
+ itiRef.current = intlTelInput_default(inputEl, initOptions);
4645
+ const handleOpen = () => onOpenCountryDropdownRef.current?.();
4646
+ const handleClose = () => onCloseCountryDropdownRef.current?.();
4647
+ const handleStrictReject = (e) => {
4648
+ const { source, rejectedInput, reason } = e.detail;
4649
+ onStrictRejectRef.current?.(source, rejectedInput, reason);
4650
+ };
4651
+ inputEl.addEventListener("open:countrydropdown", handleOpen);
4652
+ inputEl.addEventListener("close:countrydropdown", handleClose);
4653
+ inputEl.addEventListener("strict:reject", handleStrictReject);
4634
4654
  return () => {
4655
+ inputEl.removeEventListener("open:countrydropdown", handleOpen);
4656
+ inputEl.removeEventListener("close:countrydropdown", handleClose);
4657
+ inputEl.removeEventListener("strict:reject", handleStrictReject);
4635
4658
  itiRef.current?.destroy();
4636
4659
  };
4637
4660
  }, []);
@@ -4541,7 +4541,7 @@ var intlTelInput = Object.assign(
4541
4541
  attachUtils,
4542
4542
  startedLoadingUtils: false,
4543
4543
  startedLoadingAutoCountry: false,
4544
- version: "27.1.3"
4544
+ version: "27.2.0"
4545
4545
  }
4546
4546
  );
4547
4547
  var intlTelInput_default = intlTelInput;
@@ -10877,6 +10877,9 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
10877
10877
  onChangeCountry = noop,
10878
10878
  onChangeValidity = noop,
10879
10879
  onChangeErrorCode = noop,
10880
+ onOpenCountryDropdown,
10881
+ onCloseCountryDropdown,
10882
+ onStrictReject,
10880
10883
  usePreciseValidation = false,
10881
10884
  inputProps = {},
10882
10885
  disabled = void 0,
@@ -10891,6 +10894,12 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
10891
10894
  const lastEmittedValidityRef = useRef(void 0);
10892
10895
  const lastEmittedErrorCodeRef = useRef(void 0);
10893
10896
  const pendingUpdateRef = useRef(false);
10897
+ const onOpenCountryDropdownRef = useRef(onOpenCountryDropdown);
10898
+ const onCloseCountryDropdownRef = useRef(onCloseCountryDropdown);
10899
+ const onStrictRejectRef = useRef(onStrictReject);
10900
+ onOpenCountryDropdownRef.current = onOpenCountryDropdown;
10901
+ onCloseCountryDropdownRef.current = onCloseCountryDropdown;
10902
+ onStrictRejectRef.current = onStrictReject;
10894
10903
  useImperativeHandle(ref, () => ({
10895
10904
  getInstance: () => itiRef.current,
10896
10905
  getInput: () => inputRef.current
@@ -10941,10 +10950,24 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
10941
10950
  usePreciseValidation
10942
10951
  ]);
10943
10952
  useEffect(() => {
10944
- if (inputRef.current) {
10945
- itiRef.current = intlTelInput_default(inputRef.current, initOptions);
10946
- }
10953
+ const inputEl = inputRef.current;
10954
+ if (!inputEl) {
10955
+ return void 0;
10956
+ }
10957
+ itiRef.current = intlTelInput_default(inputEl, initOptions);
10958
+ const handleOpen = () => onOpenCountryDropdownRef.current?.();
10959
+ const handleClose = () => onCloseCountryDropdownRef.current?.();
10960
+ const handleStrictReject = (e) => {
10961
+ const { source, rejectedInput, reason } = e.detail;
10962
+ onStrictRejectRef.current?.(source, rejectedInput, reason);
10963
+ };
10964
+ inputEl.addEventListener("open:countrydropdown", handleOpen);
10965
+ inputEl.addEventListener("close:countrydropdown", handleClose);
10966
+ inputEl.addEventListener("strict:reject", handleStrictReject);
10947
10967
  return () => {
10968
+ inputEl.removeEventListener("open:countrydropdown", handleOpen);
10969
+ inputEl.removeEventListener("close:countrydropdown", handleClose);
10970
+ inputEl.removeEventListener("strict:reject", handleStrictReject);
10948
10971
  itiRef.current?.destroy();
10949
10972
  };
10950
10973
  }, []);
package/svelte/README.md CHANGED
@@ -3,3 +3,12 @@
3
3
  A Svelte 5 component for the [intl-tel-input](https://github.com/jackocnr/intl-tel-input) JavaScript plugin. View the [source code](https://github.com/jackocnr/intl-tel-input/blob/master/svelte/src/IntlTelInput.svelte).
4
4
 
5
5
  [Explore docs »](https://intl-tel-input.com/docs/svelte-component)
6
+
7
+ ## Running the demos locally
8
+
9
+ 1. Initialise the submodules: `git submodule update --init --recursive`
10
+ 2. Install dependencies: `npm install`
11
+ 3. Build: `npm run build`
12
+ 4. Run a demo: `npm run svelte:demo` and copy the given URL into your browser.
13
+
14
+ This defaults to the validation demo — to run a different one, set the `DEMO` env var, e.g. `DEMO=simple npm run svelte:demo`. View the full list of [available demos](https://github.com/jackocnr/intl-tel-input/tree/master/svelte/demo).
@@ -20,9 +20,18 @@
20
20
  onChangeCountry,
21
21
  onChangeValidity,
22
22
  onChangeErrorCode,
23
+ onOpenCountryDropdown,
24
+ onCloseCountryDropdown,
25
+ onStrictReject,
23
26
  ...initOptions
24
27
  } = $props() as Props;
25
28
 
29
+ type StrictRejectDetail = {
30
+ source: "key" | "paste";
31
+ rejectedInput: string;
32
+ reason: "invalid" | "max-length";
33
+ };
34
+
26
35
  // State
27
36
  let inputElement: HTMLInputElement | undefined = $state();
28
37
  let instance: Iti | undefined = $state();
@@ -96,6 +105,13 @@
96
105
  updateValue();
97
106
  };
98
107
 
108
+ const handleOpenDropdown = (): void => onOpenCountryDropdown?.();
109
+ const handleCloseDropdown = (): void => onCloseCountryDropdown?.();
110
+ const handleStrictReject = (e: Event): void => {
111
+ const { source, rejectedInput, reason } = (e as CustomEvent<StrictRejectDetail>).detail;
112
+ onStrictReject?.(source, rejectedInput, reason);
113
+ };
114
+
99
115
  // Lifecycle
100
116
  onMount(() => {
101
117
  if (inputElement) {
@@ -103,6 +119,10 @@
103
119
  if (disabled) instance.setDisabled(disabled);
104
120
  if (readonly) instance.setReadonly(readonly);
105
121
 
122
+ inputElement.addEventListener("open:countrydropdown", handleOpenDropdown);
123
+ inputElement.addEventListener("close:countrydropdown", handleCloseDropdown);
124
+ inputElement.addEventListener("strict:reject", handleStrictReject);
125
+
106
126
  lastEmittedCountry = instance.getSelectedCountryData()?.iso2 ?? "";
107
127
  hasInitialized = true;
108
128
 
@@ -128,6 +148,11 @@
128
148
  });
129
149
 
130
150
  onDestroy(() => {
151
+ if (inputElement) {
152
+ inputElement.removeEventListener("open:countrydropdown", handleOpenDropdown);
153
+ inputElement.removeEventListener("close:countrydropdown", handleCloseDropdown);
154
+ inputElement.removeEventListener("strict:reject", handleStrictReject);
155
+ }
131
156
  instance?.destroy();
132
157
  });
133
158
 
@@ -4,6 +4,9 @@ import type { Component } from "svelte";
4
4
  import type { Iti, SomeOptions } from "intl-tel-input";
5
5
  import intlTelInput from "intl-tel-input";
6
6
 
7
+ export type StrictRejectSource = "key" | "paste";
8
+ export type StrictRejectReason = "invalid" | "max-length";
9
+
7
10
  export type Props = SomeOptions & {
8
11
  disabled?: boolean;
9
12
  readonly?: boolean;
@@ -15,6 +18,9 @@ export type Props = SomeOptions & {
15
18
  onChangeCountry?: (iso2: string) => void;
16
19
  onChangeValidity?: (isValid: boolean) => void;
17
20
  onChangeErrorCode?: (errorCode: number | null) => void;
21
+ onOpenCountryDropdown?: () => void;
22
+ onCloseCountryDropdown?: () => void;
23
+ onStrictReject?: (source: StrictRejectSource, rejectedInput: string, reason: StrictRejectReason) => void;
18
24
  };
19
25
 
20
26
  export { intlTelInput };
package/vue/README.md CHANGED
@@ -3,3 +3,12 @@
3
3
  A Vue component for the [intl-tel-input](https://github.com/jackocnr/intl-tel-input) JavaScript plugin. View the [source code](https://github.com/jackocnr/intl-tel-input/blob/master/vue/src/IntlTelInput.vue).
4
4
 
5
5
  [Explore docs »](https://intl-tel-input.com/docs/vue-component)
6
+
7
+ ## Running the demos locally
8
+
9
+ 1. Initialise the submodules: `git submodule update --init --recursive`
10
+ 2. Install dependencies: `npm install`
11
+ 3. Build: `npm run build`
12
+ 4. Run a demo: `npm run vue:demo` and copy the given URL into your browser.
13
+
14
+ This defaults to the validation demo — to run a different one, set the `DEMO` env var, e.g. `DEMO=simple npm run vue:demo`. View the full list of [available demos](https://github.com/jackocnr/intl-tel-input/tree/master/vue/demo).
@@ -2517,7 +2517,7 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
2517
2517
  },
2518
2518
  startedLoadingUtils: !1,
2519
2519
  startedLoadingAutoCountry: !1,
2520
- version: "27.1.3"
2520
+ version: "27.2.0"
2521
2521
  }), $ = Q, Ce = /* @__PURE__ */ n({
2522
2522
  inheritAttrs: !1,
2523
2523
  __name: "IntlTelInput",
@@ -2572,6 +2572,9 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
2572
2572
  "changeCountry",
2573
2573
  "changeValidity",
2574
2574
  "changeErrorCode",
2575
+ "openCountryDropdown",
2576
+ "closeCountryDropdown",
2577
+ "strictReject",
2575
2578
  "update:modelValue"
2576
2579
  ],
2577
2580
  setup(n, { expose: d, emit: f }) {
@@ -2615,9 +2618,12 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
2615
2618
  if (!C.value?.isActive()) return;
2616
2619
  let e = C.value.getSelectedCountryData()?.iso2 ?? "";
2617
2620
  e !== T.value && (T.value = e, m("changeCountry", e)), j();
2621
+ }, N = () => m("openCountryDropdown"), P = () => m("closeCountryDropdown"), F = (e) => {
2622
+ let { source: t, rejectedInput: n, reason: r } = e.detail;
2623
+ m("strictReject", t, n, r);
2618
2624
  };
2619
2625
  return a(() => {
2620
- S.value && (C.value = $(S.value, x.value), p.disabled && C.value.setDisabled(p.disabled), p.readonly && C.value.setReadonly(p.readonly), T.value = C.value.getSelectedCountryData()?.iso2 ?? "", C.value.promise.then(() => {
2626
+ S.value && (C.value = $(S.value, x.value), S.value.addEventListener("open:countrydropdown", N), S.value.addEventListener("close:countrydropdown", P), S.value.addEventListener("strict:reject", F), p.disabled && C.value.setDisabled(p.disabled), p.readonly && C.value.setReadonly(p.readonly), T.value = C.value.getSelectedCountryData()?.iso2 ?? "", C.value.promise.then(() => {
2621
2627
  C.value?.isActive() && (v.value && C.value.setNumber(v.value), O ? (O = !1, M()) : (w.value = C.value.getNumber() ?? "", E.value = k(), D.value = E.value ? null : C.value.getValidationError()));
2622
2628
  }));
2623
2629
  }), u(() => p.disabled, (e) => C.value?.setDisabled(e)), u(() => p.readonly, (e) => C.value?.setReadonly(e)), u(() => v.value, (e) => {
@@ -2626,7 +2632,9 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
2626
2632
  let t = e ?? "", n = C.value.getNumber() ?? "";
2627
2633
  document.activeElement === S.value || n === t || (C.value.setNumber(t), A());
2628
2634
  });
2629
- }, { flush: "post" }), o(() => C.value?.destroy()), d({
2635
+ }, { flush: "post" }), o(() => {
2636
+ S.value && (S.value.removeEventListener("open:countrydropdown", N), S.value.removeEventListener("close:countrydropdown", P), S.value.removeEventListener("strict:reject", F)), C.value?.destroy();
2637
+ }), d({
2630
2638
  instance: C,
2631
2639
  input: S
2632
2640
  }), (e, n) => (s(), t("input", i(_.value, {
@@ -1,4 +1,4 @@
1
- import { n as e, t } from "./IntlTelInput-SQtNzOVr.js";
1
+ import { n as e, t } from "./IntlTelInput-DTtMkd4-.js";
2
2
  //#region vue/src/index.ts
3
3
  var n = t;
4
4
  //#endregion
@@ -9,21 +9,29 @@ interface Props {
9
9
  modelValue?: string | null;
10
10
  }
11
11
  type __VLS_Props = Props & SomeOptions;
12
+ type StrictRejectSource = "key" | "paste";
13
+ type StrictRejectReason = "invalid" | "max-length";
12
14
  declare const _default: import('vue').DefineComponent<__VLS_Props, {
13
15
  instance: import('vue').ShallowRef<import('intl-tel-input').Iti | null, import('intl-tel-input').Iti | null>;
14
16
  input: import('vue').Ref<HTMLInputElement | null, HTMLInputElement | null>;
15
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
16
- changeNumber: (...args: any[]) => void;
17
- changeCountry: (...args: any[]) => void;
18
- changeValidity: (...args: any[]) => void;
19
- changeErrorCode: (...args: any[]) => void;
20
- "update:modelValue": (...args: any[]) => void;
17
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
18
+ changeNumber: (value: string) => any;
19
+ changeCountry: (value: string) => any;
20
+ changeValidity: (value: boolean) => any;
21
+ changeErrorCode: (value: number | null) => any;
22
+ openCountryDropdown: () => any;
23
+ closeCountryDropdown: () => any;
24
+ strictReject: (source: StrictRejectSource, rejectedInput: string, reason: StrictRejectReason) => any;
25
+ "update:modelValue": (value: string) => any;
21
26
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
22
- onChangeNumber?: ((...args: any[]) => any) | undefined;
23
- onChangeCountry?: ((...args: any[]) => any) | undefined;
24
- onChangeValidity?: ((...args: any[]) => any) | undefined;
25
- onChangeErrorCode?: ((...args: any[]) => any) | undefined;
26
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
27
+ onChangeNumber?: ((value: string) => any) | undefined;
28
+ onChangeCountry?: ((value: string) => any) | undefined;
29
+ onChangeValidity?: ((value: boolean) => any) | undefined;
30
+ onChangeErrorCode?: ((value: number | null) => any) | undefined;
31
+ onOpenCountryDropdown?: (() => any) | undefined;
32
+ onCloseCountryDropdown?: (() => any) | undefined;
33
+ onStrictReject?: ((source: StrictRejectSource, rejectedInput: string, reason: StrictRejectReason) => any) | undefined;
34
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
27
35
  }>, {
28
36
  usePreciseValidation: boolean;
29
37
  disabled: boolean;
@@ -1,4 +1,4 @@
1
- import { n as e, t } from "./IntlTelInput-SQtNzOVr.js";
1
+ import { n as e, t } from "./IntlTelInput-DTtMkd4-.js";
2
2
  //#region dist/js/utils.js
3
3
  var n = {};
4
4
  //#endregion