@coreui/vue-pro 4.10.4 → 5.0.0-alpha.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.
Files changed (79) hide show
  1. package/README.md +1 -1
  2. package/dist/components/calendar/CCalendar.d.ts +58 -32
  3. package/dist/components/calendar/utils.d.ts +11 -4
  4. package/dist/components/close-button/CCloseButton.d.ts +9 -0
  5. package/dist/components/date-picker/CDatePicker.d.ts +89 -0
  6. package/dist/components/date-range-picker/CDateRangePicker.d.ts +89 -0
  7. package/dist/components/dropdown/CDropdown.d.ts +13 -28
  8. package/dist/components/dropdown/CDropdownToggle.d.ts +19 -9
  9. package/dist/components/dropdown/types.d.ts +15 -0
  10. package/dist/components/dropdown/utils.d.ts +6 -0
  11. package/dist/components/form/CFormInput.d.ts +6 -18
  12. package/dist/components/modal/CModal.d.ts +19 -0
  13. package/dist/components/multi-select/CMultiSelect.d.ts +1 -1
  14. package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -1
  15. package/dist/components/multi-select/types.d.ts +2 -2
  16. package/dist/components/multi-select/utils.d.ts +2 -2
  17. package/dist/components/offcanvas/COffcanvas.d.ts +9 -0
  18. package/dist/components/progress/CProgress.d.ts +102 -3
  19. package/dist/components/progress/CProgressStacked.d.ts +10 -0
  20. package/dist/components/progress/index.d.ts +2 -1
  21. package/dist/components/smart-table/CSmartTable.d.ts +0 -4
  22. package/dist/components/smart-table/CSmartTableBody.d.ts +12 -1
  23. package/dist/components/smart-table/types.d.ts +2 -2
  24. package/dist/components/smart-table/utils.d.ts +4 -2
  25. package/dist/composables/index.d.ts +3 -1
  26. package/dist/composables/useDebouncedCallback.d.ts +1 -0
  27. package/dist/index.es.js +1142 -2823
  28. package/dist/index.es.js.map +1 -1
  29. package/dist/index.js +1143 -2821
  30. package/dist/index.js.map +1 -1
  31. package/package.json +14 -14
  32. package/src/components/breadcrumb/CBreadcrumb.ts +1 -0
  33. package/src/components/button/CButton.ts +5 -5
  34. package/src/components/calendar/CCalendar.ts +444 -179
  35. package/src/components/calendar/utils.ts +93 -55
  36. package/src/components/carousel/CCarousel.ts +2 -5
  37. package/src/components/close-button/CCloseButton.ts +5 -0
  38. package/src/components/date-picker/CDatePicker.ts +43 -0
  39. package/src/components/date-range-picker/CDateRangePicker.ts +140 -126
  40. package/src/components/date-range-picker/utils.ts +2 -2
  41. package/src/components/dropdown/CDropdown.ts +23 -43
  42. package/src/components/dropdown/CDropdownMenu.ts +4 -19
  43. package/src/components/dropdown/CDropdownToggle.ts +44 -38
  44. package/src/components/dropdown/types.ts +11 -0
  45. package/src/components/dropdown/utils.ts +71 -0
  46. package/src/components/form/CFormCheck.ts +1 -1
  47. package/src/components/modal/CModal.ts +15 -1
  48. package/src/components/multi-select/CMultiSelect.ts +68 -62
  49. package/src/components/multi-select/CMultiSelectOptions.ts +1 -1
  50. package/src/components/multi-select/CMultiSelectSelection.ts +14 -13
  51. package/src/components/multi-select/types.ts +2 -2
  52. package/src/components/multi-select/utils.ts +5 -5
  53. package/src/components/navbar/CNavbar.ts +1 -1
  54. package/src/components/offcanvas/COffcanvas.ts +6 -0
  55. package/src/components/picker/CPicker.ts +7 -22
  56. package/src/components/progress/CProgress.ts +67 -9
  57. package/src/components/progress/CProgressBar.ts +4 -6
  58. package/src/components/progress/CProgressStacked.ts +19 -0
  59. package/src/components/progress/index.ts +3 -1
  60. package/src/components/sidebar/CSidebar.ts +1 -1
  61. package/src/components/smart-table/CSmartTable.ts +17 -12
  62. package/src/components/smart-table/CSmartTableBody.ts +30 -31
  63. package/src/components/smart-table/CSmartTableHead.ts +34 -11
  64. package/src/components/smart-table/types.ts +2 -2
  65. package/src/components/smart-table/utils.ts +41 -5
  66. package/src/components/time-picker/CTimePicker.ts +34 -63
  67. package/src/components/tooltip/CTooltip.ts +1 -1
  68. package/src/components/widgets/CWidgetStatsA.ts +1 -3
  69. package/src/components/widgets/CWidgetStatsB.ts +2 -4
  70. package/src/components/widgets/CWidgetStatsC.ts +2 -2
  71. package/src/components/widgets/CWidgetStatsD.ts +1 -1
  72. package/src/components/widgets/CWidgetStatsE.ts +1 -1
  73. package/src/components/widgets/CWidgetStatsF.ts +1 -1
  74. package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsE.spec.ts.snap +1 -1
  75. package/src/composables/index.ts +3 -1
  76. package/src/composables/useColorModes.ts +63 -0
  77. package/src/composables/useDebouncedCallback.ts +16 -0
  78. package/src/utils/getRTLPlacement.ts +1 -1
  79. package/src/utils/isObjectInArray.ts +1 -1
@@ -1,4 +1,14 @@
1
- import { cloneVNode, defineComponent, h, inject, onMounted, PropType, Ref, ref } from 'vue'
1
+ import {
2
+ cloneVNode,
3
+ computed,
4
+ defineComponent,
5
+ h,
6
+ inject,
7
+ onMounted,
8
+ PropType,
9
+ Ref,
10
+ ref,
11
+ } from 'vue'
2
12
 
3
13
  import { CButton } from '../button'
4
14
 
@@ -8,10 +18,6 @@ import type { Triggers } from '../../types'
8
18
  const CDropdownToggle = defineComponent({
9
19
  name: 'CDropdownToggle',
10
20
  props: {
11
- /**
12
- * Toggle the active state for the component.
13
- */
14
- active: Boolean,
15
21
  /**
16
22
  * Sets the color context of the component to one of CoreUI’s themed colors.
17
23
  *
@@ -40,6 +46,15 @@ const CDropdownToggle = defineComponent({
40
46
  * Toggle the disabled state for the component.
41
47
  */
42
48
  disabled: Boolean,
49
+ /**
50
+ * If a dropdown `variant` is set to `nav-item` then render the toggler as a link instead of a button.
51
+ *
52
+ * @since v5.0.0-alpha.1
53
+ */
54
+ navLink: {
55
+ type: Boolean,
56
+ default: true,
57
+ },
43
58
  /**
44
59
  * @values 'rounded', 'rounded-top', 'rounded-end', 'rounded-bottom', 'rounded-start', 'rounded-circle', 'rounded-pill', 'rounded-0', 'rounded-1', 'rounded-2', 'rounded-3'
45
60
  */
@@ -87,18 +102,10 @@ const CDropdownToggle = defineComponent({
87
102
  const visible = inject('visible') as Ref<boolean>
88
103
  const setVisible = inject('setVisible') as (_visible?: boolean) => void
89
104
 
90
- const className = [
91
- {
92
- 'dropdown-toggle': props.caret,
93
- 'dropdown-toggle-split': props.split,
94
- active: props.active,
95
- disabled: props.disabled,
96
- },
97
- ]
98
-
99
105
  const triggers = {
100
106
  ...((props.trigger === 'click' || props.trigger.includes('click')) && {
101
- onClick: () => {
107
+ onClick: (event: Event) => {
108
+ event.preventDefault()
102
109
  if (props.disabled) {
103
110
  return
104
111
  }
@@ -123,6 +130,20 @@ const CDropdownToggle = defineComponent({
123
130
  }),
124
131
  }
125
132
 
133
+ const togglerProps = computed(() => {
134
+ return {
135
+ class: {
136
+ 'nav-link': dropdownVariant === 'nav-item' && props.navLink,
137
+ 'dropdown-toggle': props.caret,
138
+ 'dropdown-toggle-split': props.split,
139
+ disabled: props.disabled,
140
+ show: visible.value,
141
+ },
142
+ 'aria-expanded': visible.value,
143
+ ...(!props.disabled && { ...triggers }),
144
+ }
145
+ })
146
+
126
147
  onMounted(() => {
127
148
  if (togglerRef.value) {
128
149
  dropdownToggleRef.value = togglerRef.value.$el
@@ -140,45 +161,30 @@ const CDropdownToggle = defineComponent({
140
161
  ...triggers,
141
162
  }),
142
163
  )
143
- : dropdownVariant === 'nav-item'
164
+ : dropdownVariant === 'nav-item' && props.navLink
144
165
  ? h(
145
166
  'a',
146
167
  {
147
- active: props.active,
148
- class: [
149
- 'nav-link',
150
- className,
151
- {
152
- show: visible.value,
153
- },
154
- ],
155
- disabled: props.disabled,
156
168
  href: '#',
169
+ ...togglerProps.value,
170
+ role: 'button',
157
171
  ref: dropdownToggleRef,
158
- ...triggers,
159
172
  },
160
173
  { default: () => slots.default && slots.default() },
161
174
  )
162
175
  : h(
163
176
  CButton,
164
177
  {
165
- class: [
166
- className,
167
- {
168
- show: visible.value,
169
- },
170
- ],
171
- active: props.active,
178
+ ...togglerProps.value,
172
179
  color: props.color,
180
+ component: props.component,
173
181
  disabled: props.disabled,
174
- ref: (el) => {
175
- togglerRef.value = el
176
- },
177
182
  shape: props.shape,
178
183
  size: props.size,
179
- ...triggers,
180
- ...(props.component === 'button' && { type: 'button' }),
181
184
  variant: props.variant,
185
+ ref: (el) => {
186
+ togglerRef.value = el
187
+ },
182
188
  },
183
189
  () =>
184
190
  props.split
@@ -0,0 +1,11 @@
1
+ export type Directions = 'start' | 'end'
2
+
3
+ export type Breakpoints =
4
+ | { xs: Directions }
5
+ | { sm: Directions }
6
+ | { md: Directions }
7
+ | { lg: Directions }
8
+ | { xl: Directions }
9
+ | { xxl: Directions }
10
+
11
+ export type Alignments = Directions | Breakpoints
@@ -0,0 +1,71 @@
1
+ import type { Placement } from '@popperjs/core'
2
+ import type { Placements } from '../../types'
3
+ import type { Alignments } from './types'
4
+
5
+ export const getAlignmentClassNames = (alignment: object | string) => {
6
+ const classNames: string[] = []
7
+ if (typeof alignment === 'object') {
8
+ Object.keys(alignment).map((key) => {
9
+ classNames.push(`dropdown-menu${key === 'xs' ? '' : `-${key}`}-${alignment[key]}`)
10
+ })
11
+ }
12
+
13
+ if (typeof alignment === 'string') {
14
+ classNames.push(`dropdown-menu-${alignment}`)
15
+ }
16
+
17
+ return classNames
18
+ }
19
+
20
+ export const getNextActiveElement = (
21
+ list: HTMLElement[],
22
+ activeElement: HTMLElement,
23
+ shouldGetNext: boolean,
24
+ isCycleAllowed: boolean,
25
+ ) => {
26
+ const listLength = list.length
27
+ let index = list.indexOf(activeElement)
28
+
29
+ if (index === -1) {
30
+ return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0]
31
+ }
32
+
33
+ index += shouldGetNext ? 1 : -1
34
+
35
+ if (isCycleAllowed) {
36
+ index = (index + listLength) % listLength
37
+ }
38
+
39
+ return list[Math.max(0, Math.min(index, listLength - 1))]
40
+ }
41
+
42
+ export const getPlacement = (
43
+ placement: Placement,
44
+ direction: string | undefined,
45
+ alignment: Alignments | string | undefined,
46
+ isRTL: boolean,
47
+ ): Placements => {
48
+ let _placement = placement
49
+
50
+ if (direction === 'dropup') {
51
+ _placement = isRTL ? 'top-end' : 'top-start'
52
+ }
53
+
54
+ if (direction === 'dropup-center') {
55
+ _placement = 'top'
56
+ }
57
+
58
+ if (direction === 'dropend') {
59
+ _placement = isRTL ? 'left-start' : 'right-start'
60
+ }
61
+
62
+ if (direction === 'dropstart') {
63
+ _placement = isRTL ? 'right-start' : 'left-start'
64
+ }
65
+
66
+ if (alignment === 'end') {
67
+ _placement = isRTL ? 'bottom-start' : 'bottom-end'
68
+ }
69
+
70
+ return _placement
71
+ }
@@ -259,4 +259,4 @@ const CFormCheck = defineComponent({
259
259
  },
260
260
  })
261
261
 
262
- export { CFormCheck }
262
+ export { CFormCheck }
@@ -51,6 +51,15 @@ const CModal = defineComponent({
51
51
  * A string of all className you want applied to the modal content component.
52
52
  */
53
53
  contentClassName: String,
54
+ /**
55
+ * Puts the focus on the modal when shown.
56
+ *
57
+ * @since v5.0.0-alpha.1
58
+ */
59
+ focus: {
60
+ type: Boolean,
61
+ default: true,
62
+ },
54
63
  /**
55
64
  * Set modal to covers the entire user viewport
56
65
  *
@@ -124,6 +133,7 @@ const CModal = defineComponent({
124
133
  'show',
125
134
  ],
126
135
  setup(props, { slots, attrs, emit }) {
136
+ const activeElementRef = ref()
127
137
  const modalRef = ref()
128
138
  const modalContentRef = ref()
129
139
  const visible = ref(props.visible)
@@ -136,6 +146,7 @@ const CModal = defineComponent({
136
146
  )
137
147
 
138
148
  const handleEnter = (el: RendererElement, done: () => void) => {
149
+ activeElementRef.value = document.activeElement as HTMLElement | null
139
150
  executeAfterTransition(() => done(), el as HTMLElement)
140
151
  document.body.classList.add('modal-open')
141
152
  document.body.style.overflow = 'hidden'
@@ -148,6 +159,7 @@ const CModal = defineComponent({
148
159
  }
149
160
 
150
161
  const handleAfterEnter = () => {
162
+ props.focus && modalRef.value?.focus()
151
163
  window.addEventListener('mousedown', handleMouseDown)
152
164
  window.addEventListener('keyup', handleKeyUp)
153
165
  }
@@ -166,6 +178,7 @@ const CModal = defineComponent({
166
178
  }
167
179
 
168
180
  const handleAfterLeave = (el: RendererElement) => {
181
+ activeElementRef.value?.focus()
169
182
  window.removeEventListener('mousedown', handleMouseDown)
170
183
  window.removeEventListener('keyup', handleKeyUp)
171
184
  el.style.display = 'none'
@@ -217,6 +230,7 @@ const CModal = defineComponent({
217
230
  h(
218
231
  'div',
219
232
  {
233
+ ...attrs,
220
234
  class: [
221
235
  'modal',
222
236
  {
@@ -224,6 +238,7 @@ const CModal = defineComponent({
224
238
  },
225
239
  attrs.class,
226
240
  ],
241
+ ...(visible.value ? { 'aria-modal': true, role: 'dialog' } : { 'aria-hidden': 'true' }),
227
242
  ref: modalRef,
228
243
  },
229
244
  h(
@@ -240,7 +255,6 @@ const CModal = defineComponent({
240
255
  [`modal-${props.size}`]: props.size,
241
256
  },
242
257
  ],
243
- role: 'dialog',
244
258
  },
245
259
  h(
246
260
  'div',
@@ -298,7 +298,7 @@ const CMultiSelect = defineComponent({
298
298
  if (
299
299
  props.allowCreateOptions &&
300
300
  filteredOptions.value.some(
301
- (option) => option.text && option.text.toLowerCase() === searchValue.value.toLowerCase(),
301
+ (option) => option.label && option.label.toLowerCase() === searchValue.value.toLowerCase(),
302
302
  )
303
303
  ) {
304
304
  return false
@@ -425,7 +425,7 @@ const CMultiSelect = defineComponent({
425
425
  selected.value = [
426
426
  ...selected.value,
427
427
  filteredOptions.value.find(
428
- (option) => String(option.text).toLowerCase() === searchValue.value.toLowerCase(),
428
+ (option) => String(option.label).toLowerCase() === searchValue.value.toLowerCase(),
429
429
  ) as Option,
430
430
  ]
431
431
  }
@@ -458,7 +458,7 @@ const CMultiSelect = defineComponent({
458
458
 
459
459
  const handleOptionClick = (option: Option) => {
460
460
  if (!props.multiple) {
461
- selected.value = [{ value: option.value, text: option.text }] as SelectedOption[]
461
+ selected.value = [option] as SelectedOption[]
462
462
  visible.value = false
463
463
 
464
464
  if (searchRef.value) {
@@ -483,10 +483,7 @@ const CMultiSelect = defineComponent({
483
483
  if (selected.value.some((_option) => _option.value === option.value)) {
484
484
  selected.value = selected.value.filter((_option) => _option.value !== option.value)
485
485
  } else {
486
- selected.value = [
487
- ...selected.value,
488
- { value: option.value, text: option.text },
489
- ] as SelectedOption[]
486
+ selected.value = [...selected.value, option] as SelectedOption[]
490
487
  }
491
488
  }
492
489
 
@@ -535,18 +532,13 @@ const CMultiSelect = defineComponent({
535
532
  'div',
536
533
  {
537
534
  class: [
538
- 'dropdown',
539
- 'picker',
540
535
  'form-multi-select',
541
536
  {
542
- 'form-multi-select-with-cleaner': props.cleaner,
543
537
  disabled: props.disabled,
544
538
  [`form-multi-select-${props.size}`]: props.size,
545
- 'form-multi-select-selection-tags':
546
- props.multiple && props.selectionType === 'tags',
547
- show: visible.value,
548
539
  'is-invalid': props.invalid,
549
540
  'is-valid': props.valid,
541
+ show: visible.value,
550
542
  },
551
543
  ],
552
544
  'aria-expanded': visible.value,
@@ -566,64 +558,78 @@ const CMultiSelect = defineComponent({
566
558
  },
567
559
  {
568
560
  default: () => [
569
- h(CMultiSelectSelection, {
570
- multiple: props.multiple,
571
- placeholder: props.placeholder,
572
- onRemove: (option: Option) =>
573
- !props.disabled && handleOptionClick(option),
574
- search: props.search,
575
- selected: selected.value,
576
- selectionType: props.selectionType,
577
- selectionTypeCounterText: props.selectionTypeCounterText,
578
- }),
579
- props.multiple &&
580
- props.cleaner &&
581
- selected.value.length > 0 &&
582
- !props.disabled &&
583
- h('button', {
584
- type: 'button',
585
- class: 'form-multi-select-selection-cleaner',
586
- onClick: () => handleDeselectAll(),
587
- }),
588
- props.search &&
589
- h('input', {
590
- type: 'text',
591
- class: 'form-multi-select-search',
592
- disabled: props.disabled,
593
- autocomplete: 'off',
594
- onInput: (event: InputEvent) => handleSearchChange(event),
595
- onKeydown: (event: KeyboardEvent) => handleSearchKeyDown(event),
596
- ...(selected.value.length === 0 && {
597
- placeholder: props.placeholder,
598
- }),
599
- ...(selected.value.length > 0 &&
600
- props.selectionType === 'counter' && {
601
- placeholder: `${selected.value.length} ${props.selectionTypeCounterText}`,
561
+ h(
562
+ CMultiSelectSelection,
563
+ {
564
+ multiple: props.multiple,
565
+ placeholder: props.placeholder,
566
+ onRemove: (option: Option) =>
567
+ !props.disabled && handleOptionClick(option),
568
+ search: props.search,
569
+ selected: selected.value,
570
+ selectionType: props.selectionType,
571
+ selectionTypeCounterText: props.selectionTypeCounterText,
572
+ },
573
+ {
574
+ default: () =>
575
+ props.search &&
576
+ h('input', {
577
+ type: 'text',
578
+ class: 'form-multi-select-search',
579
+ disabled: props.disabled,
580
+ autocomplete: 'off',
581
+ onInput: (event: InputEvent) => handleSearchChange(event),
582
+ onKeydown: (event: KeyboardEvent) => handleSearchKeyDown(event),
583
+ ...(selected.value.length === 0 && {
584
+ placeholder: props.placeholder,
585
+ }),
586
+ ...(selected.value.length > 0 &&
587
+ props.selectionType === 'counter' && {
588
+ placeholder: `${selected.value.length} ${props.selectionTypeCounterText}`,
589
+ }),
590
+ ...(selected.value.length > 0 &&
591
+ !props.multiple && {
592
+ placeholder: selected.value.map((option) => option.label)[0],
593
+ }),
594
+
595
+ ...(props.multiple &&
596
+ selected.value.length > 0 &&
597
+ props.selectionType !== 'counter' && {
598
+ size: searchValue.value.length + 2,
599
+ }),
600
+ ref: searchRef,
602
601
  }),
603
- ...(selected.value.length > 0 &&
604
- !props.multiple && {
605
- placeholder: selected.value.map((option) => option.text)[0],
602
+ },
603
+ ),
604
+ h(
605
+ 'div',
606
+ { class: 'form-multi-select-buttons' },
607
+ {
608
+ default: () => [
609
+ h('button', {
610
+ class: 'form-multi-select-cleaner',
611
+ onClick: () => handleDeselectAll(),
612
+ type: 'button',
606
613
  }),
607
-
608
- ...(props.multiple &&
609
- selected.value.length > 0 &&
610
- props.selectionType !== 'counter' && {
611
- size: searchValue.value.length + 2,
614
+ h('button', {
615
+ class: 'form-multi-select-indicator',
616
+ onClick: (event: Event) => {
617
+ event.preventDefault()
618
+ event.stopPropagation()
619
+ visible.value = !visible.value
620
+ },
621
+ type: 'button',
612
622
  }),
613
- ref: searchRef,
614
- }),
623
+ ],
624
+ },
625
+ ),
615
626
  ],
616
627
  },
617
628
  ),
618
629
  h(
619
630
  'div',
620
631
  {
621
- class: [
622
- 'dropdown-menu',
623
- {
624
- show: visible.value,
625
- },
626
- ],
632
+ class: 'form-multi-select-dropdown',
627
633
  role: 'menu',
628
634
  ref: dropdownRef,
629
635
  },
@@ -94,7 +94,7 @@ const CMultiSelectOptions = defineComponent({
94
94
  },
95
95
  props.scopedSlots && props.scopedSlots['options']
96
96
  ? h(props.scopedSlots['options'], { option: option })
97
- : option.text,
97
+ : option.label,
98
98
  )
99
99
  : [
100
100
  h(
@@ -36,7 +36,12 @@ const CMultiSelectSelection = defineComponent({
36
36
  h(
37
37
  'div',
38
38
  {
39
- class: 'form-multi-select-selection',
39
+ class: [
40
+ 'form-multi-select-selection',
41
+ {
42
+ 'form-multi-select-selection-tags': props.multiple && props.selectionType === 'tags',
43
+ },
44
+ ],
40
45
  },
41
46
  [
42
47
  props.multiple &&
@@ -54,17 +59,13 @@ const CMultiSelectSelection = defineComponent({
54
59
  props.selected.map((option: Option) => {
55
60
  if (props.selectionType === 'tags') {
56
61
  return h('span', { class: 'form-multi-select-tag' }, [
57
- option.text,
62
+ option.label,
58
63
  !option.disabled &&
59
- h(
60
- 'button',
61
- {
62
- class: 'form-multi-select-tag-delete close',
63
- ariaLabel: 'Close',
64
- onClick: () => handleRemove(option),
65
- },
66
- h('span', { ariaHidden: 'true' }, 'x'),
67
- ),
64
+ h('button', {
65
+ class: 'form-multi-select-tag-delete',
66
+ ariaLabel: 'Close',
67
+ onClick: () => handleRemove(option),
68
+ }),
68
69
  ])
69
70
  }
70
71
  return
@@ -72,9 +73,9 @@ const CMultiSelectSelection = defineComponent({
72
73
  props.multiple &&
73
74
  props.selectionType === 'text' &&
74
75
  props.selected.map((option, index) =>
75
- h('span', `${option.text}${index === props.selected.length - 1 ? '' : ','}\xA0`),
76
+ h('span', `${option.label}${index === props.selected.length - 1 ? '' : ','}\xA0`),
76
77
  ),
77
- !props.multiple && !props.search && props.selected.map((option) => option.text)[0],
78
+ !props.multiple && !props.search && props.selected.map((option) => option.label)[0],
78
79
  slots.default && slots.default(),
79
80
  ],
80
81
  )
@@ -2,7 +2,7 @@ export type Option = {
2
2
  custom?: boolean
3
3
  disabled?: boolean
4
4
  selected?: boolean
5
- text: string // TODO: change to label in v5
5
+ label: string
6
6
  value: number | string
7
7
  [key: string]: number | string | any
8
8
  }
@@ -15,7 +15,7 @@ export type OptionsGroup = {
15
15
 
16
16
  export type SelectedOption = {
17
17
  disabled?: boolean
18
- text: string
18
+ label: string
19
19
  value: number | string
20
20
  [key: string]: number | string | any
21
21
  }
@@ -1,7 +1,7 @@
1
1
  import type { Option, OptionsGroup, SelectedOption } from './types'
2
2
 
3
- export const createOption = (text: string, options: (Option | OptionsGroup)[]) => {
4
- const value = text.toLowerCase().replace(/\s/g, '-')
3
+ export const createOption = (label: string, options: (Option | OptionsGroup)[]) => {
4
+ const value = label.toLowerCase().replace(/\s/g, '-')
5
5
  let uniqueValue = value
6
6
  let i = 1
7
7
 
@@ -13,7 +13,7 @@ export const createOption = (text: string, options: (Option | OptionsGroup)[]) =
13
13
  return [
14
14
  {
15
15
  value: uniqueValue,
16
- text,
16
+ label,
17
17
  custom: true,
18
18
  },
19
19
  ]
@@ -28,10 +28,10 @@ export const filterOptionsList = (search: string, _options: (Option | OptionsGro
28
28
  option.options &&
29
29
  option.options.filter(
30
30
  (option: Option) =>
31
- option.text && option.text.toLowerCase().includes(search.toLowerCase()),
31
+ option.label && option.label.toLowerCase().includes(search.toLowerCase()),
32
32
  )
33
33
  if (
34
- (option.text && option.text.toLowerCase().includes(search.toLowerCase())) ||
34
+ (option.label && option.label.toLowerCase().includes(search.toLowerCase())) ||
35
35
  (options && options.length > 0)
36
36
  ) {
37
37
  optionsList.push(Object.assign({}, option, options && options.length > 0 && { options }))
@@ -74,13 +74,13 @@ const CNavbar = defineComponent({
74
74
  'navbar',
75
75
  {
76
76
  [`bg-${props.color}`]: props.color,
77
- [`navbar-${props.colorScheme}`]: props.colorScheme,
78
77
  [typeof props.expand === 'boolean'
79
78
  ? 'navbar-expand'
80
79
  : `navbar-expand-${props.expand}`]: props.expand,
81
80
  },
82
81
  props.placement,
83
82
  ],
83
+ ...(props.colorScheme && { 'data-coreui-theme': props.colorScheme }),
84
84
  },
85
85
  props.container
86
86
  ? h(
@@ -26,6 +26,10 @@ const COffcanvas = defineComponent({
26
26
  return false
27
27
  },
28
28
  },
29
+ /**
30
+ * Sets a darker color scheme.
31
+ */
32
+ dark: Boolean,
29
33
  /**
30
34
  * Closes the offcanvas when escape key is pressed.
31
35
  */
@@ -159,6 +163,7 @@ const COffcanvas = defineComponent({
159
163
  h(
160
164
  Transition,
161
165
  {
166
+ appear: visible.value,
162
167
  css: false,
163
168
  onEnter: (el, done) => handleEnter(el, done),
164
169
  onAfterEnter: () => handleAfterEnter(),
@@ -182,6 +187,7 @@ const COffcanvas = defineComponent({
182
187
  ref: offcanvasRef,
183
188
  role: 'dialog',
184
189
  tabindex: -1,
190
+ ...(props.dark && { 'data-coreui-theme': 'dark' }),
185
191
  },
186
192
  slots.default && slots.default(),
187
193
  ),