@carbon/vue 1.0.2 → 1.1.3

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +192 -0
  2. package/README.md +156 -211
  3. package/dist/carbon-vue.common.js +10567 -12509
  4. package/dist/carbon-vue.common.js.map +1 -1
  5. package/dist/carbon-vue.umd.js +10567 -12509
  6. package/dist/carbon-vue.umd.js.map +1 -1
  7. package/dist/carbon-vue.umd.min.js +31 -7
  8. package/dist/carbon-vue.umd.min.js.map +1 -1
  9. package/dist/demo.html +2 -2
  10. package/package.json +17 -157
  11. package/src/components/cv-accordion/_cv-accordion-item-skeleton.vue +3 -13
  12. package/src/components/cv-accordion/cv-accordion-item.vue +2 -9
  13. package/src/components/cv-breadcrumb/cv-breadcrumb-item.vue +3 -1
  14. package/src/components/cv-button/cv-button-skeleton.vue +1 -6
  15. package/src/components/cv-button/cv-button.vue +15 -37
  16. package/src/components/cv-checkbox/cv-checkbox.vue +42 -26
  17. package/src/components/cv-code-snippet/_cv-code-snippet-multiline.vue +13 -23
  18. package/src/components/cv-code-snippet/_cv-code-snippet-oneline.vue +11 -5
  19. package/src/components/cv-code-snippet/_cv-feedback-button.vue +1 -3
  20. package/src/components/cv-code-snippet/cv-code-snippet.vue +2 -7
  21. package/src/components/cv-content-switcher/cv-content-switcher-button.vue +20 -4
  22. package/src/components/cv-content-switcher/cv-content-switcher.vue +3 -10
  23. package/src/components/cv-data-table/cv-data-table-row.vue +15 -11
  24. package/src/components/cv-data-table/cv-data-table.vue +30 -28
  25. package/src/components/cv-date-picker/cv-date-picker.vue +53 -47
  26. package/src/components/cv-dropdown/_cv-dropdown-inner-c10.vue +226 -0
  27. package/src/components/cv-dropdown/_cv-dropdown-inner.vue +201 -0
  28. package/src/components/cv-dropdown/cv-dropdown-item.vue +6 -8
  29. package/src/components/cv-dropdown/cv-dropdown-skeleton.vue +1 -5
  30. package/src/components/cv-dropdown/cv-dropdown.vue +22 -169
  31. package/src/components/cv-file-uploader/cv-file-uploader.vue +44 -22
  32. package/src/components/cv-inline-loading/cv-inline-loading.vue +37 -0
  33. package/src/components/cv-inline-notification/cv-inline-notification.vue +22 -19
  34. package/src/components/cv-link/cv-link.vue +1 -6
  35. package/src/components/cv-loading/cv-loading.vue +13 -4
  36. package/src/components/cv-modal/cv-modal.vue +17 -15
  37. package/src/components/cv-number-input/cv-number-input.vue +20 -32
  38. package/src/components/cv-overflow-menu/cv-overflow-menu.vue +13 -19
  39. package/src/components/cv-pagination/cv-pagination.vue +61 -42
  40. package/src/components/cv-progress/_cv-progress-step-complete.vue +3 -12
  41. package/src/components/cv-progress/cv-progress-step.vue +97 -0
  42. package/src/components/cv-progress/cv-progress.vue +68 -13
  43. package/src/components/cv-radio-button/cv-radio-button.vue +1 -0
  44. package/src/components/cv-search/cv-search.vue +144 -15
  45. package/src/components/cv-select/cv-select-option.vue +3 -1
  46. package/src/components/cv-select/cv-select.vue +147 -15
  47. package/src/components/cv-slider/cv-slider.vue +14 -43
  48. package/src/components/cv-structured-list/_cv-structured-list-item-selectable.vue +18 -6
  49. package/src/components/cv-structured-list/cv-structured-list-item.vue +1 -3
  50. package/src/components/cv-structured-list/cv-structured-list.vue +10 -2
  51. package/src/components/cv-tabs/cv-tabs.vue +31 -15
  52. package/src/components/cv-tag/cv-tag.vue +23 -13
  53. package/src/components/cv-text-area/cv-text-area.vue +23 -10
  54. package/src/components/cv-text-input/cv-text-input.vue +80 -10
  55. package/src/components/cv-tile/_cv-tile-clickable.vue +1 -5
  56. package/src/components/cv-tile/_cv-tile-expandable.vue +11 -15
  57. package/src/components/cv-tile/_cv-tile-selectable.vue +14 -3
  58. package/src/components/cv-tile/cv-tile.vue +1 -4
  59. package/src/components/cv-time-picker/cv-time-picker.vue +27 -29
  60. package/src/components/cv-toast-notification/cv-toast-notification.vue +32 -6
  61. package/src/components/cv-toggle/cv-toggle.vue +3 -7
  62. package/src/components/cv-toolbar/cv-toolbar-option.vue +1 -4
  63. package/src/components/cv-toolbar/cv-toolbar-search.vue +5 -0
  64. package/src/components/cv-tooltip/cv-definition-tooltip.vue +1 -3
  65. package/src/components/cv-tooltip/cv-interactive-tooltip.vue +13 -28
  66. package/src/components/cv-tooltip/cv-tooltip.vue +11 -15
  67. package/src/components/cv-wrapper/_cv-wrapper.js +33 -0
  68. package/src/index-components-vue.js +1 -3
  69. package/src/index.js +1 -5
  70. package/src/{_internal/_feature-flags.js → internal/feature-flags.js} +30 -2
  71. package/dist/carbon-data-viz-vue.common.js +0 -23907
  72. package/dist/carbon-data-viz-vue.common.js.map +0 -1
  73. package/dist/carbon-data-viz-vue.css +0 -1
  74. package/dist/carbon-data-viz-vue.umd.js +0 -23917
  75. package/dist/carbon-data-viz-vue.umd.js.map +0 -1
  76. package/dist/carbon-data-viz-vue.umd.min.js +0 -2
  77. package/dist/carbon-data-viz-vue.umd.min.js.map +0 -1
  78. package/src/assets/styles/_carbon-helpers.scss +0 -8
  79. package/src/components/cv-checkbox/_cv-checkbox-inner-form-item.vue +0 -19
  80. package/src/components/cv-checkbox/_cv-checkbox-inner.vue +0 -59
  81. package/src/components/cv-progress/_cv-progress-step.vue +0 -51
  82. package/src/components/cv-search/_cv-search-inner-form-item.vue +0 -22
  83. package/src/components/cv-search/_cv-search-inner.vue +0 -162
  84. package/src/components/cv-select/_cv-select-inner-form-item.vue +0 -22
  85. package/src/components/cv-select/_cv-select-inner.vue +0 -78
  86. package/src/data-viz/cv-bar-graph/cv-bar-graph.vue +0 -495
  87. package/src/data-viz/cv-gauge/cv-gauge.vue +0 -196
  88. package/src/data-viz/cv-pie-chart/cv-pie-chart.vue +0 -194
  89. package/src/index-data-viz.js +0 -29
package/dist/demo.html CHANGED
@@ -11,13 +11,13 @@
11
11
  />
12
12
  <link rel="stylesheet" href="./carbon-vue.css" />
13
13
  <style>
14
- body {
14
+ .body {
15
15
  padding: 40px;
16
16
  background-color: #fff;
17
17
  }
18
18
  </style>
19
19
  </head>
20
- <body>
20
+ <body class="body">
21
21
  <div id="app">Test</div>
22
22
 
23
23
  <script>
package/package.json CHANGED
@@ -1,11 +1,8 @@
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": "1.0.2",
4
+ "version": "1.1.3",
5
5
  "license": "Apache-2.0",
6
- "engines": {
7
- "node": "10.x"
8
- },
9
6
  "repository": {
10
7
  "type": "git",
11
8
  "url": "git+https://github.com/carbon-design-system/carbon-components-vue.git"
@@ -13,16 +10,17 @@
13
10
  "bugs": {
14
11
  "url": "https://github.com/carbon-design-system/carbon-components-vue/issues/new"
15
12
  },
16
- "homepage": "https://github.com/carbon-design-system/carbon-components-vue#readme",
13
+ "homepage": "https://github.com/carbon-design-system/carbon-components-vue/tree/master/packages/core#readme",
17
14
  "main": "dist/carbon-vue.umd.min.js",
18
- "directories": {
19
- "doc": "docs"
20
- },
21
15
  "keywords": [
22
16
  "carbon",
23
17
  "vue",
24
18
  "components"
25
19
  ],
20
+ "directories": {
21
+ "src": "src",
22
+ "test": "__tests__"
23
+ },
26
24
  "publishConfig": {
27
25
  "access": "public"
28
26
  },
@@ -56,161 +54,23 @@
56
54
  "/dist",
57
55
  "/src"
58
56
  ],
59
- "sideEffects": true,
60
57
  "scripts": {
61
- "ci-check": "yarn format:diff",
62
- "format": "prettier --write \"**/*.{scss,css,js,md,vue}\"",
63
- "format:staged": "prettier --write",
64
- "format:diff": "prettier --list-different \"**/*.{scss,css,js,md,vue}\"",
65
- "format:staged": "prettier --write",
66
- "lint:es": "eslint --ext .js,.vue src",
67
- "lint:css": "stylelint 'src/**/*.vue'",
68
- "storybook": "start-storybook -p 9001 -c .storybook",
69
- "storybook-build": "build-storybook",
70
- "build": "npm run build:core && npm run build:data-viz",
71
- "build:core": "vue-cli-service build --target lib --name carbon-vue ./src/index.js --no-clean",
72
- "build:data-viz": "vue-cli-service build --target lib --name carbon-data-viz-vue ./src/index-data-viz.js --no-clean",
73
- "lint": "vue-cli-service lint ./src/index.js",
74
- "test:unit": "vue-cli-service test:unit"
58
+ "build": "vue-cli-service build --target lib --name carbon-vue ./src/index.js --no-clean"
59
+ },
60
+ "engines": {
61
+ "node": ">=10.x"
75
62
  },
76
- "peerDependencies": {},
63
+ "sideEffects": true,
77
64
  "dependencies": {
78
65
  "@carbon/icon-helpers": "0.0.1-beta.0",
79
66
  "@carbon/icons-vue": "0.0.1-beta.0",
80
- "carbon-components": "^9.48.1",
81
- "d3": "^5.7.0",
82
- "flatpickr": "4.5.1",
83
- "vue": "^2.5.21"
67
+ "carbon-components": "^9.91.0",
68
+ "flatpickr": "4.5.7",
69
+ "vue": "^2.6.10"
84
70
  },
85
71
  "devDependencies": {
86
- "@babel/core": "^7.2.2",
87
- "@commitlint/cli": "^7.2.1",
88
- "@commitlint/config-conventional": "^7.1.2",
89
- "@storybook/addon-actions": "^4.1.11",
90
- "@storybook/addon-knobs": "^4.1.11",
91
- "@storybook/addon-notes": "^4.1.11",
92
- "@storybook/addon-options": "^4.1.11",
93
- "@storybook/addon-storysource": "^4.1.11",
94
- "@storybook/vue": "^4.1.11",
95
- "@vue/cli-plugin-babel": "^3.4.0",
96
- "@vue/cli-plugin-eslint": "^3.4.0",
97
- "@vue/cli-plugin-unit-jest": "^3.4.0",
98
- "@vue/cli-service": "^3.4.0",
99
- "@vue/eslint-config-prettier": "^4.0.1",
100
- "@vue/test-utils": "^1.0.0-beta.20",
101
- "babel-eslint": "^10.0.1",
102
- "babel-jest": "^24.1.0",
103
- "babel-loader": "^7.0.0",
104
- "babel-plugin-transform-object-rest-spread": "7.0.0-beta.3",
105
- "babel-preset-env": "^1.7.0",
106
- "babel-preset-vue": "^2.0.2",
107
- "eslint": "^5.10.0",
108
- "eslint-plugin-vue": "^5.0.0-0",
109
- "husky": "^1.3.0",
110
- "jest": "^24.1.0",
111
- "jest-config": "^24.1.0",
112
- "jest-runtime": "^24.1.0",
113
- "jest-serializer-vue": "^2.0.2",
114
- "jest-transform-stub": "^2.0.0",
115
- "lint-staged": "^8.1.0",
116
- "node-sass": "^4.11.0",
117
- "prettier": "^1.15.3",
118
- "sass-loader": "^7.1.0",
119
- "stylelint": "^9.9.0",
120
- "stylelint-config-property-sort-order-smacss": "^4.0.1",
121
- "stylelint-config-sass-guidelines": "^5.3.0",
122
- "vue-highlightjs": "^1.3.3",
123
- "vue-jest": "^3.0.2",
124
- "vue-loader": "^15.4.2",
125
- "vue-template-compiler": "^2.5.21"
126
- },
127
- "husky": {
128
- "hooks": {
129
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
130
- "pre-commit": "lint-staged"
131
- }
132
- },
133
- "commitlint": {
134
- "extends": [
135
- "@commitlint/config-conventional"
136
- ]
137
- },
138
- "lint-staged": {
139
- "*.{scss,css,js,md,vue}": [
140
- "yarn format:staged",
141
- "git add"
142
- ]
72
+ "@vue/cli-service": "^3.5.1",
73
+ "vue-template-compiler": "^2.6.10"
143
74
  },
144
- "prettier": {
145
- "printWidth": 80,
146
- "singleQuote": true,
147
- "trailingComma": "es5"
148
- },
149
- "eslintConfig": {
150
- "root": true,
151
- "env": {
152
- "node": true
153
- },
154
- "extends": [
155
- "plugin:vue/essential",
156
- "@vue/prettier"
157
- ],
158
- "rules": {
159
- "no-console": [
160
- "error",
161
- {
162
- "allow": [
163
- "warn",
164
- "error"
165
- ]
166
- }
167
- ],
168
- "no-debugger": "warn",
169
- "no-unused-vars": "warn",
170
- "no-plusplus": "off",
171
- "no-undef": "off",
172
- "no-var": "error",
173
- "semi": [
174
- "error",
175
- "always"
176
- ],
177
- "no-param-reassign": [
178
- "error",
179
- {
180
- "props": false
181
- }
182
- ]
183
- },
184
- "parserOptions": {
185
- "parser": "babel-eslint"
186
- }
187
- },
188
- "browserslist": [
189
- "> 1%",
190
- "last 2 versions",
191
- "not ie <= 8"
192
- ],
193
- "jest": {
194
- "moduleFileExtensions": [
195
- "js",
196
- "jsx",
197
- "json",
198
- "vue"
199
- ],
200
- "transform": {
201
- "^.+\\.vue$": "vue-jest",
202
- ".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$": "jest-transform-stub",
203
- "^.+\\.jsx?$": "babel-jest"
204
- },
205
- "moduleNameMapper": {
206
- "^@/(.*)$": "<rootDir>/src/$1"
207
- },
208
- "snapshotSerializers": [
209
- "jest-serializer-vue"
210
- ],
211
- "testMatch": [
212
- "**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"
213
- ],
214
- "testURL": "http://localhost/"
215
- }
75
+ "gitHead": "babd1e211306c29252dbecb9f86b7d07c4e2d4fe"
216
76
  }
@@ -1,18 +1,8 @@
1
1
  <template>
2
- <li
3
- class="bx--accordion__item"
4
- :class="{ 'bx--accordion__item--active': open }"
5
- >
2
+ <li class="bx--accordion__item" :class="{ 'bx--accordion__item--active': open }">
6
3
  <button disabled type="button" class="bx--accordion__heading">
7
4
  <ChevronRight16 v-if="componentsX" class="bx--accordion__arrow" />
8
- <svg
9
- v-else
10
- class="bx--accordion__arrow"
11
- width="8"
12
- height="12"
13
- viewBox="0 0 8 12"
14
- fill-rule="evenodd"
15
- >
5
+ <svg v-else class="bx--accordion__arrow" width="8" height="12" viewBox="0 0 8 12" fill-rule="evenodd">
16
6
  <path d="M0 10.6L4.7 6 0 1.4 1.4 0l6.1 6-6.1 6z"></path>
17
7
  </svg>
18
8
  <cv-skeleton-text class="bx--accordion__title"></cv-skeleton-text>
@@ -25,7 +15,7 @@
25
15
 
26
16
  <script>
27
17
  import CvSkeletonText from '../cv-skeleton-text/cv-skeleton-text';
28
- import { componentsX } from '../../_internal/_feature-flags';
18
+ import { componentsX } from '../../internal/feature-flags';
29
19
  import ChevronRight16 from '@carbon/icons-vue/lib/chevron--right/16';
30
20
 
31
21
  export default {
@@ -19,14 +19,7 @@
19
19
  @click="toggle"
20
20
  >
21
21
  <ChevronRight16 v-if="componentsX" class="bx--accordion__arrow" />
22
- <svg
23
- v-else
24
- class="bx--accordion__arrow"
25
- width="8"
26
- height="12"
27
- viewBox="0 0 8 12"
28
- fill-rule="evenodd"
29
- >
22
+ <svg v-else class="bx--accordion__arrow" width="8" height="12" viewBox="0 0 8 12" fill-rule="evenodd">
30
23
  <path d="M0 10.6L4.7 6 0 1.4 1.4 0l6.1 6-6.1 6z"></path>
31
24
  </svg>
32
25
  <p class="bx--accordion__title">
@@ -40,7 +33,7 @@
40
33
  </template>
41
34
 
42
35
  <script>
43
- import { componentsX } from '../../_internal/_feature-flags';
36
+ import { componentsX } from '../../internal/feature-flags';
44
37
  import ChevronRight16 from '@carbon/icons-vue/lib/chevron--right/16';
45
38
  import uidMixin from '../../mixins/uid-mixin';
46
39
 
@@ -1,5 +1,7 @@
1
1
  <template>
2
- <div class="cv-breadcrumb-item bx--breadcrumb-item"><slot></slot></div>
2
+ <div class="cv-breadcrumb-item bx--breadcrumb-item">
3
+ <slot></slot>
4
+ </div>
3
5
  </template>
4
6
 
5
7
  <script>
@@ -1,10 +1,5 @@
1
1
  <template>
2
- <button
3
- disabled
4
- class="bx--btn bx--skeleton"
5
- :class="{ 'bx--btn--sm': small }"
6
- type="button"
7
- ></button>
2
+ <button disabled class="bx--btn bx--skeleton" :class="{ 'bx--btn--sm': small }" type="button"></button>
8
3
  </template>
9
4
 
10
5
  <script>
@@ -1,54 +1,40 @@
1
1
  <template>
2
2
  <button
3
3
  class="cv-button"
4
- :class="[
5
- 'bx--btn',
6
- 'bx--btn--' + kind.toLowerCase(),
7
- { 'bx--btn--sm': small },
8
- ]"
4
+ :class="['bx--btn', 'bx--btn--' + kind.toLowerCase(), { 'bx--btn--sm': small }]"
9
5
  v-on="$listeners"
10
6
  role="button"
11
7
  >
12
8
  <slot></slot>
13
9
 
14
- <component
15
- v-if="icon !== undefined && typeof icon === 'object'"
16
- :is="icon"
17
- class="bx--btn__icon"
18
- />
19
- <svg v-if="icon || iconHref" class="bx--btn__icon">
10
+ <component v-if="typeof icon === 'object'" :is="icon" class="bx--btn__icon" />
11
+ <svg v-if="typeof icon === 'string' || iconHref" class="bx--btn__icon">
20
12
  <use :href="icon || iconHref"></use>
21
13
  </svg>
22
14
  </button>
23
15
  </template>
24
16
 
25
17
  <script>
26
- import { componentsX } from '../../_internal/_feature-flags';
27
-
28
18
  export default {
29
19
  name: 'CvButton',
30
20
  props: {
31
- icon: componentsX
32
- ? {
33
- type: [String, Object],
34
- default: null,
35
- validator(val) {
36
- if (!val || typeof val === 'string') {
37
- return true;
38
- }
39
- return val.render !== null;
40
- },
21
+ icon: {
22
+ type: [String, Object],
23
+ default: null,
24
+ validator(val) {
25
+ if (!val || typeof val === 'string') {
26
+ return true;
41
27
  }
42
- : null,
28
+ return val.render !== null;
29
+ },
30
+ },
43
31
  iconHref: {
44
32
  type: String,
45
33
  default: null,
46
34
  validator(val) {
47
35
  if (process.env.NODE_ENV === 'development') {
48
- if (componentsX && val !== null) {
49
- console.warn(
50
- 'CvButton: iconHref deprecated in favour of icon to be removed in future versions.'
51
- );
36
+ if (val !== null) {
37
+ console.warn('CvButton: iconHref deprecated in favour of icon to be removed in future versions.');
52
38
  }
53
39
  }
54
40
  return true;
@@ -57,15 +43,7 @@ export default {
57
43
  kind: {
58
44
  type: String,
59
45
  default: 'primary',
60
- validator: val =>
61
- [
62
- 'primary',
63
- 'secondary',
64
- 'tertiary',
65
- 'ghost',
66
- 'danger',
67
- 'danger--primary',
68
- ].includes(val),
46
+ validator: val => ['primary', 'secondary', 'tertiary', 'ghost', 'danger', 'danger--primary'].includes(val),
69
47
  },
70
48
  small: { type: Boolean, default: false },
71
49
  },
@@ -1,42 +1,58 @@
1
1
  <template>
2
- <component
3
- :is="tagType"
4
- v-bind="$attrs"
5
- v-on="$listeners"
6
- class="cv-checkbox"
7
- >
8
- <slot></slot>
9
- </component>
2
+ <div class="cv-checkbox bx--form-item bx--checkbox-wrapper">
3
+ <label
4
+ :class="[
5
+ 'bx--checkbox-label',
6
+ {
7
+ 'bx--label--disabled': $attrs.disabled !== undefined && $attrs.disabled,
8
+ 'bx--checkbox-label__focus': hasFocus,
9
+ },
10
+ ]"
11
+ :data-contained-checkbox-state="isChecked"
12
+ :data-contained-checkbox-disabled="$attrs.disabled"
13
+ >
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 }}
27
+ </label>
28
+ </div>
10
29
  </template>
11
30
 
12
31
  <script>
13
- import CvCheckboxInnerFormItem from './_cv-checkbox-inner-form-item';
14
- import CvCheckboxInner from './_cv-checkbox-inner';
32
+ import checkMixin from '../../mixins/check-mixin';
15
33
 
16
34
  export default {
17
35
  name: 'CvCheckbox',
18
- components: { CvCheckboxInnerFormItem, CvCheckboxInner },
36
+ mixins: [checkMixin],
19
37
  inheritAttrs: false,
20
38
  props: {
21
- formItem: { type: Boolean, default: true },
39
+ label: String,
40
+ mixed: Boolean,
22
41
  },
23
- computed: {
24
- tagType() {
25
- return this.formItem
26
- ? 'cv-checkbox-inner-form-item'
27
- : 'cv-checkbox-inner';
28
- },
29
- value() {
30
- return this.$attrs.value;
42
+ data() {
43
+ return {
44
+ dataMixed: this.mixed,
45
+ hasFocus: false,
46
+ };
47
+ },
48
+ methods: {
49
+ onFocus() {
50
+ this.hasFocus = true;
31
51
  },
32
- isChecked() {
33
- return this.$children[0].isChecked;
52
+ onBlur() {
53
+ this.hasFocus = false;
34
54
  },
35
55
  },
36
- model: {
37
- prop: 'modelValue',
38
- event: 'modelEvent',
39
- },
40
56
  };
41
57
  </script>
42
58
 
@@ -9,12 +9,10 @@
9
9
  <slot></slot>
10
10
  </pre>
11
11
  </div>
12
- <cv-feedback-button
13
- feedback="Copied!"
14
- aria-label="Copy code"
15
- @click="$emit('copy-code')"
16
- >
12
+ <cv-feedback-button feedback="Copied!" aria-label="Copy code" @click="$emit('copy-code')">
13
+ <Copy16 v-if="componentsX" class="bx--snippet__icon" />
17
14
  <svg
15
+ v-else
18
16
  class="bx--snippet__icon"
19
17
  xmlns="http://www.w3.org/2000/svg"
20
18
  width="16"
@@ -28,26 +26,12 @@
28
26
  </svg>
29
27
  </cv-feedback-button>
30
28
 
31
- <cv-button
32
- type="button"
33
- kind="ghost"
34
- small
35
- class="bx--snippet-btn--expand"
36
- @click="toggleExpand"
37
- >
29
+ <cv-button type="button" kind="ghost" small class="bx--snippet-btn--expand" @click="toggleExpand">
38
30
  <span class="bx--snippet-btn--text">{{ expandButtonText }}</span>
39
- <svg
40
- class="bx--icon-chevron--down"
41
- width="12"
42
- height="7"
43
- viewBox="0 0 12 7"
44
- aria-label="Show more icon"
45
- >
31
+ <ChevronDown16 v-if="componentsX" class="bx--icon-chevron--down" />
32
+ <svg v-else class="bx--icon-chevron--down" width="12" height="7" viewBox="0 0 12 7" aria-label="Show more icon">
46
33
  <title>Show more icon</title>
47
- <path
48
- fill-rule="nonzero"
49
- d="M6.002 5.55L11.27 0l.726.685L6.003 7 0 .685.726 0z"
50
- ></path>
34
+ <path fill-rule="nonzero" d="M6.002 5.55L11.27 0l.726.685L6.003 7 0 .685.726 0z"></path>
51
35
  </svg>
52
36
  </cv-button>
53
37
  </div>
@@ -55,11 +39,16 @@
55
39
 
56
40
  <script>
57
41
  import CvFeedbackButton from './_cv-feedback-button';
42
+ import { componentsX } from '../../internal/feature-flags';
43
+ import Copy16 from '@carbon/icons-vue/lib/copy/16';
44
+ import ChevronDown16 from '@carbon/icons-vue/lib/chevron--down/16';
58
45
 
59
46
  export default {
60
47
  name: 'CvCodeSnippetMultiline',
61
48
  components: {
62
49
  CvFeedbackButton,
50
+ Copy16,
51
+ ChevronDown16,
63
52
  },
64
53
  props: {
65
54
  lessText: { type: String, default: 'Show less' },
@@ -67,6 +56,7 @@ export default {
67
56
  },
68
57
  data() {
69
58
  return {
59
+ componentsX,
70
60
  expanded: false,
71
61
  };
72
62
  },
@@ -5,12 +5,10 @@
5
5
  <slot></slot>
6
6
  </pre>
7
7
  </div>
8
- <cv-feedback-button
9
- feedback="Copied!"
10
- aria-label="Copy code"
11
- @click="$emit('copy-code')"
12
- >
8
+ <cv-feedback-button feedback="Copied!" aria-label="Copy code" @click="$emit('copy-code')">
9
+ <Copy16 v-if="componentsX" class="bx--snippet__icon" />
13
10
  <svg
11
+ v-else
14
12
  class="bx--snippet__icon"
15
13
  xmlns="http://www.w3.org/2000/svg"
16
14
  width="16"
@@ -28,11 +26,19 @@
28
26
 
29
27
  <script>
30
28
  import CvFeedbackButton from './_cv-feedback-button';
29
+ import { componentsX } from '../../internal/feature-flags';
30
+ import Copy16 from '@carbon/icons-vue/lib/copy/16';
31
31
 
32
32
  export default {
33
33
  name: 'CvCodeSnippetOneline',
34
34
  components: {
35
35
  CvFeedbackButton,
36
+ Copy16,
37
+ },
38
+ data() {
39
+ return {
40
+ componentsX,
41
+ };
36
42
  },
37
43
  };
38
44
  </script>
@@ -27,9 +27,7 @@ export default {
27
27
  },
28
28
  computed: {
29
29
  buttonClasses() {
30
- return this.inline
31
- ? 'bx--snippet bx--snippet--inline bx--btn--copy'
32
- : 'bx--snippet-button';
30
+ return this.inline ? 'bx--snippet bx--snippet--inline bx--btn--copy' : 'bx--snippet-button';
33
31
  },
34
32
  },
35
33
  data() {
@@ -1,15 +1,10 @@
1
1
  <template>
2
- <component
3
- class="cv-code-snippet"
4
- :is="theComponent"
5
- v-bind="$attrs"
6
- @copy-code="onCopyCode"
7
- >
2
+ <component class="cv-code-snippet" :is="theComponent" v-bind="$attrs" @copy-code="onCopyCode">
8
3
  <code ref="code"> <slot></slot> </code>
9
4
  <!-- textarea cannot be fully hidden for clipboard to work -->
10
5
  <textarea
11
6
  class="cv-code-snippet__clippy"
12
- style="position: absolute; left: -9999px; max-width: 0; opacity: 0; overflow: hidden"
7
+ style="position: absolute; left: -9999px; max-width: 0; opacity: 0; overflow: hidden;"
13
8
  aria-hidden="true"
14
9
  ref="clippy"
15
10
  ></textarea>
@@ -24,18 +24,35 @@
24
24
  :aria-selected="`${dataSelected}`"
25
25
  @click="open"
26
26
  >
27
- <slot></slot>
27
+ <component v-if="typeof icon === 'object'" :is="icon" class="bx--content-switcher__icon" />
28
+ <svg v-if="typeof icon === 'string'" class="bx--content-switcher__icon" height="16" width="16">
29
+ <use :href="icon"></use>
30
+ </svg>
31
+ <span>
32
+ <slot></slot>
33
+ </span>
28
34
  </button>
29
35
  </template>
30
36
 
31
37
  <script>
32
38
  import uidMixin from '../../mixins/uid-mixin';
39
+ import { componentsX } from '../../internal/feature-flags';
33
40
 
34
41
  export default {
35
42
  name: 'CvContentSwitcherButton',
36
43
  mixins: [uidMixin],
37
44
  props: {
38
45
  contentSelector: { type: String, default: undefined },
46
+ icon: {
47
+ type: [String, Object],
48
+ default: null,
49
+ validator(val) {
50
+ if (!val || typeof val === 'string') {
51
+ return true;
52
+ }
53
+ return val.render !== null;
54
+ },
55
+ },
39
56
  ownerId: { type: String, default: undefined },
40
57
  selected: Boolean,
41
58
  },
@@ -50,6 +67,7 @@ export default {
50
67
  },
51
68
  data() {
52
69
  return {
70
+ componentsX,
53
71
  dataSelected: false,
54
72
  };
55
73
  },
@@ -57,9 +75,7 @@ export default {
57
75
  this.$_CvContentSwitcherButton = true; // for use by parent with $children
58
76
 
59
77
  if (this.contentSelector === '' && this.ownerId === '') {
60
- console.error(
61
- 'CvContentSwitcherButton: ownerId or content-selector properties must not be empty strings.'
62
- );
78
+ console.error('CvContentSwitcherButton: ownerId or content-selector properties must not be empty strings.');
63
79
  }
64
80
 
65
81
  this.dataSelected = this.selected;