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B,OAAQ,CAAEX,UAAW,6BAA8BO,GAAI7B,EAAM8B,WAAa,UAAyC,QAA5B7B,EAAKD,EAAMmC,mBAAgC,IAAPlC,EAAgBA,EAAKD,EAAMoC,cAC3O,OACFpC,aAAqC,EAASA,EAAMkC,YAAc,gBAAoB,OAAQ,CAAEZ,UAAW,wBAA6C,WAAnBtB,EAAMqC,SAAwBrC,EAAMqB,YAA2C,QAA5BnB,EAAKF,EAAMqB,mBAAgC,IAAPnB,OAAgB,EAASA,EAAGoC,eAC9P,gBAAoB,MAAO,CAAEC,KAAMvC,EAAMwC,UAAY,KAAMlB,UAAW,IAAW,sBAAuB,CAAEmB,QAAShC,IAAciC,QAAS,KAElIhC,GAAa,EAAK,EACnBiC,OAAQ,KAEPjC,GAAa,EAAM,GAClBV,EAAM0B,WAAY,EAEvC3B,EAAS6C,aAAe,CACpBC,YAAY,EACZC,uBAAuB,EACvBZ,WAAW,EACXG,SAAU,UAEd,W","sources":["webpack:///./assets/stone/src/components/product/Selector.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport whatInput from 'what-input';\nconst Selector = (props) => {\n var _a, _b;\n const selectorRef = useRef(null);\n const menuRef = useRef(null);\n const [open, setOpen] = useState(false);\n const [focusList, setFocusList] = useState(false);\n useLayoutEffect(() => {\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 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(\"fieldset\", { ref: menuRef, className: classNames('selector__menu'), id: props.selectorId, tabIndex: -1 },\n React.createElement(\"legend\", { className: \"visually-hidden\" }, props.unselectedLabel),\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 React.createElement(\"div\", { role: props.listRole || null, className: classNames('selector__menu-list', { focused: focusList }), onFocus: () => {\n // handles color labels show/hide on keyboard focus\n setFocusList(true);\n }, onBlur: () => {\n // handles color labels show/hide on keyboard focus\n setFocusList(false);\n } }, props.children))));\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","focusList","setFocusList","useLayoutEffect","trackOpen","menuHeight","current","offsetHeight","style","height","visibility","removeAttribute","useEffect","currentItem","className","ref","onMouseEnter","disableHover","children","length","onMouseLeave","id","selectorId","tabIndex","unselectedLabel","hideLabel","hideValue","selectLabel","selectedLabel","itemType","displayValue","role","listRole","focused","onFocus","onBlur","defaultProps","swatchable","enableOutofstockLabel"],"sourceRoot":""}