1 min read

QueryPreviewList

QueryPreviewList

Renders the results previews of a list of objects with the information about the query preview, and exposes the QueryPreview slots to modify the content. The requests are made in sequential order.

Props

Name Description Type Default
queriesPreviewInfo The list of queries preview to render. QueryPreviewInfo[]
queryFeature The origin property for the request on each query preview. QueryFeature
maxItemsToRender Number of query preview results to be rendered on each query preview. number
debounceTimeMs Debounce time in milliseconds for triggering the search requests
on each query preview.
It will default to 0 to fit the most common use case (pre-search),
and it would work properly with a 250 value inside empathize.
number 0
persistInCache Controls whether all the QueryPreview should be removed from the state
when the component is destroyed.
boolean
animation Animation component that will be used to animate the elements. AnimationProp 'ul'

Slots

Name Description Bindings
(name - type - description)
slotName

See it in action

Here you have a basic example of how the QueryPreviewList is rendered. Keep in mind that this component is intended to be used overriding its default slot. By default it will only render the names of the results.

Play with the default slot

In this example, the results will be rendered inside a sliding panel.

Play with the result slot

The component exposes a slot to override the result content, without modifying the list.

In this example, the ID of the results will be rendered along with the name.

<template>
  <QueryPreviewList
    class="x-flex x-gap-8"
    :queriesPreviewInfo="queriesPreviewInfo"
    #result="{ result }"
  >
    <span class="x-font-bold">{{ result.id }}:</span>
    <span>{{ result.name }}</span>
  </QueryPreviewList>
</template>
<script>
  import { QueryPreviewList } from '@empathyco/x-components/queries-preview';
  export default {
    name: 'QueryPreviewListDemoOverridingResultSlot',
    components: {
      QueryPreviewList
    },
    data() {
      return {
        queriesPreviewInfo: [{ query: 'sandals' }, { query: 'tshirt' }, { query: 'jacket' }]
      };
    }
  };
</script>