@coreui/vue-pro 4.8.0-next.0 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/dist/components/form/CFormCheck.d.ts +13 -0
  3. package/dist/components/form/CFormSwitch.d.ts +13 -0
  4. package/dist/components/index.d.ts +1 -0
  5. package/dist/components/multi-select/CMultiSelect.d.ts +35 -44
  6. package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +1 -1
  7. package/dist/components/multi-select/CMultiSelectOptions.d.ts +13 -11
  8. package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -1
  9. package/dist/components/multi-select/types.d.ts +14 -0
  10. package/dist/components/multi-select/utils.d.ts +6 -0
  11. package/dist/components/smart-table/CSmartTable.d.ts +1 -1
  12. package/dist/components/smart-table/CSmartTableHead.d.ts +1 -1
  13. package/dist/components/virtual-scroller/CVirtualScroller.d.ts +23 -0
  14. package/dist/components/virtual-scroller/index.d.ts +6 -0
  15. package/dist/index.es.js +249 -135
  16. package/dist/index.es.js.map +1 -1
  17. package/dist/index.js +249 -133
  18. package/dist/index.js.map +1 -1
  19. package/dist/utils/index.d.ts +1 -3
  20. package/package.json +1 -1
  21. package/src/components/carousel/CCarousel.ts +36 -34
  22. package/src/components/form/CFormCheck.ts +7 -0
  23. package/src/components/form/CFormSwitch.ts +7 -0
  24. package/src/components/index.ts +1 -0
  25. package/src/components/multi-select/CMultiSelect.ts +33 -89
  26. package/src/components/multi-select/CMultiSelectNativeSelect.ts +2 -1
  27. package/src/components/multi-select/CMultiSelectOptions.ts +31 -17
  28. package/src/components/multi-select/CMultiSelectSelection.ts +2 -1
  29. package/src/components/multi-select/types.ts +15 -0
  30. package/src/components/multi-select/utils.ts +92 -0
  31. package/src/components/virtual-scroller/CVirtualScroller.ts +109 -0
  32. package/src/components/virtual-scroller/index.ts +10 -0
  33. package/src/utils/index.ts +1 -3
  34. package/dist/components/accordion/CAccordionCollapse.d.ts +0 -22
  35. package/dist/components/multi-select/CMultiSelect copy.d.ts +0 -305
  36. package/dist/components/pagination/CSmartPagination.d.ts +0 -257
  37. package/dist/utils/calendar.d.ts +0 -23
  38. package/dist/utils/getNextSibling.d.ts +0 -2
  39. package/dist/utils/getPreviousSibling.d.ts +0 -2
  40. package/dist/utils/isObjectInArray.d.ts +0 -2
  41. package/dist/utils/isVisible.d.ts +0 -2
  42. package/dist/utils/time.d.ts +0 -21
  43. package/src/utils/getNextSibling.ts +0 -18
  44. package/src/utils/getPreviousSibling.ts +0 -18
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, provide, h as h$1, Transition, withDirectives, inject, watch, reactive, onBeforeMount, onMounted, onUpdated, toRefs, onUnmounted, cloneVNode, nextTick, vShow, Teleport, onBeforeUnmount, computed } from 'vue';
1
+ import { defineComponent, ref, provide, h as h$1, Transition, withDirectives, inject, watch, onBeforeMount, onMounted, onUpdated, toRefs, onUnmounted, cloneVNode, nextTick, vShow, computed, Teleport, onBeforeUnmount } from 'vue';
2
2
 
3
3
  const CAccordion = defineComponent({
4
4
  name: 'CAccordion',
@@ -1905,38 +1905,6 @@ const CCardPlugin = {
1905
1905
  },
1906
1906
  };
1907
1907
 
1908
- const getNextSibling = (elem, selector) => {
1909
- // Get the next sibling element
1910
- let sibling = elem.nextElementSibling;
1911
- // If there's no selector, return the first sibling
1912
- if (!selector)
1913
- return sibling;
1914
- // If the sibling matches our selector, use it
1915
- // If not, jump to the next sibling and continue the loop
1916
- while (sibling) {
1917
- if (sibling.matches(selector))
1918
- return sibling;
1919
- sibling = sibling.nextElementSibling;
1920
- }
1921
- return;
1922
- };
1923
-
1924
- const getPreviousSibling = (elem, selector) => {
1925
- // Get the next sibling element
1926
- let sibling = elem.previousElementSibling;
1927
- // If there's no selector, return the first sibling
1928
- if (!selector)
1929
- return sibling;
1930
- // If the sibling matches our selector, use it
1931
- // If not, jump to the next sibling and continue the loop
1932
- while (sibling) {
1933
- if (sibling.matches(selector))
1934
- return sibling;
1935
- sibling = sibling.previousElementSibling;
1936
- }
1937
- return;
1938
- };
1939
-
1940
1908
  const isInViewport = (element) => {
1941
1909
  const rect = element.getBoundingClientRect();
1942
1910
  return (Math.floor(rect.top) >= 0 &&
@@ -2011,10 +1979,13 @@ const CCarousel = defineComponent({
2011
1979
  },
2012
1980
  setup(props, { slots }) {
2013
1981
  const carouselRef = ref();
2014
- const timeout = ref();
1982
+ const active = ref(props.index);
2015
1983
  const animating = ref(false);
2016
- const visible = ref();
2017
1984
  const customInterval = ref(props.interval);
1985
+ const direction = ref('next');
1986
+ const items = ref([]);
1987
+ const timeout = ref();
1988
+ const visible = ref();
2018
1989
  const setAnimating = (value) => {
2019
1990
  animating.value = value;
2020
1991
  };
@@ -2030,27 +2001,16 @@ const CCarousel = defineComponent({
2030
2001
  timeout.value = setTimeout(() => nextItemWhenVisible(), typeof customInterval.value === 'number' ? customInterval.value : props.interval);
2031
2002
  }
2032
2003
  };
2033
- const state = reactive({
2034
- items: [],
2035
- active: props.index,
2036
- direction: 'next',
2037
- });
2038
- onBeforeMount(() => {
2039
- if (slots.default) {
2040
- // @ts-expect-error TODO: fix types
2041
- state.items = slots.default().filter((child) => child.type.name === 'CCarouselItem');
2042
- }
2043
- });
2044
- const handleControlClick = (direction) => {
2004
+ const handleControlClick = (_direction) => {
2045
2005
  if (animating.value) {
2046
2006
  return;
2047
2007
  }
2048
- state.direction = direction;
2049
- if (direction === 'next') {
2050
- state.active === state.items.length - 1 ? (state.active = 0) : state.active++;
2008
+ direction.value = _direction;
2009
+ if (_direction === 'next') {
2010
+ active.value === items.value.length - 1 ? (active.value = 0) : active.value++;
2051
2011
  }
2052
2012
  else {
2053
- state.active === 0 ? (state.active = state.items.length - 1) : state.active--;
2013
+ active.value === 0 ? (active.value = items.value.length - 1) : active.value--;
2054
2014
  }
2055
2015
  };
2056
2016
  const nextItemWhenVisible = () => {
@@ -2061,17 +2021,17 @@ const CCarousel = defineComponent({
2061
2021
  }
2062
2022
  };
2063
2023
  const handleIndicatorClick = (index) => {
2064
- if (state.active === index) {
2024
+ if (active.value === index) {
2065
2025
  return;
2066
2026
  }
2067
- if (state.active < index) {
2068
- state.direction = 'next';
2069
- state.active = index;
2027
+ if (active.value < index) {
2028
+ direction.value = 'next';
2029
+ active.value = index;
2070
2030
  return;
2071
2031
  }
2072
- if (state.active > index) {
2073
- state.direction = 'prev';
2074
- state.active = index;
2032
+ if (active.value > index) {
2033
+ direction.value = 'prev';
2034
+ active.value = index;
2075
2035
  }
2076
2036
  };
2077
2037
  const handleScroll = () => {
@@ -2082,6 +2042,15 @@ const CCarousel = defineComponent({
2082
2042
  visible.value = false;
2083
2043
  }
2084
2044
  };
2045
+ onBeforeMount(() => {
2046
+ if (slots.default) {
2047
+ const children = typeof slots.default()[0].type === 'symbol' ? slots.default()[0].children : slots.default();
2048
+ if (children && Array.isArray(children)) {
2049
+ // @ts-expect-error TODO: fix types
2050
+ items.value = children.filter((child) => child.type.name === 'CCarouselItem');
2051
+ }
2052
+ }
2053
+ });
2085
2054
  onMounted(() => {
2086
2055
  window.addEventListener('scroll', handleScroll);
2087
2056
  });
@@ -2091,7 +2060,7 @@ const CCarousel = defineComponent({
2091
2060
  !animating.value && cycle();
2092
2061
  return;
2093
2062
  }
2094
- if (!props.wrap && state.active < state.items.length - 1) {
2063
+ if (!props.wrap && active.value < items.value.length - 1) {
2095
2064
  !animating.value && cycle();
2096
2065
  }
2097
2066
  });
@@ -2112,19 +2081,19 @@ const CCarousel = defineComponent({
2112
2081
  props.indicators &&
2113
2082
  h$1('div', {
2114
2083
  class: 'carousel-indicators',
2115
- }, state.items.map((_, index) => {
2084
+ }, items.value.map((_, index) => {
2116
2085
  return h$1('button', {
2117
2086
  type: 'button',
2118
2087
  id: index,
2119
2088
  'data-coreui-target': '',
2120
- ...(state.active === index && { class: 'active' }),
2089
+ ...(active.value === index && { class: 'active' }),
2121
2090
  onClick: () => handleIndicatorClick(index),
2122
2091
  });
2123
2092
  })),
2124
- h$1('div', { class: 'carousel-inner' }, state.items.map((item, index) => {
2093
+ h$1('div', { class: 'carousel-inner' }, items.value.map((item, index) => {
2125
2094
  return h$1(item, {
2126
- active: state.active === index ? true : false,
2127
- direction: state.direction,
2095
+ active: active.value === index ? true : false,
2096
+ direction: direction.value,
2128
2097
  });
2129
2098
  })),
2130
2099
  props.controls && [
@@ -4843,6 +4812,12 @@ const CFormCheck = defineComponent({
4843
4812
  type: [Boolean, String],
4844
4813
  value: undefined,
4845
4814
  },
4815
+ /**
4816
+ * Put checkboxes or radios on the opposite side.
4817
+ *
4818
+ * @sinve 4.8.0
4819
+ */
4820
+ reverse: Boolean,
4846
4821
  /**
4847
4822
  * Display validation feedback in a styled tooltip.
4848
4823
  *
@@ -4885,6 +4860,7 @@ const CFormCheck = defineComponent({
4885
4860
  'form-check',
4886
4861
  {
4887
4862
  'form-check-inline': props.inline,
4863
+ 'form-check-reverse': props.reverse,
4888
4864
  'is-invalid': props.invalid,
4889
4865
  'is-valid': props.valid,
4890
4866
  },
@@ -5582,6 +5558,12 @@ const CFormSwitch = defineComponent({
5582
5558
  type: [Boolean, String],
5583
5559
  value: undefined,
5584
5560
  },
5561
+ /**
5562
+ * Put checkboxes or radios on the opposite side.
5563
+ *
5564
+ * @sinve 4.8.0
5565
+ */
5566
+ reverse: Boolean,
5585
5567
  /**
5586
5568
  * Size the component large or extra large. Works only with `switch`.
5587
5569
  *
@@ -5629,6 +5611,7 @@ const CFormSwitch = defineComponent({
5629
5611
  class: [
5630
5612
  'form-check form-switch',
5631
5613
  {
5614
+ 'form-check-reverse': props.reverse,
5632
5615
  [`form-switch-${props.size}`]: props.size,
5633
5616
  'is-invalid': props.invalid,
5634
5617
  'is-valid': props.valid,
@@ -11530,6 +11513,159 @@ const CMultiSelectNativeSelect = defineComponent({
11530
11513
  },
11531
11514
  });
11532
11515
 
11516
+ const CVirtualScroller = defineComponent({
11517
+ name: 'CVirtualScroller',
11518
+ props: {
11519
+ /**
11520
+ * Amount of visible items
11521
+ */
11522
+ visibleItems: {
11523
+ type: Number,
11524
+ default: 10,
11525
+ },
11526
+ },
11527
+ setup(props, { slots }) {
11528
+ const virtualScrollRef = ref();
11529
+ const virtualScrollContentRef = ref();
11530
+ const currentItemIndex = ref(1);
11531
+ const itemHeight = ref(0);
11532
+ const itemsNumber = ref(0);
11533
+ const viewportPadding = ref(0);
11534
+ const buffer = computed(() => Math.floor(props.visibleItems / 2));
11535
+ const maxHeight = computed(() => itemsNumber.value * itemHeight.value + 2 * viewportPadding.value);
11536
+ const viewportHeight = computed(() => props.visibleItems * itemHeight.value + 2 * viewportPadding.value);
11537
+ onMounted(() => {
11538
+ if (virtualScrollRef.value) {
11539
+ viewportPadding.value = parseFloat(getComputedStyle(virtualScrollRef.value).paddingTop);
11540
+ // It's necessary to calculate heights of items
11541
+ virtualScrollRef.value.dispatchEvent(new CustomEvent('scroll'));
11542
+ }
11543
+ });
11544
+ const handleScroll = (scrollTop) => {
11545
+ currentItemIndex.value =
11546
+ itemHeight.value && Math.max(Math.ceil(scrollTop / itemHeight.value), 1);
11547
+ };
11548
+ return () => {
11549
+ const children = slots.default
11550
+ ? Array.isArray(slots.default()[0].children)
11551
+ ? slots.default()[0].children
11552
+ : slots.default()
11553
+ : [];
11554
+ itemsNumber.value = children && children.length ? children.length : 0;
11555
+ return h$1('div', {
11556
+ class: ['virtual-scroller'],
11557
+ onScroll: (event) => handleScroll(event.target.scrollTop),
11558
+ style: {
11559
+ height: `${maxHeight.value > viewportHeight.value ? viewportHeight.value : maxHeight.value}px`,
11560
+ overflowY: 'auto',
11561
+ },
11562
+ ref: virtualScrollRef,
11563
+ }, h$1('div', {
11564
+ class: 'virtual-scroller-content',
11565
+ style: {
11566
+ height: `${maxHeight.value}px`,
11567
+ },
11568
+ ref: virtualScrollContentRef,
11569
+ }, children.map((slot, index) => index + 1 > Math.max(currentItemIndex.value - buffer.value, 0) &&
11570
+ index + 1 <= currentItemIndex.value + props.visibleItems + buffer.value &&
11571
+ cloneVNode(slot, {
11572
+ class: [
11573
+ {
11574
+ 'virtual-scroller-item-preload': index + 1 > currentItemIndex.value + props.visibleItems ||
11575
+ index + 1 < currentItemIndex.value,
11576
+ },
11577
+ ],
11578
+ style: {
11579
+ ...(currentItemIndex.value > buffer.value && {
11580
+ transform: `translateY(${(currentItemIndex.value - buffer.value) * itemHeight.value}px)`,
11581
+ }),
11582
+ },
11583
+ ref: (node) => {
11584
+ if (node && node.offsetHeight) {
11585
+ itemHeight.value =
11586
+ node.offsetHeight +
11587
+ parseFloat(getComputedStyle(node).marginTop) +
11588
+ parseFloat(getComputedStyle(node).marginBottom);
11589
+ }
11590
+ },
11591
+ }))));
11592
+ };
11593
+ },
11594
+ });
11595
+
11596
+ const CVirtualScrollerPlugin = {
11597
+ install: (app) => {
11598
+ app.component(CVirtualScroller.name, CVirtualScroller);
11599
+ },
11600
+ };
11601
+
11602
+ const filterOptionsList = (search, _options) => {
11603
+ return search.length
11604
+ ? _options &&
11605
+ _options.reduce((acc, val) => {
11606
+ const options = val.options &&
11607
+ val.options.filter((element) => element.text && element.text.toLowerCase().includes(search.toLowerCase()));
11608
+ if ((val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
11609
+ (options && options.length)) {
11610
+ acc.push(Object.assign({}, val, options && options.length && { options }));
11611
+ }
11612
+ return acc;
11613
+ }, [])
11614
+ : _options;
11615
+ };
11616
+ const flattenArray = (options) => {
11617
+ return options.reduce((acc, val) => {
11618
+ return acc.concat(Array.isArray(val.options) ? flattenArray(val.options) : val);
11619
+ }, []);
11620
+ };
11621
+ const getNextSibling = (elem, selector) => {
11622
+ // Get the next sibling element
11623
+ let sibling = elem.nextElementSibling;
11624
+ // If there's no selector, return the first sibling
11625
+ if (!selector)
11626
+ return sibling;
11627
+ // If the sibling matches our selector, use it
11628
+ // If not, jump to the next sibling and continue the loop
11629
+ while (sibling) {
11630
+ if (sibling.matches(selector))
11631
+ return sibling;
11632
+ sibling = sibling.nextElementSibling;
11633
+ }
11634
+ return;
11635
+ };
11636
+ const getPreviousSibling = (elem, selector) => {
11637
+ // Get the next sibling element
11638
+ let sibling = elem.previousElementSibling;
11639
+ // If there's no selector, return the first sibling
11640
+ if (!selector)
11641
+ return sibling;
11642
+ // If the sibling matches our selector, use it
11643
+ // If not, jump to the next sibling and continue the loop
11644
+ while (sibling) {
11645
+ if (sibling.matches(selector))
11646
+ return sibling;
11647
+ sibling = sibling.previousElementSibling;
11648
+ }
11649
+ return;
11650
+ };
11651
+ const selectOptions = (options, selected, deselected) => {
11652
+ let _selected = [...selected, ...options];
11653
+ if (deselected) {
11654
+ _selected = _selected.filter((selectedOption) => !deselected.some((deselectedOption) => deselectedOption.value === selectedOption.value));
11655
+ }
11656
+ const deduplicated = _selected.reduce((unique, option) => {
11657
+ if (!unique.some((obj) => obj.value === option.value)) {
11658
+ unique.push({
11659
+ value: option.value,
11660
+ text: option.text,
11661
+ ...(option.disabled && { disabled: option.disabled }),
11662
+ });
11663
+ }
11664
+ return unique;
11665
+ }, []);
11666
+ return deduplicated;
11667
+ };
11668
+
11533
11669
  const CMultiSelectOptions = defineComponent({
11534
11670
  name: 'CMultiSelectOptions',
11535
11671
  props: {
@@ -11539,7 +11675,6 @@ const CMultiSelectOptions = defineComponent({
11539
11675
  options: {
11540
11676
  type: Array,
11541
11677
  default: () => [],
11542
- required: false,
11543
11678
  },
11544
11679
  /**
11545
11680
  * Sets maxHeight of options list.
@@ -11549,7 +11684,6 @@ const CMultiSelectOptions = defineComponent({
11549
11684
  optionsMaxHeight: {
11550
11685
  type: [Number, String],
11551
11686
  default: 'auto',
11552
- required: false,
11553
11687
  },
11554
11688
  /**
11555
11689
  * Sets option style.
@@ -11560,7 +11694,6 @@ const CMultiSelectOptions = defineComponent({
11560
11694
  optionsStyle: {
11561
11695
  type: String,
11562
11696
  default: 'checkbox',
11563
- required: false,
11564
11697
  validator: (value) => {
11565
11698
  return ['checkbox', 'text'].includes(value);
11566
11699
  },
@@ -11571,12 +11704,15 @@ const CMultiSelectOptions = defineComponent({
11571
11704
  searchNoResultsLabel: {
11572
11705
  type: String,
11573
11706
  default: 'no items',
11574
- required: false,
11575
11707
  },
11576
11708
  selected: {
11577
11709
  type: Array,
11578
11710
  default: () => [],
11579
- required: false,
11711
+ },
11712
+ virtualScroller: Boolean,
11713
+ visibleItems: {
11714
+ type: Number,
11715
+ default: 10,
11580
11716
  },
11581
11717
  },
11582
11718
  emits: ['optionClick'],
@@ -11628,12 +11764,19 @@ const CMultiSelectOptions = defineComponent({
11628
11764
  tabindex: 0,
11629
11765
  }, option.text))
11630
11766
  : h$1('div', { class: 'form-multi-select-options-empty' }, props.searchNoResultsLabel);
11631
- return () => h$1('div', {
11632
- class: 'form-multi-select-options',
11633
- ...(props.optionsMaxHeight !== 'auto' && {
11634
- style: { maxHeight: props.optionsMaxHeight, overflow: 'scroll' },
11635
- }),
11636
- }, createOptions(props.options));
11767
+ return () => props.virtualScroller
11768
+ ? h$1(CVirtualScroller, {
11769
+ class: 'form-multi-select-options',
11770
+ visibleItems: props.visibleItems,
11771
+ }, {
11772
+ default: () => createOptions(props.options),
11773
+ })
11774
+ : h$1('div', {
11775
+ class: 'form-multi-select-options',
11776
+ ...(props.optionsMaxHeight !== 'auto' && {
11777
+ style: { maxHeight: props.optionsMaxHeight, overflow: 'scroll' },
11778
+ }),
11779
+ }, createOptions(props.options));
11637
11780
  },
11638
11781
  });
11639
11782
 
@@ -11724,11 +11867,6 @@ const CMultiSelectSelection = defineComponent({
11724
11867
  },
11725
11868
  });
11726
11869
 
11727
- const flattenArray = (options) => {
11728
- return options.reduce((acc, val) => {
11729
- return acc.concat(Array.isArray(val.options) ? flattenArray(val.options) : val);
11730
- }, []);
11731
- };
11732
11870
  const CMultiSelect = defineComponent({
11733
11871
  name: 'CMultiSelect',
11734
11872
  props: {
@@ -11739,7 +11877,6 @@ const CMultiSelect = defineComponent({
11739
11877
  */
11740
11878
  cleaner: {
11741
11879
  type: Boolean,
11742
- required: false,
11743
11880
  default: true,
11744
11881
  },
11745
11882
  /**
@@ -11747,7 +11884,6 @@ const CMultiSelect = defineComponent({
11747
11884
  */
11748
11885
  disabled: {
11749
11886
  type: Boolean,
11750
- required: false,
11751
11887
  default: false,
11752
11888
  },
11753
11889
  /**
@@ -11802,7 +11938,6 @@ const CMultiSelect = defineComponent({
11802
11938
  multiple: {
11803
11939
  type: Boolean,
11804
11940
  default: true,
11805
- required: false,
11806
11941
  },
11807
11942
  /**
11808
11943
  * List of option elements.
@@ -11810,7 +11945,6 @@ const CMultiSelect = defineComponent({
11810
11945
  options: {
11811
11946
  type: Array,
11812
11947
  default: () => [],
11813
- required: false,
11814
11948
  },
11815
11949
  /**
11816
11950
  * Sets maxHeight of options list.
@@ -11820,7 +11954,6 @@ const CMultiSelect = defineComponent({
11820
11954
  optionsMaxHeight: {
11821
11955
  type: [Number, String],
11822
11956
  default: 'auto',
11823
- required: false,
11824
11957
  },
11825
11958
  /**
11826
11959
  * Sets option style.
@@ -11831,7 +11964,6 @@ const CMultiSelect = defineComponent({
11831
11964
  optionsStyle: {
11832
11965
  type: String,
11833
11966
  default: 'checkbox',
11834
- required: false,
11835
11967
  validator: (value) => {
11836
11968
  return ['checkbox', 'text'].includes(value);
11837
11969
  },
@@ -11844,7 +11976,6 @@ const CMultiSelect = defineComponent({
11844
11976
  placeholder: {
11845
11977
  type: String,
11846
11978
  default: 'Select...',
11847
- required: false,
11848
11979
  },
11849
11980
  /**
11850
11981
  * Enables search input element.
@@ -11852,7 +11983,6 @@ const CMultiSelect = defineComponent({
11852
11983
  search: {
11853
11984
  type: [Boolean, String],
11854
11985
  default: true,
11855
- required: false,
11856
11986
  validator: (value) => {
11857
11987
  if (typeof value == 'string') {
11858
11988
  return ['external'].includes(value);
@@ -11869,7 +11999,6 @@ const CMultiSelect = defineComponent({
11869
11999
  searchNoResultsLabel: {
11870
12000
  type: String,
11871
12001
  default: 'no items',
11872
- required: false,
11873
12002
  },
11874
12003
  /**
11875
12004
  * Enables select all button.
@@ -11878,7 +12007,6 @@ const CMultiSelect = defineComponent({
11878
12007
  */
11879
12008
  selectAll: {
11880
12009
  type: Boolean,
11881
- required: false,
11882
12010
  default: true,
11883
12011
  },
11884
12012
  /**
@@ -11888,7 +12016,6 @@ const CMultiSelect = defineComponent({
11888
12016
  */
11889
12017
  selectAllLabel: {
11890
12018
  type: String,
11891
- required: false,
11892
12019
  default: 'Select all options',
11893
12020
  },
11894
12021
  /**
@@ -11900,7 +12027,6 @@ const CMultiSelect = defineComponent({
11900
12027
  selectionType: {
11901
12028
  type: String,
11902
12029
  default: 'tags',
11903
- required: false,
11904
12030
  validator: (value) => {
11905
12031
  return ['counter', 'tags', 'text'].includes(value);
11906
12032
  },
@@ -11913,7 +12039,6 @@ const CMultiSelect = defineComponent({
11913
12039
  selectionTypeCounterText: {
11914
12040
  type: String,
11915
12041
  default: 'item(s) selected',
11916
- required: false,
11917
12042
  },
11918
12043
  /**
11919
12044
  * Size the component small or large.
@@ -11922,7 +12047,6 @@ const CMultiSelect = defineComponent({
11922
12047
  */
11923
12048
  size: {
11924
12049
  type: String,
11925
- required: false,
11926
12050
  validator: (value) => {
11927
12051
  return ['sm', 'lg'].includes(value);
11928
12052
  },
@@ -11947,6 +12071,12 @@ const CMultiSelect = defineComponent({
11947
12071
  * @since 4.6.0
11948
12072
  */
11949
12073
  valid: Boolean,
12074
+ /**
12075
+ * Enable virtual scroller for the options list.
12076
+ *
12077
+ * @since 4.8.0
12078
+ */
12079
+ virtualScroller: Boolean,
11950
12080
  /**
11951
12081
  * Toggle the visibility of multi select dropdown.
11952
12082
  *
@@ -11955,7 +12085,16 @@ const CMultiSelect = defineComponent({
11955
12085
  visible: {
11956
12086
  type: Boolean,
11957
12087
  default: false,
11958
- required: false,
12088
+ },
12089
+ /**
12090
+ *
12091
+ * Amount of visible items when virtualScroller is set to `true`.
12092
+ *
12093
+ * @since 4.8.0
12094
+ */
12095
+ visibleItems: {
12096
+ type: Number,
12097
+ default: 10,
11959
12098
  },
11960
12099
  },
11961
12100
  emits: [
@@ -11972,29 +12111,12 @@ const CMultiSelect = defineComponent({
11972
12111
  ],
11973
12112
  setup(props, { attrs, emit }) {
11974
12113
  const nativeSelectRef = ref();
11975
- provide('nativeSelectRef', nativeSelectRef);
11976
- const searchRef = ref();
11977
12114
  const options = ref(props.options);
11978
12115
  const search = ref('');
12116
+ const searchRef = ref();
11979
12117
  const selected = ref([]);
11980
12118
  const visible = ref(props.visible);
11981
- const selectOptions = (options, deselected) => {
11982
- let _selected = [...selected.value, ...options];
11983
- if (deselected) {
11984
- _selected = _selected.filter((selectedOption) => !deselected.some((deselectedOption) => deselectedOption.value === selectedOption.value));
11985
- }
11986
- const deduplicated = _selected.reduce((unique, option) => {
11987
- if (!unique.some((obj) => obj.value === option.value)) {
11988
- unique.push({
11989
- value: option.value,
11990
- text: option.text,
11991
- ...(option.disabled && { disabled: option.disabled }),
11992
- });
11993
- }
11994
- return unique;
11995
- }, []);
11996
- selected.value = deduplicated;
11997
- };
12119
+ provide('nativeSelectRef', nativeSelectRef);
11998
12120
  watch(() => props.options, (newValue, oldValue) => {
11999
12121
  if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
12000
12122
  options.value = newValue;
@@ -12012,27 +12134,15 @@ const CMultiSelect = defineComponent({
12012
12134
  }
12013
12135
  return;
12014
12136
  });
12015
- _selected && selectOptions(_selected, deselected);
12137
+ if (_selected) {
12138
+ selected.value = selectOptions(_selected, selected.value, deselected);
12139
+ }
12016
12140
  }
12017
- });
12141
+ }, { immediate: true });
12018
12142
  watch(selected, () => {
12019
12143
  nativeSelectRef.value &&
12020
12144
  nativeSelectRef.value.dispatchEvent(new Event('change', { bubbles: true }));
12021
12145
  });
12022
- const filterOptionsList = (search, _options) => {
12023
- return search.length
12024
- ? _options &&
12025
- _options.reduce((acc, val) => {
12026
- const options = val.options &&
12027
- val.options.filter((element) => element.text && element.text.toLowerCase().includes(search.toLowerCase()));
12028
- if ((val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
12029
- (options && options.length)) {
12030
- acc.push(Object.assign({}, val, options && options.length && { options }));
12031
- }
12032
- return acc;
12033
- }, [])
12034
- : options.value;
12035
- };
12036
12146
  const handleSearchChange = (event) => {
12037
12147
  const target = event.target;
12038
12148
  search.value = target.value.toLowerCase();
@@ -12070,7 +12180,7 @@ const CMultiSelect = defineComponent({
12070
12180
  }
12071
12181
  };
12072
12182
  const handleSelectAll = () => {
12073
- selectOptions(flattenArray(options.value).filter((option) => !option.disabled));
12183
+ selected.value = selectOptions(flattenArray(options.value).filter((option) => !option.disabled), selected.value);
12074
12184
  };
12075
12185
  const handleDeselectAll = () => {
12076
12186
  selected.value = selected.value.filter((option) => option.disabled);
@@ -12161,7 +12271,7 @@ const CMultiSelect = defineComponent({
12161
12271
  ref: searchRef,
12162
12272
  }),
12163
12273
  ]),
12164
- default: () => h$1('div', {}, [
12274
+ default: () => visible.value && [
12165
12275
  props.multiple &&
12166
12276
  props.selectAll &&
12167
12277
  h$1('button', {
@@ -12177,9 +12287,11 @@ const CMultiSelect = defineComponent({
12177
12287
  optionsMaxHeight: props.optionsMaxHeight,
12178
12288
  optionsStyle: props.optionsStyle,
12179
12289
  searchNoResultsLabel: props.searchNoResultsLabel,
12180
- selected: selected.value
12290
+ selected: selected.value,
12291
+ virtualScroller: props.virtualScroller,
12292
+ visibleItems: props.visibleItems,
12181
12293
  }),
12182
- ]),
12294
+ ],
12183
12295
  }),
12184
12296
  }),
12185
12297
  ];
@@ -16684,6 +16796,8 @@ var Components = /*#__PURE__*/Object.freeze({
16684
16796
  CToaster: CToaster,
16685
16797
  CTooltip: CTooltip,
16686
16798
  CTooltipPlugin: CTooltipPlugin,
16799
+ CVirtualScroller: CVirtualScroller,
16800
+ CVirtualScrollerPlugin: CVirtualScrollerPlugin,
16687
16801
  CWidgetStatsA: CWidgetStatsA,
16688
16802
  CWidgetStatsB: CWidgetStatsB,
16689
16803
  CWidgetStatsC: CWidgetStatsC,
@@ -16922,5 +17036,5 @@ const CoreuiVue = {
16922
17036
  },
16923
17037
  };
16924
17038
 
16925
- export { CAccordion, CAccordionBody, CAccordionButton, CAccordionHeader, CAccordionItem, CAccordionPlugin, CAlert, CAlertHeading, CAlertLink, CAlertPlugin, CAvatar, CAvatarPlugin, CBackdrop, CBackdropPlugin, CBadge, CBadgePlugin, CBreadcrumb, CBreadcrumbItem, CBreadcrumbPlugin, CButton, CButtonGroup, CButtonGroupPlugin, CButtonPlugin, CButtonToolbar, CCLinkPlugin, CCalendar, CCalendarPlugin, CCallout, CCalloutPlugin, CCard, CCardBody, CCardFooter, CCardGroup, CCardHeader, CCardImage, CCardImageOverlay, CCardLink, CCardPlugin, CCardSubtitle, CCardText, CCardTitle, CCarousel, CCarouselCaption, CCarouselItem, CCarouselPlugin, CCloseButton, CCloseButtonPlugin, CCol, CCollapse, CCollapsePlugin, CContainer, CDatePicker, CDatePickerPlugin, CDateRangePicker, CDateRangePickerPlugin, CDropdown, CDropdownDivider, CDropdownHeader, CDropdownItem, CDropdownMenu, CDropdownPlugin, CDropdownToggle, CElementCover, CElementCoverPlugin, CFooter, CFooterPlugin, CForm, CFormCheck, CFormFeedback, CFormFloating, CFormInput, CFormLabel, CFormPlugin, CFormRange, CFormSelect, CFormSwitch, CFormText, CFormTextarea, CGridPlugin, CHeader, CHeaderBrand, CHeaderDivider, CHeaderNav, CHeaderPlugin, CHeaderText, CHeaderToggler, CImage, CImagePlugin, CInputGroup, CInputGroupText, CLink, CListGroup, CListGroupItem, CListGroupPlugin, CLoadingButton, CLoadingButtonPlugin, CModal, CModalBody, CModalFooter, CModalHeader, CModalPlugin, CModalTitle, CMultiSelect, CMultiSelectPlugin, CNav, CNavGroup, CNavGroupItems, CNavItem, CNavLink, CNavPlugin, CNavTitle, CNavbar, CNavbarBrand, CNavbarNav, CNavbarPlugin, CNavbarText, CNavbarToggler, COffcanvas, COffcanvasBody, COffcanvasHeader, COffcanvasPlugin, COffcanvasTitle, CPagination, CPaginationItem, CPaginationPlugin, CPicker, CPickerPlugin, CPlaceholder, CPlaceholderPlugin, CPopover, CPopoverPlugin, CProgress, CProgressBar, CProgressPlugin, CRow, CSidebar, CSidebarBrand, CSidebarFooter, CSidebarHeader, CSidebarNav, CSidebarPlugin, CSidebarToggler, CSmartPagination, CSmartPaginationPlugin, CSmartTable, CSmartTablePlugin, CSpinner, CSpinnerPlugin, CTabContent, CTabPane, CTable, CTableBody, CTableCaption, CTableDataCell, CTableFoot, CTableHead, CTableHeaderCell, CTablePlugin, CTableRow, CTabsPlugin, CTimePicker, CTimePickerPlugin, CToast, CToastBody, CToastClose, CToastHeader, CToastPlugin, CToaster, CTooltip, CTooltipPlugin, CWidgetStatsA, CWidgetStatsB, CWidgetStatsC, CWidgetStatsD, CWidgetStatsE, CWidgetStatsF, CWidgetsStatsPlugin, CoreuiVue as default, vcplaceholder, vcpopover, vctooltip };
17039
+ export { CAccordion, CAccordionBody, CAccordionButton, CAccordionHeader, CAccordionItem, CAccordionPlugin, CAlert, CAlertHeading, CAlertLink, CAlertPlugin, CAvatar, CAvatarPlugin, CBackdrop, CBackdropPlugin, CBadge, CBadgePlugin, CBreadcrumb, CBreadcrumbItem, CBreadcrumbPlugin, CButton, CButtonGroup, CButtonGroupPlugin, CButtonPlugin, CButtonToolbar, CCLinkPlugin, CCalendar, CCalendarPlugin, CCallout, CCalloutPlugin, CCard, CCardBody, CCardFooter, CCardGroup, CCardHeader, CCardImage, CCardImageOverlay, CCardLink, CCardPlugin, CCardSubtitle, CCardText, CCardTitle, CCarousel, CCarouselCaption, CCarouselItem, CCarouselPlugin, CCloseButton, CCloseButtonPlugin, CCol, CCollapse, CCollapsePlugin, CContainer, CDatePicker, CDatePickerPlugin, CDateRangePicker, CDateRangePickerPlugin, CDropdown, CDropdownDivider, CDropdownHeader, CDropdownItem, CDropdownMenu, CDropdownPlugin, CDropdownToggle, CElementCover, CElementCoverPlugin, CFooter, CFooterPlugin, CForm, CFormCheck, CFormFeedback, CFormFloating, CFormInput, CFormLabel, CFormPlugin, CFormRange, CFormSelect, CFormSwitch, CFormText, CFormTextarea, CGridPlugin, CHeader, CHeaderBrand, CHeaderDivider, CHeaderNav, CHeaderPlugin, CHeaderText, CHeaderToggler, CImage, CImagePlugin, CInputGroup, CInputGroupText, CLink, CListGroup, CListGroupItem, CListGroupPlugin, CLoadingButton, CLoadingButtonPlugin, CModal, CModalBody, CModalFooter, CModalHeader, CModalPlugin, CModalTitle, CMultiSelect, CMultiSelectPlugin, CNav, CNavGroup, CNavGroupItems, CNavItem, CNavLink, CNavPlugin, CNavTitle, CNavbar, CNavbarBrand, CNavbarNav, CNavbarPlugin, CNavbarText, CNavbarToggler, COffcanvas, COffcanvasBody, COffcanvasHeader, COffcanvasPlugin, COffcanvasTitle, CPagination, CPaginationItem, CPaginationPlugin, CPicker, CPickerPlugin, CPlaceholder, CPlaceholderPlugin, CPopover, CPopoverPlugin, CProgress, CProgressBar, CProgressPlugin, CRow, CSidebar, CSidebarBrand, CSidebarFooter, CSidebarHeader, CSidebarNav, CSidebarPlugin, CSidebarToggler, CSmartPagination, CSmartPaginationPlugin, CSmartTable, CSmartTablePlugin, CSpinner, CSpinnerPlugin, CTabContent, CTabPane, CTable, CTableBody, CTableCaption, CTableDataCell, CTableFoot, CTableHead, CTableHeaderCell, CTablePlugin, CTableRow, CTabsPlugin, CTimePicker, CTimePickerPlugin, CToast, CToastBody, CToastClose, CToastHeader, CToastPlugin, CToaster, CTooltip, CTooltipPlugin, CVirtualScroller, CVirtualScrollerPlugin, CWidgetStatsA, CWidgetStatsB, CWidgetStatsC, CWidgetStatsD, CWidgetStatsE, CWidgetStatsF, CWidgetsStatsPlugin, CoreuiVue as default, vcplaceholder, vcpopover, vctooltip };
16926
17040
  //# sourceMappingURL=index.es.js.map