@patternfly/pfe-core 2.0.0-next.0 → 2.0.0-next.10
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/context.js +1 -1
- package/context.js.map +2 -2
- package/controllers/cascade-controller.js +1 -1
- package/controllers/cascade-controller.js.map +2 -2
- package/controllers/color-context.d.ts +115 -0
- package/controllers/color-context.js +2 -0
- package/controllers/color-context.js.map +7 -0
- package/controllers/{color-context-controller.scss → color-context.scss} +58 -17
- package/controllers/css-variable-controller.js.map +2 -2
- package/controllers/floating-dom-controller.d.ts +30 -0
- package/controllers/floating-dom-controller.js +2 -0
- package/controllers/floating-dom-controller.js.map +7 -0
- package/controllers/light-dom-controller.js +1 -1
- package/controllers/light-dom-controller.js.map +2 -2
- package/controllers/logger.js +1 -1
- package/controllers/logger.js.map +3 -3
- package/controllers/perf-controller.js +1 -1
- package/controllers/perf-controller.js.map +2 -2
- package/controllers/property-observer-controller.js +1 -1
- package/controllers/property-observer-controller.js.map +2 -2
- package/controllers/slot-controller.js +1 -1
- package/controllers/slot-controller.js.map +3 -3
- package/controllers/style-controller.js +1 -1
- package/controllers/style-controller.js.map +3 -3
- package/core.d.ts +1 -3
- package/core.js +1 -1
- package/core.js.map +3 -3
- package/decorators/bound.js.map +2 -2
- package/decorators/cascades.js.map +2 -2
- package/decorators/color-context.d.ts +4 -0
- package/decorators/color-context.js +2 -0
- package/decorators/color-context.js.map +7 -0
- package/decorators/deprecation.d.ts +16 -0
- package/decorators/deprecation.js +2 -0
- package/decorators/deprecation.js.map +7 -0
- package/decorators/initializer.js.map +2 -2
- package/decorators/observed.d.ts +1 -1
- package/decorators/observed.js.map +3 -3
- package/decorators/pfelement.d.ts +5 -1
- package/decorators/pfelement.js +1 -1
- package/decorators/pfelement.js.map +3 -3
- package/decorators/time.js.map +2 -2
- package/decorators/trace.js.map +2 -2
- package/decorators.d.ts +2 -0
- package/decorators.js +1 -1
- package/decorators.js.map +2 -2
- package/functions/debounce.js.map +2 -2
- package/functions/deprecatedCustomEvent.js.map +2 -2
- package/functions/random.js.map +2 -2
- package/package.json +29 -26
- package/controllers/color-context-controller.d.ts +0 -41
- package/controllers/color-context-controller.js +0 -55
- package/controllers/color-context-controller.js.map +0 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getCompatibleStyle as
|
|
1
|
+
import{getCompatibleStyle as i,supportsAdoptingStyleSheets as n}from"lit";var l=class{constructor(t,e){this.host=t;this.styles=e;this.stylesAdopted=!1;t.addController(this)}hostConnected(){if(this.stylesAdopted||!(this.host.renderRoot instanceof ShadowRoot))return;let t=[this.styles].flatMap(e=>i(e)).filter(e=>!!e);n?this.host.renderRoot.adoptedStyleSheets=[...t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet),...this.host.renderRoot.adoptedStyleSheets??[]]:t.forEach(e=>{let s=document.createElement("style"),o=window.litNonce;o!==void 0&&s.setAttribute("nonce",o),s.textContent=e.cssText,this.host.renderRoot.appendChild(s)}),this.stylesAdopted=!0}};export{l as StyleController};
|
|
2
2
|
//# sourceMappingURL=style-controller.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["style-controller.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReactiveController, ReactiveElement, CSSResultGroup, CSSResultOrNative, CSSResult } from 'lit';\nimport { getCompatibleStyle, supportsAdoptingStyleSheets } from 'lit';\n\ndeclare global {\n interface ShadowRoot {\n adoptedStyleSheets: CSSStyleSheet[];\n }\n}\n\n/**\n * Controller which adds styles to it's host element.\n * Like `static styles = []`, except a controller.\n * Should typically only be used within other controllers.\n */\nexport class StyleController implements ReactiveController {\n private stylesAdopted = false;\n\n constructor(\n private host: ReactiveElement,\n /** These styles will be applied to the host element */\n private styles: CSSResultGroup,\n ) {\n host.addController(this);\n }\n\n hostConnected(): void {\n if (this.stylesAdopted || !(this.host.renderRoot instanceof ShadowRoot)) {\n return;\n }\n\n const styles = [this.styles].flatMap(x => getCompatibleStyle(x as CSSResultOrNative)).filter(x => !!x);\n\n if (supportsAdoptingStyleSheets) {\n this.host.renderRoot.adoptedStyleSheets = [\n ...
|
|
5
|
-
"mappings": "AACA,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import type { ReactiveController, ReactiveElement, CSSResultGroup, CSSResultOrNative, CSSResult } from 'lit';\nimport { getCompatibleStyle, supportsAdoptingStyleSheets } from 'lit';\n\ndeclare global {\n interface ShadowRoot {\n adoptedStyleSheets: CSSStyleSheet[];\n }\n}\n\n/**\n * Controller which adds styles to it's host element.\n * Like `static styles = []`, except a controller.\n * Should typically only be used within other controllers.\n */\nexport class StyleController implements ReactiveController {\n private stylesAdopted = false;\n\n constructor(\n private host: ReactiveElement,\n /** These styles will be applied to the host element */\n private styles: CSSResultGroup,\n ) {\n host.addController(this);\n }\n\n hostConnected(): void {\n if (this.stylesAdopted || !(this.host.renderRoot instanceof ShadowRoot)) {\n return;\n }\n\n const styles = [this.styles].flatMap(x => getCompatibleStyle(x as CSSResultOrNative)).filter(x => !!x);\n\n if (supportsAdoptingStyleSheets) {\n this.host.renderRoot.adoptedStyleSheets = [\n ...styles.map(x => x instanceof CSSStyleSheet ? x : x.styleSheet as CSSStyleSheet),\n ...this.host.renderRoot.adoptedStyleSheets ?? [],\n ];\n } else {\n styles.forEach(s => {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (window as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n this.host.renderRoot.appendChild(style);\n });\n }\n\n this.stylesAdopted = true;\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,sBAAAA,EAAoB,+BAAAC,MAAmC,MAazD,IAAMC,EAAN,KAAoD,CAGzD,YACUC,EAEAC,EACR,CAHQ,UAAAD,EAEA,YAAAC,EALV,KAAQ,cAAgB,GAOtBD,EAAK,cAAc,IAAI,CACzB,CAEA,eAAsB,CACpB,GAAI,KAAK,eAAiB,EAAE,KAAK,KAAK,sBAAsB,YAC1D,OAGF,IAAMC,EAAS,CAAC,KAAK,MAAM,EAAE,QAAQC,GAAKL,EAAmBK,CAAsB,CAAC,EAAE,OAAOA,GAAK,CAAC,CAACA,CAAC,EAEjGJ,EACF,KAAK,KAAK,WAAW,mBAAqB,CACxC,GAAGG,EAAO,IAAIC,GAAKA,aAAa,cAAgBA,EAAIA,EAAE,UAA2B,EACjF,GAAG,KAAK,KAAK,WAAW,oBAAsB,CAAC,CACjD,EAEAD,EAAO,QAAQE,GAAK,CAClB,IAAMC,EAAQ,SAAS,cAAc,OAAO,EAEtCC,EAAS,OAAe,SAC1BA,IAAU,QACZD,EAAM,aAAa,QAASC,CAAK,EAEnCD,EAAM,YAAeD,EAAgB,QACrC,KAAK,KAAK,WAAW,YAAYC,CAAK,CACxC,CAAC,EAGH,KAAK,cAAgB,EACvB,CACF",
|
|
6
|
+
"names": ["getCompatibleStyle", "supportsAdoptingStyleSheets", "StyleController", "host", "styles", "x", "s", "style", "nonce"]
|
|
7
7
|
}
|
package/core.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComplexAttributeConverter } from 'lit';
|
|
2
|
+
export type { ColorPalette, ColorTheme } from './controllers/color-context.js';
|
|
2
3
|
/** PatternFly Elements global config object */
|
|
3
4
|
export interface PfeConfig {
|
|
4
5
|
/** Set to false to disable client-side page load performance tracking */
|
|
@@ -8,8 +9,6 @@ export interface PfeConfig {
|
|
|
8
9
|
/** Set to false to disable automatically removing `unresolved` attr from body */
|
|
9
10
|
autoReveal?: boolean;
|
|
10
11
|
}
|
|
11
|
-
export declare type ColorTheme = ('base' | 'accent' | 'complement' | 'lighter' | 'lightest' | 'darker' | 'darkest');
|
|
12
|
-
export declare type ContextTheme = ('dark' | 'light' | 'saturated');
|
|
13
12
|
declare const noPref: unique symbol;
|
|
14
13
|
/**
|
|
15
14
|
* A boolean value that indicates if the performance should be tracked.
|
|
@@ -35,4 +34,3 @@ declare global {
|
|
|
35
34
|
PfeConfig: PfeConfig;
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
|
-
export {};
|
package/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var o=Symbol();function r(e){return document.head.querySelector(`meta[name="${e}"]`)?.content}function
|
|
1
|
+
var o=Symbol();function r(e){return document.head.querySelector(`meta[name="${e}"]`)?.content}function l(e=o){return e!==o&&(window.PfeConfig.trackPerformance=!!e),window.PfeConfig.trackPerformance}var i={fromAttribute(e){return typeof e!="string"?null:e.split(",").map(t=>t.trim()).map(t=>parseInt(t,10))},toAttribute(e){return e.join(",")}},n=class extends Event{constructor(t,f){super(t,{bubbles:!0,composed:!0,...f})}},a=document.body.hasAttribute("no-auto-reveal");window.PfeConfig=Object.assign(window.PfeConfig??{},{trackPerformance:window.PfeConfig?.trackPerformance??r("pfe-track-performance")==="true",autoReveal:window.PfeConfig?.autoReveal??(a?!a:r("pfe-auto-reveal")==="true"),get log(){return!!localStorage.pfeLog},set log(e){e?localStorage.setItem("pfeLog",`${!0}`):localStorage.removeItem("pfeLog")}});export{n as ComposedEvent,i as NumberListConverter,l as trackPerformance};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|
package/core.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["core.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ComplexAttributeConverter } from 'lit';\n\n/** PatternFly Elements global config object */\nexport interface PfeConfig {\n /** Set to false to disable client-side page load performance tracking */\n trackPerformance?: boolean;\n /** Set to false to disable various debug logs */\n log?: boolean;\n /** Set to false to disable automatically removing `unresolved` attr from body */\n autoReveal?: boolean;\n}\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import type { ComplexAttributeConverter } from 'lit';\n\nexport type { ColorPalette, ColorTheme } from './controllers/color-context.js';\n\n/** PatternFly Elements global config object */\nexport interface PfeConfig {\n /** Set to false to disable client-side page load performance tracking */\n trackPerformance?: boolean;\n /** Set to false to disable various debug logs */\n log?: boolean;\n /** Set to false to disable automatically removing `unresolved` attr from body */\n autoReveal?: boolean;\n}\n\nconst noPref = Symbol();\n\n/** Retrieve an HTML metadata item */\nfunction getMeta(name: string): string|undefined {\n return document.head.querySelector<HTMLMetaElement>(`meta[name=\"${name}\"]`)?.content;\n}\n\n/**\n * A boolean value that indicates if the performance should be tracked.\n * For use in a JS file or script tag; can also be added in the constructor of a component during development.\n * @example trackPerformance(true);\n */\nexport function trackPerformance(preference: boolean | typeof noPref = noPref) {\n if (preference !== noPref) {\n window.PfeConfig.trackPerformance = !!preference;\n }\n return window.PfeConfig.trackPerformance;\n}\n\n/**\n * A LitElement property converter which represents a list of numbers as a comma separated string\n * @see https://lit.dev/docs/components/properties/#conversion-converter\n */\nexport const NumberListConverter: ComplexAttributeConverter<null|number[]> = {\n fromAttribute(value: string) {\n if (typeof value !== 'string') {\n return null;\n } else {\n return value.split(',').map(x => x.trim()).map(x => parseInt(x, 10));\n }\n },\n toAttribute(value: number[]) {\n return value.join(',');\n },\n};\n\n/**\n * A composed, bubbling event for UI interactions\n * e.g. when an accordion panel opens.\n */\nexport class ComposedEvent extends Event {\n constructor(type: string, init?: EventInit) {\n super(type, {\n bubbles: true,\n composed: true,\n ...init\n });\n }\n}\n\n// \uD83D\uDC47 SIDE EFFECTS \uD83D\uDC47\n\ndeclare global {\n interface Window {\n /** Global configuration settings for PatternFly Elements */\n PfeConfig: PfeConfig;\n }\n}\n\nconst bodyNoAutoReveal = document.body.hasAttribute('no-auto-reveal');\n\n/** Global patternfly elements config */\nwindow.PfeConfig = Object.assign(window.PfeConfig ?? {}, {\n trackPerformance: window.PfeConfig?.trackPerformance ?? getMeta('pfe-track-performance') === 'true',\n // if the body tag has `no-auto-reveal` attribute, reveal immediately\n // if `<meta name=\"pfe-auto-reveal\">` exists, and it's `content` is 'true',\n // then auto-reveal the body\n autoReveal: window.PfeConfig?.autoReveal ?? (\n bodyNoAutoReveal ? !bodyNoAutoReveal\n : getMeta('pfe-auto-reveal') === 'true'\n ),\n get log() {\n return !!localStorage.pfeLog;\n },\n set log(v: boolean) {\n if (v) {\n localStorage.setItem('pfeLog', `${true}`);\n } else {\n localStorage.removeItem('pfeLog');\n }\n },\n});\n"],
|
|
5
|
+
"mappings": "AAcA,IAAMA,EAAS,OAAO,EAGtB,SAASC,EAAQC,EAAgC,CAC/C,OAAO,SAAS,KAAK,cAA+B,cAAcA,KAAQ,GAAG,OAC/E,CAOO,SAASC,EAAiBC,EAAsCJ,EAAQ,CAC7E,OAAII,IAAeJ,IACjB,OAAO,UAAU,iBAAmB,CAAC,CAACI,GAEjC,OAAO,UAAU,gBAC1B,CAMO,IAAMC,EAAgE,CAC3E,cAAcC,EAAe,CAC3B,OAAI,OAAOA,GAAU,SACZ,KAEAA,EAAM,MAAM,GAAG,EAAE,IAAIC,GAAKA,EAAE,KAAK,CAAC,EAAE,IAAIA,GAAK,SAASA,EAAG,EAAE,CAAC,CAEvE,EACA,YAAYD,EAAiB,CAC3B,OAAOA,EAAM,KAAK,GAAG,CACvB,CACF,EAMaE,EAAN,cAA4B,KAAM,CACvC,YAAYC,EAAcC,EAAkB,CAC1C,MAAMD,EAAM,CACV,QAAS,GACT,SAAU,GACV,GAAGC,CACL,CAAC,CACH,CACF,EAWMC,EAAmB,SAAS,KAAK,aAAa,gBAAgB,EAGpE,OAAO,UAAY,OAAO,OAAO,OAAO,WAAa,CAAC,EAAG,CACvD,iBAAkB,OAAO,WAAW,kBAAoBV,EAAQ,uBAAuB,IAAM,OAI7F,WAAY,OAAO,WAAW,aAC1BU,EAAmB,CAACA,EACpBV,EAAQ,iBAAiB,IAAM,QAEnC,IAAI,KAAM,CACR,MAAO,CAAC,CAAC,aAAa,MACxB,EACA,IAAI,IAAIW,EAAY,CACdA,EACF,aAAa,QAAQ,SAAU,GAAG,IAAM,EAExC,aAAa,WAAW,QAAQ,CAEpC,CACF,CAAC",
|
|
6
|
+
"names": ["noPref", "getMeta", "name", "trackPerformance", "preference", "NumberListConverter", "value", "x", "ComposedEvent", "type", "init", "bodyNoAutoReveal", "v"]
|
|
7
7
|
}
|
package/decorators/bound.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["bound.ts"],
|
|
4
4
|
"sourcesContent": ["const configurable = true;\n\n/**\n * Binds a class method to the instance\n *\n * @example Binding an event listener\n * ```ts\n * private mo = new MutationObserver(this.onMutation);\n *\n * @bound onMutation(records: MutationRecord[]) {\n * this.count = this.children.length;\n * }\n * ```\n */\nexport function bound(_: unknown, key: string, descriptor: PropertyDescriptor): PropertyDescriptor {\n if (typeof descriptor?.value !== 'function') {\n throw new TypeError(`Only methods can be decorated with @bound. <${key ?? (_ as () => void).name}> is not a method!`);\n } /* c8 ignore next */\n return {\n configurable,\n get() {\n const value = descriptor.value.bind(this);\n Object.defineProperty(this, key, { value, configurable, writable: true });\n return value;\n },\n };\n}\n"],
|
|
5
|
-
"mappings": "AAcO,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAcO,SAASA,EAAMC,EAAYC,EAAaC,EAAoD,CACjG,GAAI,OAAOA,GAAY,OAAU,WAC/B,MAAM,IAAI,UAAU,+CAA+CD,GAAQD,EAAiB,wBAAwB,EAEtH,MAAO,CACL,gBACA,KAAM,CACJ,IAAMG,EAAQD,EAAW,MAAM,KAAK,IAAI,EACxC,cAAO,eAAe,KAAMD,EAAK,CAAE,MAAAE,EAAO,gBAAc,SAAU,EAAK,CAAC,EACjEA,CACT,CACF,CACF",
|
|
6
|
+
"names": ["bound", "_", "key", "descriptor", "value"]
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["cascades.ts"],
|
|
4
4
|
"sourcesContent": ["import type { ReactiveElement } from 'lit';\n\nimport { CascadeController } from '../controllers/cascade-controller.js';\n\n/**\n * Cascades the decorated attribute to children\n */\nexport function cascades<T extends ReactiveElement>(...items: string[]): PropertyDecorator {\n return function(proto: T, key: string & keyof T) {\n (proto.constructor as typeof ReactiveElement).addInitializer(x => {\n const instance = x as ReactiveElement;\n // You can have multiple `@cascades` decorators on an element\n // and it will only get one CascadeController for all of them\n if (!CascadeController.instances.has(instance)) {\n CascadeController.instances.set(instance, new CascadeController(instance));\n }\n\n CascadeController.instances.get(instance)?.initProp(key, items);\n });\n } as PropertyDecorator;\n}\n"],
|
|
5
|
-
"mappings": "AAEA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAEA,OAAS,qBAAAA,MAAyB,uCAK3B,SAASC,KAAuCC,EAAoC,CACzF,OAAO,SAASC,EAAUC,EAAuB,CAC9CD,EAAM,YAAuC,eAAeE,GAAK,CAChE,IAAMC,EAAWD,EAGZL,EAAkB,UAAU,IAAIM,CAAQ,GAC3CN,EAAkB,UAAU,IAAIM,EAAU,IAAIN,EAAkBM,CAAQ,CAAC,EAG3EN,EAAkB,UAAU,IAAIM,CAAQ,GAAG,SAASF,EAAKF,CAAK,CAChE,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["CascadeController", "cascades", "items", "proto", "key", "x", "instance"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ReactiveElement } from 'lit';
|
|
2
|
+
import type { ColorContextOptions } from '../controllers/color-context.js';
|
|
3
|
+
export declare function colorContextProvider<T extends ReactiveElement>(options?: ColorContextOptions): (proto: T, _key: string) => void;
|
|
4
|
+
export declare function colorContextConsumer<T extends ReactiveElement>(options?: ColorContextOptions): (proto: T, _key: string) => void;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ColorContextConsumer as n,ColorContextProvider as i}from"../controllers/color-context.js";function c(t){return function(e,r){e.constructor.addInitializer(o=>{o.__colorContextProvider=new i(o,t)})}}function C(t){return function(e,r){e.constructor.addInitializer(o=>{o.__colorContextConsumer=new n(o,t)})}}export{C as colorContextConsumer,c as colorContextProvider};
|
|
2
|
+
//# sourceMappingURL=color-context.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["color-context.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ReactiveElement } from 'lit';\nimport type { ColorContextOptions } from '../controllers/color-context.js';\n\nimport { ColorContextConsumer, ColorContextProvider } from '../controllers/color-context.js';\n\nexport function colorContextProvider<T extends ReactiveElement>(options?: ColorContextOptions) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return function(proto: T, _key: string) {\n (proto.constructor as typeof ReactiveElement).addInitializer(instance => {\n // @ts-expect-error: this is strictly for debugging purposes\n instance.__colorContextProvider =\n new ColorContextProvider(instance, options);\n });\n };\n}\n\nexport function colorContextConsumer<T extends ReactiveElement>(options?: ColorContextOptions) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return function(proto: T, _key: string) {\n (proto.constructor as typeof ReactiveElement).addInitializer(instance => {\n // @ts-expect-error: this is strictly for debugging purposes\n instance.__colorContextConsumer =\n new ColorContextConsumer(instance, options);\n });\n };\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,wBAAAA,EAAsB,wBAAAC,MAA4B,kCAEpD,SAASC,EAAgDC,EAA+B,CAE7F,OAAO,SAASC,EAAUC,EAAc,CACrCD,EAAM,YAAuC,eAAeE,GAAY,CAEvEA,EAAS,uBACP,IAAIL,EAAqBK,EAAUH,CAAO,CAC9C,CAAC,CACH,CACF,CAEO,SAASI,EAAgDJ,EAA+B,CAE7F,OAAO,SAASC,EAAUC,EAAc,CACrCD,EAAM,YAAuC,eAAeE,GAAY,CAEvEA,EAAS,uBACP,IAAIN,EAAqBM,EAAUH,CAAO,CAC9C,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["ColorContextConsumer", "ColorContextProvider", "colorContextProvider", "options", "proto", "_key", "instance", "colorContextConsumer"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactiveElement, PropertyDeclaration } from 'lit';
|
|
2
|
+
export declare type DeprecationDeclaration<K extends PropertyKey> = PropertyDeclaration & {
|
|
3
|
+
alias: string & K;
|
|
4
|
+
attribute: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Aliases the decorated field to an existing property, and logs a warning if it is used
|
|
8
|
+
* @example deprecating an attribute
|
|
9
|
+
* ```ts
|
|
10
|
+
* @property({ reflect: true, attribute: 'color-palette'})
|
|
11
|
+
* colorPalette: ColorPalette = 'base';
|
|
12
|
+
*
|
|
13
|
+
* @deprecation('colorPalette') color?: ColorPalette;
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function deprecation<K extends PropertyKey>(options: DeprecationDeclaration<K>): <T extends ReactiveElement, L extends PropertyKey>(proto: Partial<Record<K | L, T>>, key: string & keyof T) => void;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Logger as p}from"../controllers/logger.js";function d(r){return function(e,t){let{alias:a,...n}=r,o=e.constructor,l=o.getPropertyOptions(a);o.createProperty(t,{...l,...n}),o.addInitializer(s=>{s.addController(new i(s,r,t))})}}var i=class{constructor(e,t,a){this.host=e;this.options=t;this.deprecatedKey=a;this.logged=!1;this.logger=new p(e)}hostUpdate(){let{deprecatedKey:e,options:{alias:t}}=this;this.host[e]&&this.host[t]!==this.host[e]&&(this.logged||(this.logger.warn(`${e} is deprecated, use ${t} instead`),this.logged=!0),this.host[t]=this.host[e])}};export{d as deprecation};
|
|
2
|
+
//# sourceMappingURL=deprecation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["deprecation.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ReactiveElement, PropertyDeclaration, ReactiveController } from 'lit';\n\nimport { Logger } from '../controllers/logger.js';\n\nexport type DeprecationDeclaration<K extends PropertyKey> = PropertyDeclaration & {\n alias: string & K;\n attribute: string;\n}\n\n/**\n * Aliases the decorated field to an existing property, and logs a warning if it is used\n * @example deprecating an attribute\n * ```ts\n * @property({ reflect: true, attribute: 'color-palette'})\n * colorPalette: ColorPalette = 'base';\n *\n * @deprecation('colorPalette') color?: ColorPalette;\n * ```\n */\nexport function deprecation<K extends PropertyKey>(options: DeprecationDeclaration<K>) {\n return function<T extends ReactiveElement, L extends PropertyKey>(\n proto: Partial<Record<K | L, T>>,\n key: string & keyof T\n ) {\n const { alias, ...deprecationOptions } = options;\n const klass = (proto.constructor as typeof ReactiveElement);\n const declaration = klass.getPropertyOptions(alias);\n klass.createProperty(key, { ...declaration, ...deprecationOptions });\n klass.addInitializer(instance => {\n instance.addController(new Deprecation(instance as T, options, key));\n });\n };\n}\n\nclass Deprecation<T extends ReactiveElement, K extends PropertyKey> implements ReactiveController {\n private logger: Logger;\n\n private logged = false;\n\n constructor(\n private host: T,\n private options: DeprecationDeclaration<K>,\n private deprecatedKey: string & keyof T\n ) {\n this.logger = new Logger(host);\n }\n\n hostUpdate() {\n const { deprecatedKey, options: { alias } } = this;\n if (this.host[deprecatedKey]) {\n if (this.host[alias as keyof T] !== this.host[deprecatedKey]) {\n if (!this.logged) {\n this.logger.warn(`${deprecatedKey} is deprecated, use ${alias} instead`);\n this.logged = true;\n }\n this.host[alias as keyof T] = this.host[deprecatedKey];\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAEA,OAAS,UAAAA,MAAc,2BAiBhB,SAASC,EAAmCC,EAAoC,CACrF,OAAO,SACLC,EACAC,EACA,CACA,GAAM,CAAE,MAAAC,KAAUC,CAAmB,EAAIJ,EACnCK,EAASJ,EAAM,YACfK,EAAcD,EAAM,mBAAmBF,CAAK,EAClDE,EAAM,eAAeH,EAAK,CAAE,GAAGI,EAAa,GAAGF,CAAmB,CAAC,EACnEC,EAAM,eAAeE,GAAY,CAC/BA,EAAS,cAAc,IAAIC,EAAYD,EAAeP,EAASE,CAAG,CAAC,CACrE,CAAC,CACH,CACF,CAEA,IAAMM,EAAN,KAAkG,CAKhG,YACUC,EACAT,EACAU,EACR,CAHQ,UAAAD,EACA,aAAAT,EACA,mBAAAU,EALV,KAAQ,OAAS,GAOf,KAAK,OAAS,IAAIZ,EAAOW,CAAI,CAC/B,CAEA,YAAa,CACX,GAAM,CAAE,cAAAC,EAAe,QAAS,CAAE,MAAAP,CAAM,CAAE,EAAI,KAC1C,KAAK,KAAKO,IACR,KAAK,KAAKP,KAAsB,KAAK,KAAKO,KACvC,KAAK,SACR,KAAK,OAAO,KAAK,GAAGA,wBAAoCP,WAAe,EACvE,KAAK,OAAS,IAEhB,KAAK,KAAKA,GAAoB,KAAK,KAAKO,GAG9C,CACF",
|
|
6
|
+
"names": ["Logger", "deprecation", "options", "proto", "key", "alias", "deprecationOptions", "klass", "declaration", "instance", "Deprecation", "host", "deprecatedKey"]
|
|
7
|
+
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["initializer.ts"],
|
|
4
4
|
"sourcesContent": ["import type { ReactiveElement } from 'lit';\nimport type { Options } from '../controllers/light-dom-controller.js';\n\nimport { LightDOMController } from '../controllers/light-dom-controller.js';\n\n/**\n * Runs the decorated method in `connectedCallback`,\n * provided the element has light children, and sets\n * up a mutation observer to re-run the callback,\n * unless opted-out with `{ observe: false }`\n * @param options Set `observe` to `false` to skip mutation observer setup, or pass a MutationObserverInit as options\n */\nexport function initializer<T extends ReactiveElement>(options?: Options) {\n return function(proto: T, key: string) {\n // @TODO: allow multiple initializers\n (proto.constructor as typeof ReactiveElement).addInitializer(instance => {\n const initializer = proto[key as keyof T] as unknown as () => void;\n const controller = new LightDOMController(instance as ReactiveElement, initializer, options);\n if (instance.isConnected) {\n controller.hostConnected();\n }\n });\n };\n}\n"],
|
|
5
|
-
"mappings": "AAGA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAGA,OAAS,sBAAAA,MAA0B,yCAS5B,SAASC,EAAuCC,EAAmB,CACxE,OAAO,SAASC,EAAUC,EAAa,CAEpCD,EAAM,YAAuC,eAAeE,GAAY,CACvE,IAAMJ,EAAcE,EAAMC,GACpBE,EAAa,IAAIN,EAAmBK,EAA6BJ,EAAaC,CAAO,EACvFG,EAAS,aACXC,EAAW,cAAc,CAE7B,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["LightDOMController", "initializer", "options", "proto", "key", "instance", "controller"]
|
|
7
7
|
}
|
package/decorators/observed.d.ts
CHANGED
|
@@ -29,5 +29,5 @@ declare type TypedFieldDecorator<T> = (proto: T, key: string | keyof T) => void;
|
|
|
29
29
|
export declare function observed<T extends ReactiveElement>(methodName: string): TypedFieldDecorator<T>;
|
|
30
30
|
export declare function observed<T extends ReactiveElement>(cb: ChangeCallback<T>): TypedFieldDecorator<T>;
|
|
31
31
|
export declare function observed<T extends ReactiveElement>(proto: T, key: string): void;
|
|
32
|
-
export declare function observeProperty<T extends ReactiveElement>(proto: T, key: string
|
|
32
|
+
export declare function observeProperty<T extends ReactiveElement>(proto: T, key: string & keyof T, callbackOrMethod?: ChangeCallback<T>): void;
|
|
33
33
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["observed.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReactiveElement } from 'lit';\nimport type {\n ChangeCallback,\n ChangeCallbackName,\n PropertyObserverHost,\n} from '../controllers/property-observer-controller.js';\n\nimport {\n observedController,\n PropertyObserverController,\n} from '../controllers/property-observer-controller.js';\n\ntype TypedFieldDecorator<T> = (proto: T, key: string | keyof T) => void ;\n\n/**\n * Calls a _fooChanged method on the instance when the value changes.\n * Works on any class field. When using on lit observed properties,\n * Make sure `@observed` is to the left (i.e. called after) the `@property`\n * or `@state` decorator.\n *\n * @example observing a lit property\n * ```ts\n * @observed @property() foo = 'bar';\n *\n * protected _fooChanged(oldValue?: string, newValue?: string) {}\n * ```\n *\n * @example using a custom callback\n * ```ts\n * @observed('_myCallback') size = 'lg';\n *\n * _myCallback(_, size) {...}\n * ```\n *\n * @example using an arrow function\n * ```ts\n * @observed((oldVal, newVal) => console.log(`Size changed from ${oldVal} to ${newVal}`))\n * ```\n */\nexport function observed<T extends ReactiveElement>(methodName: string): TypedFieldDecorator<T>\nexport function observed<T extends ReactiveElement>(cb: ChangeCallback<T>): TypedFieldDecorator<T>\nexport function observed<T extends ReactiveElement>(proto: T, key: string): void\nexport function observed<T extends ReactiveElement>(...as: any[]): void|TypedFieldDecorator<T> {\n /** @observed('_myCustomChangeCallback') */\n if (as.length === 1) {\n const [methodNameOrCallback] = as;\n return function(proto, key) {\n (proto.constructor as typeof ReactiveElement)\n .addInitializer(x => new PropertyObserverController(x));\n observeProperty(proto, key, methodNameOrCallback);\n };\n } else {\n const [proto, key] = as;\n (proto.constructor as typeof ReactiveElement)\n .addInitializer(x => new PropertyObserverController(x));\n observeProperty(proto, key);\n }\n}\n\nexport function observeProperty<T extends ReactiveElement>(\n proto: T,\n key: string
|
|
5
|
-
"mappings": "AAOA,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import type { ReactiveElement } from 'lit';\nimport type {\n ChangeCallback,\n ChangeCallbackName,\n PropertyObserverHost,\n} from '../controllers/property-observer-controller.js';\n\nimport {\n observedController,\n PropertyObserverController,\n} from '../controllers/property-observer-controller.js';\n\ntype TypedFieldDecorator<T> = (proto: T, key: string | keyof T) => void ;\n\n/**\n * Calls a _fooChanged method on the instance when the value changes.\n * Works on any class field. When using on lit observed properties,\n * Make sure `@observed` is to the left (i.e. called after) the `@property`\n * or `@state` decorator.\n *\n * @example observing a lit property\n * ```ts\n * @observed @property() foo = 'bar';\n *\n * protected _fooChanged(oldValue?: string, newValue?: string) {}\n * ```\n *\n * @example using a custom callback\n * ```ts\n * @observed('_myCallback') size = 'lg';\n *\n * _myCallback(_, size) {...}\n * ```\n *\n * @example using an arrow function\n * ```ts\n * @observed((oldVal, newVal) => console.log(`Size changed from ${oldVal} to ${newVal}`))\n * ```\n */\nexport function observed<T extends ReactiveElement>(methodName: string): TypedFieldDecorator<T>\nexport function observed<T extends ReactiveElement>(cb: ChangeCallback<T>): TypedFieldDecorator<T>\nexport function observed<T extends ReactiveElement>(proto: T, key: string): void\nexport function observed<T extends ReactiveElement>(...as: any[]): void|TypedFieldDecorator<T> {\n /** @observed('_myCustomChangeCallback') */\n if (as.length === 1) {\n const [methodNameOrCallback] = as;\n return function(proto, key) {\n (proto.constructor as typeof ReactiveElement)\n .addInitializer(x => new PropertyObserverController(x));\n observeProperty(proto, key as string & keyof T, methodNameOrCallback);\n };\n } else {\n const [proto, key] = as;\n (proto.constructor as typeof ReactiveElement)\n .addInitializer(x => new PropertyObserverController(x));\n observeProperty(proto, key);\n }\n}\n\nexport function observeProperty<T extends ReactiveElement>(\n proto: T,\n key: string & keyof T,\n callbackOrMethod?: ChangeCallback<T>\n) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, key);\n Object.defineProperty(proto, key, {\n ...descriptor,\n configurable: true,\n set(this: PropertyObserverHost<T>, newVal: T[keyof T]) {\n const oldVal = this[key as keyof T];\n // first, call any pre-existing setters, e.g. `@property`\n descriptor?.set?.call(this, newVal);\n\n // if the user passed a callback, call it\n // e.g. `@observed((_, newVal) => console.log(newVal))`\n // safe to call before connectedCallback, because it's impossible to get a `this` ref.\n if (typeof callbackOrMethod === 'function') {\n callbackOrMethod.call(this, oldVal, newVal);\n } else {\n // if the user passed a string method name, call it on `this`\n // e.g. `@observed('_renderOptions')`\n // otherwise, use a default method name e.g. `_fooChanged`\n const actualMethodName = callbackOrMethod || `_${key}Changed`;\n\n // if the component has already connected to the DOM, run the callback\n // otherwise, If the component has not yet connected to the DOM,\n // cache the old and new values. See PropertyObserverController above\n if (this.hasUpdated) {\n this[actualMethodName as ChangeCallbackName]?.(oldVal, newVal);\n } else {\n this[observedController].cache(key as string, actualMethodName, oldVal, newVal);\n }\n }\n },\n });\n}\n"],
|
|
5
|
+
"mappings": "AAOA,OACE,sBAAAA,EACA,8BAAAC,MACK,iDAgCA,SAASC,KAAuCC,EAAwC,CAE7F,GAAIA,EAAG,SAAW,EAAG,CACnB,GAAM,CAACC,CAAoB,EAAID,EAC/B,OAAO,SAASE,EAAOC,EAAK,CACzBD,EAAM,YACJ,eAAeE,GAAK,IAAIN,EAA2BM,CAAC,CAAC,EACxDC,EAAgBH,EAAOC,EAAyBF,CAAoB,CACtE,CACF,KAAO,CACL,GAAM,CAACC,EAAOC,CAAG,EAAIH,EACpBE,EAAM,YACJ,eAAeE,GAAK,IAAIN,EAA2BM,CAAC,CAAC,EACxDC,EAAgBH,EAAOC,CAAG,CAC5B,CACF,CAEO,SAASE,EACdH,EACAC,EACAG,EACA,CACA,IAAMC,EAAa,OAAO,yBAAyBL,EAAOC,CAAG,EAC7D,OAAO,eAAeD,EAAOC,EAAK,CAChC,GAAGI,EACH,aAAc,GACd,IAAmCC,EAAoB,CACrD,IAAMC,EAAS,KAAKN,GAOpB,GALAI,GAAY,KAAK,KAAK,KAAMC,CAAM,EAK9B,OAAOF,GAAqB,WAC9BA,EAAiB,KAAK,KAAMG,EAAQD,CAAM,MACrC,CAIL,IAAME,EAAmBJ,GAAoB,IAAIH,WAK7C,KAAK,WACP,KAAKO,KAA0CD,EAAQD,CAAM,EAE7D,KAAKX,GAAoB,MAAMM,EAAeO,EAAkBD,EAAQD,CAAM,CAElF,CACF,CACF,CAAC,CACH",
|
|
6
|
+
"names": ["observedController", "PropertyObserverController", "observed", "as", "methodNameOrCallback", "proto", "key", "x", "observeProperty", "callbackOrMethod", "descriptor", "newVal", "oldVal", "actualMethodName"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export interface PfelementOptions {
|
|
2
|
+
className: string;
|
|
3
|
+
attribute: string;
|
|
4
|
+
}
|
|
1
5
|
/**
|
|
2
6
|
* Adds pfelement APIs to the decorated custom-element class
|
|
3
7
|
* 1. Adds readonly `version` field to the element constructor (class)
|
|
4
8
|
* 2. Adds `[pfelement]` attr and `.PFElement` class in connectedCallback
|
|
5
9
|
*/
|
|
6
|
-
export declare function pfelement(): ClassDecorator;
|
|
10
|
+
export declare function pfelement(options?: PfelementOptions): ClassDecorator;
|
package/decorators/pfelement.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{trackPerformance as
|
|
1
|
+
import{trackPerformance as l}from"../core.js";import{PerfController as s}from"../controllers/perf-controller.js";function m(e){return typeof e.addInitializer=="function"}var a=!1,i=new Set;async function f(e){if(i.add(e),!a){for(a=!0;i.size;){let n=[];for(let o of i)n.push(o.updateComplete),i.delete(o);await Promise.all(n)}document.body.removeAttribute("unresolved")}}function d(e){let n=e?.attribute??"pfelement",o=e?.className??"PFElement";return function(r){if(!m(r))throw new Error(`@pfelement may only decorate ReactiveElements. ${r.name} is does not implement ReactiveElement.`);r.addInitializer(t=>{window.PfeConfig.autoReveal&&f(t),t.addController({hostConnected(){t.setAttribute(n,""),t.classList.add(o)}}),l()&&new s(t)})}}export{d as pfelement};
|
|
2
2
|
//# sourceMappingURL=pfelement.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["pfelement.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReactiveElement } from 'lit';\n\nimport { trackPerformance } from '../core.js';\n\nimport {
|
|
5
|
-
"mappings": "AAEA,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import type { ReactiveElement } from 'lit';\n\nimport { trackPerformance } from '../core.js';\n\nimport { PerfController } from '../controllers/perf-controller.js';\n\nexport interface PfelementOptions {\n className: string;\n attribute: string;\n}\n\nfunction isReactiveElementClass(\n klass: Function // eslint-disable-line @typescript-eslint/ban-types\n): klass is typeof ReactiveElement {\n return typeof klass['addInitializer' as keyof typeof klass] === 'function';\n}\n\nlet waiting = false;\nconst queue = new Set<ReactiveElement>();\n\nasync function enqueue(instance: ReactiveElement) {\n queue.add(instance);\n\n // only the first call kicks off the 'timer'\n // but because of the while loop, subsequent calls will still cause an `await`\n if (!waiting) {\n waiting = true;\n while (queue.size) {\n const enqueued: Promise<boolean>[] = [];\n for (const instance of queue) {\n enqueued.push(instance.updateComplete);\n queue.delete(instance);\n }\n await Promise.all(enqueued);\n }\n document.body.removeAttribute('unresolved');\n }\n}\n\n/**\n * Adds pfelement APIs to the decorated custom-element class\n * 1. Adds readonly `version` field to the element constructor (class)\n * 2. Adds `[pfelement]` attr and `.PFElement` class in connectedCallback\n */\nexport function pfelement(options?: PfelementOptions): ClassDecorator {\n const attribute = options?.attribute ?? 'pfelement';\n const className = options?.className ?? 'PFElement';\n return function(klass) {\n if (!isReactiveElementClass(klass)) {\n throw new Error(`@pfelement may only decorate ReactiveElements. ${klass.name} is does not implement ReactiveElement.`);\n }\n\n klass.addInitializer(instance => {\n if (window.PfeConfig.autoReveal) {\n enqueue(instance);\n }\n\n // Set some global host DOM when it connects\n // by way of an ad-hoc controller\n instance.addController({\n hostConnected() {\n instance.setAttribute(attribute, '');\n instance.classList.add(className);\n },\n });\n\n if (trackPerformance()) {\n new PerfController(instance);\n }\n });\n };\n}\n"],
|
|
5
|
+
"mappings": "AAEA,OAAS,oBAAAA,MAAwB,aAEjC,OAAS,kBAAAC,MAAsB,oCAO/B,SAASC,EACPC,EACiC,CACjC,OAAO,OAAOA,EAAM,gBAA4C,UAClE,CAEA,IAAIC,EAAU,GACRC,EAAQ,IAAI,IAElB,eAAeC,EAAQC,EAA2B,CAKhD,GAJAF,EAAM,IAAIE,CAAQ,EAId,CAACH,EAAS,CAEZ,IADAA,EAAU,GACHC,EAAM,MAAM,CACjB,IAAMG,EAA+B,CAAC,EACtC,QAAWD,KAAYF,EACrBG,EAAS,KAAKD,EAAS,cAAc,EACrCF,EAAM,OAAOE,CAAQ,EAEvB,MAAM,QAAQ,IAAIC,CAAQ,CAC5B,CACA,SAAS,KAAK,gBAAgB,YAAY,CAC5C,CACF,CAOO,SAASC,EAAUC,EAA4C,CACpE,IAAMC,EAAYD,GAAS,WAAa,YAClCE,EAAYF,GAAS,WAAa,YACxC,OAAO,SAASP,EAAO,CACrB,GAAI,CAACD,EAAuBC,CAAK,EAC/B,MAAM,IAAI,MAAM,kDAAkDA,EAAM,6CAA6C,EAGvHA,EAAM,eAAeI,GAAY,CAC3B,OAAO,UAAU,YACnBD,EAAQC,CAAQ,EAKlBA,EAAS,cAAc,CACrB,eAAgB,CACdA,EAAS,aAAaI,EAAW,EAAE,EACnCJ,EAAS,UAAU,IAAIK,CAAS,CAClC,CACF,CAAC,EAEGZ,EAAiB,GACnB,IAAIC,EAAeM,CAAQ,CAE/B,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["trackPerformance", "PerfController", "isReactiveElementClass", "klass", "waiting", "queue", "enqueue", "instance", "enqueued", "pfelement", "options", "attribute", "className"]
|
|
7
7
|
}
|
package/decorators/time.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["time.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * Tracks the time a method takes to complete using the [performance API](https://developer.mozilla.org/en-US/docs/Web/API/Performance)\n */\nexport function time(tag?: string) {\n return function(_: unknown, key: string, descriptor: PropertyDescriptor) {\n const { value: f } = descriptor ?? {};\n\n if (!(typeof f === 'function')) {\n throw new Error('@time() may only decorate class methods');\n }\n\n descriptor.value = function(...args: any[]) {\n const TAG = tag ?? `${this.constructor.name}-${key}`;\n const START_TAG = `start-${TAG}`;\n const END_TAG = `end-${TAG}`;\n\n if (window.PfeConfig.trackPerformance) {\n performance.mark(START_TAG);\n }\n\n const x = f.call(this, ...args);\n\n const ret = () => {\n if (window.PfeConfig.trackPerformance) {\n performance.mark(END_TAG);\n performance.measure(TAG, START_TAG, END_TAG);\n // eslint-disable-next-line no-console\n console.log(Array.from(performance.getEntriesByName(TAG)).pop());\n }\n return x;\n };\n\n if (x instanceof Promise) {\n return x.then(ret);\n } else {\n return ret();\n }\n };\n };\n}\n"],
|
|
5
|
-
"mappings": "AAGO,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAGO,SAASA,EAAKC,EAAc,CACjC,OAAO,SAASC,EAAYC,EAAaC,EAAgC,CACvE,GAAM,CAAE,MAAOC,CAAE,EAAID,GAAc,CAAC,EAEpC,GAAM,OAAOC,GAAM,WACjB,MAAM,IAAI,MAAM,yCAAyC,EAG3DD,EAAW,MAAQ,YAAYE,EAAa,CAC1C,IAAMC,EAAMN,GAAO,GAAG,KAAK,YAAY,QAAQE,IACzCK,EAAY,SAASD,IACrBE,EAAU,OAAOF,IAEnB,OAAO,UAAU,kBACnB,YAAY,KAAKC,CAAS,EAG5B,IAAME,EAAIL,EAAE,KAAK,KAAM,GAAGC,CAAI,EAExBK,EAAM,KACN,OAAO,UAAU,mBACnB,YAAY,KAAKF,CAAO,EACxB,YAAY,QAAQF,EAAKC,EAAWC,CAAO,EAE3C,QAAQ,IAAI,MAAM,KAAK,YAAY,iBAAiBF,CAAG,CAAC,EAAE,IAAI,CAAC,GAE1DG,GAGT,OAAIA,aAAa,QACRA,EAAE,KAAKC,CAAG,EAEVA,EAAI,CAEf,CACF,CACF",
|
|
6
|
+
"names": ["time", "tag", "_", "key", "descriptor", "f", "args", "TAG", "START_TAG", "END_TAG", "x", "ret"]
|
|
7
7
|
}
|
package/decorators/trace.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["trace.ts"],
|
|
4
4
|
"sourcesContent": ["/** Logs the result of a class method */\nexport function trace(tag?: string) {\n return function(_: unknown, key: string, descriptor: PropertyDescriptor) {\n const { value: f } = descriptor;\n descriptor.value = function(...args: any[]) {\n const x = f.call(this, ...args);\n\n const ret = () => {\n // eslint-disable-next-line no-console\n console.log(tag ?? key, x);\n return x;\n };\n\n if (x instanceof Promise) {\n return x.then(ret);\n } else {\n return ret();\n }\n };\n };\n}\n"],
|
|
5
|
-
"mappings": "AACO,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AACO,SAASA,EAAMC,EAAc,CAClC,OAAO,SAASC,EAAYC,EAAaC,EAAgC,CACvE,GAAM,CAAE,MAAOC,CAAE,EAAID,EACrBA,EAAW,MAAQ,YAAYE,EAAa,CAC1C,IAAMC,EAAIF,EAAE,KAAK,KAAM,GAAGC,CAAI,EAExBE,EAAM,KAEV,QAAQ,IAAIP,GAAOE,EAAKI,CAAC,EAClBA,GAGT,OAAIA,aAAa,QACRA,EAAE,KAAKC,CAAG,EAEVA,EAAI,CAEf,CACF,CACF",
|
|
6
|
+
"names": ["trace", "tag", "_", "key", "descriptor", "f", "args", "x", "ret"]
|
|
7
7
|
}
|
package/decorators.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './decorators/bound.js';
|
|
2
2
|
export * from './decorators/cascades.js';
|
|
3
|
+
export * from './decorators/color-context.js';
|
|
4
|
+
export * from './decorators/deprecation.js';
|
|
3
5
|
export * from './decorators/initializer.js';
|
|
4
6
|
export * from './decorators/observed.js';
|
|
5
7
|
export * from './decorators/pfelement.js';
|
package/decorators.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./decorators/bound.js";export*from"./decorators/cascades.js";export*from"./decorators/initializer.js";export*from"./decorators/observed.js";export*from"./decorators/pfelement.js";export*from"./decorators/time.js";export*from"./decorators/trace.js";
|
|
1
|
+
export*from"./decorators/bound.js";export*from"./decorators/cascades.js";export*from"./decorators/color-context.js";export*from"./decorators/deprecation.js";export*from"./decorators/initializer.js";export*from"./decorators/observed.js";export*from"./decorators/pfelement.js";export*from"./decorators/time.js";export*from"./decorators/trace.js";
|
|
2
2
|
//# sourceMappingURL=decorators.js.map
|
package/decorators.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["decorators.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './decorators/bound.js';\nexport * from './decorators/cascades.js';\nexport * from './decorators/initializer.js';\nexport * from './decorators/observed.js';\nexport * from './decorators/pfelement.js';\nexport * from './decorators/time.js';\nexport * from './decorators/trace.js';\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["export * from './decorators/bound.js';\nexport * from './decorators/cascades.js';\nexport * from './decorators/color-context.js';\nexport * from './decorators/deprecation.js';\nexport * from './decorators/initializer.js';\nexport * from './decorators/observed.js';\nexport * from './decorators/pfelement.js';\nexport * from './decorators/time.js';\nexport * from './decorators/trace.js';\n"],
|
|
5
|
+
"mappings": "AAAA,WAAc,wBACd,WAAc,2BACd,WAAc,gCACd,WAAc,8BACd,WAAc,8BACd,WAAc,2BACd,WAAc,4BACd,WAAc,uBACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["debounce.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * Debounce helper function\n * @see https://davidwalsh.name/javascript-debounce-function\n *\n * @param func Function to be debounced\n * @param delay How long until it will be run\n * @param immediate Whether it should be run at the start instead of the end of the debounce\n */\nexport function debounce(\n func: (...args: any[]) => unknown,\n delay: number,\n immediate = false\n) {\n let timeout: number|null;\n return function(this: unknown, ...args: any[]) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const context = this;\n const later = function() {\n timeout = null;\n if (!immediate) {\n func.apply(context, args);\n }\n };\n const callNow = immediate && !timeout;\n clearTimeout(timeout as number);\n timeout = window.setTimeout(later, delay);\n if (callNow) {\n func.apply(context, args);\n }\n };\n}\n"],
|
|
5
|
-
"mappings": "AAQO,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAQO,SAASA,EACdC,EACAC,EACAC,EAAY,GACZ,CACA,IAAIC,EACJ,OAAO,YAA2BC,EAAa,CAE7C,IAAMC,EAAU,KACVC,EAAQ,UAAW,CACvBH,EAAU,KACLD,GACHF,EAAK,MAAMK,EAASD,CAAI,CAE5B,EACMG,EAAUL,GAAa,CAACC,EAC9B,aAAaA,CAAiB,EAC9BA,EAAU,OAAO,WAAWG,EAAOL,CAAK,EACpCM,GACFP,EAAK,MAAMK,EAASD,CAAI,CAE5B,CACF",
|
|
6
|
+
"names": ["debounce", "func", "delay", "immediate", "timeout", "args", "context", "later", "callNow"]
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["deprecatedCustomEvent.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * Construct a CustomEvent with the given name and detail.\n * The event bubbles and is composed.\n */\nexport function deprecatedCustomEvent<T>(name: string, detail?: T): CustomEvent<T> {\n return new CustomEvent(name, {\n bubbles: true,\n composed: true,\n detail,\n });\n}\n"],
|
|
5
|
-
"mappings": "AAIO,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAIO,SAASA,EAAyBC,EAAcC,EAA4B,CACjF,OAAO,IAAI,YAAYD,EAAM,CAC3B,QAAS,GACT,SAAU,GACV,OAAAC,CACF,CAAC,CACH",
|
|
6
|
+
"names": ["deprecatedCustomEvent", "name", "detail"]
|
|
7
7
|
}
|
package/functions/random.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["random.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * A quick way to fetch a random ID value.\n * _Note:_ All values are prefixed automatically to ensure an ID-safe value is returned.\n * @param prefix id-safe string prefix\n */\nexport function getRandomId(prefix = 'pfe') {\n return `${prefix}-${Math.random().toString(36).substr(2, 9)}`;\n}\n"],
|
|
5
|
-
"mappings": "AAKO,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAKO,SAASA,EAAYC,EAAS,MAAO,CAC1C,MAAO,GAAGA,KAAU,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,OAAO,EAAG,CAAC,GAC5D",
|
|
6
|
+
"names": ["getRandomId", "prefix"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/pfe-core",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "PatternFly Elements Core Library",
|
|
6
6
|
"customElements": "custom-elements.json",
|
|
@@ -9,30 +9,32 @@
|
|
|
9
9
|
"module": "./core.js",
|
|
10
10
|
"types": "./core.d.ts",
|
|
11
11
|
"exports": {
|
|
12
|
-
".":
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"./controllers
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"./
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"./
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"./
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
12
|
+
".": "./core.js",
|
|
13
|
+
"./core.js": "./core.js",
|
|
14
|
+
"./context.js": "./context.js",
|
|
15
|
+
"./decorators.js": "./decorators.js",
|
|
16
|
+
"./controllers/cascade-controller.js": "./controllers/cascade-controller.js",
|
|
17
|
+
"./controllers/color-context.js": "./controllers/color-context.js",
|
|
18
|
+
"./controllers/css-variable-controller.js": "./controllers/css-variable-controller.js",
|
|
19
|
+
"./controllers/light-dom-controller.js": "./controllers/light-dom-controller.js",
|
|
20
|
+
"./controllers/logger.js": "./controllers/logger.js",
|
|
21
|
+
"./controllers/perf-controller.js": "./controllers/perf-controller.js",
|
|
22
|
+
"./controllers/property-observer-controller.js": "./controllers/property-observer-controller.js",
|
|
23
|
+
"./controllers/slot-controller.js": "./controllers/slot-controller.js",
|
|
24
|
+
"./controllers/floating-dom-controller.js": "./controllers/floating-dom-controller.js",
|
|
25
|
+
"./controllers/style-controller.js": "./controllers/style-controller.js",
|
|
26
|
+
"./decorators/bound.js": "./decorators/bound.js",
|
|
27
|
+
"./decorators/cascades.js": "./decorators/cascades.js",
|
|
28
|
+
"./decorators/color-context.js": "./decorators/color-context.js",
|
|
29
|
+
"./decorators/deprecation.js": "./decorators/deprecation.js",
|
|
30
|
+
"./decorators/initializer.js": "./decorators/initializer.js",
|
|
31
|
+
"./decorators/observed.js": "./decorators/observed.js",
|
|
32
|
+
"./decorators/pfelement.js": "./decorators/pfelement.js",
|
|
33
|
+
"./decorators/time.js": "./decorators/time.js",
|
|
34
|
+
"./decorators/trace.js": "./decorators/trace.js",
|
|
35
|
+
"./functions/debounce.js": "./functions/debounce.js",
|
|
36
|
+
"./functions/deprecatedCustomEvent.js": "./functions/deprecatedCustomEvent.js",
|
|
37
|
+
"./functions/random.js": "./functions/random.js"
|
|
36
38
|
},
|
|
37
39
|
"publishConfig": {
|
|
38
40
|
"access": "public",
|
|
@@ -58,7 +60,8 @@
|
|
|
58
60
|
"watch:types": "tsc -w"
|
|
59
61
|
},
|
|
60
62
|
"dependencies": {
|
|
61
|
-
"
|
|
63
|
+
"@popperjs/core": "2.11.6",
|
|
64
|
+
"lit": "2.3.0"
|
|
62
65
|
},
|
|
63
66
|
"repository": {
|
|
64
67
|
"type": "git",
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
-
import type { ContextTheme } from '../core.js';
|
|
3
|
-
export declare class ColorContextController implements ReactiveController {
|
|
4
|
-
protected host: ReactiveElement;
|
|
5
|
-
private prefix;
|
|
6
|
-
private callbacks;
|
|
7
|
-
private context;
|
|
8
|
-
private style;
|
|
9
|
-
private logger;
|
|
10
|
-
private dispose?;
|
|
11
|
-
constructor(host: ReactiveElement, prefix?: string);
|
|
12
|
-
/**
|
|
13
|
-
* When a context-aware component connects:
|
|
14
|
-
* 1. Request Context from the closest context provider (being another context-aware component)
|
|
15
|
-
* 2. Listen for child components' context-request events (become a provider)
|
|
16
|
-
*/
|
|
17
|
-
hostConnected(): void;
|
|
18
|
-
/**
|
|
19
|
-
* When a context-aware component disconnects:
|
|
20
|
-
* 1. Remove all the components children from the cache of connected components
|
|
21
|
-
*/
|
|
22
|
-
hostDisconnected(): void;
|
|
23
|
-
/**
|
|
24
|
-
* On every host update (i.e. render), update the host's and all it's children's context
|
|
25
|
-
*/
|
|
26
|
-
hostUpdate(): void;
|
|
27
|
-
/** Was the context event fired requesting our colour-context context? */
|
|
28
|
-
private isColorContextEvent;
|
|
29
|
-
/** Return the current CSS `--context` value, or null */
|
|
30
|
-
private get contextVariable();
|
|
31
|
-
/** Register the dispose callback for hosts that requested multiple updates, then update the colour-context */
|
|
32
|
-
private contextCallback;
|
|
33
|
-
/**
|
|
34
|
-
* Provider part of context API
|
|
35
|
-
* When a child connects, claim its context-request event
|
|
36
|
-
* and add its callback to the Set of children if it requests multiple updates
|
|
37
|
-
*/
|
|
38
|
-
private onChildContextEvent;
|
|
39
|
-
/** Sets the `on` attribute on the host and any children that requested multiple updates */
|
|
40
|
-
update(fallback?: ContextTheme | null): void;
|
|
41
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
var f=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var r=(d,e,t,n)=>{for(var o=n>1?void 0:n?p(e,t):e,a=d.length-1,s;a>=0;a--)(s=d[a])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&f(e,t,o),o};import"lit";import{ContextEvent as k,createContext as m}from"../context.js";import{bound as c}from"../decorators/bound.js";import{Logger as u}from"./logger.js";import{StyleController as x}from"./style-controller.js";import{css as h}from"lit";var v=h`:host([context=dark]) {
|
|
2
|
-
--context: dark;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
:host([context=light]) {
|
|
6
|
-
--context: light;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
:host([context=accent]) {
|
|
10
|
-
--context: saturated;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
:host([context=saturated]) {
|
|
14
|
-
--context: saturated;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
:host([on=dark]) {
|
|
18
|
-
--pfe-broadcasted--text: var(--pfe-theme--color--text--on-dark, #fff);
|
|
19
|
-
--pfe-broadcasted--text--muted: var(--pfe-theme--color--text--muted--on-dark, #d2d2d2);
|
|
20
|
-
--pfe-broadcasted--link: var(--pfe-theme--color--link--on-dark, #73bcf7);
|
|
21
|
-
--pfe-broadcasted--link--hover: var(--pfe-theme--color--link--hover--on-dark, #bee1f4);
|
|
22
|
-
--pfe-broadcasted--link--focus: var(--pfe-theme--color--link--focus--on-dark, #bee1f4);
|
|
23
|
-
--pfe-broadcasted--link--visited: var(--pfe-theme--color--link--visited--on-dark, #bee1f4);
|
|
24
|
-
--pfe-broadcasted--link-decoration: var(--pfe-theme--link-decoration--on-dark, none);
|
|
25
|
-
--pfe-broadcasted--link-decoration--hover: var(--pfe-theme--link-decoration--hover--on-dark, underline);
|
|
26
|
-
--pfe-broadcasted--link-decoration--focus: var(--pfe-theme--link-decoration--focus--on-dark, underline);
|
|
27
|
-
--pfe-broadcasted--link-decoration--visited: var(--pfe-theme--link-decoration--visited--on-dark, none);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
:host([on=saturated]) {
|
|
31
|
-
--pfe-broadcasted--text: var(--pfe-theme--color--text--on-saturated, #fff);
|
|
32
|
-
--pfe-broadcasted--text--muted: var(--pfe-theme--color--text--muted--on-saturated, #d2d2d2);
|
|
33
|
-
--pfe-broadcasted--link: var(--pfe-theme--color--link--on-saturated, #fff);
|
|
34
|
-
--pfe-broadcasted--link--hover: var(--pfe-theme--color--link--hover--on-saturated, #fafafa);
|
|
35
|
-
--pfe-broadcasted--link--focus: var(--pfe-theme--color--link--focus--on-saturated, #fafafa);
|
|
36
|
-
--pfe-broadcasted--link--visited: var(--pfe-theme--color--link--visited--on-saturated, #d2d2d2);
|
|
37
|
-
--pfe-broadcasted--link-decoration: var(--pfe-theme--link-decoration--on-saturated, underline);
|
|
38
|
-
--pfe-broadcasted--link-decoration--hover: var(--pfe-theme--link-decoration--hover--on-saturated, underline);
|
|
39
|
-
--pfe-broadcasted--link-decoration--focus: var(--pfe-theme--link-decoration--focus--on-saturated, underline);
|
|
40
|
-
--pfe-broadcasted--link-decoration--visited: var(--pfe-theme--link-decoration--visited--on-saturated, underline);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
:host([on=light]) {
|
|
44
|
-
--pfe-broadcasted--text: var(--pfe-theme--color--text, #151515);
|
|
45
|
-
--pfe-broadcasted--text--muted: var(--pfe-theme--color--text--muted, #6a6e73);
|
|
46
|
-
--pfe-broadcasted--link: var(--pfe-theme--color--link, #06c);
|
|
47
|
-
--pfe-broadcasted--link--hover: var(--pfe-theme--color--link--hover, #004080);
|
|
48
|
-
--pfe-broadcasted--link--focus: var(--pfe-theme--color--link--focus, #004080);
|
|
49
|
-
--pfe-broadcasted--link--visited: var(--pfe-theme--color--link--visited, #6753ac);
|
|
50
|
-
--pfe-broadcasted--link-decoration: var(--pfe-theme--link-decoration, none);
|
|
51
|
-
--pfe-broadcasted--link-decoration--hover: var(--pfe-theme--link-decoration--hover, underline);
|
|
52
|
-
--pfe-broadcasted--link-decoration--focus: var(--pfe-theme--link-decoration--focus, underline);
|
|
53
|
-
--pfe-broadcasted--link-decoration--visited: var(--pfe-theme--link-decoration--visited, none);
|
|
54
|
-
}`,l=v;var i=class{constructor(e,t="pfe"){this.host=e;this.prefix=t;this.callbacks=new Set;this.style=window.getComputedStyle(e),this.context=m(`${this.prefix}-color-context`,this.contextVariable),this.logger=new u(e),new x(e,l),e.addController(this)}hostConnected(){this.host.dispatchEvent(new k(this.context,this.contextCallback,!0)),this.host.addEventListener("context-request",this.onChildContextEvent),this.update()}hostDisconnected(){this.dispose?.(),this.dispose=void 0,this.callbacks.forEach(e=>this.callbacks.delete(e))}hostUpdate(){this.update()}isColorContextEvent(e){return e.context.name===`${this.prefix}-color-context`}get contextVariable(){return this.style.getPropertyValue("--context").trim()||null}contextCallback(e,t){t&&t!==this.dispose&&this.dispose?.(),this.update(e),this.dispose=t}onChildContextEvent(e){this.isColorContextEvent(e)&&(e.stopPropagation(),e.multiple&&this.callbacks.add(e.callback),e.callback(this.host.getAttribute("on")))}update(e){let t=this.contextVariable||e,n=this.host.getAttribute("on");if(t!==n){let o=t;this.logger.log(`Resetting context from ${n} to ${o}`),o!=null?this.host.setAttribute("on",o):this.host.removeAttribute("on");for(let a of this.callbacks)a(t)}}};r([c],i.prototype,"contextCallback",1),r([c],i.prototype,"onChildContextEvent",1),r([c],i.prototype,"update",1);export{i as ColorContextController};
|
|
55
|
-
//# sourceMappingURL=color-context-controller.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["color-context-controller.ts", "color-context-controller.scss"],
|
|
4
|
-
"sourcesContent": ["import { ReactiveController, ReactiveElement } from 'lit';\nimport type { ContextTheme } from '../core.js';\nimport type { Context, UnknownContext } from '../context.js';\n\nimport { ContextEvent, createContext } from '../context.js';\nimport { bound } from '../decorators/bound.js';\nimport { Logger } from './logger.js';\nimport { StyleController } from './style-controller.js';\n\nimport CONTEXT_BASE_STYLES from './color-context-controller.scss';\n\nexport class ColorContextController implements ReactiveController {\n private callbacks = new Set<ColorContextController['update']>();\n\n private context: Context<ContextTheme|null>;\n\n private style: CSSStyleDeclaration;\n\n private logger: Logger;\n\n private dispose?: () => void;\n\n constructor(protected host: ReactiveElement, private prefix = 'pfe') {\n this.style = window.getComputedStyle(host);\n this.context = createContext(`${this.prefix}-color-context`, this.contextVariable);\n this.logger = new Logger(host);\n new StyleController(host, CONTEXT_BASE_STYLES);\n host.addController(this);\n }\n\n /**\n * When a context-aware component connects:\n * 1. Request Context from the closest context provider (being another context-aware component)\n * 2. Listen for child components' context-request events (become a provider)\n */\n hostConnected() {\n // register as a context consumer on the nearest context-aware ancestor\n this.host.dispatchEvent(new ContextEvent(this.context, this.contextCallback, true));\n // become a context provider\n this.host.addEventListener('context-request', this.onChildContextEvent);\n // \uD83D\uDC83 \uD83D\uDD7A\n this.update();\n }\n\n /**\n * When a context-aware component disconnects:\n * 1. Remove all the components children from the cache of connected components\n */\n hostDisconnected() {\n this.dispose?.();\n this.dispose = undefined;\n this.callbacks.forEach(x => this.callbacks.delete(x));\n }\n\n /**\n * On every host update (i.e. render), update the host's and all it's children's context\n */\n hostUpdate() {\n this.update();\n }\n\n /** Was the context event fired requesting our colour-context context? */\n private isColorContextEvent(\n event: ContextEvent<UnknownContext>\n ): event is ContextEvent<Context<ContextTheme|null>> {\n return event.context.name === `${this.prefix}-color-context`;\n }\n\n /** Return the current CSS `--context` value, or null */\n private get contextVariable(): ContextTheme | null {\n return this.style.getPropertyValue('--context').trim() as ContextTheme || null;\n }\n\n /** Register the dispose callback for hosts that requested multiple updates, then update the colour-context */\n @bound private contextCallback(value?: ContextTheme|null, dispose?: () => void) {\n // protect against changing providers\n if (dispose && dispose !== this.dispose) {\n this.dispose?.();\n }\n this.update(value);\n this.dispose = dispose;\n }\n\n /**\n * Provider part of context API\n * When a child connects, claim its context-request event\n * and add its callback to the Set of children if it requests multiple updates\n */\n @bound private onChildContextEvent(event: ContextEvent<UnknownContext>) {\n // only handle ContextEvents relevant to colour context\n if (this.isColorContextEvent(event)) {\n // claim the context-request event for ourselves (required by context protocol)\n event.stopPropagation();\n // Cache the callback for future updates, if requested\n if (event.multiple) {\n this.callbacks.add(event.callback);\n }\n\n // Run the callback to initialize the child's colour-context\n event.callback(this.host.getAttribute('on') as ContextTheme);\n }\n }\n\n /** Sets the `on` attribute on the host and any children that requested multiple updates */\n @bound public update(fallback?: ContextTheme|null) {\n // NB: We query the existing CSSStyleDeclaration on _every_. _single_. _update_.\n const incoming = this.contextVariable || fallback;\n const current = this.host.getAttribute('on');\n if (incoming !== current) {\n const next = incoming;\n this.logger.log(`Resetting context from ${current} to ${next}`);\n\n if (next != null) {\n this.host.setAttribute('on', next);\n } else {\n this.host.removeAttribute('on');\n }\n\n for (const cb of this.callbacks) {\n cb(incoming);\n }\n }\n }\n}\n", "import {css} from 'lit';\nexport const styles = css`:host([context=dark]) {\n --context: dark;\n}\n\n:host([context=light]) {\n --context: light;\n}\n\n:host([context=accent]) {\n --context: saturated;\n}\n\n:host([context=saturated]) {\n --context: saturated;\n}\n\n:host([on=dark]) {\n --pfe-broadcasted--text: var(--pfe-theme--color--text--on-dark, #fff);\n --pfe-broadcasted--text--muted: var(--pfe-theme--color--text--muted--on-dark, #d2d2d2);\n --pfe-broadcasted--link: var(--pfe-theme--color--link--on-dark, #73bcf7);\n --pfe-broadcasted--link--hover: var(--pfe-theme--color--link--hover--on-dark, #bee1f4);\n --pfe-broadcasted--link--focus: var(--pfe-theme--color--link--focus--on-dark, #bee1f4);\n --pfe-broadcasted--link--visited: var(--pfe-theme--color--link--visited--on-dark, #bee1f4);\n --pfe-broadcasted--link-decoration: var(--pfe-theme--link-decoration--on-dark, none);\n --pfe-broadcasted--link-decoration--hover: var(--pfe-theme--link-decoration--hover--on-dark, underline);\n --pfe-broadcasted--link-decoration--focus: var(--pfe-theme--link-decoration--focus--on-dark, underline);\n --pfe-broadcasted--link-decoration--visited: var(--pfe-theme--link-decoration--visited--on-dark, none);\n}\n\n:host([on=saturated]) {\n --pfe-broadcasted--text: var(--pfe-theme--color--text--on-saturated, #fff);\n --pfe-broadcasted--text--muted: var(--pfe-theme--color--text--muted--on-saturated, #d2d2d2);\n --pfe-broadcasted--link: var(--pfe-theme--color--link--on-saturated, #fff);\n --pfe-broadcasted--link--hover: var(--pfe-theme--color--link--hover--on-saturated, #fafafa);\n --pfe-broadcasted--link--focus: var(--pfe-theme--color--link--focus--on-saturated, #fafafa);\n --pfe-broadcasted--link--visited: var(--pfe-theme--color--link--visited--on-saturated, #d2d2d2);\n --pfe-broadcasted--link-decoration: var(--pfe-theme--link-decoration--on-saturated, underline);\n --pfe-broadcasted--link-decoration--hover: var(--pfe-theme--link-decoration--hover--on-saturated, underline);\n --pfe-broadcasted--link-decoration--focus: var(--pfe-theme--link-decoration--focus--on-saturated, underline);\n --pfe-broadcasted--link-decoration--visited: var(--pfe-theme--link-decoration--visited--on-saturated, underline);\n}\n\n:host([on=light]) {\n --pfe-broadcasted--text: var(--pfe-theme--color--text, #151515);\n --pfe-broadcasted--text--muted: var(--pfe-theme--color--text--muted, #6a6e73);\n --pfe-broadcasted--link: var(--pfe-theme--color--link, #06c);\n --pfe-broadcasted--link--hover: var(--pfe-theme--color--link--hover, #004080);\n --pfe-broadcasted--link--focus: var(--pfe-theme--color--link--focus, #004080);\n --pfe-broadcasted--link--visited: var(--pfe-theme--color--link--visited, #6753ac);\n --pfe-broadcasted--link-decoration: var(--pfe-theme--link-decoration, none);\n --pfe-broadcasted--link-decoration--hover: var(--pfe-theme--link-decoration--hover, underline);\n --pfe-broadcasted--link-decoration--focus: var(--pfe-theme--link-decoration--focus, underline);\n --pfe-broadcasted--link-decoration--visited: var(--pfe-theme--link-decoration--visited, none);\n}`;\nexport default styles;\n"],
|
|
5
|
-
"mappings": "wMAAA,YAIA,gEACA,+CACA,qCACA,wDCPA,0BACO,GAAM,GAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAsDf,EAAQ,ED5CR,WAA2D,CAWhE,YAAsB,EAA+B,EAAS,MAAO,CAA/C,YAA+B,cAV7C,eAAY,GAAI,KAWtB,KAAK,MAAQ,OAAO,iBAAiB,GACrC,KAAK,QAAU,EAAc,GAAG,KAAK,uBAAwB,KAAK,iBAClE,KAAK,OAAS,GAAI,GAAO,GACzB,GAAI,GAAgB,EAAM,GAC1B,EAAK,cAAc,MAQrB,eAAgB,CAEd,KAAK,KAAK,cAAc,GAAI,GAAa,KAAK,QAAS,KAAK,gBAAiB,KAE7E,KAAK,KAAK,iBAAiB,kBAAmB,KAAK,qBAEnD,KAAK,SAOP,kBAAmB,CACjB,KAAK,YACL,KAAK,QAAU,OACf,KAAK,UAAU,QAAQ,GAAK,KAAK,UAAU,OAAO,IAMpD,YAAa,CACX,KAAK,SAIC,oBACN,EACmD,CACnD,MAAO,GAAM,QAAQ,OAAS,GAAG,KAAK,0BAI5B,kBAAuC,CACjD,MAAO,MAAK,MAAM,iBAAiB,aAAa,QAA0B,KAI7D,gBAAgB,EAA2B,EAAsB,CAE9E,AAAI,GAAW,IAAY,KAAK,SAC9B,KAAK,YAEP,KAAK,OAAO,GACZ,KAAK,QAAU,EAQF,oBAAoB,EAAqC,CAEtE,AAAI,KAAK,oBAAoB,IAE3B,GAAM,kBAEF,EAAM,UACR,KAAK,UAAU,IAAI,EAAM,UAI3B,EAAM,SAAS,KAAK,KAAK,aAAa,QAK5B,OAAO,EAA8B,CAEjD,GAAM,GAAW,KAAK,iBAAmB,EACnC,EAAU,KAAK,KAAK,aAAa,MACvC,GAAI,IAAa,EAAS,CACxB,GAAM,GAAO,EACb,KAAK,OAAO,IAAI,0BAA0B,QAAc,KAExD,AAAI,GAAQ,KACV,KAAK,KAAK,aAAa,KAAM,GAE7B,KAAK,KAAK,gBAAgB,MAG5B,OAAW,KAAM,MAAK,UACpB,EAAG,MA7CM,GAAd,GAAc,AA/DV,EA+DU,+BAcA,GAAd,GAAc,AA7EV,EA6EU,mCAgBD,GAAb,GAAa,AA7FT,EA6FS",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|