@carbon/vue 3.0.20 → 3.0.22
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/dist/carbon-vue-3.common.js +4420 -4885
- package/dist/carbon-vue-3.common.js.map +1 -1
- package/dist/carbon-vue-3.umd.js +4422 -4887
- package/dist/carbon-vue-3.umd.js.map +1 -1
- package/dist/carbon-vue-3.umd.min.js +4 -4
- package/dist/carbon-vue-3.umd.min.js.map +1 -1
- package/dist/web-types.json +14 -1
- package/package.json +4 -4
- package/src/components/CvAspectRatio/CvAspectRatio.stories.js +2 -5
- package/src/components/CvBreadcrumb/CvBreadcrumb.stories.js +2 -5
- package/src/components/CvButton/CvButton.stories.js +1 -3
- package/src/components/CvButton/CvButtonSet.stories.js +2 -6
- package/src/components/CvButton/CvButtonSkeleton.stories.js +1 -3
- package/src/components/CvButton/CvIconButton.stories.js +1 -3
- package/src/components/CvCheckbox/CvCheckbox.stories.js +5 -4
- package/src/components/CvCodeSnippet/CvCodeSnippet.stories.js +1 -2
- package/src/components/CvComboBox/CvComboBox.stories.js +2 -5
- package/src/components/CvCopyButton/CvCopyButton.stories.js +2 -5
- package/src/components/CvDataTable/CvDataTable.stories.mdx +82 -12
- package/src/components/CvDataTable/CvDataTable.vue +71 -96
- package/src/components/CvDataTable/CvDataTableHeading.vue +25 -45
- package/src/components/CvDataTable/CvDataTableRow.vue +50 -49
- package/src/components/CvDataTable/_CvDataTableRowInner.vue +9 -18
- package/src/components/CvDatePicker/CvDatePicker.stories.js +101 -27
- package/src/components/CvDatePicker/CvDatePicker.vue +4 -2
- package/src/components/CvLink/CvLink.stories.js +1 -2
- package/src/components/CvList/CvList.stories.js +2 -5
- package/src/components/CvLoading/CvLoading.stories.js +2 -5
- package/src/components/CvMultiSelect/CvMultiSelect.vue +4 -1
- package/src/components/CvNotification/CvInlineNotification.stories.js +2 -2
- package/src/components/CvNotification/CvToastNotification.stories.js +2 -2
- package/src/components/CvNumberInput/CvNumberInput.stories.js +2 -6
- package/src/components/CvNumberInput/CvNumberInputSkeleton.stories.js +2 -6
- package/src/components/CvRadioButton/CvRadioButton.stories.js +2 -5
- package/src/components/CvSkeletonText/CvSkeletonText.stories.js +2 -5
- package/src/components/CvSlider/CvSlider.stories.js +2 -6
- package/src/components/CvSlider/CvSliderSkeleton.stories.js +2 -6
- package/src/components/CvStructuredList/CvStructuredList.stories.js +2 -5
- package/src/components/CvTag/CvTag.stories.js +2 -5
- package/src/components/CvTag/CvTagSkeleton.stories.js +2 -5
- package/src/components/CvTextArea/CvTextArea.stories.js +2 -6
- package/src/components/CvTextArea/CvTextAreaSkeleton.stories.js +2 -6
- package/src/components/CvTextInput/CvTextInput.stories.js +2 -5
- package/src/components/CvToggle/CvToggle.stories.js +2 -5
- package/src/components/CvTooltip/CvDefinitionTooltip.stories.js +2 -6
- package/src/components/CvTooltip/CvInteractiveTooltip.stories.js +2 -6
- package/src/components/CvTooltip/CvTooltip.stories.js +2 -6
- package/src/use/overflow.js +2 -2
- package/src/components/CvDataTable/cvDataTableStore.js +0 -314
package/dist/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"framework": "vue",
|
|
3
3
|
"name": "@carbon/vue",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.21",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -1342,8 +1342,18 @@
|
|
|
1342
1342
|
"name": "CvDataTableRow",
|
|
1343
1343
|
"description": "",
|
|
1344
1344
|
"attributes": [
|
|
1345
|
+
{
|
|
1346
|
+
"name": "value",
|
|
1347
|
+
"description": "The value associated with the input (required for tables with batch actions)",
|
|
1348
|
+
"value": {
|
|
1349
|
+
"kind": "expression",
|
|
1350
|
+
"type": "string"
|
|
1351
|
+
},
|
|
1352
|
+
"default": "undefined"
|
|
1353
|
+
},
|
|
1345
1354
|
{
|
|
1346
1355
|
"name": "expanded",
|
|
1356
|
+
"description": "This row will be initially expanded",
|
|
1347
1357
|
"value": {
|
|
1348
1358
|
"kind": "expression",
|
|
1349
1359
|
"type": "boolean"
|
|
@@ -1504,6 +1514,9 @@
|
|
|
1504
1514
|
"events": [
|
|
1505
1515
|
{
|
|
1506
1516
|
"name": "update:modelValue"
|
|
1517
|
+
},
|
|
1518
|
+
{
|
|
1519
|
+
"name": "dateChange"
|
|
1507
1520
|
}
|
|
1508
1521
|
],
|
|
1509
1522
|
"slots": [
|
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.
|
|
4
|
+
"version": "3.0.22",
|
|
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",
|
|
@@ -61,17 +61,17 @@
|
|
|
61
61
|
"copy-webpack-plugin": "^10.2.4",
|
|
62
62
|
"css-loader": "^6.7.2",
|
|
63
63
|
"eslint": "^8.28.0",
|
|
64
|
-
"eslint-plugin-prettier": "^
|
|
64
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
65
65
|
"eslint-plugin-vue": "^8.7.1",
|
|
66
66
|
"husky": "^7.0.4",
|
|
67
67
|
"jest": "^27.5.1",
|
|
68
68
|
"lerna": "^6.5.1",
|
|
69
69
|
"lint-staged": "^12.5.0",
|
|
70
70
|
"postcss": "^8.4.19",
|
|
71
|
-
"postcss-loader": "^
|
|
71
|
+
"postcss-loader": "^8.1.1",
|
|
72
72
|
"prettier": "^2.8.0",
|
|
73
73
|
"sass": "^1.56.1",
|
|
74
|
-
"sass-loader": "^
|
|
74
|
+
"sass-loader": "^16.0.2",
|
|
75
75
|
"storybook": "^6.5.13",
|
|
76
76
|
"style-loader": "^3.3.1",
|
|
77
77
|
"stylelint": "^14.15.0",
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { h } from 'vue';
|
|
2
|
-
import {
|
|
3
|
-
sbCompPrefix,
|
|
4
|
-
storyParametersObject,
|
|
5
|
-
} from '../../global/storybook-utils';
|
|
2
|
+
import { storyParametersObject } from '../../global/storybook-utils';
|
|
6
3
|
|
|
7
4
|
import { CvAspectRatio, CvAspectRatioConsts } from '.';
|
|
8
5
|
|
|
9
6
|
import './CvAspectRatio.stories.scss';
|
|
10
7
|
|
|
11
8
|
export default {
|
|
12
|
-
title:
|
|
9
|
+
title: 'Component/CvAspectRatio',
|
|
13
10
|
component: CvAspectRatio,
|
|
14
11
|
decorators: [
|
|
15
12
|
story => h('div', { class: 'aspect-ratio-story' }, story().render()),
|
|
@@ -5,13 +5,10 @@ import {
|
|
|
5
5
|
CvBreadcrumbSkeletonItem,
|
|
6
6
|
} from '.';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
sbCompPrefix,
|
|
10
|
-
storyParametersObject,
|
|
11
|
-
} from '../../global/storybook-utils';
|
|
8
|
+
import { storyParametersObject } from '../../global/storybook-utils';
|
|
12
9
|
|
|
13
10
|
export default {
|
|
14
|
-
title:
|
|
11
|
+
title: 'Component/CvBreadcrumb',
|
|
15
12
|
component: CvBreadcrumb,
|
|
16
13
|
argTypes: {
|
|
17
14
|
ariaLabel: {
|
|
@@ -2,12 +2,10 @@ import { action } from '@storybook/addon-actions';
|
|
|
2
2
|
import { CvButton } from './';
|
|
3
3
|
import { buttonKinds, buttonSizes } from './consts';
|
|
4
4
|
import {
|
|
5
|
-
sbCompPrefix,
|
|
6
5
|
splitSlotArgs,
|
|
7
6
|
storybookControlsFromProps,
|
|
8
7
|
storyParametersObject,
|
|
9
8
|
} from '../../global/storybook-utils';
|
|
10
|
-
import { sbBtnPrefix } from './sbBtnPrefix';
|
|
11
9
|
import { props as commonCvButtonProps } from './CvButtonCommon';
|
|
12
10
|
import {
|
|
13
11
|
Bee20,
|
|
@@ -28,7 +26,7 @@ const icons = {
|
|
|
28
26
|
};
|
|
29
27
|
|
|
30
28
|
export default {
|
|
31
|
-
title:
|
|
29
|
+
title: 'Component/CvButton',
|
|
32
30
|
component: CvButton,
|
|
33
31
|
argTypes: {
|
|
34
32
|
...storybookControlsFromProps(commonCvButtonProps),
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { CvButtonSet, CvButton } from './';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
sbCompPrefix,
|
|
5
|
-
storyParametersObject,
|
|
6
|
-
} from '../../global/storybook-utils';
|
|
7
|
-
import { sbBtnPrefix } from './sbBtnPrefix';
|
|
3
|
+
import { storyParametersObject } from '../../global/storybook-utils';
|
|
8
4
|
|
|
9
5
|
export default {
|
|
10
|
-
title:
|
|
6
|
+
title: 'Component/CvButtonSet',
|
|
11
7
|
component: CvButtonSet,
|
|
12
8
|
};
|
|
13
9
|
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { CvButtonSkeleton } from '.';
|
|
2
2
|
import { buttonSizes } from './consts.js';
|
|
3
3
|
import {
|
|
4
|
-
sbCompPrefix,
|
|
5
4
|
storybookControlsFromProps,
|
|
6
5
|
storyParametersObject,
|
|
7
6
|
} from '../../global/storybook-utils';
|
|
8
|
-
import { sbBtnPrefix } from './sbBtnPrefix';
|
|
9
7
|
|
|
10
8
|
import { props as commonCvButtonProps } from './CvButtonCommon';
|
|
11
9
|
|
|
12
10
|
export default {
|
|
13
|
-
title:
|
|
11
|
+
title: 'Component/CvButtonSkeleton',
|
|
14
12
|
component: CvButtonSkeleton,
|
|
15
13
|
argTypes: {
|
|
16
14
|
...storybookControlsFromProps({ size: commonCvButtonProps.size }),
|
|
@@ -2,12 +2,10 @@ import { action } from '@storybook/addon-actions';
|
|
|
2
2
|
import { CvIconButton } from './';
|
|
3
3
|
import { buttonKinds, buttonSizes } from './consts.js';
|
|
4
4
|
import {
|
|
5
|
-
sbCompPrefix,
|
|
6
5
|
storybookControlsFromProps,
|
|
7
6
|
storyParametersObject,
|
|
8
7
|
} from '../../global/storybook-utils';
|
|
9
8
|
import { TipAlignments } from '../CvTooltip/consts.js';
|
|
10
|
-
import { sbBtnPrefix } from './sbBtnPrefix';
|
|
11
9
|
|
|
12
10
|
import { props as commonCvButtonProps } from './CvButtonCommon';
|
|
13
11
|
import {
|
|
@@ -29,7 +27,7 @@ const icons = {
|
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
export default {
|
|
32
|
-
title:
|
|
30
|
+
title: 'Component/CvIconButton',
|
|
33
31
|
component: CvIconButton,
|
|
34
32
|
argTypes: {
|
|
35
33
|
...storybookControlsFromProps(commonCvButtonProps),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
sbCompPrefix,
|
|
3
2
|
storybookControlsFromProps,
|
|
4
3
|
storyParametersObject,
|
|
5
4
|
} from '../../global/storybook-utils';
|
|
@@ -10,12 +9,12 @@ import { props as propsCvCheck } from '../../use/cvCheck';
|
|
|
10
9
|
import { ref } from 'vue';
|
|
11
10
|
|
|
12
11
|
export default {
|
|
13
|
-
title:
|
|
12
|
+
title: 'Component/CvCheckbox',
|
|
14
13
|
component: CvCheckbox,
|
|
15
14
|
argTypes: {
|
|
16
15
|
...storybookControlsFromProps(propsCvCheck),
|
|
17
16
|
value: {
|
|
18
|
-
type: 'string',
|
|
17
|
+
type: { raw: 'string', required: true },
|
|
19
18
|
description:
|
|
20
19
|
'The value associated with the input (this is also the value that is sent on submit)',
|
|
21
20
|
table: {
|
|
@@ -68,6 +67,7 @@ const Template = args => {
|
|
|
68
67
|
|
|
69
68
|
export const Default = Template.bind({});
|
|
70
69
|
Default.args = { label: 'checkbox', value: 'check-1' };
|
|
70
|
+
Default.parameters = { controls: { sort: 'requiredFirst' } };
|
|
71
71
|
Default.parameters = storyParametersObject(
|
|
72
72
|
Default.parameters,
|
|
73
73
|
template,
|
|
@@ -81,7 +81,7 @@ const templateVModel = `<div>
|
|
|
81
81
|
</cv-checkbox>
|
|
82
82
|
<div style="margin-top:1rem; background-color: #888888; padding:1rem"><div style="font-size: 150%">Sample interaction</div>
|
|
83
83
|
<label for="checkbox">V-model: Check 1:</label>
|
|
84
|
-
<input id="checkbox" type="checkbox"
|
|
84
|
+
<input id="checkbox" type="checkbox" v-model="modelValue" />
|
|
85
85
|
<div>Checked: <span style="font-weight: bold;">{{modelValue}}</span></div>
|
|
86
86
|
</div>
|
|
87
87
|
</div>
|
|
@@ -103,6 +103,7 @@ vModel.args = {
|
|
|
103
103
|
label: 'checkbox',
|
|
104
104
|
value: 'check-1',
|
|
105
105
|
};
|
|
106
|
+
vModel.parameters = { controls: { sort: 'requiredFirst' } };
|
|
106
107
|
vModel.parameters = storyParametersObject(
|
|
107
108
|
vModel.parameters,
|
|
108
109
|
templateVModel,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { carbonPrefix } from '../../global/settings';
|
|
2
2
|
import {
|
|
3
|
-
sbCompPrefix,
|
|
4
3
|
splitSlotArgs,
|
|
5
4
|
storyParametersObject,
|
|
6
5
|
} from '../../global/storybook-utils';
|
|
@@ -12,7 +11,7 @@ import CvCodeSnippetConsts from './consts';
|
|
|
12
11
|
import './CvCodeSnippet.stories.scss';
|
|
13
12
|
|
|
14
13
|
export default {
|
|
15
|
-
title:
|
|
14
|
+
title: 'Component/CvCodeSnippet',
|
|
16
15
|
component: CvCodeSnippet,
|
|
17
16
|
argTypes: {
|
|
18
17
|
default: { control: { type: 'text' } },
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
sbCompPrefix,
|
|
3
|
-
storyParametersObject,
|
|
4
|
-
} from '../../global/storybook-utils';
|
|
1
|
+
import { storyParametersObject } from '../../global/storybook-utils';
|
|
5
2
|
|
|
6
3
|
import { CvComboBox } from '.';
|
|
7
4
|
import { action } from '@storybook/addon-actions';
|
|
@@ -41,7 +38,7 @@ const initArgs = {
|
|
|
41
38
|
};
|
|
42
39
|
|
|
43
40
|
export default {
|
|
44
|
-
title:
|
|
41
|
+
title: 'Component/CvComboBox',
|
|
45
42
|
component: CvComboBox,
|
|
46
43
|
parameters: {
|
|
47
44
|
a11y: {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import CvCopyButton from '.';
|
|
2
2
|
|
|
3
3
|
import { action } from '@storybook/addon-actions';
|
|
4
|
-
import {
|
|
5
|
-
sbCompPrefix,
|
|
6
|
-
storyParametersObject,
|
|
7
|
-
} from '../../global/storybook-utils';
|
|
4
|
+
import { storyParametersObject } from '../../global/storybook-utils';
|
|
8
5
|
|
|
9
6
|
export default {
|
|
10
|
-
title:
|
|
7
|
+
title: 'Component/CvCopyButton',
|
|
11
8
|
component: CvCopyButton,
|
|
12
9
|
argTypes: {},
|
|
13
10
|
};
|
|
@@ -21,8 +21,10 @@ const testData = ref([
|
|
|
21
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
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
23
|
]);
|
|
24
|
+
const sortOpts = ref({index: "0", order: "none", name: "name"})
|
|
24
25
|
function sortTestData(opts) {
|
|
25
26
|
action('sort')(opts)
|
|
27
|
+
sortOpts.value = opts
|
|
26
28
|
if (opts.order === 'none')
|
|
27
29
|
return testData.value.sort((a, b) => a.index.localeCompare(b.index, 'en', { sensitivity: 'base' }));
|
|
28
30
|
let direction = 1
|
|
@@ -32,6 +34,17 @@ function sortTestData(opts) {
|
|
|
32
34
|
else if (opts.name === 'year')
|
|
33
35
|
return testData.value.sort((a, b) => direction * (a.year - b.year));
|
|
34
36
|
}
|
|
37
|
+
// duplicate the test data
|
|
38
|
+
const originalTestData = ref(JSON.parse(JSON.stringify(testData.value)))
|
|
39
|
+
const searchOpts = ref("")
|
|
40
|
+
function searchTestData(opts) {
|
|
41
|
+
action('search')(opts)
|
|
42
|
+
searchOpts.value = opts
|
|
43
|
+
if (!opts) testData.value = JSON.parse(JSON.stringify(originalTestData.value))
|
|
44
|
+
else testData.value = originalTestData.value.filter(data => data.name.indexOf(opts) > -1)
|
|
45
|
+
return sortTestData(sortOpts.value)
|
|
46
|
+
}
|
|
47
|
+
const selectedRows = ref(["COBOL"])
|
|
35
48
|
|
|
36
49
|
<Meta title={`${sbCompPrefix}/CvDataTable`} component={CvDataTable} />
|
|
37
50
|
|
|
@@ -59,10 +72,11 @@ setup() {
|
|
|
59
72
|
template: undefined},
|
|
60
73
|
trashIcon: TrashCanIcon,
|
|
61
74
|
onSort: sortTestData,
|
|
62
|
-
onSearch:
|
|
75
|
+
onSearch: searchTestData,
|
|
63
76
|
onRowSelectChange: action('row-select-change'),
|
|
64
77
|
onRowSelectChanges: action('row-select-changes'),
|
|
65
78
|
onOverflowMenuClick: action('overflow-menu-click'),
|
|
79
|
+
onVmodel: action('v-model'),
|
|
66
80
|
onRowExpanded: action('row-expanded'),
|
|
67
81
|
onPagination: action('pagination'),
|
|
68
82
|
onAction1: action('compile'),
|
|
@@ -72,11 +86,15 @@ setup() {
|
|
|
72
86
|
useActions: args.useActions,
|
|
73
87
|
useBatchActions: args.useBatchActions,
|
|
74
88
|
useHelperTextSlot: args.useHelperTextSlot,
|
|
89
|
+
usePagination: args.usePagination,
|
|
75
90
|
skeletonRows: args.skeletonRows,
|
|
76
91
|
skeletonCols: args.skeletonCols,
|
|
77
92
|
skeletonTitle: args.title,
|
|
78
93
|
skeletonHelper: args.helperText,
|
|
79
94
|
testData,
|
|
95
|
+
originalTestData,
|
|
96
|
+
searchOpts,
|
|
97
|
+
selectedRows
|
|
80
98
|
};
|
|
81
99
|
},
|
|
82
100
|
// And then the `args` are bound to your component with `v-bind="args"`
|
|
@@ -91,6 +109,8 @@ const defaultTemplate = `
|
|
|
91
109
|
@overflow-menu-click="onOverflowMenuClick"
|
|
92
110
|
@row-expanded="onRowExpanded"
|
|
93
111
|
@pagination="onPagination"
|
|
112
|
+
:pagination="usePagination"
|
|
113
|
+
:initialSearchValue="searchOpts"
|
|
94
114
|
>
|
|
95
115
|
<template v-if="useBatchActions" #batch-actions>
|
|
96
116
|
<cv-button :icon="trashIcon" @click="onDelete">Delete</cv-button>
|
|
@@ -113,14 +133,14 @@ const defaultTemplate = `
|
|
|
113
133
|
</cv-data-table-action>
|
|
114
134
|
</template>
|
|
115
135
|
<template #headings>
|
|
116
|
-
<cv-data-table-heading heading="Name" name="name" sortable/>
|
|
117
|
-
<cv-data-table-heading heading="Year" name="year" sortable/>
|
|
118
|
-
<cv-data-table-heading heading="Object Oriented"/>
|
|
119
|
-
<cv-data-table-heading heading="Purpose" />
|
|
120
|
-
<cv-data-table-heading heading="Standard" />
|
|
136
|
+
<cv-data-table-heading id="sb-name" heading="Name" name="name" sortable order="ascending"/>
|
|
137
|
+
<cv-data-table-heading id="sb-year" heading="Year" name="year" sortable/>
|
|
138
|
+
<cv-data-table-heading id="sb-oo" heading="Object Oriented"/>
|
|
139
|
+
<cv-data-table-heading id="sb-purpose" heading="Purpose" />
|
|
140
|
+
<cv-data-table-heading id="sb-standard" heading="Standard" />
|
|
121
141
|
</template>
|
|
122
142
|
<template #data>
|
|
123
|
-
<cv-data-table-row v-for="row in testData" :key="row.name" :value="row.name">
|
|
143
|
+
<cv-data-table-row v-for="row in testData" :id="row.name" :key="row.name" :value="row.name">
|
|
124
144
|
<cv-data-table-cell>{{row.name}}</cv-data-table-cell>
|
|
125
145
|
<cv-data-table-cell>{{row.year}}</cv-data-table-cell>
|
|
126
146
|
<cv-data-table-cell>{{row.oo}}</cv-data-table-cell>
|
|
@@ -135,6 +155,7 @@ const expandingRowsTemplate = defaultTemplate.replace(
|
|
|
135
155
|
"<!-- Add optional expanding data here -->",
|
|
136
156
|
`<template #expandedContent>{{row.desc}}</template>`)
|
|
137
157
|
.replace('@search="onSearch"', '')
|
|
158
|
+
.replace('testData', 'originalTestData')
|
|
138
159
|
const skeletonTemplate = `
|
|
139
160
|
<cv-data-table-skeleton
|
|
140
161
|
:columns="skeletonCols"
|
|
@@ -153,6 +174,17 @@ const skeletonTemplate = `
|
|
|
153
174
|
</template>
|
|
154
175
|
</cv-data-table-skeleton>
|
|
155
176
|
`;
|
|
177
|
+
const vModelTemplate = defaultTemplate
|
|
178
|
+
.replace('@search="onSearch"', 'v-model:rows-selected="selectedRows"')
|
|
179
|
+
.replace('@row-select-change="onRowSelectChange"', '@update:rows-selected="onVmodel"')
|
|
180
|
+
.replace('@row-select-changes="onRowSelectChanges"','')
|
|
181
|
+
.replace('testData', 'originalTestData') + `
|
|
182
|
+
<div style="margin-top:1rem; background-color: #888888; padding:1rem"><div style="font-size: 150%">Sample interaction</div>
|
|
183
|
+
<select name="programming-languages" id="programming-languages" v-model="selectedRows" multiple>
|
|
184
|
+
<option v-for="l in originalTestData" :id="l.name" :key="l.name" :value="l.name">{{l.name}}</option>
|
|
185
|
+
</select>
|
|
186
|
+
<div>selections: {{ selectedRows }} </div>
|
|
187
|
+
</div>`
|
|
156
188
|
|
|
157
189
|
# CvDataTable
|
|
158
190
|
|
|
@@ -160,7 +192,10 @@ const skeletonTemplate = `
|
|
|
160
192
|
- Sorting, filtering and pagination are the responsibility of the component user. This component raises events to facilitate this.
|
|
161
193
|
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.
|
|
162
194
|
```javascript
|
|
195
|
+
// sort example
|
|
196
|
+
const sortOpts = ref({index: "0", order: "none", name: "name"})
|
|
163
197
|
function sortTestData(opts) {
|
|
198
|
+
sortOpts.value = opts // remember this so it can be used in filtering
|
|
164
199
|
if (opts.order === 'none')
|
|
165
200
|
return testData.value.sort((a, b) => a.index.localeCompare(b.index, 'en', { sensitivity: 'base' }));
|
|
166
201
|
let direction = 1
|
|
@@ -170,6 +205,12 @@ const skeletonTemplate = `
|
|
|
170
205
|
else if (opts.name === 'year')
|
|
171
206
|
return testData.value.sort((a, b) => direction * (a.year - b.year));
|
|
172
207
|
}
|
|
208
|
+
// filter example
|
|
209
|
+
function searchTestData(opts) {
|
|
210
|
+
if (!opts) testData.value = allData.value
|
|
211
|
+
else testData.value = allData.value.filter(data => data.name.indexOf(opts) > -1)
|
|
212
|
+
return sortTestData(sortOpts.value)
|
|
213
|
+
}
|
|
173
214
|
```
|
|
174
215
|
- The search bar appears only if the search event is listened for.
|
|
175
216
|
|
|
@@ -178,6 +219,7 @@ const skeletonTemplate = `
|
|
|
178
219
|
- aria-label-expand-row: Aria label for expanding row expansion button. default: 'Expand current row'
|
|
179
220
|
- aria-label-collapse-row: Aria label for expanding row collapse button. default: 'Collapse current row'
|
|
180
221
|
- expanded: initial state of the expanded row
|
|
222
|
+
- value: this is the value assign to the checkbox for tables with batch actions.
|
|
181
223
|
|
|
182
224
|
**Migration notes:**
|
|
183
225
|
|
|
@@ -190,9 +232,6 @@ completion for it. See [discussion](https://github.com/vuejs/core/issues/3432) f
|
|
|
190
232
|
`search` emit is still emitted it is just not defined directly on the component.
|
|
191
233
|
- The React does not seem to have an "autoWidth" property. It is still supported here but likely the better choice is `staticWidth`.
|
|
192
234
|
- Row sizes in the React component are 'xs', 'sm', 'md', 'lg', & 'xl'. The rowSizes from Vue2 are still supported.
|
|
193
|
-
- The Vue 3 implementation uses an internal store to manage the state of the table. You can see updates
|
|
194
|
-
to the state by setting the debug variable in the local storage. `localStorage.debug="cv:data-table-store"`
|
|
195
|
-
and then reloading the page.
|
|
196
235
|
- If you were using something like `this.$refs.tableEditPath.batchActive = true` to force batch actions to show even
|
|
197
236
|
when no items were select, please now use the new property `stickyBatchActive`.
|
|
198
237
|
|
|
@@ -228,10 +267,12 @@ when no items were select, please now use the new property `stickyBatchActive`.
|
|
|
228
267
|
helperText: 'Table helper text',
|
|
229
268
|
useActions: false,
|
|
230
269
|
useBatchActions: false,
|
|
270
|
+
usePagination: true
|
|
231
271
|
}}
|
|
232
272
|
argTypes={{
|
|
233
273
|
rowSize: { control: 'select', default: 'lg', options: ['xs', 'sm', 'md', 'lg', 'xl'] },
|
|
234
274
|
rowsSelected: { control: 'multi-select', options: ['Java', 'COBOL', 'C++'] },
|
|
275
|
+
useBatchActions: { description: "To use batch actions you should assign a usable `id` to each row. i.e. `<cv-data-table-row :id=\"item.id\" ...` This `id` value is passed to the row selection events." }
|
|
235
276
|
}}
|
|
236
277
|
>
|
|
237
278
|
{Template.bind({})}
|
|
@@ -245,7 +286,6 @@ when no items were select, please now use the new property `stickyBatchActive`.
|
|
|
245
286
|
controls: { exclude: ['default',
|
|
246
287
|
'template',
|
|
247
288
|
'overflow-menu-click',
|
|
248
|
-
'pagination',
|
|
249
289
|
'row-expanded',
|
|
250
290
|
'row-select-change',
|
|
251
291
|
'row-select-changes',
|
|
@@ -270,6 +310,7 @@ when no items were select, please now use the new property `stickyBatchActive`.
|
|
|
270
310
|
helperText: 'Click row to expand',
|
|
271
311
|
useActions: false,
|
|
272
312
|
useBatchActions: false,
|
|
313
|
+
usePagination: true
|
|
273
314
|
}}
|
|
274
315
|
argTypes={{
|
|
275
316
|
rowSize: { control: 'select', default: 'standard', options: ['compact', 'short', 'standard', 'tall'] },
|
|
@@ -296,7 +337,36 @@ when no items were select, please now use the new property `stickyBatchActive`.
|
|
|
296
337
|
skeletonRows: 5,
|
|
297
338
|
skeletonCols: 5,
|
|
298
339
|
useBatchActions: false,
|
|
299
|
-
useActions: false
|
|
340
|
+
useActions: false,
|
|
341
|
+
usePagination: true
|
|
342
|
+
}}
|
|
343
|
+
argTypes={{
|
|
344
|
+
}}
|
|
345
|
+
>
|
|
346
|
+
{Template.bind({})}
|
|
347
|
+
</Story>
|
|
348
|
+
</Canvas>
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
# Using v-model selected rows
|
|
352
|
+
If you are using the selected rows for batch actions or any other purpose, you should assign usable values to the rows.
|
|
353
|
+
It is these values that are included in the selected rows events and in the selected rows v-model. Set the v-model on the
|
|
354
|
+
cv-table like `<cv-table v-model:rows-selected="selectedRows" ...`
|
|
355
|
+
|
|
356
|
+
<Canvas>
|
|
357
|
+
<Story
|
|
358
|
+
name="v-model Selected Rows"
|
|
359
|
+
parameters={{
|
|
360
|
+
controls: { include: [ ] },
|
|
361
|
+
docs: { source: { code: storySourceCode(vModelTemplate, Template.args) } },
|
|
362
|
+
}}
|
|
363
|
+
args={{
|
|
364
|
+
template: vModelTemplate,
|
|
365
|
+
title: 'v-model example',
|
|
366
|
+
helperText: 'select rows to see updates',
|
|
367
|
+
useBatchActions: true,
|
|
368
|
+
useActions: false,
|
|
369
|
+
usePagination: false
|
|
300
370
|
}}
|
|
301
371
|
argTypes={{
|
|
302
372
|
}}
|