@spectrum-web-components/overlay 0.19.6-overlay.18 → 0.30.1-overlay.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/overlay-trigger.dev.js +2 -1
- package/overlay-trigger.dev.js.map +2 -2
- package/overlay-trigger.js +1 -1
- package/overlay-trigger.js.map +3 -3
- package/package.json +7 -7
- package/sp-overlay.dev.js +2 -1
- package/sp-overlay.dev.js.map +2 -2
- package/sp-overlay.js +1 -1
- package/sp-overlay.js.map +3 -3
- package/src/Overlay.js.map +1 -1
- package/src/OverlayBase.d.ts +11 -1
- package/src/OverlayBase.dev.js +141 -91
- package/src/OverlayBase.dev.js.map +2 -2
- package/src/OverlayBase.js +6 -7
- package/src/OverlayBase.js.map +3 -3
- package/src/OverlayDialog.js.map +1 -1
- package/src/OverlayNoPopover.js.map +1 -1
- package/src/OverlayPopover.dev.js +22 -2
- package/src/OverlayPopover.dev.js.map +2 -2
- package/src/OverlayPopover.js +1 -1
- package/src/OverlayPopover.js.map +3 -3
- package/src/OverlayStack.dev.js +18 -8
- package/src/OverlayStack.dev.js.map +2 -2
- package/src/OverlayStack.js +1 -1
- package/src/OverlayStack.js.map +3 -3
- package/src/OverlayTrigger.dev.js +1 -0
- package/src/OverlayTrigger.dev.js.map +2 -2
- package/src/OverlayTrigger.js +1 -0
- package/src/OverlayTrigger.js.map +2 -2
- package/src/PlacementController.js.map +1 -1
- package/src/overlay-base.css.dev.js +1 -1
- package/src/overlay-base.css.dev.js.map +1 -1
- package/src/overlay-base.css.js +1 -1
- package/src/overlay-base.css.js.map +1 -1
- package/src/placement.js.map +1 -1
- package/src/topLayerOverTransforms.dev.js +4 -0
- package/src/topLayerOverTransforms.dev.js.map +2 -2
- package/src/topLayerOverTransforms.js +1 -1
- package/src/topLayerOverTransforms.js.map +2 -2
- package/test/index.js +113 -106
- package/test/index.js.map +2 -2
- package/test/overlay-element.test.js +345 -411
- package/test/overlay-element.test.js.map +2 -2
- package/test/overlay-lifecycle.test.js +1 -33
- package/test/overlay-lifecycle.test.js.map +2 -2
- package/test/overlay-trigger-extended.test.js +1 -1
- package/test/overlay-trigger-extended.test.js.map +2 -2
- package/test/overlay-trigger-hover-click.test.js +23 -23
- package/test/overlay-trigger-hover-click.test.js.map +2 -2
- package/test/overlay-trigger-hover.test.js +42 -36
- package/test/overlay-trigger-hover.test.js.map +2 -2
- package/test/overlay-trigger-longpress.test.js +51 -51
- package/test/overlay-trigger-longpress.test.js.map +2 -2
- package/test/overlay.test.js +8 -12
- package/test/overlay.test.js.map +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["overlay-base.css.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2023 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--swc-overlay-animation-distance:var(\n--spectrum-picker-m-texticon-popover-offset-y,var(--spectrum-global-dimension-size-75)\n)
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--swc-overlay-animation-distance:var(\n--spectrum-picker-m-texticon-popover-offset-y,var(--spectrum-global-dimension-size-75)\n)}dialog{background:none;border:0;box-sizing:border-box;display:flex;margin:0;max-height:calc(100vh - 16px);max-height:calc(100dvh - 16px);max-width:calc(100vw - 16px);opacity:1!important;overflow:visible;padding:0;position:fixed}:host(:not([open])) dialog{left:0;pointer-events:none;top:0;transform:translate(-999em,-999em)}dialog::backdrop{display:none}dialog>div{width:100%}::slotted(sp-popover){position:static}dialog[actual-placement*=top]{margin-top:var(--swc-overlay-animation-distance);padding-block:var(--swc-overlay-animation-distance)}dialog[actual-placement*=right]{margin-left:calc(var(--swc-overlay-animation-distance)*-1);padding-inline:var(--swc-overlay-animation-distance)}dialog[actual-placement*=bottom]{margin-top:calc(var(--swc-overlay-animation-distance)*-1);padding-block:var(--swc-overlay-animation-distance)}dialog[actual-placement*=left]{margin-left:var(--swc-overlay-animation-distance);padding-inline:var(--swc-overlay-animation-distance)}slot[name=longpress-describedby-descriptor]{display:none}@supports selector(:open){dialog{opacity:0}dialog:open{opacity:1}}@supports selector(:popover-open){dialog{opacity:0}dialog:popover-open{opacity:1}}@supports (not selector(:open)) and (not selector(:popover-open)){:host:not([open]) dialog{pointer-events:none}dialog[actual-placement]{z-index:var(--swc-overlay-z-index)}}\n`;\nexport default styles;"],
|
|
5
5
|
"mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA;AAAA;AAAA,EAKf,eAAeC",
|
|
6
6
|
"names": ["css", "styles"]
|
|
7
7
|
}
|
package/src/placement.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["placement.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n arrow,\n computePosition,\n flip,\n offset,\n Placement,\n shift,\n size,\n} from '@floating-ui/dom';\nimport type { VirtualTrigger } from './VirtualTrigger.js';\nimport { topLayerOverTransforms } from './topLayerOverTransforms.js';\n\ntype OverlayOptions = {\n abortPromise?: Promise<boolean>;\n delayed?: boolean;\n offset?: number | [number, number]; // supporting multi-axis\n placement: Placement;\n notImmediatelyClosable?: boolean; // rename or place behind other API options\n receivesFocus?: 'auto';\n root?: HTMLElement;\n trigger: HTMLElement | VirtualTrigger;\n type?: 'modal' | 'page' | 'hint' | 'auto' | 'manual';\n};\n\ntype OverlayData = {\n initialHeight?: number;\n isConstrained?: boolean;\n elements?: HTMLElement[];\n tipElement?: HTMLElement;\n};\n\nfunction roundByDPR(num?: number): number {\n if (typeof num === 'undefined') return 0;\n const dpr = window.devicePixelRatio || 1;\n return Math.round(num * dpr) / dpr || -10000;\n}\n\n// See: https://spectrum.adobe.com/page/popover/#Container-padding\nconst REQUIRED_DISTANCE_TO_EDGE = 8;\n// See: https://github.com/adobe/spectrum-web-components/issues/910\nconst MIN_OVERLAY_HEIGHT = 100;\n\nconst getFallbackPlacements = (placement: Placement): Placement[] => {\n const fallbacks: Record<Placement, Placement[]> = {\n left: ['right', 'bottom', 'top'],\n 'left-start': ['right-start', 'bottom', 'top'],\n 'left-end': ['right-end', 'bottom', 'top'],\n right: ['left', 'bottom', 'top'],\n 'right-start': ['left-start', 'bottom', 'top'],\n 'right-end': ['left-end', 'bottom', 'top'],\n top: ['bottom', 'left', 'right'],\n 'top-start': ['bottom-start', 'left', 'right'],\n 'top-end': ['bottom-end', 'left', 'right'],\n bottom: ['top', 'left', 'right'],\n 'bottom-start': ['top-start', 'left', 'right'],\n 'bottom-end': ['top-end', 'left', 'right'],\n };\n return fallbacks[placement] ?? [placement];\n};\n\nexport const updateOverlayPosition = async (\n target: HTMLElement,\n options: OverlayOptions,\n overlayData: OverlayData\n): Promise<void> => {\n await (document.fonts ? document.fonts.ready : Promise.resolve());\n\n const flipMiddleware = !(options.trigger instanceof HTMLElement)\n ? flip({\n padding: REQUIRED_DISTANCE_TO_EDGE,\n fallbackPlacements: getFallbackPlacements(options.placement),\n })\n : flip({\n padding: REQUIRED_DISTANCE_TO_EDGE,\n });\n\n const mainAxis = Array.isArray(options?.offset)\n ? options?.offset[0]\n : options?.offset || 0;\n const crossAxis = Array.isArray(options?.offset)\n ? options?.offset[1] || 0\n : 0;\n\n const middleware = [\n offset({\n mainAxis,\n crossAxis,\n }),\n shift({ padding: REQUIRED_DISTANCE_TO_EDGE }),\n flipMiddleware,\n size({\n padding: REQUIRED_DISTANCE_TO_EDGE,\n apply: ({\n availableWidth,\n availableHeight,\n rects: { floating },\n }) => {\n const maxHeight = Math.max(\n MIN_OVERLAY_HEIGHT,\n Math.floor(availableHeight)\n );\n const actualHeight = floating.height;\n overlayData.initialHeight =\n !overlayData.isConstrained /* && !this.virtualTrigger */\n ? actualHeight\n : overlayData.initialHeight || actualHeight;\n overlayData.isConstrained =\n actualHeight < overlayData.initialHeight ||\n maxHeight <= actualHeight;\n const appliedHeight = overlayData.isConstrained\n ? `${maxHeight}px`\n : '';\n Object.assign(target.style, {\n maxWidth: `${Math.floor(availableWidth)}px`,\n maxHeight: appliedHeight,\n height: appliedHeight,\n });\n },\n }),\n ...(overlayData.tipElement\n ? [arrow({ element: overlayData.tipElement })]\n : []),\n topLayerOverTransforms(),\n ];\n const { x, y, placement, middlewareData } = await computePosition(\n options.trigger,\n target,\n {\n placement: options.placement,\n middleware,\n strategy: 'fixed',\n }\n );\n\n Object.assign(target.style, {\n top: '0px',\n left: '0px',\n transform: `translate(${roundByDPR(x)}px, ${roundByDPR(y)}px)`,\n });\n\n if (placement !== target.getAttribute('actual-placement')) {\n target.setAttribute('actual-placement', placement);\n overlayData.elements?.forEach((element) => {\n element.setAttribute('placement', placement);\n });\n }\n\n if (overlayData.tipElement && middlewareData.arrow) {\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n\n Object.assign(overlayData.tipElement.style, {\n top:\n placement.startsWith('right') || placement.startsWith('left')\n ? '0px'\n : '',\n left:\n placement.startsWith('bottom') || placement.startsWith('top')\n ? '0px'\n : '',\n transform: `translate(${roundByDPR(arrowX)}px, ${roundByDPR(\n arrowY\n )}px)`,\n });\n }\n};\n"],
|
|
5
|
-
"mappings": "aAWA,OACI,SAAAA,EACA,mBAAAC,EACA,QAAAC,EACA,UAAAC,EAEA,SAAAC,EACA,QAAAC,MACG,mBAEP,OAAS,0BAAAC,MAA8B,8BAqBvC,SAASC,EAAWC,EAAsB,CACtC,GAAI,OAAOA,GAAQ,YAAa,MAAO,GACvC,MAAMC,EAAM,OAAO,kBAAoB,EACvC,OAAO,KAAK,MAAMD,EAAMC,CAAG,EAAIA,GAAO,IAC1C,CAGA,MAAMC,EAA4B,EAE5BC,EAAqB,IAErBC,EAAyBC,GAAsC,CArDrE,IAAAC,EAoEI,OAAOA,EAd2C,CAC9C,KAAM,CAAC,QAAS,SAAU,KAAK,EAC/B,aAAc,CAAC,cAAe,SAAU,KAAK,EAC7C,WAAY,CAAC,YAAa,SAAU,KAAK,EACzC,MAAO,CAAC,OAAQ,SAAU,KAAK,EAC/B,cAAe,CAAC,aAAc,SAAU,KAAK,EAC7C,YAAa,CAAC,WAAY,SAAU,KAAK,EACzC,IAAK,CAAC,SAAU,OAAQ,OAAO,EAC/B,YAAa,CAAC,eAAgB,OAAQ,OAAO,EAC7C,UAAW,CAAC,aAAc,OAAQ,OAAO,EACzC,OAAQ,CAAC,MAAO,OAAQ,OAAO,EAC/B,eAAgB,CAAC,YAAa,OAAQ,OAAO,EAC7C,aAAc,CAAC,UAAW,OAAQ,OAAO,CAC7C,EACiBD,CAAS,IAAnB,KAAAC,EAAwB,CAACD,CAAS,CAC7C,EAEO,aAAM,sBAA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,GAAaC,EACjB,MAAMC,EAAgBV,EAAY,cAC5B,GAAGQ,MACH,GACN,OAAO,OAAOV,EAAO,MAAO,CACxB,SAAU,GAAG,KAAK,MAAMO,CAAc,MACtC,UAAWK,EACX,OAAQA,CACZ,CAAC,CACL,CACJ,CAAC,EACD,GAAIV,EAAY,WACV,CAACjB,EAAM,CAAE,QAASiB,EAAY,UAAW,CAAC,CAAC,EAC3C,CAAC,EACPX,EAAuB,CAC3B,EACM,CAAE,EAAG,EAAAsB,EAAG,UAAAf,EAAW,eAAAgB,CAAe,EAAI,MAAM5B,EAC9Ce,EAAQ,QACRD,EACA,CACI,UAAWC,EAAQ,UACnB,WAAAK,EACA,SAAU,OACd,CACJ,EAeA,GAbA,OAAO,OAAON,EAAO,MAAO,CACxB,IAAK,MACL,KAAM,MACN,UAAW,aAAaR,EAAW,CAAC,QAAQA,EAAWqB,CAAC,MAC5D,CAAC,EAEGf,IAAcE,EAAO,aAAa,kBAAkB,IACpDA,EAAO,aAAa,mBAAoBF,CAAS,GACjDC,EAAAG,EAAY,WAAZ,MAAAH,EAAsB,QAASgB,GAAY,CACvCA,EAAQ,aAAa,YAAajB,CAAS,CAC/C,IAGAI,EAAY,YAAcY,EAAe,MAAO,CAChD,KAAM,CAAE,EAAGE,EAAQ,EAAGC,CAAO,EAAIH,EAAe,MAEhD,OAAO,OAAOZ,EAAY,WAAW,MAAO,CACxC,IACIJ,EAAU,WAAW,OAAO,GAAKA,EAAU,WAAW,MAAM,EACtD,MACA,GACV,KACIA,EAAU,WAAW,QAAQ,GAAKA,EAAU,WAAW,KAAK,EACtD,MACA,GACV,UAAW,aAAaN,EAAWwB,CAAM,QAAQxB,EAC7CyB,CACJ,MACJ,CAAC,EAET",
|
|
6
6
|
"names": ["arrow", "computePosition", "flip", "offset", "shift", "size", "topLayerOverTransforms", "roundByDPR", "num", "dpr", "REQUIRED_DISTANCE_TO_EDGE", "MIN_OVERLAY_HEIGHT", "getFallbackPlacements", "placement", "_a", "target", "options", "overlayData", "flipMiddleware", "mainAxis", "crossAxis", "middleware", "availableWidth", "availableHeight", "floating", "maxHeight", "actualHeight", "appliedHeight", "y", "middlewareData", "element", "arrowX", "arrowY"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["topLayerOverTransforms.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { MiddlewareArguments } from '@floating-ui/dom';\n\nexport const topLayerOverTransforms = () => ({\n name: 'topLayer',\n async fn(middlewareArguments: MiddlewareArguments) {\n const {\n x,\n y,\n elements: { reference, floating },\n } = middlewareArguments;\n let onTopLayer = false;\n let topLayerIsFloating = false;\n const diffCoords = {\n x: 0,\n y: 0,\n };\n try {\n onTopLayer = onTopLayer || floating.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (e) {}\n try {\n onTopLayer = onTopLayer || floating.matches(':modal');\n // eslint-disable-next-line no-empty\n } catch (e) {}\n topLayerIsFloating = onTopLayer;\n if (!onTopLayer) {\n const dialogAncestorQueryEvent = new Event(\n 'floating-ui-dialog-test',\n { composed: true, bubbles: true }\n );\n floating.addEventListener(\n 'floating-ui-dialog-test',\n (event: Event) => {\n (event.composedPath() as unknown as Element[]).forEach(\n (el) => {\n if (el === floating || el.localName !== 'dialog')\n return;\n try {\n onTopLayer = onTopLayer || el.matches(':modal');\n if (onTopLayer) {\n // console.log(el);\n }\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n );\n },\n { once: true }\n );\n floating.dispatchEvent(dialogAncestorQueryEvent);\n }\n let overTransforms = false;\n const containingBlock = getContainingBlock(reference as Element);\n if (containingBlock !== null && !isWindow(containingBlock)) {\n overTransforms = true;\n }\n\n if (onTopLayer && overTransforms) {\n const rect = containingBlock!.getBoundingClientRect();\n diffCoords.x = rect.x;\n diffCoords.y = rect.y;\n }\n\n if (onTopLayer && topLayerIsFloating) {\n return {\n x: x + diffCoords.x,\n y: y + diffCoords.y,\n data: diffCoords,\n };\n }\n\n if (onTopLayer) {\n return {\n x,\n y,\n data: diffCoords,\n };\n }\n\n return {\n x: x - diffCoords.x,\n y: y - diffCoords.y,\n data: diffCoords,\n };\n },\n});\n\n/* COPY/PASTE from Floating UI */\n\nfunction getContainingBlock(element: Element) {\n let currentNode: Node | null = getParentNode(element);\n\n if (isShadowRoot(currentNode)) {\n currentNode = currentNode.host;\n }\n\n while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {\n if (isContainingBlock(currentNode)) {\n return currentNode;\n } else {\n const parent = (\n currentNode.assignedSlot\n ? currentNode.assignedSlot\n : currentNode.parentNode\n ) as Node;\n currentNode = isShadowRoot(parent) ? parent.host : parent;\n }\n }\n\n return null;\n}\n\nexport function isLastTraversableNode(node: Node) {\n return ['html', 'body', '#document'].includes(getNodeName(node));\n}\n\nfunction isContainingBlock(element: HTMLElement) {\n // TODO: Try and use feature detection here instead\n const isFirefox = /firefox/i.test(getUAString());\n if (element.tagName === 'dialog') {\n return true;\n }\n const css = getComputedStyle(element); // This is non-exhaustive but covers the most common CSS properties that\n // create a containing block.\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n\n return (\n css.transform !== 'none' ||\n css.perspective !== 'none' || // @ts-ignore (TS 4.1 compat)\n css.contain === 'paint' ||\n ['transform', 'perspective'].includes(css.willChange) ||\n (isFirefox && css.willChange === 'filter') ||\n (isFirefox && (css.filter ? css.filter !== 'none' : false))\n );\n}\n\ninterface NavigatorUAData {\n brands: Array<{ brand: string; version: string }>;\n mobile: boolean;\n platform: string;\n}\n\nexport function getUAString(): string {\n const uaData = (navigator as any).userAgentData as\n | NavigatorUAData\n | undefined;\n\n if (uaData?.brands) {\n return uaData.brands\n .map((item) => `${item.brand}/${item.version}`)\n .join(' ');\n }\n\n return navigator.userAgent;\n}\n\nexport function getParentNode(node: Node): Node {\n if (getNodeName(node) === 'html') {\n return node;\n }\n\n return (\n // this is a quicker (but less type safe) way to save quite some bytes from the bundle\n // @ts-ignore\n node.assignedSlot || // step into the shadow DOM of the parent of a slotted node\n node.parentNode || // DOM Element detected\n (isShadowRoot(node) ? node.host : null) || // ShadowRoot detected\n getDocumentElement(node) // fallback\n );\n}\n\nexport function getNodeName(node: Node | Window): string {\n return isWindow(node)\n ? ''\n : node\n ? (node.nodeName || '').toLowerCase()\n : '';\n}\n\nexport function getDocumentElement(node: Node | Window): HTMLElement {\n return (\n (isNode(node) ? node.ownerDocument : node.document) || window.document\n ).documentElement;\n}\n\nexport function isNode(value: any): value is Node {\n return value instanceof (getWindow(value) as unknown as { Node: any }).Node;\n}\n\nexport function isWindow(value: any): value is Window {\n return (\n value &&\n value.document &&\n value.location &&\n value.alert &&\n value.setInterval\n );\n}\n\nexport function getWindow(node: Node | Window): Window {\n if (node == null) {\n return window;\n }\n\n if (!isWindow(node)) {\n const ownerDocument = node.ownerDocument;\n return ownerDocument ? ownerDocument.defaultView || window : window;\n }\n\n return node;\n}\n\nexport function isShadowRoot(node: Node): node is ShadowRoot {\n // Browsers without `ShadowRoot` support\n if (typeof ShadowRoot === 'undefined') {\n return false;\n }\n\n const OwnElement = (\n getWindow(node) as unknown as { ShadowRoot: ShadowRoot }\n ).ShadowRoot;\n const testNode = node as Node;\n return (\n node instanceof (OwnElement as unknown as any) ||\n testNode instanceof ShadowRoot\n );\n}\n\nexport function isHTMLElement(value: any): value is HTMLElement {\n return (\n value instanceof\n (getWindow(value) as unknown as { HTMLElement: any }).HTMLElement\n );\n}\n"],
|
|
5
|
-
"mappings": ";A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OAAO,OACT,IAAI,CAAC,SAAS,GAAG,KAAK,SAAS,KAAK,SAAS,EAC7C,KAAK,GAAG;AAAA,EACjB;AAEA,SAAO,UAAU;AACrB;AAEO,gBAAS,cAAc,MAAkB;AAC5C,MAAI,YAAY,IAAI,MAAM,QAAQ;AAC9B,WAAO;AAAA,EACX;AAEA;AAAA;AAAA;AAAA,IAGI,KAAK;AAAA,IACL,KAAK;AAAA,KACJ,aAAa,IAAI,IAAI,KAAK,OAAO;AAAA,IAClC,mBAAmB,IAAI;AAAA;AAE/B;AAEO,gBAAS,YAAY,MAA6B;AACrD,SAAO,SAAS,IAAI,IACd,KACA,QACC,KAAK,YAAY,IAAI,YAAY,IAClC;AACV;AAEO,gBAAS,mBAAmB,MAAkC;AACjE,WACK,OAAO,IAAI,IAAI,KAAK,gBAAgB,KAAK,aAAa,OAAO,UAChE;AACN;AAEO,gBAAS,OAAO,OAA2B;AAC9C,SAAO,iBAAkB,UAAU,KAAK,EAA+B;AAC3E;AAEO,gBAAS,SAAS,OAA6B;AAClD,SACI,SACA,MAAM,YACN,MAAM,YACN,MAAM,SACN,MAAM;AAEd;AAEO,gBAAS,UAAU,MAA6B;AACnD,MAAI,QAAQ,MAAM;AACd,WAAO;AAAA,EACX;AAEA,MAAI,CAAC,SAAS,IAAI,GAAG;AACjB,UAAM,gBAAgB,KAAK;AAC3B,WAAO,gBAAgB,cAAc,eAAe,SAAS;AAAA,EACjE;AAEA,SAAO;AACX;AAEO,gBAAS,aAAa,MAAgC;AAEzD,MAAI,OAAO,eAAe,aAAa;AACnC,WAAO;AAAA,EACX;AAEA,QAAM,aACF,UAAU,IAAI,EAChB;AACF,QAAM,WAAW;AACjB,SACI,gBAAiB,cACjB,oBAAoB;AAE5B;AAEO,gBAAS,cAAc,OAAkC;AAC5D,SACI,iBACC,UAAU,KAAK,EAAsC;AAE9D;",
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { MiddlewareArguments } from '@floating-ui/dom';\n\nexport const topLayerOverTransforms = () => ({\n name: 'topLayer',\n async fn(middlewareArguments: MiddlewareArguments) {\n const {\n x,\n y,\n elements: { reference, floating },\n } = middlewareArguments;\n let onTopLayer = false;\n let topLayerIsFloating = false;\n const diffCoords = {\n x: 0,\n y: 0,\n };\n try {\n onTopLayer = onTopLayer || floating.matches(':popover-open');\n // eslint-disable-next-line no-empty\n } catch (e) {}\n try {\n onTopLayer = onTopLayer || floating.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (e) {}\n try {\n onTopLayer = onTopLayer || floating.matches(':modal');\n // eslint-disable-next-line no-empty\n } catch (e) {}\n topLayerIsFloating = onTopLayer;\n if (!onTopLayer) {\n const dialogAncestorQueryEvent = new Event(\n 'floating-ui-dialog-test',\n { composed: true, bubbles: true }\n );\n floating.addEventListener(\n 'floating-ui-dialog-test',\n (event: Event) => {\n (event.composedPath() as unknown as Element[]).forEach(\n (el) => {\n if (el === floating || el.localName !== 'dialog')\n return;\n try {\n onTopLayer = onTopLayer || el.matches(':modal');\n if (onTopLayer) {\n // console.log(el);\n }\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n );\n },\n { once: true }\n );\n floating.dispatchEvent(dialogAncestorQueryEvent);\n }\n let overTransforms = false;\n const containingBlock = getContainingBlock(reference as Element);\n if (containingBlock !== null && !isWindow(containingBlock)) {\n overTransforms = true;\n }\n\n if (onTopLayer && overTransforms) {\n const rect = containingBlock!.getBoundingClientRect();\n diffCoords.x = rect.x;\n diffCoords.y = rect.y;\n }\n\n if (onTopLayer && topLayerIsFloating) {\n return {\n x: x + diffCoords.x,\n y: y + diffCoords.y,\n data: diffCoords,\n };\n }\n\n if (onTopLayer) {\n return {\n x,\n y,\n data: diffCoords,\n };\n }\n\n return {\n x: x - diffCoords.x,\n y: y - diffCoords.y,\n data: diffCoords,\n };\n },\n});\n\n/* COPY/PASTE from Floating UI */\n\nfunction getContainingBlock(element: Element) {\n let currentNode: Node | null = getParentNode(element);\n\n if (isShadowRoot(currentNode)) {\n currentNode = currentNode.host;\n }\n\n while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {\n if (isContainingBlock(currentNode)) {\n return currentNode;\n } else {\n const parent = (\n currentNode.assignedSlot\n ? currentNode.assignedSlot\n : currentNode.parentNode\n ) as Node;\n currentNode = isShadowRoot(parent) ? parent.host : parent;\n }\n }\n\n return null;\n}\n\nexport function isLastTraversableNode(node: Node) {\n return ['html', 'body', '#document'].includes(getNodeName(node));\n}\n\nfunction isContainingBlock(element: HTMLElement) {\n // TODO: Try and use feature detection here instead\n const isFirefox = /firefox/i.test(getUAString());\n if (element.tagName === 'dialog') {\n return true;\n }\n const css = getComputedStyle(element); // This is non-exhaustive but covers the most common CSS properties that\n // create a containing block.\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n\n return (\n css.transform !== 'none' ||\n css.perspective !== 'none' || // @ts-ignore (TS 4.1 compat)\n css.contain === 'paint' ||\n ['transform', 'perspective'].includes(css.willChange) ||\n (isFirefox && css.willChange === 'filter') ||\n (isFirefox && (css.filter ? css.filter !== 'none' : false))\n );\n}\n\ninterface NavigatorUAData {\n brands: Array<{ brand: string; version: string }>;\n mobile: boolean;\n platform: string;\n}\n\nexport function getUAString(): string {\n const uaData = (navigator as any).userAgentData as\n | NavigatorUAData\n | undefined;\n\n if (uaData?.brands) {\n return uaData.brands\n .map((item) => `${item.brand}/${item.version}`)\n .join(' ');\n }\n\n return navigator.userAgent;\n}\n\nexport function getParentNode(node: Node): Node {\n if (getNodeName(node) === 'html') {\n return node;\n }\n\n return (\n // this is a quicker (but less type safe) way to save quite some bytes from the bundle\n // @ts-ignore\n node.assignedSlot || // step into the shadow DOM of the parent of a slotted node\n node.parentNode || // DOM Element detected\n (isShadowRoot(node) ? node.host : null) || // ShadowRoot detected\n getDocumentElement(node) // fallback\n );\n}\n\nexport function getNodeName(node: Node | Window): string {\n return isWindow(node)\n ? ''\n : node\n ? (node.nodeName || '').toLowerCase()\n : '';\n}\n\nexport function getDocumentElement(node: Node | Window): HTMLElement {\n return (\n (isNode(node) ? node.ownerDocument : node.document) || window.document\n ).documentElement;\n}\n\nexport function isNode(value: any): value is Node {\n return value instanceof (getWindow(value) as unknown as { Node: any }).Node;\n}\n\nexport function isWindow(value: any): value is Window {\n return (\n value &&\n value.document &&\n value.location &&\n value.alert &&\n value.setInterval\n );\n}\n\nexport function getWindow(node: Node | Window): Window {\n if (node == null) {\n return window;\n }\n\n if (!isWindow(node)) {\n const ownerDocument = node.ownerDocument;\n return ownerDocument ? ownerDocument.defaultView || window : window;\n }\n\n return node;\n}\n\nexport function isShadowRoot(node: Node): node is ShadowRoot {\n // Browsers without `ShadowRoot` support\n if (typeof ShadowRoot === 'undefined') {\n return false;\n }\n\n const OwnElement = (\n getWindow(node) as unknown as { ShadowRoot: ShadowRoot }\n ).ShadowRoot;\n const testNode = node as Node;\n return (\n node instanceof (OwnElement as unknown as any) ||\n testNode instanceof ShadowRoot\n );\n}\n\nexport function isHTMLElement(value: any): value is HTMLElement {\n return (\n value instanceof\n (getWindow(value) as unknown as { HTMLElement: any }).HTMLElement\n );\n}\n"],
|
|
5
|
+
"mappings": ";AAaO,aAAM,yBAAyB,OAAO;AAAA,EACzC,MAAM;AAAA,EACN,MAAM,GAAG,qBAA0C;AAC/C,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA,UAAU,EAAE,WAAW,SAAS;AAAA,IACpC,IAAI;AACJ,QAAI,aAAa;AACjB,QAAI,qBAAqB;AACzB,UAAM,aAAa;AAAA,MACf,GAAG;AAAA,MACH,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AAI,MAAM,QAAQ;AAC9B,WAAO;AAAA,EACX;AAEA;AAAA;AAAA;AAAA,IAGI,KAAK;AAAA,IACL,KAAK;AAAA,KACJ,aAAa,IAAI,IAAI,KAAK,OAAO;AAAA,IAClC,mBAAmB,IAAI;AAAA;AAE/B;AAEO,gBAAS,YAAY,MAA6B;AACrD,SAAO,SAAS,IAAI,IACd,KACA,QACC,KAAK,YAAY,IAAI,YAAY,IAClC;AACV;AAEO,gBAAS,mBAAmB,MAAkC;AACjE,WACK,OAAO,IAAI,IAAI,KAAK,gBAAgB,KAAK,aAAa,OAAO,UAChE;AACN;AAEO,gBAAS,OAAO,OAA2B;AAC9C,SAAO,iBAAkB,UAAU,KAAK,EAA+B;AAC3E;AAEO,gBAAS,SAAS,OAA6B;AAClD,SACI,SACA,MAAM,YACN,MAAM,YACN,MAAM,SACN,MAAM;AAEd;AAEO,gBAAS,UAAU,MAA6B;AACnD,MAAI,QAAQ,MAAM;AACd,WAAO;AAAA,EACX;AAEA,MAAI,CAAC,SAAS,IAAI,GAAG;AACjB,UAAM,gBAAgB,KAAK;AAC3B,WAAO,gBAAgB,cAAc,eAAe,SAAS;AAAA,EACjE;AAEA,SAAO;AACX;AAEO,gBAAS,aAAa,MAAgC;AAEzD,MAAI,OAAO,eAAe,aAAa;AACnC,WAAO;AAAA,EACX;AAEA,QAAM,aACF,UAAU,IAAI,EAChB;AACF,QAAM,WAAW;AACjB,SACI,gBAAiB,cACjB,oBAAoB;AAE5B;AAEO,gBAAS,cAAc,OAAkC;AAC5D,SACI,iBACC,UAAU,KAAK,EAAsC;AAE9D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";export const topLayerOverTransforms=()=>({name:"topLayer",async fn(e){const{x:
|
|
1
|
+
"use strict";export const topLayerOverTransforms=()=>({name:"topLayer",async fn(e){const{x:t,y:n,elements:{reference:d,floating:i}}=e;let o=!1,l=!1;const r={x:0,y:0};try{o=o||i.matches(":popover-open")}catch(a){}try{o=o||i.matches(":open")}catch(a){}try{o=o||i.matches(":modal")}catch(a){}if(l=o,!o){const a=new Event("floating-ui-dialog-test",{composed:!0,bubbles:!0});i.addEventListener("floating-ui-dialog-test",f=>{f.composedPath().forEach(c=>{if(!(c===i||c.localName!=="dialog"))try{o=o||c.matches(":modal")}catch(w){}})},{once:!0}),i.dispatchEvent(a)}let u=!1;const s=m(d);if(s!==null&&!isWindow(s)&&(u=!0),o&&u){const a=s.getBoundingClientRect();r.x=a.x,r.y=a.y}return o&&l?{x:t+r.x,y:n+r.y,data:r}:o?{x:t,y:n,data:r}:{x:t-r.x,y:n-r.y,data:r}}});function m(e){let t=getParentNode(e);for(isShadowRoot(t)&&(t=t.host);isHTMLElement(t)&&!isLastTraversableNode(t);){if(g(t))return t;{const n=t.assignedSlot?t.assignedSlot:t.parentNode;t=isShadowRoot(n)?n.host:n}}return null}export function isLastTraversableNode(e){return["html","body","#document"].includes(getNodeName(e))}function g(e){const t=/firefox/i.test(getUAString());if(e.tagName==="dialog")return!0;const n=getComputedStyle(e);return n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].includes(n.willChange)||t&&n.willChange==="filter"||t&&(n.filter?n.filter!=="none":!1)}export function getUAString(){const e=navigator.userAgentData;return e!=null&&e.brands?e.brands.map(t=>`${t.brand}/${t.version}`).join(" "):navigator.userAgent}export function getParentNode(e){return getNodeName(e)==="html"?e:e.assignedSlot||e.parentNode||(isShadowRoot(e)?e.host:null)||getDocumentElement(e)}export function getNodeName(e){return isWindow(e)?"":e?(e.nodeName||"").toLowerCase():""}export function getDocumentElement(e){return((isNode(e)?e.ownerDocument:e.document)||window.document).documentElement}export function isNode(e){return e instanceof getWindow(e).Node}export function isWindow(e){return e&&e.document&&e.location&&e.alert&&e.setInterval}export function getWindow(e){if(e==null)return window;if(!isWindow(e)){const t=e.ownerDocument;return t&&t.defaultView||window}return e}export function isShadowRoot(e){if(typeof ShadowRoot=="undefined")return!1;const t=getWindow(e).ShadowRoot,n=e;return e instanceof t||n instanceof ShadowRoot}export function isHTMLElement(e){return e instanceof getWindow(e).HTMLElement}
|
|
2
2
|
//# sourceMappingURL=topLayerOverTransforms.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["topLayerOverTransforms.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { MiddlewareArguments } from '@floating-ui/dom';\n\nexport const topLayerOverTransforms = () => ({\n name: 'topLayer',\n async fn(middlewareArguments: MiddlewareArguments) {\n const {\n x,\n y,\n elements: { reference, floating },\n } = middlewareArguments;\n let onTopLayer = false;\n let topLayerIsFloating = false;\n const diffCoords = {\n x: 0,\n y: 0,\n };\n try {\n onTopLayer = onTopLayer || floating.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (e) {}\n try {\n onTopLayer = onTopLayer || floating.matches(':modal');\n // eslint-disable-next-line no-empty\n } catch (e) {}\n topLayerIsFloating = onTopLayer;\n if (!onTopLayer) {\n const dialogAncestorQueryEvent = new Event(\n 'floating-ui-dialog-test',\n { composed: true, bubbles: true }\n );\n floating.addEventListener(\n 'floating-ui-dialog-test',\n (event: Event) => {\n (event.composedPath() as unknown as Element[]).forEach(\n (el) => {\n if (el === floating || el.localName !== 'dialog')\n return;\n try {\n onTopLayer = onTopLayer || el.matches(':modal');\n if (onTopLayer) {\n // console.log(el);\n }\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n );\n },\n { once: true }\n );\n floating.dispatchEvent(dialogAncestorQueryEvent);\n }\n let overTransforms = false;\n const containingBlock = getContainingBlock(reference as Element);\n if (containingBlock !== null && !isWindow(containingBlock)) {\n overTransforms = true;\n }\n\n if (onTopLayer && overTransforms) {\n const rect = containingBlock!.getBoundingClientRect();\n diffCoords.x = rect.x;\n diffCoords.y = rect.y;\n }\n\n if (onTopLayer && topLayerIsFloating) {\n return {\n x: x + diffCoords.x,\n y: y + diffCoords.y,\n data: diffCoords,\n };\n }\n\n if (onTopLayer) {\n return {\n x,\n y,\n data: diffCoords,\n };\n }\n\n return {\n x: x - diffCoords.x,\n y: y - diffCoords.y,\n data: diffCoords,\n };\n },\n});\n\n/* COPY/PASTE from Floating UI */\n\nfunction getContainingBlock(element: Element) {\n let currentNode: Node | null = getParentNode(element);\n\n if (isShadowRoot(currentNode)) {\n currentNode = currentNode.host;\n }\n\n while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {\n if (isContainingBlock(currentNode)) {\n return currentNode;\n } else {\n const parent = (\n currentNode.assignedSlot\n ? currentNode.assignedSlot\n : currentNode.parentNode\n ) as Node;\n currentNode = isShadowRoot(parent) ? parent.host : parent;\n }\n }\n\n return null;\n}\n\nexport function isLastTraversableNode(node: Node) {\n return ['html', 'body', '#document'].includes(getNodeName(node));\n}\n\nfunction isContainingBlock(element: HTMLElement) {\n // TODO: Try and use feature detection here instead\n const isFirefox = /firefox/i.test(getUAString());\n if (element.tagName === 'dialog') {\n return true;\n }\n const css = getComputedStyle(element); // This is non-exhaustive but covers the most common CSS properties that\n // create a containing block.\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n\n return (\n css.transform !== 'none' ||\n css.perspective !== 'none' || // @ts-ignore (TS 4.1 compat)\n css.contain === 'paint' ||\n ['transform', 'perspective'].includes(css.willChange) ||\n (isFirefox && css.willChange === 'filter') ||\n (isFirefox && (css.filter ? css.filter !== 'none' : false))\n );\n}\n\ninterface NavigatorUAData {\n brands: Array<{ brand: string; version: string }>;\n mobile: boolean;\n platform: string;\n}\n\nexport function getUAString(): string {\n const uaData = (navigator as any).userAgentData as\n | NavigatorUAData\n | undefined;\n\n if (uaData?.brands) {\n return uaData.brands\n .map((item) => `${item.brand}/${item.version}`)\n .join(' ');\n }\n\n return navigator.userAgent;\n}\n\nexport function getParentNode(node: Node): Node {\n if (getNodeName(node) === 'html') {\n return node;\n }\n\n return (\n // this is a quicker (but less type safe) way to save quite some bytes from the bundle\n // @ts-ignore\n node.assignedSlot || // step into the shadow DOM of the parent of a slotted node\n node.parentNode || // DOM Element detected\n (isShadowRoot(node) ? node.host : null) || // ShadowRoot detected\n getDocumentElement(node) // fallback\n );\n}\n\nexport function getNodeName(node: Node | Window): string {\n return isWindow(node)\n ? ''\n : node\n ? (node.nodeName || '').toLowerCase()\n : '';\n}\n\nexport function getDocumentElement(node: Node | Window): HTMLElement {\n return (\n (isNode(node) ? node.ownerDocument : node.document) || window.document\n ).documentElement;\n}\n\nexport function isNode(value: any): value is Node {\n return value instanceof (getWindow(value) as unknown as { Node: any }).Node;\n}\n\nexport function isWindow(value: any): value is Window {\n return (\n value &&\n value.document &&\n value.location &&\n value.alert &&\n value.setInterval\n );\n}\n\nexport function getWindow(node: Node | Window): Window {\n if (node == null) {\n return window;\n }\n\n if (!isWindow(node)) {\n const ownerDocument = node.ownerDocument;\n return ownerDocument ? ownerDocument.defaultView || window : window;\n }\n\n return node;\n}\n\nexport function isShadowRoot(node: Node): node is ShadowRoot {\n // Browsers without `ShadowRoot` support\n if (typeof ShadowRoot === 'undefined') {\n return false;\n }\n\n const OwnElement = (\n getWindow(node) as unknown as { ShadowRoot: ShadowRoot }\n ).ShadowRoot;\n const testNode = node as Node;\n return (\n node instanceof (OwnElement as unknown as any) ||\n testNode instanceof ShadowRoot\n );\n}\n\nexport function isHTMLElement(value: any): value is HTMLElement {\n return (\n value instanceof\n (getWindow(value) as unknown as { HTMLElement: any }).HTMLElement\n );\n}\n"],
|
|
5
|
-
"mappings": "aAaO,aAAM,uBAAyB,KAAO,CACzC,KAAM,WACN,MAAM,GAAGA,EAA0C,CAC/C,KAAM,CACF,EAAAC,EACA,EAAAC,EACA,SAAU,CAAE,UAAAC,EAAW,SAAAC,CAAS,CACpC,EAAIJ,EACJ,IAAIK,EAAa,GACbC,EAAqB,GACzB,MAAMC,EAAa,CACf,EAAG,EACH,EAAG,CACP,EACA,GAAI,CACAF,EAAaA,GAAcD,EAAS,QAAQ,OAAO,CAEvD,OAASI,EAAP,CAAW,CACb,GAAI,CACAH,EAAaA,GAAcD,EAAS,QAAQ,QAAQ,CAExD,OAASI,EAAP,CAAW,CAEb,GADAF,EAAqBD,EACjB,CAACA,EAAY,CACb,MAAMI,EAA2B,IAAI,MACjC,0BACA,CAAE,SAAU,GAAM,QAAS,EAAK,CACpC,EACAL,EAAS,iBACL,0BACCM,GAAiB,CACbA,EAAM,aAAa,EAA2B,QAC1CC,GAAO,CACJ,GAAI,EAAAA,IAAOP,GAAYO,EAAG,YAAc,UAExC,GAAI,CACAN,EAAaA,GAAcM,EAAG,QAAQ,QAAQ,CAKlD,OAASH,EAAP,CAAW,CACjB,CACJ,CACJ,EACA,CAAE,KAAM,EAAK,CACjB,EACAJ,EAAS,cAAcK,CAAwB,
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { MiddlewareArguments } from '@floating-ui/dom';\n\nexport const topLayerOverTransforms = () => ({\n name: 'topLayer',\n async fn(middlewareArguments: MiddlewareArguments) {\n const {\n x,\n y,\n elements: { reference, floating },\n } = middlewareArguments;\n let onTopLayer = false;\n let topLayerIsFloating = false;\n const diffCoords = {\n x: 0,\n y: 0,\n };\n try {\n onTopLayer = onTopLayer || floating.matches(':popover-open');\n // eslint-disable-next-line no-empty\n } catch (e) {}\n try {\n onTopLayer = onTopLayer || floating.matches(':open');\n // eslint-disable-next-line no-empty\n } catch (e) {}\n try {\n onTopLayer = onTopLayer || floating.matches(':modal');\n // eslint-disable-next-line no-empty\n } catch (e) {}\n topLayerIsFloating = onTopLayer;\n if (!onTopLayer) {\n const dialogAncestorQueryEvent = new Event(\n 'floating-ui-dialog-test',\n { composed: true, bubbles: true }\n );\n floating.addEventListener(\n 'floating-ui-dialog-test',\n (event: Event) => {\n (event.composedPath() as unknown as Element[]).forEach(\n (el) => {\n if (el === floating || el.localName !== 'dialog')\n return;\n try {\n onTopLayer = onTopLayer || el.matches(':modal');\n if (onTopLayer) {\n // console.log(el);\n }\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n );\n },\n { once: true }\n );\n floating.dispatchEvent(dialogAncestorQueryEvent);\n }\n let overTransforms = false;\n const containingBlock = getContainingBlock(reference as Element);\n if (containingBlock !== null && !isWindow(containingBlock)) {\n overTransforms = true;\n }\n\n if (onTopLayer && overTransforms) {\n const rect = containingBlock!.getBoundingClientRect();\n diffCoords.x = rect.x;\n diffCoords.y = rect.y;\n }\n\n if (onTopLayer && topLayerIsFloating) {\n return {\n x: x + diffCoords.x,\n y: y + diffCoords.y,\n data: diffCoords,\n };\n }\n\n if (onTopLayer) {\n return {\n x,\n y,\n data: diffCoords,\n };\n }\n\n return {\n x: x - diffCoords.x,\n y: y - diffCoords.y,\n data: diffCoords,\n };\n },\n});\n\n/* COPY/PASTE from Floating UI */\n\nfunction getContainingBlock(element: Element) {\n let currentNode: Node | null = getParentNode(element);\n\n if (isShadowRoot(currentNode)) {\n currentNode = currentNode.host;\n }\n\n while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {\n if (isContainingBlock(currentNode)) {\n return currentNode;\n } else {\n const parent = (\n currentNode.assignedSlot\n ? currentNode.assignedSlot\n : currentNode.parentNode\n ) as Node;\n currentNode = isShadowRoot(parent) ? parent.host : parent;\n }\n }\n\n return null;\n}\n\nexport function isLastTraversableNode(node: Node) {\n return ['html', 'body', '#document'].includes(getNodeName(node));\n}\n\nfunction isContainingBlock(element: HTMLElement) {\n // TODO: Try and use feature detection here instead\n const isFirefox = /firefox/i.test(getUAString());\n if (element.tagName === 'dialog') {\n return true;\n }\n const css = getComputedStyle(element); // This is non-exhaustive but covers the most common CSS properties that\n // create a containing block.\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n\n return (\n css.transform !== 'none' ||\n css.perspective !== 'none' || // @ts-ignore (TS 4.1 compat)\n css.contain === 'paint' ||\n ['transform', 'perspective'].includes(css.willChange) ||\n (isFirefox && css.willChange === 'filter') ||\n (isFirefox && (css.filter ? css.filter !== 'none' : false))\n );\n}\n\ninterface NavigatorUAData {\n brands: Array<{ brand: string; version: string }>;\n mobile: boolean;\n platform: string;\n}\n\nexport function getUAString(): string {\n const uaData = (navigator as any).userAgentData as\n | NavigatorUAData\n | undefined;\n\n if (uaData?.brands) {\n return uaData.brands\n .map((item) => `${item.brand}/${item.version}`)\n .join(' ');\n }\n\n return navigator.userAgent;\n}\n\nexport function getParentNode(node: Node): Node {\n if (getNodeName(node) === 'html') {\n return node;\n }\n\n return (\n // this is a quicker (but less type safe) way to save quite some bytes from the bundle\n // @ts-ignore\n node.assignedSlot || // step into the shadow DOM of the parent of a slotted node\n node.parentNode || // DOM Element detected\n (isShadowRoot(node) ? node.host : null) || // ShadowRoot detected\n getDocumentElement(node) // fallback\n );\n}\n\nexport function getNodeName(node: Node | Window): string {\n return isWindow(node)\n ? ''\n : node\n ? (node.nodeName || '').toLowerCase()\n : '';\n}\n\nexport function getDocumentElement(node: Node | Window): HTMLElement {\n return (\n (isNode(node) ? node.ownerDocument : node.document) || window.document\n ).documentElement;\n}\n\nexport function isNode(value: any): value is Node {\n return value instanceof (getWindow(value) as unknown as { Node: any }).Node;\n}\n\nexport function isWindow(value: any): value is Window {\n return (\n value &&\n value.document &&\n value.location &&\n value.alert &&\n value.setInterval\n );\n}\n\nexport function getWindow(node: Node | Window): Window {\n if (node == null) {\n return window;\n }\n\n if (!isWindow(node)) {\n const ownerDocument = node.ownerDocument;\n return ownerDocument ? ownerDocument.defaultView || window : window;\n }\n\n return node;\n}\n\nexport function isShadowRoot(node: Node): node is ShadowRoot {\n // Browsers without `ShadowRoot` support\n if (typeof ShadowRoot === 'undefined') {\n return false;\n }\n\n const OwnElement = (\n getWindow(node) as unknown as { ShadowRoot: ShadowRoot }\n ).ShadowRoot;\n const testNode = node as Node;\n return (\n node instanceof (OwnElement as unknown as any) ||\n testNode instanceof ShadowRoot\n );\n}\n\nexport function isHTMLElement(value: any): value is HTMLElement {\n return (\n value instanceof\n (getWindow(value) as unknown as { HTMLElement: any }).HTMLElement\n );\n}\n"],
|
|
5
|
+
"mappings": "aAaO,aAAM,uBAAyB,KAAO,CACzC,KAAM,WACN,MAAM,GAAGA,EAA0C,CAC/C,KAAM,CACF,EAAAC,EACA,EAAAC,EACA,SAAU,CAAE,UAAAC,EAAW,SAAAC,CAAS,CACpC,EAAIJ,EACJ,IAAIK,EAAa,GACbC,EAAqB,GACzB,MAAMC,EAAa,CACf,EAAG,EACH,EAAG,CACP,EACA,GAAI,CACAF,EAAaA,GAAcD,EAAS,QAAQ,eAAe,CAE/D,OAASI,EAAP,CAAW,CACb,GAAI,CACAH,EAAaA,GAAcD,EAAS,QAAQ,OAAO,CAEvD,OAASI,EAAP,CAAW,CACb,GAAI,CACAH,EAAaA,GAAcD,EAAS,QAAQ,QAAQ,CAExD,OAASI,EAAP,CAAW,CAEb,GADAF,EAAqBD,EACjB,CAACA,EAAY,CACb,MAAMI,EAA2B,IAAI,MACjC,0BACA,CAAE,SAAU,GAAM,QAAS,EAAK,CACpC,EACAL,EAAS,iBACL,0BACCM,GAAiB,CACbA,EAAM,aAAa,E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,EAAWR,EACjB,OACIA,aAAiBO,GACjBC,aAAoB,UAE5B,CAEO,gBAAS,cAAcH,EAAkC,CAC5D,OACIA,aACC,UAAUA,CAAK,EAAsC,WAE9D",
|
|
6
6
|
"names": ["middlewareArguments", "x", "y", "reference", "floating", "onTopLayer", "topLayerIsFloating", "diffCoords", "e", "dialogAncestorQueryEvent", "event", "el", "overTransforms", "containingBlock", "getContainingBlock", "rect", "element", "currentNode", "isContainingBlock", "parent", "node", "isFirefox", "css", "uaData", "item", "value", "ownerDocument", "OwnElement", "testNode"]
|
|
7
7
|
}
|
package/test/index.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import {
|
|
3
|
-
escapeEvent,
|
|
4
|
-
fixture,
|
|
5
|
-
isOnTopLayer,
|
|
6
|
-
isVisible
|
|
7
|
-
} from "../../../test/testing-helpers.js";
|
|
2
|
+
import { fixture, isOnTopLayer } from "../../../test/testing-helpers.js";
|
|
8
3
|
import {
|
|
9
4
|
aTimeout,
|
|
10
5
|
elementUpdated,
|
|
@@ -17,6 +12,8 @@ import {
|
|
|
17
12
|
import "@spectrum-web-components/button/sp-button.js";
|
|
18
13
|
import "@spectrum-web-components/popover/sp-popover.js";
|
|
19
14
|
import "@spectrum-web-components/theme/sp-theme.js";
|
|
15
|
+
import { sendMouse } from "../../../test/plugins/browser.js";
|
|
16
|
+
import { sendKeys } from "@web/test-runner-commands";
|
|
20
17
|
function pressKey(code) {
|
|
21
18
|
const up = new KeyboardEvent("keyup", {
|
|
22
19
|
bubbles: true,
|
|
@@ -26,9 +23,6 @@ function pressKey(code) {
|
|
|
26
23
|
});
|
|
27
24
|
document.dispatchEvent(up);
|
|
28
25
|
}
|
|
29
|
-
const pressEscape = () => {
|
|
30
|
-
document.dispatchEvent(escapeEvent());
|
|
31
|
-
};
|
|
32
26
|
const pressSpace = () => pressKey("Space");
|
|
33
27
|
export const runOverlayTriggerTests = (type) => {
|
|
34
28
|
describe(`Overlay Trigger - ${type}`, () => {
|
|
@@ -231,9 +225,8 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
231
225
|
"hover not available at point"
|
|
232
226
|
).to.be.false;
|
|
233
227
|
});
|
|
234
|
-
it
|
|
235
|
-
const
|
|
236
|
-
const triggerZone = root.querySelector(
|
|
228
|
+
it("does not open a popover when [disabled]", async function() {
|
|
229
|
+
const triggerZone = this.outerTrigger.shadowRoot.querySelector(
|
|
237
230
|
"#trigger"
|
|
238
231
|
);
|
|
239
232
|
expect(this.outerTrigger.disabled).to.be.false;
|
|
@@ -245,7 +238,14 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
245
238
|
"hover available at point"
|
|
246
239
|
).to.be.true;
|
|
247
240
|
let closed = oneEvent(this.outerTrigger, "sp-closed");
|
|
248
|
-
|
|
241
|
+
sendMouse({
|
|
242
|
+
steps: [
|
|
243
|
+
{
|
|
244
|
+
type: "click",
|
|
245
|
+
position: [1, 1]
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
});
|
|
249
249
|
await closed;
|
|
250
250
|
expect(
|
|
251
251
|
await isOnTopLayer(this.outerClickContent),
|
|
@@ -286,7 +286,7 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
286
286
|
"hover not available at point"
|
|
287
287
|
).to.be.false;
|
|
288
288
|
});
|
|
289
|
-
it
|
|
289
|
+
it("opens a nested popover", async function() {
|
|
290
290
|
expect(
|
|
291
291
|
await isOnTopLayer(this.outerClickContent),
|
|
292
292
|
"hover not available at point"
|
|
@@ -303,7 +303,7 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
303
303
|
await isOnTopLayer(this.outerClickContent),
|
|
304
304
|
"outer click content available at point"
|
|
305
305
|
).to.be.true;
|
|
306
|
-
expect(
|
|
306
|
+
expect(await isOnTopLayer(this.innerClickContent)).to.be.false;
|
|
307
307
|
open = oneEvent(this.innerTrigger, "sp-opened");
|
|
308
308
|
this.innerButton.click();
|
|
309
309
|
await open;
|
|
@@ -316,7 +316,7 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
316
316
|
"inner click content available at point"
|
|
317
317
|
).to.be.true;
|
|
318
318
|
});
|
|
319
|
-
it
|
|
319
|
+
it('focus previous "modal" when closing nested "modal"', async function() {
|
|
320
320
|
this.outerTrigger.type = "modal";
|
|
321
321
|
this.innerTrigger.type = "modal";
|
|
322
322
|
expect(
|
|
@@ -350,7 +350,9 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
350
350
|
"inner click content available at point"
|
|
351
351
|
).to.be.true;
|
|
352
352
|
const innerClose = oneEvent(this.innerButton, "sp-closed");
|
|
353
|
-
|
|
353
|
+
await sendKeys({
|
|
354
|
+
press: "Escape"
|
|
355
|
+
});
|
|
354
356
|
await innerClose;
|
|
355
357
|
expect(
|
|
356
358
|
await isOnTopLayer(this.outerClickContent),
|
|
@@ -365,7 +367,7 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
365
367
|
"outer popover recieved focus"
|
|
366
368
|
).to.be.true;
|
|
367
369
|
});
|
|
368
|
-
it
|
|
370
|
+
it("escape closes an open popover", async function() {
|
|
369
371
|
this.outerTrigger.type = "modal";
|
|
370
372
|
this.innerTrigger.type = "modal";
|
|
371
373
|
const outerOpen = oneEvent(this.outerButton, "sp-opened");
|
|
@@ -396,7 +398,9 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
396
398
|
"inner click content available at point"
|
|
397
399
|
).to.be.true;
|
|
398
400
|
const innerClose = oneEvent(this.innerButton, "sp-closed");
|
|
399
|
-
|
|
401
|
+
await sendKeys({
|
|
402
|
+
press: "Escape"
|
|
403
|
+
});
|
|
400
404
|
await innerClose;
|
|
401
405
|
expect(
|
|
402
406
|
await isOnTopLayer(this.outerClickContent),
|
|
@@ -407,7 +411,9 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
407
411
|
"inner click content not available at point"
|
|
408
412
|
).to.be.false;
|
|
409
413
|
const outerClose = oneEvent(this.outerButton, "sp-closed");
|
|
410
|
-
|
|
414
|
+
await sendKeys({
|
|
415
|
+
press: "Escape"
|
|
416
|
+
});
|
|
411
417
|
await outerClose;
|
|
412
418
|
expect(
|
|
413
419
|
await isOnTopLayer(this.outerClickContent),
|
|
@@ -418,7 +424,7 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
418
424
|
"inner click content not available at point"
|
|
419
425
|
).to.be.false;
|
|
420
426
|
});
|
|
421
|
-
it
|
|
427
|
+
it("click closes an open popover", async function() {
|
|
422
428
|
this.outerTrigger.type = "modal";
|
|
423
429
|
this.innerTrigger.type = "modal";
|
|
424
430
|
const outerOpen = oneEvent(this.outerButton, "sp-opened");
|
|
@@ -450,7 +456,14 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
450
456
|
"inner click content is available at point"
|
|
451
457
|
).to.be.true;
|
|
452
458
|
const innerClose = oneEvent(this.innerButton, "sp-closed");
|
|
453
|
-
|
|
459
|
+
sendMouse({
|
|
460
|
+
steps: [
|
|
461
|
+
{
|
|
462
|
+
type: "click",
|
|
463
|
+
position: [1, 1]
|
|
464
|
+
}
|
|
465
|
+
]
|
|
466
|
+
});
|
|
454
467
|
await innerClose;
|
|
455
468
|
expect(
|
|
456
469
|
await isOnTopLayer(this.outerClickContent),
|
|
@@ -461,7 +474,14 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
461
474
|
"inner click content is not available at point"
|
|
462
475
|
).to.be.false;
|
|
463
476
|
const outerClose = oneEvent(this.outerButton, "sp-closed");
|
|
464
|
-
|
|
477
|
+
sendMouse({
|
|
478
|
+
steps: [
|
|
479
|
+
{
|
|
480
|
+
type: "click",
|
|
481
|
+
position: [1, 1]
|
|
482
|
+
}
|
|
483
|
+
]
|
|
484
|
+
});
|
|
465
485
|
await outerClose;
|
|
466
486
|
expect(
|
|
467
487
|
await isOnTopLayer(this.outerClickContent),
|
|
@@ -472,28 +492,38 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
472
492
|
"inner click content is not available at point"
|
|
473
493
|
).to.be.not;
|
|
474
494
|
});
|
|
475
|
-
it
|
|
476
|
-
|
|
477
|
-
const
|
|
478
|
-
"#trigger"
|
|
479
|
-
);
|
|
480
|
-
expect(triggerZone).to.exist;
|
|
481
|
-
if (!triggerZone)
|
|
482
|
-
return;
|
|
483
|
-
expect(this.outerButton).to.exist;
|
|
484
|
-
expect(this.hoverContent).to.exist;
|
|
485
|
-
expect(isVisible(this.hoverContent)).to.be.false;
|
|
495
|
+
it("opens a hover popover", async function() {
|
|
496
|
+
expect(await isOnTopLayer(this.hoverContent)).to.be.false;
|
|
497
|
+
const rect = this.outerTrigger.getBoundingClientRect();
|
|
486
498
|
const open = oneEvent(this.outerTrigger, "sp-opened");
|
|
487
|
-
|
|
488
|
-
|
|
499
|
+
sendMouse({
|
|
500
|
+
steps: [
|
|
501
|
+
{
|
|
502
|
+
type: "move",
|
|
503
|
+
position: [
|
|
504
|
+
rect.left + rect.width / 2,
|
|
505
|
+
rect.top + rect.height / 2
|
|
506
|
+
]
|
|
507
|
+
}
|
|
508
|
+
]
|
|
509
|
+
});
|
|
489
510
|
await open;
|
|
490
511
|
expect(
|
|
491
512
|
await isOnTopLayer(this.hoverContent),
|
|
492
513
|
"hover content is available at point"
|
|
493
514
|
).to.be.true;
|
|
494
515
|
const close = oneEvent(this.outerTrigger, "sp-closed");
|
|
495
|
-
|
|
496
|
-
|
|
516
|
+
sendMouse({
|
|
517
|
+
steps: [
|
|
518
|
+
{
|
|
519
|
+
type: "move",
|
|
520
|
+
position: [
|
|
521
|
+
rect.left + rect.width * 2,
|
|
522
|
+
rect.top + rect.height / 2
|
|
523
|
+
]
|
|
524
|
+
}
|
|
525
|
+
]
|
|
526
|
+
});
|
|
497
527
|
await close;
|
|
498
528
|
expect(
|
|
499
529
|
await isOnTopLayer(this.hoverContent),
|
|
@@ -501,33 +531,42 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
501
531
|
).to.be.false;
|
|
502
532
|
});
|
|
503
533
|
it("closes a hover popover", async function() {
|
|
504
|
-
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
const mouseLeave = new MouseEvent("mouseleave");
|
|
519
|
-
triggerZone.dispatchEvent(mouseEnter);
|
|
534
|
+
expect(await isOnTopLayer(this.hoverContent)).to.be.false;
|
|
535
|
+
const rect = this.outerTrigger.getBoundingClientRect();
|
|
536
|
+
const close = oneEvent(this.outerTrigger, "sp-closed");
|
|
537
|
+
await sendMouse({
|
|
538
|
+
steps: [
|
|
539
|
+
{
|
|
540
|
+
type: "move",
|
|
541
|
+
position: [
|
|
542
|
+
rect.left + rect.width / 2,
|
|
543
|
+
rect.top + rect.height / 2
|
|
544
|
+
]
|
|
545
|
+
}
|
|
546
|
+
]
|
|
547
|
+
});
|
|
520
548
|
await nextFrame();
|
|
521
549
|
await nextFrame();
|
|
522
|
-
triggerZone.dispatchEvent(mouseLeave);
|
|
523
550
|
await nextFrame();
|
|
524
551
|
await nextFrame();
|
|
552
|
+
await sendMouse({
|
|
553
|
+
steps: [
|
|
554
|
+
{
|
|
555
|
+
type: "move",
|
|
556
|
+
position: [
|
|
557
|
+
rect.left + rect.width * 2,
|
|
558
|
+
rect.top + rect.height / 2
|
|
559
|
+
]
|
|
560
|
+
}
|
|
561
|
+
]
|
|
562
|
+
});
|
|
563
|
+
await close;
|
|
525
564
|
expect(
|
|
526
565
|
await isOnTopLayer(this.hoverContent),
|
|
527
566
|
"hover content is not available at point"
|
|
528
567
|
).to.be.false;
|
|
529
568
|
});
|
|
530
|
-
it
|
|
569
|
+
it("dispatches events on open/close", async function() {
|
|
531
570
|
const opened = oneEvent(this.outerButton, "sp-opened");
|
|
532
571
|
this.outerButton.click();
|
|
533
572
|
const openedEvent = await opened;
|
|
@@ -536,11 +575,18 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
536
575
|
"hover content is available at point"
|
|
537
576
|
).to.be.true;
|
|
538
577
|
expect(this.outerTrigger.open).to.equal("click");
|
|
539
|
-
expect(openedEvent.detail.interaction).to.equal("
|
|
578
|
+
expect(openedEvent.detail.interaction).to.equal("auto");
|
|
540
579
|
const closed = oneEvent(this.outerButton, "sp-closed");
|
|
541
|
-
|
|
580
|
+
sendMouse({
|
|
581
|
+
steps: [
|
|
582
|
+
{
|
|
583
|
+
type: "click",
|
|
584
|
+
position: [1, 1]
|
|
585
|
+
}
|
|
586
|
+
]
|
|
587
|
+
});
|
|
542
588
|
const closedEvent = await closed;
|
|
543
|
-
expect(closedEvent.detail.interaction).to.equal("
|
|
589
|
+
expect(closedEvent.detail.interaction).to.equal("auto");
|
|
544
590
|
expect(
|
|
545
591
|
await isOnTopLayer(this.outerClickContent),
|
|
546
592
|
"hover content is not available at point"
|
|
@@ -560,52 +606,6 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
560
606
|
});
|
|
561
607
|
await Promise.all(closes);
|
|
562
608
|
});
|
|
563
|
-
it.skip("acquires a `color` and `size` from `sp-theme`", async () => {
|
|
564
|
-
const el = await fixture(html`
|
|
565
|
-
<sp-theme color="dark">
|
|
566
|
-
<sp-theme color="light">
|
|
567
|
-
<overlay-trigger id="trigger" placement="top">
|
|
568
|
-
<sp-button
|
|
569
|
-
id="outer-button"
|
|
570
|
-
variant="primary"
|
|
571
|
-
slot="trigger"
|
|
572
|
-
>
|
|
573
|
-
Show Popover
|
|
574
|
-
</sp-button>
|
|
575
|
-
<sp-popover
|
|
576
|
-
id="outer-popover"
|
|
577
|
-
dialog
|
|
578
|
-
slot="click-content"
|
|
579
|
-
direction="bottom"
|
|
580
|
-
tip
|
|
581
|
-
>
|
|
582
|
-
<sp-button
|
|
583
|
-
id="test-button"
|
|
584
|
-
variant="primary"
|
|
585
|
-
>
|
|
586
|
-
Test popover.
|
|
587
|
-
</sp-button>
|
|
588
|
-
</sp-popover>
|
|
589
|
-
</overlay-trigger>
|
|
590
|
-
</sp-theme>
|
|
591
|
-
</sp-theme>
|
|
592
|
-
`);
|
|
593
|
-
await elementUpdated(el);
|
|
594
|
-
expect(document.querySelector("active-overlay")).to.be.null;
|
|
595
|
-
const button = el.querySelector("sp-button");
|
|
596
|
-
const testButton = el.querySelector("#test-button");
|
|
597
|
-
const buttonStyles = getComputedStyle(button);
|
|
598
|
-
const opened = oneEvent(button, "sp-opened");
|
|
599
|
-
button.click();
|
|
600
|
-
await opened;
|
|
601
|
-
const testStyles = getComputedStyle(testButton);
|
|
602
|
-
expect(testStyles.getPropertyValue("background")).to.equal(
|
|
603
|
-
buttonStyles.getPropertyValue("background")
|
|
604
|
-
);
|
|
605
|
-
expect(testStyles.getPropertyValue("min-height")).to.equal(
|
|
606
|
-
buttonStyles.getPropertyValue("min-height")
|
|
607
|
-
);
|
|
608
|
-
});
|
|
609
609
|
it.skip('manages multiple layers of `type="modal"', async () => {
|
|
610
610
|
var _a, _b, _c;
|
|
611
611
|
const el = await fixture(html`
|
|
@@ -720,7 +720,14 @@ export const runOverlayTriggerTests = (type) => {
|
|
|
720
720
|
).to.equal("open");
|
|
721
721
|
await nextFrame();
|
|
722
722
|
const closed = oneEvent(triggers[2], "sp-closed");
|
|
723
|
-
|
|
723
|
+
sendMouse({
|
|
724
|
+
steps: [
|
|
725
|
+
{
|
|
726
|
+
type: "click",
|
|
727
|
+
position: [1, 1]
|
|
728
|
+
}
|
|
729
|
+
]
|
|
730
|
+
});
|
|
724
731
|
await closed;
|
|
725
732
|
await elementUpdated(overlayTriggers[2]);
|
|
726
733
|
activeOverlays = [
|