@genesislcap/foundation-utils
Advanced tools
Comparing version 14.3.1-alpha-d0e4402.0 to 14.4.0
import { Constructable, FASTElement } from '@microsoft/fast-element'; | ||
export type ConstructableLifecycleHandler = Constructable<FASTElement & HTMLElement>; | ||
type Draggable = { | ||
type FoundationLayoutContainer = { | ||
dragging: boolean; | ||
hasFirstLoaded: boolean; | ||
_key: 'foundation-layout'; | ||
}; | ||
type LayoutCacheContainer = { | ||
_key: 'foundation-layout-cache'; | ||
}; | ||
type DOMContainer = { | ||
_key: 'dom'; | ||
}; | ||
type Container = FoundationLayoutContainer | LayoutCacheContainer | DOMContainer; | ||
export declare const LifecycleMixin: <T extends ConstructableLifecycleHandler>(Base: T) => { | ||
new (...args: any[]): { | ||
"__#1@#_containingLayout": Draggable | null; | ||
"__#1@#_container": Container; | ||
cloneNode(deep?: boolean): Node; | ||
@@ -13,3 +22,3 @@ deepClone(): Node; | ||
readonly shouldRunConnect: boolean; | ||
"__#1@#_tryFindContainingLayout"(e: Element): Draggable | null; | ||
"__#1@#_tryFindContainingLayout"(e: Element): Container; | ||
connectedCallback(): void; | ||
@@ -329,3 +338,4 @@ readonly $fastController: import("@microsoft/fast-element").Controller; | ||
} & T; | ||
export declare const layoutCacheDocument: unique symbol; | ||
export {}; | ||
//# sourceMappingURL=lifecycle.d.ts.map |
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib"; | ||
export const LifecycleMixin = (Base) => { var _instances, __containingLayout, __tryFindContainingLayout, _a; return _a = class extends Base { | ||
export const LifecycleMixin = (Base) => { var _instances, __container, __tryFindContainingLayout, _a; return _a = class extends Base { | ||
constructor(...args) { | ||
super(args); | ||
_instances.add(this); | ||
__containingLayout.set(this, null); | ||
__container.set(this, { _key: 'dom' }); | ||
} | ||
@@ -23,5 +23,9 @@ cloneNode(deep) { | ||
get shouldRunDisconnect() { | ||
if (__classPrivateFieldGet(this, __containingLayout, "f") === null) | ||
if (__classPrivateFieldGet(this, __container, "f")._key === 'dom') { | ||
return true; | ||
return !__classPrivateFieldGet(this, __containingLayout, "f").dragging; | ||
} | ||
if (__classPrivateFieldGet(this, __container, "f")._key === 'foundation-layout-cache') { | ||
return false; | ||
} | ||
return !(__classPrivateFieldGet(this, __container, "f").dragging || !__classPrivateFieldGet(this, __container, "f").hasFirstLoaded); | ||
} | ||
@@ -33,16 +37,21 @@ get shouldRunConnect() { | ||
super.connectedCallback(); | ||
if (__classPrivateFieldGet(this, __containingLayout, "f") === null) { | ||
__classPrivateFieldSet(this, __containingLayout, __classPrivateFieldGet(this, _instances, "m", __tryFindContainingLayout).call(this, this), "f"); | ||
if (__classPrivateFieldGet(this, __container, "f")._key !== 'foundation-layout') { | ||
__classPrivateFieldSet(this, __container, __classPrivateFieldGet(this, _instances, "m", __tryFindContainingLayout).call(this, this), "f"); | ||
} | ||
} | ||
}, | ||
__containingLayout = new WeakMap(), | ||
__container = new WeakMap(), | ||
_instances = new WeakSet(), | ||
__tryFindContainingLayout = function __tryFindContainingLayout(e) { | ||
if (e.getRootNode() instanceof Document || e.getRootNode() instanceof DocumentFragment) { | ||
return null; | ||
if (e.getRootNode()[layoutCacheDocument] === true) { | ||
return { _key: 'foundation-layout-cache' }; | ||
} | ||
if (e.getRootNode() instanceof Document) { | ||
return { _key: 'dom' }; | ||
} | ||
const shadowHost = e.getRootNode().host; | ||
if (shadowHost.constructor.name === 'FoundationLayout') { | ||
return shadowHost; | ||
const layoutHost = shadowHost; | ||
layoutHost._key = 'foundation-layout'; | ||
return layoutHost; | ||
} | ||
@@ -52,1 +61,2 @@ return __classPrivateFieldGet(this, _instances, "m", __tryFindContainingLayout).call(this, shadowHost); | ||
_a; }; | ||
export const layoutCacheDocument = Symbol('layout-cache-document'); |
{ | ||
"name": "@genesislcap/foundation-utils", | ||
"description": "Genesis Foundation Utils", | ||
"version": "14.3.1-alpha-d0e4402.0", | ||
"version": "14.4.0", | ||
"sideEffects": false, | ||
@@ -91,3 +91,3 @@ "license": "SEE LICENSE IN license.txt", | ||
}, | ||
"gitHead": "4321a5bdc42370bb1d5731a0fba999fdedc0e8bb" | ||
"gitHead": "faee66c559ee8763ae7bd4cc448b768d86391a41" | ||
} |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
100290
1567
2