@carbon/vue 1.1.0 → 1.1.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.
@@ -1,13 +1,18 @@
1
1
  <template>
2
2
  <cv-form-item class="cv-file-uploader">
3
- <strong class="bx--label">{{ label }}</strong>
3
+ <strong :class="componentsX ? 'bx--label' : 'bx--file--label'">
4
+ {{ label }}
5
+ </strong>
4
6
  <p class="bx--label-description">{{ helperText }}</p>
5
7
  <div class="bx--file" data-file>
6
8
  <label
7
9
  :for="uid"
8
- class="bx--file-btn bx--btn bx--btn--secondary"
10
+ class="bx--file--btn bx--btn bx--btn--primary bx--btn--sm"
9
11
  role="button"
10
12
  tabindex="0"
13
+ @keydown.enter.prevent="onShow()"
14
+ @keydown.space.prevent
15
+ @keyup.space.prevent="onShow()"
11
16
  >{{ buttonLabel }}</label
12
17
  >
13
18
  <input
@@ -18,6 +23,8 @@
18
23
  data-file-uploader
19
24
  data-target="[data-file-container]"
20
25
  v-on="inputListeners"
26
+ ref="file-input"
27
+ tabindex="-1"
21
28
  />
22
29
  <div data-file-container class="bx--file-container">
23
30
  <div
@@ -32,10 +39,18 @@
32
39
  :data-for="uid"
33
40
  class="bx--file__state-container"
34
41
  :data-test="file.state"
35
- wibble="banana"
36
42
  >
43
+ <cv-inline-loader
44
+ v-if="
45
+ componentsX &&
46
+ (file.state === 'uploading' || file.state === 'complete')
47
+ "
48
+ :active="file.state === 'uploading'"
49
+ loading-text
50
+ loaded-text
51
+ />
37
52
  <div
38
- v-if="file.state === 'uploading'"
53
+ v-if="!componentsX && file.state === 'uploading'"
39
54
  class="bx--loading"
40
55
  tabindex="0"
41
56
  style="width: 1rem; height: 1rem;"
@@ -45,7 +60,7 @@
45
60
  </svg>
46
61
  </div>
47
62
  <svg
48
- v-if="file.state === 'complete'"
63
+ v-if="!componentsX && file.state === 'complete'"
49
64
  class="bx--file-complete"
50
65
  fill-rule="evenodd"
51
66
  height="16"
@@ -61,13 +76,32 @@
61
76
  ></path>
62
77
  </svg>
63
78
  <svg
64
- v-if="removable"
79
+ v-if="componentsX && removable"
65
80
  class="bx--file-close"
66
- fill-rule="evenodd"
67
81
  role="button"
82
+ width="16"
83
+ height="16"
84
+ viewBox="0 0 16 16"
85
+ tabindex="0"
86
+ alt="Remove file"
87
+ arial-label="Remove file"
88
+ @click="remove(index)"
89
+ @keydown.enter.prevent="remove(index)"
90
+ @keydown.space.prevent
91
+ @keyup.space.prevent="remove(index)"
92
+ >
93
+ <path
94
+ d="M12 4.7l-.7-.7L8 7.3 4.7 4l-.7.7L7.3 8 4 11.3l.7.7L8 8.7l3.3 3.3.7-.7L8.7 8z"
95
+ ></path>
96
+ </svg>
97
+ <svg
98
+ v-if="!componentsX && removable"
99
+ class="bx--file-close"
100
+ fill-rule="evenodd"
68
101
  height="16"
69
102
  width="16"
70
103
  viewBox="0 0 16 16"
104
+ role="button"
71
105
  tabindex="0"
72
106
  alt="Remove file"
73
107
  arial-label="Remove file"
@@ -92,6 +126,8 @@
92
126
  <script>
93
127
  import uidMixin from '../../mixins/uid-mixin';
94
128
  import CvFormItem from '../cv-form/cv-form-item';
129
+ import { componentsX } from '../../_internal/_feature-flags';
130
+ import CvInlineLoader from '../cv-inline-loader/cv-inline-loader';
95
131
 
96
132
  const CONSTS = {
97
133
  STATES: {
@@ -103,7 +139,7 @@ const CONSTS = {
103
139
 
104
140
  export default {
105
141
  name: 'CvFileUploader',
106
- components: { CvFormItem },
142
+ components: { CvFormItem, CvInlineLoader },
107
143
  mixins: [uidMixin],
108
144
  inheritAttrs: false,
109
145
  props: {
@@ -124,6 +160,7 @@ export default {
124
160
  },
125
161
  data() {
126
162
  return {
163
+ componentsX,
127
164
  internalFiles: [],
128
165
  };
129
166
  },
@@ -165,6 +202,9 @@ export default {
165
202
  }
166
203
  this.$emit('change', this.internalFiles);
167
204
  },
205
+ onShow() {
206
+ this.$refs['file-input'].click();
207
+ },
168
208
  },
169
209
  };
170
210
  </script>
@@ -1,14 +1,20 @@
1
1
  <template>
2
2
  <div
3
- data-inline-notification
3
+ data-notification
4
4
  class="cv-inline-notification bx--inline-notification"
5
5
  :class="`bx--inline-notification--${kind.toLowerCase()}`"
6
6
  v-on="$listeners"
7
- :aria-role="isAlert ? 'alert' : false"
7
+ :role="isAlert ? 'alert' : false"
8
8
  :aria-live="!isAlert ? 'polite' : false"
9
9
  >
10
10
  <div class="bx--inline-notification__details">
11
+ <component
12
+ v-if="componentsX"
13
+ :is="icon"
14
+ class="bx--inline-notification__icon"
15
+ />
11
16
  <cv-icon
17
+ v-else
12
18
  :href="`cv(${icon})`"
13
19
  class="bx--inline-notification__icon"
14
20
  width="16"
@@ -25,7 +31,9 @@
25
31
  class="bx--inline-notification__close-button"
26
32
  @click="$emit('close')"
27
33
  >
34
+ <Close16 v-if="componentsX" class="bx--inline-notification__close-icon" />
28
35
  <svg
36
+ v-else
29
37
  class="bx--inline-notification__close-icon"
30
38
  aria-label="close"
31
39
  width="10"
@@ -45,10 +53,20 @@
45
53
  <script>
46
54
  import notificationMixin from '../../mixins/notification-mixin';
47
55
  import CvIcon from '../cv-icon/_cv-icon';
56
+ import { componentsX } from '../../_internal/_feature-flags';
57
+ import ErrorFilled16 from '@carbon/icons-vue/lib/error--filled/16';
58
+ import CheckmarkFilled16 from '@carbon/icons-vue/lib/checkmark--filled/16';
59
+ import WarningAltFilled16 from '@carbon/icons-vue/lib/warning--filled/16';
60
+ import Close16 from '@carbon/icons-vue/lib/close/16';
48
61
 
49
62
  export default {
50
63
  name: 'CvInlineNotification',
51
- components: { CvIcon },
64
+ components: { CvIcon, Close16 },
65
+ data() {
66
+ return {
67
+ componentsX,
68
+ };
69
+ },
52
70
  mixins: [notificationMixin],
53
71
  props: {
54
72
  kind: {
@@ -61,13 +79,13 @@ export default {
61
79
  icon() {
62
80
  switch (this.kind) {
63
81
  case 'error':
64
- return 'icon--error--solid';
82
+ return componentsX ? ErrorFilled16 : 'icon--error--solid';
65
83
  case 'warning':
66
- return 'icon--warning--solid';
84
+ return componentsX ? WarningAltFilled16 : 'icon--warning--solid';
67
85
  case 'success':
68
- return 'icon--checkmark--solid';
86
+ return componentsX ? CheckmarkFilled16 : 'icon--checkmark--solid';
69
87
  default:
70
- return 'icon--info--solid';
88
+ return componentsX ? null : 'icon--info--solid';
71
89
  }
72
90
  },
73
91
  },
@@ -11,13 +11,29 @@
11
11
  >
12
12
  <svg class="bx--loading__svg" viewBox="-75 -75 150 150">
13
13
  <title>Loading</title>
14
- <circle cx="0" cy="0" r="37.5"></circle>
14
+ <circle
15
+ v-if="componentsX && small"
16
+ class="bx--loading__background"
17
+ cx="0"
18
+ cy="0"
19
+ r="37.5"
20
+ ></circle>
21
+ <circle
22
+ :class="{
23
+ 'bx--loading__stroke': componentsX,
24
+ }"
25
+ cx="0"
26
+ cy="0"
27
+ r="37.5"
28
+ ></circle>
15
29
  </svg>
16
30
  </div>
17
31
  </div>
18
32
  </template>
19
33
 
20
34
  <script>
35
+ import { componentsX } from '../../_internal/_feature-flags';
36
+
21
37
  export default {
22
38
  name: 'CvLoading',
23
39
  props: {
@@ -36,6 +52,7 @@ export default {
36
52
  },
37
53
  data() {
38
54
  return {
55
+ componentsX,
39
56
  stopped: false,
40
57
  };
41
58
  },
@@ -27,7 +27,9 @@
27
27
  <slot name="title">Modal Title</slot>
28
28
  </h2>
29
29
  <button class="bx--modal-close" type="button" @click="hide" ref="close">
30
+ <Close16 v-if="componentsX" class="bx--modal-close__icon" />
30
31
  <cv-icon
32
+ v-else
31
33
  class="bx--modal-close__icon"
32
34
  href="cv(icon--close)"
33
35
  height="10px"
@@ -36,7 +38,7 @@
36
38
  </button>
37
39
  </div>
38
40
 
39
- <div class="bx--modal-content">
41
+ <div class="bx--modal-content" ref="content">
40
42
  <slot name="content">
41
43
  <p>
42
44
  Passive modal notifications should only appear if there is an action
@@ -81,6 +83,8 @@
81
83
  import CvButton from '../cv-button/cv-button';
82
84
  import CvIcon from '../cv-icon/_cv-icon';
83
85
  import uidMixin from '../../mixins/uid-mixin';
86
+ import Close16 from '@carbon/icons-vue/lib/close//16';
87
+ import { componentsX } from '../../_internal/_feature-flags';
84
88
 
85
89
  export default {
86
90
  name: 'CvModal',
@@ -88,6 +92,7 @@ export default {
88
92
  components: {
89
93
  CvButton,
90
94
  CvIcon,
95
+ Close16,
91
96
  },
92
97
  props: {
93
98
  kind: {
@@ -99,6 +104,7 @@ export default {
99
104
  },
100
105
  data() {
101
106
  return {
107
+ componentsX,
102
108
  dataVisible: false,
103
109
  };
104
110
  },
@@ -119,14 +125,14 @@ export default {
119
125
  computed: {
120
126
  primaryKind() {
121
127
  if (this.kind === 'danger') {
122
- return 'danger--primary';
128
+ return componentsX ? 'danger' : 'danger--primary';
123
129
  } else {
124
130
  return 'primary';
125
131
  }
126
132
  },
127
133
  secondaryKind() {
128
134
  if (this.kind === 'danger') {
129
- return 'tertiary';
135
+ return componentsX ? 'secondary' : 'tertiary';
130
136
  } else {
131
137
  return 'secondary';
132
138
  }
@@ -149,7 +155,12 @@ export default {
149
155
  this.$refs.close.focus();
150
156
  },
151
157
  onShown() {
152
- if (this.$slots['primary-button']) {
158
+ const focusEl = this.$refs.content.querySelector(
159
+ '[data-modal-primary-focus]'
160
+ );
161
+ if (focusEl) {
162
+ focusEl.focus();
163
+ } else if (this.$slots['primary-button']) {
153
164
  this.$refs.primary.$el.focus();
154
165
  } else if (this.$slots['secondary-button']) {
155
166
  this.$refs.secondary.$el.focus();
@@ -15,7 +15,8 @@
15
15
  @click="doUp"
16
16
  type="button"
17
17
  >
18
- <svg width="10" height="5" viewBox="0 0 10 5">
18
+ <CaretUpGlyph v-if="componentsX" />
19
+ <svg v-else width="10" height="5" viewBox="0 0 10 5">
19
20
  <path d="M0 5L5 .002 10 5z" fill-rule="evenodd"></path>
20
21
  </svg>
21
22
  </button>
@@ -24,7 +25,8 @@
24
25
  @click="doDown"
25
26
  type="button"
26
27
  >
27
- <svg width="10" height="5" viewBox="0 0 10 5">
28
+ <CaretDownGlyph v-if="componentsX" />
29
+ <svg v-else width="10" height="5" viewBox="0 0 10 5">
28
30
  <path d="M0 0l5 4.998L10 0z" fill-rule="evenodd"></path>
29
31
  </svg>
30
32
  </button>
@@ -50,10 +52,14 @@
50
52
  <script>
51
53
  import uidMixin from '../../mixins/uid-mixin';
52
54
  import themeMixin from '../../mixins/theme-mixin';
55
+ import { componentsX } from '../../_internal/_feature-flags';
56
+ import CaretDownGlyph from '@carbon/icons-vue/lib/caret--down/index';
57
+ import CaretUpGlyph from '@carbon/icons-vue/lib/caret--up/index';
53
58
 
54
59
  export default {
55
60
  name: 'CvNumberInput',
56
61
  mixins: [uidMixin, themeMixin],
62
+ components: { CaretDownGlyph, CaretUpGlyph },
57
63
  inheritAttrs: false,
58
64
  props: {
59
65
  helperText: { type: String, default: null },
@@ -75,6 +81,7 @@ export default {
75
81
  },
76
82
  data() {
77
83
  return {
84
+ componentsX,
78
85
  internalValue: this.value,
79
86
  };
80
87
  },
@@ -8,16 +8,18 @@
8
8
  @keydown.right.prevent="moveRight"
9
9
  @keydown.left.prevent="moveLeft"
10
10
  >
11
- <div class="bx--tabs-trigger" tabindex="0">
12
- <a
13
- href="javascript:void(0)"
14
- class="bx--tabs-trigger-text"
15
- tabindex="-1"
16
- ></a>
17
- <svg width="10" height="5" viewBox="0 0 10 5">
18
- <path d="M0 0l5 4.998L10 0z" fill-rule="evenodd"></path>
19
- </svg>
20
- </div>
11
+ <cv-dropdown
12
+ class="bx--tabs-trigger"
13
+ :value="`${selectedIndex}`"
14
+ @change="onDropChange"
15
+ >
16
+ <cv-dropdown-item
17
+ v-for="(tab, index) in tabs"
18
+ :key="`drop-${index}`"
19
+ :value="`${index}`"
20
+ >{{ tab.label }}</cv-dropdown-item
21
+ >
22
+ </cv-dropdown>
21
23
  <ul class="bx--tabs__nav bx--tabs__nav--hidden" role="tablist">
22
24
  <li
23
25
  v-for="(tab, index) in tabs"
@@ -42,13 +44,19 @@
42
44
  </li>
43
45
  </ul>
44
46
  </nav>
45
- <div class="cv-tabs__panels"><slot></slot></div>
47
+ <div class="cv-tabs__panels">
48
+ <slot></slot>
49
+ </div>
46
50
  </div>
47
51
  </template>
48
52
 
49
53
  <script>
54
+ import CvDropdown from '../cv-dropdown/cv-dropdown';
55
+ import CvDropdownItem from '../cv-dropdown/cv-dropdown-item';
56
+
50
57
  export default {
51
58
  name: 'CvTabs',
59
+ components: { CvDropdown, CvDropdownItem },
52
60
  data() {
53
61
  return {
54
62
  tabs: [],
@@ -64,6 +72,9 @@ export default {
64
72
  this.$on('cv:selected', srcComponent => this.onCvSelected(srcComponent));
65
73
  },
66
74
  methods: {
75
+ onDropChange(val) {
76
+ this.onTabClick(parseInt(val));
77
+ },
67
78
  onCvMount(srcComponent) {
68
79
  this.tabs.push(srcComponent);
69
80
  this.checkSelected();
@@ -7,6 +7,11 @@
7
7
  :aria-role="isAlert ? 'alert' : false"
8
8
  :aria-live="!isAlert ? 'polite' : false"
9
9
  >
10
+ <component
11
+ v-if="componentsX"
12
+ :is="icon"
13
+ class="bx--toast-notification__icon"
14
+ />
10
15
  <div class="bx--toast-notification__details">
11
16
  <h3 class="bx--toast-notification__title">{{ title }}</h3>
12
17
  <p class="bx--toast-notification__subtitle">{{ subTitle }}</p>
@@ -18,7 +23,9 @@
18
23
  class="bx--toast-notification__close-button"
19
24
  @click="$emit('close')"
20
25
  >
26
+ <Close16 v-if="componentsX" class="bx--toast-notification__close-icon" />
21
27
  <svg
28
+ v-else
22
29
  class="bx--toast-notification-icon"
23
30
  aria-label="close"
24
31
  width="10"
@@ -37,9 +44,20 @@
37
44
 
38
45
  <script>
39
46
  import notificationMixin from '../../mixins/notification-mixin';
47
+ import { componentsX } from '../../_internal/_feature-flags';
48
+ import ErrorFilled16 from '@carbon/icons-vue/lib/error--filled/16';
49
+ import CheckmarkFilled16 from '@carbon/icons-vue/lib/checkmark--filled/16';
50
+ import WarningAltFilled16 from '@carbon/icons-vue/lib/warning--alt--filled/16';
51
+ import Close16 from '@carbon/icons-vue/lib/close/16';
40
52
 
41
53
  export default {
42
54
  name: 'CvToastNotification',
55
+ components: { Close16 },
56
+ data() {
57
+ return {
58
+ componentsX,
59
+ };
60
+ },
43
61
  mixins: [notificationMixin],
44
62
  props: {
45
63
  caption: String,
@@ -49,6 +67,23 @@ export default {
49
67
  validator: val => ['error', 'info', 'warning', 'success'].includes(val),
50
68
  },
51
69
  },
70
+ computed: {
71
+ icon() {
72
+ if (this.componentsX) {
73
+ switch (this.kind) {
74
+ case 'error':
75
+ return ErrorFilled16;
76
+ case 'warning':
77
+ return WarningAltFilled16;
78
+ case 'success':
79
+ return CheckmarkFilled16;
80
+ default:
81
+ return null;
82
+ }
83
+ }
84
+ return null;
85
+ },
86
+ },
52
87
  };
53
88
  </script>
54
89