Skip to content

Commit

Permalink
React component usePreciseValidation prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jackocnr committed Mar 17, 2024
1 parent 96f9faf commit 2ea955e
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 85 deletions.
4 changes: 2 additions & 2 deletions react/build/IntlTelInput.cjs.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions react/build/IntlTelInput.cjs.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions react/build/IntlTelInput.esm.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions react/build/IntlTelInput.esm.js.map

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions react/demo/simple-bundle.js

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions react/demo/validation-bundle.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion react/src/IntlTelInput.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable react/jsx-filename-extension */
/* eslint-disable import/no-extraneous-dependencies */
import React, { useRef, useEffect } from 'react';
import PropTypes from 'prop-types';
import intlTelInput from "../../build/js/intlTelInput";
Expand All @@ -9,6 +10,7 @@ const IntlTelInput = ({
onChangeCountry,
onChangeValidity,
onChangeErrorCode,
usePreciseValidation,
initOptions,
className,
disabled,
Expand All @@ -28,7 +30,8 @@ const IntlTelInput = ({
onChangeNumber(num);
onChangeCountry(countryIso);

if (itiRef.current.isValidNumber()) {
const isValid = usePreciseValidation ? itiRef.current.isValidNumberPrecise() : itiRef.current.isValidNumber();
if (isValid) {
onChangeValidity(true);
onChangeErrorCode(null);
} else {
Expand Down Expand Up @@ -71,6 +74,7 @@ IntlTelInput.propTypes = {
onChangeCountry: PropTypes.func,
onChangeValidity: PropTypes.func,
onChangeErrorCode: PropTypes.func,
usePreciseValidation: PropTypes.bool,
initOptions: PropTypes.shape({
allowDropdown: PropTypes.bool,
autoPlaceholder: PropTypes.string,
Expand Down Expand Up @@ -108,6 +112,7 @@ IntlTelInput.defaultProps = {
onChangeCountry: () => {},
onChangeValidity: () => {},
onChangeErrorCode: () => {},
usePreciseValidation: false,
initOptions: {},
className: "",
disabled: false,
Expand Down

0 comments on commit 2ea955e

Please sign in to comment.