@mozaic-ds/vue 0.28.2 → 0.29.1-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mozaic-ds/vue",
3
- "version": "0.28.2",
3
+ "version": "0.29.1-beta.0",
4
4
  "description": "Vue.js implementation of Mozaic Design System",
5
5
  "author": "Adeo - Mozaic Design System",
6
6
  "scripts": {
@@ -23,10 +23,10 @@
23
23
  "postinstall.js"
24
24
  ],
25
25
  "dependencies": {
26
- "@mozaic-ds/css-dev-tools": "^1.44.0",
27
- "@mozaic-ds/icons": "^1.44.0",
28
- "@mozaic-ds/styles": "^1.44.0",
29
- "@mozaic-ds/web-fonts": "^1.22.0",
26
+ "@mozaic-ds/css-dev-tools": "1.44.0",
27
+ "@mozaic-ds/icons": "1.45.0",
28
+ "@mozaic-ds/styles": "1.45.1",
29
+ "@mozaic-ds/web-fonts": "1.22.0",
30
30
  "core-js": "^3.25.5",
31
31
  "libphonenumber-js": "^1.10.14",
32
32
  "vue": "^2.6.14",
@@ -6,6 +6,7 @@
6
6
  class="mc-text-input mc-password-input__control"
7
7
  :class="setInputClasses"
8
8
  :aria-invalid="isInvalid"
9
+ spellcheck="false"
9
10
  />
10
11
 
11
12
  <button
@@ -74,6 +74,7 @@
74
74
  :value="phoneNumber"
75
75
  :placeholder="placeholder"
76
76
  :maxlength="maxlength"
77
+ spellcheck="false"
77
78
  @blur="onChangePhoneNumber"
78
79
  @focus="(event) => (formatOnBlur ? cleanFormat(event) : null)"
79
80
  @keyup="onKeyPressPhoneNumber"
@@ -19,7 +19,7 @@
19
19
  v-bind="tab.attrs"
20
20
  :to="tab.to"
21
21
  class="mc-tabs__element"
22
- :class="setLinkClass(tab)"
22
+ :class="setActiveClass(tab)"
23
23
  active-class="mc-tabs__element--selected"
24
24
  >
25
25
  <span class="mc-tabs__text">{{ tab.text }}</span>
@@ -35,9 +35,14 @@
35
35
  class="mc-tabs__element"
36
36
  role="tab"
37
37
  :aria-selected="tab.active ? 'true' : 'false'"
38
- :class="setLinkClass(tab)"
39
- v-bind="tab.attrs"
40
- @click="onTabClicked($event, tab, index)"
38
+ :class="setActiveClass(tab)"
39
+ @click="
40
+ manageTabs(
41
+ $event.target,
42
+ $event,
43
+ Object.assign({ index: index }, tab)
44
+ )
45
+ "
41
46
  >
42
47
  <span class="mc-tabs__text">{{ tab.text }}</span>
43
48
  </component>
@@ -89,40 +94,41 @@ export default {
89
94
  },
90
95
  activeIndex: {
91
96
  type: Number,
92
- default: null,
97
+ default: 0,
93
98
  },
94
99
  },
95
100
 
96
101
  data() {
97
102
  return {
98
103
  tablist: null,
99
- localActiveIndex: null,
100
104
  };
101
105
  },
102
106
 
103
107
  computed: {
104
108
  setClasses() {
105
- return {
106
- 'mc-tabs--full': this.align === 'full',
107
- 'mc-tabs--full-centered': this.align === 'centered',
108
- 'mc-tabs--dropdown': this.type === 'dropdown',
109
- 'mc-tabs--no-divider': !this.shadow,
110
- };
109
+ const classes = [
110
+ {
111
+ 'mc-tabs--full': this.align === 'full',
112
+ 'mc-tabs--full-centered': this.align === 'centered',
113
+ 'mc-tabs--dropdown': this.type === 'dropdown',
114
+ 'mc-tabs--no-shadow': !this.shadow,
115
+ },
116
+ ];
117
+
118
+ return classes;
111
119
  },
112
120
  },
113
121
 
114
122
  watch: {
115
123
  activeIndex(newValue) {
116
- this.localActiveIndex = newValue;
117
- },
118
- localActiveIndex: {
119
- handler: function (newValue) {
120
- const selectedTab = this.getTabFromIndex(newValue);
121
- if (selectedTab) {
122
- this.setTabState(selectedTab);
123
- }
124
- },
125
- immediate: true,
124
+ const tab = this.getTabFromIndex(newValue);
125
+ if (tab && this.tabs[newValue]) {
126
+ this.manageTabs(
127
+ tab,
128
+ null,
129
+ Object.assign({ index: newValue }, this.tabs[newValue])
130
+ );
131
+ }
126
132
  },
127
133
  },
128
134
 
@@ -132,16 +138,17 @@ export default {
132
138
  this.tablist = this.$refs.tablist;
133
139
 
134
140
  if (this.activeIndex) {
135
- this.localActiveIndex = this.activeIndex;
141
+ const tab = this.getTabFromIndex(this.activeIndex);
142
+ if (tab) {
143
+ this.manageTabs(tab);
144
+ }
136
145
  } else {
137
- const isActive = this.tabs.some(
138
- (tab) =>
139
- Object.prototype.hasOwnProperty.call(tab, 'active') &&
140
- tab.active === true
146
+ const isActive = this.tabs.some((tab) =>
147
+ Object.prototype.hasOwnProperty.call(tab, 'active')
141
148
  );
142
-
143
149
  if (!isActive) {
144
- this.localActiveIndex = 0;
150
+ const firstTab = this.tablist.querySelector('.mc-tabs__element');
151
+ this.manageTabs(firstTab);
145
152
  }
146
153
  }
147
154
  }
@@ -149,20 +156,34 @@ export default {
149
156
  },
150
157
 
151
158
  methods: {
152
- setLinkClass: function (tab) {
153
- return {
154
- 'mc-tabs__element--selected': tab.active,
155
- 'mc-tabs__element--disabled': tab.disabled,
156
- };
159
+ setActiveClass: function (tab) {
160
+ const tabClasses = [];
161
+
162
+ if (tab.active) {
163
+ tabClasses.push('mc-tabs__element--selected');
164
+ }
165
+
166
+ if (tab.disabled) {
167
+ tabClasses.push('mc-tabs__element--disabled');
168
+ }
169
+
170
+ return tabClasses;
157
171
  },
158
- setTabState(tab) {
172
+ manageTabs: function (el, e, tab) {
173
+ if (tab && tab.disabled) {
174
+ return;
175
+ }
176
+ if (e) {
177
+ this.$emit('tab-clicked', e.currentTarget, tab);
178
+ }
179
+
159
180
  this.tablist.querySelectorAll('.mc-tabs__element').forEach((el) => {
160
181
  el.classList.remove('mc-tabs__element--selected');
161
182
  el.setAttribute('aria-selected', 'false');
162
183
  });
163
184
 
164
- tab.classList.add('mc-tabs__element--selected');
165
- tab.setAttribute('aria-selected', 'true');
185
+ el.classList.add('mc-tabs__element--selected');
186
+ el.setAttribute('aria-selected', 'true');
166
187
  },
167
188
  getTabFromIndex: function (index) {
168
189
  if (
@@ -173,22 +194,11 @@ export default {
173
194
  return this.tablist.children[index].children[0];
174
195
  }
175
196
  },
176
- onTabClicked(e, tab, index) {
177
- if (tab && tab.disabled) {
178
- return;
179
- }
180
-
181
- if (typeof this.activeIndex !== 'number') {
182
- this.localActiveIndex = index;
183
- }
184
-
185
- this.$emit('tab-clicked', e.target, Object.assign({ index: index }, tab));
186
- },
187
197
  },
188
198
  };
189
199
  </script>
190
200
 
191
201
  <style lang="scss">
192
- @import 'settings-tools/_all-settings';
193
- @import 'components/_c.tabs';
202
+ @import 'settings-tools/all-settings';
203
+ @import 'components/c.tabs';
194
204
  </style>
@@ -7,6 +7,7 @@
7
7
  ]"
8
8
  :aria-invalid="isInvalid"
9
9
  :value="value"
10
+ spellcheck="false"
10
11
  v-on="inputListeners"
11
12
  />
12
13
  </template>
@@ -6,6 +6,7 @@
6
6
  :class="setClasses"
7
7
  :aria-invalid="isInvalid"
8
8
  :value="value"
9
+ spellcheck="false"
9
10
  v-on="inputListeners"
10
11
  />
11
12
  </template>