From a485dea768918280e2fec46cae0d5a3f4932002f Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Wed, 24 Jul 2024 17:57:35 +0200 Subject: [PATCH] feat: make internal demo app functional (#1574) BREAKING-CHANGE: refactors the GlobalXBus to use a prop to receive the listeners instead of relying on attributes. --- .../x-components/src/components/base-grid.vue | 20 +- .../src/components/global-x-bus.vue | 19 +- .../src/components/snippet-callbacks.vue | 2 +- packages/x-components/src/views/home/Home.vue | 596 +++++++++--------- 4 files changed, 323 insertions(+), 314 deletions(-) diff --git a/packages/x-components/src/components/base-grid.vue b/packages/x-components/src/components/base-grid.vue index 1d4a096948..86ed995de2 100644 --- a/packages/x-components/src/components/base-grid.vue +++ b/packages/x-components/src/components/base-grid.vue @@ -36,12 +36,17 @@ defineComponent, inject, onBeforeUnmount, + onMounted, PropType, Ref, ref, watch } from 'vue'; - import { MaybeComputedElementRef, useResizeObserver } from '@vueuse/core'; + import { + MaybeComputedElementRef, + useResizeObserver, + UseResizeObserverReturn + } from '@vueuse/core'; import { toKebabCase } from '../utils/string'; import { ListItem, VueCSSClasses } from '../utils/types'; import { AnimationProp } from '../types/animation-prop'; @@ -229,11 +234,14 @@ * * @internal */ - const resizeObserver = useResizeObserver( - gridEl as MaybeComputedElementRef, - updateRenderedColumnsNumber - ); - onBeforeUnmount(() => resizeObserver.stop()); + let resizeObserver: UseResizeObserverReturn; + onMounted(() => { + resizeObserver = useResizeObserver( + gridEl as MaybeComputedElementRef, + updateRenderedColumnsNumber + ); + }); + onBeforeUnmount(() => resizeObserver?.stop()); return { gridItems, diff --git a/packages/x-components/src/components/global-x-bus.vue b/packages/x-components/src/components/global-x-bus.vue index b816054fb5..eefae60612 100644 --- a/packages/x-components/src/components/global-x-bus.vue +++ b/packages/x-components/src/components/global-x-bus.vue @@ -1,8 +1,7 @@ @@ -39,11 +44,11 @@ This component emits no own events, but you can subscribe to any X Event using V ## See it in action This component does not render anything. Its only responsibility is to facilitate listening to any X -Event by using Vue component listeners. +Event by using the prop `listeners` ```vue