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jE,EAAMkE,WAAa,UAAyC,QAA5BjE,EAAKD,EAAMsE,mBAAgC,IAAPrE,EAAgBA,EAAKD,EAAMuE,cAC3O,OACFvE,aAAqC,EAASA,EAAMqE,YAAc,gBAAoB,OAAQ,CAAEX,UAAW,wBAA6C,WAAnB1D,EAAMwE,SAAwBxE,EAAMkB,YAA2C,QAA5BhB,EAAKF,EAAMkB,mBAAgC,IAAPhB,OAAgB,EAASA,EAAGuE,eAC9PnE,GAAS,gBAAoB,WAAY,KACrC,gBAAoB,SAAU,CAAEoD,UAAW,mBAAqB1D,EAAM0E,iBACtE,gBAAoB,KAAgBC,OAAOC,OAAO,CAAEC,SAAWxD,IACvDF,EAAUP,QAAUS,CAAM,GACzBY,GAAajC,EAAM8D,SAAS,GAAGgB,KAAI,CAACC,EAAOC,IAAO,gBAAoB,KAAa,CAAEC,IAAKD,GAAKD,QAAc,EAEtIhF,EAASmF,aAAe,CACpBC,YAAY,EACZC,uBAAuB,EACvBf,WAAW,EACXG,SAAU,UAEd,W","sources":["webpack:///./assets/stone/src/components/product/SelectorSwiper.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport whatInput from 'what-input';\nimport SwiperCore, { A11y, Controller, EffectCoverflow, Keyboard } from 'swiper';\nimport { Swiper as SwiperInstance, SwiperSlide } from 'swiper/react';\nSwiperCore.use([A11y, Keyboard, Controller, EffectCoverflow]);\nconst Selector = (props) => {\n var _a, _b;\n const selectorRef = useRef(null);\n const menuRef = useRef(null);\n const [open, setOpen] = useState(false);\n useEffect(() => {\n var _a, _b;\n if (open) {\n props.trackOpen ? props.trackOpen() : null;\n const menuHeight = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight;\n if (selectorRef.current && menuHeight > selectorRef.current.offsetHeight) {\n selectorRef.current.style.height = `${menuHeight}px`;\n selectorRef.current.style.visibility = 'visible';\n }\n }\n else {\n (_b = selectorRef.current) === null || _b === void 0 ? void 0 : _b.removeAttribute('style');\n }\n }, [open]);\n useEffect(() => {\n setOpen(props.open);\n }, [props.open, props.currentItem]);\n const swiperRef = useRef();\n /* methods */\n const slideMove = (swiper) => {\n const prev = document.getElementById(`selector-prev-${props.groupid}`);\n const next = document.getElementById(`selector-next-${props.groupid}`);\n if (swiper.isBeginning) {\n prev === null || prev === void 0 ? void 0 : prev.setAttribute('disabled', 'disabled');\n prev === null || prev === void 0 ? void 0 : prev.classList.add('swiper-button-disabled');\n }\n else {\n prev === null || prev === void 0 ? void 0 : prev.removeAttribute('disabled');\n prev === null || prev === void 0 ? void 0 : prev.classList.remove('swiper-button-disabled');\n }\n if (swiper.isEnd) {\n next === null || next === void 0 ? void 0 : next.setAttribute('disabled', 'disabled');\n next === null || next === void 0 ? void 0 : next.classList.add('swiper-button-disabled');\n }\n else {\n next === null || next === void 0 ? void 0 : next.removeAttribute('disabled');\n next === null || next === void 0 ? void 0 : next.classList.remove('swiper-button-disabled');\n }\n };\n /* config */\n const swiperConf = {\n a11y: {\n slideRole: null,\n slideLabelMessage: null,\n },\n // navigation: true,\n slidesPerView: (props.fullExpanded && 4) || 3.5,\n spaceBetween: 4,\n autoplay: false,\n slideToClickedSlide: false,\n breakpoints: {\n [window.mqObj.lg]: {\n slidesPerView: 6,\n },\n [window.mqObj.xxl]: {\n slidesPerView: 5,\n spaceBetween: 6,\n },\n },\n onSlideChange: slideMove,\n onInit: (swiper) => {\n slideMove(swiper);\n },\n };\n /* EFFECT */\n useLayoutEffect(() => {\n const prev = document.getElementById(`selector-prev-${props.groupid}`);\n const next = document.getElementById(`selector-next-${props.groupid}`);\n const prevHandler = (e) => {\n e.preventDefault();\n swiperRef.current.slidePrev();\n };\n const nextHandler = (e) => {\n e.preventDefault();\n swiperRef.current.slideNext();\n };\n prev === null || prev === void 0 ? void 0 : prev.addEventListener('click', prevHandler);\n next === null || next === void 0 ? void 0 : next.addEventListener('click', nextHandler);\n return () => {\n prev === null || prev === void 0 ? void 0 : prev.removeEventListener('click', prevHandler);\n next === null || next === void 0 ? void 0 : next.removeEventListener('click', nextHandler);\n };\n }, [props.open]);\n return (React.createElement(\"div\", { className: classNames(props.className), ref: selectorRef, onMouseEnter: () => {\n whatInput.ask() === 'mouse' && !props.disableHover && props.children.length !== 1 && setOpen(true);\n }, onMouseLeave: () => {\n !props.disableHover && !props.open && props.children.length !== 1 && setOpen(false);\n } },\n React.createElement(\"div\", { ref: menuRef, className: classNames('selector__menu'), id: props.selectorId, \"aria-labelledby\": props.selectorId + '-title', \"aria-hidden\": open ? null : true, tabIndex: -1 },\n (!(props === null || props === void 0 ? void 0 : props.hideLabel) || (props === null || props === void 0 ? void 0 : props.hideValue)) && (React.createElement(\"div\", { className: \"selector__menu-labels\" },\n !(props === null || props === void 0 ? void 0 : props.hideLabel) && (React.createElement(\"span\", { className: \"selector__menu-label label\", id: props.selectorId + '-title' }, (_a = props.selectLabel) !== null && _a !== void 0 ? _a : props.selectedLabel,\n \":\")),\n !(props === null || props === void 0 ? void 0 : props.hideValue) && React.createElement(\"span\", { className: \"selector__menu-value\" }, props.itemType === 'string' ? props.currentItem : (_b = props.currentItem) === null || _b === void 0 ? void 0 : _b.displayValue))),\n open && (React.createElement(\"fieldset\", null,\n React.createElement(\"legend\", { className: \"visually-hidden\" }, props.unselectedLabel),\n React.createElement(SwiperInstance, Object.assign({ onSwiper: (swiper) => {\n swiperRef.current = swiper;\n } }, swiperConf), props.children[0].map((child, k) => (React.createElement(SwiperSlide, { key: k }, child)))))))));\n};\nSelector.defaultProps = {\n swatchable: false,\n enableOutofstockLabel: false,\n hideValue: false,\n itemType: 'object',\n};\nexport default Selector;\n"],"names":["Selector","props","_a","_b","selectorRef","useRef","menuRef","open","setOpen","useState","useEffect","trackOpen","menuHeight","current","offsetHeight","style","height","visibility","removeAttribute","currentItem","swiperRef","slideMove","swiper","prev","document","getElementById","groupid","next","isBeginning","setAttribute","classList","add","remove","isEnd","swiperConf","a11y","slideRole","slideLabelMessage","slidesPerView","fullExpanded","spaceBetween","autoplay","slideToClickedSlide","breakpoints","window","mqObj","lg","xxl","onSlideChange","onInit","useLayoutEffect","prevHandler","e","preventDefault","slidePrev","nextHandler","slideNext","addEventListener","removeEventListener","className","ref","onMouseEnter","disableHover","children","length","onMouseLeave","id","selectorId","tabIndex","hideLabel","hideValue","selectLabel","selectedLabel","itemType","displayValue","unselectedLabel","Object","assign","onSwiper","map","child","k","key","defaultProps","swatchable","enableOutofstockLabel"],"sourceRoot":""}