@carbon/vue 3.0.7-alpha.0 → 3.0.8-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 +7 -0
- package/dist/carbon-vue-3.common.js +3438 -177
- package/dist/carbon-vue-3.common.js.map +1 -1
- package/dist/carbon-vue-3.umd.js +3438 -177
- 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/package.json +7 -4
- package/src/components/CvCheckbox/CvCheckbox.stories.js +18 -7
- package/src/components/CvCheckbox/CvCheckbox.vue +19 -3
- package/src/components/CvCheckbox/CvCheckboxSkeleton.vue +16 -0
- package/src/components/CvCheckbox/__tests__/__snapshots__/CvCheckboxSkeleton.spec.js.snap +3 -0
- package/src/components/CvCheckbox/index.js +2 -1
- package/src/components/CvDropdown/CvDropdown.vue +0 -2
- package/src/components/CvFileUploader/CvFileUploader.stories.mdx +333 -0
- package/src/components/CvFileUploader/CvFileUploader.vue +286 -0
- package/src/components/CvFileUploader/CvFileUploaderItem.vue +92 -0
- package/src/components/CvFileUploader/CvFileUploaderSkeleton.vue +16 -0
- package/src/components/CvFileUploader/const.js +10 -0
- package/src/components/CvFileUploader/index.js +5 -0
- package/src/components/CvMultiSelect/CvMultiSelect.stories.mdx +1 -1
- package/src/components/CvProgress/CvProgress.stories.mdx +202 -0
- package/src/components/CvProgress/CvProgress.vue +78 -0
- package/src/components/CvProgress/CvProgressStep.vue +124 -0
- package/src/components/CvProgress/index.js +4 -0
- package/src/components/CvRadioButton/CvRadioButton.stories.js +166 -0
- package/src/components/CvRadioButton/CvRadioButton.vue +57 -0
- package/src/components/CvRadioButton/CvRadioGroup.vue +27 -0
- package/src/components/CvRadioButton/__tests__/__snapshots__/CvRadioButton.spec.js.snap +27 -0
- package/src/components/CvRadioButton/index.js +6 -0
- package/src/components/CvSearch/CvSearch.stories.mdx +168 -0
- package/src/components/CvSearch/CvSearch.vue +250 -0
- package/src/components/CvSearch/index.js +3 -0
- package/src/components/CvSelect/CvSelect.vue +27 -6
- package/src/components/CvSlider/CvSlider.stories.js +166 -0
- package/src/components/CvSlider/CvSlider.vue +324 -0
- package/src/components/CvSlider/CvSliderSkeleton.stories.js +26 -0
- package/src/components/CvSlider/CvSliderSkeleton.vue +18 -0
- package/src/components/CvSlider/__tests__/__snapshots__/CvSlider.spec.js.snap +13 -0
- package/src/components/CvSlider/__tests__/__snapshots__/CvSliderSkeleton.spec.js.snap +13 -0
- package/src/components/CvSlider/index.js +5 -0
- package/src/components/CvSlider/sbSliderPrefix.js +2 -0
- package/src/components/CvTextArea/CvTextArea.stories.js +2 -2
- package/src/components/CvTextArea/CvTextAreaSkeleton.stories.js +29 -0
- package/src/components/CvTextArea/CvTextAreaSkeleton.vue +10 -0
- package/src/components/CvTextArea/StorybookGroupConst.js +1 -0
- package/src/components/CvTextArea/__tests__/__snapshots__/CvTextAreaSkeleton.spec.js.snap +7 -0
- package/src/components/CvTextArea/index.js +2 -1
- package/src/components/CvTimePicker/CvTimePicker.stories.mdx +325 -0
- package/src/components/CvTimePicker/CvTimePicker.vue +217 -0
- package/src/components/CvTimePicker/index.js +21 -0
- package/src/components/CvToggle/CvToggle-Skeleton.vue +27 -12
- package/src/components/CvToggle/CvToggle.stories.js +20 -3
- package/src/components/CvToggle/CvToggle.vue +22 -5
- package/src/components/CvToggle/__tests__/__snapshots__/CvToggle.spec.js.snap +3 -3
- package/src/components/CvTooltip/CvDefinitionTooltip.stories.js +80 -0
- package/src/components/CvTooltip/CvDefinitionTooltip.vue +61 -0
- package/src/components/CvTooltip/CvInteractiveTooltip.stories.js +90 -0
- package/src/components/CvTooltip/CvInteractiveTooltip.vue +267 -0
- package/src/components/CvTooltip/CvTooltip.stories.js +128 -0
- package/src/components/CvTooltip/CvTooltip.vue +44 -0
- package/src/components/CvTooltip/__tests__/__snapshots__/CvTooltip.spec.js.snap +525 -0
- package/src/components/CvTooltip/consts.js +15 -0
- package/src/components/CvTooltip/index.js +6 -0
- package/src/components/CvTooltip/sbTooltipPrefix.js +2 -0
- package/src/components/CvUIShell/CvSideNav.vue +10 -1
- package/src/components/CvUIShell/CvUIShell.stories.mdx +116 -50
- package/src/index.d.ts +6 -0
- package/src/index.js +11 -0
- package/src/use/cvCheck.js +3 -0
- package/src/use/index.js +2 -0
- package/src/use/useMethods.js +18 -0
- package/src/use/useRadio.js +25 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<cv-form-item class="cv-file-uploader">
|
|
3
|
+
<p :class="`${carbonPrefix}--file--label`">{{ label }}</p>
|
|
4
|
+
<p :class="`${carbonPrefix}--label-description`">{{ helperText }}</p>
|
|
5
|
+
<div v-if="kind === 'button'" :class="`${carbonPrefix}--file`" data-file>
|
|
6
|
+
<label
|
|
7
|
+
:for="cvId"
|
|
8
|
+
:class="buttonClasses"
|
|
9
|
+
tabindex="0"
|
|
10
|
+
@keydown.enter.prevent="onKeyHit"
|
|
11
|
+
@keydown.space.prevent="onKeyHit"
|
|
12
|
+
>
|
|
13
|
+
<slot name="drop-target">{{ internalDropTargetLabel }}</slot>
|
|
14
|
+
</label>
|
|
15
|
+
<input
|
|
16
|
+
:id="cvId"
|
|
17
|
+
ref="fileInput"
|
|
18
|
+
:class="`${carbonPrefix}--file-input`"
|
|
19
|
+
:accept="accept"
|
|
20
|
+
type="file"
|
|
21
|
+
v-bind="$attrs"
|
|
22
|
+
data-file-uploader
|
|
23
|
+
data-target="[data-file-container]"
|
|
24
|
+
@change="onChange"
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
27
|
+
<div v-else :class="`${carbonPrefix}--file`" data-file>
|
|
28
|
+
<label :for="cvId">
|
|
29
|
+
<div
|
|
30
|
+
role="button"
|
|
31
|
+
tabindex="0"
|
|
32
|
+
data-file-drop-container
|
|
33
|
+
:class="[
|
|
34
|
+
`${carbonPrefix}--file-browse-btn`,
|
|
35
|
+
`${carbonPrefix}--file__drop-container`,
|
|
36
|
+
{
|
|
37
|
+
[`${carbonPrefix}--file__drop-container--drag-over`]: allowDrop,
|
|
38
|
+
},
|
|
39
|
+
]"
|
|
40
|
+
@dragover="onDragEvent"
|
|
41
|
+
@dragleave="onDragEvent"
|
|
42
|
+
@drop="onDragEvent"
|
|
43
|
+
@keydown.enter.prevent="onKeyHit"
|
|
44
|
+
@keydown.space.prevent="onKeyHit"
|
|
45
|
+
>
|
|
46
|
+
<slot name="drop-target">{{ internalDropTargetLabel }}</slot>
|
|
47
|
+
</div>
|
|
48
|
+
<input
|
|
49
|
+
:id="cvId"
|
|
50
|
+
ref="fileInput"
|
|
51
|
+
:class="`${carbonPrefix}--file-input`"
|
|
52
|
+
:accept="accept"
|
|
53
|
+
type="file"
|
|
54
|
+
v-bind="$attrs"
|
|
55
|
+
tabindex="-1"
|
|
56
|
+
data-file-uploader
|
|
57
|
+
data-target="[data-file-container]"
|
|
58
|
+
@change="onChange"
|
|
59
|
+
/>
|
|
60
|
+
</label>
|
|
61
|
+
</div>
|
|
62
|
+
<div
|
|
63
|
+
:class="`${carbonPrefix}--file ${carbonPrefix}--file-container`"
|
|
64
|
+
data-file-container
|
|
65
|
+
>
|
|
66
|
+
<cv-file-uploader-item
|
|
67
|
+
v-for="(item, index) in internalFiles"
|
|
68
|
+
:key="item.file.name"
|
|
69
|
+
:item="item"
|
|
70
|
+
:removable="removable"
|
|
71
|
+
:removeAriaLabel="removeAriaLabel"
|
|
72
|
+
@remove="onItemRemove(index)"
|
|
73
|
+
/>
|
|
74
|
+
</div>
|
|
75
|
+
</cv-form-item>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<script setup>
|
|
79
|
+
import { ref, computed, onMounted, watch } from 'vue';
|
|
80
|
+
import CvFileUploaderItem from './CvFileUploaderItem.vue';
|
|
81
|
+
import { carbonPrefix } from '../../global/settings';
|
|
82
|
+
import { CvFormItem } from '../CvForm';
|
|
83
|
+
import { useCvId, props as cvIdProps } from '../../use/cvId';
|
|
84
|
+
import { KINDS, STATES } from './const';
|
|
85
|
+
import {
|
|
86
|
+
props as commonCvButtonProps,
|
|
87
|
+
useCvButtonCommon,
|
|
88
|
+
} from '../CvButton/CvButtonCommon';
|
|
89
|
+
|
|
90
|
+
const emit = defineEmits(['update:modelValue']);
|
|
91
|
+
|
|
92
|
+
const props = defineProps({
|
|
93
|
+
accept: String,
|
|
94
|
+
buttonKind: commonCvButtonProps.kind,
|
|
95
|
+
buttonLabel: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: undefined,
|
|
98
|
+
deprecated: true,
|
|
99
|
+
validator: val => {
|
|
100
|
+
if (val !== undefined && process.env.NODE_ENV === 'development') {
|
|
101
|
+
console.warn(
|
|
102
|
+
'CvFileUploader: button-label prop deprecated in favour of drop-target-label'
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
buttonSize: commonCvButtonProps.size,
|
|
109
|
+
clearOnReselect: Boolean,
|
|
110
|
+
dropTargetLabel: String,
|
|
111
|
+
helperText: String,
|
|
112
|
+
kind: {
|
|
113
|
+
type: String,
|
|
114
|
+
default: KINDS.DRAG_TARGET,
|
|
115
|
+
validator: val => {
|
|
116
|
+
const validValues = Object.values(KINDS);
|
|
117
|
+
if (!validValues.includes(val)) {
|
|
118
|
+
console.warn(
|
|
119
|
+
`CvFileUploader: valid values for 'kind' are ${validValues}`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
label: String,
|
|
126
|
+
modelValue: Array,
|
|
127
|
+
removable: Boolean,
|
|
128
|
+
removeAriaLabel: String,
|
|
129
|
+
...cvIdProps,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// DOM Elements
|
|
133
|
+
const fileInput = ref(null);
|
|
134
|
+
|
|
135
|
+
// Data
|
|
136
|
+
const allowDrop = ref(false);
|
|
137
|
+
const internalFiles = ref([]);
|
|
138
|
+
|
|
139
|
+
// Computed
|
|
140
|
+
const { buttonClasses } = useCvButtonCommon(props.buttonKind, props.buttonSize);
|
|
141
|
+
const cvId = useCvId(props);
|
|
142
|
+
const internalDropTargetLabel = computed(() => {
|
|
143
|
+
return (
|
|
144
|
+
props.dropTargetLabel ||
|
|
145
|
+
props.buttonLabel ||
|
|
146
|
+
'Drag and drop files here or upload'
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
const isFileTypeAllowed = computed(() => {
|
|
150
|
+
const acceptAny = !props.accept;
|
|
151
|
+
const allowedTypes = props.accept
|
|
152
|
+
? props.accept.split(',').map(x => x.trim())
|
|
153
|
+
: [];
|
|
154
|
+
if (allowedTypes.includes('.jpg')) {
|
|
155
|
+
allowedTypes.push('.jpeg');
|
|
156
|
+
}
|
|
157
|
+
return file => {
|
|
158
|
+
if (acceptAny) return true;
|
|
159
|
+
const extension = '.' + file.name.split('.').pop();
|
|
160
|
+
return allowedTypes.includes(file.type) || allowedTypes.includes(extension);
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Watchers
|
|
165
|
+
watch(
|
|
166
|
+
() => props.modelValue,
|
|
167
|
+
newValue => {
|
|
168
|
+
internalFiles.value = newValue || [];
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
// Methods
|
|
173
|
+
function addFiles(files) {
|
|
174
|
+
for (const file of files) {
|
|
175
|
+
const internalFile = internalFiles.value.find(
|
|
176
|
+
item => item.file.name === file.name
|
|
177
|
+
);
|
|
178
|
+
const newFile = createInternalFile(internalFile?.file || file);
|
|
179
|
+
|
|
180
|
+
if (internalFile) {
|
|
181
|
+
internalFile.state = newFile.initialState;
|
|
182
|
+
internalFile.invalidMessageTitle = newFile.invalidMessageTitle;
|
|
183
|
+
internalFile.invalidMessage = newFile.invalidMessage;
|
|
184
|
+
} else {
|
|
185
|
+
internalFiles.value.push(newFile);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// clear input we do not need to maintain it
|
|
189
|
+
fileInput.value.value = '';
|
|
190
|
+
emit('update:modelValue', internalFiles.value);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function createInternalFile(file) {
|
|
194
|
+
const initialState = props.initialStateUploading
|
|
195
|
+
? STATES.UPLOADING
|
|
196
|
+
: STATES.NONE;
|
|
197
|
+
const isTypeNotAllowed = !isFileTypeAllowed.value(file);
|
|
198
|
+
const invalidMessageTitle = isTypeNotAllowed ? 'Invalid file type' : '';
|
|
199
|
+
const invalidMessage = isTypeNotAllowed
|
|
200
|
+
? `"${file.name}" does not have a valid file type.`
|
|
201
|
+
: '';
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
state: initialState,
|
|
205
|
+
file,
|
|
206
|
+
invalidMessageTitle,
|
|
207
|
+
invalidMessage,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function onChange(ev) {
|
|
212
|
+
if (ev.target.files.length !== 0 && props.clearOnReselect) {
|
|
213
|
+
internalFiles.value = [];
|
|
214
|
+
}
|
|
215
|
+
addFiles(ev.target.files);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function onDragEvent(evt) {
|
|
219
|
+
if (Array.prototype.indexOf.call(evt.dataTransfer.types, 'Files') === -1) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (evt.type === 'dragleave') {
|
|
224
|
+
allowDrop.value = false;
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (evt.type === 'dragover') {
|
|
229
|
+
evt.preventDefault();
|
|
230
|
+
const dropEffect = 'copy';
|
|
231
|
+
if (Array.isArray(evt.dataTransfer.types)) {
|
|
232
|
+
try {
|
|
233
|
+
// IE11 throws a "permission denied" error accessing `.effectAllowed`
|
|
234
|
+
evt.dataTransfer.effectAllowed = dropEffect;
|
|
235
|
+
} catch (e) {
|
|
236
|
+
// ignore
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
evt.dataTransfer.dropEffect = dropEffect;
|
|
240
|
+
allowDrop.value = true;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (evt.type === 'drop') {
|
|
244
|
+
evt.preventDefault();
|
|
245
|
+
addFiles(evt.dataTransfer.files);
|
|
246
|
+
allowDrop.value = false;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function onItemRemove(index) {
|
|
251
|
+
internalFiles.value.splice(index, 1);
|
|
252
|
+
emit('update:modelValue', this.internalFiles);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function onKeyHit() {
|
|
256
|
+
fileInput.value.click();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Lifecycle Hooks
|
|
260
|
+
onMounted(() => {
|
|
261
|
+
internalFiles.value = props.modelValue || [];
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// exposed methods
|
|
265
|
+
defineExpose({
|
|
266
|
+
setState(index, state) {
|
|
267
|
+
if ([STATES.COMPLETE, STATES.UPLOADING, STATES.NONE].includes(state)) {
|
|
268
|
+
internalFiles.value[index].state = state;
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
clear() {
|
|
272
|
+
internalFiles.value = [];
|
|
273
|
+
emit('update:modelValue', internalFiles);
|
|
274
|
+
},
|
|
275
|
+
setInvalidMessage(index, message) {
|
|
276
|
+
internalFiles.value[index].invalidMessage = message;
|
|
277
|
+
},
|
|
278
|
+
remove: onItemRemove,
|
|
279
|
+
});
|
|
280
|
+
</script>
|
|
281
|
+
|
|
282
|
+
<script>
|
|
283
|
+
export default {
|
|
284
|
+
inheritAttrs: false,
|
|
285
|
+
};
|
|
286
|
+
</script>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="[
|
|
4
|
+
`${carbonPrefix}--file__selected-file`,
|
|
5
|
+
{ [`${carbonPrefix}--file__selected-file--invalid`]: isInvalid },
|
|
6
|
+
]"
|
|
7
|
+
>
|
|
8
|
+
<p :class="`${carbonPrefix}--file-filename`" :title="item.file?.name">
|
|
9
|
+
{{ item.file?.name }}
|
|
10
|
+
</p>
|
|
11
|
+
<span :class="`${carbonPrefix}--file__state-container`">
|
|
12
|
+
<div
|
|
13
|
+
v-if="item.state === 'uploading'"
|
|
14
|
+
:class="`${carbonPrefix}--inline-loading__animation`"
|
|
15
|
+
>
|
|
16
|
+
<div
|
|
17
|
+
data-inline-loading-spinner
|
|
18
|
+
:class="`${carbonPrefix}--loading ${carbonPrefix}--loading--small`"
|
|
19
|
+
>
|
|
20
|
+
<svg
|
|
21
|
+
:class="`${carbonPrefix}--loading__svg`"
|
|
22
|
+
viewBox="-75 -75 150 150"
|
|
23
|
+
>
|
|
24
|
+
<circle
|
|
25
|
+
:class="`${carbonPrefix}--loading__background`"
|
|
26
|
+
cx="0"
|
|
27
|
+
cy="0"
|
|
28
|
+
r="37.5"
|
|
29
|
+
/>
|
|
30
|
+
<circle
|
|
31
|
+
:class="`${carbonPrefix}--loading__stroke`"
|
|
32
|
+
cx="0"
|
|
33
|
+
cy="0"
|
|
34
|
+
r="37.5"
|
|
35
|
+
/>
|
|
36
|
+
</svg>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<CheckmarkFilled16
|
|
40
|
+
v-if="item.state === 'complete'"
|
|
41
|
+
:class="`${carbonPrefix}--file-complete`"
|
|
42
|
+
/>
|
|
43
|
+
<WarningFilled16
|
|
44
|
+
v-if="isInvalid"
|
|
45
|
+
:class="`${carbonPrefix}--file--invalid`"
|
|
46
|
+
/>
|
|
47
|
+
<button
|
|
48
|
+
v-if="removable"
|
|
49
|
+
type="button"
|
|
50
|
+
:class="`${carbonPrefix}--file-close`"
|
|
51
|
+
:alt="removeAriaLabel"
|
|
52
|
+
:arial-label="removeAriaLabel"
|
|
53
|
+
@click="emit('remove', item)"
|
|
54
|
+
>
|
|
55
|
+
<Close16 />
|
|
56
|
+
<span :class="`${carbonPrefix}--visually-hidden`">
|
|
57
|
+
{{ removeAriaLabel }}
|
|
58
|
+
</span>
|
|
59
|
+
</button>
|
|
60
|
+
</span>
|
|
61
|
+
<!-- check role (alert) and id / accessibility -->
|
|
62
|
+
<div v-if="isInvalid" :class="`${carbonPrefix}--form-requirement`">
|
|
63
|
+
<div :class="`${carbonPrefix}--form-requirement__title`">
|
|
64
|
+
{{ item.invalidMessageTitle || 'Invalid file' }}
|
|
65
|
+
</div>
|
|
66
|
+
<p :class="`${carbonPrefix}--form-requirement__supplement`">
|
|
67
|
+
{{ item.invalidMessage }}
|
|
68
|
+
</p>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</template>
|
|
72
|
+
|
|
73
|
+
<script setup>
|
|
74
|
+
import { computed } from 'vue';
|
|
75
|
+
import { carbonPrefix } from '../../global/settings';
|
|
76
|
+
import CheckmarkFilled16 from '@carbon/icons-vue/es/checkmark--filled/16';
|
|
77
|
+
import WarningFilled16 from '@carbon/icons-vue/es/warning--filled/16';
|
|
78
|
+
import Close16 from '@carbon/icons-vue/es/close/16';
|
|
79
|
+
|
|
80
|
+
const emit = defineEmits(['remove']);
|
|
81
|
+
|
|
82
|
+
const props = defineProps({
|
|
83
|
+
item: Object,
|
|
84
|
+
removable: Boolean,
|
|
85
|
+
removeAriaLabel: { type: String, default: 'Remove selected file' },
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Computed
|
|
89
|
+
const isInvalid = computed(() => {
|
|
90
|
+
return props.item.invalidMessage && props.item.invalidMessage.length;
|
|
91
|
+
});
|
|
92
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="`${carbonPrefix}--form-item`">
|
|
3
|
+
<cv-skeleton-text heading width="100px" />
|
|
4
|
+
<cv-skeleton-text
|
|
5
|
+
width="225px"
|
|
6
|
+
:class="`${carbonPrefix}--label-description`"
|
|
7
|
+
/>
|
|
8
|
+
<cv-button-skeleton />
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import CvSkeletonText from '../CvSkeletonText';
|
|
14
|
+
import { CvButtonSkeleton } from '../CvButton';
|
|
15
|
+
import { carbonPrefix } from '../../global/settings';
|
|
16
|
+
</script>
|
|
@@ -176,6 +176,7 @@ Migration notes:
|
|
|
176
176
|
label: 'Choose replicants',
|
|
177
177
|
helperText: 'Do Androids Dream of Electric Sheep?',
|
|
178
178
|
title: 'Characters',
|
|
179
|
+
disabled: false,
|
|
179
180
|
}}
|
|
180
181
|
argTypes={{
|
|
181
182
|
filterTagKind: {
|
|
@@ -231,7 +232,6 @@ Migration notes:
|
|
|
231
232
|
'autoHighlight',
|
|
232
233
|
'change',
|
|
233
234
|
'direction',
|
|
234
|
-
'disabled',
|
|
235
235
|
'filter',
|
|
236
236
|
'filterTagKind',
|
|
237
237
|
'filterable',
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
|
+
import { CvProgress, CvProgressStep } from '.';
|
|
3
|
+
import { Time20 as TimeIcon } from '@carbon/icons-vue';
|
|
4
|
+
// noinspection ES6PreferShortImport
|
|
5
|
+
import { sbCompPrefix } from '../../global/storybook-utils';
|
|
6
|
+
import { action } from '@storybook/addon-actions';
|
|
7
|
+
|
|
8
|
+
<Meta title={`${sbCompPrefix}/CvProgress`} component={CvProgress} />
|
|
9
|
+
|
|
10
|
+
export const Template = args => ({
|
|
11
|
+
// Components used in your story `template` are defined in the `components` object
|
|
12
|
+
components: {
|
|
13
|
+
CvProgress,
|
|
14
|
+
CvProgressStep,
|
|
15
|
+
TimeIcon,
|
|
16
|
+
},
|
|
17
|
+
// The story's `args` need to be mapped into the template through the `setup()` method
|
|
18
|
+
setup() {
|
|
19
|
+
return {
|
|
20
|
+
initialStep: args.initialStep,
|
|
21
|
+
steps: args.steps,
|
|
22
|
+
vertical: args.vertical,
|
|
23
|
+
spaceEqually: args.spaceEqually,
|
|
24
|
+
step1: args.step1,
|
|
25
|
+
step2: args.step2,
|
|
26
|
+
step3: args.step3,
|
|
27
|
+
step4: args.step4,
|
|
28
|
+
step5: args.step5,
|
|
29
|
+
completeIds: args.completeIds,
|
|
30
|
+
invalidIds: args.invalidIds,
|
|
31
|
+
disabledIds: args.disabledIds,
|
|
32
|
+
onStepClicked: action('step-clicked'),
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
// And then the `args` are bound to your component with `v-bind="args"`
|
|
36
|
+
template: args.template,
|
|
37
|
+
});
|
|
38
|
+
const defaultTemplate = `
|
|
39
|
+
<cv-progress
|
|
40
|
+
:initial-step="initialStep"
|
|
41
|
+
:steps="steps"
|
|
42
|
+
:vertical="vertical"
|
|
43
|
+
:space-equally="spaceEqually"
|
|
44
|
+
@step-clicked="onStepClicked">
|
|
45
|
+
</cv-progress>
|
|
46
|
+
`;
|
|
47
|
+
const slotTemplate = `
|
|
48
|
+
<cv-progress
|
|
49
|
+
:initial-step="initialStep"
|
|
50
|
+
:vertical="vertical"
|
|
51
|
+
:spaceEqually="spaceEqually"
|
|
52
|
+
>
|
|
53
|
+
<cv-progress-step
|
|
54
|
+
id="step-1"
|
|
55
|
+
:label="step1"
|
|
56
|
+
:complete="completeIds.includes('step-1')"
|
|
57
|
+
:invalid="invalidIds.includes('step-1')"
|
|
58
|
+
:disabled="disabledIds.includes('step-1')"
|
|
59
|
+
additionalInfo="with Meg Murry"
|
|
60
|
+
description="time icon description"
|
|
61
|
+
@step-clicked="onStepClicked"
|
|
62
|
+
>
|
|
63
|
+
<template v-slot:step-icon>
|
|
64
|
+
<time-icon :class="[{['bx--progress__warning']:invalidIds.includes('step-1')}]"/>
|
|
65
|
+
</template>
|
|
66
|
+
</cv-progress-step>
|
|
67
|
+
<cv-progress-step
|
|
68
|
+
id="step-2"
|
|
69
|
+
:label="step2"
|
|
70
|
+
:complete="completeIds.includes('step-2')"
|
|
71
|
+
:invalid="invalidIds.includes('step-2')"
|
|
72
|
+
:disabled="disabledIds.includes('step-2')"
|
|
73
|
+
additionalInfo="save Charles Wallace"
|
|
74
|
+
@step-clicked="onStepClicked"
|
|
75
|
+
>
|
|
76
|
+
</cv-progress-step>
|
|
77
|
+
<cv-progress-step
|
|
78
|
+
id="step-3"
|
|
79
|
+
:label="step3"
|
|
80
|
+
:complete="completeIds.includes('step-3')"
|
|
81
|
+
:invalid="invalidIds.includes('step-3')"
|
|
82
|
+
:disabled="disabledIds.includes('step-3')"
|
|
83
|
+
additionalInfo="save the world"
|
|
84
|
+
@step-clicked="onStepClicked"
|
|
85
|
+
>
|
|
86
|
+
</cv-progress-step>
|
|
87
|
+
<cv-progress-step
|
|
88
|
+
id="step-4"
|
|
89
|
+
:label="step4"
|
|
90
|
+
:complete="completeIds.includes('step-4')"
|
|
91
|
+
:invalid="invalidIds.includes('step-4')"
|
|
92
|
+
:disabled="disabledIds.includes('step-4')"
|
|
93
|
+
additionalInfo="Twins Dennys and Sandy"
|
|
94
|
+
@step-clicked="onStepClicked"
|
|
95
|
+
>
|
|
96
|
+
</cv-progress-step>
|
|
97
|
+
<cv-progress-step
|
|
98
|
+
id="step-5"
|
|
99
|
+
:label="step5"
|
|
100
|
+
:complete="completeIds.includes('step-5')"
|
|
101
|
+
:invalid="invalidIds.includes('step-5')"
|
|
102
|
+
:disabled="disabledIds.includes('step-5')"
|
|
103
|
+
additionalInfo="with Polyhymnia O'Keefe"
|
|
104
|
+
@step-clicked="onStepClicked"
|
|
105
|
+
>
|
|
106
|
+
</cv-progress-step>
|
|
107
|
+
</cv-progress>
|
|
108
|
+
`;
|
|
109
|
+
|
|
110
|
+
# CvProgress
|
|
111
|
+
|
|
112
|
+
**Migration notes:**
|
|
113
|
+
|
|
114
|
+
- The "current" icon is updated to match Carbon React
|
|
115
|
+
- Added the property `spaceEqually` to match Carbon React
|
|
116
|
+
- The property name `initialStep` is misleading. It is treated as the Current progress (currentIndex).
|
|
117
|
+
- To override the default icons, provide an icon in the `step-icon` slot in the `cv-progress-step`
|
|
118
|
+
|
|
119
|
+
<Canvas>
|
|
120
|
+
<Story
|
|
121
|
+
name="Default"
|
|
122
|
+
parameters={{
|
|
123
|
+
controls: {
|
|
124
|
+
exclude: ['default', 'template', 'step-clicked'],
|
|
125
|
+
},
|
|
126
|
+
docs: { source: { code: defaultTemplate } },
|
|
127
|
+
}}
|
|
128
|
+
args={{
|
|
129
|
+
template: defaultTemplate,
|
|
130
|
+
steps: [
|
|
131
|
+
'Planet Uriel',
|
|
132
|
+
'The Happy Medium',
|
|
133
|
+
'The Black Thing',
|
|
134
|
+
'Rescue Dr. Murry',
|
|
135
|
+
'Rescue Charles Wallace',
|
|
136
|
+
'Back to Earth',
|
|
137
|
+
],
|
|
138
|
+
}}
|
|
139
|
+
argTypes={{
|
|
140
|
+
initialStep: {
|
|
141
|
+
control: {
|
|
142
|
+
type: 'number',
|
|
143
|
+
min: -1,
|
|
144
|
+
max: 6,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
{Template.bind({})}
|
|
150
|
+
</Story>
|
|
151
|
+
</Canvas>
|
|
152
|
+
|
|
153
|
+
# Slotted
|
|
154
|
+
|
|
155
|
+
Use `cv-progress-step` for more control over the display.
|
|
156
|
+
|
|
157
|
+
<Canvas>
|
|
158
|
+
<Story
|
|
159
|
+
name="slotted"
|
|
160
|
+
parameters={{
|
|
161
|
+
controls: {
|
|
162
|
+
exclude: ['default', 'template', 'step-clicked', 'steps'],
|
|
163
|
+
},
|
|
164
|
+
docs: { source: { code: slotTemplate } },
|
|
165
|
+
}}
|
|
166
|
+
args={{
|
|
167
|
+
template: slotTemplate,
|
|
168
|
+
step1: 'A Wrinkle in Time',
|
|
169
|
+
step2: 'A Wind in the Door',
|
|
170
|
+
step3: 'A Swiftly Tilting Planet',
|
|
171
|
+
step4: 'Many Waters',
|
|
172
|
+
step5: 'An Acceptable Time',
|
|
173
|
+
vertical: true,
|
|
174
|
+
completeIds: [],
|
|
175
|
+
invalidIds: [],
|
|
176
|
+
disabledIds: [],
|
|
177
|
+
}}
|
|
178
|
+
argTypes={{
|
|
179
|
+
initialStep: {
|
|
180
|
+
control: {
|
|
181
|
+
type: 'number',
|
|
182
|
+
min: -1,
|
|
183
|
+
max: 6,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
disabledIds: {
|
|
187
|
+
control: 'multi-select',
|
|
188
|
+
options: ['step-1', 'step-2', 'step-3', 'step-4', 'step-5'],
|
|
189
|
+
},
|
|
190
|
+
completeIds: {
|
|
191
|
+
control: 'multi-select',
|
|
192
|
+
options: ['step-1', 'step-2', 'step-3', 'step-4', 'step-5'],
|
|
193
|
+
},
|
|
194
|
+
invalidIds: {
|
|
195
|
+
control: 'multi-select',
|
|
196
|
+
options: ['step-1', 'step-2', 'step-3', 'step-4', 'step-5'],
|
|
197
|
+
},
|
|
198
|
+
}}
|
|
199
|
+
>
|
|
200
|
+
{Template.bind({})}
|
|
201
|
+
</Story>
|
|
202
|
+
</Canvas>
|