Skip to content

Commit

Permalink
feat: move use-filters-injection file && refactor category filter cre…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
lauramargar committed May 15, 2024
1 parent 09ae739 commit b2c342f
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 19 deletions.
15 changes: 5 additions & 10 deletions packages/_vue3-migration-test/src/x-modules/facets/x-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@ const facets: Record<Facet['id'], Facet> = {
createFilter('red', true),
createFilter('blue', false)
]),
category: createSimpleFacetStub('category', createFilter => [
createFilter('dress', false),
createFilter('floral', false, 5),
createFilter('skirt', false, 9),
createFilter('print', false, 9),
createFilter('midi', false, 3),
createFilter('fitted', false, 0),
createFilter('short', false),
createFilter('long', false, 15)
])
category: createSimpleFacetStub('category', createFilter =>
['dress', 'floral', 'skirt', 'print', 'midi', 'fitted', 'short', 'long'].map((query, index) =>
createFilter(query, false, index)
)
)
};
const filters = arrayToObject(
Object.values(facets).flatMap(facet => facet.filters),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
createHierarchicalFilter,
createSimpleFilter
} from '../../__stubs__/filters-stubs.factory';
import { useFiltersInjection } from '../use-filters-injection';
import { useFiltersInjection } from '../../x-modules/facets/composables/use-filters-injection';

const Provider = defineComponent({
name: 'Provider',
Expand Down
1 change: 0 additions & 1 deletion packages/x-components/src/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ export * from './use-store';
export * from './use-state';
export * from './use-getter';
export * from './use-alias-api';
export * from './use-filters-injection';
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { computed, defineComponent, PropType, provide, h } from 'vue';
import { facetsXModule } from '../../x-module';
import { useRegisterXModule } from '../../../../composables/use-register-x-module';
import { useFiltersInjection } from '../../../../composables/use-filters-injection';
import { useFiltersInjection } from '../../composables/use-filters-injection';
/**
* The `ExcludeFiltersWithNoResults` component filters the provided list of filters, excluding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import { facetsXModule } from '../../x-module';
import { AnimationProp } from '../../../../types/animation-prop';
import { useRegisterXModule } from '../../../../composables/use-register-x-module';
import { useFiltersInjection } from '../../../../composables/use-filters-injection';
import { useFiltersInjection } from '../../composables/use-filters-injection';
/**
* Renders a list with a list item per each
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import { DebouncedFunction, VueCSSClasses } from '../../../../utils/types';
import { facetsXModule } from '../../x-module';
import { useRegisterXModule } from '../../../../composables/use-register-x-module';
import { useFiltersInjection } from '../../../../composables/use-filters-injection';
import { useFiltersInjection } from '../../composables/use-filters-injection';
/**
* Renders the filters sifted with the input query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import { VueCSSClasses } from '../../../../utils';
import { facetsXModule } from '../../x-module';
import { useRegisterXModule } from '../../../../composables/use-register-x-module';
import { useFiltersInjection } from '../../../../composables/use-filters-injection';
import { useFiltersInjection } from '../../composables/use-filters-injection';
/**
* Component that slices a list of filters and returns them using the default scoped slot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { isArrayEmpty } from '../../../../utils';
import { facetsXModule } from '../../x-module';
import { useRegisterXModule } from '../../../../composables/use-register-x-module';
import { useFiltersInjection } from '../../../../composables/use-filters-injection';
import { useFiltersInjection } from '../../composables/use-filters-injection';
/**
* Component that sorts a list of filters and returns them using the default scoped slot.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './use-facets';
export * from './use-filters-injection';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Filter, HierarchicalFilter, isHierarchicalFilter } from '@empathyco/x-types';
import { computed, inject, Ref } from 'vue';
import { isArrayEmpty } from '../utils/array';
import { isArrayEmpty } from '../../../utils/array';

/**
* Composable to share filters injection logic.
Expand All @@ -17,7 +17,7 @@ export function useFiltersInjection(props: {
This prop is used in the `HierarchicalFilter` component and only in that case. It is necessary
to make the `renderedFilters` to return only the filters of each level of the hierarchy.
*/
parentId?: Filter['id'] | undefined;
parentId?: Filter['id'];
}) {
/**
* The injected filters array.
Expand Down

0 comments on commit b2c342f

Please sign in to comment.