UNPKG

@empathyco/x-components

Version:
52 lines (49 loc) 1.75 kB
import { defineComponent, computed } from 'vue'; import BaseEventButton from '../../../components/base-event-button.vue.js'; import { useFacets } from '../composables/use-facets.js'; import { facetsXModule } from '../x-module.js'; /** * Renders a simple button, emitting the needed events when clicked. * * @public */ var _sfc_main = defineComponent({ name: 'ClearFilters', xModule: facetsXModule.name, components: { BaseEventButton }, props: { /** Array of facets ids used to get the selected filters for those facets. */ facetsIds: Array, /** Flag to render the component even if there are no filters selected. */ alwaysVisible: Boolean, }, setup(props) { const { selectedFilters, hasSelectedFilters, isVisible } = useFacets(props); /** * The events that will be emitted when the button clear filters is clicked. * * @returns The events to be emitted when the button clear filters is clicked. */ const events = computed(() => ({ UserClickedClearAllFilters: props.facetsIds, })); /** * Dynamic CSS classes to apply to the component. * * @returns The dynamic CSS classes to apply to the component. */ const cssClasses = computed(() => ({ 'x-clear-filters--has-not-selected-filters': !hasSelectedFilters.value, 'x-clear-filters--has-selected-filters': hasSelectedFilters.value, })); return { selectedFilters, hasSelectedFilters, isVisible, events, cssClasses, }; }, }); export { _sfc_main as default }; //# sourceMappingURL=clear-filters.vue2.js.map