react-survey-builder 1.0.44 → 1.0.46

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.
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validatePhone = exports.validateEmail = exports.validateDate = exports.toE164PhoneNumber = void 0;
7
+ var _reactPhoneNumberInput = require("react-phone-number-input");
8
+ var validateEmail = exports.validateEmail = function validateEmail(email) {
9
+ return email.match(
10
+ // eslint-disable-next-line no-useless-escape
11
+ /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
12
+ };
13
+ var toE164PhoneNumber = exports.toE164PhoneNumber = function toE164PhoneNumber(phoneNumberValue) {
14
+ if (phoneNumberValue !== undefined && phoneNumberValue !== null) {
15
+ //Filter only numbers from the input
16
+ var cleaned = ('' + phoneNumberValue).replace(/\D/g, '');
17
+
18
+ //Check if the input is of correct
19
+ var match = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/);
20
+ if (match) {
21
+ //Remove the matched extension code
22
+ //Change this to format for any country code.
23
+ var intlCode = match[1] ? '+1' : '+1';
24
+ return [intlCode, match[2], match[3], match[4]].join('');
25
+ }
26
+ return '';
27
+ } else {
28
+ return '';
29
+ }
30
+ };
31
+ var validatePhone = exports.validatePhone = function validatePhone(phone) {
32
+ return (0, _reactPhoneNumberInput.isValidPhoneNumber)(toE164PhoneNumber(phone), 'US');
33
+ };
34
+ var validateDate = exports.validateDate = function validateDate(dateString) {
35
+ if (dateString !== undefined && dateString !== null && dateString !== "") {
36
+ var dateformat = /^(0?[1-9]|1[0-2])[\/](0?[1-9]|[1-2][0-9]|3[01])[\/]\d{4}$/;
37
+
38
+ // Matching the date through regular expression
39
+ if (dateString.match(dateformat)) {
40
+ var operator = dateString.split('/');
41
+
42
+ // Extract the string into month, date and year
43
+ var datepart = [];
44
+ if (operator.length > 1) {
45
+ datepart = dateString.split('/');
46
+ }
47
+ var month = parseInt(datepart[0]);
48
+ var day = parseInt(datepart[1]);
49
+ var year = parseInt(datepart[2]);
50
+ if (day > 31 || day < 1) {
51
+ return false;
52
+ }
53
+ var currentYear = new Date().getFullYear();
54
+ if (year < 1900 || year > currentYear + 5) {
55
+ return false;
56
+ }
57
+
58
+ // Create a list of days of a month
59
+ var ListofDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
60
+ if (month === 1 || month > 2) {
61
+ if (day > ListofDays[month - 1]) {
62
+ // to check if the date is out of range
63
+ return false;
64
+ }
65
+ } else if (month === 2) {
66
+ var leapYear = false;
67
+ if (!(year % 4) && year % 100 || !(year % 400)) leapYear = true;
68
+ if (leapYear === false && day >= 29) return false;else if (leapYear === true && day > 29) {
69
+ // console.log('Invalid date format!');
70
+ return false;
71
+ }
72
+ } else if (month > 12 || month < 1) {
73
+ return false;
74
+ }
75
+ } else {
76
+ // console.log("Invalid date format!");
77
+ return false;
78
+ }
79
+ }
80
+ return true;
81
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-survey-builder",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "description": "A complete survey builder for react.",
5
5
  "main": "lib/index.js",
6
6
  "types": "types/index.d.ts",
@@ -44,15 +44,15 @@
44
44
  "moment": "^2.30.1",
45
45
  "moment-timezone": "^0.5.44",
46
46
  "prop-types": "^15.7.2",
47
- "react": "^18.2.0",
47
+ "react": ">=18.2.0",
48
48
  "react-bootstrap": "^2.10.2",
49
49
  "react-bootstrap-range-slider": "^3.0.8",
50
50
  "react-bootstrap-typeahead": "^6.3.2",
51
51
  "react-dnd": "^11.1.3",
52
52
  "react-dnd-html5-backend": "^11.1.3",
53
- "react-dom": "^18.2.0",
53
+ "react-dom": ">=18.2.0",
54
54
  "react-draft-wysiwyg": "^1.15.0",
55
- "react-hook-form": "^7.45.4",
55
+ "react-hook-form": "^7.51.1",
56
56
  "react-icons": "^5.0.1",
57
57
  "react-imask": "^7.6.0",
58
58
  "react-phone-number-input": "^3.3.9",