@carbon/vue 3.0.8-alpha.0 → 3.0.9

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 (37) hide show
  1. package/README.md +60 -21
  2. package/dist/carbon-vue-3.common.js +539 -69
  3. package/dist/carbon-vue-3.common.js.map +1 -1
  4. package/dist/carbon-vue-3.umd.js +539 -69
  5. package/dist/carbon-vue-3.umd.js.map +1 -1
  6. package/dist/carbon-vue-3.umd.min.js +4 -4
  7. package/dist/carbon-vue-3.umd.min.js.map +1 -1
  8. package/package.json +2 -2
  9. package/src/components/CvFileUploader/CvFileUploader.stories.mdx +24 -6
  10. package/src/components/CvFileUploader/CvFileUploader.vue +58 -19
  11. package/src/components/CvNotification/CvToastNotification.stories.js +71 -1
  12. package/src/components/CvNotification/CvToastNotification.vue +6 -4
  13. package/src/components/CvOverflowMenu/CvOverflowMenu.stories.mdx +68 -12
  14. package/src/components/CvOverflowMenu/CvOverflowMenu.vue +39 -45
  15. package/src/components/CvOverflowMenu/CvOverflowMenuItem.vue +6 -11
  16. package/src/components/CvOverflowMenu/index.js +2 -1
  17. package/src/components/CvStructuredList/CvStructuredList.stories.js +141 -0
  18. package/src/components/CvStructuredList/CvStructuredList.vue +44 -0
  19. package/src/components/CvStructuredList/CvStructuredListData.vue +19 -0
  20. package/src/components/CvStructuredList/CvStructuredListHeading.vue +11 -0
  21. package/src/components/CvStructuredList/CvStructuredListItem.vue +47 -0
  22. package/src/components/CvStructuredList/CvStructuredListItemSelectable.vue +56 -0
  23. package/src/components/CvStructuredList/CvStructuredListItemStandard.vue +11 -0
  24. package/src/components/CvStructuredList/__tests__/__snapshots__/CvStructuredList.spec.js.snap +73 -0
  25. package/src/components/CvStructuredList/__tests__/__snapshots__/CvStructuredListData.spec.js.snap +5 -0
  26. package/src/components/CvStructuredList/__tests__/__snapshots__/CvStructuredListHeading.spec.js.snap +9 -0
  27. package/src/components/CvStructuredList/__tests__/__snapshots__/CvStructuredListItem.spec.js.snap +7 -0
  28. package/src/components/CvStructuredList/index.js +12 -0
  29. package/src/components/CvTabs/CvTabs.stories.mdx +84 -3
  30. package/src/components/CvTabs/CvTabs.vue +3 -1
  31. package/src/components/CvTabs/__tests__/__snapshots__/CvTabs.spec.js.snap +24 -0
  32. package/src/components/CvTag/CvTag.stories.js +2 -1
  33. package/src/components/CvTag/CvTag.vue +10 -5
  34. package/src/components/CvTag/CvTagSkeleton.stories.js +39 -0
  35. package/src/components/CvTag/CvTagSkeleton.vue +20 -0
  36. package/src/components/CvTag/index.js +2 -1
  37. package/src/use/useRadio.js +0 -1
@@ -0,0 +1,141 @@
1
+ import { action } from '@storybook/addon-actions';
2
+ import { ref } from 'vue';
3
+ import {
4
+ sbCompPrefix,
5
+ storyParametersObject,
6
+ } from '../../global/storybook-utils';
7
+ import {
8
+ CvStructuredList,
9
+ CvStructuredListHeading,
10
+ CvStructuredListData,
11
+ CvStructuredListItem,
12
+ } from '.';
13
+
14
+ export default {
15
+ title: `${sbCompPrefix}/CvStructuredList`,
16
+ component: CvStructuredList,
17
+ argTypes: {
18
+ selectable: {
19
+ type: 'boolean',
20
+ table: {
21
+ type: { summary: 'boolean' },
22
+ category: 'props',
23
+ },
24
+ description:
25
+ 'Makes list items selectable (prop on cv-structured-list component)',
26
+ },
27
+ condensed: {
28
+ type: 'boolean',
29
+ table: {
30
+ type: { summary: 'boolean' },
31
+ category: 'props',
32
+ },
33
+ description:
34
+ 'Condense spacing of the structured list (prop on cv-structured-list component)',
35
+ },
36
+ noWrap: {
37
+ type: 'boolean',
38
+ table: {
39
+ type: { summary: 'boolean' },
40
+ category: 'props',
41
+ },
42
+ description:
43
+ 'Prevent text wrapping in list data (prop on cv-structured-list-data component)',
44
+ },
45
+ },
46
+ };
47
+
48
+ const DefaultListItems = [
49
+ {
50
+ id: 'item-1',
51
+ data: [
52
+ 'Item_1',
53
+ 'Item_1',
54
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque vulputate nisl a porttitor interdum.',
55
+ ],
56
+ },
57
+ {
58
+ id: 'item-2',
59
+ data: [
60
+ 'Item_2',
61
+ 'Item_2',
62
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque vulputate nisl a porttitor interdum.',
63
+ ],
64
+ },
65
+ ];
66
+
67
+ const template = `
68
+ <div>
69
+ <cv-structured-list v-bind="args">
70
+ <template v-slot:headings>
71
+ <cv-structured-list-heading>
72
+ Heading 1
73
+ </cv-structured-list-heading>
74
+ <cv-structured-list-heading>
75
+ Heading 2
76
+ </cv-structured-list-heading>
77
+ <cv-structured-list-heading>
78
+ Heading 3
79
+ </cv-structured-list-heading>
80
+ </template>
81
+
82
+ <template v-slot:items>
83
+ <cv-structured-list-item v-for="({id, data}, index) in DefaultListItems" :key="index" name="group-1" :value="id" v-model="listValue" @change="onChange">
84
+ <cv-structured-list-data v-for="(itemData, dataIndex) in data" :key="dataIndex" :no-wrap="args.noWrap">{{ itemData }}</cv-structured-list-data>
85
+ </cv-structured-list-item>
86
+ </template>
87
+ </cv-structured-list>
88
+
89
+ <div style="margin-top:1rem; background-color: #888888; padding:1rem" v-if="args.withVModel">
90
+ <div style="font-size: 150%">Sample interaction</div>
91
+ <template
92
+ v-for="({id}, vmodelIndex) in DefaultListItems"
93
+ :key="vmodelIndex"
94
+ >
95
+ <input name="listValue" :id="id" type="radio" @change="(ev) => {listValue = ev.target.id}" :checked="id === listValue" />
96
+ <label :for="id" style="margin-right: 16px;">{{id}}:</label>
97
+ </template>
98
+
99
+ <div style="margin-top: 16px;">Checked: <span style="font-weight: bold;">{{ listValue }}</span></div>
100
+ </div>
101
+ </div>
102
+ `;
103
+
104
+ const Template = args => {
105
+ return {
106
+ components: {
107
+ CvStructuredList,
108
+ CvStructuredListHeading,
109
+ CvStructuredListData,
110
+ CvStructuredListItem,
111
+ },
112
+ setup: () => ({
113
+ args,
114
+ listValue: ref(DefaultListItems[0].id),
115
+ DefaultListItems,
116
+ onChange: action('change'),
117
+ }),
118
+ template,
119
+ };
120
+ };
121
+
122
+ export const Default = Template.bind({});
123
+ Default.args = {
124
+ withVModel: false,
125
+ };
126
+ Default.parameters = storyParametersObject(
127
+ Default.parameters,
128
+ template,
129
+ Default.args
130
+ );
131
+
132
+ export const VModel = Template.bind({});
133
+ VModel.args = {
134
+ selectable: true,
135
+ withVModel: true,
136
+ };
137
+ VModel.parameters = storyParametersObject(
138
+ VModel.parameters,
139
+ template,
140
+ VModel.args
141
+ );
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <div
3
+ :class="[
4
+ `${carbonPrefix}--structured-list`,
5
+ {
6
+ [`${carbonPrefix}--structured-list--selection`]: selectable,
7
+ [`${carbonPrefix}--structured-list--condensed`]: condensed,
8
+ },
9
+ ]"
10
+ :data-structured-list="selectable"
11
+ >
12
+ <div :class="`${carbonPrefix}--structured-list-thead`">
13
+ <div
14
+ :class="`${carbonPrefix}--structured-list-row ${carbonPrefix}--structured-list-row--header-row`"
15
+ >
16
+ <slot name="headings"></slot>
17
+ <div
18
+ v-if="selectable"
19
+ :class="`${carbonPrefix}--structured-list-th`"
20
+ ></div>
21
+ </div>
22
+ </div>
23
+ <div :class="`${carbonPrefix}--structured-list-tbody`">
24
+ <slot name="items"></slot>
25
+ </div>
26
+ </div>
27
+ </template>
28
+
29
+ <script setup>
30
+ import { defineEmits, provide } from 'vue';
31
+ import { carbonPrefix } from '../../global/settings';
32
+
33
+ const props = defineProps({
34
+ selectable: Boolean,
35
+ condensed: Boolean,
36
+ });
37
+
38
+ const emit = defineEmits(['change']);
39
+
40
+ provide('change', val => {
41
+ emit('change', val);
42
+ });
43
+ provide('selectable', props.selectable);
44
+ </script>
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <div
3
+ :class="[
4
+ `cv-structured-list-data ${carbonPrefix}--structured-list-td`,
5
+ {
6
+ [`${carbonPrefix}--structured-list-content--nowrap`]: noWrap,
7
+ },
8
+ ]"
9
+ >
10
+ <slot></slot>
11
+ </div>
12
+ </template>
13
+
14
+ <script setup>
15
+ import { carbonPrefix } from '../../global/settings';
16
+ defineProps({
17
+ noWrap: Boolean,
18
+ });
19
+ </script>
@@ -0,0 +1,11 @@
1
+ <template>
2
+ <div
3
+ :class="`cv-structured-list-heading ${carbonPrefix}--structured-list-th`"
4
+ >
5
+ <slot></slot>
6
+ </div>
7
+ </template>
8
+
9
+ <script setup>
10
+ import { carbonPrefix } from '../../global/settings';
11
+ </script>
@@ -0,0 +1,47 @@
1
+ <template>
2
+ <component
3
+ :is="tagType"
4
+ v-bind="$attrs"
5
+ class="cv-structured-list-item"
6
+ :value="value"
7
+ :modelValue="modelValue"
8
+ >
9
+ <slot></slot>
10
+ </component>
11
+ </template>
12
+
13
+ <script setup>
14
+ import { computed, inject, provide } from 'vue';
15
+ import CvStructuredListItemStandard from './CvStructuredListItemStandard.vue';
16
+ import CvStructuredListItemSelectable from './CvStructuredListItemSelectable.vue';
17
+
18
+ defineOptions({
19
+ inheritAttrs: false,
20
+ });
21
+
22
+ defineProps({
23
+ modelValue: {
24
+ type: String,
25
+ default: undefined,
26
+ },
27
+ value: {
28
+ type: String,
29
+ default: undefined,
30
+ },
31
+ });
32
+
33
+ const selectable = inject('selectable');
34
+ const change = inject('change');
35
+ const emit = defineEmits(['change']);
36
+
37
+ provide('onRadioItemChange', clickedItemCvId => {
38
+ emit('change', clickedItemCvId);
39
+ change(clickedItemCvId); //emit to parent
40
+ });
41
+
42
+ const tagType = computed(() => {
43
+ return selectable
44
+ ? CvStructuredListItemSelectable
45
+ : CvStructuredListItemStandard;
46
+ });
47
+ </script>
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <label
3
+ :for="cvId"
4
+ :aria-label="label"
5
+ :class="[
6
+ `cv-structured-list-item--selectable ${carbonPrefix}--structured-list-row`,
7
+ { ' ${carbonPrefix}--structured-list-row--selected': isChecked },
8
+ ]"
9
+ tabindex="0"
10
+ >
11
+ <slot></slot>
12
+ <input
13
+ v-bind="$attrs"
14
+ tabindex="-1"
15
+ :id="cvId"
16
+ :class="`${carbonPrefix}--structured-list-input`"
17
+ :checked="isChecked"
18
+ :value="value"
19
+ type="radio"
20
+ @change="onChange"
21
+ />
22
+ <div :class="`${carbonPrefix}--structured-list-td`">
23
+ <CheckmarkFilled16 :class="`${carbonPrefix}--structured-list-svg`" />
24
+ </div>
25
+ </label>
26
+ </template>
27
+
28
+ <script setup>
29
+ import { carbonPrefix } from '../../global/settings';
30
+ import { useCvId, propsCvId, useRadio } from '../../use';
31
+ import CheckmarkFilled16 from '@carbon/icons-vue/es/checkmark--filled/16';
32
+
33
+ defineOptions({
34
+ inheritAttrs: false,
35
+ });
36
+
37
+ const props = defineProps({
38
+ label: {
39
+ type: String,
40
+ default: undefined,
41
+ },
42
+ modelValue: {
43
+ type: String,
44
+ default: undefined,
45
+ },
46
+ value: {
47
+ type: String,
48
+ default: undefined,
49
+ },
50
+ ...propsCvId,
51
+ });
52
+
53
+ const cvId = useCvId(props);
54
+ const emit = defineEmits(['update:modelValue', 'change']);
55
+ const { isChecked, onChange } = useRadio(props, emit);
56
+ </script>
@@ -0,0 +1,11 @@
1
+ <template>
2
+ <div
3
+ :class="`cv-structured-list-item--standard ${carbonPrefix}--structured-list-row`"
4
+ >
5
+ <slot></slot>
6
+ </div>
7
+ </template>
8
+
9
+ <script setup>
10
+ import { carbonPrefix } from '../../global/settings';
11
+ </script>
@@ -0,0 +1,73 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`CvStructuredList should render \`headings\` slot correctly 1`] = `
4
+ <div class="bx--structured-list bx--structured-list--selection bx--structured-list--condensed" data-structured-list="true" defaultid="test-1">
5
+ <div class="bx--structured-list-thead">
6
+ <div class="bx--structured-list-row bx--structured-list-row--header-row">
7
+ <div class="headings-slot-test">Headings slot test</div>
8
+ <div class="bx--structured-list-th"></div>
9
+ </div>
10
+ </div>
11
+ <div class="bx--structured-list-tbody"></div>
12
+ </div>
13
+ `;
14
+
15
+ exports[`CvStructuredList should render \`items\` slot correctly 1`] = `
16
+ <div class="bx--structured-list bx--structured-list--selection bx--structured-list--condensed" data-structured-list="true" defaultid="test-1">
17
+ <div class="bx--structured-list-thead">
18
+ <div class="bx--structured-list-row bx--structured-list-row--header-row">
19
+ <div class="bx--structured-list-th"></div>
20
+ </div>
21
+ </div>
22
+ <div class="bx--structured-list-tbody">
23
+ <ul class="items-slot-test">
24
+ <li>Test 1.1</li>
25
+ <li>Test 1.2</li>
26
+ </ul>
27
+ </div>
28
+ </div>
29
+ `;
30
+
31
+ exports[`CvStructuredList should render correctly when condensed 1`] = `
32
+ <div class="bx--structured-list bx--structured-list--condensed" data-structured-list="false" defaultid="test-1">
33
+ <div class="bx--structured-list-thead">
34
+ <div class="bx--structured-list-row bx--structured-list-row--header-row">
35
+ <!--v-if-->
36
+ </div>
37
+ </div>
38
+ <div class="bx--structured-list-tbody"></div>
39
+ </div>
40
+ `;
41
+
42
+ exports[`CvStructuredList should render correctly when not selectable and not condensed 1`] = `
43
+ <div class="bx--structured-list" data-structured-list="false" defaultid="test-1">
44
+ <div class="bx--structured-list-thead">
45
+ <div class="bx--structured-list-row bx--structured-list-row--header-row">
46
+ <!--v-if-->
47
+ </div>
48
+ </div>
49
+ <div class="bx--structured-list-tbody"></div>
50
+ </div>
51
+ `;
52
+
53
+ exports[`CvStructuredList should render correctly when selectable 1`] = `
54
+ <div class="bx--structured-list bx--structured-list--selection" data-structured-list="true" defaultid="test-1">
55
+ <div class="bx--structured-list-thead">
56
+ <div class="bx--structured-list-row bx--structured-list-row--header-row">
57
+ <div class="bx--structured-list-th"></div>
58
+ </div>
59
+ </div>
60
+ <div class="bx--structured-list-tbody"></div>
61
+ </div>
62
+ `;
63
+
64
+ exports[`CvStructuredList should render correctly when selectable and condensed 1`] = `
65
+ <div class="bx--structured-list bx--structured-list--selection bx--structured-list--condensed" data-structured-list="true" defaultid="test-1">
66
+ <div class="bx--structured-list-thead">
67
+ <div class="bx--structured-list-row bx--structured-list-row--header-row">
68
+ <div class="bx--structured-list-th"></div>
69
+ </div>
70
+ </div>
71
+ <div class="bx--structured-list-tbody"></div>
72
+ </div>
73
+ `;
@@ -0,0 +1,5 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`CvStructuredListData should render correctly when not wrapping text 1`] = `<div class="cv-structured-list-data bx--structured-list-td bx--structured-list-content--nowrap" id="test-3"></div>`;
4
+
5
+ exports[`CvStructuredListData should render correctly when wrapping text 1`] = `<div class="cv-structured-list-data bx--structured-list-td" id="test-3"></div>`;
@@ -0,0 +1,9 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`CvStructuredListHeading should render correctly 1`] = `<div class="cv-structured-list-heading bx--structured-list-th"></div>`;
4
+
5
+ exports[`CvStructuredListHeading should render with slot correctly 1`] = `
6
+ <div class="cv-structured-list-heading bx--structured-list-th">
7
+ <div class="headings-slot-default-test">Headings slot default test</div>
8
+ </div>
9
+ `;
@@ -0,0 +1,7 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`CvStructuredListItem should render correctly when \`value\` is default 1`] = `<cv-structured-list-item-standard-stub id="test-2" class="cv-structured-list-item" modelvalue="test"></cv-structured-list-item-standard-stub>`;
4
+
5
+ exports[`CvStructuredListItem should render correctly when \`value\` is set 1`] = `<cv-structured-list-item-standard-stub id="test-2" class="cv-structured-list-item" modelvalue="test" value="strictured list item value test"></cv-structured-list-item-standard-stub>`;
6
+
7
+ exports[`CvStructuredListItem should render correctly when slot is specified 1`] = `<cv-structured-list-item-standard-stub id="test-2" class="cv-structured-list-item" modelvalue="test"></cv-structured-list-item-standard-stub>`;
@@ -0,0 +1,12 @@
1
+ import CvStructuredListData from './CvStructuredListData.vue';
2
+ import CvStructuredListHeading from './CvStructuredListHeading.vue';
3
+ import CvStructuredListItem from './CvStructuredListItem.vue';
4
+ import CvStructuredList from './CvStructuredList.vue';
5
+ export {
6
+ CvStructuredList,
7
+ CvStructuredListItem,
8
+ CvStructuredListHeading,
9
+ CvStructuredListData,
10
+ };
11
+
12
+ export default CvStructuredList;
@@ -5,6 +5,7 @@ import CvTab from './CvTab.vue';
5
5
  import CvTabsSkeleton from './CvTabsSkeleton.vue';
6
6
  import SbContainer from './_SbContainer.vue';
7
7
  import { action } from '@storybook/addon-actions';
8
+ import { IbmSecurity20 as SampleIcon } from '@carbon/icons-vue';
8
9
 
9
10
  <Meta
10
11
  title={`${sbCompPrefix}/CvTabs`}
@@ -23,6 +24,7 @@ export const Template = args => ({
23
24
  CvTabs,
24
25
  CvTab,
25
26
  CvTabsSkeleton,
27
+ SampleIcon,
26
28
  },
27
29
  // The story's `args` need to be mapped into the template through the `setup()` method
28
30
  setup() {
@@ -31,6 +33,7 @@ export const Template = args => ({
31
33
  noDefaultToFirst: args.noDefaultToFirst,
32
34
  selectedId: args.selectedId,
33
35
  disabledIds: args.disabledIds,
36
+ slottedTabs: args.slottedTabs,
34
37
  onTabSelected: action('tab-selected'),
35
38
  onTabSelectedId: action('tab-selected-id'),
36
39
  };
@@ -46,20 +49,47 @@ const defaultTemplate = `
46
49
  @tab-selected-id="onTabSelectedId"
47
50
  aria-label="navigation tab label">
48
51
  <cv-tab id="tab-1" label="House" :selected="selectedId === 'tab-1'" :disabled="disabledIds.includes('tab-1')">
49
- <p>
52
+ <p v-if="slottedTabs">
53
+ To customise tab look, in CvTabs component use scoped slot named with tab's id.
54
+ Example: current tab has id "<strong>tab-1</strong>", so the code for customising tab looks like:
55
+ <div style="background-color: lightgrey; padding: 0.5rem;">
56
+ &lt;template #tab-1="tab"&gt;
57
+ {&nbsp;{ tab.label }&nbsp;} &lt;IbmSecurity20 /&gt;
58
+ &lt;template&gt;
59
+ </div>
60
+ </p>
61
+ <p v-else>
50
62
  29 Arlington Avenue is a house in Islington, London. Douglas Adams shared the house for a time
51
63
  with Jonny Brock and Clare Gorst. It is mentioned in the dedication of The Hitchhiker's Guide to
52
64
  the Galaxy, which is dedicated to the "Arlingtonians for tea, sympathy, and a sofa."
53
65
  </p>
54
66
  </cv-tab>
55
67
  <cv-tab id="tab-2" label="Bar" :selected="selectedId === 'tab-2'" :disabled="disabledIds.includes('tab-2')">
56
- <p>
68
+ <p v-if="slottedTabs">
69
+ To customise tab look, in CvTabs component use scoped slot named with tab's id.
70
+ Example: current tab has id "<strong>tab-2</strong>", so the code for customising tab looks like:
71
+ <div style="background-color: lightgrey; padding: 0.5rem;">
72
+ &lt;template #tab-2="tab"&gt;
73
+ {&nbsp;{ tab.label }&nbsp;} &lt;strong style="color: red;"&gt;(*)&lt;/strong&gt;
74
+ &lt;template&gt;
75
+ </div>
76
+ </p>
77
+ <p v-else>
57
78
  The Old Pink Dog Bar was the bar in Han Dold City that Ford Prefect was in when he discovered
58
79
  that his Guide had his full entry on Earth on it.
59
80
  </p>
60
81
  </cv-tab>
61
82
  <cv-tab id="tab-3" label="Reach" :selected="selectedId === 'tab-3'" :disabled="disabledIds.includes('tab-3')">
62
- <p>
83
+ <p v-if="slottedTabs">
84
+ To customise tab look, in CvTabs component use scoped slot named with tab's id.
85
+ Example: current tab has id "<strong>tab-3</strong>", so the code for customising tab looks like:
86
+ <div style="background-color: lightgrey; padding: 0.5rem;">
87
+ &lt;template #tab-3="tab"&gt;
88
+ {&nbsp;{ tab.label }&nbsp;} &lt;strong style="color: orange;"&gt;(!)&lt;/strong&gt;
89
+ &lt;template&gt;
90
+ </div>
91
+ </p>
92
+ <p v-else>
63
93
  The Third Reach of the Unknown is what might be loosely described as a "place" which exists only
64
94
  under high improbability conditions and was created on the starship Heart of Gold due to the
65
95
  Infinite Improbability Drive. During Arthur Dent and Ford Prefect's first trip on board the Heart
@@ -81,6 +111,15 @@ const defaultTemplate = `
81
111
  <a target='_blank' href='https://hitchhikers.fandom.com/wiki/Main_Page'>credits</a>
82
112
  </p>
83
113
  </cv-tab>
114
+ <template v-if="slottedTabs" #tab-1="tab">
115
+ House <SampleIcon/>
116
+ </template>
117
+ <template v-if="slottedTabs" #tab-2="tab">
118
+ {{tab.label}} <strong style="color: red;">(*)</strong>
119
+ </template>
120
+ <template v-if="slottedTabs" #tab-3="tab">
121
+ {{tab.label}} <strong style="color: orange;">(!)</strong>
122
+ </template>
84
123
  </cv-tabs>
85
124
  `;
86
125
  const skeletonTemplate = `<cv-tabs-skeleton></cv-tabs-skeleton>`;
@@ -173,3 +212,45 @@ screens, and so I suggest using a different component for mobile cases.
173
212
  {Template.bind({})}
174
213
  </Story>
175
214
  </Canvas>
215
+
216
+ # Tabs slotted
217
+
218
+ <Canvas>
219
+ <Story
220
+ name="tabsSlot"
221
+ parameters={{
222
+ controls: {
223
+ exclude: [
224
+ 'default',
225
+ 'template',
226
+ 'leftOverflowIconButtonProps',
227
+ 'rightOverflowIconButtonProps',
228
+ 'scrollIntoView',
229
+ 'tab-selected',
230
+ 'tab-selected-id',
231
+ 'slottedTabs',
232
+ ],
233
+ },
234
+ docs: { source: { code: defaultTemplate } },
235
+ }}
236
+ args={{
237
+ template: defaultTemplate,
238
+ selectedId: '',
239
+ disabledIds: [],
240
+ slottedTabs: true
241
+ }}
242
+ argTypes={{
243
+ selectedId: {
244
+ control: 'select',
245
+ default: '',
246
+ options: ['', 'tab-1', 'tab-2', 'tab-3', 'tab-4', 'tab-5'],
247
+ },
248
+ disabledIds: {
249
+ control: 'multi-select',
250
+ options: ['tab-1', 'tab-2', 'tab-3', 'tab-4', 'tab-5'],
251
+ },
252
+ }}
253
+ >
254
+ {Template.bind({})}
255
+ </Story>
256
+ </Canvas>
@@ -76,7 +76,9 @@
76
76
  :tabindex="selectedId === tab.uid ? 0 : -1"
77
77
  type="button"
78
78
  >
79
- {{ tab.label }}
79
+ <slot :name="tab.uid" v-bind="tab">
80
+ {{ tab.label }}
81
+ </slot>
80
82
  </button>
81
83
  </li>
82
84
  </ul>
@@ -0,0 +1,24 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`CvTabs CvTabs - test slotted tab buttons to match snapshot 1`] = `
4
+ <div class="cv-tabs ABC-class-123" style="width: 100%;" aria-label="ABC-aria-label-123">
5
+ <div data-tabs="" class="cv-tab bx--tabs--scrollable ABC-class-123" role="navigation" aria-label="ABC-aria-label-123"><button aria-hidden="true" aria-label="scroll left" class="bx--tab--overflow-nav-button--hidden" tabindex="-1" type="button"><svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true">
6
+ <path d="M5 8L10 3 10.7 3.7 6.4 8 10.7 12.3 10 13z"></path>
7
+ </svg></button>
8
+ <!--v-if-->
9
+ <ul class="bx--tabs--scrollable__nav" role="tablist">
10
+ <li class="cv-tabs-button bx--tabs--scrollable__nav-item bx--tabs__nav-item--selected bx--tabs--scrollable__nav-item--selected" role="presentation"><button class="bx--tabs--scrollable__nav-link" role="tab" aria-controls="tab-1" aria-disabled="false" aria-selected="true" id="tab-1-link" tabindex="0" type="button">Hello <strong style="color: red;">(*)</strong></button></li>
11
+ <li class="cv-tabs-button bx--tabs--scrollable__nav-item" role="presentation"><button class="bx--tabs--scrollable__nav-link" role="tab" aria-controls="tab-2" aria-disabled="false" aria-selected="false" id="tab-2-link" tabindex="-1" type="button">Origin<strong style="color: orange;">(!)</strong></button></li>
12
+ <li class="cv-tabs-button bx--tabs--scrollable__nav-item" role="presentation"><button class="bx--tabs--scrollable__nav-link" role="tab" aria-controls="tab-3" aria-disabled="false" aria-selected="false" id="tab-3-link" tabindex="-1" type="button">Tab 3 label</button></li>
13
+ </ul>
14
+ <!--v-if--><button aria-hidden="true" aria-label="scroll right" class="bx--tab--overflow-nav-button--hidden" tabindex="-1" type="button"><svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true">
15
+ <path d="M11 8L6 13 5.3 12.3 9.6 8 5.3 3.7 6 3z"></path>
16
+ </svg></button>
17
+ </div>
18
+ <div class="cv-tabs__panels">
19
+ <div class="cv-tab bx--tab-content" id="tab-1" role="tabpanel" aria-labelledby="tab-1-link" aria-hidden="false">Tab 1 content</div>
20
+ <div class="cv-tab bx--tab-content" id="tab-2" role="tabpanel" aria-labelledby="tab-2-link" aria-hidden="true" hidden="">Tab 2 content</div>
21
+ <div class="cv-tab bx--tab-content" id="tab-3" role="tabpanel" aria-labelledby="tab-3-link" aria-hidden="true" hidden="">Tab 3 content</div>
22
+ </div>
23
+ </div>
24
+ `;
@@ -14,7 +14,7 @@ export default {
14
14
  },
15
15
  };
16
16
 
17
- const template = `<CvTag @remove="onRemove" v-bind="args" />`;
17
+ const template = `<cv-tag @remove="onRemove" v-bind="args" />`;
18
18
  const Template = (args, { argTypes }) => {
19
19
  return {
20
20
  props: Object.keys(argTypes),
@@ -56,6 +56,7 @@ Filter.parameters = storyParametersObject(
56
56
  export const Skeleton = Template.bind({});
57
57
  Skeleton.args = {
58
58
  skeleton: true,
59
+ label: '',
59
60
  };
60
61
  Skeleton.parameters = storyParametersObject(
61
62
  Skeleton.parameters,