{"version":3,"file":"filter-list.js","sources":["../../../../../Flow.Showcase.Static.Bundler/Root/entrypoints/filter-list.ts"],"sourcesContent":["// @ts-nocheck\n\n/** @type {NodeListOf} */ (document.querySelectorAll(\"[data-filter-container]\")).forEach((filterList) => {\n const searchInput = /** @type {HTMLInputElement | null} */ (filterList.querySelector(\"[data-filter-search]\"));\n const moreButton = /** @type {HTMLButtonElement | null} */ (filterList.querySelector(\"[data-btn-more]\"));\n const lessButton = /** @type {HTMLButtonElement | null} */ (filterList.querySelector(\"[data-btn-less]\"));\n const items = /** @type {HTMLElement[]} */ ([...filterList.querySelectorAll(\"[data-filter-item]\")]);\n const placeholder = filterList.querySelector(\"[data-filter-placeholder]\");\n\n if (!searchInput || !moreButton || !lessButton || !placeholder) {\n throw new Error('Failed to find an element for filtered list')\n }\n\n // Раскрытие списка\n moreButton.addEventListener('click', () => {\n filterList.dataset.expanded = \"true\";\n toggleButtons();\n });\n\n // Сворачивание списка\n lessButton.addEventListener('click', () => {\n filterList.dataset.expanded = \"false\";\n\n items.forEach((item) => {\n item.classList.remove(\"display-none\");\n });\n searchInput.value = \"\";\n showPlaceholder(false);\n toggleButtons();\n });\n\n // Поиск и фильтрация элементов списка\n searchInput.addEventListener('input', (e) => {\n const searchString = /** @type {HTMLInputElement} */ (e.target).value.toLowerCase().trim();\n items.forEach((item) => {\n const isItemVisible = item.dataset.title?.toLowerCase().trim().includes(searchString);\n\n if (isItemVisible) {\n item.classList.remove(\"display-none\");\n } else {\n item.classList.add(\"display-none\");\n }\n });\n\n const hasVisibleItems = items.some((item) => window.getComputedStyle(item).display !== 'none');\n showPlaceholder(!hasVisibleItems);\n });\n\n // Показать или скрыть сообщение о том, что искомые элементы в списке не найдены\n /** @param {boolean} show */\n const showPlaceholder = (show) => {\n if (show) {\n placeholder.classList.remove(\"display-none\");\n } else {\n placeholder.classList.add(\"display-none\");\n }\n }\n\n const toggleButtons = () => {\n moreButton.classList.toggle('display-none');\n lessButton.classList.toggle('display-none');\n }\n});\n"],"names":["filterList","searchInput","moreButton","lessButton","items","placeholder","toggleButtons","item","showPlaceholder","e","searchString","_a","hasVisibleItems","show"],"mappings":"AAEwC,SAAS,iBAAiB,yBAAyB,EAAG,QAASA,GAAe,CAC9G,MAAAC,EAAsDD,EAAW,cAAc,sBAAsB,EACrGE,EAAsDF,EAAW,cAAc,iBAAiB,EAChGG,EAAsDH,EAAW,cAAc,iBAAiB,EAChGI,EAAsC,CAAC,GAAGJ,EAAW,iBAAiB,oBAAoB,CAAC,EAC3FK,EAAcL,EAAW,cAAc,2BAA2B,EAExE,GAAI,CAACC,GAAe,CAACC,GAAc,CAACC,GAAc,CAACE,EAC3C,MAAA,IAAI,MAAM,6CAA6C,EAIpDH,EAAA,iBAAiB,QAAS,IAAM,CACzCF,EAAW,QAAQ,SAAW,OAChBM,EAAA,CAAA,CACf,EAGUH,EAAA,iBAAiB,QAAS,IAAM,CACzCH,EAAW,QAAQ,SAAW,QAExBI,EAAA,QAASG,GAAS,CACjBA,EAAA,UAAU,OAAO,cAAc,CAAA,CACrC,EACDN,EAAY,MAAQ,GACpBO,EAAgB,EAAK,EACPF,EAAA,CAAA,CACf,EAGWL,EAAA,iBAAiB,QAAUQ,GAAM,CACrC,MAAAC,EAAgDD,EAAE,OAAQ,MAAM,cAAc,KAAK,EACnFL,EAAA,QAASG,GAAS,CAhCY,IAAAI,IAiCZA,EAAAJ,EAAK,QAAQ,QAAb,YAAAI,EAAoB,cAAc,OAAO,SAASD,IAGjEH,EAAA,UAAU,OAAO,cAAc,EAE/BA,EAAA,UAAU,IAAI,cAAc,CACnC,CACD,EAEK,MAAAK,EAAkBR,EAAM,KAAMG,GAAS,OAAO,iBAAiBA,CAAI,EAAE,UAAY,MAAM,EAC7FC,EAAgB,CAACI,CAAe,CAAA,CACjC,EAIK,MAAAJ,EAAmBK,GAAS,CAC5BA,EACUR,EAAA,UAAU,OAAO,cAAc,EAE/BA,EAAA,UAAU,IAAI,cAAc,CAE5C,EAEMC,EAAgB,IAAM,CACfJ,EAAA,UAAU,OAAO,cAAc,EAC/BC,EAAA,UAAU,OAAO,cAAc,CAC5C,CACF,CAAC"}