@jobber/components 4.11.1 → 4.12.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.
|
@@ -84,11 +84,23 @@ function InputPhoneNumber(_a) {
|
|
|
84
84
|
var { required } = _a, props = tslib_es6.__rest(_a, ["required"]);
|
|
85
85
|
const { placeholder, validations } = props;
|
|
86
86
|
const pattern = "(***) ***-****";
|
|
87
|
+
const errorSubject = placeholder || "Phone number";
|
|
87
88
|
return (React__default["default"].createElement(InputMask, { pattern: pattern, strict: false },
|
|
88
|
-
React__default["default"].createElement(FormField.FormField, Object.assign({}, props, { type: "tel", validations: Object.assign({ required: {
|
|
89
|
+
React__default["default"].createElement(FormField.FormField, Object.assign({}, props, { type: "tel", validations: Object.assign(Object.assign({ required: {
|
|
89
90
|
value: Boolean(required),
|
|
90
|
-
message: `${
|
|
91
|
-
} }, validations) }))));
|
|
91
|
+
message: `${errorSubject} is required`,
|
|
92
|
+
} }, validations), { validate: getPhoneNumberValidation }) }))));
|
|
93
|
+
function getPhoneNumberValidation(value) {
|
|
94
|
+
// Remove space, parenthesis and hyphen
|
|
95
|
+
const cleanValue = value.replace(/[- )(]/g, "");
|
|
96
|
+
if (cleanValue.length < 10) {
|
|
97
|
+
return `${errorSubject} must contain ten or more digits`;
|
|
98
|
+
}
|
|
99
|
+
if (typeof (validations === null || validations === void 0 ? void 0 : validations.validate) === "function") {
|
|
100
|
+
return validations.validate(value);
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
92
104
|
}
|
|
93
105
|
|
|
94
106
|
exports.InputPhoneNumber = InputPhoneNumber;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"> 1%",
|
|
84
84
|
"IE 10"
|
|
85
85
|
],
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "76676bbc5392f8d5d20fcf8812f1b051f900fb6d"
|
|
87
87
|
}
|