@coreui/vue-pro 4.8.0-next.1 → 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.
package/dist/index.js CHANGED
@@ -1983,10 +1983,13 @@ const CCarousel = vue.defineComponent({
1983
1983
  },
1984
1984
  setup(props, { slots }) {
1985
1985
  const carouselRef = vue.ref();
1986
- const timeout = vue.ref();
1986
+ const active = vue.ref(props.index);
1987
1987
  const animating = vue.ref(false);
1988
- const visible = vue.ref();
1989
1988
  const customInterval = vue.ref(props.interval);
1989
+ const direction = vue.ref('next');
1990
+ const items = vue.ref([]);
1991
+ const timeout = vue.ref();
1992
+ const visible = vue.ref();
1990
1993
  const setAnimating = (value) => {
1991
1994
  animating.value = value;
1992
1995
  };
@@ -2002,27 +2005,16 @@ const CCarousel = vue.defineComponent({
2002
2005
  timeout.value = setTimeout(() => nextItemWhenVisible(), typeof customInterval.value === 'number' ? customInterval.value : props.interval);
2003
2006
  }
2004
2007
  };
2005
- const state = vue.reactive({
2006
- items: [],
2007
- active: props.index,
2008
- direction: 'next',
2009
- });
2010
- vue.onBeforeMount(() => {
2011
- if (slots.default) {
2012
- // @ts-expect-error TODO: fix types
2013
- state.items = slots.default().filter((child) => child.type.name === 'CCarouselItem');
2014
- }
2015
- });
2016
- const handleControlClick = (direction) => {
2008
+ const handleControlClick = (_direction) => {
2017
2009
  if (animating.value) {
2018
2010
  return;
2019
2011
  }
2020
- state.direction = direction;
2021
- if (direction === 'next') {
2022
- state.active === state.items.length - 1 ? (state.active = 0) : state.active++;
2012
+ direction.value = _direction;
2013
+ if (_direction === 'next') {
2014
+ active.value === items.value.length - 1 ? (active.value = 0) : active.value++;
2023
2015
  }
2024
2016
  else {
2025
- state.active === 0 ? (state.active = state.items.length - 1) : state.active--;
2017
+ active.value === 0 ? (active.value = items.value.length - 1) : active.value--;
2026
2018
  }
2027
2019
  };
2028
2020
  const nextItemWhenVisible = () => {
@@ -2033,17 +2025,17 @@ const CCarousel = vue.defineComponent({
2033
2025
  }
2034
2026
  };
2035
2027
  const handleIndicatorClick = (index) => {
2036
- if (state.active === index) {
2028
+ if (active.value === index) {
2037
2029
  return;
2038
2030
  }
2039
- if (state.active < index) {
2040
- state.direction = 'next';
2041
- state.active = index;
2031
+ if (active.value < index) {
2032
+ direction.value = 'next';
2033
+ active.value = index;
2042
2034
  return;
2043
2035
  }
2044
- if (state.active > index) {
2045
- state.direction = 'prev';
2046
- state.active = index;
2036
+ if (active.value > index) {
2037
+ direction.value = 'prev';
2038
+ active.value = index;
2047
2039
  }
2048
2040
  };
2049
2041
  const handleScroll = () => {
@@ -2054,6 +2046,15 @@ const CCarousel = vue.defineComponent({
2054
2046
  visible.value = false;
2055
2047
  }
2056
2048
  };
2049
+ vue.onBeforeMount(() => {
2050
+ if (slots.default) {
2051
+ const children = typeof slots.default()[0].type === 'symbol' ? slots.default()[0].children : slots.default();
2052
+ if (children && Array.isArray(children)) {
2053
+ // @ts-expect-error TODO: fix types
2054
+ items.value = children.filter((child) => child.type.name === 'CCarouselItem');
2055
+ }
2056
+ }
2057
+ });
2057
2058
  vue.onMounted(() => {
2058
2059
  window.addEventListener('scroll', handleScroll);
2059
2060
  });
@@ -2063,7 +2064,7 @@ const CCarousel = vue.defineComponent({
2063
2064
  !animating.value && cycle();
2064
2065
  return;
2065
2066
  }
2066
- if (!props.wrap && state.active < state.items.length - 1) {
2067
+ if (!props.wrap && active.value < items.value.length - 1) {
2067
2068
  !animating.value && cycle();
2068
2069
  }
2069
2070
  });
@@ -2084,19 +2085,19 @@ const CCarousel = vue.defineComponent({
2084
2085
  props.indicators &&
2085
2086
  vue.h('div', {
2086
2087
  class: 'carousel-indicators',
2087
- }, state.items.map((_, index) => {
2088
+ }, items.value.map((_, index) => {
2088
2089
  return vue.h('button', {
2089
2090
  type: 'button',
2090
2091
  id: index,
2091
2092
  'data-coreui-target': '',
2092
- ...(state.active === index && { class: 'active' }),
2093
+ ...(active.value === index && { class: 'active' }),
2093
2094
  onClick: () => handleIndicatorClick(index),
2094
2095
  });
2095
2096
  })),
2096
- vue.h('div', { class: 'carousel-inner' }, state.items.map((item, index) => {
2097
+ vue.h('div', { class: 'carousel-inner' }, items.value.map((item, index) => {
2097
2098
  return vue.h(item, {
2098
- active: state.active === index ? true : false,
2099
- direction: state.direction,
2099
+ active: active.value === index ? true : false,
2100
+ direction: direction.value,
2100
2101
  });
2101
2102
  })),
2102
2103
  props.controls && [
@@ -4815,6 +4816,12 @@ const CFormCheck = vue.defineComponent({
4815
4816
  type: [Boolean, String],
4816
4817
  value: undefined,
4817
4818
  },
4819
+ /**
4820
+ * Put checkboxes or radios on the opposite side.
4821
+ *
4822
+ * @sinve 4.8.0
4823
+ */
4824
+ reverse: Boolean,
4818
4825
  /**
4819
4826
  * Display validation feedback in a styled tooltip.
4820
4827
  *
@@ -4857,6 +4864,7 @@ const CFormCheck = vue.defineComponent({
4857
4864
  'form-check',
4858
4865
  {
4859
4866
  'form-check-inline': props.inline,
4867
+ 'form-check-reverse': props.reverse,
4860
4868
  'is-invalid': props.invalid,
4861
4869
  'is-valid': props.valid,
4862
4870
  },
@@ -5554,6 +5562,12 @@ const CFormSwitch = vue.defineComponent({
5554
5562
  type: [Boolean, String],
5555
5563
  value: undefined,
5556
5564
  },
5565
+ /**
5566
+ * Put checkboxes or radios on the opposite side.
5567
+ *
5568
+ * @sinve 4.8.0
5569
+ */
5570
+ reverse: Boolean,
5557
5571
  /**
5558
5572
  * Size the component large or extra large. Works only with `switch`.
5559
5573
  *
@@ -5601,6 +5615,7 @@ const CFormSwitch = vue.defineComponent({
5601
5615
  class: [
5602
5616
  'form-check form-switch',
5603
5617
  {
5618
+ 'form-check-reverse': props.reverse,
5604
5619
  [`form-switch-${props.size}`]: props.size,
5605
5620
  'is-invalid': props.invalid,
5606
5621
  'is-valid': props.valid,