@carbon/vue 3.0.12 → 3.0.14
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/README.md +9 -0
- package/dist/carbon-vue-3.common.js +216 -108
- package/dist/carbon-vue-3.common.js.map +1 -1
- package/dist/carbon-vue-3.umd.js +216 -108
- package/dist/carbon-vue-3.umd.js.map +1 -1
- package/dist/carbon-vue-3.umd.min.js +2 -2
- package/dist/carbon-vue-3.umd.min.js.map +1 -1
- package/dist/web-types.json +49 -17
- package/package.json +6 -4
- package/src/components/CvAccordion/CvAccordion.stories.mdx +162 -0
- package/src/components/CvAccordion/CvAccordion.vue +18 -5
- package/src/components/CvAccordion/CvAccordionItem.vue +19 -7
- package/src/components/CvAccordion/consts.js +8 -9
- package/src/components/CvButton/CvIconButton.vue +1 -1
- package/src/components/CvCheckbox/CvCheckbox.vue +8 -3
- package/src/components/CvComboBox/CvComboBox.vue +1 -1
- package/src/components/CvDataTable/CvDataTable.vue +26 -7
- package/src/components/CvDataTable/CvDataTableRow.vue +11 -3
- package/src/components/CvDataTable/_CvDataTableRowInner.vue +12 -3
- package/src/components/CvDataTable/cvDataTableStore.js +1 -0
- package/src/components/CvDatePicker/CvDatePicker.stories.js +165 -14
- package/src/components/CvDatePicker/CvDatePicker.vue +33 -20
- package/src/components/CvDropdown/CvDropdown.stories.mdx +6 -2
- package/src/components/CvDropdown/CvDropdown.vue +3 -3
- package/src/components/CvFileUploader/CvFileUploader.vue +2 -2
- package/src/components/CvNotification/CvToastNotification.stories.js +65 -5
- package/src/components/CvNotification/CvToastNotificationTemplate.mdx +17 -0
- package/src/components/CvNumberInput/CvNumberInput.vue +3 -3
- package/src/components/CvOverflowMenu/CvOverflowMenuItem.vue +2 -2
- package/src/components/CvProgress/CvProgress.stories.mdx +29 -7
- package/src/components/CvProgress/CvProgress.vue +1 -0
- package/src/components/CvProgress/CvProgressStep.vue +2 -0
- package/src/components/CvRadioButton/CvRadioButton.stories.js +20 -1
- package/src/components/CvRadioButton/CvRadioButton.vue +7 -5
- package/src/components/CvRadioButton/CvRadioGroup.vue +18 -2
- package/src/components/CvRadioButton/__tests__/__snapshots__/CvRadioButton.spec.js.snap +6 -4
- package/src/components/CvSlider/CvSlider.vue +1 -1
- package/src/components/CvTag/CvTag.vue +1 -1
- package/telemetry.yml +8 -0
- package/src/components/CvAccordion/CvAccordion.stories.js +0 -55
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.13",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -13,27 +13,27 @@
|
|
|
13
13
|
"attributes": [
|
|
14
14
|
{
|
|
15
15
|
"name": "align",
|
|
16
|
-
"description": "
|
|
16
|
+
"description": "Specify the alignment of the accordion heading title and chevron.",
|
|
17
17
|
"value": {
|
|
18
18
|
"kind": "expression",
|
|
19
19
|
"type": "string"
|
|
20
20
|
},
|
|
21
|
-
"default": "
|
|
21
|
+
"default": "''"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"name": "size",
|
|
25
|
-
"description": "
|
|
25
|
+
"description": "Specify the size of the Accordion",
|
|
26
26
|
"value": {
|
|
27
27
|
"kind": "expression",
|
|
28
28
|
"type": "string"
|
|
29
29
|
},
|
|
30
|
-
"default": "
|
|
30
|
+
"default": "''"
|
|
31
31
|
}
|
|
32
32
|
],
|
|
33
33
|
"events": [
|
|
34
34
|
{
|
|
35
35
|
"name": "change",
|
|
36
|
-
"description": "Triggers when
|
|
36
|
+
"description": "Triggers when state of an accordion item changes"
|
|
37
37
|
}
|
|
38
38
|
],
|
|
39
39
|
"slots": [
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"attributes": [
|
|
53
53
|
{
|
|
54
54
|
"name": "disabled",
|
|
55
|
-
"description": "disables this
|
|
55
|
+
"description": "disables this accordion item",
|
|
56
56
|
"value": {
|
|
57
57
|
"kind": "expression",
|
|
58
58
|
"type": "boolean"
|
|
@@ -60,13 +60,18 @@
|
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"name": "open",
|
|
63
|
-
"description": "
|
|
63
|
+
"description": "open state of the accordion item. available as a v-model",
|
|
64
64
|
"value": {
|
|
65
65
|
"kind": "expression",
|
|
66
66
|
"type": "boolean"
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
],
|
|
70
|
+
"events": [
|
|
71
|
+
{
|
|
72
|
+
"name": "update:open"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
70
75
|
"slots": [
|
|
71
76
|
{
|
|
72
77
|
"name": "title",
|
|
@@ -346,6 +351,7 @@
|
|
|
346
351
|
},
|
|
347
352
|
{
|
|
348
353
|
"name": "label",
|
|
354
|
+
"required": true,
|
|
349
355
|
"description": "Provide a label to provide a description of the Checkbox input that you are exposing to the user",
|
|
350
356
|
"value": {
|
|
351
357
|
"kind": "expression",
|
|
@@ -1043,6 +1049,15 @@
|
|
|
1043
1049
|
},
|
|
1044
1050
|
"default": "false"
|
|
1045
1051
|
},
|
|
1052
|
+
{
|
|
1053
|
+
"name": "expandable",
|
|
1054
|
+
"description": "Table will have expandable rows",
|
|
1055
|
+
"value": {
|
|
1056
|
+
"kind": "expression",
|
|
1057
|
+
"type": "boolean"
|
|
1058
|
+
},
|
|
1059
|
+
"default": "false"
|
|
1060
|
+
},
|
|
1046
1061
|
{
|
|
1047
1062
|
"name": "title",
|
|
1048
1063
|
"value": {
|
|
@@ -1381,6 +1396,7 @@
|
|
|
1381
1396
|
},
|
|
1382
1397
|
{
|
|
1383
1398
|
"name": "dateLabel",
|
|
1399
|
+
"description": "Date picker label",
|
|
1384
1400
|
"value": {
|
|
1385
1401
|
"kind": "expression",
|
|
1386
1402
|
"type": "string"
|
|
@@ -1389,22 +1405,16 @@
|
|
|
1389
1405
|
},
|
|
1390
1406
|
{
|
|
1391
1407
|
"name": "dateEndLabel",
|
|
1408
|
+
"description": "Date picker end label (when using kind=\"range\")",
|
|
1392
1409
|
"value": {
|
|
1393
1410
|
"kind": "expression",
|
|
1394
1411
|
"type": "string"
|
|
1395
1412
|
},
|
|
1396
1413
|
"default": "'End date'"
|
|
1397
1414
|
},
|
|
1398
|
-
{
|
|
1399
|
-
"name": "invalid",
|
|
1400
|
-
"value": {
|
|
1401
|
-
"kind": "expression",
|
|
1402
|
-
"type": "boolean"
|
|
1403
|
-
},
|
|
1404
|
-
"default": "false"
|
|
1405
|
-
},
|
|
1406
1415
|
{
|
|
1407
1416
|
"name": "disabled",
|
|
1417
|
+
"description": "If true, the date picker will be disabled",
|
|
1408
1418
|
"value": {
|
|
1409
1419
|
"kind": "expression",
|
|
1410
1420
|
"type": "boolean"
|
|
@@ -1413,6 +1423,7 @@
|
|
|
1413
1423
|
},
|
|
1414
1424
|
{
|
|
1415
1425
|
"name": "invalidMessage",
|
|
1426
|
+
"description": "Date picker text on invalid value",
|
|
1416
1427
|
"value": {
|
|
1417
1428
|
"kind": "expression",
|
|
1418
1429
|
"type": "string"
|
|
@@ -1421,6 +1432,7 @@
|
|
|
1421
1432
|
},
|
|
1422
1433
|
{
|
|
1423
1434
|
"name": "pattern",
|
|
1435
|
+
"description": "Regex pattern used for form validation, default \\d{1,2}/\\d{1,2}/\\d{4}",
|
|
1424
1436
|
"value": {
|
|
1425
1437
|
"kind": "expression",
|
|
1426
1438
|
"type": "string"
|
|
@@ -1429,6 +1441,7 @@
|
|
|
1429
1441
|
},
|
|
1430
1442
|
{
|
|
1431
1443
|
"name": "placeholder",
|
|
1444
|
+
"description": "Date picker input placeholder, shown when date picker is empty. Default 'mm/dd/yyyy'",
|
|
1432
1445
|
"value": {
|
|
1433
1446
|
"kind": "expression",
|
|
1434
1447
|
"type": "string"
|
|
@@ -1437,6 +1450,7 @@
|
|
|
1437
1450
|
},
|
|
1438
1451
|
{
|
|
1439
1452
|
"name": "calOptions",
|
|
1453
|
+
"description": "You can pass flatpickr options through this prop.\n See https://flatpickr.js.org/options/ for more details.\n Some of the options is not supported (for example, onChange, onReady, mode, nextArrow, prevArrow).\n Also, you have to pass dateFormat field in calOptions object if you use it.",
|
|
1440
1454
|
"value": {
|
|
1441
1455
|
"kind": "expression",
|
|
1442
1456
|
"type": "object"
|
|
@@ -1453,6 +1467,7 @@
|
|
|
1453
1467
|
},
|
|
1454
1468
|
{
|
|
1455
1469
|
"name": "kind",
|
|
1470
|
+
"description": "Date picker kind (also known as mode in flatpickr options).\n Possible values: 'short', 'simple', 'single', 'range'",
|
|
1456
1471
|
"value": {
|
|
1457
1472
|
"kind": "expression",
|
|
1458
1473
|
"type": "string"
|
|
@@ -3598,11 +3613,12 @@
|
|
|
3598
3613
|
},
|
|
3599
3614
|
{
|
|
3600
3615
|
"name": "label",
|
|
3616
|
+
"required": true,
|
|
3601
3617
|
"value": {
|
|
3602
3618
|
"kind": "expression",
|
|
3603
3619
|
"type": "string"
|
|
3604
3620
|
},
|
|
3605
|
-
"default": "
|
|
3621
|
+
"default": "null"
|
|
3606
3622
|
},
|
|
3607
3623
|
{
|
|
3608
3624
|
"name": "value",
|
|
@@ -3650,6 +3666,22 @@
|
|
|
3650
3666
|
"kind": "expression",
|
|
3651
3667
|
"type": "boolean"
|
|
3652
3668
|
}
|
|
3669
|
+
},
|
|
3670
|
+
{
|
|
3671
|
+
"name": "legendText",
|
|
3672
|
+
"required": true,
|
|
3673
|
+
"value": {
|
|
3674
|
+
"kind": "expression",
|
|
3675
|
+
"type": "string"
|
|
3676
|
+
},
|
|
3677
|
+
"default": "null"
|
|
3678
|
+
},
|
|
3679
|
+
{
|
|
3680
|
+
"name": "hideLegend",
|
|
3681
|
+
"value": {
|
|
3682
|
+
"kind": "expression",
|
|
3683
|
+
"type": "boolean"
|
|
3684
|
+
}
|
|
3653
3685
|
}
|
|
3654
3686
|
],
|
|
3655
3687
|
"events": [
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/vue",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.14",
|
|
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",
|
|
8
8
|
"types": "src/index.d.ts",
|
|
9
9
|
"web-types": "dist/web-types.json",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"_postinstall": "node prepare.js && node .storybook/postinstall.js",
|
|
11
|
+
"_postinstall": "node prepare.js && node .storybook/postinstall.js && ibmtelemetry --config=telemetry.yml",
|
|
12
12
|
"prepack": "pinst --disable",
|
|
13
13
|
"postpack": "pinst --enable",
|
|
14
14
|
"build": "vue-cli-service build --target lib --name carbon-vue-3 ./src/index.js --no-clean",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@carbon/icons-vue": "^10.60.0",
|
|
32
|
+
"@ibm/telemetry-js": "^1.2.1",
|
|
32
33
|
"@vueuse/core": "^4.11.2",
|
|
33
34
|
"carbon-components": "^10.58.5",
|
|
34
35
|
"eslint-plugin-prettier-vue": "^4.2.0",
|
|
@@ -157,7 +158,8 @@
|
|
|
157
158
|
},
|
|
158
159
|
"files": [
|
|
159
160
|
"/dist",
|
|
160
|
-
"/src"
|
|
161
|
+
"/src",
|
|
162
|
+
"telemetry.yml"
|
|
161
163
|
],
|
|
162
164
|
"commitlint": {
|
|
163
165
|
"extends": [
|
|
@@ -174,5 +176,5 @@
|
|
|
174
176
|
"url": "git+https://github.com/carbon-design-system/carbon-components-vue.git"
|
|
175
177
|
},
|
|
176
178
|
"sideEffects": true,
|
|
177
|
-
"gitHead": "
|
|
179
|
+
"gitHead": "dd069f41ff788b4698a23fe9bfbc12874be40843"
|
|
178
180
|
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
3
|
+
import { CvAccordion, CvAccordionItem } from '.';
|
|
4
|
+
import { alignConsts, sizeConsts } from './consts';
|
|
5
|
+
import {
|
|
6
|
+
sbCompPrefix,
|
|
7
|
+
storyParametersObject,
|
|
8
|
+
} from '../../global/storybook-utils';
|
|
9
|
+
import { ref } from 'vue';
|
|
10
|
+
const open = ref({
|
|
11
|
+
accItem1: false,
|
|
12
|
+
accItem2: false,
|
|
13
|
+
accItem3: false,
|
|
14
|
+
accItem4: false,
|
|
15
|
+
});
|
|
16
|
+
const disabledItems = ref(new Set())
|
|
17
|
+
function onToggleEpisode3(){
|
|
18
|
+
if (disabledItems.value.has(3)) disabledItems.value.delete(3)
|
|
19
|
+
else disabledItems.value.add(3)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
<Meta title={`${sbCompPrefix}/CvAccordion`} component={CvAccordion} />
|
|
23
|
+
|
|
24
|
+
export const Template = args => ({
|
|
25
|
+
components: { CvAccordion, CvAccordionItem },
|
|
26
|
+
setup() {
|
|
27
|
+
return {
|
|
28
|
+
...args,
|
|
29
|
+
align: alignConsts[alignConsts.$labels[args.align]],
|
|
30
|
+
size: sizeConsts[sizeConsts.$labels[args.size]],
|
|
31
|
+
onChange: action('change'),
|
|
32
|
+
disabledItems,
|
|
33
|
+
onToggleEpisode3,
|
|
34
|
+
open,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
template: args.template,
|
|
38
|
+
});
|
|
39
|
+
const template = `<cv-accordion @change="onChange" :align="align" :size="size">
|
|
40
|
+
<cv-accordion-item v-for="n in 4" :key="\`acc-item-\${n}\`" :id="n % 2 ? \`acc-item-\${n}\` : ''" :disabled="disabledItems.has(n)">
|
|
41
|
+
<template v-slot:title>Episode {{n}} </template>
|
|
42
|
+
<template v-slot:content>
|
|
43
|
+
<p>Did you hear that? They've shut down the main reactor. We'll be destroyed for sure. This is madness! We're doomed! There'll be no escape for the Princess this time. What's that? R2! R2-D2, where are you? At last! Where have you been? They're heading in this direction.</p>
|
|
44
|
+
</template>
|
|
45
|
+
</cv-accordion-item>
|
|
46
|
+
</cv-accordion>
|
|
47
|
+
<div><button @click="onToggleEpisode3">Disable Episode 3</button></div>
|
|
48
|
+
`;
|
|
49
|
+
const Default = Template.bind({});
|
|
50
|
+
Default.args = {};
|
|
51
|
+
Default.parameters = storyParametersObject(
|
|
52
|
+
Default.parameters,
|
|
53
|
+
template,
|
|
54
|
+
Default.args
|
|
55
|
+
);
|
|
56
|
+
const templateVModel = `
|
|
57
|
+
<div>
|
|
58
|
+
<cv-accordion @change="onChange" :align="align" :size="size">
|
|
59
|
+
<cv-accordion-item v-for="n in 4" :key="\`acc-item-\${n}\`" :id="\`accItem\${n}\`" v-model:open="open[\`accItem\${n}\`]">
|
|
60
|
+
<template #title>Episode {{n}} </template>
|
|
61
|
+
<template #content>
|
|
62
|
+
<p>Give us a few minutes to lock it down. Large leak...very dangerous. Who is this? What's your operating number? Boring conversation anyway. Luke! We're going to have company! Aren't you a little short to be a stormtrooper? What? Oh...the uniform.</p>
|
|
63
|
+
</template>
|
|
64
|
+
</cv-accordion-item>
|
|
65
|
+
</cv-accordion>
|
|
66
|
+
<div style="margin-top:1rem; background-color: #888888; padding:1rem"><div style="font-size: 150%">Sample interaction</div>
|
|
67
|
+
<label for="checkbox">V-model: Check 1:</label>
|
|
68
|
+
<input id="checkbox" type="checkbox" v-model="open.accItem1"/>
|
|
69
|
+
<span>Checked: <span style="font-weight: bold;">{{open.accItem1}}</span></span><br/>
|
|
70
|
+
<label for="checkbox">V-model: Check 2:</label>
|
|
71
|
+
<input id="checkbox" type="checkbox" v-model="open.accItem2"/>
|
|
72
|
+
<span>Checked: <span style="font-weight: bold;">{{open.accItem2}}</span></span><br/>
|
|
73
|
+
<label for="checkbox">V-model: Check 3:</label>
|
|
74
|
+
<input id="checkbox" type="checkbox" v-model="open.accItem3"/>
|
|
75
|
+
<span>Checked: <span style="font-weight: bold;">{{open.accItem3}}</span></span><br/>
|
|
76
|
+
<label for="checkbox">V-model: Check 4:</label>
|
|
77
|
+
<input id="checkbox" type="checkbox" v-model="open.accItem4"/>
|
|
78
|
+
<span>Checked: <span style="font-weight: bold;">{{open.accItem4}}</span></span>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
# CvAccordion
|
|
84
|
+
|
|
85
|
+
<Canvas>
|
|
86
|
+
<Story
|
|
87
|
+
name="Default"
|
|
88
|
+
parameters={{
|
|
89
|
+
docs: { source: { code: template } },
|
|
90
|
+
controls: {
|
|
91
|
+
include: ['align', 'size'],
|
|
92
|
+
},
|
|
93
|
+
}}
|
|
94
|
+
args={{
|
|
95
|
+
template: template,
|
|
96
|
+
}}
|
|
97
|
+
argTypes={{
|
|
98
|
+
align: {
|
|
99
|
+
control: 'select',
|
|
100
|
+
options: Object.keys(alignConsts.$labels),
|
|
101
|
+
},
|
|
102
|
+
size: {
|
|
103
|
+
control: 'select',
|
|
104
|
+
options: Object.keys(sizeConsts.$labels),
|
|
105
|
+
},
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
{Template.bind({})}
|
|
109
|
+
</Story>
|
|
110
|
+
</Canvas>
|
|
111
|
+
|
|
112
|
+
# Control open state with v-model
|
|
113
|
+
|
|
114
|
+
- Notes: The Vue 2 component does not support v-model. One interesting implementation using this would be to create an
|
|
115
|
+
"auto close" component such that opening one section closes other sections.
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
// example auto close
|
|
119
|
+
// <cv-accordion @change="onAutoClose">
|
|
120
|
+
const open = ref({
|
|
121
|
+
accItem1: false,
|
|
122
|
+
accItem2: false,
|
|
123
|
+
accItem3: false,
|
|
124
|
+
accItem4: false,
|
|
125
|
+
});
|
|
126
|
+
function autoClose(ev) {
|
|
127
|
+
if (ev.change.open) {
|
|
128
|
+
for (let state in open.value) {
|
|
129
|
+
if (state !== ev.change.id) open.value[state] = false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
<Canvas>
|
|
136
|
+
<Story
|
|
137
|
+
name="v-model"
|
|
138
|
+
parameters={{
|
|
139
|
+
docs: { source: { code: templateVModel } },
|
|
140
|
+
controls: {
|
|
141
|
+
include: ['align', 'size'],
|
|
142
|
+
},
|
|
143
|
+
}}
|
|
144
|
+
args={{
|
|
145
|
+
template: templateVModel,
|
|
146
|
+
}}
|
|
147
|
+
argTypes={{
|
|
148
|
+
align: {
|
|
149
|
+
control: 'select',
|
|
150
|
+
default: 'end',
|
|
151
|
+
options: Object.keys(alignConsts.$labels),
|
|
152
|
+
},
|
|
153
|
+
size: {
|
|
154
|
+
control: 'select',
|
|
155
|
+
default: 'md',
|
|
156
|
+
options: Object.keys(sizeConsts.$labels),
|
|
157
|
+
},
|
|
158
|
+
}}
|
|
159
|
+
>
|
|
160
|
+
{Template.bind({})}
|
|
161
|
+
</Story>
|
|
162
|
+
</Canvas>
|
|
@@ -26,26 +26,26 @@ import { alignConsts, sizeConsts } from './consts';
|
|
|
26
26
|
|
|
27
27
|
defineProps({
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Specify the alignment of the accordion heading title and chevron.
|
|
30
30
|
*/
|
|
31
31
|
align: {
|
|
32
32
|
type: String,
|
|
33
|
-
default:
|
|
33
|
+
default: '',
|
|
34
34
|
validator: val => alignConsts.includes(val),
|
|
35
35
|
},
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Specify the size of the Accordion
|
|
38
38
|
*/
|
|
39
39
|
size: {
|
|
40
40
|
type: String,
|
|
41
|
-
default:
|
|
41
|
+
default: '',
|
|
42
42
|
validator: val => sizeConsts.includes(val),
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
const emit = defineEmits({
|
|
47
47
|
/**
|
|
48
|
-
* Triggers when
|
|
48
|
+
* Triggers when state of an accordion item changes
|
|
49
49
|
*/
|
|
50
50
|
change: payload => {
|
|
51
51
|
return (
|
|
@@ -83,6 +83,19 @@ provide('registerItem', (itemCvId, item) => {
|
|
|
83
83
|
provide('deregisterItem', itemCvId => {
|
|
84
84
|
items.delete(itemCvId);
|
|
85
85
|
});
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @typedef {Object} AccordionChangeElement
|
|
89
|
+
* @property {string} id
|
|
90
|
+
* @property {boolean} open
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {Object} AccordionChangeEvent
|
|
95
|
+
* @property {AccordionChangeElement} change
|
|
96
|
+
* @property {Array<AccordionChangeElement>} state
|
|
97
|
+
* @param ev
|
|
98
|
+
*/
|
|
86
99
|
provide('onAccItemChange', (clickedItemCvId, open) => {
|
|
87
100
|
items.get(clickedItemCvId).open = open;
|
|
88
101
|
emit('change', {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
>
|
|
16
16
|
<button
|
|
17
17
|
ref="button"
|
|
18
|
-
:disabled="disabled"
|
|
18
|
+
:disabled="disabled || null"
|
|
19
19
|
type="button"
|
|
20
20
|
:class="`${carbonPrefix}--accordion__heading`"
|
|
21
21
|
:aria-expanded="isOpen ? 'true' : 'false'"
|
|
@@ -46,18 +46,18 @@ export default {
|
|
|
46
46
|
</script>
|
|
47
47
|
|
|
48
48
|
<script setup>
|
|
49
|
-
import { onMounted, onBeforeUnmount, inject, ref } from 'vue';
|
|
49
|
+
import { onMounted, onBeforeUnmount, inject, ref, watch } from 'vue';
|
|
50
50
|
import { carbonPrefix } from '../../global/settings';
|
|
51
51
|
import { useCvId, props as propsCvId } from '../../use/cvId';
|
|
52
52
|
import { ChevronRight16 } from '@carbon/icons-vue/';
|
|
53
53
|
|
|
54
54
|
const props = defineProps({
|
|
55
55
|
/**
|
|
56
|
-
* disables this
|
|
56
|
+
* disables this accordion item
|
|
57
57
|
*/
|
|
58
58
|
disabled: Boolean,
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* open state of the accordion item. available as a v-model
|
|
61
61
|
*/
|
|
62
62
|
open: Boolean,
|
|
63
63
|
...propsCvId,
|
|
@@ -66,10 +66,21 @@ const props = defineProps({
|
|
|
66
66
|
// Accordion methods
|
|
67
67
|
const registerItem = inject('registerItem', () => {});
|
|
68
68
|
const deregisterItem = inject('deregisterItem', () => {});
|
|
69
|
-
const
|
|
69
|
+
const onAccItemChange = inject(
|
|
70
|
+
'onAccItemChange',
|
|
71
|
+
(clickedItemCvId, open) => {}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const emit = defineEmits(['update:open']);
|
|
75
|
+
watch(
|
|
76
|
+
() => props.open,
|
|
77
|
+
() => {
|
|
78
|
+
if (props.open !== isOpen.value) toggleOpen(props.open);
|
|
79
|
+
}
|
|
80
|
+
);
|
|
70
81
|
|
|
71
82
|
// Accordion item methods
|
|
72
|
-
const cvId = useCvId(props);
|
|
83
|
+
const cvId = useCvId(props, true);
|
|
73
84
|
const isOpen = ref(props.open);
|
|
74
85
|
const animation = ref('');
|
|
75
86
|
|
|
@@ -77,8 +88,9 @@ const toggleOpen = force => {
|
|
|
77
88
|
const newValue = typeof force !== 'undefined' ? force : !isOpen.value;
|
|
78
89
|
|
|
79
90
|
animation.value = newValue ? 'expanding' : 'collapsing';
|
|
91
|
+
if (newValue !== props.open) emit('update:open', newValue);
|
|
92
|
+
if (isOpen.value !== newValue) onAccItemChange(cvId.value, newValue);
|
|
80
93
|
isOpen.value = newValue;
|
|
81
|
-
onAccItemChagne(cvId.value, newValue);
|
|
82
94
|
};
|
|
83
95
|
|
|
84
96
|
const onClick = () => {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
export const alignConsts = [
|
|
1
|
+
export const alignConsts = ['', 'start', 'end'];
|
|
2
2
|
alignConsts.$labels = {
|
|
3
|
-
'
|
|
4
|
-
Start: 1,
|
|
5
|
-
End: 2,
|
|
6
|
-
'Empty string': 3,
|
|
3
|
+
'Default (end)': 0,
|
|
4
|
+
'Start (start)': 1,
|
|
5
|
+
'End (end)': 2,
|
|
7
6
|
};
|
|
8
|
-
export const sizeConsts = [
|
|
7
|
+
export const sizeConsts = ['', 'sm', 'md', 'xl'];
|
|
9
8
|
sizeConsts.$labels = {
|
|
10
|
-
'
|
|
9
|
+
'Default (md)': 0,
|
|
11
10
|
'Small (sm)': 1,
|
|
12
|
-
'
|
|
13
|
-
'
|
|
11
|
+
'Medium (md)': 2,
|
|
12
|
+
'Extra large (xl)': 3,
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
const CvAccordionConsts = { alignConsts, sizeConsts };
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
`${carbonPrefix}--tooltip--${tipPosition || 'bottom'}`,
|
|
8
8
|
`${carbonPrefix}--tooltip--align-${tipAlignment || 'center'}`,
|
|
9
9
|
]"
|
|
10
|
-
:disabled="disabled"
|
|
10
|
+
:disabled="disabled || null"
|
|
11
11
|
@click="$emit('click', $event)"
|
|
12
12
|
>
|
|
13
13
|
<span :class="`${carbonPrefix}--assistive-text`">{{ label }}</span>
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
<div
|
|
3
3
|
class="cv-checkbox"
|
|
4
4
|
:class="[
|
|
5
|
-
`${carbonPrefix}--checkbox--${inline ? 'inline' : 'wrapper'}`,
|
|
6
5
|
{ [`${carbonPrefix}--form-item`]: formItem },
|
|
6
|
+
{ [`${carbonPrefix}--checkbox--inline`]: inline },
|
|
7
|
+
{ [`${carbonPrefix}--checkbox-wrapper`]: !inline },
|
|
7
8
|
]"
|
|
8
9
|
>
|
|
9
10
|
<input
|
|
@@ -13,7 +14,6 @@
|
|
|
13
14
|
type="checkbox"
|
|
14
15
|
:class="`${carbonPrefix}--checkbox`"
|
|
15
16
|
:checked="isChecked === true"
|
|
16
|
-
:aria-checked="`${isChecked}`"
|
|
17
17
|
:value="value"
|
|
18
18
|
:disabled="disabled || null"
|
|
19
19
|
@focus="onFocus"
|
|
@@ -55,7 +55,12 @@ const props = defineProps({
|
|
|
55
55
|
/**
|
|
56
56
|
* Provide a label to provide a description of the Checkbox input that you are exposing to the user
|
|
57
57
|
*/
|
|
58
|
-
label: {
|
|
58
|
+
label: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: null,
|
|
61
|
+
required: true,
|
|
62
|
+
validator: label => !!label.length,
|
|
63
|
+
},
|
|
59
64
|
/**
|
|
60
65
|
* Specify whether the "bx--form-item" style should be applied
|
|
61
66
|
*/
|