@carbon/vue 2.23.0-canary.0 → 2.23.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.23.0-canary.0",
4
+ "version": "2.23.1",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -73,5 +73,5 @@
73
73
  "eslint-plugin-prettier": "^3.1.1",
74
74
  "vue-template-compiler": "^2.6.10"
75
75
  },
76
- "gitHead": "3d4153ed4048ee0dad2507d53fa3a82fea0763e3"
76
+ "gitHead": "b83ca8b2c7be451e477f6e661f12a135a301c826"
77
77
  }
@@ -1,5 +1,18 @@
1
1
  <template>
2
2
  <div class="cv-checkbox bx--checkbox-wrapper" :class="{ 'bx--form-item': formItem }">
3
+ <input
4
+ ref="input"
5
+ v-bind="$attrs"
6
+ v-on="inputListeners"
7
+ class="bx--checkbox"
8
+ type="checkbox"
9
+ :checked="isChecked === true"
10
+ :aria-checked="`${isChecked}`"
11
+ @focus="onFocus"
12
+ @blur="onBlur"
13
+ :value="value"
14
+ :id="uid"
15
+ />
3
16
  <label
4
17
  :class="[
5
18
  'bx--checkbox-label',
@@ -10,32 +23,25 @@
10
23
  ]"
11
24
  :data-contained-checkbox-state="isChecked"
12
25
  :data-contained-checkbox-disabled="$attrs.disabled"
26
+ :for="uid"
13
27
  >
14
- <input
15
- ref="input"
16
- v-bind="$attrs"
17
- v-on="inputListeners"
18
- class="bx--checkbox"
19
- type="checkbox"
20
- :checked="isChecked === true"
21
- :aria-checked="`${isChecked}`"
22
- @focus="onFocus"
23
- @blur="onBlur"
24
- :value="value"
25
- />
26
- {{ label }}
28
+ <span class="bx--checkbox-label-text" :class="{ 'bx--visually-hidden': hideLabel }">
29
+ {{ label }}
30
+ </span>
27
31
  </label>
28
32
  </div>
29
33
  </template>
30
34
 
31
35
  <script>
32
36
  import checkMixin from '../../mixins/check-mixin';
37
+ import uidMixin from '../../mixins/uid-mixin';
33
38
 
34
39
  export default {
35
40
  name: 'CvCheckbox',
36
- mixins: [checkMixin],
41
+ mixins: [checkMixin, uidMixin],
37
42
  inheritAttrs: false,
38
43
  props: {
44
+ hideLabel: Boolean,
39
45
  label: String,
40
46
  mixed: Boolean,
41
47
  formItem: { type: Boolean, default: true },
@@ -13,7 +13,7 @@
13
13
  <Copy16 class="bx--snippet__icon" />
14
14
  </cv-feedback-button>
15
15
 
16
- <cv-button type="button" kind="ghost" small class="bx--snippet-btn--expand" @click="toggleExpand">
16
+ <cv-button type="button" kind="ghost" size="small" class="bx--snippet-btn--expand" @click="toggleExpand">
17
17
  <span class="bx--snippet-btn--text">{{ expandButtonText }}</span>
18
18
  <ChevronDown16 class="bx--icon-chevron--down" />
19
19
  </cv-button>
@@ -1,11 +1,19 @@
1
1
  <template>
2
- <th :aria-sort="sortOrder">
3
- <button type="button" v-if="sortable" :class="['bx--table-sort', orderClass]" @click="onSortClick">
2
+ <th :aria-sort="sortOrder" :style="skeleton && headingStyle">
3
+ <button
4
+ type="button"
5
+ v-if="sortable"
6
+ :class="['bx--table-sort', orderClass]"
7
+ @click="onSortClick"
8
+ :style="headingStyle"
9
+ >
4
10
  <cv-wrapper :tag-type="headingLabelTag" class="bx--table-header-label">{{ heading }}</cv-wrapper>
5
11
  <ArrowDown16 class="bx--table-sort__icon" />
6
12
  <Arrows16 class="bx--table-sort__icon-unsorted" />
7
13
  </button>
8
- <cv-wrapper v-else :tag-type="headingLabelTag" class="bx--table-header-label">{{ heading }}</cv-wrapper>
14
+ <cv-wrapper v-else :tag-type="headingLabelTag" class="bx--table-header-label" :style="headingStyle">{{
15
+ heading
16
+ }}</cv-wrapper>
9
17
  </th>
10
18
  </template>
11
19
 
@@ -28,6 +36,7 @@ export default {
28
36
  sortable: Boolean,
29
37
  order: { type: String, default: 'none' },
30
38
  skeleton: Boolean,
39
+ headingStyle: Object,
31
40
  },
32
41
  computed: {
33
42
  sortOrder() {
@@ -10,7 +10,14 @@
10
10
  </button>
11
11
  </td>
12
12
  <td v-if="hasBatchActions" class="bx--table-column-checkbox">
13
- <cv-checkbox :form-item="false" :value="value" v-model="dataChecked" @change="onChange" ref="rowChecked" />
13
+ <cv-checkbox
14
+ :form-item="false"
15
+ :value="value"
16
+ v-model="dataChecked"
17
+ @change="onChange"
18
+ ref="rowChecked"
19
+ :aria-label="ariaLabelForBatchCheckbox || `Select row ${value} for batch action`"
20
+ />
14
21
  </td>
15
22
  <slot />
16
23
  <td v-if="hasOverflowMenu" class="bx--table-column-menu">
@@ -42,6 +49,7 @@ export default {
42
49
  name: 'CvDataTableRowInner',
43
50
  components: { CvCheckbox, CvOverflowMenu, CvOverflowMenuItem, ChevronRight16 },
44
51
  props: {
52
+ ariaLabelForBatchCheckbox: String,
45
53
  checked: Boolean,
46
54
  expanded: Boolean,
47
55
  expandingRow: Boolean,
@@ -19,7 +19,9 @@
19
19
  >
20
20
  <div class="bx--action-list">
21
21
  <slot name="batch-actions" />
22
- <cv-button class="bx--batch-summary__cancel" small @click="deselect">{{ batchCancelLabel }}</cv-button>
22
+ <cv-button class="bx--batch-summary__cancel" size="small" @click="deselect">{{
23
+ batchCancelLabel
24
+ }}</cv-button>
23
25
  </div>
24
26
  <div class="bx--batch-summary">
25
27
  <p class="bx--batch-summary__para">
@@ -114,11 +116,11 @@
114
116
  <cv-data-table-heading
115
117
  v-for="(column, index) in dataColumns"
116
118
  :key="`${index}:${column}`"
117
- :heading="column.label ? column.label : column"
118
- :sortable="isSortable(column)"
119
+ :heading="columnHeading(column)"
120
+ :sortable="isColSortable(column)"
119
121
  :order="column.order"
120
122
  @sort="val => onSort(index, val)"
121
- :style="headingStyle(index)"
123
+ :heading-style="headingStyle(index)"
122
124
  :skeleton="skeleton"
123
125
  />
124
126
  <th v-if="hasOverflowMenu"></th>
@@ -275,15 +277,25 @@ export default {
275
277
  this.checkSlots();
276
278
  },
277
279
  computed: {
278
- isSortable() {
280
+ columnHeading() {
279
281
  return col => {
280
- if (col && this.columns.some(column => column.sortable)) {
281
- return col.sortable;
282
+ if (typeof col === 'object') {
283
+ return col.label || '';
282
284
  } else {
283
- return this.sortable || this.columns.some(column => column.sortable);
285
+ return col;
284
286
  }
285
287
  };
286
288
  },
289
+ isSortable() {
290
+ // is any column sortable
291
+ return this.sortable || this.columns.some(column => column.sortable);
292
+ },
293
+ isColSortable() {
294
+ return col => {
295
+ // is specific column or all sortable
296
+ return (col && col.sortable) || this.sortable;
297
+ };
298
+ },
287
299
  hasTableHeader() {
288
300
  return this.title || this.isHelper;
289
301
  },
@@ -441,6 +453,7 @@ export default {
441
453
  watchColumns() {
442
454
  this.dataColumns = this.isSortable
443
455
  ? this.columns.map(item => ({
456
+ ...item,
444
457
  label: item.label ? item.label : item,
445
458
  order: 'none',
446
459
  sortable: item.sortable,
@@ -157,20 +157,22 @@ export default {
157
157
  if (this.open) {
158
158
  const menuPosition = this.$el.getBoundingClientRect();
159
159
  return this.$nextTick(() => {
160
+ const pixelsScrolledX = window.scrollX || window.pageXOffset;
161
+ const pixelsScrolledY = window.scrollY || window.pageYOffset;
160
162
  if (this.flipMenu) {
161
163
  this.left =
162
164
  menuPosition.left +
163
165
  this.offsetLeft -
164
166
  this.$refs.popup.offsetWidth +
165
167
  this.$el.offsetWidth +
166
- window.scrollX;
168
+ pixelsScrolledX;
167
169
  } else {
168
- this.left = menuPosition.left + this.offsetLeft + window.scrollX;
170
+ this.left = menuPosition.left + this.offsetLeft + pixelsScrolledX;
169
171
  }
170
172
  if (this.up) {
171
- this.top = menuPosition.top + this.offsetTop - this.$refs.popup.offsetHeight + window.scrollY;
173
+ this.top = menuPosition.top + this.offsetTop - this.$refs.popup.offsetHeight + pixelsScrolledY;
172
174
  } else {
173
- this.top = menuPosition.bottom + this.offsetTop + window.scrollY;
175
+ this.top = menuPosition.bottom + this.offsetTop + pixelsScrolledY;
174
176
  }
175
177
  });
176
178
  }
@@ -119,28 +119,30 @@ export default {
119
119
  },
120
120
  position() {
121
121
  const menuPosition = this.$refs.trigger.getBoundingClientRect();
122
+ const pixelsScrolledX = window.scrollX || window.pageXOffset;
123
+ const pixelsScrolledY = window.scrollY || window.pageYOffset;
122
124
 
123
125
  if (this.direction === 'top' || this.direction === 'bottom') {
124
126
  this.left =
125
127
  menuPosition.left +
126
128
  0.5 +
127
129
  (this.$refs.trigger.offsetWidth - this.$refs.popup.offsetWidth) / 2 +
128
- window.scrollX;
130
+ pixelsScrolledX;
129
131
 
130
132
  if (this.direction === 'bottom') {
131
- this.top = menuPosition.bottom + 10 + window.scrollY;
133
+ this.top = menuPosition.bottom + 10 + pixelsScrolledY;
132
134
  } else {
133
- this.top = menuPosition.top - 15 - this.$refs.popup.offsetHeight + window.scrollY;
135
+ this.top = menuPosition.top - 15 - this.$refs.popup.offsetHeight + pixelsScrolledY;
134
136
  }
135
137
  } else {
136
138
  this.top =
137
139
  menuPosition.top +
138
140
  (this.$refs.trigger.offsetHeight - 0.5 - this.$refs.popup.offsetHeight) / 2 +
139
- window.scrollY;
141
+ pixelsScrolledY;
140
142
  if (this.direction === 'left') {
141
- this.left = menuPosition.left - 10 - this.$refs.popup.offsetWidth + window.scrollX;
143
+ this.left = menuPosition.left - 10 - this.$refs.popup.offsetWidth + pixelsScrolledX;
142
144
  } else {
143
- this.left = menuPosition.right + 15 + window.scrollX;
145
+ this.left = menuPosition.right + 15 + pixelsScrolledX;
144
146
  }
145
147
  }
146
148
  },
@@ -3,6 +3,7 @@
3
3
  class="cv-header-panel bx--header-panel"
4
4
  :class="{ 'bx--header-panel--expanded': panelExpanded }"
5
5
  :aria-hidden="!panelExpanded"
6
+ :id="id"
6
7
  @focusout="onFocusout"
7
8
  @mousedown="onMouseDown"
8
9
  >
@@ -8,6 +8,7 @@
8
8
  'bx--side-nav--ux': isChildOfHeader,
9
9
  }"
10
10
  :aria-hidden="!panelExpanded && !fixed"
11
+ :id="id"
11
12
  @focusout="onFocusout"
12
13
  @mousedown="onMouseDown"
13
14
  >