@economic/taco 2.45.2 → 2.45.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/esm/packages/taco/src/utils/dom.js +2 -2
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/taco.cjs.development.js +2 -2
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
@@ -1,5 +1,5 @@
|
|
1
1
|
// taken from react-aria
|
2
|
-
const FOCUSABLE_ELEMENTS = ['[tabindex]:not([disabled])
|
2
|
+
const FOCUSABLE_ELEMENTS = ['[tabindex]:not([disabled])', 'input:not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'button:not([disabled])', 'a[href]', 'area[href]', 'summary', 'iframe', 'object', 'embed', 'audio[controls]', 'video[controls]', '[contenteditable]', 'details:not([disabled])', 'summary:not(:disabled)'];
|
3
3
|
const hasFocusableElement = element => {
|
4
4
|
if (!element) {
|
5
5
|
return null;
|
@@ -28,7 +28,7 @@ const getNextFocussableElement = currentElement => {
|
|
28
28
|
let focussableElements = [...document.querySelectorAll(FOCUSABLE_ELEMENTS.join(','))];
|
29
29
|
const currentElementIndex = focussableElements.indexOf(currentElement);
|
30
30
|
if (currentElementIndex > -1) {
|
31
|
-
focussableElements = focussableElements.slice(currentElementIndex + 1);
|
31
|
+
focussableElements = focussableElements.slice(currentElementIndex + 1).filter(element => element.getAttribute('tabindex') !== '-1');
|
32
32
|
if (focussableElements.length) {
|
33
33
|
var _focussableElements$;
|
34
34
|
focussableElements = focussableElements.filter(element => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"dom.js","sources":["../../../../../../src/utils/dom.ts"],"sourcesContent":["// taken from react-aria\nconst FOCUSABLE_ELEMENTS = [\n '[tabindex]:not([disabled])
|
1
|
+
{"version":3,"file":"dom.js","sources":["../../../../../../src/utils/dom.ts"],"sourcesContent":["// taken from react-aria\nconst FOCUSABLE_ELEMENTS = [\n '[tabindex]:not([disabled])',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'button:not([disabled])',\n 'a[href]',\n 'area[href]',\n 'summary',\n 'iframe',\n 'object',\n 'embed',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]',\n 'details:not([disabled])',\n 'summary:not(:disabled)',\n];\n\nexport const hasFocusableElement = (element: HTMLElement | null) => {\n if (!element) {\n return null;\n }\n\n return !!element.querySelector(FOCUSABLE_ELEMENTS.join(','));\n};\n\nexport const isOverflowing = (element: HTMLElement | null) =>\n element !== null ? element.scrollWidth > element.offsetWidth : false;\n\nexport const getIndexOfFirstChildOverflowingParent = (element: HTMLElement, overscan = 0) => {\n let index = 0;\n let boundaryChildIndex: number | null = null;\n const clientRect = element.getBoundingClientRect();\n\n for (const child of Array.from(element.children)) {\n const right = child.getBoundingClientRect().right - clientRect.left;\n const width = clientRect.width - overscan;\n\n if (right > width) {\n boundaryChildIndex = index;\n break;\n }\n index++;\n }\n\n return boundaryChildIndex;\n};\n\nexport const getNextFocussableElement = (currentElement: HTMLElement | null) => {\n if (!currentElement) {\n return null;\n }\n\n let focussableElements = [...document.querySelectorAll<HTMLElement>(FOCUSABLE_ELEMENTS.join(','))];\n const currentElementIndex = focussableElements.indexOf(currentElement);\n\n if (currentElementIndex > -1) {\n focussableElements = focussableElements\n .slice(currentElementIndex + 1)\n .filter(element => element.getAttribute('tabindex') !== '-1');\n\n if (focussableElements.length) {\n focussableElements = focussableElements.filter(element => (element as any).checkVisibility?.() ?? true);\n return focussableElements[0] ?? null;\n }\n }\n\n return null;\n};\n\nconst getOverlaySelector = (element: Element | null) => {\n switch (element?.getAttribute('role')) {\n case 'dialog':\n return `[aria-controls='${element.id}']`;\n\n case 'menu':\n return `#${element.getAttribute('aria-labelledby')}`;\n\n default:\n return undefined;\n }\n};\n\nexport function isElementInsideOrTriggeredFromContainer(element: Element | null, container: Element | null) {\n const selector = getOverlaySelector(element) ?? getOverlaySelector(element?.closest('[role=dialog],[role=menu]') ?? null);\n\n if (selector) {\n if (container?.querySelector(selector)) {\n return true;\n }\n\n const elementInDocument = document.querySelector(selector);\n\n // if the element does exist, see if it is itself connected to somethng that was triggered from the container\n if (elementInDocument) {\n return isElementInsideOrTriggeredFromContainer(elementInDocument, container);\n }\n\n return false;\n }\n\n return !!container?.contains(element);\n}\n\nexport function isElementInsideOverlay(element: Element | null) {\n return !!element?.closest('[role=dialog],[role=menu]');\n}\n\nexport function isSiblingElementInsideSameParentOverlay(element: Element | null, sibling: Element | null) {\n return !!element?.closest('[role=dialog],[role=menu]')?.contains(sibling);\n}\n\nexport function isElementInteractive(element: Element | null) {\n if (!element) {\n return false;\n }\n\n return (\n ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'LABEL', 'OPTION'].includes(element.tagName) &&\n !(element as HTMLElement).hidden &&\n !(element as HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLButtonElement).disabled &&\n !(element as HTMLInputElement | HTMLTextAreaElement).readOnly\n );\n}\n\nexport function isElementInsideTable3OrReport(element: Element | null) {\n return !!element?.closest('[data-taco^=table]');\n}\n\nexport function setDataFocusAttribute(target: Element) {\n target.setAttribute('data-focus', 'programmatic');\n\n const cleanup = () => {\n target.removeAttribute('data-focus');\n target.removeEventListener('blur', cleanup);\n };\n\n target.addEventListener('blur', cleanup);\n}\n"],"names":["FOCUSABLE_ELEMENTS","hasFocusableElement","element","querySelector","join","getIndexOfFirstChildOverflowingParent","overscan","index","boundaryChildIndex","clientRect","getBoundingClientRect","child","Array","from","children","right","left","width","getNextFocussableElement","currentElement","focussableElements","document","querySelectorAll","currentElementIndex","indexOf","slice","filter","getAttribute","length","_focussableElements$","_element$checkVisibil","_element$checkVisibil2","checkVisibility","call","getOverlaySelector","id","undefined","isElementInsideOrTriggeredFromContainer","container","selector","_getOverlaySelector","_element$closest","closest","elementInDocument","contains","isElementInsideOverlay","isSiblingElementInsideSameParentOverlay","sibling","_element$closest2","isElementInteractive","includes","tagName","hidden","disabled","readOnly","isElementInsideTable3OrReport","setDataFocusAttribute","target","setAttribute","cleanup","removeAttribute","removeEventListener","addEventListener"],"mappings":"AAAA;AACA,MAAMA,kBAAkB,GAAG,CACvB,4BAA4B,EAC5B,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,SAAS,EACT,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,CAC3B;MAEYC,mBAAmB,GAAIC,OAA2B;EAC3D,IAAI,CAACA,OAAO,EAAE;IACV,OAAO,IAAI;;EAGf,OAAO,CAAC,CAACA,OAAO,CAACC,aAAa,CAACH,kBAAkB,CAACI,IAAI,CAAC,GAAG,CAAC,CAAC;AAChE;MAKaC,qCAAqC,GAAGA,CAACH,OAAoB,EAAEI,QAAQ,GAAG,CAAC;EACpF,IAAIC,KAAK,GAAG,CAAC;EACb,IAAIC,kBAAkB,GAAkB,IAAI;EAC5C,MAAMC,UAAU,GAAGP,OAAO,CAACQ,qBAAqB,EAAE;EAElD,KAAK,MAAMC,KAAK,IAAIC,KAAK,CAACC,IAAI,CAACX,OAAO,CAACY,QAAQ,CAAC,EAAE;IAC9C,MAAMC,KAAK,GAAGJ,KAAK,CAACD,qBAAqB,EAAE,CAACK,KAAK,GAAGN,UAAU,CAACO,IAAI;IACnE,MAAMC,KAAK,GAAGR,UAAU,CAACQ,KAAK,GAAGX,QAAQ;IAEzC,IAAIS,KAAK,GAAGE,KAAK,EAAE;MACfT,kBAAkB,GAAGD,KAAK;MAC1B;;IAEJA,KAAK,EAAE;;EAGX,OAAOC,kBAAkB;AAC7B;MAEaU,wBAAwB,GAAIC,cAAkC;EACvE,IAAI,CAACA,cAAc,EAAE;IACjB,OAAO,IAAI;;EAGf,IAAIC,kBAAkB,GAAG,CAAC,GAAGC,QAAQ,CAACC,gBAAgB,CAActB,k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,IACrG,CAAEnD,OAAkD,CAACoD,QAAQ;AAErE;SAEgBC,6BAA6BA,CAACrD,OAAuB;EACjE,OAAO,CAAC,EAACA,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEwC,OAAO,CAAC,oBAAoB,CAAC;AACnD;SAEgBc,qBAAqBA,CAACC,MAAe;EACjDA,MAAM,CAACC,YAAY,CAAC,YAAY,EAAE,cAAc,CAAC;EAEjD,MAAMC,OAAO,GAAGA;IACZF,MAAM,CAACG,eAAe,CAAC,YAAY,CAAC;IACpCH,MAAM,CAACI,mBAAmB,CAAC,MAAM,EAAEF,OAAO,CAAC;GAC9C;EAEDF,MAAM,CAACK,gBAAgB,CAAC,MAAM,EAAEH,OAAO,CAAC;AAC5C;;;;"}
|
@@ -4161,7 +4161,7 @@ const useMergedRef = ref => {
|
|
4161
4161
|
};
|
4162
4162
|
|
4163
4163
|
// taken from react-aria
|
4164
|
-
const FOCUSABLE_ELEMENTS = ['[tabindex]:not([disabled])
|
4164
|
+
const FOCUSABLE_ELEMENTS = ['[tabindex]:not([disabled])', 'input:not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'button:not([disabled])', 'a[href]', 'area[href]', 'summary', 'iframe', 'object', 'embed', 'audio[controls]', 'video[controls]', '[contenteditable]', 'details:not([disabled])', 'summary:not(:disabled)'];
|
4165
4165
|
const hasFocusableElement = element => {
|
4166
4166
|
if (!element) {
|
4167
4167
|
return null;
|
@@ -4190,7 +4190,7 @@ const getNextFocussableElement = currentElement => {
|
|
4190
4190
|
let focussableElements = [...document.querySelectorAll(FOCUSABLE_ELEMENTS.join(','))];
|
4191
4191
|
const currentElementIndex = focussableElements.indexOf(currentElement);
|
4192
4192
|
if (currentElementIndex > -1) {
|
4193
|
-
focussableElements = focussableElements.slice(currentElementIndex + 1);
|
4193
|
+
focussableElements = focussableElements.slice(currentElementIndex + 1).filter(element => element.getAttribute('tabindex') !== '-1');
|
4194
4194
|
if (focussableElements.length) {
|
4195
4195
|
var _focussableElements$;
|
4196
4196
|
focussableElements = focussableElements.filter(element => {
|