@carbon/vue 2.34.0 → 2.36.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +25 -18
  3. package/dist/carbon-vue.common.js +1357 -1014
  4. package/dist/carbon-vue.common.js.map +1 -1
  5. package/dist/carbon-vue.umd.js +1357 -1014
  6. package/dist/carbon-vue.umd.js.map +1 -1
  7. package/dist/carbon-vue.umd.min.js +3 -3
  8. package/dist/carbon-vue.umd.min.js.map +1 -1
  9. package/package.json +6 -6
  10. package/src/components/cv-accordion/cv-accordion-item.vue +4 -0
  11. package/src/components/cv-accordion/cv-accordion-skeleton.vue +17 -1
  12. package/src/components/cv-accordion/cv-accordion.vue +18 -1
  13. package/src/components/cv-button/button-mixin.js +12 -7
  14. package/src/components/cv-button/cv-button-set.vue +4 -1
  15. package/src/components/cv-button/cv-icon-button.vue +1 -1
  16. package/src/components/cv-code-snippet/_cv-code-snippet-inline.vue +13 -7
  17. package/src/components/cv-code-snippet/_cv-code-snippet-multiline.vue +13 -7
  18. package/src/components/cv-code-snippet/_cv-code-snippet-oneline.vue +10 -11
  19. package/src/components/cv-code-snippet/cv-code-snippet.vue +17 -1
  20. package/src/components/cv-combo-box/cv-combo-box.vue +1 -1
  21. package/src/components/cv-content-switcher/cv-content-switcher.vue +20 -3
  22. package/src/components/cv-data-table/cv-data-table.vue +11 -3
  23. package/src/components/cv-date-picker/cv-date-picker.vue +1 -1
  24. package/src/components/cv-dropdown/cv-dropdown.vue +1 -1
  25. package/src/components/cv-loading/cv-loading.vue +5 -1
  26. package/src/components/cv-modal/cv-modal.vue +31 -0
  27. package/src/components/cv-multi-select/cv-multi-select.vue +7 -8
  28. package/src/components/cv-number-input/cv-number-input.vue +1 -1
  29. package/src/components/cv-search/cv-search.vue +1 -1
  30. package/src/components/cv-select/cv-select.vue +1 -1
  31. package/src/components/cv-slider/cv-slider.vue +1 -1
  32. package/src/components/cv-tabs/cv-tabs.vue +9 -1
  33. package/src/components/cv-tag/cv-tag.vue +0 -1
  34. package/src/components/cv-text-area/cv-text-area.vue +1 -1
  35. package/src/components/cv-text-input/cv-text-input.vue +1 -2
  36. package/src/components/cv-tile/cv-tile.vue +1 -1
  37. package/src/components/cv-time-picker/cv-time-picker.vue +2 -2
  38. package/src/components/cv-tooltip/cv-definition-tooltip.vue +1 -1
  39. package/src/components/cv-ui-shell/cv-header-panel.vue +1 -1
  40. package/src/components/cv-ui-shell/cv-side-nav-link.vue +10 -2
  41. package/src/components/cv-ui-shell/cv-side-nav.vue +1 -1
  42. package/src/directives/clickout.js +21 -9
  43. package/src/mixins/theme-mixin.js +14 -2
@@ -41,7 +41,7 @@
41
41
  type="number"
42
42
  :class="[
43
43
  `${carbonPrefix}--text-input ${carbonPrefix}--slider-text-input`,
44
- { [`${carbonPrefix}--text-input--light`]: theme === 'light' },
44
+ { [`${carbonPrefix}--text-input--light`]: isLight },
45
45
  ]"
46
46
  :placeholder="min"
47
47
  v-model="internalValue"
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="cv-tabs" @focusout="onFocusout" @focusin="onFocusin" style="width: 100%;">
2
+ <div class="cv-tabs" ref="tabs" style="width: 100%;">
3
3
  <div
4
4
  data-tabs
5
5
  :class="[`cv-tab ${carbonPrefix}--tabs`, { [`${carbonPrefix}--tabs--container`]: container }]"
@@ -89,6 +89,14 @@ export default {
89
89
  this.$on('cv:disabled', srcComponent => this.onCvDisabled(srcComponent));
90
90
  this.$on('cv:enabled', srcComponent => this.onCvEnabled(srcComponent));
91
91
  },
92
+ mounted() {
93
+ this.$refs.tabs.addEventListener('focusout', this.onFocusout);
94
+ this.$refs.tabs.addEventListener('focusin', this.onFocusin);
95
+ },
96
+ beforeDestroy() {
97
+ this.$refs.tabs.removeEventListener('focusout', this.onFocusout);
98
+ this.$refs.tabs.removeEventListener('focusin', this.onFocusin);
99
+ },
92
100
  computed: {
93
101
  triggerStyleOverride() {
94
102
  // <style carbon tweaks - DO NOT USE STYLE TAG as it causes SSR issues
@@ -8,7 +8,6 @@
8
8
  [`${carbonPrefix}--tag--disabled`]: disabled,
9
9
  },
10
10
  ]"
11
- :tabindex="!disabled ? 0 : undefined"
12
11
  role="listitem"
13
12
  :title="title"
14
13
  @keydown.enter.stop.prevent="$emit('remove')"
@@ -17,7 +17,7 @@
17
17
  :class="[
18
18
  `${carbonPrefix}--text-area`,
19
19
  {
20
- [`${carbonPrefix}--text-area--light`]: theme === 'light',
20
+ [`${carbonPrefix}--text-area--light`]: isLight,
21
21
  [`${carbonPrefix}--text-area--invalid`]: isInvalid,
22
22
  },
23
23
  ]"
@@ -17,7 +17,7 @@
17
17
  :class="[
18
18
  `${carbonPrefix}--text-input`,
19
19
  {
20
- [`${carbonPrefix}--text-input--light`]: theme === 'light',
20
+ [`${carbonPrefix}--text-input--light`]: isLight,
21
21
  [`${carbonPrefix}--text-input--invalid`]: isInvalid,
22
22
  },
23
23
  ]"
@@ -78,7 +78,6 @@ export default {
78
78
  passwordHideLabel: { type: String, default: 'Hide password' },
79
79
  passwordShowLabel: { type: String, default: 'Show password' },
80
80
  passwordVisible: Boolean,
81
- theme: String,
82
81
  type: String,
83
82
  value: String,
84
83
  },
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="tagType"
4
- :class="[`cv-tile ${carbonPrefix}--tile`, { [`${carbonPrefix}--tile--light`]: theme === 'light' }]"
4
+ :class="[`cv-tile ${carbonPrefix}--tile`, { [`${carbonPrefix}--tile--light`]: isLight }]"
5
5
  :checked="selected"
6
6
  :expanded="expanded"
7
7
  v-bind="$attrs"
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div :class="`cv-time-picker ${carbonPrefix}--form-item`">
3
3
  <div
4
- :class="[`${carbonPrefix}--time-picker`, { [`${carbonPrefix}--time-picker--light`]: theme === 'light' }]"
4
+ :class="[`${carbonPrefix}--time-picker`, { [`${carbonPrefix}--time-picker--light`]: isLight }]"
5
5
  :data-invalid="isInvalid"
6
6
  >
7
7
  <div :class="`${carbonPrefix}--time-picker__input`">
@@ -12,7 +12,7 @@
12
12
  type="text"
13
13
  :class="[
14
14
  `${carbonPrefix}--time-picker__input-field ${carbonPrefix}--text-input`,
15
- { [`${carbonPrefix}--text-input--light`]: theme === 'light' },
15
+ { [`${carbonPrefix}--text-input--light`]: isLight },
16
16
  ]"
17
17
  :pattern="pattern"
18
18
  v-bind="$attrs"
@@ -30,7 +30,7 @@ export default {
30
30
  type: String,
31
31
  default: 'top',
32
32
  validator(val) {
33
- const validValues = ['top', 'bottom'];
33
+ const validValues = ['top', 'left', 'right', 'bottom'];
34
34
  const valid = validValues.includes(val);
35
35
  if (!valid) {
36
36
  console.warn(`CVDefinitionTooltip.direction must be one of the following: ${validValues}`);
@@ -62,7 +62,7 @@ export default {
62
62
  this.$parent.$emit('cv:panel-focusout', this, ev);
63
63
  },
64
64
  onMouseDown(ev) {
65
- if (this.$el === ev.target) {
65
+ if (this.$el == ev.target || this.$el.contains(ev.target)) {
66
66
  // ignore mousedown on panel can cause focus event
67
67
  ev.preventDefault();
68
68
  }
@@ -36,11 +36,19 @@ export default {
36
36
  },
37
37
  data() {
38
38
  return {
39
- hasNavIcon: this.$slots['nav-icon'],
39
+ hasNavIcon: false,
40
40
  };
41
41
  },
42
+ mounted() {
43
+ this.checkSlots();
44
+ },
42
45
  updated() {
43
- this.hasNavIcon = !!this.$slots['nav-icon'];
46
+ this.checkSlots();
47
+ },
48
+ methods: {
49
+ checkSlots() {
50
+ this.hasNavIcon = !!this.$slots['nav-icon'];
51
+ },
44
52
  },
45
53
  };
46
54
  </script>
@@ -80,7 +80,7 @@ export default {
80
80
  this.$parent.$emit('cv:panel-focusout', this, ev);
81
81
  },
82
82
  onMouseDown(ev) {
83
- if (this.$el === ev.target) {
83
+ if (this.$el == ev.target || this.$el.contains(ev.target)) {
84
84
  // ignore mousedown on panel can cause focus event
85
85
  ev.preventDefault();
86
86
  }
@@ -1,17 +1,29 @@
1
1
  // This directive determines calls the associated method if a click happens outside of el
2
2
 
3
+ const handlerMap = new WeakMap();
4
+
3
5
  export default {
4
6
  bind(el, binding, vnode) {
5
- el.clickOutHandler = function(event) {
6
- // neither element or child of
7
- if (!(el == event.target || el.contains(event.target))) {
8
- // call method
9
- vnode.context[binding.expression](event);
10
- }
11
- };
12
- document.body.addEventListener('click', el.clickOutHandler);
7
+ if (!el.clickOutsideBlur) {
8
+ el.clickOutsideBlur = function(blurEv) {
9
+ // neither element or child of
10
+ if (!handlerMap.has(el)) {
11
+ handlerMap.set(el, clickoutEv => {
12
+ // neither element or child of
13
+ if (!(el == clickoutEv.target || el.contains(clickoutEv.target))) {
14
+ // call method
15
+ vnode.context[binding.expression](clickoutEv);
16
+ }
17
+ });
18
+ document.body.addEventListener('click', handlerMap.get(el));
19
+ }
20
+ };
21
+
22
+ el.addEventListener('focusout', el.clickOutsideBlur);
23
+ }
13
24
  },
14
25
  unbind(el) {
15
- document.body.removeEventListener('click', el.clickOutHandler);
26
+ handlerMap.delete(el);
27
+ el.removeEventListener('focusout', el.clickOutsideBlur);
16
28
  },
17
29
  };
@@ -2,10 +2,22 @@ const options = ['light'];
2
2
 
3
3
  export default {
4
4
  props: {
5
+ light: Boolean,
5
6
  theme: {
6
7
  type: String,
7
- default: '',
8
- validator: value => value.length === 0 || options.includes(value),
8
+ default: undefined,
9
+ validator: value => {
10
+ if (value !== undefined && process.env.NODE_ENV === 'development') {
11
+ console.warn(`theme='light' deprecated in favour of boolean light property.`);
12
+ }
13
+
14
+ return value.length === 0 || options.includes(value);
15
+ },
16
+ },
17
+ },
18
+ computed: {
19
+ isLight() {
20
+ return this.light || this.theme === 'light';
9
21
  },
10
22
  },
11
23
  };