Skip to content

Commit

Permalink
chore: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
annacv committed Mar 1, 2024
1 parent 274277c commit 896ddf3
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<template>
<div></div>
</template>
<script lang="ts">
import { defineComponent, PropType, onMounted, watch, computed, ComputedRef } from 'vue';
import { defineComponent, PropType, onMounted, watch, computed, ref, inject } from 'vue';
import { createRawFilters } from '../../../utils/filters';
import { isArrayEmpty } from '../../../utils/array';
import { SnippetConfig } from '../../../x-installer/api/api.types';
import { useHybridInject, useNoElementRender } from '../../../composables/index';
import { useXBus } from '../../../composables/use-x-bus';
/**
Expand All @@ -28,7 +30,7 @@
default: () => []
}
},
setup(props, { slots }) {
setup() {
// eslint-disable-next-line @typescript-eslint/unbound-method
const { emit } = useXBus();
Expand All @@ -37,17 +39,19 @@
*
* @internal
*/
const snippetConfig = useHybridInject<SnippetConfig>('snippetConfig');
const snippetConfig = inject<SnippetConfig>('snippetConfig');
/**
* Gets the provided preselected filters prioritizing the {@link SnippetConfig} over the
* filters prop.
*
* @returns An array of filter's ids.
*/
const preselectedFilters: ComputedRef<string[]> = computed(() => {
return snippetConfig.value?.filters ?? props.filters;
});
const preselectedFilters = ref(
computed(() => {
return snippetConfig?.filters;
})
);
/**
* Emits the {@link FacetsXEvents.PreselectedFiltersProvided} to save
Expand All @@ -63,7 +67,7 @@
* Emits the {@link FacetsXEvents.PreselectedFiltersProvided} when the
* computed prop changes.
*/
watch(preselectedFilters, emitPreselectedFilters);
watch(() => snippetConfig?.filters, emitPreselectedFilters);
/**
* Emits the {@link FacetsXEvents.PreselectedFiltersProvided} when the
Expand All @@ -73,7 +77,10 @@
emitPreselectedFilters();
});
return () => useNoElementRender(slots);
return {
snippetConfig,
preselectedFilters
};
}
});
</script>
Expand Down

0 comments on commit 896ddf3

Please sign in to comment.