@burh/nuxt-core 1.0.211 → 1.0.212

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.
@@ -54,6 +54,7 @@
54
54
  <base-input
55
55
  type="text"
56
56
  v-model="phone"
57
+ v-on:input="maskCellphone($event)"
57
58
  id="phone"
58
59
  :error="errors[0]"
59
60
  :valid="errors.length ? true : false"
@@ -106,8 +107,32 @@ export default {
106
107
  return;
107
108
  }
108
109
 
110
+ this.phone = this.phone.replace(/\D+/g, '');
111
+
109
112
  this.$emit('send-contact', this.name, this.phone);
110
113
  this.$emit('close');
114
+ },
115
+ maskCellphone(v, onlyMasking = false) {
116
+ if (v == null || v == '') {
117
+ return;
118
+ }
119
+ var mask = v.replace(/\D/g, '');
120
+ mask = mask.replace(/^0/, '');
121
+ if (mask.length > 10) {
122
+ mask = mask.replace(/^(\d\d)(\d{5})(\d{4}).*/, '($1) $2-$3');
123
+ } else if (mask.length > 5) {
124
+ mask = mask.replace(/^(\d\d)(\d{4})(\d{0,4}).*/, '($1) $2-$3');
125
+ } else if (mask.length > 2) {
126
+ mask = mask.replace(/^(\d\d)(\d{0,5})/, '($1) $2');
127
+ } else {
128
+ mask = mask.replace(/^(\d*)/, '($1');
129
+ }
130
+
131
+ if (!onlyMasking) {
132
+ this.phone = mask;
133
+ } else {
134
+ return mask;
135
+ }
111
136
  }
112
137
  }
113
138
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burh/nuxt-core",
3
- "version": "1.0.211",
3
+ "version": "1.0.212",
4
4
  "description": "Design System and Components.",
5
5
  "author": "Burh",
6
6
  "scripts": {