{"version":3,"file":"product-card-list.js","sources":["../../../../../Flow.Showcase.Static.Bundler/Root/entrypoints/product-card-list.ts"],"sourcesContent":["// @ts-nocheck\n\n// Список продуктовых карточек в виде слайдера\ndocument\n .querySelectorAll(\"[data-product-card-list-slider]\")\n .forEach((element) => {\n try {\n const scrollArea = /** @type {HTMLDivElement} */ (\n element.querySelector(\"[data-scroll-area]\")\n );\n const leftBtn = /** @type {HTMLButtonElement} */ (\n element.querySelector(\"[data-left-btn]\")\n );\n const rightBtn = /** @type {HTMLButtonElement} */ (\n element.querySelector(\"[data-right-btn]\")\n );\n\n updateScrollButtons();\n\n leftBtn.addEventListener(\"click\", () => {\n scrollArea.scrollTo({\n left: scrollArea.scrollLeft - scrollArea.clientWidth,\n behavior: \"smooth\",\n });\n });\n\n rightBtn.addEventListener(\"click\", () => {\n scrollArea.scrollTo({\n left: scrollArea.scrollLeft + scrollArea.clientWidth,\n behavior: \"smooth\",\n });\n });\n\n scrollArea.addEventListener(\"scrollend\", updateScrollButtons);\n new ResizeObserver(updateScrollButtons).observe(scrollArea);\n\n // Обновить состояние кнопок прокрутки влево/вправо.\n // Если все карточки умещаются в область, то кнопки невидимы.\n // Если некуда прокручивать, то кнопка неактивная.\n function updateScrollButtons() {\n if (scrollArea.scrollWidth <= scrollArea.clientWidth) {\n leftBtn.classList.add(\"display-none\");\n rightBtn.classList.add(\"display-none\");\n } else {\n leftBtn.classList.remove(\"display-none\");\n rightBtn.classList.remove(\"display-none\");\n leftBtn.disabled = scrollArea.scrollLeft <= 0;\n rightBtn.disabled =\n scrollArea.scrollLeft >= scrollArea.scrollWidth - scrollArea.clientWidth;\n }\n }\n } catch (err) {\n console.error(err);\n }\n });\n\n\n// Расширяемый список продуктовых карточек\ndocument.querySelectorAll(\"[data-product-card-list-expandable]\").forEach(element => {\n try {\n const list = /** @type {HTMLDivElement} */ (\n element.querySelector(\"[data-list]\")\n );\n const showMoreBtn = /** @type {HTMLButtonElement} */ (\n element.querySelector(\"[data-show-more-btn]\")\n );\n const showLessBtn = /** @type {HTMLButtonElement} */ (\n element.querySelector(\"[data-show-less-btn]\")\n );\n\n showMoreBtn.addEventListener(\"click\", () => {\n list.dataset.expanded = \"true\";\n showMoreBtn.classList.toggle(\"display-none\", true);\n showLessBtn.classList.toggle(\"display-none\", false);\n });\n\n showLessBtn.addEventListener(\"click\", () => {\n list.dataset.expanded = \"false\";\n showMoreBtn.classList.toggle(\"display-none\", false);\n showLessBtn.classList.toggle(\"display-none\", true);\n })\n } catch (err) {\n console.error(err);\n }\n})\n"],"names":["element","updateScrollButtons","scrollArea","leftBtn","rightBtn","err","list","showMoreBtn","showLessBtn"],"mappings":"AAGA,SACK,iBAAiB,iCAAiC,EAClD,QAASA,GAAY,CACd,GAAA,CAiCA,IAASC,EAAT,UAA+B,CACvBC,EAAW,aAAeA,EAAW,aAC7BC,EAAA,UAAU,IAAI,cAAc,EAC3BC,EAAA,UAAU,IAAI,cAAc,IAE7BD,EAAA,UAAU,OAAO,cAAc,EAC9BC,EAAA,UAAU,OAAO,cAAc,EAChCD,EAAA,SAAWD,EAAW,YAAc,EAC5CE,EAAS,SACLF,EAAW,YAAcA,EAAW,YAAcA,EAAW,YAEzE,EAXSD,IAAAA,EAAAA,EAhCH,MAAAC,EACFF,EAAQ,cAAc,oBAAoB,EAExCG,EACFH,EAAQ,cAAc,iBAAiB,EAErCI,EACFJ,EAAQ,cAAc,kBAAkB,EAG5CC,EAAoB,EAEZE,EAAA,iBAAiB,QAAS,IAAM,CACpCD,EAAW,SAAS,CAChB,KAAMA,EAAW,WAAaA,EAAW,YACzC,SAAU,QAAA,CACb,CAAA,CACJ,EAEQE,EAAA,iBAAiB,QAAS,IAAM,CACrCF,EAAW,SAAS,CAChB,KAAMA,EAAW,WAAaA,EAAW,YACzC,SAAU,QAAA,CACb,CAAA,CACJ,EAEUA,EAAA,iBAAiB,YAAaD,CAAmB,EAC5D,IAAI,eAAeA,CAAmB,EAAE,QAAQC,CAAU,QAiBrDG,EAAK,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