@carbon/vue 1.0.0 → 1.1.1
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/CHANGELOG.md +192 -0
- package/README.md +9 -156
- package/dist/carbon-data-viz-vue.common.js +6 -6
- package/dist/carbon-data-viz-vue.common.js.map +1 -1
- package/dist/carbon-data-viz-vue.css +1 -1
- package/dist/carbon-data-viz-vue.umd.js +6 -6
- package/dist/carbon-data-viz-vue.umd.js.map +1 -1
- package/dist/carbon-data-viz-vue.umd.min.js.map +1 -1
- package/dist/carbon-vue.common.js +8807 -4866
- package/dist/carbon-vue.common.js.map +1 -1
- package/dist/carbon-vue.umd.js +8807 -4866
- package/dist/carbon-vue.umd.js.map +1 -1
- package/dist/carbon-vue.umd.min.js +4 -4
- package/dist/carbon-vue.umd.min.js.map +1 -1
- package/dist/demo.html +2 -2
- package/package.json +21 -8
- package/src/_internal/_feature-flags.js +42 -0
- package/src/components/cv-accordion/_cv-accordion-item-skeleton.vue +10 -0
- package/src/components/cv-accordion/cv-accordion-item.vue +6 -0
- package/src/components/cv-button/cv-button.vue +32 -3
- package/src/components/cv-checkbox/_cv-checkbox-inner-form-item.vue +1 -1
- package/src/components/cv-checkbox/_cv-checkbox-inner.vue +1 -0
- package/src/components/cv-checkbox/cv-checkbox-skeleton.vue +13 -0
- package/src/components/cv-code-snippet/_cv-code-snippet-multiline.vue +10 -0
- package/src/components/cv-code-snippet/_cv-code-snippet-oneline.vue +10 -0
- package/src/components/cv-code-snippet/cv-code-snippet-skeleton.vue +29 -0
- package/src/components/cv-code-snippet/cv-code-snippet.vue +1 -1
- package/src/components/cv-content-switcher/cv-content-switcher-button.vue +28 -1
- package/src/components/cv-content-switcher/cv-content-switcher.vue +1 -1
- package/src/components/cv-data-table/cv-data-table.vue +54 -18
- package/src/components/cv-date-picker/_cv-date-picker-inner-c10.vue +220 -0
- package/src/components/cv-date-picker/_cv-date-picker-inner.vue +231 -0
- package/src/components/cv-date-picker/cv-date-picker.vue +17 -216
- package/src/components/cv-dropdown/_cv-dropdown-inner-c10.vue +201 -0
- package/src/components/cv-dropdown/_cv-dropdown-inner-form-item.vue +22 -0
- package/src/components/cv-dropdown/_cv-dropdown-inner.vue +213 -0
- package/src/components/cv-dropdown/cv-dropdown-item.vue +4 -0
- package/src/components/cv-dropdown/cv-dropdown-skeleton.vue +18 -0
- package/src/components/cv-dropdown/cv-dropdown.vue +20 -167
- package/src/components/cv-file-uploader/cv-file-uploader-skeleton.vue +22 -0
- package/src/components/cv-file-uploader/cv-file-uploader.vue +48 -8
- package/src/components/cv-inline-loader/cv-inline-loader.vue +42 -0
- package/src/components/cv-inline-notification/cv-inline-notification.vue +25 -7
- package/src/components/cv-loading/cv-loading.vue +18 -1
- package/src/components/cv-modal/cv-modal.vue +17 -6
- package/src/components/cv-number-input/cv-number-input.vue +9 -2
- package/src/components/cv-overflow-menu/cv-overflow-menu.vue +17 -15
- package/src/components/cv-pagination/cv-pagination.vue +2 -2
- package/src/components/cv-radio-button/cv-radio-button.vue +1 -0
- package/src/components/cv-slider/cv-slider.vue +6 -6
- package/src/components/cv-structured-list/_cv-structured-list-item-selectable.vue +1 -0
- package/src/components/cv-tabs/cv-tabs.vue +22 -11
- package/src/components/cv-text-input/cv-text-input.vue +70 -0
- package/src/components/cv-toast-notification/cv-toast-notification.vue +35 -0
- package/src/components/cv-tooltip/cv-interactive-tooltip.vue +4 -4
- package/src/data-viz/cv-bar-graph/cv-bar-graph.vue +7 -4
- package/src/data-viz/cv-gauge/cv-gauge.vue +1 -1
- package/src/data-viz/cv-pie-chart/cv-pie-chart.vue +8 -7
- package/src/components/cv-data-table/_cv-data-table-temp.vue +0 -669
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,8 +1,11 @@
|
|
|
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.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=10.x"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "git+https://github.com/carbon-design-system/carbon-components-vue.git"
|
|
@@ -43,6 +46,10 @@
|
|
|
43
46
|
{
|
|
44
47
|
"name": "Oleksandr Sabov",
|
|
45
48
|
"email": "sabov@de.ibm.com"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "Conrad Schmidt",
|
|
52
|
+
"email": "conrad.schmidt@de.ibm.com"
|
|
46
53
|
}
|
|
47
54
|
],
|
|
48
55
|
"files": [
|
|
@@ -51,27 +58,32 @@
|
|
|
51
58
|
],
|
|
52
59
|
"sideEffects": true,
|
|
53
60
|
"scripts": {
|
|
61
|
+
"build": "npm run build:core && npm run build:data-viz",
|
|
62
|
+
"lint": "vue-cli-service lint ./src/index.js",
|
|
63
|
+
"build:core": "vue-cli-service build --target lib --name carbon-vue ./src/index.js --no-clean",
|
|
64
|
+
"build:data-viz": "vue-cli-service build --target lib --name carbon-data-viz-vue ./src/index-data-viz.js --no-clean",
|
|
54
65
|
"ci-check": "yarn format:diff",
|
|
55
66
|
"format": "prettier --write \"**/*.{scss,css,js,md,vue}\"",
|
|
56
67
|
"format:diff": "prettier --list-different \"**/*.{scss,css,js,md,vue}\"",
|
|
68
|
+
"format:staged": "prettier --write",
|
|
69
|
+
"lint:css": "stylelint 'src/**/*.{vue,scss}'",
|
|
57
70
|
"lint:es": "eslint --ext .js,.vue src",
|
|
58
|
-
"lint:
|
|
71
|
+
"lint:style": "vue-cli-service lint:style",
|
|
59
72
|
"storybook": "start-storybook -p 9001 -c .storybook",
|
|
60
73
|
"storybook-build": "build-storybook",
|
|
61
|
-
"build": "npm run build:core && npm run build:data-viz",
|
|
62
|
-
"build:core": "vue-cli-service build --target lib --name carbon-vue ./src/index.js --no-clean",
|
|
63
|
-
"build:data-viz": "vue-cli-service build --target lib --name carbon-data-viz-vue ./src/index-data-viz.js --no-clean",
|
|
64
|
-
"lint": "vue-cli-service lint ./src/index.js",
|
|
65
74
|
"test:unit": "vue-cli-service test:unit"
|
|
66
75
|
},
|
|
67
76
|
"peerDependencies": {},
|
|
68
77
|
"dependencies": {
|
|
78
|
+
"@carbon/icon-helpers": "0.0.1-beta.0",
|
|
79
|
+
"@carbon/icons-vue": "0.0.1-beta.0",
|
|
69
80
|
"carbon-components": "^9.48.1",
|
|
70
81
|
"d3": "^5.7.0",
|
|
71
82
|
"flatpickr": "4.5.1",
|
|
72
83
|
"vue": "^2.5.21"
|
|
73
84
|
},
|
|
74
85
|
"devDependencies": {
|
|
86
|
+
"@ascendancyy/vue-cli-plugin-stylelint": "^1.1.2",
|
|
75
87
|
"@babel/core": "^7.2.2",
|
|
76
88
|
"@commitlint/cli": "^7.2.1",
|
|
77
89
|
"@commitlint/config-conventional": "^7.1.2",
|
|
@@ -90,7 +102,8 @@
|
|
|
90
102
|
"babel-eslint": "^10.0.1",
|
|
91
103
|
"babel-jest": "^24.1.0",
|
|
92
104
|
"babel-loader": "^7.0.0",
|
|
93
|
-
"babel-plugin-transform-object-
|
|
105
|
+
"babel-plugin-transform-object-from-destructuring": "^1.0.3",
|
|
106
|
+
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
|
94
107
|
"babel-preset-env": "^1.7.0",
|
|
95
108
|
"babel-preset-vue": "^2.0.2",
|
|
96
109
|
"eslint": "^5.10.0",
|
|
@@ -126,7 +139,7 @@
|
|
|
126
139
|
},
|
|
127
140
|
"lint-staged": {
|
|
128
141
|
"*.{scss,css,js,md,vue}": [
|
|
129
|
-
"yarn format",
|
|
142
|
+
"yarn format:staged",
|
|
130
143
|
"git add"
|
|
131
144
|
]
|
|
132
145
|
},
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2018
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This file contains the list of the default values of compile-time feature flags.
|
|
10
|
+
*
|
|
11
|
+
* Build toolchain can replace variable here and/or the references
|
|
12
|
+
* in order to apply non-default values to those feature flags.
|
|
13
|
+
*
|
|
14
|
+
* @example <div v-if="aFeatureFlag">foo</div><div v-else>bar</div>
|
|
15
|
+
* import { aFeatureFlag } from '/path/to/_feagure-flags';
|
|
16
|
+
* ...
|
|
17
|
+
* data() { return { aFeatureFlag } }
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Breaking changes for next release.
|
|
22
|
+
*/
|
|
23
|
+
export let breakingChangesX;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Next gen of Carbon component design.
|
|
27
|
+
*/
|
|
28
|
+
export let componentsX;
|
|
29
|
+
|
|
30
|
+
export const override = val => {
|
|
31
|
+
if (val) {
|
|
32
|
+
breakingChangesX = val.breakingChangesX === true;
|
|
33
|
+
componentsX = val.componentsX === true;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const reset = () => {
|
|
38
|
+
componentsX = false;
|
|
39
|
+
breakingChangesX = false;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
reset();
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
:class="{ 'bx--accordion__item--active': open }"
|
|
5
5
|
>
|
|
6
6
|
<button disabled type="button" class="bx--accordion__heading">
|
|
7
|
+
<ChevronRight16 v-if="componentsX" class="bx--accordion__arrow" />
|
|
7
8
|
<svg
|
|
9
|
+
v-else
|
|
8
10
|
class="bx--accordion__arrow"
|
|
9
11
|
width="8"
|
|
10
12
|
height="12"
|
|
@@ -23,15 +25,23 @@
|
|
|
23
25
|
|
|
24
26
|
<script>
|
|
25
27
|
import CvSkeletonText from '../cv-skeleton-text/cv-skeleton-text';
|
|
28
|
+
import { componentsX } from '../../_internal/_feature-flags';
|
|
29
|
+
import ChevronRight16 from '@carbon/icons-vue/lib/chevron--right/16';
|
|
26
30
|
|
|
27
31
|
export default {
|
|
28
32
|
name: 'CvAccordionItemSkeleton',
|
|
29
33
|
components: {
|
|
34
|
+
ChevronRight16,
|
|
30
35
|
CvSkeletonText,
|
|
31
36
|
},
|
|
32
37
|
props: {
|
|
33
38
|
open: { type: Boolean, default: false },
|
|
34
39
|
},
|
|
40
|
+
data() {
|
|
41
|
+
return {
|
|
42
|
+
componentsX,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
35
45
|
};
|
|
36
46
|
</script>
|
|
37
47
|
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
:aria-controls="uid"
|
|
19
19
|
@click="toggle"
|
|
20
20
|
>
|
|
21
|
+
<ChevronRight16 v-if="componentsX" class="bx--accordion__arrow" />
|
|
21
22
|
<svg
|
|
23
|
+
v-else
|
|
22
24
|
class="bx--accordion__arrow"
|
|
23
25
|
width="8"
|
|
24
26
|
height="12"
|
|
@@ -38,11 +40,14 @@
|
|
|
38
40
|
</template>
|
|
39
41
|
|
|
40
42
|
<script>
|
|
43
|
+
import { componentsX } from '../../_internal/_feature-flags';
|
|
44
|
+
import ChevronRight16 from '@carbon/icons-vue/lib/chevron--right/16';
|
|
41
45
|
import uidMixin from '../../mixins/uid-mixin';
|
|
42
46
|
|
|
43
47
|
export default {
|
|
44
48
|
name: 'CvAccordionItem',
|
|
45
49
|
mixins: [uidMixin],
|
|
50
|
+
components: { ChevronRight16 },
|
|
46
51
|
props: {
|
|
47
52
|
open: { type: Boolean, default: false },
|
|
48
53
|
},
|
|
@@ -56,6 +61,7 @@ export default {
|
|
|
56
61
|
},
|
|
57
62
|
data() {
|
|
58
63
|
return {
|
|
64
|
+
componentsX,
|
|
59
65
|
dataOpen: false,
|
|
60
66
|
};
|
|
61
67
|
},
|
|
@@ -10,8 +10,14 @@
|
|
|
10
10
|
role="button"
|
|
11
11
|
>
|
|
12
12
|
<slot></slot>
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
<component
|
|
15
|
+
v-if="typeof icon === 'object'"
|
|
16
|
+
:is="icon"
|
|
17
|
+
class="bx--btn__icon"
|
|
18
|
+
/>
|
|
19
|
+
<svg v-if="typeof icon === 'string' || iconHref" class="bx--btn__icon">
|
|
20
|
+
<use :href="icon || iconHref"></use>
|
|
15
21
|
</svg>
|
|
16
22
|
</button>
|
|
17
23
|
</template>
|
|
@@ -20,7 +26,30 @@
|
|
|
20
26
|
export default {
|
|
21
27
|
name: 'CvButton',
|
|
22
28
|
props: {
|
|
23
|
-
|
|
29
|
+
icon: {
|
|
30
|
+
type: [String, Object],
|
|
31
|
+
default: null,
|
|
32
|
+
validator(val) {
|
|
33
|
+
if (!val || typeof val === 'string') {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return val.render !== null;
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
iconHref: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: null,
|
|
42
|
+
validator(val) {
|
|
43
|
+
if (process.env.NODE_ENV === 'development') {
|
|
44
|
+
if (val !== null) {
|
|
45
|
+
console.warn(
|
|
46
|
+
'CvButton: iconHref deprecated in favour of icon to be removed in future versions.'
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
},
|
|
52
|
+
},
|
|
24
53
|
kind: {
|
|
25
54
|
type: String,
|
|
26
55
|
default: 'primary',
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="cv-checkbox bx--form-item bx--checkbox-wrapper">
|
|
3
|
+
<label class="bx--checkbox-label bx--skeleton"></label>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
name: 'CvCheckboxSkeleton',
|
|
10
|
+
};
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<style lang="scss"></style>
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
aria-label="Copy code"
|
|
15
15
|
@click="$emit('copy-code')"
|
|
16
16
|
>
|
|
17
|
+
<Copy16 v-if="componentsX" class="bx--snippet__icon" />
|
|
17
18
|
<svg
|
|
19
|
+
v-else
|
|
18
20
|
class="bx--snippet__icon"
|
|
19
21
|
xmlns="http://www.w3.org/2000/svg"
|
|
20
22
|
width="16"
|
|
@@ -36,7 +38,9 @@
|
|
|
36
38
|
@click="toggleExpand"
|
|
37
39
|
>
|
|
38
40
|
<span class="bx--snippet-btn--text">{{ expandButtonText }}</span>
|
|
41
|
+
<ChevronDown16 v-if="componentsX" class="bx--icon-chevron--down" />
|
|
39
42
|
<svg
|
|
43
|
+
v-else
|
|
40
44
|
class="bx--icon-chevron--down"
|
|
41
45
|
width="12"
|
|
42
46
|
height="7"
|
|
@@ -55,11 +59,16 @@
|
|
|
55
59
|
|
|
56
60
|
<script>
|
|
57
61
|
import CvFeedbackButton from './_cv-feedback-button';
|
|
62
|
+
import { componentsX } from '../../_internal/_feature-flags';
|
|
63
|
+
import Copy16 from '@carbon/icons-vue/lib/copy/16';
|
|
64
|
+
import ChevronDown16 from '@carbon/icons-vue/lib/chevron--down/16';
|
|
58
65
|
|
|
59
66
|
export default {
|
|
60
67
|
name: 'CvCodeSnippetMultiline',
|
|
61
68
|
components: {
|
|
62
69
|
CvFeedbackButton,
|
|
70
|
+
Copy16,
|
|
71
|
+
ChevronDown16,
|
|
63
72
|
},
|
|
64
73
|
props: {
|
|
65
74
|
lessText: { type: String, default: 'Show less' },
|
|
@@ -67,6 +76,7 @@ export default {
|
|
|
67
76
|
},
|
|
68
77
|
data() {
|
|
69
78
|
return {
|
|
79
|
+
componentsX,
|
|
70
80
|
expanded: false,
|
|
71
81
|
};
|
|
72
82
|
},
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
aria-label="Copy code"
|
|
11
11
|
@click="$emit('copy-code')"
|
|
12
12
|
>
|
|
13
|
+
<Copy16 v-if="componentsX" class="bx--snippet__icon" />
|
|
13
14
|
<svg
|
|
15
|
+
v-else
|
|
14
16
|
class="bx--snippet__icon"
|
|
15
17
|
xmlns="http://www.w3.org/2000/svg"
|
|
16
18
|
width="16"
|
|
@@ -28,11 +30,19 @@
|
|
|
28
30
|
|
|
29
31
|
<script>
|
|
30
32
|
import CvFeedbackButton from './_cv-feedback-button';
|
|
33
|
+
import { componentsX } from '../../_internal/_feature-flags';
|
|
34
|
+
import Copy16 from '@carbon/icons-vue/lib/copy/16';
|
|
31
35
|
|
|
32
36
|
export default {
|
|
33
37
|
name: 'CvCodeSnippetOneline',
|
|
34
38
|
components: {
|
|
35
39
|
CvFeedbackButton,
|
|
40
|
+
Copy16,
|
|
41
|
+
},
|
|
42
|
+
data() {
|
|
43
|
+
return {
|
|
44
|
+
componentsX,
|
|
45
|
+
};
|
|
36
46
|
},
|
|
37
47
|
};
|
|
38
48
|
</script>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="bx--snippet bx--skeleton" :class="typeClass">
|
|
3
|
+
<div class="bx--snippet-container">
|
|
4
|
+
<span v-if="!multi" />
|
|
5
|
+
<span v-if="multi" />
|
|
6
|
+
<span v-if="multi" />
|
|
7
|
+
<span v-if="multi" />
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
export default {
|
|
14
|
+
name: 'CvCodeSnippetSkeleton',
|
|
15
|
+
props: {
|
|
16
|
+
kind: { type: String, default: 'oneline' },
|
|
17
|
+
},
|
|
18
|
+
computed: {
|
|
19
|
+
typeClass() {
|
|
20
|
+
return `bx--snippet--${this.multi ? 'multi' : 'single'}`;
|
|
21
|
+
},
|
|
22
|
+
multi() {
|
|
23
|
+
return this.kind === 'multiline';
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<style lang="scss"></style>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<!-- textarea cannot be fully hidden for clipboard to work -->
|
|
10
10
|
<textarea
|
|
11
11
|
class="cv-code-snippet__clippy"
|
|
12
|
-
style="position: absolute; left: -9999px; max-width: 0; opacity: 0; overflow: hidden"
|
|
12
|
+
style="position: absolute; left: -9999px; max-width: 0; opacity: 0; overflow: hidden;"
|
|
13
13
|
aria-hidden="true"
|
|
14
14
|
ref="clippy"
|
|
15
15
|
></textarea>
|
|
@@ -24,18 +24,44 @@
|
|
|
24
24
|
:aria-selected="`${dataSelected}`"
|
|
25
25
|
@click="open"
|
|
26
26
|
>
|
|
27
|
-
<
|
|
27
|
+
<component
|
|
28
|
+
v-if="typeof icon === 'object'"
|
|
29
|
+
:is="icon"
|
|
30
|
+
class="bx--content-switcher__icon"
|
|
31
|
+
/>
|
|
32
|
+
<svg
|
|
33
|
+
v-if="typeof icon === 'string'"
|
|
34
|
+
class="bx--content-switcher__icon"
|
|
35
|
+
height="16"
|
|
36
|
+
width="16"
|
|
37
|
+
>
|
|
38
|
+
<use :href="icon"></use>
|
|
39
|
+
</svg>
|
|
40
|
+
<span>
|
|
41
|
+
<slot></slot>
|
|
42
|
+
</span>
|
|
28
43
|
</button>
|
|
29
44
|
</template>
|
|
30
45
|
|
|
31
46
|
<script>
|
|
32
47
|
import uidMixin from '../../mixins/uid-mixin';
|
|
48
|
+
import { componentsX } from '../../_internal/_feature-flags';
|
|
33
49
|
|
|
34
50
|
export default {
|
|
35
51
|
name: 'CvContentSwitcherButton',
|
|
36
52
|
mixins: [uidMixin],
|
|
37
53
|
props: {
|
|
38
54
|
contentSelector: { type: String, default: undefined },
|
|
55
|
+
icon: {
|
|
56
|
+
type: [String, Object],
|
|
57
|
+
default: null,
|
|
58
|
+
validator(val) {
|
|
59
|
+
if (!val || typeof val === 'string') {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return val.render !== null;
|
|
63
|
+
},
|
|
64
|
+
},
|
|
39
65
|
ownerId: { type: String, default: undefined },
|
|
40
66
|
selected: Boolean,
|
|
41
67
|
},
|
|
@@ -50,6 +76,7 @@ export default {
|
|
|
50
76
|
},
|
|
51
77
|
data() {
|
|
52
78
|
return {
|
|
79
|
+
componentsX,
|
|
53
80
|
dataSelected: false,
|
|
54
81
|
};
|
|
55
82
|
},
|
|
@@ -24,7 +24,7 @@ const toggleContent = (selector, on) => {
|
|
|
24
24
|
export default {
|
|
25
25
|
name: 'CvContentSwitcher',
|
|
26
26
|
created() {
|
|
27
|
-
// add these on created otherwise cv:mounted is too
|
|
27
|
+
// add these on created otherwise cv:mounted is too late.
|
|
28
28
|
this.$on('cv:open', srcComponent => this.onCvOpen(srcComponent));
|
|
29
29
|
this.$on('cv:mounted', srcComponent => this.onCvMount(srcComponent));
|
|
30
30
|
this.$on('cv:beforeDestroy', srcComponent =>
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
</div>
|
|
17
17
|
<div class="bx--batch-summary">
|
|
18
18
|
<p class="bx--batch-summary__para">
|
|
19
|
-
<span data-items-selected>{{
|
|
20
|
-
selected
|
|
19
|
+
<span data-items-selected>{{ dataRowsSelected.length }}</span>
|
|
20
|
+
items selected
|
|
21
21
|
</p>
|
|
22
22
|
<button class="bx--batch-summary__cancel" @click="deselect">
|
|
23
23
|
Cancel
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
v-for="(row, rowIndex) in data"
|
|
71
71
|
:key="`row:${rowIndex}`"
|
|
72
72
|
:value="`${rowIndex}`"
|
|
73
|
-
ref="
|
|
73
|
+
ref="dataRowsSelected"
|
|
74
74
|
:overflow-menu="overflowMenu"
|
|
75
75
|
>
|
|
76
76
|
<cv-data-table-cell
|
|
@@ -104,6 +104,8 @@ import CvDataTableHeadnig from './_cv-data-table-heading';
|
|
|
104
104
|
import CvDataTableRow from './cv-data-table-row';
|
|
105
105
|
import CvDataTableCell from './cv-data-table-cell';
|
|
106
106
|
|
|
107
|
+
const rows = children => children.filter(child => child.isCvDataTableRow);
|
|
108
|
+
|
|
107
109
|
export default {
|
|
108
110
|
name: 'CvDataTable',
|
|
109
111
|
components: {
|
|
@@ -131,6 +133,11 @@ export default {
|
|
|
131
133
|
columns: { type: Array, required: true },
|
|
132
134
|
data: { type: Array, requried: true },
|
|
133
135
|
zebra: Boolean,
|
|
136
|
+
rowsSelected: { type: Array, default: () => [] },
|
|
137
|
+
},
|
|
138
|
+
model: {
|
|
139
|
+
prop: 'rows-selected',
|
|
140
|
+
event: 'row-select-changes',
|
|
134
141
|
},
|
|
135
142
|
data() {
|
|
136
143
|
return {
|
|
@@ -142,7 +149,7 @@ export default {
|
|
|
142
149
|
: this.columns,
|
|
143
150
|
batchActive: false,
|
|
144
151
|
headingChecked: false,
|
|
145
|
-
|
|
152
|
+
dataRowsSelected: this.rowsSelected,
|
|
146
153
|
};
|
|
147
154
|
},
|
|
148
155
|
watch: {
|
|
@@ -152,6 +159,9 @@ export default {
|
|
|
152
159
|
columns() {
|
|
153
160
|
this.watchColumns();
|
|
154
161
|
},
|
|
162
|
+
rowsSelected() {
|
|
163
|
+
this.updateRowsSelected();
|
|
164
|
+
},
|
|
155
165
|
},
|
|
156
166
|
mounted() {
|
|
157
167
|
console.warn(
|
|
@@ -159,6 +169,7 @@ export default {
|
|
|
159
169
|
this.$vnode.componentOptions.Ctor.extendOptions.name
|
|
160
170
|
} - Under review. This component isn't quite ready. Hopefully no features will get broken but this cannot be guarenteed.`
|
|
161
171
|
);
|
|
172
|
+
this.updateRowsSelected();
|
|
162
173
|
},
|
|
163
174
|
computed: {
|
|
164
175
|
hasBatchActions() {
|
|
@@ -190,10 +201,10 @@ export default {
|
|
|
190
201
|
) {
|
|
191
202
|
return Math.min(
|
|
192
203
|
this.internalPagination.numberOfItems,
|
|
193
|
-
this.
|
|
204
|
+
rows(this.$children).length
|
|
194
205
|
);
|
|
195
206
|
} else {
|
|
196
|
-
return this.
|
|
207
|
+
return rows(this.$children).length;
|
|
197
208
|
}
|
|
198
209
|
},
|
|
199
210
|
modifierClasses() {
|
|
@@ -213,41 +224,66 @@ export default {
|
|
|
213
224
|
return index => this.columns[index].dataStyle;
|
|
214
225
|
},
|
|
215
226
|
selectedRows() {
|
|
216
|
-
return this.
|
|
227
|
+
return this.dataRowsSelected;
|
|
217
228
|
},
|
|
218
229
|
},
|
|
219
230
|
methods: {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
this.batchActive = this.headingChecked;
|
|
223
|
-
this.rowChecks = [];
|
|
231
|
+
updateRowsSelected() {
|
|
232
|
+
this.dataRowsSelected = [];
|
|
224
233
|
for (const i in this.$children) {
|
|
225
234
|
let child = this.$children[i];
|
|
226
235
|
if (child.isCvDataTableRow) {
|
|
227
|
-
child.dataChecked = this.
|
|
236
|
+
child.dataChecked = this.rowsSelected.includes(child.value);
|
|
228
237
|
|
|
229
|
-
if (
|
|
230
|
-
this.
|
|
238
|
+
if (child.dataChecked) {
|
|
239
|
+
this.dataRowsSelected.push(child.value);
|
|
231
240
|
}
|
|
232
241
|
}
|
|
233
242
|
}
|
|
243
|
+
this.headingChecked =
|
|
244
|
+
this.dataRowsSelected.length ===
|
|
245
|
+
this.$children.filter(item => item.isCvDataTableRow).length;
|
|
246
|
+
this.batchActive = this.dataRowsSelected.length > 0;
|
|
247
|
+
},
|
|
248
|
+
onHeadingCheckChange() {
|
|
249
|
+
// check /uncheck all children
|
|
250
|
+
this.batchActive = this.headingChecked;
|
|
251
|
+
this.dataRowsSelected = [];
|
|
252
|
+
for (const child of rows(this.$children)) {
|
|
253
|
+
if (this.headingChecked) {
|
|
254
|
+
this.dataRowsSelected.push(child.value);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (child.dataChecked !== this.headingChecked) {
|
|
258
|
+
child.dataChecked = this.headingChecked;
|
|
259
|
+
|
|
260
|
+
this.$emit('row-select-change', {
|
|
261
|
+
value: child.value,
|
|
262
|
+
selected: child.dataChecked,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
this.$emit('row-select-changes', this.dataRowsSelected);
|
|
234
267
|
},
|
|
235
268
|
deselect() {
|
|
236
269
|
this.headingChecked = false;
|
|
237
270
|
this.onHeadingCheckChange();
|
|
238
271
|
},
|
|
239
272
|
onRowCheckChange(value, checked) {
|
|
240
|
-
let modelSet = new Set(this.
|
|
273
|
+
let modelSet = new Set(this.dataRowsSelected);
|
|
241
274
|
|
|
242
275
|
if (!checked) {
|
|
243
276
|
modelSet.delete(value);
|
|
244
277
|
} else {
|
|
245
278
|
modelSet.add(value);
|
|
246
279
|
}
|
|
247
|
-
this.
|
|
280
|
+
this.dataRowsSelected = Array.from(modelSet);
|
|
281
|
+
this.headingChecked =
|
|
282
|
+
this.dataRowsSelected.length === rows(this.$children).length;
|
|
283
|
+
this.batchActive = this.dataRowsSelected.length > 0;
|
|
248
284
|
|
|
249
|
-
this
|
|
250
|
-
this
|
|
285
|
+
this.$emit('row-select-change', { value, selected: checked });
|
|
286
|
+
this.$emit('row-select-changes', this.dataRowsSelected);
|
|
251
287
|
},
|
|
252
288
|
onMenuItemClick(val) {
|
|
253
289
|
this.$emit('overflow-menu-click', val);
|