Filter

<div x-data class="fixed right-0 z-40 inset-y-0 max-w-full">
    <div x-cloak x-transition.opacity x-show="$store.asideBlocs.asides.find(aside => aside.name === 'storeLocatorFilter')?.open" class="fixed inset-0 w-full h-full bg-dark-40 backdrop-blur-xl"></div>
    <div x-cloak x-transition:enter="transition ease-out duration-300" x-transition:enter-start="translate-x-full" x-transition:enter-end="translate-x-0" x-transition:leave="transition ease-in duration-300" x-transition:leave-start="translate-x-0" x-transition:leave-end="translate-x-full" x-show="$store.asideBlocs.asides.find(aside => aside.name === 'storeLocatorFilter')?.open" class="h-full relative bg-light-white overflow-hidden w-screen md:max-w-screen-sm flex flex-col" @click.outside="$store.asideBlocs.closeAside('storeLocatorFilter')">
        <div class="p-4 md:px-10 md:py-6 font-medium text-2xl flex justify-between items-center">
            Filtrer
            <button type="button" @click="$store.asideBlocs.closeAside('storeLocatorFilter')" class="max-md:btn-size-sm btn btn-dark-ghost  btn-only-icon">
                <svg class=" shrink-0" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path fill-rule="evenodd" clip-rule="evenodd" d="M8.99469 7.9047C8.70179 7.6118 8.22692 7.6118 7.93403 7.9047C7.64113 8.19759 7.64113 8.67246 7.93403 8.96536L10.9392 11.9706L7.93403 14.9758C7.64114 15.2687 7.64114 15.7435 7.93403 16.0364C8.22693 16.3293 8.7018 16.3293 8.99469 16.0364L11.9999 13.0312L15.0051 16.0364C15.298 16.3293 15.7729 16.3293 16.0658 16.0364C16.3586 15.7435 16.3586 15.2687 16.0658 14.9758L13.0606 11.9706L16.0658 8.96536C16.3587 8.67246 16.3587 8.19759 16.0658 7.9047C15.7729 7.6118 15.298 7.6118 15.0051 7.9047L11.9999 10.9099L8.99469 7.9047Z" fill="currentColor" />
                </svg>

            </button>
        </div>
        <div class="px-4 md:px-10 overflow-auto flex-1 border-t border-b border-neutral-200">

            <div x-cloak class="text-neutral-800">
                <div class="flex flex-col gap-2 flex-wrap">

                    <p class="font-medium py-4 md:pt-6 md:pb-3 text-base md:text-xl">Spécialités du magasin</p>
                    <div x-data="storeFilters('types')" class="flex flex-col gap-4 md:gap-6 w-full">
                        <div x-show="items.length > 0" class="grid grid-cols-1 md:grid-cols-2 gap-4 md:gap-6 pb-4 md:pb-3">
                            <template x-for="item in filteredItems" :key="item.label">
                                <label class="selection-control-label selection-control-size-md">
                                    <input :checked="$store.locator.currentSelectedFilters[category].includes(item.label)" @click="$store.locator.updateFilter(category, item.label)" type="checkbox">
                                    <span x-text="item.label + ' (' + item.count + ')'"></span>
                                </label>
                            </template>
                        </div>
                    </div>

                    <script>
                        function storeFilters(category) {
                            return {
                                search: '',
                                category: category,
                                items: [],
                                init() {
                                    // Observer les changements dans les filtres du type actuel
                                    this.$watch('$store.locator.currentFilterList', (value) => {
                                        if (value && value[this.category]) {
                                            this.items = value[this.category];
                                        }
                                    }, {
                                        deep: true
                                    });
                                    // Initialisation immédiate si les données sont déjà disponibles
                                    if (this.$store.locator.currentFilterList?.[this.category]) {
                                        this.items = this.$store.locator.currentFilterList[this.category];
                                    }
                                },
                            }
                        }
                    </script>

                    <div x-data="{ expanded: false }" class="border-b border-neutral-200 md:pb-3 text-neutral-800 text-neutral-800">
                        <h2 class="font-medium py-4 md:pt-6 md:pb-3 text-base md:text-xl">
                            <button type="button" @click="expanded = !expanded " class="flex justify-between items-center w-full ">
                                <span class="flex flex-wrap gap-3">
                                    Mutuelles
                                </span>

                                <span :class="expanded ? 'rotate-180' : ''" class="transform transition-transform duration-300">
                                    <svg class=" shrink-0" width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path fill-rule="evenodd" clip-rule="evenodd" d="M12.5303 14.5303C12.2374 14.8232 11.7626 14.8232 11.4697 14.5303L7.46967 10.5303C7.17678 10.2374 7.17678 9.76256 7.46967 9.46967C7.76256 9.17678 8.23744 9.17678 8.53033 9.46967L12 12.9393L15.4697 9.46967C15.7626 9.17678 16.2374 9.17678 16.5303 9.46967C16.8232 9.76256 16.8232 10.2374 16.5303 10.5303L12.5303 14.5303Z" fill="currentColor" />
                                    </svg>
                                </span>
                            </button>
                        </h2>
                        <div x-cloak x-show="expanded" x-collapse class=" ">
                            <div x-data="storeFilters('mutuals')" class="flex flex-col gap-4 md:gap-6 w-full">
                                <label class="relative">
                                    <input x-model="search" type="text" placeholder="Rechercher" class="w-full leading-icon">
                                    <svg class=" shrink-0" width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path fill-rule="evenodd" clip-rule="evenodd" d="M11 3.75C6.99594 3.75 3.75 6.99594 3.75 11C3.75 15.0041 6.99594 18.25 11 18.25C15.0041 18.25 18.25 15.0041 18.25 11C18.25 6.99594 15.0041 3.75 11 3.75ZM2.25 11C2.25 6.16751 6.16751 2.25 11 2.25C15.8325 2.25 19.75 6.16751 19.75 11C19.75 13.1462 18.9773 15.112 17.6949 16.6342L21.5303 20.4697C21.8232 20.7626 21.8232 21.2374 21.5303 21.5303C21.2374 21.8232 20.7626 21.8232 20.4697 21.5303L16.6342 17.6949C15.112 18.9773 13.1462 19.75 11 19.75C6.16751 19.75 2.25 15.8325 2.25 11Z" fill="currentColor" />
                                    </svg>
                                </label>

                                <div x-show="items.length > 0" class="grid grid-cols-1 md:grid-cols-2 gap-4 md:gap-6 pb-4 md:pb-3">
                                    <template x-for="item in filteredItems" :key="item.label">
                                        <label class="selection-control-label selection-control-size-md">
                                            <input :checked="$store.locator.currentSelectedFilters[category].includes(item.label)" @click="$store.locator.updateFilter(category, item.label)" type="checkbox">
                                            <span x-text="item.label + ' (' + item.count + ')'"></span>
                                        </label>
                                    </template>
                                </div>
                            </div>

                            <script>
                                function storeFilters(category) {
                                    return {
                                        search: '',
                                        category: category,
                                        items: [],
                                        init() {
                                            // Observer les changements dans les filtres du type actuel
                                            this.$watch('$store.locator.currentFilterList', (value) => {
                                                if (value && value[this.category]) {
                                                    this.items = value[this.category];
                                                }
                                            }, {
                                                deep: true
                                            });
                                            // Initialisation immédiate si les données sont déjà disponibles
                                            if (this.$store.locator.currentFilterList?.[this.category]) {
                                                this.items = this.$store.locator.currentFilterList[this.category];
                                            }
                                        },
                                        get filteredItems() {
                                            if (this.search === '') {
                                                return this.items;
                                            }
                                            return this.items.filter(item =>
                                                item.toLowerCase()
                                                .replace(/ /g, '')
                                                .includes(this.search.toLowerCase().replace(/ /g, ''))
                                            );
                                        }
                                    }
                                }
                            </script>

                        </div>
                    </div>

                    <div x-data="{ expanded: false }" class="border-b border-neutral-200 md:pb-3 text-neutral-800 text-neutral-800">
                        <h2 class="font-medium py-4 md:pt-6 md:pb-3 text-base md:text-xl">
                            <button type="button" @click="expanded = !expanded " class="flex justify-between items-center w-full ">
                                <span class="flex flex-wrap gap-3">
                                    Marques
                                </span>

                                <span :class="expanded ? 'rotate-180' : ''" class="transform transition-transform duration-300">
                                    <svg class=" shrink-0" width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path fill-rule="evenodd" clip-rule="evenodd" d="M12.5303 14.5303C12.2374 14.8232 11.7626 14.8232 11.4697 14.5303L7.46967 10.5303C7.17678 10.2374 7.17678 9.76256 7.46967 9.46967C7.76256 9.17678 8.23744 9.17678 8.53033 9.46967L12 12.9393L15.4697 9.46967C15.7626 9.17678 16.2374 9.17678 16.5303 9.46967C16.8232 9.76256 16.8232 10.2374 16.5303 10.5303L12.5303 14.5303Z" fill="currentColor" />
                                    </svg>
                                </span>
                            </button>
                        </h2>
                        <div x-cloak x-show="expanded" x-collapse class=" ">
                            <div x-data="storeFilters('brands')" class="flex flex-col gap-4 md:gap-6 w-full">
                                <label class="relative">
                                    <input x-model="search" type="text" placeholder="Rechercher" class="w-full leading-icon">
                                    <svg class=" shrink-0" width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path fill-rule="evenodd" clip-rule="evenodd" d="M11 3.75C6.99594 3.75 3.75 6.99594 3.75 11C3.75 15.0041 6.99594 18.25 11 18.25C15.0041 18.25 18.25 15.0041 18.25 11C18.25 6.99594 15.0041 3.75 11 3.75ZM2.25 11C2.25 6.16751 6.16751 2.25 11 2.25C15.8325 2.25 19.75 6.16751 19.75 11C19.75 13.1462 18.9773 15.112 17.6949 16.6342L21.5303 20.4697C21.8232 20.7626 21.8232 21.2374 21.5303 21.5303C21.2374 21.8232 20.7626 21.8232 20.4697 21.5303L16.6342 17.6949C15.112 18.9773 13.1462 19.75 11 19.75C6.16751 19.75 2.25 15.8325 2.25 11Z" fill="currentColor" />
                                    </svg>
                                </label>

                                <div x-show="items.length > 0" class="grid grid-cols-1 md:grid-cols-2 gap-4 md:gap-6 pb-4 md:pb-3">
                                    <template x-for="item in filteredItems" :key="item.label">
                                        <label class="selection-control-label selection-control-size-md">
                                            <input :checked="$store.locator.currentSelectedFilters[category].includes(item.label)" @click="$store.locator.updateFilter(category, item.label)" type="checkbox">
                                            <span x-text="item.label + ' (' + item.count + ')'"></span>
                                        </label>
                                    </template>
                                </div>
                            </div>

                            <script>
                                function storeFilters(category) {
                                    return {
                                        search: '',
                                        category: category,
                                        items: [],
                                        init() {
                                            // Observer les changements dans les filtres du type actuel
                                            this.$watch('$store.locator.currentFilterList', (value) => {
                                                if (value && value[this.category]) {
                                                    this.items = value[this.category];
                                                }
                                            }, {
                                                deep: true
                                            });
                                            // Initialisation immédiate si les données sont déjà disponibles
                                            if (this.$store.locator.currentFilterList?.[this.category]) {
                                                this.items = this.$store.locator.currentFilterList[this.category];
                                            }
                                        },
                                        get filteredItems() {
                                            if (this.search === '') {
                                                return this.items;
                                            }
                                            return this.items.filter(item =>
                                                item.toLowerCase()
                                                .replace(/ /g, '')
                                                .includes(this.search.toLowerCase().replace(/ /g, ''))
                                            );
                                        }
                                    }
                                }
                            </script>

                        </div>
                    </div>
                </div>
            </div>

        </div>
        <div class="p-2 md:px-10 md:py-6">
            <div class="flex items-center justify-between">
                <a href="#" x-data="{ buttonLabel() { return `Voir les ${$store.locator.countStore} magasins` } }" @click="$store.locator.applyFilters(); $store.asideBlocs.closeAside('storeLocatorFilter')" :class="$store.locator.isAudio ? 'btn-audio' : 'btn-dark'" x-text="buttonLabel()" class="w-full  btn btn-audio btn-size-lg">
                    Voir les magasins

                </a>
            </div>
        </div>
    </div>
</div>
{% embed "@side-panel" with panel|merge({sidePanelButton:panel.sidePanelButton|merge({label:(panel.sidePanelButton.label is defined ? panel.sidePanelButton.label|format(product_quantity|default('600')))})}) %}
    {% block content %}
        {# Section des filtres appliqués #}
        <div x-cloak
             class="text-neutral-800"
        >
            <div class="flex flex-col gap-2 flex-wrap">
                {# Filtres Types #}
                {% render "@storelocator-checkboxes" with { category: 'types' } %}

                {# Filtres Mutuelles #}
                {% render "@storelocator-searchable-checkboxes" with { category: 'mutuals' } %}

                {# Filtres Marques #}
                {% render "@storelocator-searchable-checkboxes" with { category: 'brands' } %}
            </div>
        </div>
    {% endblock %}

    {% block panel_button %}
        <div class="flex items-center justify-between">
            {% render "@template-button" with panel.sidePanelButton|merge({
                label: "Voir les magasins",
                size: 'lg',
                color: 'audio',
                button_class: "w-full",
                button_attribute: ('x-data="{ buttonLabel() { return `Voir les ${$store.locator.countStore} magasins` } }" @click="$store.locator.applyFilters(); $store.asideBlocs.closeAside(\'storeLocatorFilter\')" :class="$store.locator.isAudio ? \'btn-audio\' : \'btn-dark\'" x-text="buttonLabel()"')|replace({"\'": "'"}),
            }) %}
        </div>
    {% endblock %}
{% endembed %}
{
  "accordion": {
    "accordion_title_class": "font-medium pt-6 pb-3 text-xl",
    "accordion_content_class": " ",
    "accordion_border_class": "pt-3",
    "border": true,
    "chevronIcon": {
      "size": "32"
    }
  },
  "panel": {
    "title": "Filtrer",
    "sidePanelButton": {
      "label": "Filtre",
      "href": "#"
    },
    "showValue": "$store.asideBlocs.asides.find(aside => aside.name === 'storeLocatorFilter')?.open",
    "closeButtonAlpineClick": "$store.asideBlocs.closeAside('storeLocatorFilter')"
  }
}

No notes defined.