@coreui/vue-pro 4.8.2 → 4.9.0-beta.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 (226) hide show
  1. package/README.md +1 -1
  2. package/dist/components/accordion/CAccordion.d.ts +1 -1
  3. package/dist/components/accordion/CAccordionBody.d.ts +1 -1
  4. package/dist/components/accordion/CAccordionButton.d.ts +1 -1
  5. package/dist/components/accordion/CAccordionHeader.d.ts +1 -1
  6. package/dist/components/accordion/CAccordionItem.d.ts +1 -1
  7. package/dist/components/alert/CAlert.d.ts +1 -1
  8. package/dist/components/alert/CAlertHeading.d.ts +1 -1
  9. package/dist/components/alert/CAlertLink.d.ts +1 -1
  10. package/dist/components/avatar/CAvatar.d.ts +1 -1
  11. package/dist/components/backdrop/CBackdrop.d.ts +1 -1
  12. package/dist/components/badge/CBadge.d.ts +1 -1
  13. package/dist/components/breadcrumb/CBreadcrumb.d.ts +1 -1
  14. package/dist/components/breadcrumb/CBreadcrumbItem.d.ts +1 -1
  15. package/dist/components/button/CButton.d.ts +1 -1
  16. package/dist/components/button-group/CButtonGroup.d.ts +1 -1
  17. package/dist/components/button-group/CButtonToolbar.d.ts +1 -1
  18. package/dist/components/calendar/CCalendar.d.ts +33 -1
  19. package/dist/components/callout/CCallout.d.ts +1 -1
  20. package/dist/components/card/CCard.d.ts +1 -1
  21. package/dist/components/card/CCardBody.d.ts +1 -1
  22. package/dist/components/card/CCardFooter.d.ts +1 -1
  23. package/dist/components/card/CCardGroup.d.ts +1 -1
  24. package/dist/components/card/CCardHeader.d.ts +1 -1
  25. package/dist/components/card/CCardImage.d.ts +1 -1
  26. package/dist/components/card/CCardImageOverlay.d.ts +1 -1
  27. package/dist/components/card/CCardLink.d.ts +1 -1
  28. package/dist/components/card/CCardSubtitle.d.ts +1 -1
  29. package/dist/components/card/CCardText.d.ts +1 -1
  30. package/dist/components/card/CCardTitle.d.ts +1 -1
  31. package/dist/components/carousel/CCarousel.d.ts +1 -1
  32. package/dist/components/carousel/CCarouselCaption.d.ts +1 -1
  33. package/dist/components/carousel/CCarouselItem.d.ts +1 -1
  34. package/dist/components/close-button/CCloseButton.d.ts +1 -1
  35. package/dist/components/collapse/CCollapse.d.ts +1 -1
  36. package/dist/components/date-picker/CDatePicker.d.ts +35 -3
  37. package/dist/components/date-range-picker/CDateRangePicker.d.ts +89 -78
  38. package/dist/components/date-range-picker/utils.d.ts +1 -0
  39. package/dist/components/dropdown/CDropdown.d.ts +2 -2
  40. package/dist/components/dropdown/CDropdownDivider.d.ts +1 -1
  41. package/dist/components/dropdown/CDropdownHeader.d.ts +1 -1
  42. package/dist/components/dropdown/CDropdownItem.d.ts +1 -1
  43. package/dist/components/dropdown/CDropdownMenu.d.ts +1 -1
  44. package/dist/components/dropdown/CDropdownToggle.d.ts +1 -1
  45. package/dist/components/element-cover/CElementCover.d.ts +1 -1
  46. package/dist/components/footer/CFooter.d.ts +1 -1
  47. package/dist/components/form/CForm.d.ts +1 -1
  48. package/dist/components/form/CFormCheck.d.ts +10 -2
  49. package/dist/components/form/CFormControl.d.ts +2 -2
  50. package/dist/components/form/CFormControlValidation.d.ts +1 -1
  51. package/dist/components/form/CFormControlWrapper.d.ts +1 -1
  52. package/dist/components/form/CFormFeedback.d.ts +1 -1
  53. package/dist/components/form/CFormFloating.d.ts +1 -1
  54. package/dist/components/form/CFormInput.d.ts +12 -12
  55. package/dist/components/form/CFormLabel.d.ts +1 -1
  56. package/dist/components/form/CFormRange.d.ts +1 -1
  57. package/dist/components/form/CFormSelect.d.ts +1 -1
  58. package/dist/components/form/CFormSwitch.d.ts +1 -1
  59. package/dist/components/form/CFormText.d.ts +1 -1
  60. package/dist/components/form/CFormTextarea.d.ts +3 -3
  61. package/dist/components/form/CInputGroup.d.ts +1 -1
  62. package/dist/components/form/CInputGroupText.d.ts +1 -1
  63. package/dist/components/grid/CCol.d.ts +1 -1
  64. package/dist/components/grid/CContainer.d.ts +1 -1
  65. package/dist/components/grid/CRow.d.ts +1 -1
  66. package/dist/components/header/CHeader.d.ts +1 -1
  67. package/dist/components/header/CHeaderBrand.d.ts +1 -1
  68. package/dist/components/header/CHeaderDivider.d.ts +1 -1
  69. package/dist/components/header/CHeaderNav.d.ts +1 -1
  70. package/dist/components/header/CHeaderText.d.ts +1 -1
  71. package/dist/components/header/CHeaderToggler.d.ts +1 -1
  72. package/dist/components/image/CImage.d.ts +1 -1
  73. package/dist/components/link/CLink.d.ts +1 -1
  74. package/dist/components/list-group/CListGroup.d.ts +1 -1
  75. package/dist/components/list-group/CListGroupItem.d.ts +1 -1
  76. package/dist/components/loading-button/CLoadingButton.d.ts +1 -1
  77. package/dist/components/modal/CModal.d.ts +1 -1
  78. package/dist/components/modal/CModalBody.d.ts +1 -1
  79. package/dist/components/modal/CModalFooter.d.ts +1 -1
  80. package/dist/components/modal/CModalHeader.d.ts +1 -1
  81. package/dist/components/modal/CModalTitle.d.ts +1 -1
  82. package/dist/components/multi-select/CMultiSelect.d.ts +73 -59
  83. package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +9 -33
  84. package/dist/components/multi-select/CMultiSelectOptions.d.ts +12 -41
  85. package/dist/components/multi-select/CMultiSelectSelection.d.ts +6 -59
  86. package/dist/components/multi-select/types.d.ts +8 -3
  87. package/dist/components/multi-select/utils.d.ts +9 -4
  88. package/dist/components/nav/CNav.d.ts +1 -1
  89. package/dist/components/nav/CNavGroup.d.ts +1 -1
  90. package/dist/components/nav/CNavGroupItems.d.ts +1 -1
  91. package/dist/components/nav/CNavItem.d.ts +1 -1
  92. package/dist/components/nav/CNavLink.d.ts +1 -1
  93. package/dist/components/nav/CNavTitle.d.ts +1 -1
  94. package/dist/components/navbar/CNavbar.d.ts +1 -1
  95. package/dist/components/navbar/CNavbarBrand.d.ts +1 -1
  96. package/dist/components/navbar/CNavbarNav.d.ts +1 -1
  97. package/dist/components/navbar/CNavbarText.d.ts +1 -1
  98. package/dist/components/navbar/CNavbarToggler.d.ts +1 -1
  99. package/dist/components/offcanvas/COffcanvas.d.ts +1 -1
  100. package/dist/components/offcanvas/COffcanvasBody.d.ts +1 -1
  101. package/dist/components/offcanvas/COffcanvasHeader.d.ts +1 -1
  102. package/dist/components/offcanvas/COffcanvasTitle.d.ts +1 -1
  103. package/dist/components/pagination/CPagination.d.ts +1 -1
  104. package/dist/components/pagination/CPaginationItem.d.ts +1 -1
  105. package/dist/components/picker/CPicker.d.ts +57 -7
  106. package/dist/components/placeholder/CPlaceholder.d.ts +1 -1
  107. package/dist/components/popover/CPopover.d.ts +2 -2
  108. package/dist/components/progress/CProgress.d.ts +1 -1
  109. package/dist/components/progress/CProgressBar.d.ts +1 -1
  110. package/dist/components/sidebar/CSidebar.d.ts +1 -1
  111. package/dist/components/sidebar/CSidebarBrand.d.ts +1 -1
  112. package/dist/components/sidebar/CSidebarFooter.d.ts +1 -1
  113. package/dist/components/sidebar/CSidebarHeader.d.ts +1 -1
  114. package/dist/components/sidebar/CSidebarNav.d.ts +1 -1
  115. package/dist/components/sidebar/CSidebarToggler.d.ts +1 -1
  116. package/dist/components/smart-pagination/CSmartPagination.d.ts +1 -1
  117. package/dist/components/smart-table/CSmartTable.d.ts +20 -56
  118. package/dist/components/smart-table/CSmartTableBody.d.ts +1 -1
  119. package/dist/components/smart-table/CSmartTableCleaner.d.ts +1 -1
  120. package/dist/components/smart-table/CSmartTableFilter.d.ts +1 -1
  121. package/dist/components/smart-table/CSmartTableHead.d.ts +10 -1
  122. package/dist/components/smart-table/CSmartTableItemsPerPageSelector.d.ts +1 -1
  123. package/dist/components/smart-table/types.d.ts +12 -0
  124. package/dist/components/smart-table/utils.d.ts +12 -2
  125. package/dist/components/spinner/CSpinner.d.ts +1 -1
  126. package/dist/components/table/CTable.d.ts +1 -1
  127. package/dist/components/table/CTableBody.d.ts +1 -1
  128. package/dist/components/table/CTableCaption.d.ts +1 -1
  129. package/dist/components/table/CTableDataCell.d.ts +1 -1
  130. package/dist/components/table/CTableFoot.d.ts +1 -1
  131. package/dist/components/table/CTableHead.d.ts +1 -1
  132. package/dist/components/table/CTableHeaderCell.d.ts +1 -1
  133. package/dist/components/table/CTableRow.d.ts +1 -1
  134. package/dist/components/tabs/CTabContent.d.ts +1 -1
  135. package/dist/components/tabs/CTabPane.d.ts +1 -1
  136. package/dist/components/time-picker/CTimePicker.d.ts +1 -1
  137. package/dist/components/time-picker/CTimePickerRollCol.d.ts +1 -1
  138. package/dist/components/toast/CToast.d.ts +1 -1
  139. package/dist/components/toast/CToastBody.d.ts +1 -1
  140. package/dist/components/toast/CToastClose.d.ts +1 -1
  141. package/dist/components/toast/CToastHeader.d.ts +1 -1
  142. package/dist/components/toast/CToaster.d.ts +1 -1
  143. package/dist/components/tooltip/CTooltip.d.ts +2 -2
  144. package/dist/components/virtual-scroller/CVirtualScroller.d.ts +1 -1
  145. package/dist/components/widgets/CWidgetStatsA.d.ts +1 -1
  146. package/dist/components/widgets/CWidgetStatsB.d.ts +1 -1
  147. package/dist/components/widgets/CWidgetStatsC.d.ts +1 -1
  148. package/dist/components/widgets/CWidgetStatsD.d.ts +1 -1
  149. package/dist/components/widgets/CWidgetStatsE.d.ts +1 -1
  150. package/dist/components/widgets/CWidgetStatsF.d.ts +1 -1
  151. package/dist/composables/index.d.ts +2 -0
  152. package/dist/composables/useColorModes.d.ts +5 -0
  153. package/dist/directives/index.d.ts +1 -1
  154. package/dist/directives/v-c-visible.d.ts +1 -1
  155. package/dist/index.d.ts +2 -1
  156. package/dist/index.es.js +4224 -4159
  157. package/dist/index.es.js.map +1 -1
  158. package/dist/index.js +4226 -4160
  159. package/dist/index.js.map +1 -1
  160. package/dist/utils/getUID.d.ts +2 -0
  161. package/dist/utils/index.d.ts +4 -1
  162. package/dist/utils/isObjectInArray.d.ts +2 -0
  163. package/dist/utils/isRTL.d.ts +2 -0
  164. package/package.json +11 -11
  165. package/src/components/accordion/CAccordionItem.ts +2 -2
  166. package/src/components/backdrop/CBackdrop.ts +1 -1
  167. package/src/components/calendar/CCalendar.ts +111 -49
  168. package/src/components/carousel/CCarousel.ts +7 -7
  169. package/src/components/date-picker/CDatePicker.ts +16 -1
  170. package/src/components/date-range-picker/CDateRangePicker.ts +179 -128
  171. package/src/components/date-range-picker/utils.ts +49 -0
  172. package/src/components/dropdown/CDropdown.ts +34 -31
  173. package/src/components/dropdown/CDropdownMenu.ts +1 -1
  174. package/src/components/dropdown/CDropdownToggle.ts +1 -1
  175. package/src/components/element-cover/CElementCover.ts +1 -0
  176. package/src/components/form/CFormCheck.ts +10 -4
  177. package/src/components/form/CFormInput.ts +2 -2
  178. package/src/components/form/CFormLabel.ts +1 -1
  179. package/src/components/form/CFormSelect.ts +1 -1
  180. package/src/components/grid/CCol.ts +1 -1
  181. package/src/components/grid/CContainer.ts +1 -1
  182. package/src/components/header/CHeader.ts +1 -1
  183. package/src/components/modal/CModal.ts +1 -0
  184. package/src/components/multi-select/CMultiSelect.ts +337 -144
  185. package/src/components/multi-select/CMultiSelectNativeSelect.ts +8 -15
  186. package/src/components/multi-select/CMultiSelectOptions.ts +32 -39
  187. package/src/components/multi-select/CMultiSelectSelection.ts +24 -40
  188. package/src/components/multi-select/types.ts +10 -4
  189. package/src/components/multi-select/utils.ts +71 -37
  190. package/src/components/nav/CNavGroup.ts +4 -0
  191. package/src/components/navbar/CNavbar.ts +1 -1
  192. package/src/components/navbar/CNavbarBrand.ts +1 -1
  193. package/src/components/offcanvas/COffcanvas.ts +3 -2
  194. package/src/components/pagination/CPaginationItem.ts +1 -1
  195. package/src/components/picker/CPicker.ts +106 -157
  196. package/src/components/popover/CPopover.ts +18 -2
  197. package/src/components/props.ts +2 -6
  198. package/src/components/sidebar/CSidebar.ts +3 -2
  199. package/src/components/smart-table/CSmartTable.ts +45 -52
  200. package/src/components/smart-table/CSmartTableBody.ts +5 -3
  201. package/src/components/smart-table/CSmartTableHead.ts +41 -14
  202. package/src/components/smart-table/types.ts +13 -0
  203. package/src/components/smart-table/utils.ts +119 -21
  204. package/src/components/spinner/CSpinner.ts +4 -2
  205. package/src/components/table/CTable.ts +19 -18
  206. package/src/components/table/types.ts +19 -19
  207. package/src/components/time-picker/CTimePicker.ts +216 -125
  208. package/src/components/toast/CToast.ts +1 -1
  209. package/src/components/tooltip/CTooltip.ts +19 -3
  210. package/src/components/virtual-scroller/CVirtualScroller.ts +10 -8
  211. package/src/components/widgets/CWidgetStatsA.ts +1 -1
  212. package/src/components/widgets/CWidgetStatsB.ts +1 -1
  213. package/src/components/widgets/CWidgetStatsC.ts +1 -1
  214. package/src/components/widgets/CWidgetStatsE.ts +1 -1
  215. package/src/components/widgets/CWidgetStatsF.ts +1 -1
  216. package/src/composables/index.ts +3 -0
  217. package/src/composables/useColorModes.ts +57 -0
  218. package/src/directives/index.ts +1 -1
  219. package/src/directives/v-c-popover.ts +9 -13
  220. package/src/directives/v-c-tooltip.ts +8 -12
  221. package/src/directives/v-c-visible.ts +1 -1
  222. package/src/index.ts +8 -29
  223. package/src/utils/getUID.ts +9 -0
  224. package/src/utils/index.ts +4 -1
  225. package/src/utils/isObjectInArray.ts +14 -0
  226. package/src/utils/isRTL.ts +13 -0
@@ -5,29 +5,17 @@ import type { Option } from './types'
5
5
  const CMultiSelectNativeSelect = defineComponent({
6
6
  name: 'CMultiSelectGroupOption',
7
7
  props: {
8
- /**
9
- * It specifies that multiple options can be selected at once.
10
- *
11
- * @default true
12
- */
8
+ id: String,
13
9
  multiple: {
14
10
  type: Boolean,
15
11
  default: true,
16
- required: false,
17
12
  },
18
- /**
19
- * List of option elements.
20
- */
21
13
  options: {
22
14
  type: Array as PropType<Option[]>,
23
15
  default: () => [],
24
- required: false,
25
- },
26
- value: {
27
- type: [Number, String, Array],
28
- default: undefined,
29
- require: false,
30
16
  },
17
+ required: Boolean,
18
+ value: [Number, String, Array],
31
19
  },
32
20
  emits: ['change'],
33
21
  setup(props, { emit }) {
@@ -39,6 +27,7 @@ const CMultiSelectNativeSelect = defineComponent({
39
27
  : h('option', { disabled: option.disabled, value: option.value })
40
28
  })
41
29
  }
30
+
42
31
  const handleChange = (event: Event) => {
43
32
  const target = event.target as HTMLSelectElement
44
33
  emit('change', Number(target.value))
@@ -48,9 +37,13 @@ const CMultiSelectNativeSelect = defineComponent({
48
37
  h(
49
38
  'select',
50
39
  {
40
+ className: 'multi-select-new',
41
+ ...(props.id && { id: `${props.id}-multi-select` }),
42
+ ...(props.id && { name: `${props.id}-multi-select` }),
51
43
  multiple: props.multiple,
52
44
  tabIndex: '-1',
53
45
  style: { display: 'none' },
46
+ required: props.required,
54
47
  value: props.value,
55
48
  ref: nativeSelectRef,
56
49
  onChange: handleChange,
@@ -1,35 +1,23 @@
1
1
  import { defineComponent, h, PropType, VNode } from 'vue'
2
2
 
3
+ import { CElementCover } from '../element-cover'
3
4
  import { CVirtualScroller } from '../virtual-scroller'
4
5
 
5
6
  import { getNextSibling, getPreviousSibling } from './utils'
6
- import type { Option } from './types'
7
+ import type { Option, OptionsGroup } from './types'
7
8
 
8
9
  const CMultiSelectOptions = defineComponent({
9
10
  name: 'CMultiSelectOptions',
10
11
  props: {
11
- /**
12
- * List of option elements.
13
- */
12
+ loading: Boolean,
14
13
  options: {
15
- type: Array as PropType<Option[]>,
14
+ type: Array as PropType<(Option | OptionsGroup)[]>,
16
15
  default: () => [],
17
16
  },
18
- /**
19
- * Sets maxHeight of options list.
20
- *
21
- * @default 'auto'
22
- */
23
17
  optionsMaxHeight: {
24
18
  type: [Number, String],
25
19
  default: 'auto',
26
20
  },
27
- /**
28
- * Sets option style.
29
- *
30
- * @values 'checkbox', 'text'
31
- * @default 'checkbox'
32
- */
33
21
  optionsStyle: {
34
22
  type: String,
35
23
  default: 'checkbox',
@@ -37,9 +25,7 @@ const CMultiSelectOptions = defineComponent({
37
25
  return ['checkbox', 'text'].includes(value)
38
26
  },
39
27
  },
40
- /**
41
- * Sets the label for no results when filtering.
42
- */
28
+ scopedSlots: Object,
43
29
  searchNoResultsLabel: {
44
30
  type: String,
45
31
  default: 'no items',
@@ -67,18 +53,16 @@ const CMultiSelectOptions = defineComponent({
67
53
  event.preventDefault()
68
54
  const target = event.target as HTMLElement
69
55
  const next = getNextSibling(target, '.form-multi-select-option')
70
- if (next) {
71
- ;(next as HTMLElement).focus() // eslint-disable-line prettier/prettier
72
- }
56
+
57
+ next && (next as HTMLElement).focus()
73
58
  }
74
59
 
75
60
  if (event.key === 'Up' || event.key === 'ArrowUp') {
76
61
  event.preventDefault()
77
62
  const target = event.target as HTMLElement
78
63
  const prev = getPreviousSibling(target, '.form-multi-select-option')
79
- if (prev) {
80
- ;(prev as HTMLElement).focus() // eslint-disable-line prettier/prettier
81
- }
64
+
65
+ prev && (prev as HTMLElement).focus()
82
66
  }
83
67
  }
84
68
 
@@ -87,15 +71,11 @@ const CMultiSelectOptions = defineComponent({
87
71
  }
88
72
 
89
73
  // TODO: find solution how to remove any
90
- const createOptions = (options: Option[]): VNode | VNode[] | any =>
74
+ const createOptions = (options: (Option | OptionsGroup)[]): VNode | VNode[] | any =>
91
75
  options.length > 0
92
- ? options.map((option: Option) =>
93
- option.options
94
- ? [
95
- h('div', { class: 'form-multi-select-optgroup-label' }, option.label),
96
- createOptions(option.options),
97
- ]
98
- : h(
76
+ ? options.map((option: Option | OptionsGroup) =>
77
+ 'value' in option
78
+ ? h(
99
79
  'div',
100
80
  {
101
81
  class: [
@@ -108,16 +88,27 @@ const CMultiSelectOptions = defineComponent({
108
88
  disabled: option.disabled,
109
89
  },
110
90
  ],
111
- onClick: () => handleOptionClick(option),
112
- onKeydown: (event: any) => handleKeyDown(event, option),
91
+ onClick: () => handleOptionClick(option as Option),
92
+ onKeydown: (event: any) => handleKeyDown(event, option as Option),
113
93
  tabindex: 0,
114
94
  },
115
- option.text,
116
- ),
95
+ props.scopedSlots && props.scopedSlots['options']
96
+ ? h(props.scopedSlots['options'], { option: option })
97
+ : option.text,
98
+ )
99
+ : [
100
+ h(
101
+ 'div',
102
+ { class: 'form-multi-select-optgroup-label' },
103
+ props.scopedSlots && props.scopedSlots['options-groups']
104
+ ? h(props.scopedSlots['options-groups'], { option: option })
105
+ : option.label,
106
+ ),
107
+ ],
117
108
  )
118
109
  : h('div', { class: 'form-multi-select-options-empty' }, props.searchNoResultsLabel)
119
110
 
120
- return () =>
111
+ return () => [
121
112
  props.virtualScroller
122
113
  ? h(
123
114
  CVirtualScroller,
@@ -138,7 +129,9 @@ const CMultiSelectOptions = defineComponent({
138
129
  }),
139
130
  },
140
131
  createOptions(props.options),
141
- )
132
+ ),
133
+ props.loading && h(CElementCover),
134
+ ]
142
135
  },
143
136
  })
144
137
 
@@ -5,56 +5,30 @@ import type { Option } from './types'
5
5
  const CMultiSelectSelection = defineComponent({
6
6
  name: 'CMultiSelectSelection',
7
7
  props: {
8
- /**
9
- * It specifies that multiple options can be selected at once.
10
- *
11
- * @default true
12
- */
13
8
  multiple: {
14
9
  type: Boolean,
15
10
  default: true,
16
- required: false,
17
- },
18
- /**
19
- * Enables search input element.
20
- */
21
- search: {
22
- type: [Boolean, String],
23
- required: false,
24
- default: false,
25
11
  },
12
+ placeholder: String,
13
+ search: [Boolean, String],
26
14
  selected: {
27
15
  type: Array as PropType<Option[]>,
28
16
  default: () => [],
29
- required: false,
30
17
  },
31
- /**
32
- * Sets the selection style.
33
- *
34
- * @values 'counter', 'tags', 'text'
35
- * @default 'tags'
36
- */
37
18
  selectionType: {
38
19
  type: String,
39
20
  default: 'tags',
40
- required: false,
41
21
  validator: (value: string) => {
42
22
  return ['counter', 'tags', 'text'].includes(value)
43
23
  },
44
24
  },
45
- /**
46
- * Sets the counter selection label.
47
- *
48
- * @default 'item(s) selected'
49
- */
50
25
  selectionTypeCounterText: {
51
26
  type: String,
52
27
  default: 'item(s) selected',
53
- required: false,
54
28
  },
55
29
  },
56
30
  emits: ['remove'],
57
- setup(props, { emit }) {
31
+ setup(props, { emit, slots }) {
58
32
  const handleRemove = (option: Option) => {
59
33
  emit('remove', option as Option)
60
34
  }
@@ -62,12 +36,23 @@ const CMultiSelectSelection = defineComponent({
62
36
  h(
63
37
  'div',
64
38
  {
65
- 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
+ ],
66
45
  },
67
46
  [
68
47
  props.multiple &&
69
48
  props.selectionType === 'counter' &&
70
49
  !props.search &&
50
+ props.selected.length === 0 &&
51
+ props.placeholder,
52
+ props.multiple &&
53
+ props.selectionType === 'counter' &&
54
+ !props.search &&
55
+ props.selected.length > 0 &&
71
56
  `${props.selected.length} ${props.selectionTypeCounterText}`,
72
57
  props.multiple &&
73
58
  props.selectionType === 'tags' &&
@@ -76,23 +61,22 @@ const CMultiSelectSelection = defineComponent({
76
61
  return h('span', { class: 'form-multi-select-tag' }, [
77
62
  option.text,
78
63
  !option.disabled &&
79
- h(
80
- 'button',
81
- {
82
- class: 'form-multi-select-tag-delete close',
83
- ariaLabel: 'Close',
84
- onClick: () => handleRemove(option),
85
- },
86
- h('span', { ariaHidden: 'true' }, 'x'),
87
- ),
64
+ h('button', {
65
+ class: 'form-multi-select-tag-delete',
66
+ ariaLabel: 'Close',
67
+ onClick: () => handleRemove(option),
68
+ }),
88
69
  ])
89
70
  }
90
71
  return
91
72
  }),
92
73
  props.multiple &&
93
74
  props.selectionType === 'text' &&
94
- props.selected.map((option) => option.text).join(', '),
75
+ props.selected.map((option, index) =>
76
+ h('span', `${option.text}${index === props.selected.length - 1 ? '' : ','}\xA0`),
77
+ ),
95
78
  !props.multiple && !props.search && props.selected.map((option) => option.text)[0],
79
+ slots.default && slots.default(),
96
80
  ],
97
81
  )
98
82
  },
@@ -1,15 +1,21 @@
1
1
  export type Option = {
2
+ custom?: boolean
2
3
  disabled?: boolean
3
- label?: string
4
- options?: Option[]
5
- order?: number
6
4
  selected?: boolean
7
- text: string
5
+ text: string // TODO: change to label in v5
8
6
  value: number | string
7
+ [key: string]: number | string | any
8
+ }
9
+
10
+ export type OptionsGroup = {
11
+ label: string
12
+ options?: Option[]
13
+ [key: string]: number | string | any
9
14
  }
10
15
 
11
16
  export type SelectedOption = {
12
17
  disabled?: boolean
13
18
  text: string
14
19
  value: number | string
20
+ [key: string]: number | string | any
15
21
  }
@@ -1,32 +1,69 @@
1
- import type { Option, SelectedOption } from './types'
2
-
3
- export const filterOptionsList = (search: string, _options: Option[]) => {
4
- return search.length
5
- ? _options &&
6
- _options.reduce((acc: Option[], val: Option) => {
7
- const options =
8
- val.options &&
9
- val.options.filter(
10
- (element) =>
11
- element.text && element.text.toLowerCase().includes(search.toLowerCase()),
12
- )
13
-
14
- if (
15
- (val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
16
- (options && options.length)
17
- ) {
18
- acc.push(Object.assign({}, val, options && options.length && { options }))
19
- }
20
-
21
- return acc
22
- }, [])
23
- : _options
1
+ import type { Option, OptionsGroup, SelectedOption } from './types'
2
+
3
+ export const createOption = (text: string, options: (Option | OptionsGroup)[]) => {
4
+ const value = text.toLowerCase().replace(/\s/g, '-')
5
+ let uniqueValue = value
6
+ let i = 1
7
+
8
+ while (options.some((option) => String(option.value) === uniqueValue)) {
9
+ uniqueValue = `${value}-${i}`
10
+ i++
11
+ }
12
+
13
+ return [
14
+ {
15
+ value: uniqueValue,
16
+ text,
17
+ custom: true,
18
+ },
19
+ ]
24
20
  }
25
21
 
26
- export const flattenArray = (options: Option[]): Option[] => {
27
- return options.reduce((acc: Option[], val: Option) => {
28
- return acc.concat(Array.isArray(val.options) ? flattenArray(val.options) : val)
29
- }, [])
22
+ export const filterOptionsList = (search: string, _options: (Option | OptionsGroup)[]) => {
23
+ if (search.length > 0 && _options) {
24
+ const optionsList = []
25
+
26
+ for (const option of _options) {
27
+ const options =
28
+ option.options &&
29
+ option.options.filter(
30
+ (option: Option) =>
31
+ option.text && option.text.toLowerCase().includes(search.toLowerCase()),
32
+ )
33
+ if (
34
+ (option.text && option.text.toLowerCase().includes(search.toLowerCase())) ||
35
+ (options && options.length > 0)
36
+ ) {
37
+ optionsList.push(Object.assign({}, option, options && options.length > 0 && { options }))
38
+ }
39
+ }
40
+
41
+ return optionsList
42
+ }
43
+
44
+ return _options
45
+ }
46
+
47
+ export const flattenOptionsArray = (
48
+ options: (Option | OptionsGroup)[],
49
+ keepGroupLabel?: boolean,
50
+ ): (Option | OptionsGroup)[] => {
51
+ const optionsList: (Option | OptionsGroup)[] = []
52
+
53
+ for (const option of options) {
54
+ if (Array.isArray(option.options)) {
55
+ const { options, ...rest } = option
56
+ if (keepGroupLabel) {
57
+ optionsList.push(rest)
58
+ }
59
+
60
+ optionsList.push(...options)
61
+ } else {
62
+ optionsList.push(option)
63
+ }
64
+ }
65
+
66
+ return optionsList
30
67
  }
31
68
 
32
69
  export const getNextSibling = (elem: HTMLElement, selector?: string) => {
@@ -64,7 +101,7 @@ export const getPreviousSibling = (elem: HTMLElement, selector?: string) => {
64
101
  }
65
102
 
66
103
  export const selectOptions = (
67
- options: Option[],
104
+ options: (Option | OptionsGroup)[],
68
105
  selected: SelectedOption[],
69
106
  deselected?: Option[],
70
107
  ) => {
@@ -77,16 +114,13 @@ export const selectOptions = (
77
114
  )
78
115
  }
79
116
 
80
- const deduplicated = _selected.reduce((unique: Option[], option) => {
81
- if (!unique.some((obj) => obj.value === option.value)) {
82
- unique.push({
83
- value: option.value,
84
- text: option.text,
85
- ...(option.disabled && { disabled: option.disabled }),
86
- })
117
+ const deduplicated: SelectedOption[] = []
118
+
119
+ for (const option of _selected) {
120
+ if (!deduplicated.some((obj) => obj.value === option.value)) {
121
+ deduplicated.push(option as SelectedOption)
87
122
  }
88
- return unique
89
- }, []) as SelectedOption[]
123
+ }
90
124
 
91
125
  return deduplicated
92
126
  }
@@ -63,19 +63,23 @@ const CNavGroup = defineComponent({
63
63
  navGroupRef.value.classList.add('show')
64
64
  }
65
65
 
66
+ // eslint-disable-next-line unicorn/consistent-function-scoping
66
67
  const handleEnter = (el: RendererElement, done: () => void) => {
67
68
  executeAfterTransition(() => done(), el as HTMLElement)
68
69
  el.style.height = `${el.scrollHeight}px`
69
70
  }
70
71
 
72
+ // eslint-disable-next-line unicorn/consistent-function-scoping
71
73
  const handleAfterEnter = (el: RendererElement) => {
72
74
  el.style.height = 'auto'
73
75
  }
74
76
 
77
+ // eslint-disable-next-line unicorn/consistent-function-scoping
75
78
  const handleBeforeLeave = (el: RendererElement) => {
76
79
  el.style.height = `${el.scrollHeight}px`
77
80
  }
78
81
 
82
+ // eslint-disable-next-line unicorn/consistent-function-scoping
79
83
  const handleLeave = (el: RendererElement, done: () => void) => {
80
84
  executeAfterTransition(() => done(), el as HTMLElement)
81
85
  setTimeout(() => {
@@ -85,7 +85,7 @@ const CNavbar = defineComponent({
85
85
  props.container
86
86
  ? h(
87
87
  'div',
88
- { class: [`container${props.container !== true ? '-' + props.container : ''}`] },
88
+ { class: [`container${props.container === true ? '' : '-' + props.container}`] },
89
89
  slots.default && slots.default(),
90
90
  )
91
91
  : slots.default && slots.default(),
@@ -19,7 +19,7 @@ const CNavbarBrand = defineComponent({
19
19
  setup(props, { slots }) {
20
20
  return () =>
21
21
  h(
22
- props.component ? props.component : props.href ? 'a' : 'span',
22
+ props.component ?? (props.href ? 'a' : 'span'),
23
23
  {
24
24
  class: 'navbar-brand',
25
25
  href: props.href,
@@ -101,7 +101,6 @@ const COffcanvas = defineComponent({
101
101
  },
102
102
  )
103
103
 
104
-
105
104
  watch(visible, () => {
106
105
  if (visible.value && !props.scroll) {
107
106
  document.body.style.overflow = 'hidden'
@@ -128,11 +127,13 @@ const COffcanvas = defineComponent({
128
127
  offcanvasRef.value.focus()
129
128
  }
130
129
 
130
+ // eslint-disable-next-line unicorn/consistent-function-scoping
131
131
  const handleLeave = (el: RendererElement, done: () => void) => {
132
132
  executeAfterTransition(() => done(), el as HTMLElement)
133
133
  el.classList.add('hiding')
134
134
  }
135
135
 
136
+ // eslint-disable-next-line unicorn/consistent-function-scoping
136
137
  const handleAfterLeave = (el: RendererElement) => {
137
138
  el.classList.remove('show', 'hiding')
138
139
  }
@@ -172,7 +173,7 @@ const COffcanvas = defineComponent({
172
173
  class: [
173
174
  {
174
175
  [`offcanvas${
175
- typeof props.responsive !== 'boolean' ? '-' + props.responsive : ''
176
+ typeof props.responsive === 'boolean' ? '' : '-' + props.responsive
176
177
  }`]: props.responsive,
177
178
  [`offcanvas-${props.placement}`]: props.placement,
178
179
  },
@@ -24,7 +24,7 @@ const CPaginationItem = defineComponent({
24
24
  },
25
25
  setup(props, { slots }) {
26
26
  return () => {
27
- const component = props.component ? props.component : props.active ? 'span' : 'a'
27
+ const component = props.component ?? (props.active ? 'span' : 'a')
28
28
  return h(
29
29
  'li',
30
30
  {