@carbon/vue 3.0.5-alpha.0 → 3.0.7-alpha.0
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 +16 -0
- package/dist/carbon-vue-3.common.js +22859 -11008
- package/dist/carbon-vue-3.common.js.map +1 -1
- package/dist/carbon-vue-3.css +1 -0
- package/dist/carbon-vue-3.umd.js +22859 -11008
- package/dist/carbon-vue-3.umd.js.map +1 -1
- package/dist/carbon-vue-3.umd.min.js +30 -2
- package/dist/carbon-vue-3.umd.min.js.map +1 -1
- package/package.json +5 -4
- package/src/components/CvAccordion/CvAccordion.stories.js +1 -0
- package/src/components/CvButton/CvButton.stories.js +3 -3
- package/src/components/CvButton/CvButtonSkeleton.stories.js +79 -0
- package/src/components/CvButton/CvButtonSkeleton.vue +19 -0
- package/src/components/CvButton/index.js +8 -1
- package/src/components/CvDatePicker/CvDatePicker-notes.md +86 -0
- package/src/components/CvDatePicker/CvDatePicker.stories.js +241 -0
- package/src/components/CvDatePicker/CvDatePicker.vue +402 -0
- package/src/components/CvDatePicker/CvDatePickerSkeleton.vue +106 -0
- package/src/components/CvDatePicker/index.js +4 -0
- package/src/components/CvDatePicker/plugins/appendToPlugin.js +64 -0
- package/src/components/CvDatePicker/plugins/fixEventsPlugin.js +79 -0
- package/src/components/CvDatePicker/plugins/monthSelectPlugin.js +86 -0
- package/src/components/CvDatePicker/plugins/rangePlugin.js +47 -0
- package/src/components/CvDropdown/CvDropdown.stories.mdx +407 -0
- package/src/components/CvDropdown/CvDropdown.vue +418 -0
- package/src/components/CvDropdown/CvDropdownItem.vue +86 -0
- package/src/components/CvDropdown/CvDropdownSkeleton.vue +17 -0
- package/src/components/CvDropdown/index.js +5 -0
- package/src/components/CvForm/CvForm.stories.mdx +193 -0
- package/src/components/CvForm/CvForm.vue +9 -0
- package/src/components/CvForm/CvFormGroup.vue +27 -0
- package/src/components/CvForm/CvFormItem.vue +9 -0
- package/src/components/CvForm/index.js +5 -0
- package/src/components/CvInlineLoading/CvInlineLoading.stories.mdx +87 -0
- package/src/components/CvInlineLoading/CvInlineLoading.vue +144 -0
- package/src/components/CvInlineLoading/consts.js +9 -0
- package/src/components/CvInlineLoading/index.js +4 -0
- package/src/components/CvModal/CvModal.stories.mdx +236 -0
- package/src/components/CvModal/CvModal.vue +401 -0
- package/src/components/CvModal/index.js +3 -0
- package/src/components/CvMultiSelect/CvMultiSelect.stories.mdx +333 -0
- package/src/components/CvMultiSelect/CvMultiSelect.vue +705 -0
- package/src/components/CvMultiSelect/consts.js +16 -0
- package/src/components/CvMultiSelect/index.js +3 -0
- package/src/components/CvNumberInput/CvNumberInput.stories.js +265 -0
- package/src/components/CvNumberInput/CvNumberInput.vue +227 -0
- package/src/components/CvNumberInput/CvNumberInputSkeleton.stories.js +30 -0
- package/src/components/CvNumberInput/CvNumberInputSkeleton.vue +10 -0
- package/src/components/CvNumberInput/StorybookGroupConst.js +1 -0
- package/src/components/CvNumberInput/__tests__/__snapshots__/CvNumberInput.spec.js.snap +21 -0
- package/src/components/CvNumberInput/index.js +5 -0
- package/src/components/CvTabs/CvTab.vue +77 -0
- package/src/components/CvTabs/CvTabs.stories.mdx +175 -0
- package/src/components/CvTabs/CvTabs.vue +406 -0
- package/src/components/CvTabs/CvTabsSkeleton.vue +24 -0
- package/src/components/CvTabs/_SbContainer.vue +22 -0
- package/src/components/CvTabs/index.js +5 -0
- package/src/components/CvToggle/CvToggle-Skeleton.vue +29 -0
- package/src/components/CvToggle/CvToggle.stories.js +232 -0
- package/src/components/CvToggle/CvToggle.vue +70 -0
- package/src/components/CvToggle/__tests__/__snapshots__/CvToggle.spec.js.snap +7 -0
- package/src/components/CvToggle/index.js +4 -0
- package/src/global/storybook-utils/story-source-code.js +1 -0
- package/src/use/cvInput.js +34 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
|
+
import CvMultiSelect from './CvMultiSelect.vue';
|
|
3
|
+
import { tagKinds } from '../CvTag/consts';
|
|
4
|
+
import { sbCompPrefix } from '../../global/storybook-utils';
|
|
5
|
+
import { DIRECTIONS, selectionFeedbackOptions } from './consts';
|
|
6
|
+
import { action } from '@storybook/addon-actions';
|
|
7
|
+
import { ref } from 'vue';
|
|
8
|
+
const myValue = ref(['iran_deckard']);
|
|
9
|
+
const pkdCharacters = [
|
|
10
|
+
'Rick Deckard',
|
|
11
|
+
'Garland',
|
|
12
|
+
'Rachael Rosen',
|
|
13
|
+
'Roy Batty',
|
|
14
|
+
'Harry Bryant',
|
|
15
|
+
'Hannibal Chew',
|
|
16
|
+
'Dave Holden',
|
|
17
|
+
'Leon Kowalski',
|
|
18
|
+
'Taffey Lewis',
|
|
19
|
+
'Pris Stratton',
|
|
20
|
+
'J.F. Sebastian',
|
|
21
|
+
'Dr. Eldon Rosen',
|
|
22
|
+
'Zhora Salome',
|
|
23
|
+
'John "J.R." Isidore',
|
|
24
|
+
'Iran Deckard',
|
|
25
|
+
'Wilbur Mercer',
|
|
26
|
+
'Buster Friendly',
|
|
27
|
+
'Phil Resch',
|
|
28
|
+
];
|
|
29
|
+
const pkdOptions = pkdCharacters.map(item => {
|
|
30
|
+
const nameVal = item.replace(/\W+/g, '_').toLowerCase();
|
|
31
|
+
return {
|
|
32
|
+
name: nameVal,
|
|
33
|
+
label: item,
|
|
34
|
+
value: nameVal,
|
|
35
|
+
disabled: false,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
const pkdValues = pkdOptions.map(item => item.value);
|
|
39
|
+
|
|
40
|
+
<Meta title={`${sbCompPrefix}/CvMultiSelect`} component={CvMultiSelect} />
|
|
41
|
+
|
|
42
|
+
export const Template = args => ({
|
|
43
|
+
// Components used in your story `template` are defined in the `components` object
|
|
44
|
+
components: {
|
|
45
|
+
CvMultiSelect,
|
|
46
|
+
},
|
|
47
|
+
// The story's `args` need to be mapped into the template through the `setup()` method
|
|
48
|
+
setup() {
|
|
49
|
+
return {
|
|
50
|
+
options: args.options,
|
|
51
|
+
autoFilter: args.autoFilter,
|
|
52
|
+
autoHighlight: args.autoHighlight,
|
|
53
|
+
disabled: args.disabled,
|
|
54
|
+
filterTagKind: args.filterTagKind,
|
|
55
|
+
inline: args.inline,
|
|
56
|
+
invalidMessage: args.invalidMessage,
|
|
57
|
+
helperText: args.helperText,
|
|
58
|
+
title: args.title,
|
|
59
|
+
label: args.label,
|
|
60
|
+
highlight: args.highlight,
|
|
61
|
+
value: args.value,
|
|
62
|
+
selectionFeedback: args.selectionFeedback,
|
|
63
|
+
filterable: args.filterable,
|
|
64
|
+
light: args.light,
|
|
65
|
+
direction: args.direction,
|
|
66
|
+
warningMessage: args.warningMessage,
|
|
67
|
+
slotInvalidText: args.slotInvalidText,
|
|
68
|
+
slotWarningText: args.slotWarningText,
|
|
69
|
+
slotHelperText: args.slotHelperText,
|
|
70
|
+
myValue: myValue,
|
|
71
|
+
onChange: action('change'),
|
|
72
|
+
onFilter: action('filter'),
|
|
73
|
+
onVmodel: action('update:value'),
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
template: args.template,
|
|
77
|
+
});
|
|
78
|
+
const defaultTemplate = `
|
|
79
|
+
<div :style="{width: '19rem', paddingTop: direction==='top' ? '90px' : undefined}">
|
|
80
|
+
<cv-multi-select
|
|
81
|
+
:autoFilter="autoFilter"
|
|
82
|
+
:autoHighlight="autoHighlight"
|
|
83
|
+
:direction="direction"
|
|
84
|
+
:disabled="disabled"
|
|
85
|
+
:filterable="filterable"
|
|
86
|
+
:filterTagKind="filterTagKind"
|
|
87
|
+
:helperText="helperText"
|
|
88
|
+
:highlight="highlight"
|
|
89
|
+
:inline="inline"
|
|
90
|
+
:invalidMessage="invalidMessage"
|
|
91
|
+
:label="label"
|
|
92
|
+
:light="light"
|
|
93
|
+
:options="options"
|
|
94
|
+
:selectionFeedback="selectionFeedback"
|
|
95
|
+
:title="title"
|
|
96
|
+
:value="value"
|
|
97
|
+
:warningMessage="warningMessage"
|
|
98
|
+
@change="onChange"
|
|
99
|
+
@filter="onFilter"
|
|
100
|
+
>
|
|
101
|
+
</cv-multi-select>
|
|
102
|
+
</div>
|
|
103
|
+
`;
|
|
104
|
+
const slotsTemplate = `
|
|
105
|
+
<div :style="{width: '19rem'}">
|
|
106
|
+
<cv-multi-select
|
|
107
|
+
:label="label"
|
|
108
|
+
:options="options"
|
|
109
|
+
:title="title"
|
|
110
|
+
@change="onChange"
|
|
111
|
+
@filter="onFilter"
|
|
112
|
+
>
|
|
113
|
+
<template v-if="slotInvalidText" v-slot:invalid-message>That is <span style="font-weight:900">NOT</span> a replicant</template>
|
|
114
|
+
<template v-if="slotWarningText" v-slot:warning-message>Are you sure that is a <span style="font-variant-caps: petite-caps;">Replicant</span></template>
|
|
115
|
+
<template v-if="slotHelperText" v-slot:helper-text>Help Rick Deckard <span style="font-variant: small-caps;">“retire”</span> rogue androids</template>
|
|
116
|
+
</cv-multi-select>
|
|
117
|
+
</div>
|
|
118
|
+
`;
|
|
119
|
+
const vModelTemplate = `
|
|
120
|
+
<div :style="{width: '19rem'}">
|
|
121
|
+
<div>current values: {{myValue}} </div>
|
|
122
|
+
<cv-multi-select
|
|
123
|
+
:label="label"
|
|
124
|
+
:options="options"
|
|
125
|
+
:title="title"
|
|
126
|
+
v-model:value="myValue"
|
|
127
|
+
@change="onChange"
|
|
128
|
+
@filter="onFilter"
|
|
129
|
+
>
|
|
130
|
+
</cv-multi-select>
|
|
131
|
+
<div style="margin-top:2rem">
|
|
132
|
+
<div>v-model:value</div>
|
|
133
|
+
<select name="cars" id="cars" v-model="myValue" multiple>
|
|
134
|
+
<option v-for="opt in options" :key="opt.value" :value="opt.value">{{opt.value}}</option>
|
|
135
|
+
</select>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
# CvMultiSelect
|
|
141
|
+
|
|
142
|
+
Migration notes:
|
|
143
|
+
|
|
144
|
+
- Added the `direction` option to match Carbon React. Note that in the similar dropdown component,
|
|
145
|
+
this property is named `up` and uses a boolean value. If you prefer the boolean here,
|
|
146
|
+
let us know in the Slack channel.
|
|
147
|
+
- Added the `warningMessage` option to match Carbon React
|
|
148
|
+
- Setting `autoFilter` to true now implies `filterable`. Previous versions required `filterable` to
|
|
149
|
+
be explicitly set to `true` for `autoFilter` to work properly.
|
|
150
|
+
- The `v-model` is different in Vue 3 than Vue 2.If you specify it you will see a error deprecation message in the log.
|
|
151
|
+
Please use `v-model:value=something` instead.
|
|
152
|
+
|
|
153
|
+
<Canvas>
|
|
154
|
+
<Story
|
|
155
|
+
name="Default"
|
|
156
|
+
parameters={{
|
|
157
|
+
controls: {
|
|
158
|
+
exclude: [
|
|
159
|
+
'change',
|
|
160
|
+
'filter',
|
|
161
|
+
'helper-text',
|
|
162
|
+
'invalid-message',
|
|
163
|
+
'modelValue',
|
|
164
|
+
'template',
|
|
165
|
+
'update:modelValue',
|
|
166
|
+
'update:value',
|
|
167
|
+
'warning-message',
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
docs: { source: { code: defaultTemplate } },
|
|
171
|
+
}}
|
|
172
|
+
args={{
|
|
173
|
+
template: defaultTemplate,
|
|
174
|
+
options: pkdOptions,
|
|
175
|
+
light: false,
|
|
176
|
+
label: 'Choose replicants',
|
|
177
|
+
helperText: 'Do Androids Dream of Electric Sheep?',
|
|
178
|
+
title: 'Characters',
|
|
179
|
+
}}
|
|
180
|
+
argTypes={{
|
|
181
|
+
filterTagKind: {
|
|
182
|
+
control: 'select',
|
|
183
|
+
default: 'high-contrast',
|
|
184
|
+
options: tagKinds,
|
|
185
|
+
},
|
|
186
|
+
highlight: {
|
|
187
|
+
control: 'select',
|
|
188
|
+
default: undefined,
|
|
189
|
+
options: ['', ...pkdValues],
|
|
190
|
+
},
|
|
191
|
+
selectionFeedback: {
|
|
192
|
+
control: 'select',
|
|
193
|
+
default: 'top-after-reopen',
|
|
194
|
+
options: selectionFeedbackOptions,
|
|
195
|
+
table: { defaultValue: { summary: 'top-after-reopen' } },
|
|
196
|
+
},
|
|
197
|
+
light: {
|
|
198
|
+
description: '`true` to use the light version.',
|
|
199
|
+
table: { category: 'props', defaultValue: { summary: false } },
|
|
200
|
+
},
|
|
201
|
+
direction: {
|
|
202
|
+
control: 'select',
|
|
203
|
+
default: 'bottom',
|
|
204
|
+
options: DIRECTIONS,
|
|
205
|
+
table: { defaultValue: { summary: 'bottom' } },
|
|
206
|
+
},
|
|
207
|
+
options: {
|
|
208
|
+
description: `options in the form [{ label: '', value: '', name: '', disabled: false}]`,
|
|
209
|
+
control: 'inline-radio',
|
|
210
|
+
options: [],
|
|
211
|
+
},
|
|
212
|
+
value: {
|
|
213
|
+
control: 'multi-select',
|
|
214
|
+
options: pkdValues,
|
|
215
|
+
},
|
|
216
|
+
}}
|
|
217
|
+
>
|
|
218
|
+
{Template.bind({})}
|
|
219
|
+
</Story>
|
|
220
|
+
</Canvas>
|
|
221
|
+
|
|
222
|
+
# Use slots with helper, invalid, & warning text
|
|
223
|
+
|
|
224
|
+
<Canvas>
|
|
225
|
+
<Story
|
|
226
|
+
name="Slots"
|
|
227
|
+
parameters={{
|
|
228
|
+
controls: {
|
|
229
|
+
exclude: [
|
|
230
|
+
'autoFilter',
|
|
231
|
+
'autoHighlight',
|
|
232
|
+
'change',
|
|
233
|
+
'direction',
|
|
234
|
+
'disabled',
|
|
235
|
+
'filter',
|
|
236
|
+
'filterTagKind',
|
|
237
|
+
'filterable',
|
|
238
|
+
'helper-text',
|
|
239
|
+
'helperText',
|
|
240
|
+
'highlight',
|
|
241
|
+
'inline',
|
|
242
|
+
'invalid-message',
|
|
243
|
+
'invalidMessage',
|
|
244
|
+
'light',
|
|
245
|
+
'modelValue',
|
|
246
|
+
'options',
|
|
247
|
+
'selectionFeedback',
|
|
248
|
+
'template',
|
|
249
|
+
'update:modelValue',
|
|
250
|
+
'update:value',
|
|
251
|
+
'value',
|
|
252
|
+
'warning-message',
|
|
253
|
+
'warningMessage',
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
docs: { source: { code: slotsTemplate } },
|
|
257
|
+
}}
|
|
258
|
+
args={{
|
|
259
|
+
template: slotsTemplate,
|
|
260
|
+
options: pkdOptions,
|
|
261
|
+
label: 'Choose replicants',
|
|
262
|
+
title: 'Characters',
|
|
263
|
+
slotInvalidText: false,
|
|
264
|
+
slotWarningText: false,
|
|
265
|
+
slotHelperText: true,
|
|
266
|
+
}}
|
|
267
|
+
argTypes={{}}
|
|
268
|
+
>
|
|
269
|
+
{Template.bind({})}
|
|
270
|
+
</Story>
|
|
271
|
+
</Canvas>
|
|
272
|
+
|
|
273
|
+
# v-model
|
|
274
|
+
|
|
275
|
+
Note: Specifying `v-model="something"` will not work. Use `v-model:value=something` instead.
|
|
276
|
+
|
|
277
|
+
<Canvas>
|
|
278
|
+
<Story
|
|
279
|
+
name="v-model"
|
|
280
|
+
parameters={{
|
|
281
|
+
controls: {
|
|
282
|
+
exclude: [
|
|
283
|
+
'autoFilter',
|
|
284
|
+
'autoHighlight',
|
|
285
|
+
'change',
|
|
286
|
+
'direction',
|
|
287
|
+
'disabled',
|
|
288
|
+
'filter',
|
|
289
|
+
'filterTagKind',
|
|
290
|
+
'filterable',
|
|
291
|
+
'helper-text',
|
|
292
|
+
'helperText',
|
|
293
|
+
'highlight',
|
|
294
|
+
'inline',
|
|
295
|
+
'invalid-message',
|
|
296
|
+
'invalidMessage',
|
|
297
|
+
'light',
|
|
298
|
+
'modelValue',
|
|
299
|
+
'options',
|
|
300
|
+
'selectionFeedback',
|
|
301
|
+
'template',
|
|
302
|
+
'update:modelValue',
|
|
303
|
+
'update:value',
|
|
304
|
+
'value',
|
|
305
|
+
'warning-message',
|
|
306
|
+
'warningMessage',
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
docs: { source: { code: vModelTemplate } },
|
|
310
|
+
}}
|
|
311
|
+
args={{
|
|
312
|
+
template: vModelTemplate,
|
|
313
|
+
options: pkdOptions,
|
|
314
|
+
light: false,
|
|
315
|
+
label: 'Choose replicants',
|
|
316
|
+
helperText: 'Do Androids Dream of Electric Sheep?',
|
|
317
|
+
title: 'Characters',
|
|
318
|
+
}}
|
|
319
|
+
argTypes={{
|
|
320
|
+
options: {
|
|
321
|
+
description: `options in the form [{ label: '', value: '', name: '', disabled: false}]`,
|
|
322
|
+
control: 'inline-radio',
|
|
323
|
+
options: [],
|
|
324
|
+
},
|
|
325
|
+
value: {
|
|
326
|
+
control: 'multi-select',
|
|
327
|
+
options: pkdValues,
|
|
328
|
+
},
|
|
329
|
+
}}
|
|
330
|
+
>
|
|
331
|
+
{Template.bind({})}
|
|
332
|
+
</Story>
|
|
333
|
+
</Canvas>
|