@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
@@ -4,12 +4,11 @@ import { format as dateFormat } from 'date-fns'
4
4
 
5
5
  import { CButton } from '../button'
6
6
  import { CCalendar } from '../calendar'
7
- import { CFormInput, CInputGroup, CInputGroupText } from '../form'
8
7
  import { CFormControlWrapper } from './../form/CFormControlWrapper'
9
8
  import { CPicker } from '../picker'
10
9
  import { CTimePicker } from '../time-picker'
11
10
 
12
- import { getLocalDateFromString } from '../calendar/utils'
11
+ import { getLocalDateFromString } from './utils'
13
12
 
14
13
  import { Color } from '../props'
15
14
 
@@ -26,9 +25,7 @@ const CDateRangePicker = defineComponent({
26
25
  /**
27
26
  * Default date of the component
28
27
  */
29
- calendarDate: {
30
- type: [Date, String],
31
- },
28
+ calendarDate: [Date, String],
32
29
  /**
33
30
  * Toggle visibility or set the content of cancel button.
34
31
  */
@@ -154,40 +151,29 @@ const CDateRangePicker = defineComponent({
154
151
  /**
155
152
  * Specify the list of dates that cannot be selected.
156
153
  */
157
- disabledDates: {
158
- type: Array as PropType<Date[] | Date[][]>,
159
- },
154
+ disabledDates: Array as PropType<Date[] | Date[][]>,
160
155
  /**
161
156
  * Initial selected to date (range).
162
157
  */
163
- endDate: {
164
- type: [Date, String],
165
- required: false,
166
- },
158
+ endDate: [Date, String],
167
159
  /**
168
160
  * Provide valuable, actionable feedback.
169
161
  *
170
162
  * @since 4.6.0
171
163
  */
172
- feedback: {
173
- type: String,
174
- },
164
+ feedback: String,
175
165
  /**
176
166
  * Provide valuable, actionable feedback.
177
167
  *
178
168
  * @since 4.6.0
179
169
  */
180
- feedbackInvalid: {
181
- type: String,
182
- },
170
+ feedbackInvalid: String,
183
171
  /**
184
172
  * Provide valuable, actionable invalid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
185
173
  *
186
174
  * @since 4.6.0
187
175
  */
188
- feedbackValid: {
189
- type: String,
190
- },
176
+ feedbackValid: String,
191
177
  /**
192
178
  * Sets the day of start week.
193
179
  * - 0 - Sunday,
@@ -235,15 +221,16 @@ const CDateRangePicker = defineComponent({
235
221
  *
236
222
  * @since 4.6.0
237
223
  */
238
- invalid: Boolean,
224
+ invalid: {
225
+ type: Boolean,
226
+ default: undefined,
227
+ },
239
228
  /**
240
229
  * Add a caption for a component.
241
230
  *
242
231
  * @since 4.6.0
243
232
  */
244
- label: {
245
- type: String,
246
- },
233
+ label: String,
247
234
  /**
248
235
  * Sets the default locale for components. If not set, it is inherited from the navigator.language.
249
236
  */
@@ -254,15 +241,11 @@ const CDateRangePicker = defineComponent({
254
241
  /**
255
242
  * Max selectable date.
256
243
  */
257
- maxDate: {
258
- type: [Date, String],
259
- },
244
+ maxDate: [Date, String],
260
245
  /**
261
246
  * Min selectable date.
262
247
  */
263
- minDate: {
264
- type: [Date, String],
265
- },
248
+ minDate: [Date, String],
266
249
  /**
267
250
  * Show arrows navigation.
268
251
  */
@@ -280,7 +263,7 @@ const CDateRangePicker = defineComponent({
280
263
  * Specifies a short hint that is visible in the input.
281
264
  */
282
265
  placeholder: {
283
- type: [String, Array] as PropType<String | String[]>,
266
+ type: [String, Array] as PropType<string | string[]>,
284
267
  default: () => ['Start date', 'End date'],
285
268
  },
286
269
  /**
@@ -294,10 +277,31 @@ const CDateRangePicker = defineComponent({
294
277
  * Predefined date ranges the user can select from.
295
278
  */
296
279
  ranges: Object,
280
+ /**
281
+ * When present, it specifies that must be filled out before submitting the form.
282
+ *
283
+ * @since 4.9.0
284
+ */
285
+ required: Boolean,
297
286
  /**
298
287
  * Toggle select mode between start and end date.
299
288
  */
300
289
  selectEndDate: Boolean,
290
+ /**
291
+ * Set whether days in adjacent months shown before or after the current month are selectable. This only applies if the `showAdjacementDays` option is set to true.
292
+ *
293
+ * @since 4.9.0
294
+ */
295
+ selectAdjacementDays: Boolean,
296
+ /**
297
+ * Set whether to display dates in adjacent months (non-selectable) at the start and end of the current month.
298
+ *
299
+ * @since 4.9.0
300
+ */
301
+ showAdjacementDays: {
302
+ type: Boolean,
303
+ default: true,
304
+ },
301
305
  /**
302
306
  * Default icon or character character that separates two dates.
303
307
  */
@@ -320,17 +324,13 @@ const CDateRangePicker = defineComponent({
320
324
  /**
321
325
  * Initial selected date.
322
326
  */
323
- startDate: {
324
- type: [Date, String],
325
- },
327
+ startDate: [Date, String],
326
328
  /**
327
329
  * Add helper text to the component.
328
330
  *
329
331
  * @since 4.6.0
330
332
  */
331
- text: {
332
- type: String,
333
- },
333
+ text: String,
334
334
  /**
335
335
  * Provide an additional time selection by adding select boxes to choose times.
336
336
  */
@@ -385,7 +385,10 @@ const CDateRangePicker = defineComponent({
385
385
  *
386
386
  * @since 4.6.0
387
387
  */
388
- valid: Boolean,
388
+ valid: {
389
+ type: Boolean,
390
+ default: undefined,
391
+ },
389
392
  /**
390
393
  * Toggle the visibility of the component.
391
394
  */
@@ -451,6 +454,10 @@ const CDateRangePicker = defineComponent({
451
454
  'update:end-date',
452
455
  ],
453
456
  setup(props, { slots, attrs, emit }) {
457
+ const inputEndRef = ref()
458
+ const inputStartRef = ref()
459
+ const formRef = ref()
460
+
454
461
  const visible = ref(props.visible)
455
462
  const calendarDate = ref<Date>(
456
463
  props.calendarDate
@@ -470,13 +477,20 @@ const CDateRangePicker = defineComponent({
470
477
  const maxDate = ref(props.maxDate && new Date(props.maxDate))
471
478
  const minDate = ref(props.minDate && new Date(props.minDate))
472
479
  const selectEndDate = ref(false)
473
-
480
+ const isValid = ref(props.valid || (props.invalid && false))
474
481
  const isMobile = ref(false)
475
482
 
476
483
  onMounted(() => {
477
484
  isMobile.value = window.innerWidth < 768
478
485
  })
479
486
 
487
+ watch(
488
+ () => [props.valid, props.invalid],
489
+ () => {
490
+ isValid.value = props.valid || (props.invalid && false)
491
+ },
492
+ )
493
+
480
494
  watch(
481
495
  () => props.startDate,
482
496
  () => {
@@ -515,12 +529,28 @@ const CDateRangePicker = defineComponent({
515
529
  },
516
530
  )
517
531
 
532
+ watch(inputStartRef, () => {
533
+ if (inputStartRef.value && inputStartRef.value.form) {
534
+ formRef.value = inputStartRef.value.form
535
+ }
536
+ })
537
+
538
+ watch([formRef, startDate, endDate], () => {
539
+ if (formRef.value) {
540
+ formRef.value.addEventListener('submit', (event: Event) => {
541
+ setTimeout(() => handleFormValidation(event.target as HTMLFormElement))
542
+ })
543
+
544
+ handleFormValidation(formRef.value)
545
+ }
546
+ })
547
+
518
548
  const formatDate = (date: Date) => {
519
549
  return props.format
520
550
  ? dateFormat(date, props.format)
521
551
  : props.timepicker
522
- ? date.toLocaleString(props.format)
523
- : date.toLocaleDateString(props.format)
552
+ ? date.toLocaleString(props.locale)
553
+ : date.toLocaleDateString(props.locale)
524
554
  }
525
555
 
526
556
  const setInputValue = (date: Date | null) => {
@@ -548,6 +578,19 @@ const CDateRangePicker = defineComponent({
548
578
  calendarDate.value = date
549
579
  }
550
580
 
581
+ const handleFormValidation = (form: HTMLFormElement) => {
582
+ if (!form.classList.contains('was-validated')) {
583
+ return
584
+ }
585
+
586
+ if ((props.range && startDate.value && endDate.value) || (!props.range && startDate.value)) {
587
+ isValid.value = true
588
+ return
589
+ }
590
+
591
+ isValid.value = false
592
+ }
593
+
551
594
  const handleStartDateChange = (date: Date) => {
552
595
  startDate.value = date
553
596
  inputStartHoverValue.value = null
@@ -600,25 +643,27 @@ const CDateRangePicker = defineComponent({
600
643
 
601
644
  const InputGroup = () =>
602
645
  h(
603
- CInputGroup,
646
+ 'div',
604
647
  {
605
- class: 'picker-input-group',
606
- size: props.size,
648
+ class: 'date-picker-input-group',
607
649
  },
608
- () => [
609
- h(CFormInput, {
650
+ [
651
+ h('input', {
610
652
  autocomplete: 'off',
611
- class: {
612
- hover: inputStartHoverValue.value,
613
- },
653
+ class: [
654
+ 'date-picker-input',
655
+ {
656
+ hover: inputStartHoverValue.value,
657
+ },
658
+ ],
614
659
  disabled: props.disabled,
615
660
  ...(props.id && { name: props.range ? `${props.id}-start-date` : `${props.id}-date` }),
616
661
  onClick: () => {
617
662
  selectEndDate.value = false
618
663
  },
619
- onInput: (event) => {
664
+ onInput: (event: Event) => {
620
665
  const date = getLocalDateFromString(
621
- event.target.value,
666
+ (event.target as HTMLInputElement).value,
622
667
  props.locale,
623
668
  props.timepicker,
624
669
  )
@@ -631,31 +676,30 @@ const CDateRangePicker = defineComponent({
631
676
  ? props.placeholder[0]
632
677
  : props.placeholder,
633
678
  readonly: props.inputReadOnly || typeof props.format === 'string',
679
+ required: props.required,
680
+ ref: inputStartRef,
634
681
  value: inputStartHoverValue.value
635
682
  ? setInputValue(inputStartHoverValue.value)
636
683
  : setInputValue(startDate.value),
637
684
  }),
685
+ props.range && props.separator !== false && h('div', { class: 'date-picker-separator' }),
638
686
  props.range &&
639
- props.separator !== false &&
640
- h(CInputGroupText, {}, () =>
641
- slots.separator
642
- ? slots.separator()
643
- : h('span', { class: 'picker-input-group-icon date-picker-arrow-icon' }),
644
- ),
645
- props.range &&
646
- h(CFormInput, {
687
+ h('input', {
647
688
  autocomplete: 'off',
648
- class: {
649
- hover: inputEndHoverValue.value,
650
- },
689
+ class: [
690
+ 'date-picker-input',
691
+ {
692
+ hover: inputEndHoverValue.value,
693
+ },
694
+ ],
651
695
  disabled: props.disabled,
652
696
  ...(props.id && { name: `${props.id}-end-date` }),
653
697
  onClick: () => {
654
698
  selectEndDate.value = true
655
699
  },
656
- onInput: (event) => {
700
+ onInput: (event: Event) => {
657
701
  const date = getLocalDateFromString(
658
- event.target.value,
702
+ (event.target as HTMLInputElement).value,
659
703
  props.locale,
660
704
  props.timepicker,
661
705
  )
@@ -666,35 +710,19 @@ const CDateRangePicker = defineComponent({
666
710
  },
667
711
  placeholder: props.placeholder[1],
668
712
  readonly: props.inputReadOnly || typeof props.format === 'string',
713
+ required: props.required,
714
+ ref: inputEndRef,
669
715
  value: inputEndHoverValue.value
670
716
  ? setInputValue(inputEndHoverValue.value)
671
717
  : setInputValue(endDate.value),
672
718
  }),
673
- (props.indicator || props.cleaner) &&
674
- h(CInputGroupText, {}, () => [
675
- props.indicator &&
676
- h(
677
- 'span',
678
- {
679
- class: 'picker-input-group-indicator',
680
- },
681
- slots.indicator
682
- ? slots.indicator()
683
- : h('span', { class: 'picker-input-group-icon date-picker-input-icon' }),
684
- ),
685
- props.cleaner &&
686
- h(
687
- 'span',
688
- {
689
- class: 'picker-input-group-cleaner',
690
- onClick: (event: Event) => handleClear(event),
691
- role: 'button',
692
- },
693
- slots.cleaner
694
- ? slots.cleaner()
695
- : h('span', { class: 'picker-input-group-icon date-picker-cleaner-icon' }),
696
- ),
697
- ]),
719
+ props.indicator && h('div', { class: 'date-picker-indicator' }),
720
+ props.cleaner &&
721
+ (startDate.value || endDate.value) &&
722
+ h('div', {
723
+ class: 'date-picker-cleaner',
724
+ onClick: (event: Event) => handleClear(event),
725
+ }),
698
726
  ],
699
727
  )
700
728
 
@@ -707,34 +735,30 @@ const CDateRangePicker = defineComponent({
707
735
  feedbackInvalid: props.feedbackInvalid,
708
736
  feedbackValid: props.feedbackValid,
709
737
  id: props.id,
710
- invalid: props.invalid,
738
+ invalid: isValid.value === false ? true : false,
711
739
  label: props.label,
712
740
  text: props.text,
713
741
  tooltipFeedback: props.tooltipFeedback,
714
- valid: props.valid,
742
+ valid: isValid.value,
715
743
  },
716
744
  {
717
745
  default: () =>
718
746
  h(
719
747
  CPicker,
720
748
  {
721
- cancelButton: props.cancelButton,
722
- cancelButtonColor: props.cancelButtonColor,
723
- cancelButtonSize: props.cancelButtonSize,
724
- cancelButtonVariant: props.cancelButtonVariant,
725
- class: ['date-picker', { 'is-invalid': props.invalid, 'is-valid': props.valid }],
726
- confirmButton: props.confirmButton,
727
- confirmButtonColor: props.confirmButtonColor,
728
- confirmButtonSize: props.confirmButtonSize,
729
- confirmButtonVariant: props.confirmButtonVariant,
749
+ class: [
750
+ 'date-picker',
751
+ {
752
+ [`date-picker-${props.size}`]: props.size,
753
+ disabled: props.disabled,
754
+ 'is-invalid': isValid.value === false ? true : false,
755
+ 'is-valid': isValid.value,
756
+ },
757
+ ],
730
758
  disabled: props.disabled,
759
+ dropdownClassNames: 'date-picker-dropdown',
731
760
  footer: props.footer || props.timepicker,
732
761
  id: props.id,
733
- onCancel: () => {
734
- startDate.value = initialStartDate.value
735
- endDate.value = initialEndDate.value
736
- visible.value = false
737
- },
738
762
  onHide: () => {
739
763
  visible.value = false
740
764
  emit('hide')
@@ -754,30 +778,55 @@ const CDateRangePicker = defineComponent({
754
778
  visible: visible.value,
755
779
  },
756
780
  {
757
- ...(slots.cancelButton && {
758
- cancelButton: () => slots.cancelButton && slots.cancelButton(),
759
- }),
760
- ...(slots.confirmButton && {
761
- confirmButton: () => slots.confirmButton && slots.confirmButton(),
762
- }),
763
781
  toggler: () => InputGroup(),
764
782
  footer: () =>
765
- h(
766
- CButton,
767
- {
768
- class: 'me-auto',
769
- color: props.todayButtonColor,
770
- size: props.todayButtonSize,
771
- variant: props.todayButtonVariant,
772
- onClick: () => {
773
- const date = new Date()
774
- startDate.value = date
775
- endDate.value = date
776
- calendarDate.value = date
777
- },
778
- },
779
- () => props.todayButton,
780
- ),
783
+ h('div', { class: 'date-picker-footer' }, [
784
+ props.todayButton &&
785
+ h(
786
+ CButton,
787
+ {
788
+ class: 'me-auto',
789
+ color: props.todayButtonColor,
790
+ size: props.todayButtonSize,
791
+ variant: props.todayButtonVariant,
792
+ onClick: () => {
793
+ const date = new Date()
794
+ startDate.value = date
795
+ endDate.value = date
796
+ calendarDate.value = date
797
+ },
798
+ },
799
+ () => props.todayButton,
800
+ ),
801
+ props.cancelButton &&
802
+ h(
803
+ CButton,
804
+ {
805
+ color: props.cancelButtonColor,
806
+ onClick: () => {
807
+ startDate.value = initialStartDate.value
808
+ endDate.value = initialEndDate.value
809
+ visible.value = false
810
+ },
811
+ size: props.cancelButtonSize,
812
+ variant: props.cancelButtonVariant,
813
+ },
814
+ () => props.cancelButton,
815
+ ),
816
+ props.confirmButton &&
817
+ h(
818
+ CButton,
819
+ {
820
+ color: props.confirmButtonColor,
821
+ onClick: () => {
822
+ visible.value = false
823
+ },
824
+ size: props.confirmButtonSize,
825
+ variant: props.confirmButtonVariant,
826
+ },
827
+ () => props.confirmButton,
828
+ ),
829
+ ]),
781
830
  default: () =>
782
831
  h(
783
832
  'div',
@@ -829,6 +878,8 @@ const CDateRangePicker = defineComponent({
829
878
  navigation: props.navigation,
830
879
  range: props.range,
831
880
  selectEndDate: selectEndDate.value,
881
+ selectAdjacementDays: props.selectAdjacementDays,
882
+ showAdjacementDays: props.showAdjacementDays,
832
883
  ...(startDate.value && { startDate: startDate.value }),
833
884
  onCalendarCellHover: (date: Date | null) =>
834
885
  handleCalendarCellHover(date),
@@ -0,0 +1,49 @@
1
+ export const getLocalDateFromString = (string: string, locale: string, time?: boolean) => {
2
+ if (!Number.isNaN(Date.parse(string))) {
3
+ return new Date(Date.parse(string))
4
+ }
5
+
6
+ const date = new Date(2013, 11, 31, 17, 19, 22)
7
+ let regex = time ? date.toLocaleString(locale) : date.toLocaleDateString(locale)
8
+ regex = regex
9
+ .replace('2013', '(?<year>[0-9]{2,4})')
10
+ .replace('12', '(?<month>[0-9]{1,2})')
11
+ .replace('31', '(?<day>[0-9]{1,2})')
12
+
13
+ if (time) {
14
+ regex = regex
15
+ .replace('5', '(?<hour>[0-9]{1,2})')
16
+ .replace('17', '(?<hour>[0-9]{1,2})')
17
+ .replace('19', '(?<minute>[0-9]{1,2})')
18
+ .replace('22', '(?<second>[0-9]{1,2})')
19
+ .replace('PM', '(?<ampm>[A-Z]{2})')
20
+ }
21
+
22
+ const rgx = new RegExp(`${regex}`)
23
+ const partials = string.match(rgx)
24
+
25
+ if (partials === null) return
26
+
27
+ const newDate =
28
+ partials.groups &&
29
+ (time
30
+ ? new Date(
31
+ Number(partials.groups['year']),
32
+ Number(partials.groups['month']) - 1,
33
+ Number(partials.groups['day']),
34
+ partials.groups['ampm']
35
+ ? partials.groups['ampm'] === 'PM'
36
+ ? Number(partials.groups['hour']) + 12
37
+ : Number(partials.groups['hour'])
38
+ : Number(partials.groups['hour']),
39
+ Number(partials.groups['minute']),
40
+ Number(partials.groups['second']),
41
+ )
42
+ : new Date(
43
+ Number(partials.groups['year']),
44
+ Number(partials.groups['month']) - 1,
45
+ Number(partials.groups['day']),
46
+ ))
47
+
48
+ return newDate
49
+ }
@@ -1,7 +1,8 @@
1
- import { defineComponent, h, ref, provide, watch, PropType } from 'vue'
1
+ import { defineComponent, h, ref, provide, watch, PropType, onMounted } from 'vue'
2
2
  import { createPopper, Placement } from '@popperjs/core'
3
3
 
4
4
  import { Triggers } from '../../types'
5
+ import { isRTL } from '../../utils'
5
6
 
6
7
  const CDropdown = defineComponent({
7
8
  name: 'CDropdown',
@@ -18,22 +19,22 @@ const CDropdown = defineComponent({
18
19
  if (value === 'start' || value === 'end') {
19
20
  return true
20
21
  } else {
21
- if (typeof value.xs !== 'undefined' && (value.xs === 'start' || value.xs === 'end')) {
22
+ if (value.xs !== undefined && (value.xs === 'start' || value.xs === 'end')) {
22
23
  return true
23
24
  }
24
- if (typeof value.sm !== 'undefined' && (value.sm === 'start' || value.sm === 'end')) {
25
+ if (value.sm !== undefined && (value.sm === 'start' || value.sm === 'end')) {
25
26
  return true
26
27
  }
27
- if (typeof value.md !== 'undefined' && (value.md === 'start' || value.md === 'end')) {
28
+ if (value.md !== undefined && (value.md === 'start' || value.md === 'end')) {
28
29
  return true
29
30
  }
30
- if (typeof value.lg !== 'undefined' && (value.lg === 'start' || value.lg === 'end')) {
31
+ if (value.lg !== undefined && (value.lg === 'start' || value.lg === 'end')) {
31
32
  return true
32
33
  }
33
- if (typeof value.xl !== 'undefined' && (value.xl === 'start' || value.xl === 'end')) {
34
+ if (value.xl !== undefined && (value.xl === 'start' || value.xl === 'end')) {
34
35
  return true
35
36
  }
36
- if (typeof value.xxl !== 'undefined' && (value.xxl === 'start' || value.xxl === 'end')) {
37
+ if (value.xxl !== undefined && (value.xxl === 'start' || value.xxl === 'end')) {
37
38
  return true
38
39
  }
39
40
  return false
@@ -149,30 +150,6 @@ const CDropdown = defineComponent({
149
150
  provide('dropdownToggleRef', dropdownToggleRef)
150
151
  provide('dropdownMenuRef', dropdownMenuRef)
151
152
 
152
- if (props.direction === 'center') {
153
- placement.value = 'bottom'
154
- }
155
-
156
- if (props.direction === 'dropup') {
157
- placement.value = 'top-start'
158
- }
159
-
160
- if (props.direction === 'dropup-center') {
161
- placement.value = 'top'
162
- }
163
-
164
- if (props.direction === 'dropend') {
165
- placement.value = 'right-start'
166
- }
167
-
168
- if (props.direction === 'dropstart') {
169
- placement.value = 'left-start'
170
- }
171
-
172
- if (props.alignment === 'end') {
173
- placement.value = 'bottom-end'
174
- }
175
-
176
153
  const initPopper = () => {
177
154
  // Disable popper if responsive aligment is set.
178
155
  if (typeof props.alignment === 'object') {
@@ -228,6 +205,32 @@ const CDropdown = defineComponent({
228
205
  visible.value ? emit('show') : emit('hide')
229
206
  })
230
207
 
208
+ onMounted(() => {
209
+ if (props.direction === 'center') {
210
+ placement.value = 'bottom'
211
+ }
212
+
213
+ if (props.direction === 'dropup') {
214
+ placement.value = isRTL(dropdownMenuRef.value) ? 'top-end' : 'top-start'
215
+ }
216
+
217
+ if (props.direction === 'dropup-center') {
218
+ placement.value = 'top'
219
+ }
220
+
221
+ if (props.direction === 'dropend') {
222
+ placement.value = isRTL(dropdownMenuRef.value) ? 'left-start' : 'right-start'
223
+ }
224
+
225
+ if (props.direction === 'dropstart') {
226
+ placement.value = isRTL(dropdownMenuRef.value) ? 'right-start' : 'left-start'
227
+ }
228
+
229
+ if (props.alignment === 'end') {
230
+ placement.value = isRTL(dropdownMenuRef.value) ? 'bottom-start' : 'bottom-end'
231
+ }
232
+ })
233
+
231
234
  return () =>
232
235
  props.variant === 'input-group'
233
236
  ? [slots.default && slots.default()]
@@ -22,7 +22,7 @@ const CDropdownMenu = defineComponent({
22
22
 
23
23
  const { autoClose, alignment, dark, popper } = config
24
24
 
25
- // eslint-disable-next-line @typescript-eslint/ban-types
25
+ // eslint-disable-next-line @typescript-eslint/ban-types, unicorn/consistent-function-scoping
26
26
  const alignmentClassNames = (alignment: object | string) => {
27
27
  const classNames: string[] = []
28
28
  if (typeof alignment === 'object') {