@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.
Files changed (40) hide show
  1. package/README.md +9 -0
  2. package/dist/carbon-vue-3.common.js +216 -108
  3. package/dist/carbon-vue-3.common.js.map +1 -1
  4. package/dist/carbon-vue-3.umd.js +216 -108
  5. package/dist/carbon-vue-3.umd.js.map +1 -1
  6. package/dist/carbon-vue-3.umd.min.js +2 -2
  7. package/dist/carbon-vue-3.umd.min.js.map +1 -1
  8. package/dist/web-types.json +49 -17
  9. package/package.json +6 -4
  10. package/src/components/CvAccordion/CvAccordion.stories.mdx +162 -0
  11. package/src/components/CvAccordion/CvAccordion.vue +18 -5
  12. package/src/components/CvAccordion/CvAccordionItem.vue +19 -7
  13. package/src/components/CvAccordion/consts.js +8 -9
  14. package/src/components/CvButton/CvIconButton.vue +1 -1
  15. package/src/components/CvCheckbox/CvCheckbox.vue +8 -3
  16. package/src/components/CvComboBox/CvComboBox.vue +1 -1
  17. package/src/components/CvDataTable/CvDataTable.vue +26 -7
  18. package/src/components/CvDataTable/CvDataTableRow.vue +11 -3
  19. package/src/components/CvDataTable/_CvDataTableRowInner.vue +12 -3
  20. package/src/components/CvDataTable/cvDataTableStore.js +1 -0
  21. package/src/components/CvDatePicker/CvDatePicker.stories.js +165 -14
  22. package/src/components/CvDatePicker/CvDatePicker.vue +33 -20
  23. package/src/components/CvDropdown/CvDropdown.stories.mdx +6 -2
  24. package/src/components/CvDropdown/CvDropdown.vue +3 -3
  25. package/src/components/CvFileUploader/CvFileUploader.vue +2 -2
  26. package/src/components/CvNotification/CvToastNotification.stories.js +65 -5
  27. package/src/components/CvNotification/CvToastNotificationTemplate.mdx +17 -0
  28. package/src/components/CvNumberInput/CvNumberInput.vue +3 -3
  29. package/src/components/CvOverflowMenu/CvOverflowMenuItem.vue +2 -2
  30. package/src/components/CvProgress/CvProgress.stories.mdx +29 -7
  31. package/src/components/CvProgress/CvProgress.vue +1 -0
  32. package/src/components/CvProgress/CvProgressStep.vue +2 -0
  33. package/src/components/CvRadioButton/CvRadioButton.stories.js +20 -1
  34. package/src/components/CvRadioButton/CvRadioButton.vue +7 -5
  35. package/src/components/CvRadioButton/CvRadioGroup.vue +18 -2
  36. package/src/components/CvRadioButton/__tests__/__snapshots__/CvRadioButton.spec.js.snap +6 -4
  37. package/src/components/CvSlider/CvSlider.vue +1 -1
  38. package/src/components/CvTag/CvTag.vue +1 -1
  39. package/telemetry.yml +8 -0
  40. package/src/components/CvAccordion/CvAccordion.stories.js +0 -55
@@ -132,7 +132,7 @@
132
132
  <thead>
133
133
  <tr>
134
134
  <th
135
- v-if="hasExpandables"
135
+ v-if="hasExpandingRows"
136
136
  :class="`${carbonPrefix}--table-expand`"
137
137
  :data-previous-value="
138
138
  dataExpandAll ? 'collapsed' : 'expanded'
@@ -181,7 +181,7 @@
181
181
  </tr>
182
182
  </thead>
183
183
 
184
- <component :is="hasExpandables ? Empty : 'tbody'">
184
+ <component :is="hasExpandingRows ? Empty : 'tbody'">
185
185
  <slot name="data">
186
186
  <cv-data-table-row
187
187
  v-for="(row, rowIndex) in data"
@@ -246,8 +246,10 @@ import {
246
246
  unref,
247
247
  useSlots,
248
248
  watch,
249
+ provide,
249
250
  } from 'vue';
250
251
  import { props as propsCvId, useCvId } from '../../use/cvId';
252
+ //TODO: Remove this store and replace with provide/inject
251
253
  import store from './cvDataTableStore';
252
254
  import Empty from '../CvEmpty/_CvEmpty.vue';
253
255
 
@@ -316,6 +318,8 @@ const props = defineProps({
316
318
  * can be sorted
317
319
  */
318
320
  sortable: { type: Boolean, default: false },
321
+ /** Table will have expandable rows */
322
+ expandable: { type: Boolean, default: false },
319
323
  title: { type: String, default: undefined },
320
324
  /**
321
325
  * An array containing a list of columns
@@ -375,6 +379,25 @@ watch(() => props.rowsSelected, updateRowsSelected);
375
379
  const searchContainer = ref(null);
376
380
  const magnifier = ref(null);
377
381
  const search = ref(null);
382
+
383
+ /** @type {Ref<Set<String>>} */
384
+ const expandingRowIds = ref(new Set());
385
+ const hasExpandingRows = computed(() => {
386
+ return expandingRowIds.value.size > 0;
387
+ });
388
+ provide('expanding-row-ids', expandingRowIds);
389
+ provide('has-expanding-rows', hasExpandingRows);
390
+ onMounted(() => {
391
+ if (props.expandable) expandingRowIds.value.add('table-expand-row');
392
+ });
393
+ watch(
394
+ () => props.expandable,
395
+ () => {
396
+ if (props.expandable) expandingRowIds.value.add('table-expand-row');
397
+ else expandingRowIds.value.delete('table-expand-row');
398
+ }
399
+ );
400
+
378
401
  onMounted(() => {
379
402
  if (searchContainer.value) {
380
403
  magnifier.value?.addEventListener('blur', checkSearchFocus);
@@ -382,7 +405,6 @@ onMounted(() => {
382
405
  }
383
406
  if (props.initialSearchValue) clearSearchVisible.value = true;
384
407
  updateRowsSelected();
385
- store.setSomeExpandingRows(uid);
386
408
  });
387
409
 
388
410
  onUnmounted(() => {
@@ -428,6 +450,7 @@ const isSortable = computed(() => {
428
450
  // is any column sortable
429
451
  return props.sortable || store.someSortableHeadings(uid.value);
430
452
  });
453
+
431
454
  function isColSortable(c) {
432
455
  const col = unref(c);
433
456
  // is specific column or all sortable
@@ -439,10 +462,6 @@ const hasTableHeader = computed(() => {
439
462
  return props.title || isHelper.value;
440
463
  });
441
464
 
442
- const hasExpandables = computed(() => {
443
- return store.someExpandingRows(uid);
444
- });
445
-
446
465
  const hasOverflowMenu = computed(() => {
447
466
  return (
448
467
  props.overflowMenu === true ||
@@ -53,6 +53,7 @@ import {
53
53
  useAttrs,
54
54
  useSlots,
55
55
  watch,
56
+ inject,
56
57
  } from 'vue';
57
58
  import store from './cvDataTableStore';
58
59
  import { getBus } from '../../global/component-utils/event-bus';
@@ -63,7 +64,16 @@ const props = defineProps({
63
64
  });
64
65
  const cvId = useCvId(props, true);
65
66
 
67
+ /** @type {Ref<Set<String>>} */
68
+ const expandingRowIds = inject('expanding-row-ids', ref(new Set()));
66
69
  const dataExpandable = ref(false);
70
+ watch(dataExpandable, () => {
71
+ if (dataExpandable.value) expandingRowIds.value?.add(cvId.value);
72
+ else expandingRowIds.value?.delete(cvId.value);
73
+ });
74
+ const dataSomeExpandingRows = computed(() => {
75
+ return expandingRowIds.value?.size > 0;
76
+ });
67
77
 
68
78
  const attrs = useAttrs();
69
79
  const slots = useSlots();
@@ -118,9 +128,7 @@ watch(
118
128
  });
119
129
  }
120
130
  );
121
- const dataSomeExpandingRows = computed(() => {
122
- return store.someExpandingRows(parent);
123
- });
131
+
124
132
  function onExpandedChange(val) {
125
133
  const row = store.findRow(parent, cvId);
126
134
  store.updateRow(parent, {
@@ -21,7 +21,6 @@
21
21
  >
22
22
  <ChevronRight16 :class="`${carbonPrefix}--table-expand__svg`" />
23
23
  </button>
24
- <div v-else>{{ expandingRow }}</div>
25
24
  </td>
26
25
  <td
27
26
  v-if="hasBatchActions"
@@ -66,7 +65,15 @@ import CvCheckbox from '../CvCheckbox';
66
65
  import CvOverflowMenu from '../CvOverflowMenu';
67
66
  import CvOverflowMenuItem from '../CvOverflowMenu/CvOverflowMenuItem.vue';
68
67
  import ChevronRight16 from '@carbon/icons-vue/es/chevron--right/16';
69
- import { computed, onMounted, onUpdated, ref, useSlots, watch } from 'vue';
68
+ import {
69
+ computed,
70
+ onMounted,
71
+ onUpdated,
72
+ ref,
73
+ useSlots,
74
+ watch,
75
+ inject,
76
+ } from 'vue';
70
77
  import store from './cvDataTableStore';
71
78
  import { getBus } from '../../global/component-utils/event-bus';
72
79
 
@@ -82,8 +89,10 @@ const props = defineProps({
82
89
  rowId: { type: String, default: undefined },
83
90
  });
84
91
 
92
+ /** @type {Ref<UnwrapRef<Set<>>>} */
93
+ const expandingRowIds = inject('expanding-row-ids', ref(new Set()));
85
94
  const dataSomeExpandingRows = computed(() => {
86
- return store.someExpandingRows(parent);
95
+ return expandingRowIds.value.size > 0;
87
96
  });
88
97
 
89
98
  const overflowMenuButtons = computed(() => {
@@ -1,3 +1,4 @@
1
+ //TODO: Remove this store and replace with provide/inject
1
2
  import { reactive, unref } from 'vue';
2
3
  let loggerEnabled = false;
3
4
  try {
@@ -15,7 +15,9 @@ const initArgs = {
15
15
 
16
16
  const now = new Date();
17
17
  const tomorrow = new Date();
18
+ const nextWeek = new Date();
18
19
  tomorrow.setDate(now.getDate() + 1);
20
+ nextWeek.setDate(now.getDate() + 7);
19
21
 
20
22
  export default {
21
23
  title: `${sbCompPrefix}/CvDatePicker`,
@@ -29,11 +31,12 @@ export default {
29
31
  },
30
32
  },
31
33
  argTypes: {
32
- dateLabel: { type: String, description: 'Date picker label' },
33
- invalidMessage: {
34
+ kind: {
34
35
  type: String,
35
- description: 'Date picker text on invalid value',
36
+ options: ['short', 'simple', 'single', 'range'],
37
+ control: { type: 'select' },
36
38
  },
39
+ calOptions: { type: Object },
37
40
  },
38
41
  };
39
42
 
@@ -41,7 +44,7 @@ export default {
41
44
 
42
45
  const template = `
43
46
  <div>
44
- <cv-date-picker v-bind='args' @change='onChange'>
47
+ <cv-date-picker v-bind="args" @change="onChange" :value="now">
45
48
  </cv-date-picker>
46
49
  </div>
47
50
  `;
@@ -50,6 +53,7 @@ const Template = args => {
50
53
  components: { CvDatePicker },
51
54
  setup: () => ({
52
55
  args,
56
+ now,
53
57
  onChange: action('change'),
54
58
  }),
55
59
  template,
@@ -58,6 +62,11 @@ const Template = args => {
58
62
 
59
63
  export const Default = Template.bind({});
60
64
  Default.args = initArgs;
65
+ Default.parameters = {
66
+ controls: {
67
+ exclude: ['update:modelValue', 'invalid-message', 'modelValue'],
68
+ },
69
+ };
61
70
  Default.parameters = storyParametersObject(
62
71
  Default.parameters,
63
72
  template,
@@ -66,13 +75,13 @@ Default.parameters = storyParametersObject(
66
75
 
67
76
  /* V-MODEL STORY */
68
77
 
69
- const modelValue = ref('');
78
+ const modelValue = ref(now);
70
79
  const templateVModel = `
71
80
  <div>
72
- <cv-date-picker v-bind='args' @change='onChange' v-model="modelValue">
81
+ <cv-date-picker v-bind="args" @change="onChange" v-model="modelValue">
73
82
  </cv-date-picker>
74
83
  </div>
75
- <div style="margin: 32px 0;">
84
+ <div style="margin-top:2rem; background-color: #888888; padding:1rem">
76
85
  <div style="font-size: 150%;">Sample interaction</div>
77
86
  <label for="date-model" style='margin-right: 0.5rem'>V-model:</label>
78
87
  <input id="date-model" type="text" :value="modelValue.startDate || modelValue" @change="ev => { if (args.kind === 'range') { modelValue.startDate = ev.currentTarget.value } else { modelValue = ev.currentTarget.value } }"/>
@@ -95,6 +104,11 @@ const TemplateVModel = args => {
95
104
 
96
105
  export const vModel = TemplateVModel.bind({});
97
106
  vModel.args = initArgs;
107
+ vModel.parameters = {
108
+ controls: {
109
+ exclude: ['update:modelValue', 'invalid-message', 'modelValue'],
110
+ },
111
+ };
98
112
  vModel.parameters = storyParametersObject(
99
113
  vModel.parameters,
100
114
  templateVModel,
@@ -105,7 +119,7 @@ vModel.parameters = storyParametersObject(
105
119
 
106
120
  const templateInvalidMessage = `
107
121
  <div>
108
- <cv-date-picker v-bind='args' @change='onChange'>
122
+ <cv-date-picker v-bind="args" @change="onChange" :value="now">
109
123
  </cv-date-picker>
110
124
  </div>
111
125
  `;
@@ -115,6 +129,7 @@ const TemplateInvalidMessage = args => {
115
129
  components: { CvDatePicker },
116
130
  setup: () => ({
117
131
  args,
132
+ now,
118
133
  onChange: action('change'),
119
134
  }),
120
135
  template: templateInvalidMessage,
@@ -123,12 +138,22 @@ const TemplateInvalidMessage = args => {
123
138
 
124
139
  export const InvalidMessage = TemplateInvalidMessage.bind({});
125
140
  InvalidMessage.args = { ...initArgs, invalidMessage: 'Invalid date' };
141
+ InvalidMessage.parameters = {
142
+ controls: {
143
+ include: ['invalidMessage'],
144
+ },
145
+ };
146
+ InvalidMessage.parameters = storyParametersObject(
147
+ InvalidMessage.parameters,
148
+ templateInvalidMessage,
149
+ InvalidMessage.args
150
+ );
126
151
 
127
152
  /* INVALID MESSAGE SLOT STORY */
128
153
 
129
154
  const templateInvalidMessageSlot = `
130
155
  <div>
131
- <cv-date-picker v-bind='args' @change='onChange'>
156
+ <cv-date-picker v-bind="args" @change="onChange" :value="now">
132
157
  <template #invalid-message>Invalid date slot</template>
133
158
  </cv-date-picker>
134
159
  </div>
@@ -139,6 +164,7 @@ const TemplateInvalidMessageSlot = args => {
139
164
  components: { CvDatePicker },
140
165
  setup: () => ({
141
166
  args,
167
+ now,
142
168
  onChange: action('change'),
143
169
  }),
144
170
  template: templateInvalidMessageSlot,
@@ -147,13 +173,35 @@ const TemplateInvalidMessageSlot = args => {
147
173
 
148
174
  export const InvalidMessageSlot = TemplateInvalidMessageSlot.bind({});
149
175
  InvalidMessageSlot.args = initArgs;
176
+ InvalidMessageSlot.parameters = {
177
+ controls: {
178
+ include: [],
179
+ },
180
+ docs: {
181
+ description: {
182
+ story: `Use slot to set invalid message \`<template #invalid-message>Invalid date slot</template>\``,
183
+ },
184
+ },
185
+ };
186
+ InvalidMessageSlot.parameters = storyParametersObject(
187
+ InvalidMessageSlot.parameters,
188
+ templateInvalidMessageSlot,
189
+ InvalidMessageSlot.args
190
+ );
150
191
 
151
192
  /* SINGLE USING DATE STORY */
152
193
 
194
+ const singleValue = ref(now);
153
195
  const templateSingleUsingDate = `
154
196
  <div>
155
- <cv-date-picker v-bind='args' @change='onChange' kind="single" :value="now">
197
+ <cv-date-picker v-bind="args" @change="onChange" kind="single" v-model="singleValue">
156
198
  </cv-date-picker>
199
+ </div>`;
200
+ const templateSingleUsingDateVModel = `
201
+ <div style="margin-top:2rem; background-color: #888888; padding:1rem">
202
+ <div style="font-size: 150%;">Sample interaction</div>
203
+ <label for="date-model" style='margin-right: 0.5rem'>V-model:</label>
204
+ <input id="date-model" type="text" :value="singleValue" @change="ev => { singleValue = ev.currentTarget.value }"/>
157
205
  </div>
158
206
  `;
159
207
 
@@ -163,20 +211,90 @@ const TemplateSingleUsingDate = args => {
163
211
  setup: () => ({
164
212
  args,
165
213
  now,
214
+ singleValue,
166
215
  onChange: action('change'),
167
216
  }),
168
- template: templateSingleUsingDate,
217
+ template: templateSingleUsingDate + templateSingleUsingDateVModel,
169
218
  };
170
219
  };
171
220
 
172
221
  export const SingleUsingDate = TemplateSingleUsingDate.bind({});
173
222
  SingleUsingDate.args = initArgs;
223
+ SingleUsingDate.parameters = {
224
+ controls: {
225
+ include: ['dateLabel', 'disabled', 'invalidMessage', 'placeholder'],
226
+ },
227
+ docs: {
228
+ description: {
229
+ story: `Example of single date input with v-model`,
230
+ },
231
+ },
232
+ };
233
+ SingleUsingDate.parameters = storyParametersObject(
234
+ SingleUsingDate.parameters,
235
+ templateSingleUsingDate,
236
+ SingleUsingDate.args
237
+ );
238
+
239
+ /* SINGLE USING MIN MAX PARAMS STORY */
240
+
241
+ const templateSingleUsingMinMax = `
242
+ <div>
243
+ <cv-date-picker v-bind='args' @change="onChange" kind="single" :value="now" :cal-options="calOptions">
244
+ </cv-date-picker>
245
+ </div>
246
+ `;
247
+
248
+ const TemplateSingleUsingMinMax = args => {
249
+ return {
250
+ components: { CvDatePicker },
251
+ setup: () => ({
252
+ args,
253
+ now,
254
+ calOptions: {
255
+ minDate: now,
256
+ maxDate: nextWeek,
257
+ dateFormat: 'm/d/Y',
258
+ },
259
+ onChange: action('change'),
260
+ }),
261
+ template: templateSingleUsingMinMax,
262
+ };
263
+ };
264
+
265
+ const codeMinMax = `
266
+ const now = new Date();
267
+ const nextWeek = new Date();
268
+ nextWeek.setDate(now.getDate() + 7);
269
+ const calOptions = ref({
270
+ minDate: now,
271
+ maxDate: nextWeek,
272
+ dateFormat: 'm/d/Y'
273
+ })
274
+ ${templateSingleUsingMinMax}
275
+ `;
276
+ const docMinMax = `Example showing how "calOptions" prop can be used to control the min/max date.`;
277
+ export const SingleUsingMinMax = TemplateSingleUsingMinMax.bind({});
278
+ SingleUsingMinMax.args = initArgs;
279
+
280
+ SingleUsingMinMax.parameters = {
281
+ controls: {
282
+ exclude: ['update:modelValue', 'invalid-message', 'modelValue', 'kind'],
283
+ },
284
+ docs: {
285
+ source: { code: codeMinMax },
286
+ description: {
287
+ story: docMinMax,
288
+ },
289
+ },
290
+ };
174
291
 
175
292
  /* RANGE USING DATE STORY */
176
293
 
177
294
  const templateRangeUsingDate = `
178
295
  <div>
179
- <cv-date-picker v-bind='args' @change='onChange' kind="range" :value="{startDate: now.toLocaleDateString(), endDate: tomorrow.toLocaleDateString()}">
296
+ <cv-date-picker v-bind="args" @change="onChange" kind="range"
297
+ :value="{startDate: now.toLocaleDateString(), endDate: tomorrow.toLocaleDateString()}">
180
298
  </cv-date-picker>
181
299
  </div>
182
300
  `;
@@ -196,12 +314,22 @@ const TemplateRangeUsingDate = args => {
196
314
 
197
315
  export const RangeUsingDate = TemplateRangeUsingDate.bind({});
198
316
  RangeUsingDate.args = initArgs;
317
+ RangeUsingDate.parameters = {
318
+ controls: {
319
+ exclude: ['update:modelValue', 'invalid-message', 'kind', 'modelValue'],
320
+ },
321
+ };
322
+ RangeUsingDate.parameters = storyParametersObject(
323
+ RangeUsingDate.parameters,
324
+ templateRangeUsingDate,
325
+ RangeUsingDate.args
326
+ );
199
327
 
200
328
  /* MINIMAL STORY */
201
329
 
202
330
  const templateMinimal = `
203
331
  <div>
204
- <cv-date-picker v-bind='args' @change='onChange'>
332
+ <cv-date-picker v-bind="args" @change="onChange" :value="now">
205
333
  </cv-date-picker>
206
334
  </div>
207
335
  `;
@@ -211,6 +339,7 @@ const TemplateMinimal = args => {
211
339
  components: { CvDatePicker },
212
340
  setup: () => ({
213
341
  args,
342
+ now,
214
343
  onChange: action('change'),
215
344
  }),
216
345
  template: templateMinimal,
@@ -218,12 +347,22 @@ const TemplateMinimal = args => {
218
347
  };
219
348
 
220
349
  export const Minimal = TemplateMinimal.bind({});
350
+ Minimal.parameters = {
351
+ controls: {
352
+ exclude: ['update:modelValue', 'invalid-message', 'modelValue'],
353
+ },
354
+ };
355
+ Minimal.parameters = storyParametersObject(
356
+ Minimal.parameters,
357
+ templateMinimal,
358
+ Minimal.args
359
+ );
221
360
 
222
361
  /* SKELETON STORY */
223
362
 
224
363
  const templateSkeleton = `
225
364
  <div>
226
- <cv-date-picker-skeleton v-bind='args'></cv-date-picker-skeleton>
365
+ <cv-date-picker-skeleton v-bind="args"></cv-date-picker-skeleton>
227
366
  </div>
228
367
  `;
229
368
 
@@ -239,3 +378,15 @@ const TemplateSkeleton = args => {
239
378
  };
240
379
 
241
380
  export const Skeleton = TemplateSkeleton.bind({});
381
+ Skeleton.args = initArgs;
382
+ Skeleton.args = initArgs;
383
+ Skeleton.parameters = {
384
+ controls: {
385
+ include: [],
386
+ },
387
+ };
388
+ Skeleton.parameters = storyParametersObject(
389
+ Skeleton.parameters,
390
+ templateSkeleton,
391
+ Skeleton.args
392
+ );
@@ -24,7 +24,7 @@
24
24
  'single',
25
25
  'range',
26
26
  ].includes(getKind),
27
- [`${carbonPrefix}--date-picker--nolabel`]: getDateLabel !== undefined,
27
+ [`${carbonPrefix}--date-picker--nolabel`]: !getDateLabel,
28
28
  }"
29
29
  >
30
30
  <label
@@ -139,13 +139,22 @@ let calendar;
139
139
 
140
140
  const props = defineProps({
141
141
  modelValue: { type: [String, Object, Array, Date], default: undefined },
142
+ /** Date picker label */
142
143
  dateLabel: { type: String, default: undefined },
144
+ /** Date picker end label (when using kind="range") */
143
145
  dateEndLabel: { type: String, default: 'End date' },
144
- invalid: { type: Boolean, default: false },
146
+ /** If true, the date picker will be disabled */
145
147
  disabled: { type: Boolean, default: false },
148
+ /** Date picker text on invalid value */
146
149
  invalidMessage: { type: String, default: undefined },
150
+ /** Regex pattern used for form validation, default \d{1,2}/\d{1,2}/\d{4} */
147
151
  pattern: { type: String, default: '\\d{1,2}/\\d{1,2}/\\d{4}' },
152
+ /** Date picker input placeholder, shown when date picker is empty. Default 'mm/dd/yyyy' */
148
153
  placeholder: { type: String, default: 'mm/dd/yyyy' },
154
+ /** You can pass flatpickr options through this prop.
155
+ See https://flatpickr.js.org/options/ for more details.
156
+ Some of the options is not supported (for example, onChange, onReady, mode, nextArrow, prevArrow).
157
+ Also, you have to pass dateFormat field in calOptions object if you use it. */
149
158
  calOptions: {
150
159
  type: Object,
151
160
  default() {
@@ -155,6 +164,8 @@ const props = defineProps({
155
164
  },
156
165
  },
157
166
  formItem: { type: Boolean, default: true },
167
+ /** Date picker kind (also known as mode in flatpickr options).
168
+ Possible values: 'short', 'simple', 'single', 'range' */
158
169
  kind: {
159
170
  type: String,
160
171
  default: 'simple',
@@ -180,18 +191,16 @@ const getKind = computed({
180
191
  },
181
192
  });
182
193
 
183
- const getDateLabel = computed({
184
- get() {
185
- if (props.kind === 'range' && !props.dateLabel) {
194
+ const getDateLabel = computed(() => {
195
+ if (props.dateLabel !== undefined) {
196
+ return props.dateLabel;
197
+ } else {
198
+ if (props.kind === 'range') {
186
199
  return 'Start date';
200
+ } else {
201
+ return 'Date';
187
202
  }
188
-
189
- if (!props.dateLabel) {
190
- return 'Date label';
191
- }
192
-
193
- return props.dateLabel;
194
- },
203
+ }
195
204
  });
196
205
 
197
206
  const isRange = computed(() => {
@@ -300,6 +309,7 @@ const initFlatpickr = () => {
300
309
  };
301
310
 
302
311
  let dateToString = val => {
312
+ if (!val) return '';
303
313
  return calendar.formatDate(val, props.calOptions.dateFormat);
304
314
  };
305
315
 
@@ -336,14 +346,17 @@ const handleUpdateEvent = event => {
336
346
  };
337
347
 
338
348
  const setDate = value => {
339
- if (!value) return;
340
-
341
- if (isSingle.value) {
342
- calendar.setDate(value, true);
343
- } else if (isRange.value) {
344
- calendar.setDate([value.startDate, value.endDate], true);
345
- } else {
346
- date.value.value = value;
349
+ try {
350
+ if (value === undefined) return;
351
+ if (isSingle.value) {
352
+ calendar.setDate(value, true);
353
+ } else if (isRange.value) {
354
+ calendar.setDate([value.startDate, value.endDate], true);
355
+ } else {
356
+ date.value.value = value;
357
+ }
358
+ } catch (e) {
359
+ console.error('setDate', e);
347
360
  }
348
361
  };
349
362
 
@@ -150,10 +150,14 @@ const skeletonTemplate = `
150
150
  Notes:
151
151
 
152
152
  - You can place a Dropdown inline with other content by using the inline variant
153
- Migration notes:
154
- - Added the `size` option to match Carbon React
153
+
154
+ Migration notes:
155
+ - **Breaking**. The selected item contents are no longer copied directly to the "internal caption". If you are trying to style both
156
+ the drop-down item and its appearance after it is selected, please see the `internal-caption` slot. See the "Slots"
157
+ story for an example.- Added the `size` option to match Carbon React
155
158
  - Added the `warningMessage` option to match Carbon React
156
159
 
160
+
157
161
  <Canvas>
158
162
  <Story
159
163
  name="Default"
@@ -77,7 +77,7 @@
77
77
  :aria-expanded="open ? 'true' : 'false'"
78
78
  :aria-labelledby="ariaLabeledBy"
79
79
  :class="`${carbonPrefix}--list-box__field`"
80
- :disabled="disabled"
80
+ :disabled="disabled || null"
81
81
  aria-haspopup="true"
82
82
  type="button"
83
83
  >
@@ -293,9 +293,9 @@ watch(open, () => {
293
293
  });
294
294
  const ariaLabeledBy = computed(() => {
295
295
  if (props.label) {
296
- return `${uid}-label ${uid}-value`;
296
+ return `${uid.value}-label ${uid.value}-value`;
297
297
  } else {
298
- return `${uid}-value`;
298
+ return `${uid.value}-value`;
299
299
  }
300
300
  });
301
301
  const internalCaption = computed(() => {
@@ -34,7 +34,7 @@
34
34
  ref="fileInput"
35
35
  :class="`${carbonPrefix}--file-input`"
36
36
  :accept="accept"
37
- :disabled="disabled"
37
+ :disabled="disabled || null"
38
38
  type="file"
39
39
  v-bind="$attrs"
40
40
  data-file-uploader
@@ -70,7 +70,7 @@
70
70
  ref="fileInput"
71
71
  :class="`${carbonPrefix}--file-input`"
72
72
  :accept="accept"
73
- :disabled="disabled"
73
+ :disabled="disabled || null"
74
74
  type="file"
75
75
  v-bind="$attrs"
76
76
  tabindex="-1"