{"version":3,"file":"accessibility.utils-BHpQquJG.js","sources":["../../../../Coloplast.UI/src/shared/utils/accessibility.utils.ts"],"sourcesContent":["/**\r\n * Helps to convert keydown events to \"click\", eg. on labels connected to checkboxes\r\n * @param e - keyboard event\r\n * @param keysToClick - keys to be treated as \"click\"\r\n */\r\nexport function keydownToClick(e: KeyboardEvent, keysToClick: string[] = ['Enter', 'Space', 'NumpadEnter']) {\r\n\te.preventDefault();\r\n\r\n\tif (!e.target || e.code && !keysToClick.includes(e.code)) return;\r\n\r\n\tconst targetElement = (e.target as HTMLElement);\r\n\tconst element = targetElement?.getAttribute('type') !== 'button' ? targetElement.closest('button') : targetElement;\r\n\tconst htmlElement = element || targetElement\r\n\r\n\thtmlElement?.previousElementSibling?.dispatchEvent(new MouseEvent('click'));\r\n}\r\n"],"names":["keydownToClick","keysToClick","_a","targetElement","htmlElement"],"mappings":"AAKO,SAASA,EAAe,EAAkBC,EAAwB,CAAC,QAAS,QAAS,aAAa,EAAG,CAArG,IAAAC,EAGF,GAFJ,EAAE,eAAe,EAEb,CAAC,EAAE,QAAU,EAAE,MAAQ,CAACD,EAAY,SAAS,EAAE,IAAI,EAAG,OAE1D,MAAME,EAAiB,EAAE,OAEnBC,IADUD,GAAA,YAAAA,EAAe,aAAa,WAAY,SAAWA,EAAc,QAAQ,QAAQ,EAAIA,IACtEA,GAE/BD,EAAAE,GAAA,YAAAA,EAAa,yBAAb,MAAAF,EAAqC,cAAc,IAAI,WAAW,OAAO,EAC1E"}