@jobber/components 4.11.1 → 4.12.1

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.
@@ -11,7 +11,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
11
11
 
12
12
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
13
13
 
14
- var css_248z = ".EQDmgmJchDA- {\n margin: 0;\n}\n\n.DkzfClUGQlc- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n border-bottom: calc(16px / 16) solid rgb(225, 225, 225);\n border-bottom: var(--border-base) solid var(--color-border);\n}\n\n.DkzfClUGQlc-:first-child {\n padding-top: 0;\n}\n\n.DkzfClUGQlc-:last-child {\n padding-bottom: 0;\n border-bottom: none;\n}\n\n.DkzfClUGQlc- dd {\n min-width: calc(16px * 7.5);\n min-width: calc(var(--base-unit) * 7.5);\n box-sizing: border-box;\n padding-right: calc(16px / 2);\n padding-right: var(--space-small);\n -webkit-margin-start: 0;\n margin-left: 0;\n -ms-flex: 1 1 40%;\n flex: 1 1 40%;\n}\n\n.DkzfClUGQlc- dt {\n -ms-flex: 1 1 60%;\n flex: 1 1 60%;\n}\n";
14
+ var css_248z = ".EQDmgmJchDA- {\n margin: 0;\n}\n\n.DkzfClUGQlc- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n border-bottom: calc(16px / 16) solid rgb(225, 225, 225);\n border-bottom: var(--border-base) solid var(--color-border);\n}\n\n.DkzfClUGQlc-:first-child {\n padding-top: 0;\n}\n\n.DkzfClUGQlc-:last-child {\n padding-bottom: 0;\n border-bottom: none;\n}\n\n.DkzfClUGQlc- dd {\n min-width: calc(16px * 7.5);\n min-width: calc(var(--base-unit) * 7.5);\n box-sizing: border-box;\n padding-right: calc(16px / 2);\n padding-right: var(--space-small);\n -webkit-margin-start: 0;\n margin-left: 0;\n -ms-flex: 1 1 60%;\n flex: 1 1 60%;\n}\n\n.DkzfClUGQlc- dt {\n -ms-flex: 1 1 40%;\n flex: 1 1 40%;\n}\n";
15
15
  var styles = {"descriptionList":"EQDmgmJchDA-","termGroup":"DkzfClUGQlc-"};
16
16
  styleInject_es.styleInject(css_248z);
17
17
 
@@ -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: `${placeholder || "This"} is required`,
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.11.1",
3
+ "version": "4.12.1",
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": "9a18e5b1eff8708289ee20dc5a090ef06fc51346"
86
+ "gitHead": "8ef4129d2e9df9e4436f0b848c5809dd23f7cafc"
87
87
  }