@carbon/vue 2.16.0 → 2.17.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/vue",
3
3
  "description": "A collection of components for the Carbon Design System built using Vue.js",
4
- "version": "2.16.0",
4
+ "version": "2.17.1",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -63,7 +63,7 @@
63
63
  "sideEffects": true,
64
64
  "dependencies": {
65
65
  "@carbon/icons-vue": "10.6.1",
66
- "carbon-components": "10.7.0",
66
+ "carbon-components": "10.7.3",
67
67
  "flatpickr": "4.6.3",
68
68
  "vue": "^2.6.10"
69
69
  },
@@ -73,5 +73,5 @@
73
73
  "eslint-plugin-prettier": "^3.1.1",
74
74
  "vue-template-compiler": "^2.6.10"
75
75
  },
76
- "gitHead": "cbf298ff93b0cf9ccff74772b0203c027558c550"
76
+ "gitHead": "638a3416a706a1172f45f09e37082e6527cd0ad4"
77
77
  }
@@ -18,15 +18,15 @@
18
18
  <template>
19
19
  <div :class="{ 'bx--form-item': formItem }">
20
20
  <div class="bx--dropdown__wrapper" :class="{ 'bx--dropdown__wrapper--inline': inline, 'cv-dropdown': !formItem }">
21
- <span v-if="label" :id="`${uid}-label`" class="bx--label" :class="{ 'bx--label--disabled': $attrs.disabled }">
21
+ <span v-if="label" :id="`${uid}-label`" class="bx--label" :class="{ 'bx--label--disabled': disabled }">
22
22
  {{ label }}
23
23
  </span>
24
24
 
25
25
  <div
26
26
  v-if="!inline && isHelper"
27
27
  class="bx--form__helper-text"
28
- :class="{ 'bx--form__helper-text--disabled': $attrs.disabled }"
29
- :aria-disabled="$attrs.disabled"
28
+ :class="{ 'bx--form__helper-text--disabled': disabled }"
29
+ :aria-disabled="disabled"
30
30
  >
31
31
  <slot name="helper-text">{{ helperText }}</slot>
32
32
  </div>
@@ -42,7 +42,7 @@
42
42
  'bx--dropdown--up': up,
43
43
  'bx--dropdown--open': open,
44
44
  'bx--dropdown--invalid': isInvalid,
45
- 'bx--dropdown--disabled': $attrs.disabled,
45
+ 'bx--dropdown--disabled': disabled,
46
46
  'bx--dropdown--inline': inline,
47
47
  }"
48
48
  v-bind="$attrs"
@@ -109,6 +109,7 @@ export default {
109
109
  mixins: [themeMixin, uidMixin],
110
110
  components: { WarningFilled16, ChevronDown16 },
111
111
  props: {
112
+ disabled: Boolean,
112
113
  formItem: { type: Boolean, default: true },
113
114
  inline: Boolean,
114
115
  invalidMessage: { type: String, default: undefined },
@@ -162,15 +163,22 @@ export default {
162
163
  },
163
164
  set(val) {
164
165
  const childItems = this.dropdownItems();
166
+ let selectedChild;
165
167
  for (let index in childItems) {
166
168
  let child = childItems[index];
167
169
  let selected = child.value === val;
168
170
  child.internalSelected = selected;
169
171
 
170
172
  if (selected) {
171
- this.$refs.valueContent.innerHTML = child.internalContent;
173
+ selectedChild = child;
172
174
  }
173
175
  }
176
+ if (selectedChild) {
177
+ this.$refs.valueContent.innerHTML = selectedChild.internalContent;
178
+ } else {
179
+ this.$refs.valueContent.innerHTML = this.placeholder;
180
+ }
181
+
174
182
  if (this.dataValue !== val) {
175
183
  // only raise event on change
176
184
  this.dataValue = val;
@@ -246,16 +254,20 @@ export default {
246
254
  this.$el.focus();
247
255
  },
248
256
  onClick(ev) {
249
- this.open = !this.open;
250
- if (!this.open) {
251
- this.$el.focus();
252
- }
257
+ if (this.disabled) {
258
+ ev.preventDefault();
259
+ } else {
260
+ this.open = !this.open;
261
+ if (!this.open) {
262
+ this.$el.focus();
263
+ }
253
264
 
254
- if (ev.target.classList.contains('bx--dropdown-link')) {
255
- const targetItemEl = ev.target.parentNode;
256
- const newValue = targetItemEl.getAttribute('data-value');
265
+ if (ev.target.classList.contains('bx--dropdown-link')) {
266
+ const targetItemEl = ev.target.parentNode;
267
+ const newValue = targetItemEl.getAttribute('data-value');
257
268
 
258
- this.internalValue = newValue;
269
+ this.internalValue = newValue;
270
+ }
259
271
  }
260
272
  },
261
273
  },
@@ -19,6 +19,14 @@
19
19
  <p class="bx--inline-notification__subtitle">{{ subTitle }}</p>
20
20
  </div>
21
21
  </div>
22
+ <button
23
+ v-if="actionLabel"
24
+ @click="$emit('action')"
25
+ class="bx--inline-notification__action-button bx--btn bx--btn--sm bx--btn--ghost"
26
+ type="button"
27
+ >
28
+ {{ actionLabel }}
29
+ </button>
22
30
  <button
23
31
  type="button"
24
32
  :aria-label="closeAriaLabel"
@@ -43,6 +51,7 @@ export default {
43
51
  components: { Close16 },
44
52
  mixins: [notificationMixin],
45
53
  props: {
54
+ actionLabel: { type: String, default: '' },
46
55
  closeAriaLabel: { type: String, default: 'Dismiss notification' },
47
56
  kind: {
48
57
  type: String,
@@ -11,8 +11,8 @@
11
11
  >
12
12
  <svg class="bx--loading__svg" viewBox="-75 -75 150 150">
13
13
  <title>Loading</title>
14
- <circle v-if="small" class="bx--loading__background" cx="0" cy="0" r="37.5"></circle>
15
- <circle class="bx--loading__stroke" cx="0" cy="0" r="37.5"></circle>
14
+ <circle v-if="small" class="bx--loading__background" cx="0" cy="0" :r="loadingRadius" />
15
+ <circle class="bx--loading__stroke" cx="0" cy="0" :r="loadingRadius" />
16
16
  </svg>
17
17
  </div>
18
18
  </div>
@@ -32,6 +32,9 @@ export default {
32
32
 
33
33
  return `bx--loading-overlay ${this.stopped ? 'bx--loading-overlay--stop' : ''}`;
34
34
  },
35
+ loadingRadius() {
36
+ return this.small ? '26.8125' : '37.5';
37
+ },
35
38
  },
36
39
  data() {
37
40
  return {
@@ -8,14 +8,14 @@
8
8
  }"
9
9
  @focusout="onFocusOut"
10
10
  >
11
- <label v-if="title" :for="uid" class="bx--label" :class="{ 'bx--label--disabled': $attrs.disabled }">
11
+ <label v-if="title" :for="uid" class="bx--label" :class="{ 'bx--label--disabled': disabled }">
12
12
  {{ title }}
13
13
  </label>
14
14
 
15
15
  <div
16
16
  v-if="!inline && isHelper"
17
17
  class="bx--form__helper-text"
18
- :class="{ 'bx--form__helper-text--disabled': $attrs.disabled }"
18
+ :class="{ 'bx--form__helper-text--disabled': disabled }"
19
19
  >
20
20
  <slot name="helper-text">{{ helperText }}</slot>
21
21
  </div>
@@ -28,7 +28,7 @@
28
28
  'bx--list-box--light': theme === 'light',
29
29
  'bx--multi-select--expanded': open,
30
30
  'bx--multi-select--invalid': isInvalid,
31
- 'bx--multi-select--disabled bx--list-box--disabled': $attrs.disabled,
31
+ 'bx--multi-select--disabled bx--list-box--disabled': disabled,
32
32
  'bx--multi-select--inline bx--list-box--inline': inline,
33
33
  'bx--multi-select--selected': dataValue.length > 0,
34
34
  'bx--combo-box': filterable,
@@ -57,6 +57,7 @@
57
57
  >
58
58
  <cv-tag
59
59
  :class="{ 'bx--list-box__selection--multi': filterable && dataValue.length > 0 }"
60
+ :disabled="disabled"
60
61
  v-show="dataValue.length > 0"
61
62
  kind="filter"
62
63
  :label="`${dataValue.length}`"
@@ -152,6 +153,7 @@ export default {
152
153
  props: {
153
154
  autoFilter: Boolean,
154
155
  autoHighlight: Boolean,
156
+ disabled: Boolean,
155
157
  inline: Boolean,
156
158
  invalidMessage: { type: String, default: undefined },
157
159
  helperText: { type: String, default: undefined },
@@ -391,8 +393,12 @@ export default {
391
393
  }
392
394
  },
393
395
  onClick(ev) {
394
- this.doOpen(!this.open);
395
- this.inputOrButtonFocus();
396
+ if (this.disabled) {
397
+ ev.preventDefault();
398
+ } else {
399
+ this.doOpen(!this.open);
400
+ this.inputOrButtonFocus();
401
+ }
396
402
  },
397
403
  clearValues() {
398
404
  this.dataValue = [];
@@ -119,7 +119,7 @@ export default {
119
119
  if (this.open) {
120
120
  if (
121
121
  ev.relatedTarget === null ||
122
- !(this.$el === ev.relatedTarget || this.$refs.popup.contains(ev.relatedTarget))
122
+ !(this.$refs.trigger === ev.relatedTarget || this.$refs.popup.contains(ev.relatedTarget))
123
123
  ) {
124
124
  this.open = false;
125
125
  this.positionListen(false);
@@ -9,21 +9,23 @@
9
9
  @keydown.right.prevent="moveRight"
10
10
  @keydown.left.prevent="moveLeft"
11
11
  >
12
- <cv-dropdown class="bx--tabs-trigger" :value="`${selectedIndex}`" @change="onDropChange" :form-item="false">
13
- <cv-dropdown-item v-for="(tab, index) in tabs" :key="`drop-${index}`" :value="`${index}`">
14
- {{ tab.label }}
15
- </cv-dropdown-item>
12
+ <cv-dropdown class="bx--tabs-trigger" :value="`${selectedId}`" @change="onDropChange" :form-item="false">
13
+ <cv-dropdown-item v-for="tab in tabs" :key="`drop-${tab.uid}`" :value="`${tab.uid}`">{{
14
+ tab.label
15
+ }}</cv-dropdown-item>
16
16
  </cv-dropdown>
17
17
  <ul class="bx--tabs__nav bx--tabs__nav--hidden" role="tablist">
18
18
  <li
19
- v-for="(tab, index) in tabs"
20
- :key="index"
19
+ v-for="tab in tabs"
20
+ :key="tab.uid"
21
21
  class="cv-tabs-button bx--tabs__nav-item"
22
22
  :class="{
23
- 'bx--tabs__nav-item--selected': selectedIndex == index,
24
- 'bx--tabs__nav-item--disabled': disabledTabs.indexOf(index) !== -1,
23
+ 'bx--tabs__nav-item--selected': selectedId == tab.uid,
24
+ 'bx--tabs__nav-item--disabled': disabledTabs.indexOf(tab.uid) !== -1,
25
25
  }"
26
- role="presentation"
26
+ role="tab"
27
+ :aria-selected="selectedId == tab.uid"
28
+ :aria-disabled="disabledTabs.indexOf(tab.uid) !== -1"
27
29
  >
28
30
  <a
29
31
  class="bx--tabs__nav-link"
@@ -31,8 +33,7 @@
31
33
  role="tab"
32
34
  :aria-controls="tab.uid"
33
35
  :id="`${tab.uid}-link`"
34
- aria-selected="false"
35
- @click="onTabClick(index)"
36
+ @click="onTabClick(tab.uid)"
36
37
  ref="link"
37
38
  >{{ tab.label }}</a
38
39
  >
@@ -58,7 +59,6 @@ export default {
58
59
  data() {
59
60
  return {
60
61
  tabs: [],
61
- selectedIndex: -1,
62
62
  selectedId: undefined,
63
63
  disabledTabs: [],
64
64
  };
@@ -73,51 +73,59 @@ export default {
73
73
  },
74
74
  methods: {
75
75
  onDropChange(val) {
76
- this.onTabClick(parseInt(val));
76
+ this.onTabClick(val);
77
77
  },
78
78
  onCvMount(srcComponent) {
79
79
  this.tabs.push(srcComponent);
80
80
 
81
81
  this.checkDisabled(srcComponent);
82
- if (this.selectedIndex < 0) {
82
+ if (this.selectedId === undefined) {
83
83
  this.checkSelected();
84
84
  }
85
85
  },
86
86
  onCvBeforeDestroy(srcComponent) {
87
87
  const tabIndex = this.tabs.findIndex(item => item.uid === srcComponent.uid);
88
88
  if (tabIndex > -1) {
89
+ const wasSelected = srcComponent.uid === this.selectedId;
90
+
89
91
  this.tabs.splice(tabIndex, 1);
92
+ this.selectedId = undefined;
90
93
 
91
94
  this.checkDisabled(srcComponent);
92
- if (tabIndex <= this.selectedIndex) {
95
+
96
+ if (wasSelected) {
93
97
  this.checkSelected();
94
98
  }
95
99
  }
96
100
  },
97
- onTabClick(index) {
98
- if (this.disabledTabs.indexOf(index) === -1) {
99
- if (this.selectedId !== this.tabs[index].uid) {
100
- this.selectedIndex = index;
101
- this.selectedId = this.tabs[index].uid;
101
+ onTabClick(id) {
102
+ if (this.disabledTabs.indexOf(id) === -1) {
103
+ if (this.selectedId !== id) {
104
+ let newIndex = -1;
105
+
106
+ this.selectedId = id;
102
107
 
103
108
  for (let i = 0; i < this.tabs.length; i++) {
104
- this.tabs[i].internalSelected = i === index;
109
+ if (this.tabs[i].uid === id) {
110
+ this.tabs[i].internalSelected = true;
111
+ newIndex = i;
112
+ } else {
113
+ this.tabs[i].internalSelected = false;
114
+ }
105
115
  }
106
- this.$emit('tab-selected', index);
116
+
117
+ this.$emit('tab-selected', newIndex);
107
118
  }
108
119
  }
109
120
  },
110
121
  onCvSelected(srcComponent) {
111
- const tabIndex = this.tabs.findIndex(item => item.uid === srcComponent.uid);
112
- this.onTabClick(tabIndex);
122
+ this.onTabClick(srcComponent.uid);
113
123
  },
114
124
  onCvDisabled(srcComponent) {
115
- const tabIndex = this.tabs.findIndex(item => item.uid === srcComponent.uid);
116
- this.disabledTabs.push(tabIndex);
125
+ this.disabledTabs.push(srcComponent.uid);
117
126
  },
118
127
  onCvEnabled(srcComponent) {
119
- const tabIndex = this.tabs.findIndex(item => item.uid === srcComponent.uid);
120
- let arrIdx = this.disabledTabs.indexOf(tabIndex);
128
+ let arrIdx = this.disabledTabs.indexOf(srcComponent.uid);
121
129
  if (arrIdx !== -1) {
122
130
  this.disabledTabs.splice(arrIdx, 1);
123
131
  }
@@ -134,12 +142,13 @@ export default {
134
142
 
135
143
  for (let i = 0; i < this.tabs.length; i++) {
136
144
  if (this.tabs[i].internalSelected) {
137
- this.onTabClick(i);
145
+ this.onTabClick(this.tabs[i].uid);
138
146
  somethingSelected = true;
139
147
  }
140
148
  }
149
+
141
150
  if (!this.noDefaultToFirst && !somethingSelected && this.tabs.length) {
142
- this.onTabClick(0);
151
+ this.onTabClick(this.tabs[0].uid);
143
152
  }
144
153
  },
145
154
  isAllTabsDisabled() {
@@ -149,42 +158,65 @@ export default {
149
158
  if (this.isAllTabsDisabled()) {
150
159
  return;
151
160
  }
161
+ let newId;
152
162
  let newIndex;
153
- if (this.selectedIndex > 0) {
154
- newIndex = this.selectedIndex - 1;
163
+
164
+ if (this.selectedId) {
165
+ newIndex = this.tabs.indexOf(this.selectedId);
166
+ }
167
+
168
+ if (newIndex > 0) {
169
+ newIndex--;
155
170
  } else {
156
171
  newIndex = this.tabs.length - 1;
157
172
  }
158
- while (this.disabledTabs.indexOf(newIndex) !== -1) {
173
+ newId = this.tabs[newIndex].uid;
174
+
175
+ while (this.disabledTabs.indexOf(newId) !== -1) {
159
176
  if (newIndex > 0) {
160
177
  newIndex--;
161
178
  } else {
162
179
  newIndex = this.tabs.length - 1;
163
180
  }
181
+ newId = this.tabs[newIndex].uid;
164
182
  }
165
- this.onTabClick(newIndex);
183
+ this.onTabClick(newId);
166
184
  this.$refs.link[newIndex].focus();
167
185
  },
168
186
  moveRight() {
169
187
  if (this.isAllTabsDisabled()) {
170
188
  return;
171
189
  }
190
+ let newId;
172
191
  let newIndex;
173
- if (this.selectedIndex < this.tabs.length - 1) {
174
- newIndex = this.selectedIndex + 1;
192
+
193
+ if (this.selectedId) {
194
+ newIndex = this.tabs.indexOf(this.selectedId);
195
+ }
196
+
197
+ if (newIndex < this.tabs.length - 1) {
198
+ newIndex++;
175
199
  } else {
176
200
  newIndex = 0;
177
201
  }
202
+ newId = this.tabs[newIndex].uid;
203
+
178
204
  while (this.disabledTabs.indexOf(newIndex) !== -1) {
179
205
  if (newIndex < this.tabs.length - 1) {
180
- newIndex = newIndex + 1;
206
+ newIndex++;
181
207
  } else {
182
208
  newIndex = 0;
183
209
  }
210
+ newId = this.tabs[newIndex].uid;
184
211
  }
185
- this.onTabClick(newIndex);
212
+
213
+ this.onTabClick(newId);
186
214
  this.$refs.link[newIndex].focus();
187
215
  },
216
+ selected(index) {
217
+ let selItem = this.tabs[index ? index : -1];
218
+ this.selectedId = selItem ? selItem.uid : undefined;
219
+ },
188
220
  },
189
221
  };
190
222
  </script>
@@ -8,7 +8,7 @@
8
8
  'bx--tag--disabled': disabled,
9
9
  },
10
10
  ]"
11
- tabindex="0"
11
+ :tabindex="!disabled ? 0 : undefined"
12
12
  role="listitem"
13
13
  :title="title"
14
14
  @keydown.enter.stop.prevent="$emit('remove')"
@@ -16,7 +16,7 @@
16
16
  @keyup.space.prevent="$emit('remove')"
17
17
  >
18
18
  {{ label }}
19
- <Close16 v-if="isFilter" :aria-label="clearAriaLabel" role="button" @click.stop.prevent="$emit('remove')" />
19
+ <Close16 v-if="isFilter" :aria-label="clearAriaLabel" role="button" @click.stop.prevent="onRemove" />
20
20
  </span>
21
21
  </template>
22
22
 
@@ -60,5 +60,12 @@ export default {
60
60
  return this.isFilter ? this.clearAriaLabel : null;
61
61
  },
62
62
  },
63
+ methods: {
64
+ onRemove() {
65
+ if (!this.disabled) {
66
+ this.$emit('remove');
67
+ }
68
+ },
69
+ },
63
70
  };
64
71
  </script>
@@ -1,13 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`CvTag matches tag filter snapshot 1`] = `
4
- <span tabindex="0" title="Clear filter" class="cv-tag bx--tag bx--tag--filter bx--tag--filter">
5
- I am a filter tag
6
- <close16-stub aria-label="Clear filter" role="button"></close16-stub></span>
7
- `;
8
-
9
- exports[`CvTag matches tag snapshot 1`] = `
10
- <span tabindex="0" class="cv-tag bx--tag bx--tag--red">
11
- I am a tag
12
- <!----></span>
13
- `;