Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
package.dist.prod.util.FocusableElements.js.map Maven / Gradle / Ivy
{
"version": 3,
"sources": ["../../../src/util/FocusableElements.ts"],
"sourcesContent": ["import isElementHidden from \"./isElementHidden.js\";\nimport isElementClickable from \"./isElementClickable.js\";\nimport { instanceOfUI5Element } from \"../UI5Element.js\";\n\ntype FocusableElementPromise = Promise;\n\nconst isFocusTrap = (el: HTMLElement) => {\n\treturn el.hasAttribute(\"data-ui5-focus-trap\");\n};\n\nconst getFirstFocusableElement = async (container: HTMLElement, startFromContainer?: boolean): FocusableElementPromise => {\n\tif (!container || isElementHidden(container)) {\n\t\treturn null;\n\t}\n\n\treturn findFocusableElement(container, true, startFromContainer);\n};\n\nconst getLastFocusableElement = async (container: HTMLElement, startFromContainer?: boolean): FocusableElementPromise => {\n\tif (!container || isElementHidden(container)) {\n\t\treturn null;\n\t}\n\n\treturn findFocusableElement(container, false, startFromContainer);\n};\n\nconst isElemFocusable = (el: HTMLElement) => {\n\treturn el.hasAttribute(\"data-ui5-focus-redirect\") || !isElementHidden(el);\n};\n\nconst findFocusableElement = async (container: HTMLElement, forward: boolean, startFromContainer?: boolean): FocusableElementPromise => {\n\tlet child: HTMLElement | undefined;\n\tlet assignedElements;\n\tlet currentIndex = -1;\n\n\tif (container.shadowRoot) {\n\t\tchild = forward ? container.shadowRoot.firstChild as HTMLElement : container.shadowRoot.lastChild as HTMLElement;\n\t} else if (container instanceof HTMLSlotElement && container.assignedNodes()) {\n\t\tassignedElements = container.assignedNodes();\n\t\tcurrentIndex = forward ? 0 : assignedElements.length - 1;\n\t\tchild = assignedElements[currentIndex] as HTMLElement;\n\t} else if (startFromContainer) {\n\t\tchild = container;\n\t} else {\n\t\tchild = forward ? container.firstElementChild as HTMLElement : container.lastElementChild as HTMLElement;\n\t}\n\n\tlet focusableDescendant;\n\n\t/* eslint-disable no-await-in-loop */\n\n\twhile (child) {\n\t\tconst originalChild: HTMLElement | undefined = child;\n\n\t\tif (instanceOfUI5Element(child)) {\n\t\t\tchild = await child.getFocusDomRefAsync();\n\t\t}\n\n\t\tif (!child) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (child.nodeType === 1 && isElemFocusable(child) && !isFocusTrap(child)) {\n\t\t\tif (isElementClickable(child)) {\n\t\t\t\treturn (child && typeof child.focus === \"function\") ? child : null;\n\t\t\t}\n\n\t\t\tfocusableDescendant = await findFocusableElement(child, forward);\n\t\t\tif (focusableDescendant) {\n\t\t\t\treturn (focusableDescendant && typeof focusableDescendant.focus === \"function\") ? focusableDescendant : null;\n\t\t\t}\n\t\t}\n\n\t\tchild = forward ? originalChild.nextSibling as HTMLElement : originalChild.previousSibling as HTMLElement;\n\n\t\t// If the child element is not part of the currently assigned element,\n\t\t// we have to check the next/previous element assigned to the slot or continue with the next/previous sibling of the slot,\n\t\t// otherwise, the nextSibling/previousSibling is the next element inside the light DOM\n\t\tif (assignedElements && !assignedElements[currentIndex].contains(child)) {\n\t\t\tcurrentIndex = forward ? currentIndex + 1 : currentIndex - 1;\n\n\t\t\tchild = assignedElements[currentIndex] as HTMLElement;\n\t\t}\n\t}\n\n\t/* eslint-enable no-await-in-loop */\n\n\treturn null;\n};\n\nexport {\n\tgetFirstFocusableElement,\n\tgetLastFocusableElement,\n};\n"],
"mappings": "aAAA,OAAOA,MAAqB,uBAC5B,OAAOC,MAAwB,0BAC/B,OAAS,wBAAAC,MAA4B,mBAIrC,MAAMC,EAAeC,GACbA,EAAG,aAAa,qBAAqB,EAGvCC,EAA2B,MAAOC,EAAwBC,IAC3D,CAACD,GAAaN,EAAgBM,CAAS,EACnC,KAGDE,EAAqBF,EAAW,GAAMC,CAAkB,EAG1DE,EAA0B,MAAOH,EAAwBC,IAC1D,CAACD,GAAaN,EAAgBM,CAAS,EACnC,KAGDE,EAAqBF,EAAW,GAAOC,CAAkB,EAG3DG,EAAmBN,GACjBA,EAAG,aAAa,yBAAyB,GAAK,CAACJ,EAAgBI,CAAE,EAGnEI,EAAuB,MAAOF,EAAwBK,EAAkBJ,IAA0D,CACvI,IAAIK,EACAC,EACAC,EAAe,GAEfR,EAAU,WACbM,EAAQD,EAAUL,EAAU,WAAW,WAA4BA,EAAU,WAAW,UAC9EA,aAAqB,iBAAmBA,EAAU,cAAc,GAC1EO,EAAmBP,EAAU,cAAc,EAC3CQ,EAAeH,EAAU,EAAIE,EAAiB,OAAS,EACvDD,EAAQC,EAAiBC,CAAY,GAC3BP,EACVK,EAAQN,EAERM,EAAQD,EAAUL,EAAU,kBAAmCA,EAAU,iBAG1E,IAAIS,EAIJ,KAAOH,GAAO,CACb,MAAMI,EAAyCJ,EAM/C,GAJIV,EAAqBU,CAAK,IAC7BA,EAAQ,MAAMA,EAAM,oBAAoB,GAGrC,CAACA,EACJ,OAAO,KAGR,GAAIA,EAAM,WAAa,GAAKF,EAAgBE,CAAK,GAAK,CAACT,EAAYS,CAAK,EAAG,CAC1E,GAAIX,EAAmBW,CAAK,EAC3B,OAAQA,GAAS,OAAOA,EAAM,OAAU,WAAcA,EAAQ,KAI/D,GADAG,EAAsB,MAAMP,EAAqBI,EAAOD,CAAO,EAC3DI,EACH,OAAQA,GAAuB,OAAOA,EAAoB,OAAU,WAAcA,EAAsB,IAE1G,CAEAH,EAAQD,EAAUK,EAAc,YAA6BA,EAAc,gBAKvEH,GAAoB,CAACA,EAAiBC,CAAY,EAAE,SAASF,CAAK,IACrEE,EAAeH,EAAUG,EAAe,EAAIA,EAAe,EAE3DF,EAAQC,EAAiBC,CAAY,EAEvC,CAIA,OAAO,IACR,EAEA,OACCT,KAAA,yBACAI,KAAA",
"names": ["isElementHidden", "isElementClickable", "instanceOfUI5Element", "isFocusTrap", "el", "getFirstFocusableElement", "container", "startFromContainer", "findFocusableElement", "getLastFocusableElement", "isElemFocusable", "forward", "child", "assignedElements", "currentIndex", "focusableDescendant", "originalChild"]
}