@spectrum-web-components/overlay
Advanced tools
Comparing version 0.11.1 to 0.11.2
@@ -6,2 +6,6 @@ # Change Log | ||
## [0.11.2](https://github.com/adobe/spectrum-web-components/compare/@spectrum-web-components/overlay@0.11.1...@spectrum-web-components/overlay@0.11.2) (2021-03-29) | ||
**Note:** Version bump only for package @spectrum-web-components/overlay | ||
## [0.11.1](https://github.com/adobe/spectrum-web-components/compare/@spectrum-web-components/overlay@0.11.0...@spectrum-web-components/overlay@0.11.1) (2021-03-22) | ||
@@ -8,0 +12,0 @@ |
@@ -21,3 +21,3 @@ { | ||
], | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "", | ||
@@ -65,9 +65,9 @@ "main": "./src/index.js", | ||
"@popperjs/core": "^2.2.2", | ||
"@spectrum-web-components/action-button": "^0.4.3", | ||
"@spectrum-web-components/action-button": "^0.4.4", | ||
"@spectrum-web-components/base": "^0.4.2", | ||
"@spectrum-web-components/theme": "^0.8.3", | ||
"@spectrum-web-components/theme": "^0.8.4", | ||
"popper-max-size-modifier": "^0.2.0", | ||
"tslib": "^2.0.0" | ||
}, | ||
"gitHead": "1bdbe17c20ca0be44b4683470041f8f4c7c5909f" | ||
"gitHead": "4defd67aae71ad095d1c001bd1d23665edf39b24" | ||
} |
@@ -25,5 +25,3 @@ import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base'; | ||
trigger: HTMLElement; | ||
private placeholder?; | ||
private popper?; | ||
private originalSlot?; | ||
_state: OverlayStateType; | ||
@@ -39,2 +37,3 @@ get state(): OverlayStateType; | ||
private originalPlacement?; | ||
private restoreContent?; | ||
/** | ||
@@ -41,0 +40,0 @@ * @prop Used by the popper library to indicate where the overlay was |
@@ -14,2 +14,3 @@ /* | ||
import { html, ifDefined, property, SpectrumElement, } from '@spectrum-web-components/base'; | ||
import { reparentChildren } from '@spectrum-web-components/shared'; | ||
import styles from './active-overlay.css.js'; | ||
@@ -256,18 +257,4 @@ import { applyMaxSize, createPopper, maxSize } from './popper.js'; | ||
stealOverlayContent(element) { | ||
/* c8 ignore next */ | ||
if (this.placeholder || !element) | ||
return; | ||
if (!this.placeholder) { | ||
this.placeholder = document.createComment('placeholder for ' + element.nodeName); | ||
} | ||
const parentElement = element.parentElement || element.getRootNode(); | ||
if (parentElement) { | ||
parentElement.replaceChild(this.placeholder, element); | ||
} | ||
this.overlayContent = element; | ||
this.originalSlot = | ||
this.overlayContent.getAttribute('slot') || undefined; | ||
this.overlayContent.setAttribute('slot', 'overlay'); | ||
this.appendChild(this.overlayContent); | ||
this.originalPlacement = this.overlayContent.getAttribute('placement'); | ||
this.originalPlacement = element.getAttribute('placement'); | ||
this.restoreContent = reparentChildren([element], this); | ||
this.stealOverlayContentResolver(); | ||
@@ -277,24 +264,11 @@ } | ||
/* c8 ignore next */ | ||
if (!this.overlayContent) | ||
if (!this.restoreContent) | ||
return; | ||
if (this.originalSlot) { | ||
this.overlayContent.setAttribute('slot', this.originalSlot); | ||
delete this.originalSlot; | ||
} | ||
else { | ||
this.overlayContent.removeAttribute('slot'); | ||
} | ||
if (this.placeholder) { | ||
const parentElement = this.placeholder.parentElement || | ||
this.placeholder.getRootNode(); | ||
if (parentElement) { | ||
parentElement.replaceChild(this.overlayContent, this.placeholder); | ||
this.willNotifyClosed = true; | ||
} | ||
} | ||
const [element] = this.restoreContent(); | ||
this.restoreContent = undefined; | ||
this.willNotifyClosed = true; | ||
if (this.originalPlacement) { | ||
this.overlayContent.setAttribute('placement', this.originalPlacement); | ||
element.setAttribute('placement', this.originalPlacement); | ||
delete this.originalPlacement; | ||
} | ||
delete this.placeholder; | ||
} | ||
@@ -354,3 +328,3 @@ async updateOverlayPosition() { | ||
<div id="contents"> | ||
<slot @slotchange=${this.onSlotChange} name="overlay"></slot> | ||
<slot @slotchange=${this.onSlotChange}></slot> | ||
</div> | ||
@@ -357,0 +331,0 @@ `; |
@@ -22,2 +22,3 @@ /* | ||
} from '@spectrum-web-components/base'; | ||
import { reparentChildren } from '@spectrum-web-components/shared'; | ||
import { Color, Scale } from '@spectrum-web-components/theme'; | ||
@@ -119,5 +120,3 @@ import styles from './active-overlay.css.js'; | ||
private placeholder?: Comment; | ||
private popper?: Instance; | ||
private originalSlot?: string; | ||
@@ -160,2 +159,3 @@ @property() | ||
private originalPlacement?: Placement; | ||
private restoreContent?: () => Element[]; | ||
@@ -367,26 +367,4 @@ /** | ||
private stealOverlayContent(element: HTMLElement): void { | ||
/* c8 ignore next */ | ||
if (this.placeholder || !element) return; | ||
if (!this.placeholder) { | ||
this.placeholder = document.createComment( | ||
'placeholder for ' + element.nodeName | ||
); | ||
} | ||
const parentElement = element.parentElement || element.getRootNode(); | ||
if (parentElement) { | ||
parentElement.replaceChild(this.placeholder, element); | ||
} | ||
this.overlayContent = element; | ||
this.originalSlot = | ||
this.overlayContent.getAttribute('slot') || undefined; | ||
this.overlayContent.setAttribute('slot', 'overlay'); | ||
this.appendChild(this.overlayContent); | ||
this.originalPlacement = this.overlayContent.getAttribute( | ||
'placement' | ||
) as Placement; | ||
this.originalPlacement = element.getAttribute('placement') as Placement; | ||
this.restoreContent = reparentChildren([element], this); | ||
this.stealOverlayContentResolver(); | ||
@@ -399,33 +377,12 @@ } | ||
/* c8 ignore next */ | ||
if (!this.overlayContent) return; | ||
if (!this.restoreContent) return; | ||
if (this.originalSlot) { | ||
this.overlayContent.setAttribute('slot', this.originalSlot); | ||
delete this.originalSlot; | ||
} else { | ||
this.overlayContent.removeAttribute('slot'); | ||
} | ||
const [element] = this.restoreContent(); | ||
this.restoreContent = undefined; | ||
this.willNotifyClosed = true; | ||
if (this.placeholder) { | ||
const parentElement = | ||
this.placeholder.parentElement || | ||
this.placeholder.getRootNode(); | ||
if (parentElement) { | ||
parentElement.replaceChild( | ||
this.overlayContent, | ||
this.placeholder | ||
); | ||
this.willNotifyClosed = true; | ||
} | ||
} | ||
if (this.originalPlacement) { | ||
this.overlayContent.setAttribute( | ||
'placement', | ||
this.originalPlacement | ||
); | ||
element.setAttribute('placement', this.originalPlacement); | ||
delete this.originalPlacement; | ||
} | ||
delete this.placeholder; | ||
} | ||
@@ -514,3 +471,3 @@ | ||
<div id="contents"> | ||
<slot @slotchange=${this.onSlotChange} name="overlay"></slot> | ||
<slot @slotchange=${this.onSlotChange}></slot> | ||
</div> | ||
@@ -517,0 +474,0 @@ `; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
284812
69
3724
11