@carbon/vue 3.0.11 → 3.0.12

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
  "license": "Apache-2.0",
4
- "version": "3.0.11",
4
+ "version": "3.0.12",
5
5
  "description": "A collection of components for the Carbon Design System built using Vue.js",
6
6
  "packageManager": "yarn@3.2.0",
7
7
  "main": "dist/carbon-vue-3.umd.min.js",
@@ -174,5 +174,5 @@
174
174
  "url": "git+https://github.com/carbon-design-system/carbon-components-vue.git"
175
175
  },
176
176
  "sideEffects": true,
177
- "gitHead": "1a9b7dd369e0985937b5b1efcc1dea6ce9ce40a5"
177
+ "gitHead": "f685b28f8725fb4f61078e347e394ea08e4c0b5c"
178
178
  }
@@ -10,16 +10,28 @@ import { sbCompPrefix } from '../../global/storybook-utils';
10
10
  import { action } from '@storybook/addon-actions';
11
11
  import { Terminal16 as CompileIcon, Debug16 as DebugIcon, Chip16 as EmbedIcon,
12
12
  TrashCan16 as TrashCanIcon} from '@carbon/icons-vue'
13
- const testData = [
14
- { name:"Java", year:1995, oo:"Yes", purpose:"Applications", standard:"Java Language Specification", desc: "As of September 2022, Java 19 is the latest version, while Java 17, 11 and 8 are the current long-term support (LTS) versions."},
15
- { name:"COBOL", year:1959, oo:"Yes", purpose:"Business applications", standard:"COBOL 2014", desc: "COBOL statements have an English-like syntax, which was designed to be self-documenting and highly readable."},
16
- { name:"Pascal", year:1970, oo:"No", purpose:"Applications", standard:"None", desc: "Pascal was developed on the pattern of the ALGOL 60 language."},
17
- { name:"Ada", year:1980, oo:"Yes", purpose:"US DoD projects", standard:"Ada 2012 TC1", desc: "Ada was named after Ada Lovelace (1815–1852), who has been credited as the first computer programmer."},
18
- { name:"BASIC", year:1964, oo:"No", purpose:"Education", standard:"ANSI", desc: "BASIC declined in popularity in the 1990s"},
19
- { name:"C++", year:1985, oo:"Yes", purpose:"Systems programming", standard:"ISO/IEC 2017", desc: "C++ is standardized by the International Organization for Standardization (ISO), with the latest standard version ratified and published by ISO in December 2020 as ISO/IEC 14882:2020 (informally known as C++20)."},
20
- { name:"Fortran", year:1957, oo:"No", purpose:"Engineering applications", standard:"ANSI", desc: "Fortran was originally developed by IBM in the 1950s for scientific and engineering applications, and subsequently came to dominate scientific computing."},
21
- { name:"Go", year:2009, oo:"Maybe", purpose:"Networked applications", standard:"Go Spec", desc: "Go's designers were primarily motivated by their shared dislike of C++."},
22
- ];
13
+ import { ref } from 'vue';
14
+ const testData = ref([
15
+ { index:"0", name:"Java", year:1995, oo:"Yes", purpose:"Applications", standard:"Java Language Specification", desc: "As of September 2022, Java 19 is the latest version, while Java 17, 11 and 8 are the current long-term support (LTS) versions."},
16
+ { index:"1", name:"COBOL", year:1959, oo:"Yes", purpose:"Business applications", standard:"COBOL 2014", desc: "COBOL statements have an English-like syntax, which was designed to be self-documenting and highly readable."},
17
+ { index:"2", name:"Pascal", year:1970, oo:"No", purpose:"Applications", standard:"None", desc: "Pascal was developed on the pattern of the ALGOL 60 language."},
18
+ { index:"3", name:"Ada", year:1980, oo:"Yes", purpose:"US DoD projects", standard:"Ada 2012 TC1", desc: "Ada was named after Ada Lovelace (1815–1852), who has been credited as the first computer programmer."},
19
+ { index:"4", name:"BASIC", year:1964, oo:"No", purpose:"Education", standard:"ANSI", desc: "BASIC declined in popularity in the 1990s"},
20
+ { index:"5", name:"C++", year:1985, oo:"Yes", purpose:"Systems programming", standard:"ISO/IEC 2017", desc: "C++ is standardized by the International Organization for Standardization (ISO), with the latest standard version ratified and published by ISO in December 2020 as ISO/IEC 14882:2020 (informally known as C++20)."},
21
+ { index:"6", name:"Fortran", year:1957, oo:"No", purpose:"Engineering applications", standard:"ANSI", desc: "Fortran was originally developed by IBM in the 1950s for scientific and engineering applications, and subsequently came to dominate scientific computing."},
22
+ { index:"7", name:"Go", year:2009, oo:"Maybe", purpose:"Networked applications", standard:"Go Spec", desc: "Go's designers were primarily motivated by their shared dislike of C++."},
23
+ ]);
24
+ function sortTestData(opts) {
25
+ action('sort')(opts)
26
+ if (opts.order === 'none')
27
+ return testData.value.sort((a, b) => a.index.localeCompare(b.index, 'en', { sensitivity: 'base' }));
28
+ let direction = 1
29
+ if (opts.order === 'descending') direction = -1
30
+ if (opts.name === 'name')
31
+ return testData.value.sort((a, b) => direction * a.name.localeCompare(b.name, 'en', { sensitivity: 'base' }));
32
+ else if (opts.name === 'year')
33
+ return testData.value.sort((a, b) => direction * (a.year - b.year));
34
+ }
23
35
 
24
36
  <Meta title={`${sbCompPrefix}/CvDataTable`} component={CvDataTable} />
25
37
 
@@ -46,7 +58,7 @@ setup() {
46
58
  useHelperTextSlot: undefined,
47
59
  template: undefined},
48
60
  trashIcon: TrashCanIcon,
49
- onSort: action('sort'),
61
+ onSort: sortTestData,
50
62
  onSearch: action('search'),
51
63
  onRowSelectChange: action('row-select-change'),
52
64
  onRowSelectChanges: action('row-select-changes'),
@@ -101,14 +113,14 @@ const defaultTemplate = `
101
113
  </embed-icon>
102
114
  </cv-data-table-action>
103
115
  </template>
104
- <template v-slot:headings>
116
+ <template #headings>
105
117
  <cv-data-table-heading heading="Name" name="name" sortable/>
106
118
  <cv-data-table-heading heading="Year" name="year" sortable/>
107
119
  <cv-data-table-heading heading="Object Oriented"/>
108
120
  <cv-data-table-heading heading="Purpose" />
109
121
  <cv-data-table-heading heading="Standard" />
110
122
  </template>
111
- <template v-slot:data>
123
+ <template #data>
112
124
  <cv-data-table-row v-for="row in testData" :key="row.name" :value="row.name">
113
125
  <cv-data-table-cell>{{row.name}}</cv-data-table-cell>
114
126
  <cv-data-table-cell>{{row.year}}</cv-data-table-cell>
@@ -122,7 +134,7 @@ const defaultTemplate = `
122
134
  `;
123
135
  const expandingRowsTemplate = defaultTemplate.replace(
124
136
  "<!-- Add optional expanding data here -->",
125
- `<template v-slot:expandedContent>{{row.desc}}</template>`)
137
+ `<template #expandedContent>{{row.desc}}</template>`)
126
138
  .replace('@search="onSearch"', '')
127
139
  const skeletonTemplate = `
128
140
  <cv-data-table-skeleton
@@ -137,6 +149,19 @@ const skeletonTemplate = `
137
149
 
138
150
  **Usage:**
139
151
  - Sorting, filtering and pagination are the responsibility of the component user. This component raises events to facilitate this.
152
+ For example the test data is sorted like this but this is very specific to this data. Users will need to provide their own sort and filtering.
153
+ ```javascript
154
+ function sortTestData(opts) {
155
+ if (opts.order === 'none')
156
+ return testData.value.sort((a, b) => a.index.localeCompare(b.index, 'en', { sensitivity: 'base' }));
157
+ let direction = 1
158
+ if (opts.order === 'descending') direction = -1
159
+ if (opts.name === 'name')
160
+ return testData.value.sort((a, b) => direction * a.name.localeCompare(b.name, 'en', { sensitivity: 'base' }));
161
+ else if (opts.name === 'year')
162
+ return testData.value.sort((a, b) => direction * (a.year - b.year));
163
+ }
164
+ ```
140
165
  - The search bar appears only if the search event is listened for.
141
166
 
142
167
  **Row attributes:**
@@ -127,11 +127,9 @@ const internalOrder = computed(() => {
127
127
  return undefined;
128
128
  }
129
129
  const heading = store.findHeading(parent, cvId);
130
- if (heading?.order !== 'ascending' && heading?.order !== 'descending') {
131
- return 'none';
132
- } else {
133
- return heading?.order;
134
- }
130
+ if (['ascending', 'descending', 'none'].includes(heading?.order))
131
+ return heading.order;
132
+ else return 'none';
135
133
  });
136
134
 
137
135
  const headingLabelTag = computed(() => {
@@ -42,13 +42,12 @@
42
42
  data-date-picker-input
43
43
  role="datepicker"
44
44
  :data-invalid="isInvalid || null"
45
- :disabled="disabled"
46
- :data-date-picker-input-from="getKind === 'range'"
45
+ :disabled="disabled || null"
46
+ :data-date-picker-input-from="`${getKind === 'range'}`"
47
47
  :class="`${carbonPrefix}--date-picker__input`"
48
48
  :pattern="pattern"
49
49
  :placeholder="placeholder"
50
50
  @change="handleUpdateEvent"
51
- @click="handleClick"
52
51
  />
53
52
  <Calendar16
54
53
  v-if="['single', 'range'].includes(getKind)"
@@ -87,9 +86,9 @@
87
86
  type="text"
88
87
  data-date-picker-input
89
88
  role="todatepicker"
90
- :data-date-picker-input-to="kind === 'range'"
89
+ :data-date-picker-input-to="`${kind === 'range'}`"
91
90
  :data-invalid="isInvalid || null"
92
- :disabled="disabled"
91
+ :disabled="disabled || null"
93
92
  :class="`${carbonPrefix}--date-picker__input`"
94
93
  :pattern="pattern"
95
94
  :placeholder="placeholder"
@@ -136,9 +135,6 @@ const dateWrapper = ref(null);
136
135
  const date = ref(null);
137
136
  const todate = ref(null);
138
137
 
139
- const cvId = useCvId(props, true, 'date-picker-');
140
- const isLight = useIsLight(props);
141
-
142
138
  let calendar;
143
139
 
144
140
  const props = defineProps({
@@ -169,6 +165,9 @@ const props = defineProps({
169
165
  ...propsCvTheme,
170
166
  });
171
167
 
168
+ const cvId = useCvId(props, true, 'date-picker-');
169
+ const isLight = useIsLight(props);
170
+
172
171
  const emit = defineEmits(['update:modelValue']);
173
172
 
174
173
  const getKind = computed({
@@ -8,7 +8,7 @@
8
8
  `cv-modal ${carbonPrefix}--modal`,
9
9
  {
10
10
  'is-visible': dataVisible,
11
- [`${carbonPrefix}--modal--danger`]: kind === 'danger',
11
+ [`${carbonPrefix}--modal--danger`]: kind === MODAL_KIND_DANGER,
12
12
  },
13
13
  ]"
14
14
  tabindex="-1"
@@ -119,6 +119,15 @@
119
119
  </template>
120
120
 
121
121
  <script setup>
122
+ import {
123
+ MODAL_KIND_DANGER,
124
+ MODAL_KIND_PRIMARY,
125
+ MODAL_KINDS,
126
+ MODAL_SIZE_EXTRA_SMALL,
127
+ MODAL_SIZE_LARGE,
128
+ MODAL_SIZE_SMALL,
129
+ MODAL_SIZES,
130
+ } from './index';
122
131
  import CvButton from '../CvButton/CvButton.vue';
123
132
  import { carbonPrefix } from '../../global/settings';
124
133
  import { props as propsCvId, useCvId } from '../../use/cvId';
@@ -155,7 +164,11 @@ const props = defineProps({
155
164
  kind: {
156
165
  type: String,
157
166
  default: '',
158
- validator: val => ['', 'danger'].includes(val),
167
+ validator: val => {
168
+ const valid = MODAL_KINDS.includes(val);
169
+ if (!valid) console.warn('valid kinds:', MODAL_KINDS);
170
+ return valid;
171
+ },
159
172
  },
160
173
  /**
161
174
  * boolean value if true the component user is expected to close the modal via visible property.
@@ -187,8 +200,11 @@ const props = defineProps({
187
200
  */
188
201
  size: {
189
202
  type: String,
190
- validator: val =>
191
- ['', 'xs', 'sm', 'small', 'md', 'large', 'lg'].includes(val),
203
+ validator: val => {
204
+ const valid = MODAL_SIZES.includes(val);
205
+ if (!valid) console.warn('valid sizes:', MODAL_SIZES);
206
+ return valid;
207
+ },
192
208
  default: '',
193
209
  },
194
210
  /**
@@ -333,22 +349,22 @@ const dialogAttrs = computed(() => {
333
349
  return attrs;
334
350
  });
335
351
  const primaryKind = computed(() => {
336
- if (props.kind === 'danger') {
337
- return 'danger';
352
+ if (props.kind === MODAL_KIND_DANGER) {
353
+ return MODAL_KIND_DANGER;
338
354
  } else {
339
- return 'primary';
355
+ return MODAL_KIND_PRIMARY;
340
356
  }
341
357
  });
342
358
  const internalSize = computed(() => {
343
359
  switch (props.size) {
344
- case 'xs':
345
- return 'xs';
346
- case 'sm':
360
+ case MODAL_SIZE_EXTRA_SMALL:
361
+ return MODAL_SIZE_EXTRA_SMALL;
362
+ case MODAL_SIZE_SMALL:
347
363
  case 'small':
348
- return 'sm';
349
- case 'lg':
364
+ return MODAL_SIZE_SMALL;
365
+ case MODAL_SIZE_LARGE:
350
366
  case 'large':
351
- return 'lg';
367
+ return MODAL_SIZE_LARGE;
352
368
  default:
353
369
  return '';
354
370
  }
@@ -398,4 +414,10 @@ function onOtherBtnClick(ev) {
398
414
  onBeforeUnmount(() => {
399
415
  if (dataVisible.value) hide();
400
416
  });
417
+
418
+ // exposing methods
419
+ defineExpose({
420
+ show,
421
+ hide,
422
+ });
401
423
  </script>
@@ -1,3 +1,31 @@
1
1
  import CvModal from './CvModal.vue';
2
- export { CvModal };
2
+
3
+ const MODAL_SIZE_EXTRA_SMALL = 'xs';
4
+ const MODAL_SIZE_SMALL = 'sm';
5
+ const MODAL_SIZE_MEDIUM = 'md';
6
+ const MODAL_SIZE_LARGE = 'lg';
7
+ const MODAL_SIZES = [
8
+ '',
9
+ MODAL_SIZE_EXTRA_SMALL,
10
+ MODAL_SIZE_SMALL,
11
+ 'small',
12
+ MODAL_SIZE_MEDIUM,
13
+ 'medium',
14
+ 'large',
15
+ MODAL_SIZE_LARGE,
16
+ ];
17
+ const MODAL_KIND_PRIMARY = 'primary';
18
+ const MODAL_KIND_DANGER = 'danger';
19
+ const MODAL_KINDS = ['', MODAL_KIND_PRIMARY, MODAL_KIND_DANGER];
20
+
21
+ export {
22
+ CvModal,
23
+ MODAL_SIZES,
24
+ MODAL_SIZE_EXTRA_SMALL,
25
+ MODAL_SIZE_SMALL,
26
+ MODAL_SIZE_LARGE,
27
+ MODAL_KINDS,
28
+ MODAL_KIND_PRIMARY,
29
+ MODAL_KIND_DANGER,
30
+ };
3
31
  export default CvModal;
@@ -426,8 +426,8 @@ onUpdated(checkSlots);
426
426
  onMounted(updateOptions);
427
427
  onMounted(updateSelectedItems);
428
428
 
429
- watch(() => props.modelValue, updateSelectedItems);
430
- watch(() => props.options, updateOptions);
429
+ watch(() => props.modelValue, updateSelectedItems, { deep: true });
430
+ watch(() => props.options, updateOptions, { deep: true });
431
431
  watch(() => props.selectionFeedback, updateOptions);
432
432
 
433
433
  const highlighted = computed({
@@ -1,7 +1,8 @@
1
1
  import { action } from '@storybook/addon-actions';
2
- import { sbCompPrefix } from '../../global/storybook-utils';
2
+ import { sbCompPrefix, storySourceCode } from '../../global/storybook-utils';
3
3
 
4
4
  import { CvInlineNotification, CvNotificationConsts } from '.';
5
+ import DocumentationTemplate from './CvInlineNotificationTemplate.mdx';
5
6
 
6
7
  export default {
7
8
  title: `${sbCompPrefix}/CvInlineNotification`,
@@ -59,6 +60,11 @@ export default {
59
60
  control: { type: 'boolean' },
60
61
  },
61
62
  },
63
+ parameters: {
64
+ docs: {
65
+ page: DocumentationTemplate,
66
+ },
67
+ },
62
68
  };
63
69
 
64
70
  const template = `<cv-inline-notification v-bind="args" @action="onAction" @close="onClose" />`;
@@ -79,6 +85,10 @@ const Template = args => {
79
85
  export const Info = Template.bind({});
80
86
  Info.args = {
81
87
  kind: CvNotificationConsts.notificationKinds[0],
88
+ primary: true,
89
+ };
90
+ Info.parameters = {
91
+ docs: { source: { code: storySourceCode(template, Info.args) } },
82
92
  };
83
93
 
84
94
  export const InfoSquare = Template.bind({});
@@ -86,24 +96,71 @@ InfoSquare.storyName = 'Info square';
86
96
  InfoSquare.args = {
87
97
  kind: CvNotificationConsts.notificationKinds[1],
88
98
  };
99
+ InfoSquare.parameters = {
100
+ docs: { source: { code: storySourceCode(template, InfoSquare.args) } },
101
+ };
89
102
 
90
103
  export const Success = Template.bind({});
91
104
  Success.args = {
92
105
  kind: CvNotificationConsts.notificationKinds[2],
93
106
  };
107
+ Success.parameters = {
108
+ docs: { source: { code: storySourceCode(template, Success.args) } },
109
+ };
94
110
 
95
111
  export const Warning = Template.bind({});
96
112
  Warning.args = {
97
113
  kind: CvNotificationConsts.notificationKinds[3],
98
114
  };
115
+ Warning.parameters = {
116
+ docs: { source: { code: storySourceCode(template, Warning.args) } },
117
+ };
99
118
 
100
119
  export const WarningAlt = Template.bind({});
101
120
  WarningAlt.storyName = 'Warning (alt)';
102
121
  WarningAlt.args = {
103
122
  kind: CvNotificationConsts.notificationKinds[4],
104
123
  };
124
+ WarningAlt.parameters = {
125
+ docs: { source: { code: storySourceCode(template, WarningAlt.args) } },
126
+ };
105
127
 
106
128
  export const Error = Template.bind({});
107
129
  Error.args = {
108
130
  kind: CvNotificationConsts.notificationKinds[5],
109
131
  };
132
+ Error.parameters = {
133
+ docs: { source: { code: storySourceCode(template, Error.args) } },
134
+ };
135
+
136
+ const templateSlots = `
137
+ <cv-inline-notification v-bind="args">
138
+ <template #title>
139
+ <h2>Big title</h2>
140
+ </template>
141
+ <template #subtitle>
142
+ Lorem ipsum dolor sit amet, <a href="#">consectetur adipisicing elit</a>, seed do eiusmod tempor <strong>incididunt ut labore</strong> et dolore magna aliqua.
143
+ </template>
144
+ </cv-inline-notification>`;
145
+ const SlotTemplate = args => {
146
+ return {
147
+ components: { CvInlineNotification },
148
+ template: templateSlots,
149
+ setup() {
150
+ return {
151
+ onAction: action('action'),
152
+ onClose: action('close'),
153
+ args,
154
+ };
155
+ },
156
+ };
157
+ };
158
+ export const Slots = SlotTemplate.bind({});
159
+ Slots.args = {
160
+ kind: CvNotificationConsts.notificationKinds[0],
161
+ actionLabel: '',
162
+ hideCloseButton: true,
163
+ };
164
+ Slots.parameters = {
165
+ docs: { source: { code: storySourceCode(templateSlots, Slots.args) } },
166
+ };
@@ -15,10 +15,14 @@
15
15
  />
16
16
  <div :class="`${carbonPrefix}--inline-notification__text-wrapper`">
17
17
  <p :class="`${carbonPrefix}--inline-notification__title`">
18
- {{ title }}
18
+ <slot name="title">
19
+ {{ title }}
20
+ </slot>
19
21
  </p>
20
22
  <div :class="`${carbonPrefix}--inline-notification__subtitle`">
21
- {{ subTitle }}
23
+ <slot name="subtitle">
24
+ {{ subTitle }}
25
+ </slot>
22
26
  </div>
23
27
  </div>
24
28
  </div>
@@ -35,6 +39,7 @@
35
39
  {{ actionLabel }}
36
40
  </button>
37
41
  <button
42
+ v-if="!hideCloseButton"
38
43
  type="button"
39
44
  :aria-label="closeAriaLabel"
40
45
  :class="`${carbonPrefix}--inline-notification__close-button`"
@@ -66,7 +71,7 @@ export default {
66
71
  type: String,
67
72
  default: '',
68
73
  },
69
- /** Notification sub title (supports HTML) */
74
+ /** Notification subtitle */
70
75
  subTitle: {
71
76
  type: String,
72
77
  default: '',
@@ -86,6 +91,11 @@ export default {
86
91
  type: Boolean,
87
92
  default: false,
88
93
  },
94
+ /** Set to true to hide the code button */
95
+ hideCloseButton: {
96
+ type: Boolean,
97
+ default: false,
98
+ },
89
99
  },
90
100
  emits: [
91
101
  /** Emitted on clicking the action button */
@@ -0,0 +1,16 @@
1
+ import { Meta, Title, Primary, Stories } from '@storybook/addon-docs';
2
+
3
+ <Meta isTemplate />
4
+
5
+ <Title />
6
+
7
+ Migration notes:
8
+
9
+ - **Breaking**. The `subTitle` property no longer renders html. Please use the `subtitle` slot instead.
10
+ - The `title` content can now be provided in the `title` slot.
11
+
12
+ <Primary />
13
+
14
+ <Controls />
15
+
16
+ <Stories />
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="formItem ? 'div' : CvEmpty"
4
- :class="`cv-search ${carbonPrefix}--form-item`"
4
+ :class="[`cv-search`, `${carbonPrefix}--form-item`, $attrs.class]"
5
5
  >
6
6
  <div
7
7
  ref="elSearch"
@@ -71,7 +71,7 @@
71
71
  role="tab"
72
72
  :aria-controls="tab.uid"
73
73
  :aria-disabled="disabledTabs.has(tab.uid) || null"
74
- :aria-selected="selectedId === tab.uid"
74
+ :aria-selected="`${selectedId === tab.uid}`"
75
75
  :tabindex="selectedId === tab.uid ? 0 : -1"
76
76
  type="button"
77
77
  @click="onTabClick(tab.uid)"
@@ -187,7 +187,7 @@ function maybeSelectFirstTab() {
187
187
  if (index > -1) selectedId.value = tabs.value[index].uid;
188
188
  }
189
189
  onMounted(maybeSelectFirstTab);
190
- watch(tabs, maybeSelectFirstTab);
190
+ watch(tabs, maybeSelectFirstTab, { deep: true });
191
191
  watch(selectedId, () => {
192
192
  nextTick(() => {
193
193
  doTabClick(selectedId.value);