first commit

This commit is contained in:
becarta
2025-05-16 00:17:42 +02:00
parent ea5c866137
commit bacf566ec9
6020 changed files with 1715262 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* Whether the current browser supports `adoptedStyleSheets`.
*/
export declare const supportsAdoptingStyleSheets: boolean;
/**
* A CSSResult or native CSSStyleSheet.
*
* In browsers that support constructible CSS style sheets, CSSStyleSheet
* object can be used for styling along side CSSResult from the `css`
* template tag.
*/
export declare type CSSResultOrNative = CSSResult | CSSStyleSheet;
export declare type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;
/**
* A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.
*/
export declare type CSSResultGroup = CSSResultOrNative | CSSResultArray;
/**
* A container for a string of CSS text, that may be used to create a CSSStyleSheet.
*
* CSSResult is the return value of `css`-tagged template literals and
* `unsafeCSS()`. In order to ensure that CSSResults are only created via the
* `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.
*/
export declare class CSSResult {
['_$cssResult$']: boolean;
readonly cssText: string;
private _styleSheet?;
private _strings;
private constructor();
get styleSheet(): CSSStyleSheet | undefined;
toString(): string;
}
/**
* Wrap a value for interpolation in a {@linkcode css} tagged template literal.
*
* This is unsafe because untrusted CSS text can be used to phone home
* or exfiltrate data to an attacker controlled site. Take care to only use
* this with trusted input.
*/
export declare const unsafeCSS: (value: unknown) => CSSResult;
/**
* A template literal tag which can be used with LitElement's
* {@linkcode LitElement.styles} property to set element styles.
*
* For security reasons, only literal string values and number may be used in
* embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}
* may be used inside an expression.
*/
export declare const css: (strings: TemplateStringsArray, ...values: (CSSResultGroup | number)[]) => CSSResult;
/**
* Applies the given styles to a `shadowRoot`. When Shadow DOM is
* available but `adoptedStyleSheets` is not, styles are appended to the
* `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
* Note, when shimming is used, any styles that are subsequently placed into
* the shadowRoot should be placed *before* any shimmed adopted styles. This
* will match spec behavior that gives adopted sheets precedence over styles in
* shadowRoot.
*/
export declare const adoptStyles: (renderRoot: ShadowRoot, styles: Array<CSSResultOrNative>) => void;
export declare const getCompatibleStyle: (s: CSSResultOrNative) => CSSResultOrNative;
//# sourceMappingURL=css-tag.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"css-tag.d.ts","sourceRoot":"","sources":["../src/css-tag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAIJ,CAAC;AAEvC;;;;;;GAMG;AACH,oBAAY,iBAAiB,GAAG,SAAS,GAAG,aAAa,CAAC;AAE1D,oBAAY,cAAc,GAAG,KAAK,CAAC,iBAAiB,GAAG,cAAc,CAAC,CAAC;AAEvE;;GAEG;AACH,oBAAY,cAAc,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAMhE;;;;;;GAMG;AACH,qBAAa,SAAS;IAEpB,CAAC,cAAc,CAAC,UAAQ;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,WAAW,CAAC,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAmC;IAEnD,OAAO;IAgBP,IAAI,UAAU,IAAI,aAAa,GAAG,SAAS,CAoB1C;IAED,QAAQ,IAAI,MAAM;CAGnB;AAyBD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,UAAW,OAAO,cAKrC,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,YACL,oBAAoB,aAClB,CAAC,cAAc,GAAG,MAAM,CAAC,EAAE,KACrC,SAaF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,eACV,UAAU,UACd,MAAM,iBAAiB,CAAC,SAkBjC,CAAC;AAUF,eAAO,MAAM,kBAAkB,MAGrB,iBAAiB,sBAEwC,CAAC"}

View File

@@ -0,0 +1,132 @@
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const NODE_MODE = false;
const global = NODE_MODE ? globalThis : window;
/**
* Whether the current browser supports `adoptedStyleSheets`.
*/
export const supportsAdoptingStyleSheets = global.ShadowRoot &&
(global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&
'adoptedStyleSheets' in Document.prototype &&
'replace' in CSSStyleSheet.prototype;
const constructionToken = Symbol();
const cssTagCache = new WeakMap();
/**
* A container for a string of CSS text, that may be used to create a CSSStyleSheet.
*
* CSSResult is the return value of `css`-tagged template literals and
* `unsafeCSS()`. In order to ensure that CSSResults are only created via the
* `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.
*/
export class CSSResult {
constructor(cssText, strings, safeToken) {
// This property needs to remain unminified.
this['_$cssResult$'] = true;
if (safeToken !== constructionToken) {
throw new Error('CSSResult is not constructable. Use `unsafeCSS` or `css` instead.');
}
this.cssText = cssText;
this._strings = strings;
}
// This is a getter so that it's lazy. In practice, this means stylesheets
// are not created until the first element instance is made.
get styleSheet() {
// If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is
// constructable.
let styleSheet = this._styleSheet;
const strings = this._strings;
if (supportsAdoptingStyleSheets && styleSheet === undefined) {
const cacheable = strings !== undefined && strings.length === 1;
if (cacheable) {
styleSheet = cssTagCache.get(strings);
}
if (styleSheet === undefined) {
(this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(this.cssText);
if (cacheable) {
cssTagCache.set(strings, styleSheet);
}
}
}
return styleSheet;
}
toString() {
return this.cssText;
}
}
const textFromCSSResult = (value) => {
// This property needs to remain unminified.
if (value['_$cssResult$'] === true) {
return value.cssText;
}
else if (typeof value === 'number') {
return value;
}
else {
throw new Error(`Value passed to 'css' function must be a 'css' function result: ` +
`${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +
`to ensure page security.`);
}
};
/**
* Wrap a value for interpolation in a {@linkcode css} tagged template literal.
*
* This is unsafe because untrusted CSS text can be used to phone home
* or exfiltrate data to an attacker controlled site. Take care to only use
* this with trusted input.
*/
export const unsafeCSS = (value) => new CSSResult(typeof value === 'string' ? value : String(value), undefined, constructionToken);
/**
* A template literal tag which can be used with LitElement's
* {@linkcode LitElement.styles} property to set element styles.
*
* For security reasons, only literal string values and number may be used in
* embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}
* may be used inside an expression.
*/
export const css = (strings, ...values) => {
const cssText = strings.length === 1
? strings[0]
: values.reduce((acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1], strings[0]);
return new CSSResult(cssText, strings, constructionToken);
};
/**
* Applies the given styles to a `shadowRoot`. When Shadow DOM is
* available but `adoptedStyleSheets` is not, styles are appended to the
* `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
* Note, when shimming is used, any styles that are subsequently placed into
* the shadowRoot should be placed *before* any shimmed adopted styles. This
* will match spec behavior that gives adopted sheets precedence over styles in
* shadowRoot.
*/
export const adoptStyles = (renderRoot, styles) => {
if (supportsAdoptingStyleSheets) {
renderRoot.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
}
else {
styles.forEach((s) => {
const style = document.createElement('style');
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const nonce = global['litNonce'];
if (nonce !== undefined) {
style.setAttribute('nonce', nonce);
}
style.textContent = s.cssText;
renderRoot.appendChild(style);
});
}
};
const cssResultFromStyleSheet = (sheet) => {
let cssText = '';
for (const rule of sheet.cssRules) {
cssText += rule.cssText;
}
return unsafeCSS(cssText);
};
export const getCompatibleStyle = supportsAdoptingStyleSheets ||
(NODE_MODE && global.CSSStyleSheet === undefined)
? (s) => s
: (s) => s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;
//# sourceMappingURL=css-tag.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
export * from './decorators/base.js';
export * from './decorators/custom-element.js';
export * from './decorators/property.js';
export * from './decorators/state.js';
export * from './decorators/event-options.js';
export * from './decorators/query.js';
export * from './decorators/query-all.js';
export * from './decorators/query-async.js';
export * from './decorators/query-assigned-elements.js';
export * from './decorators/query-assigned-nodes.js';
//# sourceMappingURL=decorators.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC"}

View File

@@ -0,0 +1,22 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all
* property decorators (but not class decorators) in this file that have
* an @ExportDecoratedItems annotation must be defined as a regular function,
* not an arrow function.
*/
export * from './decorators/base.js';
export * from './decorators/custom-element.js';
export * from './decorators/property.js';
export * from './decorators/state.js';
export * from './decorators/event-options.js';
export * from './decorators/query.js';
export * from './decorators/query-all.js';
export * from './decorators/query-async.js';
export * from './decorators/query-assigned-elements.js';
export * from './decorators/query-assigned-nodes.js';
//# sourceMappingURL=decorators.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nexport * from './decorators/base.js';\nexport * from './decorators/custom-element.js';\nexport * from './decorators/property.js';\nexport * from './decorators/state.js';\nexport * from './decorators/event-options.js';\nexport * from './decorators/query.js';\nexport * from './decorators/query-all.js';\nexport * from './decorators/query-async.js';\nexport * from './decorators/query-assigned-elements.js';\nexport * from './decorators/query-assigned-nodes.js';\n"]}

View File

@@ -0,0 +1,56 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import { ReactiveElement } from '../reactive-element.js';
/**
* Generates a public interface type that removes private and protected fields.
* This allows accepting otherwise compatible versions of the type (e.g. from
* multiple copies of the same package in `node_modules`).
*/
export declare type Interface<T> = {
[K in keyof T]: T[K];
};
export declare type Constructor<T> = {
new (...args: any[]): T;
};
export interface ClassDescriptor {
kind: 'class';
elements: ClassElement[];
finisher?: <T>(clazz: Constructor<T>) => void | Constructor<T>;
}
export interface ClassElement {
kind: 'field' | 'method';
key: PropertyKey;
placement: 'static' | 'prototype' | 'own';
initializer?: Function;
extras?: ClassElement[];
finisher?: <T>(clazz: Constructor<T>) => void | Constructor<T>;
descriptor?: PropertyDescriptor;
}
export declare const legacyPrototypeMethod: (descriptor: PropertyDescriptor, proto: Object, name: PropertyKey) => void;
export declare const standardPrototypeMethod: (descriptor: PropertyDescriptor, element: ClassElement) => {
kind: string;
placement: string;
key: PropertyKey;
descriptor: PropertyDescriptor;
};
/**
* Helper for decorating a property that is compatible with both TypeScript
* and Babel decorators. The optional `finisher` can be used to perform work on
* the class. The optional `descriptor` should return a PropertyDescriptor
* to install for the given property.
*
* @param finisher {function} Optional finisher method; receives the element
* constructor and property key as arguments and has no return value.
* @param descriptor {function} Optional descriptor method; receives the
* property key as an argument and returns a property descriptor to define for
* the given property.
* @returns {ClassElement|void}
*/
export declare const decorateProperty: ({ finisher, descriptor, }: {
finisher?: ((ctor: typeof ReactiveElement, property: PropertyKey) => void) | null | undefined;
descriptor?: ((property: PropertyKey) => PropertyDescriptor) | undefined;
}) => (protoOrDescriptor: Interface<ReactiveElement> | ClassElement, name?: PropertyKey) => void | any;
//# sourceMappingURL=base.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/decorators/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAEvD;;;;GAIG;AACH,oBAAY,SAAS,CAAC,CAAC,IAAI;KACxB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrB,CAAC;AAEF,oBAAY,WAAW,CAAC,CAAC,IAAI;IAE3B,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;CACzB,CAAC;AAGF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;CAChE;AAGD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,GAAG,EAAE,WAAW,CAAC;IACjB,SAAS,EAAE,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAC;IAC1C,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAC/D,UAAU,CAAC,EAAE,kBAAkB,CAAC;CACjC;AAED,eAAO,MAAM,qBAAqB,eACpB,kBAAkB,SACvB,MAAM,QACP,WAAW,SAGlB,CAAC;AAEF,eAAO,MAAM,uBAAuB,eACtB,kBAAkB,WACrB,YAAY;;;;;CAMrB,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB;uBAMb,sBAAsB,YAAY,WAAW,KAAK,IAAI;6BAE1C,WAAW,KAAK,kBAAkB;0BAGvC,UAAU,eAAe,CAAC,GAAG,YAAY,SACrD,WAAW,KAGjB,IAAI,GAAG,GAmCT,CAAC"}

View File

@@ -0,0 +1,65 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
export const legacyPrototypeMethod = (descriptor, proto, name) => {
Object.defineProperty(proto, name, descriptor);
};
export const standardPrototypeMethod = (descriptor, element) => ({
kind: 'method',
placement: 'prototype',
key: element.key,
descriptor,
});
/**
* Helper for decorating a property that is compatible with both TypeScript
* and Babel decorators. The optional `finisher` can be used to perform work on
* the class. The optional `descriptor` should return a PropertyDescriptor
* to install for the given property.
*
* @param finisher {function} Optional finisher method; receives the element
* constructor and property key as arguments and has no return value.
* @param descriptor {function} Optional descriptor method; receives the
* property key as an argument and returns a property descriptor to define for
* the given property.
* @returns {ClassElement|void}
*/
export const decorateProperty = ({ finisher, descriptor, }) => (protoOrDescriptor, name
// Note TypeScript requires the return type to be `void|any`
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) => {
var _a;
// TypeScript / Babel legacy mode
if (name !== undefined) {
const ctor = protoOrDescriptor
.constructor;
if (descriptor !== undefined) {
Object.defineProperty(protoOrDescriptor, name, descriptor(name));
}
finisher === null || finisher === void 0 ? void 0 : finisher(ctor, name);
// Babel standard mode
}
else {
// Note, the @property decorator saves `key` as `originalKey`
// so try to use it here.
const key =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(_a = protoOrDescriptor.originalKey) !== null && _a !== void 0 ? _a : protoOrDescriptor.key;
const info = descriptor != undefined
? {
kind: 'method',
placement: 'prototype',
key,
descriptor: descriptor(protoOrDescriptor.key),
}
: { ...protoOrDescriptor, key };
if (finisher != undefined) {
info.finisher = function (ctor) {
finisher(ctor, key);
};
}
return info;
}
};
//# sourceMappingURL=base.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,27 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import { ClassDescriptor } from './base.js';
/**
* Allow for custom element classes with private constructors
*/
declare type CustomElementClass = Omit<typeof HTMLElement, 'new'>;
/**
* Class decorator factory that defines the decorated class as a custom element.
*
* ```js
* @customElement('my-element')
* class MyElement extends LitElement {
* render() {
* return html``;
* }
* }
* ```
* @category Decorator
* @param tagName The tag name of the custom element to define.
*/
export declare const customElement: (tagName: string) => (classOrDescriptor: CustomElementClass | ClassDescriptor) => any;
export {};
//# sourceMappingURL=custom-element.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"custom-element.d.ts","sourceRoot":"","sources":["../../src/decorators/custom-element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAc,eAAe,EAAC,MAAM,WAAW,CAAC;AAEvD;;GAEG;AACH,aAAK,kBAAkB,GAAG,IAAI,CAAC,OAAO,WAAW,EAAE,KAAK,CAAC,CAAC;AA4B1D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,YACd,MAAM,yBACI,kBAAkB,GAAG,eAAe,QAGkB,CAAC"}

View File

@@ -0,0 +1,44 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const legacyCustomElement = (tagName, clazz) => {
customElements.define(tagName, clazz);
// Cast as any because TS doesn't recognize the return type as being a
// subtype of the decorated class when clazz is typed as
// `Constructor<HTMLElement>` for some reason.
// `Constructor<HTMLElement>` is helpful to make sure the decorator is
// applied to elements however.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return clazz;
};
const standardCustomElement = (tagName, descriptor) => {
const { kind, elements } = descriptor;
return {
kind,
elements,
// This callback is called once the class is otherwise fully defined
finisher(clazz) {
customElements.define(tagName, clazz);
},
};
};
/**
* Class decorator factory that defines the decorated class as a custom element.
*
* ```js
* @customElement('my-element')
* class MyElement extends LitElement {
* render() {
* return html``;
* }
* }
* ```
* @category Decorator
* @param tagName The tag name of the custom element to define.
*/
export const customElement = (tagName) => (classOrDescriptor) => typeof classOrDescriptor === 'function'
? legacyCustomElement(tagName, classOrDescriptor)
: standardCustomElement(tagName, classOrDescriptor);
//# sourceMappingURL=custom-element.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"custom-element.js","sourceRoot":"","sources":["../../src/decorators/custom-element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAE,KAAyB,EAAE,EAAE;IACzE,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,KAAiC,CAAC,CAAC;IAClE,sEAAsE;IACtE,wDAAwD;IACxD,8CAA8C;IAC9C,sEAAsE;IACtE,+BAA+B;IAC/B,8DAA8D;IAC9D,OAAO,KAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAC5B,OAAe,EACf,UAA2B,EAC3B,EAAE;IACF,MAAM,EAAC,IAAI,EAAE,QAAQ,EAAC,GAAG,UAAU,CAAC;IACpC,OAAO;QACL,IAAI;QACJ,QAAQ;QACR,oEAAoE;QACpE,QAAQ,CAAC,KAA+B;YACtC,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,CAAC,OAAe,EAAE,EAAE,CACpB,CAAC,iBAAuD,EAAE,EAAE,CAC1D,OAAO,iBAAiB,KAAK,UAAU;IACrC,CAAC,CAAC,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACjD,CAAC,CAAC,qBAAqB,CAAC,OAAO,EAAE,iBAAoC,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\nimport {Constructor, ClassDescriptor} from './base.js';\n\n/**\n * Allow for custom element classes with private constructors\n */\ntype CustomElementClass = Omit<typeof HTMLElement, 'new'>;\n\nconst legacyCustomElement = (tagName: string, clazz: CustomElementClass) => {\n customElements.define(tagName, clazz as CustomElementConstructor);\n // Cast as any because TS doesn't recognize the return type as being a\n // subtype of the decorated class when clazz is typed as\n // `Constructor<HTMLElement>` for some reason.\n // `Constructor<HTMLElement>` is helpful to make sure the decorator is\n // applied to elements however.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return clazz as any;\n};\n\nconst standardCustomElement = (\n tagName: string,\n descriptor: ClassDescriptor\n) => {\n const {kind, elements} = descriptor;\n return {\n kind,\n elements,\n // This callback is called once the class is otherwise fully defined\n finisher(clazz: Constructor<HTMLElement>) {\n customElements.define(tagName, clazz);\n },\n };\n};\n\n/**\n * Class decorator factory that defines the decorated class as a custom element.\n *\n * ```js\n * @customElement('my-element')\n * class MyElement extends LitElement {\n * render() {\n * return html``;\n * }\n * }\n * ```\n * @category Decorator\n * @param tagName The tag name of the custom element to define.\n */\nexport const customElement =\n (tagName: string) =>\n (classOrDescriptor: CustomElementClass | ClassDescriptor) =>\n typeof classOrDescriptor === 'function'\n ? legacyCustomElement(tagName, classOrDescriptor)\n : standardCustomElement(tagName, classOrDescriptor as ClassDescriptor);\n"]}

View File

@@ -0,0 +1,38 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import { ReactiveElement } from '../reactive-element.js';
/**
* Adds event listener options to a method used as an event listener in a
* lit-html template.
*
* @param options An object that specifies event listener options as accepted by
* `EventTarget#addEventListener` and `EventTarget#removeEventListener`.
*
* Current browsers support the `capture`, `passive`, and `once` options. See:
* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Parameters
*
* ```ts
* class MyElement {
* clicked = false;
*
* render() {
* return html`
* <div @click=${this._onClick}>
* <button></button>
* </div>
* `;
* }
*
* @eventOptions({capture: true})
* _onClick(e) {
* this.clicked = true;
* }
* }
* ```
* @category Decorator
*/
export declare function eventOptions(options: AddEventListenerOptions): (protoOrDescriptor: import("./base.js").ClassElement | import("./base.js").Interface<ReactiveElement>, name?: PropertyKey | undefined) => any;
//# sourceMappingURL=event-options.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"event-options.d.ts","sourceRoot":"","sources":["../../src/decorators/event-options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,uBAAuB,iJAU5D"}

View File

@@ -0,0 +1,46 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import { decorateProperty } from './base.js';
/**
* Adds event listener options to a method used as an event listener in a
* lit-html template.
*
* @param options An object that specifies event listener options as accepted by
* `EventTarget#addEventListener` and `EventTarget#removeEventListener`.
*
* Current browsers support the `capture`, `passive`, and `once` options. See:
* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Parameters
*
* ```ts
* class MyElement {
* clicked = false;
*
* render() {
* return html`
* <div @click=${this._onClick}>
* <button></button>
* </div>
* `;
* }
*
* @eventOptions({capture: true})
* _onClick(e) {
* this.clicked = true;
* }
* }
* ```
* @category Decorator
*/
export function eventOptions(options) {
return decorateProperty({
finisher: (ctor, name) => {
Object.assign(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ctor.prototype[name], options);
},
});
}
//# sourceMappingURL=event-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"event-options.js","sourceRoot":"","sources":["../../src/decorators/event-options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,YAAY,CAAC,OAAgC;IAC3D,OAAO,gBAAgB,CAAC;QACtB,QAAQ,EAAE,CAAC,IAA4B,EAAE,IAAiB,EAAE,EAAE;YAC5D,MAAM,CAAC,MAAM;YACX,8DAA8D;YAC9D,IAAI,CAAC,SAAS,CAAC,IAA6B,CAAQ,EACpD,OAAO,CACR,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {ReactiveElement} from '../reactive-element.js';\nimport {decorateProperty} from './base.js';\n\n/**\n * Adds event listener options to a method used as an event listener in a\n * lit-html template.\n *\n * @param options An object that specifies event listener options as accepted by\n * `EventTarget#addEventListener` and `EventTarget#removeEventListener`.\n *\n * Current browsers support the `capture`, `passive`, and `once` options. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Parameters\n *\n * ```ts\n * class MyElement {\n * clicked = false;\n *\n * render() {\n * return html`\n * <div @click=${this._onClick}>\n * <button></button>\n * </div>\n * `;\n * }\n *\n * @eventOptions({capture: true})\n * _onClick(e) {\n * this.clicked = true;\n * }\n * }\n * ```\n * @category Decorator\n */\nexport function eventOptions(options: AddEventListenerOptions) {\n return decorateProperty({\n finisher: (ctor: typeof ReactiveElement, name: PropertyKey) => {\n Object.assign(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ctor.prototype[name as keyof ReactiveElement] as any,\n options\n );\n },\n });\n}\n"]}

View File

@@ -0,0 +1,41 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import { PropertyDeclaration } from '../reactive-element.js';
import { ClassElement } from './base.js';
/**
* A property decorator which creates a reactive property that reflects a
* corresponding attribute value. When a decorated property is set
* the element will update and render. A {@linkcode PropertyDeclaration} may
* optionally be supplied to configure property features.
*
* This decorator should only be used for public fields. As public fields,
* properties should be considered as primarily settable by element users,
* either via attribute or the property itself.
*
* Generally, properties that are changed by the element should be private or
* protected fields and should use the {@linkcode state} decorator.
*
* However, sometimes element code does need to set a public property. This
* should typically only be done in response to user interaction, and an event
* should be fired informing the user; for example, a checkbox sets its
* `checked` property when clicked and fires a `changed` event. Mutating public
* properties should typically not be done for non-primitive (object or array)
* properties. In other cases when an element needs to manage state, a private
* property decorated via the {@linkcode state} decorator should be used. When
* needed, state properties can be initialized via public properties to
* facilitate complex interactions.
*
* ```ts
* class MyElement {
* @property({ type: Boolean })
* clicked = false;
* }
* ```
* @category Decorator
* @ExportDecoratedItems
*/
export declare function property(options?: PropertyDeclaration): (protoOrDescriptor: Object | ClassElement, name?: PropertyKey) => any;
//# sourceMappingURL=property.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../src/decorators/property.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAC,mBAAmB,EAAkB,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AA4DvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,uBAEzB,MAAM,GAAG,YAAY,SAAS,WAAW,KAAG,GAAG,CAI3E"}

View File

@@ -0,0 +1,92 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const standardProperty = (options, element) => {
// When decorating an accessor, pass it through and add property metadata.
// Note, the `hasOwnProperty` check in `createProperty` ensures we don't
// stomp over the user's accessor.
if (element.kind === 'method' &&
element.descriptor &&
!('value' in element.descriptor)) {
return {
...element,
finisher(clazz) {
clazz.createProperty(element.key, options);
},
};
}
else {
// createProperty() takes care of defining the property, but we still
// must return some kind of descriptor, so return a descriptor for an
// unused prototype field. The finisher calls createProperty().
return {
kind: 'field',
key: Symbol(),
placement: 'own',
descriptor: {},
// store the original key so subsequent decorators have access to it.
originalKey: element.key,
// When @babel/plugin-proposal-decorators implements initializers,
// do this instead of the initializer below. See:
// https://github.com/babel/babel/issues/9260 extras: [
// {
// kind: 'initializer',
// placement: 'own',
// initializer: descriptor.initializer,
// }
// ],
initializer() {
if (typeof element.initializer === 'function') {
this[element.key] = element.initializer.call(this);
}
},
finisher(clazz) {
clazz.createProperty(element.key, options);
},
};
}
};
const legacyProperty = (options, proto, name) => {
proto.constructor.createProperty(name, options);
};
/**
* A property decorator which creates a reactive property that reflects a
* corresponding attribute value. When a decorated property is set
* the element will update and render. A {@linkcode PropertyDeclaration} may
* optionally be supplied to configure property features.
*
* This decorator should only be used for public fields. As public fields,
* properties should be considered as primarily settable by element users,
* either via attribute or the property itself.
*
* Generally, properties that are changed by the element should be private or
* protected fields and should use the {@linkcode state} decorator.
*
* However, sometimes element code does need to set a public property. This
* should typically only be done in response to user interaction, and an event
* should be fired informing the user; for example, a checkbox sets its
* `checked` property when clicked and fires a `changed` event. Mutating public
* properties should typically not be done for non-primitive (object or array)
* properties. In other cases when an element needs to manage state, a private
* property decorated via the {@linkcode state} decorator should be used. When
* needed, state properties can be initialized via public properties to
* facilitate complex interactions.
*
* ```ts
* class MyElement {
* @property({ type: Boolean })
* clicked = false;
* }
* ```
* @category Decorator
* @ExportDecoratedItems
*/
export function property(options) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (protoOrDescriptor, name) => name !== undefined
? legacyProperty(options, protoOrDescriptor, name)
: standardProperty(options, protoOrDescriptor);
}
//# sourceMappingURL=property.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import { ReactiveElement } from '../reactive-element.js';
/**
* A property decorator that converts a class property into a getter
* that executes a querySelectorAll on the element's renderRoot.
*
* @param selector A DOMString containing one or more selectors to match.
*
* See:
* https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
*
* ```ts
* class MyElement {
* @queryAll('div')
* divs: NodeListOf<HTMLDivElement>;
*
* render() {
* return html`
* <div id="first"></div>
* <div id="second"></div>
* `;
* }
* }
* ```
* @category Decorator
*/
export declare function queryAll(selector: string): (protoOrDescriptor: import("./base.js").ClassElement | import("./base.js").Interface<ReactiveElement>, name?: PropertyKey | undefined) => any;
//# sourceMappingURL=query-all.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query-all.d.ts","sourceRoot":"","sources":["../../src/decorators/query-all.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAGvD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,iJAUxC"}

View File

@@ -0,0 +1,43 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import { decorateProperty } from './base.js';
/**
* A property decorator that converts a class property into a getter
* that executes a querySelectorAll on the element's renderRoot.
*
* @param selector A DOMString containing one or more selectors to match.
*
* See:
* https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
*
* ```ts
* class MyElement {
* @queryAll('div')
* divs: NodeListOf<HTMLDivElement>;
*
* render() {
* return html`
* <div id="first"></div>
* <div id="second"></div>
* `;
* }
* }
* ```
* @category Decorator
*/
export function queryAll(selector) {
return decorateProperty({
descriptor: (_name) => ({
get() {
var _a, _b;
return (_b = (_a = this.renderRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selector)) !== null && _b !== void 0 ? _b : [];
},
enumerable: true,
configurable: true,
}),
});
}
//# sourceMappingURL=query-all.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query-all.js","sourceRoot":"","sources":["../../src/decorators/query-all.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,QAAQ,CAAC,QAAgB;IACvC,OAAO,gBAAgB,CAAC;QACtB,UAAU,EAAE,CAAC,KAAkB,EAAE,EAAE,CAAC,CAAC;YACnC,GAAG;;gBACD,OAAO,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,gBAAgB,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAAC;YAC3D,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC;KACH,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {ReactiveElement} from '../reactive-element.js';\nimport {decorateProperty} from './base.js';\n\n/**\n * A property decorator that converts a class property into a getter\n * that executes a querySelectorAll on the element's renderRoot.\n *\n * @param selector A DOMString containing one or more selectors to match.\n *\n * See:\n * https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll\n *\n * ```ts\n * class MyElement {\n * @queryAll('div')\n * divs: NodeListOf<HTMLDivElement>;\n *\n * render() {\n * return html`\n * <div id=\"first\"></div>\n * <div id=\"second\"></div>\n * `;\n * }\n * }\n * ```\n * @category Decorator\n */\nexport function queryAll(selector: string) {\n return decorateProperty({\n descriptor: (_name: PropertyKey) => ({\n get(this: ReactiveElement) {\n return this.renderRoot?.querySelectorAll(selector) ?? [];\n },\n enumerable: true,\n configurable: true,\n }),\n });\n}\n"]}

View File

@@ -0,0 +1,50 @@
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import type { ReactiveElement } from '../reactive-element.js';
import type { QueryAssignedNodesOptions } from './query-assigned-nodes.js';
/**
* Options for the {@linkcode queryAssignedElements} decorator. Extends the
* options that can be passed into
* [HTMLSlotElement.assignedElements](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedElements).
*/
export interface QueryAssignedElementsOptions extends QueryAssignedNodesOptions {
/**
* CSS selector used to filter the elements returned. For example, a selector
* of `".item"` will only include elements with the `item` class.
*/
selector?: string;
}
/**
* A property decorator that converts a class property into a getter that
* returns the `assignedElements` of the given `slot`. Provides a declarative
* way to use
* [`HTMLSlotElement.assignedElements`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedElements).
*
* Can be passed an optional {@linkcode QueryAssignedElementsOptions} object.
*
* Example usage:
* ```ts
* class MyElement {
* @queryAssignedElements({ slot: 'list' })
* listItems!: Array<HTMLElement>;
* @queryAssignedElements()
* unnamedSlotEls!: Array<HTMLElement>;
*
* render() {
* return html`
* <slot name="list"></slot>
* <slot></slot>
* `;
* }
* }
* ```
*
* Note, the type of this property should be annotated as `Array<HTMLElement>`.
*
* @category Decorator
*/
export declare function queryAssignedElements(options?: QueryAssignedElementsOptions): (protoOrDescriptor: import("./base.js").ClassElement | import("./base.js").Interface<ReactiveElement>, name?: PropertyKey | undefined) => any;
//# sourceMappingURL=query-assigned-elements.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query-assigned-elements.d.ts","sourceRoot":"","sources":["../../src/decorators/query-assigned-elements.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,2BAA2B,CAAC;AAmBzE;;;;GAIG;AACH,MAAM,WAAW,4BACf,SAAQ,yBAAyB;IACjC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,4BAA4B,iJAmB3E"}

View File

@@ -0,0 +1,72 @@
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
var _a;
/*
* IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all
* property decorators (but not class decorators) in this file that have
* an @ExportDecoratedItems annotation must be defined as a regular function,
* not an arrow function.
*/
import { decorateProperty } from './base.js';
const NODE_MODE = false;
const global = NODE_MODE ? globalThis : window;
/**
* A tiny module scoped polyfill for HTMLSlotElement.assignedElements.
*/
const slotAssignedElements = ((_a = global.HTMLSlotElement) === null || _a === void 0 ? void 0 : _a.prototype.assignedElements) != null
? (slot, opts) => slot.assignedElements(opts)
: (slot, opts) => slot
.assignedNodes(opts)
.filter((node) => node.nodeType === Node.ELEMENT_NODE);
/**
* A property decorator that converts a class property into a getter that
* returns the `assignedElements` of the given `slot`. Provides a declarative
* way to use
* [`HTMLSlotElement.assignedElements`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedElements).
*
* Can be passed an optional {@linkcode QueryAssignedElementsOptions} object.
*
* Example usage:
* ```ts
* class MyElement {
* @queryAssignedElements({ slot: 'list' })
* listItems!: Array<HTMLElement>;
* @queryAssignedElements()
* unnamedSlotEls!: Array<HTMLElement>;
*
* render() {
* return html`
* <slot name="list"></slot>
* <slot></slot>
* `;
* }
* }
* ```
*
* Note, the type of this property should be annotated as `Array<HTMLElement>`.
*
* @category Decorator
*/
export function queryAssignedElements(options) {
const { slot, selector } = options !== null && options !== void 0 ? options : {};
return decorateProperty({
descriptor: (_name) => ({
get() {
var _a;
const slotSelector = `slot${slot ? `[name=${slot}]` : ':not([name])'}`;
const slotEl = (_a = this.renderRoot) === null || _a === void 0 ? void 0 : _a.querySelector(slotSelector);
const elements = slotEl != null ? slotAssignedElements(slotEl, options) : [];
if (selector) {
return elements.filter((node) => node.matches(selector));
}
return elements;
},
enumerable: true,
configurable: true,
}),
});
}
//# sourceMappingURL=query-assigned-elements.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query-assigned-elements.js","sourceRoot":"","sources":["../../src/decorators/query-assigned-elements.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH;;;;;GAKG;AAEH,OAAO,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAK3C,MAAM,SAAS,GAAG,KAAK,CAAC;AACxB,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;AAE/C;;GAEG;AACH,MAAM,oBAAoB,GACxB,CAAA,MAAA,MAAM,CAAC,eAAe,0CAAE,SAAS,CAAC,gBAAgB,KAAI,IAAI;IACxD,CAAC,CAAC,CAAC,IAAqB,EAAE,IAA2B,EAAE,EAAE,CACrD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;IAC/B,CAAC,CAAC,CAAC,IAAqB,EAAE,IAA2B,EAAE,EAAE,CACrD,IAAI;SACD,aAAa,CAAC,IAAI,CAAC;SACnB,MAAM,CACL,CAAC,IAAI,EAAmB,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,CAC/D,CAAC;AAgBZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAsC;IAC1E,MAAM,EAAC,IAAI,EAAE,QAAQ,EAAC,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IACvC,OAAO,gBAAgB,CAAC;QACtB,UAAU,EAAE,CAAC,KAAkB,EAAE,EAAE,CAAC,CAAC;YACnC,GAAG;;gBACD,MAAM,YAAY,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;gBACvE,MAAM,MAAM,GACV,MAAA,IAAI,CAAC,UAAU,0CAAE,aAAa,CAAkB,YAAY,CAAC,CAAC;gBAChE,MAAM,QAAQ,GACZ,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC9D,IAAI,QAAQ,EAAE;oBACZ,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;iBAC1D;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC;KACH,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {decorateProperty} from './base.js';\n\nimport type {ReactiveElement} from '../reactive-element.js';\nimport type {QueryAssignedNodesOptions} from './query-assigned-nodes.js';\n\nconst NODE_MODE = false;\nconst global = NODE_MODE ? globalThis : window;\n\n/**\n * A tiny module scoped polyfill for HTMLSlotElement.assignedElements.\n */\nconst slotAssignedElements =\n global.HTMLSlotElement?.prototype.assignedElements != null\n ? (slot: HTMLSlotElement, opts?: AssignedNodesOptions) =>\n slot.assignedElements(opts)\n : (slot: HTMLSlotElement, opts?: AssignedNodesOptions) =>\n slot\n .assignedNodes(opts)\n .filter(\n (node): node is Element => node.nodeType === Node.ELEMENT_NODE\n );\n\n/**\n * Options for the {@linkcode queryAssignedElements} decorator. Extends the\n * options that can be passed into\n * [HTMLSlotElement.assignedElements](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedElements).\n */\nexport interface QueryAssignedElementsOptions\n extends QueryAssignedNodesOptions {\n /**\n * CSS selector used to filter the elements returned. For example, a selector\n * of `\".item\"` will only include elements with the `item` class.\n */\n selector?: string;\n}\n\n/**\n * A property decorator that converts a class property into a getter that\n * returns the `assignedElements` of the given `slot`. Provides a declarative\n * way to use\n * [`HTMLSlotElement.assignedElements`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedElements).\n *\n * Can be passed an optional {@linkcode QueryAssignedElementsOptions} object.\n *\n * Example usage:\n * ```ts\n * class MyElement {\n * @queryAssignedElements({ slot: 'list' })\n * listItems!: Array<HTMLElement>;\n * @queryAssignedElements()\n * unnamedSlotEls!: Array<HTMLElement>;\n *\n * render() {\n * return html`\n * <slot name=\"list\"></slot>\n * <slot></slot>\n * `;\n * }\n * }\n * ```\n *\n * Note, the type of this property should be annotated as `Array<HTMLElement>`.\n *\n * @category Decorator\n */\nexport function queryAssignedElements(options?: QueryAssignedElementsOptions) {\n const {slot, selector} = options ?? {};\n return decorateProperty({\n descriptor: (_name: PropertyKey) => ({\n get(this: ReactiveElement) {\n const slotSelector = `slot${slot ? `[name=${slot}]` : ':not([name])'}`;\n const slotEl =\n this.renderRoot?.querySelector<HTMLSlotElement>(slotSelector);\n const elements =\n slotEl != null ? slotAssignedElements(slotEl, options) : [];\n if (selector) {\n return elements.filter((node) => node.matches(selector));\n }\n return elements;\n },\n enumerable: true,\n configurable: true,\n }),\n });\n}\n"]}

View File

@@ -0,0 +1,80 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* Options for the {@linkcode queryAssignedNodes} decorator. Extends the options
* that can be passed into [HTMLSlotElement.assignedNodes](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedNodes).
*/
export interface QueryAssignedNodesOptions extends AssignedNodesOptions {
/**
* Name of the slot to query. Leave empty for the default slot.
*/
slot?: string;
}
declare type TSDecoratorReturnType = void | any;
/**
* A property decorator that converts a class property into a getter that
* returns the `assignedNodes` of the given `slot`.
*
* Can be passed an optional {@linkcode QueryAssignedNodesOptions} object.
*
* Example usage:
* ```ts
* class MyElement {
* @queryAssignedNodes({slot: 'list', flatten: true})
* listItems!: Array<Node>;
*
* render() {
* return html`
* <slot name="list"></slot>
* `;
* }
* }
* ```
*
* Note the type of this property should be annotated as `Array<Node>`.
*
* @category Decorator
*/
export declare function queryAssignedNodes(options?: QueryAssignedNodesOptions): TSDecoratorReturnType;
/**
* A property decorator that converts a class property into a getter that
* returns the `assignedNodes` of the given named `slot`.
*
* Example usage:
* ```ts
* class MyElement {
* @queryAssignedNodes('list', true, '.item')
* listItems!: Array<HTMLElement>;
*
* render() {
* return html`
* <slot name="list"></slot>
* `;
* }
* }
* ```
*
* Note the type of this property should be annotated as `Array<Node>` if used
* without a `selector` or `Array<HTMLElement>` if a selector is provided.
* Use {@linkcode queryAssignedElements @queryAssignedElements} to list only
* elements, and optionally filter the element list using a CSS selector.
*
* @param slotName A string name of the slot.
* @param flatten A boolean which when true flattens the assigned nodes,
* meaning any assigned nodes that are slot elements are replaced with their
* assigned nodes.
* @param selector A CSS selector used to filter the elements returned.
*
* @category Decorator
* @deprecated Prefer passing in a single options object, i.e. `{slot: 'list'}`.
* If using `selector` please use `@queryAssignedElements`.
* `@queryAssignedNodes('', false, '.item')` is functionally identical to
* `@queryAssignedElements({slot: '', flatten: false, selector: '.item'})` or
* `@queryAssignedElements({selector: '.item'})`.
*/
export declare function queryAssignedNodes(slotName?: string, flatten?: boolean, selector?: string): TSDecoratorReturnType;
export {};
//# sourceMappingURL=query-assigned-nodes.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query-assigned-nodes.d.ts","sourceRoot":"","sources":["../../src/decorators/query-assigned-nodes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH;;;GAGG;AACH,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAID,aAAK,qBAAqB,GAAG,IAAI,GAAG,GAAG,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,CAAC,EAAE,yBAAyB,GAClC,qBAAqB,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,OAAO,EACjB,QAAQ,CAAC,EAAE,MAAM,GAChB,qBAAqB,CAAC"}

View File

@@ -0,0 +1,47 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all
* property decorators (but not class decorators) in this file that have
* an @ExportDecoratedItems annotation must be defined as a regular function,
* not an arrow function.
*/
import { decorateProperty } from './base.js';
import { queryAssignedElements } from './query-assigned-elements.js';
export function queryAssignedNodes(slotOrOptions, flatten, selector) {
// Normalize the overloaded arguments.
let slot = slotOrOptions;
let assignedNodesOptions;
if (typeof slotOrOptions === 'object') {
slot = slotOrOptions.slot;
assignedNodesOptions = slotOrOptions;
}
else {
assignedNodesOptions = { flatten };
}
// For backwards compatibility, queryAssignedNodes with a selector behaves
// exactly like queryAssignedElements with a selector.
if (selector) {
return queryAssignedElements({
slot: slot,
flatten,
selector,
});
}
return decorateProperty({
descriptor: (_name) => ({
get() {
var _a, _b;
const slotSelector = `slot${slot ? `[name=${slot}]` : ':not([name])'}`;
const slotEl = (_a = this.renderRoot) === null || _a === void 0 ? void 0 : _a.querySelector(slotSelector);
return (_b = slotEl === null || slotEl === void 0 ? void 0 : slotEl.assignedNodes(assignedNodesOptions)) !== null && _b !== void 0 ? _b : [];
},
enumerable: true,
configurable: true,
}),
});
}
//# sourceMappingURL=query-assigned-nodes.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,40 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import { ReactiveElement } from '../reactive-element.js';
/**
* A property decorator that converts a class property into a getter that
* returns a promise that resolves to the result of a querySelector on the
* element's renderRoot done after the element's `updateComplete` promise
* resolves. When the queried property may change with element state, this
* decorator can be used instead of requiring users to await the
* `updateComplete` before accessing the property.
*
* @param selector A DOMString containing one or more selectors to match.
*
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
*
* ```ts
* class MyElement {
* @queryAsync('#first')
* first: Promise<HTMLDivElement>;
*
* render() {
* return html`
* <div id="first"></div>
* <div id="second"></div>
* `;
* }
* }
*
* // external usage
* async doSomethingWithFirst() {
* (await aMyElement.first).doSomething();
* }
* ```
* @category Decorator
*/
export declare function queryAsync(selector: string): (protoOrDescriptor: import("./base.js").ClassElement | import("./base.js").Interface<ReactiveElement>, name?: PropertyKey | undefined) => any;
//# sourceMappingURL=query-async.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query-async.d.ts","sourceRoot":"","sources":["../../src/decorators/query-async.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAQvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,iJAW1C"}

View File

@@ -0,0 +1,57 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import { decorateProperty } from './base.js';
// Note, in the future, we may extend this decorator to support the use case
// where the queried element may need to do work to become ready to interact
// with (e.g. load some implementation code). If so, we might elect to
// add a second argument defining a function that can be run to make the
// queried element loaded/updated/ready.
/**
* A property decorator that converts a class property into a getter that
* returns a promise that resolves to the result of a querySelector on the
* element's renderRoot done after the element's `updateComplete` promise
* resolves. When the queried property may change with element state, this
* decorator can be used instead of requiring users to await the
* `updateComplete` before accessing the property.
*
* @param selector A DOMString containing one or more selectors to match.
*
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
*
* ```ts
* class MyElement {
* @queryAsync('#first')
* first: Promise<HTMLDivElement>;
*
* render() {
* return html`
* <div id="first"></div>
* <div id="second"></div>
* `;
* }
* }
*
* // external usage
* async doSomethingWithFirst() {
* (await aMyElement.first).doSomething();
* }
* ```
* @category Decorator
*/
export function queryAsync(selector) {
return decorateProperty({
descriptor: (_name) => ({
async get() {
var _a;
await this.updateComplete;
return (_a = this.renderRoot) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
},
enumerable: true,
configurable: true,
}),
});
}
//# sourceMappingURL=query-async.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query-async.js","sourceRoot":"","sources":["../../src/decorators/query-async.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAE3C,4EAA4E;AAC5E,4EAA4E;AAC5E,sEAAsE;AACtE,wEAAwE;AACxE,wCAAwC;AACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,OAAO,gBAAgB,CAAC;QACtB,UAAU,EAAE,CAAC,KAAkB,EAAE,EAAE,CAAC,CAAC;YACnC,KAAK,CAAC,GAAG;;gBACP,MAAM,IAAI,CAAC,cAAc,CAAC;gBAC1B,OAAO,MAAA,IAAI,CAAC,UAAU,0CAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;YAClD,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC;KACH,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {ReactiveElement} from '../reactive-element.js';\nimport {decorateProperty} from './base.js';\n\n// Note, in the future, we may extend this decorator to support the use case\n// where the queried element may need to do work to become ready to interact\n// with (e.g. load some implementation code). If so, we might elect to\n// add a second argument defining a function that can be run to make the\n// queried element loaded/updated/ready.\n/**\n * A property decorator that converts a class property into a getter that\n * returns a promise that resolves to the result of a querySelector on the\n * element's renderRoot done after the element's `updateComplete` promise\n * resolves. When the queried property may change with element state, this\n * decorator can be used instead of requiring users to await the\n * `updateComplete` before accessing the property.\n *\n * @param selector A DOMString containing one or more selectors to match.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector\n *\n * ```ts\n * class MyElement {\n * @queryAsync('#first')\n * first: Promise<HTMLDivElement>;\n *\n * render() {\n * return html`\n * <div id=\"first\"></div>\n * <div id=\"second\"></div>\n * `;\n * }\n * }\n *\n * // external usage\n * async doSomethingWithFirst() {\n * (await aMyElement.first).doSomething();\n * }\n * ```\n * @category Decorator\n */\nexport function queryAsync(selector: string) {\n return decorateProperty({\n descriptor: (_name: PropertyKey) => ({\n async get(this: ReactiveElement) {\n await this.updateComplete;\n return this.renderRoot?.querySelector(selector);\n },\n enumerable: true,\n configurable: true,\n }),\n });\n}\n"]}

View File

@@ -0,0 +1,33 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import { ReactiveElement } from '../reactive-element.js';
/**
* A property decorator that converts a class property into a getter that
* executes a querySelector on the element's renderRoot.
*
* @param selector A DOMString containing one or more selectors to match.
* @param cache An optional boolean which when true performs the DOM query only
* once and caches the result.
*
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
*
* ```ts
* class MyElement {
* @query('#first')
* first: HTMLDivElement;
*
* render() {
* return html`
* <div id="first"></div>
* <div id="second"></div>
* `;
* }
* }
* ```
* @category Decorator
*/
export declare function query(selector: string, cache?: boolean): (protoOrDescriptor: import("./base.js").ClassElement | import("./base.js").Interface<ReactiveElement>, name?: PropertyKey | undefined) => any;
//# sourceMappingURL=query.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/decorators/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,iJA8BtD"}

View File

@@ -0,0 +1,57 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import { decorateProperty } from './base.js';
/**
* A property decorator that converts a class property into a getter that
* executes a querySelector on the element's renderRoot.
*
* @param selector A DOMString containing one or more selectors to match.
* @param cache An optional boolean which when true performs the DOM query only
* once and caches the result.
*
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
*
* ```ts
* class MyElement {
* @query('#first')
* first: HTMLDivElement;
*
* render() {
* return html`
* <div id="first"></div>
* <div id="second"></div>
* `;
* }
* }
* ```
* @category Decorator
*/
export function query(selector, cache) {
return decorateProperty({
descriptor: (name) => {
const descriptor = {
get() {
var _a, _b;
return (_b = (_a = this.renderRoot) === null || _a === void 0 ? void 0 : _a.querySelector(selector)) !== null && _b !== void 0 ? _b : null;
},
enumerable: true,
configurable: true,
};
if (cache) {
const key = typeof name === 'symbol' ? Symbol() : `__${name}`;
descriptor.get = function () {
var _a, _b;
if (this[key] === undefined) {
this[key] = (_b = (_a = this.renderRoot) === null || _a === void 0 ? void 0 : _a.querySelector(selector)) !== null && _b !== void 0 ? _b : null;
}
return this[key];
};
}
return descriptor;
},
});
}
//# sourceMappingURL=query.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/decorators/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,KAAe;IACrD,OAAO,gBAAgB,CAAC;QACtB,UAAU,EAAE,CAAC,IAAiB,EAAE,EAAE;YAChC,MAAM,UAAU,GAAG;gBACjB,GAAG;;oBACD,OAAO,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,aAAa,CAAC,QAAQ,CAAC,mCAAI,IAAI,CAAC;gBAC1D,CAAC;gBACD,UAAU,EAAE,IAAI;gBAChB,YAAY,EAAE,IAAI;aACnB,CAAC;YACF,IAAI,KAAK,EAAE;gBACT,MAAM,GAAG,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC9D,UAAU,CAAC,GAAG,GAAG;;oBACf,IACG,IAAmD,CAClD,GAAa,CACd,KAAK,SAAS,EACf;wBACC,IAAmD,CAClD,GAAa,CACd,GAAG,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,aAAa,CAAC,QAAQ,CAAC,mCAAI,IAAI,CAAC;qBACtD;oBACD,OAAQ,IAAmD,CACzD,GAAa,CACd,CAAC;gBACJ,CAAC,CAAC;aACH;YACD,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {ReactiveElement} from '../reactive-element.js';\nimport {decorateProperty} from './base.js';\n\n/**\n * A property decorator that converts a class property into a getter that\n * executes a querySelector on the element's renderRoot.\n *\n * @param selector A DOMString containing one or more selectors to match.\n * @param cache An optional boolean which when true performs the DOM query only\n * once and caches the result.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector\n *\n * ```ts\n * class MyElement {\n * @query('#first')\n * first: HTMLDivElement;\n *\n * render() {\n * return html`\n * <div id=\"first\"></div>\n * <div id=\"second\"></div>\n * `;\n * }\n * }\n * ```\n * @category Decorator\n */\nexport function query(selector: string, cache?: boolean) {\n return decorateProperty({\n descriptor: (name: PropertyKey) => {\n const descriptor = {\n get(this: ReactiveElement) {\n return this.renderRoot?.querySelector(selector) ?? null;\n },\n enumerable: true,\n configurable: true,\n };\n if (cache) {\n const key = typeof name === 'symbol' ? Symbol() : `__${name}`;\n descriptor.get = function (this: ReactiveElement) {\n if (\n (this as unknown as {[key: string]: Element | null})[\n key as string\n ] === undefined\n ) {\n (this as unknown as {[key: string]: Element | null})[\n key as string\n ] = this.renderRoot?.querySelector(selector) ?? null;\n }\n return (this as unknown as {[key: string]: Element | null})[\n key as string\n ];\n };\n }\n return descriptor;\n },\n });\n}\n"]}

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
export interface InternalPropertyDeclaration<Type = unknown> {
/**
* A function that indicates if a property should be considered changed when
* it is set. The function should take the `newValue` and `oldValue` and
* return `true` if an update should be requested.
*/
hasChanged?(value: Type, oldValue: Type): boolean;
}
/**
* Declares a private or protected reactive property that still triggers
* updates to the element when it changes. It does not reflect from the
* corresponding attribute.
*
* Properties declared this way must not be used from HTML or HTML templating
* systems, they're solely for properties internal to the element. These
* properties may be renamed by optimization tools like closure compiler.
* @category Decorator
*/
export declare function state(options?: InternalPropertyDeclaration): (protoOrDescriptor: Object | import("./base.js").ClassElement, name?: PropertyKey | undefined) => any;
//# sourceMappingURL=state.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/decorators/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,MAAM,WAAW,2BAA2B,CAAC,IAAI,GAAG,OAAO;IACzD;;;;OAIG;IACH,UAAU,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC;CACnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,2BAA2B,yGAK1D"}

View File

@@ -0,0 +1,29 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all
* property decorators (but not class decorators) in this file that have
* an @ExportDecoratedItems annotation must be defined as a regular function,
* not an arrow function.
*/
import { property } from './property.js';
/**
* Declares a private or protected reactive property that still triggers
* updates to the element when it changes. It does not reflect from the
* corresponding attribute.
*
* Properties declared this way must not be used from HTML or HTML templating
* systems, they're solely for properties internal to the element. These
* properties may be renamed by optimization tools like closure compiler.
* @category Decorator
*/
export function state(options) {
return property({
...options,
state: true,
});
}
//# sourceMappingURL=state.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/decorators/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAWvC;;;;;;;;;GASG;AACH,MAAM,UAAU,KAAK,CAAC,OAAqC;IACzD,OAAO,QAAQ,CAAC;QACd,GAAG,OAAO;QACV,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/*\n * IMPORTANT: For compatibility with tsickle and the Closure JS compiler, all\n * property decorators (but not class decorators) in this file that have\n * an @ExportDecoratedItems annotation must be defined as a regular function,\n * not an arrow function.\n */\n\nimport {property} from './property.js';\n\nexport interface InternalPropertyDeclaration<Type = unknown> {\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n}\n\n/**\n * Declares a private or protected reactive property that still triggers\n * updates to the element when it changes. It does not reflect from the\n * corresponding attribute.\n *\n * Properties declared this way must not be used from HTML or HTML templating\n * systems, they're solely for properties internal to the element. These\n * properties may be renamed by optimization tools like closure compiler.\n * @category Decorator\n */\nexport function state(options?: InternalPropertyDeclaration) {\n return property({\n ...options,\n state: true,\n });\n}\n"]}

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* ReactiveElement patch to support browsers without native web components.
*
* This module should be used in addition to loading the web components
* polyfills via @webcomponents/webcomponentjs. When using those polyfills
* support for polyfilled Shadow DOM is automatic via the ShadyDOM polyfill, but
* support for Shadow DOM like css scoping is opt-in. This module uses ShadyCSS
* to scope styles defined via the `static styles` property.
*
* @packageDocumentation
*/
export {};
//# sourceMappingURL=polyfill-support.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"polyfill-support.d.ts","sourceRoot":"","sources":["../src/polyfill-support.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC"}

View File

@@ -0,0 +1,99 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
var _a, _b;
var SCOPED = '__scoped';
// Note, explicitly use `var` here so that this can be re-defined when
// bundled.
// eslint-disable-next-line no-var
var DEV_MODE = true;
var polyfillSupport = function (_a) {
var ReactiveElement = _a.ReactiveElement;
// polyfill-support is only needed if ShadyCSS or the ApplyShim is in use
// We test at the point of patching, which makes it safe to load
// webcomponentsjs and polyfill-support in either order
if (window.ShadyCSS === undefined ||
(window.ShadyCSS.nativeShadow && !window.ShadyCSS.ApplyShim)) {
return;
}
// console.log(
// '%c Making ReactiveElement compatible with ShadyDOM/CSS.',
// 'color: lightgreen; font-style: italic'
// );
var elementProto = ReactiveElement.prototype;
// In noPatch mode, patch the ReactiveElement prototype so that no
// ReactiveElements must be wrapped.
if (window.ShadyDOM &&
window.ShadyDOM.inUse &&
window.ShadyDOM.noPatch === true) {
window.ShadyDOM.patchElementProto(elementProto);
}
/**
* Patch to apply adoptedStyleSheets via ShadyCSS
*/
var createRenderRoot = elementProto.createRenderRoot;
elementProto.createRenderRoot = function () {
var _a, _b, _c;
// Pass the scope to render options so that it gets to lit-html for proper
// scoping via ShadyCSS.
var name = this.localName;
// If using native Shadow DOM must adoptStyles normally,
// otherwise do nothing.
if (window.ShadyCSS.nativeShadow) {
return createRenderRoot.call(this);
}
else {
if (!this.constructor.hasOwnProperty(SCOPED)) {
this.constructor[SCOPED] =
true;
// Use ShadyCSS's `prepareAdoptedCssText` to shim adoptedStyleSheets.
var css = this.constructor.elementStyles.map(function (v) {
return v instanceof CSSStyleSheet
? Array.from(v.cssRules).reduce(function (a, r) { return (a += r.cssText); }, '')
: v.cssText;
});
(_b = (_a = window.ShadyCSS) === null || _a === void 0 ? void 0 : _a.ScopingShim) === null || _b === void 0 ? void 0 : _b.prepareAdoptedCssText(css, name);
if (this.constructor._$handlesPrepareStyles === undefined) {
window.ShadyCSS.prepareTemplateStyles(document.createElement('template'), name);
}
}
return ((_c = this.shadowRoot) !== null && _c !== void 0 ? _c : this.attachShadow(this.constructor
.shadowRootOptions));
}
};
/**
* Patch connectedCallback to apply ShadyCSS custom properties shimming.
*/
var connectedCallback = elementProto.connectedCallback;
elementProto.connectedCallback = function () {
connectedCallback.call(this);
// Note, must do first update separately so that we're ensured
// that rendering has completed before calling this.
if (this.hasUpdated) {
window.ShadyCSS.styleElement(this);
}
};
/**
* Patch update to apply ShadyCSS custom properties shimming for first
* update.
*/
var didUpdate = elementProto._$didUpdate;
elementProto._$didUpdate = function (changedProperties) {
// Note, must do first update here so rendering has completed before
// calling this and styles are correct by updated/firstUpdated.
if (!this.hasUpdated) {
window.ShadyCSS.styleElement(this);
}
didUpdate.call(this, changedProperties);
};
};
if (DEV_MODE) {
(_a = globalThis.reactiveElementPolyfillSupportDevMode) !== null && _a !== void 0 ? _a : (globalThis.reactiveElementPolyfillSupportDevMode = polyfillSupport);
}
else {
(_b = globalThis.reactiveElementPolyfillSupport) !== null && _b !== void 0 ? _b : (globalThis.reactiveElementPolyfillSupport = polyfillSupport);
}
export {};
//# sourceMappingURL=polyfill-support.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,77 @@
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* An object that can host Reactive Controllers and call their lifecycle
* callbacks.
*/
export interface ReactiveControllerHost {
/**
* Adds a controller to the host, which sets up the controller's lifecycle
* methods to be called with the host's lifecycle.
*/
addController(controller: ReactiveController): void;
/**
* Removes a controller from the host.
*/
removeController(controller: ReactiveController): void;
/**
* Requests a host update which is processed asynchronously. The update can
* be waited on via the `updateComplete` property.
*/
requestUpdate(): void;
/**
* Returns a Promise that resolves when the host has completed updating.
* The Promise value is a boolean that is `true` if the element completed the
* update without triggering another update. The Promise result is `false` if
* a property was set inside `updated()`. If the Promise is rejected, an
* exception was thrown during the update.
*
* @return A promise of a boolean that indicates if the update resolved
* without triggering another update.
*/
readonly updateComplete: Promise<boolean>;
}
/**
* A Reactive Controller is an object that enables sub-component code
* organization and reuse by aggregating the state, behavior, and lifecycle
* hooks related to a single feature.
*
* Controllers are added to a host component, or other object that implements
* the `ReactiveControllerHost` interface, via the `addController()` method.
* They can hook their host components's lifecycle by implementing one or more
* of the lifecycle callbacks, or initiate an update of the host component by
* calling `requestUpdate()` on the host.
*/
export interface ReactiveController {
/**
* Called when the host is connected to the component tree. For custom
* element hosts, this corresponds to the `connectedCallback()` lifecycle,
* which is only called when the component is connected to the document.
*/
hostConnected?(): void;
/**
* Called when the host is disconnected from the component tree. For custom
* element hosts, this corresponds to the `disconnectedCallback()` lifecycle,
* which is called the host or an ancestor component is disconnected from the
* document.
*/
hostDisconnected?(): void;
/**
* Called during the client-side host update, just before the host calls
* its own update.
*
* Code in `update()` can depend on the DOM as it is not called in
* server-side rendering.
*/
hostUpdate?(): void;
/**
* Called after a host update, just before the host calls firstUpdated and
* updated. It is not called in server-side rendering.
*
*/
hostUpdated?(): void;
}
//# sourceMappingURL=reactive-controller.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"reactive-controller.d.ts","sourceRoot":"","sources":["../src/reactive-controller.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAEpD;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAEvD;;;OAGG;IACH,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;;;;;;OASG;IACH,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3C;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,aAAa,CAAC,IAAI,IAAI,CAAC;IAEvB;;;;;OAKG;IACH,gBAAgB,CAAC,IAAI,IAAI,CAAC;IAE1B;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,IAAI,CAAC;IAEpB;;;;OAIG;IACH,WAAW,CAAC,IAAI,IAAI,CAAC;CACtB"}

View File

@@ -0,0 +1,7 @@
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
export {};
//# sourceMappingURL=reactive-controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"reactive-controller.js","sourceRoot":"","sources":["../src/reactive-controller.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * An object that can host Reactive Controllers and call their lifecycle\n * callbacks.\n */\nexport interface ReactiveControllerHost {\n /**\n * Adds a controller to the host, which sets up the controller's lifecycle\n * methods to be called with the host's lifecycle.\n */\n addController(controller: ReactiveController): void;\n\n /**\n * Removes a controller from the host.\n */\n removeController(controller: ReactiveController): void;\n\n /**\n * Requests a host update which is processed asynchronously. The update can\n * be waited on via the `updateComplete` property.\n */\n requestUpdate(): void;\n\n /**\n * Returns a Promise that resolves when the host has completed updating.\n * The Promise value is a boolean that is `true` if the element completed the\n * update without triggering another update. The Promise result is `false` if\n * a property was set inside `updated()`. If the Promise is rejected, an\n * exception was thrown during the update.\n *\n * @return A promise of a boolean that indicates if the update resolved\n * without triggering another update.\n */\n readonly updateComplete: Promise<boolean>;\n}\n\n/**\n * A Reactive Controller is an object that enables sub-component code\n * organization and reuse by aggregating the state, behavior, and lifecycle\n * hooks related to a single feature.\n *\n * Controllers are added to a host component, or other object that implements\n * the `ReactiveControllerHost` interface, via the `addController()` method.\n * They can hook their host components's lifecycle by implementing one or more\n * of the lifecycle callbacks, or initiate an update of the host component by\n * calling `requestUpdate()` on the host.\n */\nexport interface ReactiveController {\n /**\n * Called when the host is connected to the component tree. For custom\n * element hosts, this corresponds to the `connectedCallback()` lifecycle,\n * which is only called when the component is connected to the document.\n */\n hostConnected?(): void;\n\n /**\n * Called when the host is disconnected from the component tree. For custom\n * element hosts, this corresponds to the `disconnectedCallback()` lifecycle,\n * which is called the host or an ancestor component is disconnected from the\n * document.\n */\n hostDisconnected?(): void;\n\n /**\n * Called during the client-side host update, just before the host calls\n * its own update.\n *\n * Code in `update()` can depend on the DOM as it is not called in\n * server-side rendering.\n */\n hostUpdate?(): void;\n\n /**\n * Called after a host update, just before the host calls firstUpdated and\n * updated. It is not called in server-side rendering.\n *\n */\n hostUpdated?(): void;\n}\n"]}

View File

@@ -0,0 +1,732 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* Use this module if you want to create your own base class extending
* {@link ReactiveElement}.
* @packageDocumentation
*/
import { CSSResultGroup, CSSResultOrNative } from './css-tag.js';
import type { ReactiveController, ReactiveControllerHost } from './reactive-controller.js';
export * from './css-tag.js';
export type { ReactiveController, ReactiveControllerHost, } from './reactive-controller.js';
/**
* Contains types that are part of the unstable debug API.
*
* Everything in this API is not stable and may change or be removed in the future,
* even on patch releases.
*/
export declare namespace ReactiveUnstable {
/**
* When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,
* we will emit 'lit-debug' events to window, with live details about the update and render
* lifecycle. These can be useful for writing debug tooling and visualizations.
*
* Please be aware that running with window.emitLitDebugLogEvents has performance overhead,
* making certain operations that are normally very cheap (like a no-op render) much slower,
* because we must copy data and dispatch events.
*/
namespace DebugLog {
type Entry = Update;
interface Update {
kind: 'update';
}
}
}
/**
* Converts property values to and from attribute values.
*/
export interface ComplexAttributeConverter<Type = unknown, TypeHint = unknown> {
/**
* Called to convert an attribute value to a property
* value.
*/
fromAttribute?(value: string | null, type?: TypeHint): Type;
/**
* Called to convert a property value to an attribute
* value.
*
* It returns unknown instead of string, to be compatible with
* https://github.com/WICG/trusted-types (and similar efforts).
*/
toAttribute?(value: Type, type?: TypeHint): unknown;
}
declare type AttributeConverter<Type = unknown, TypeHint = unknown> = ComplexAttributeConverter<Type> | ((value: string | null, type?: TypeHint) => Type);
/**
* Defines options for a property accessor.
*/
export interface PropertyDeclaration<Type = unknown, TypeHint = unknown> {
/**
* When set to `true`, indicates the property is internal private state. The
* property should not be set by users. When using TypeScript, this property
* should be marked as `private` or `protected`, and it is also a common
* practice to use a leading `_` in the name. The property is not added to
* `observedAttributes`.
*/
readonly state?: boolean;
/**
* Indicates how and whether the property becomes an observed attribute.
* If the value is `false`, the property is not added to `observedAttributes`.
* If true or absent, the lowercased property name is observed (e.g. `fooBar`
* becomes `foobar`). If a string, the string value is observed (e.g
* `attribute: 'foo-bar'`).
*/
readonly attribute?: boolean | string;
/**
* Indicates the type of the property. This is used only as a hint for the
* `converter` to determine how to convert the attribute
* to/from a property.
*/
readonly type?: TypeHint;
/**
* Indicates how to convert the attribute to/from a property. If this value
* is a function, it is used to convert the attribute value a the property
* value. If it's an object, it can have keys for `fromAttribute` and
* `toAttribute`. If no `toAttribute` function is provided and
* `reflect` is set to `true`, the property value is set directly to the
* attribute. A default `converter` is used if none is provided; it supports
* `Boolean`, `String`, `Number`, `Object`, and `Array`. Note,
* when a property changes and the converter is used to update the attribute,
* the property is never updated again as a result of the attribute changing,
* and vice versa.
*/
readonly converter?: AttributeConverter<Type, TypeHint>;
/**
* Indicates if the property should reflect to an attribute.
* If `true`, when the property is set, the attribute is set using the
* attribute name determined according to the rules for the `attribute`
* property option and the value of the property converted using the rules
* from the `converter` property option.
*/
readonly reflect?: boolean;
/**
* A function that indicates if a property should be considered changed when
* it is set. The function should take the `newValue` and `oldValue` and
* return `true` if an update should be requested.
*/
hasChanged?(value: Type, oldValue: Type): boolean;
/**
* Indicates whether an accessor will be created for this property. By
* default, an accessor will be generated for this property that requests an
* update when set. If this flag is `true`, no accessor will be created, and
* it will be the user's responsibility to call
* `this.requestUpdate(propertyName, oldValue)` to request an update when
* the property changes.
*/
readonly noAccessor?: boolean;
}
/**
* Map of properties to PropertyDeclaration options. For each property an
* accessor is made, and the property is processed according to the
* PropertyDeclaration options.
*/
export interface PropertyDeclarations {
readonly [key: string]: PropertyDeclaration;
}
declare type PropertyDeclarationMap = Map<PropertyKey, PropertyDeclaration>;
/**
* A Map of property keys to values.
*
* Takes an optional type parameter T, which when specified as a non-any,
* non-unknown type, will make the Map more strongly-typed, associating the map
* keys with their corresponding value type on T.
*
* Use `PropertyValues<this>` when overriding ReactiveElement.update() and
* other lifecycle methods in order to get stronger type-checking on keys
* and values.
*/
export declare type PropertyValues<T = any> = T extends object ? PropertyValueMap<T> : Map<PropertyKey, unknown>;
/**
* Do not use, instead prefer {@linkcode PropertyValues}.
*/
export interface PropertyValueMap<T> extends Map<PropertyKey, unknown> {
get<K extends keyof T>(k: K): T[K];
set<K extends keyof T>(key: K, value: T[K]): this;
has<K extends keyof T>(k: K): boolean;
delete<K extends keyof T>(k: K): boolean;
}
export declare const defaultConverter: ComplexAttributeConverter;
export interface HasChanged {
(value: unknown, old: unknown): boolean;
}
/**
* Change function that returns true if `value` is different from `oldValue`.
* This method is used as the default for a property's `hasChanged` function.
*/
export declare const notEqual: HasChanged;
/**
* The Closure JS Compiler doesn't currently have good support for static
* property semantics where "this" is dynamic (e.g.
* https://github.com/google/closure-compiler/issues/3177 and others) so we use
* this hack to bypass any rewriting by the compiler.
*/
declare const finalized = "finalized";
/**
* A string representing one of the supported dev mode warning categories.
*/
export declare type WarningKind = 'change-in-update' | 'migration';
export declare type Initializer = (element: ReactiveElement) => void;
/**
* Base element class which manages element properties and attributes. When
* properties change, the `update` method is asynchronously called. This method
* should be supplied by subclassers to render updates as desired.
* @noInheritDoc
*/
export declare abstract class ReactiveElement extends HTMLElement implements ReactiveControllerHost {
/**
* Read or set all the enabled warning categories for this class.
*
* This property is only used in development builds.
*
* @nocollapse
* @category dev-mode
*/
static enabledWarnings?: WarningKind[];
/**
* Enable the given warning category for this class.
*
* This method only exists in development builds, so it should be accessed
* with a guard like:
*
* ```ts
* // Enable for all ReactiveElement subclasses
* ReactiveElement.enableWarning?.('migration');
*
* // Enable for only MyElement and subclasses
* MyElement.enableWarning?.('migration');
* ```
*
* @nocollapse
* @category dev-mode
*/
static enableWarning?: (warningKind: WarningKind) => void;
/**
* Disable the given warning category for this class.
*
* This method only exists in development builds, so it should be accessed
* with a guard like:
*
* ```ts
* // Disable for all ReactiveElement subclasses
* ReactiveElement.disableWarning?.('migration');
*
* // Disable for only MyElement and subclasses
* MyElement.disableWarning?.('migration');
* ```
*
* @nocollapse
* @category dev-mode
*/
static disableWarning?: (warningKind: WarningKind) => void;
/**
* Adds an initializer function to the class that is called during instance
* construction.
*
* This is useful for code that runs against a `ReactiveElement`
* subclass, such as a decorator, that needs to do work for each
* instance, such as setting up a `ReactiveController`.
*
* ```ts
* const myDecorator = (target: typeof ReactiveElement, key: string) => {
* target.addInitializer((instance: ReactiveElement) => {
* // This is run during construction of the element
* new MyController(instance);
* });
* }
* ```
*
* Decorating a field will then cause each instance to run an initializer
* that adds a controller:
*
* ```ts
* class MyElement extends LitElement {
* @myDecorator foo;
* }
* ```
*
* Initializers are stored per-constructor. Adding an initializer to a
* subclass does not add it to a superclass. Since initializers are run in
* constructors, initializers will run in order of the class hierarchy,
* starting with superclasses and progressing to the instance's class.
*
* @nocollapse
*/
static addInitializer(initializer: Initializer): void;
static _initializers?: Initializer[];
/**
* Maps attribute names to properties; for example `foobar` attribute to
* `fooBar` property. Created lazily on user subclasses when finalizing the
* class.
* @nocollapse
*/
private static __attributeToPropertyMap;
/**
* Marks class as having finished creating properties.
*/
protected static [finalized]: boolean;
/**
* Memoized list of all element properties, including any superclass properties.
* Created lazily on user subclasses when finalizing the class.
* @nocollapse
* @category properties
*/
static elementProperties: PropertyDeclarationMap;
/**
* User-supplied object that maps property names to `PropertyDeclaration`
* objects containing options for configuring reactive properties. When
* a reactive property is set the element will update and render.
*
* By default properties are public fields, and as such, they should be
* considered as primarily settable by element users, either via attribute or
* the property itself.
*
* Generally, properties that are changed by the element should be private or
* protected fields and should use the `state: true` option. Properties
* marked as `state` do not reflect from the corresponding attribute
*
* However, sometimes element code does need to set a public property. This
* should typically only be done in response to user interaction, and an event
* should be fired informing the user; for example, a checkbox sets its
* `checked` property when clicked and fires a `changed` event. Mutating
* public properties should typically not be done for non-primitive (object or
* array) properties. In other cases when an element needs to manage state, a
* private property set with the `state: true` option should be used. When
* needed, state properties can be initialized via public properties to
* facilitate complex interactions.
* @nocollapse
* @category properties
*/
static properties: PropertyDeclarations;
/**
* Memoized list of all element styles.
* Created lazily on user subclasses when finalizing the class.
* @nocollapse
* @category styles
*/
static elementStyles: Array<CSSResultOrNative>;
/**
* Array of styles to apply to the element. The styles should be defined
* using the {@linkcode css} tag function, via constructible stylesheets, or
* imported from native CSS module scripts.
*
* Note on Content Security Policy:
*
* Element styles are implemented with `<style>` tags when the browser doesn't
* support adopted StyleSheets. To use such `<style>` tags with the style-src
* CSP directive, the style-src value must either include 'unsafe-inline' or
* `nonce-<base64-value>` with `<base64-value>` replaced be a server-generated
* nonce.
*
* To provide a nonce to use on generated `<style>` elements, set
* `window.litNonce` to a server-generated nonce in your page's HTML, before
* loading application code:
*
* ```html
* <script>
* // Generated and unique per request:
* window.litNonce = 'a1b2c3d4';
* </script>
* ```
* @nocollapse
* @category styles
*/
static styles?: CSSResultGroup;
/**
* The set of properties defined by this class that caused an accessor to be
* added during `createProperty`.
* @nocollapse
*/
private static __reactivePropertyKeys?;
/**
* Returns a list of attributes corresponding to the registered properties.
* @nocollapse
* @category attributes
*/
static get observedAttributes(): string[];
/**
* Creates a property accessor on the element prototype if one does not exist
* and stores a {@linkcode PropertyDeclaration} for the property with the
* given options. The property setter calls the property's `hasChanged`
* property option or uses a strict identity check to determine whether or not
* to request an update.
*
* This method may be overridden to customize properties; however,
* when doing so, it's important to call `super.createProperty` to ensure
* the property is setup correctly. This method calls
* `getPropertyDescriptor` internally to get a descriptor to install.
* To customize what properties do when they are get or set, override
* `getPropertyDescriptor`. To customize the options for a property,
* implement `createProperty` like this:
*
* ```ts
* static createProperty(name, options) {
* options = Object.assign(options, {myOption: true});
* super.createProperty(name, options);
* }
* ```
*
* @nocollapse
* @category properties
*/
static createProperty(name: PropertyKey, options?: PropertyDeclaration): void;
/**
* Returns a property descriptor to be defined on the given named property.
* If no descriptor is returned, the property will not become an accessor.
* For example,
*
* ```ts
* class MyElement extends LitElement {
* static getPropertyDescriptor(name, key, options) {
* const defaultDescriptor =
* super.getPropertyDescriptor(name, key, options);
* const setter = defaultDescriptor.set;
* return {
* get: defaultDescriptor.get,
* set(value) {
* setter.call(this, value);
* // custom action.
* },
* configurable: true,
* enumerable: true
* }
* }
* }
* ```
*
* @nocollapse
* @category properties
*/
protected static getPropertyDescriptor(name: PropertyKey, key: string | symbol, options: PropertyDeclaration): PropertyDescriptor | undefined;
/**
* Returns the property options associated with the given property.
* These options are defined with a `PropertyDeclaration` via the `properties`
* object or the `@property` decorator and are registered in
* `createProperty(...)`.
*
* Note, this method should be considered "final" and not overridden. To
* customize the options for a given property, override
* {@linkcode createProperty}.
*
* @nocollapse
* @final
* @category properties
*/
static getPropertyOptions(name: PropertyKey): PropertyDeclaration<unknown, unknown>;
/**
* Creates property accessors for registered properties, sets up element
* styling, and ensures any superclasses are also finalized. Returns true if
* the element was finalized.
* @nocollapse
*/
protected static finalize(): boolean;
/**
* Options used when calling `attachShadow`. Set this property to customize
* the options for the shadowRoot; for example, to create a closed
* shadowRoot: `{mode: 'closed'}`.
*
* Note, these options are used in `createRenderRoot`. If this method
* is customized, options should be respected if possible.
* @nocollapse
* @category rendering
*/
static shadowRootOptions: ShadowRootInit;
/**
* Takes the styles the user supplied via the `static styles` property and
* returns the array of styles to apply to the element.
* Override this method to integrate into a style management system.
*
* Styles are deduplicated preserving the _last_ instance in the list. This
* is a performance optimization to avoid duplicated styles that can occur
* especially when composing via subclassing. The last item is kept to try
* to preserve the cascade order with the assumption that it's most important
* that last added styles override previous styles.
*
* @nocollapse
* @category styles
*/
protected static finalizeStyles(styles?: CSSResultGroup): Array<CSSResultOrNative>;
/**
* Node or ShadowRoot into which element DOM should be rendered. Defaults
* to an open shadowRoot.
* @category rendering
*/
readonly renderRoot: HTMLElement | ShadowRoot;
/**
* Returns the property name for the given attribute `name`.
* @nocollapse
*/
private static __attributeNameForProperty;
private __instanceProperties?;
private __updatePromise;
/**
* True if there is a pending update as a result of calling `requestUpdate()`.
* Should only be read.
* @category updates
*/
isUpdatePending: boolean;
/**
* Is set to `true` after the first update. The element code cannot assume
* that `renderRoot` exists before the element `hasUpdated`.
* @category updates
*/
hasUpdated: boolean;
/**
* Map with keys of properties that should be reflected when updated.
*/
private __reflectingProperties?;
/**
* Name of currently reflecting property
*/
private __reflectingProperty;
/**
* Set of controllers.
*/
private __controllers?;
constructor();
/**
* Internal only override point for customizing work done when elements
* are constructed.
*/
private __initialize;
/**
* Registers a `ReactiveController` to participate in the element's reactive
* update cycle. The element automatically calls into any registered
* controllers during its lifecycle callbacks.
*
* If the element is connected when `addController()` is called, the
* controller's `hostConnected()` callback will be immediately called.
* @category controllers
*/
addController(controller: ReactiveController): void;
/**
* Removes a `ReactiveController` from the element.
* @category controllers
*/
removeController(controller: ReactiveController): void;
/**
* Fixes any properties set on the instance before upgrade time.
* Otherwise these would shadow the accessor and break these properties.
* The properties are stored in a Map which is played back after the
* constructor runs. Note, on very old versions of Safari (<=9) or Chrome
* (<=41), properties created for native platform properties like (`id` or
* `name`) may not have default values set in the element constructor. On
* these browsers native properties appear on instances and therefore their
* default value will overwrite any element default (e.g. if the element sets
* this.id = 'id' in the constructor, the 'id' will become '' since this is
* the native platform default).
*/
private __saveInstanceProperties;
/**
* Returns the node into which the element should render and by default
* creates and returns an open shadowRoot. Implement to customize where the
* element's DOM is rendered. For example, to render into the element's
* childNodes, return `this`.
*
* @return Returns a node into which to render.
* @category rendering
*/
protected createRenderRoot(): Element | ShadowRoot;
/**
* On first connection, creates the element's renderRoot, sets up
* element styling, and enables updating.
* @category lifecycle
*/
connectedCallback(): void;
/**
* Note, this method should be considered final and not overridden. It is
* overridden on the element instance with a function that triggers the first
* update.
* @category updates
*/
protected enableUpdating(_requestedUpdate: boolean): void;
/**
* Allows for `super.disconnectedCallback()` in extensions while
* reserving the possibility of making non-breaking feature additions
* when disconnecting at some point in the future.
* @category lifecycle
*/
disconnectedCallback(): void;
/**
* Synchronizes property values when attributes change.
*
* Specifically, when an attribute is set, the corresponding property is set.
* You should rarely need to implement this callback. If this method is
* overridden, `super.attributeChangedCallback(name, _old, value)` must be
* called.
*
* See [using the lifecycle callbacks](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks)
* on MDN for more information about the `attributeChangedCallback`.
* @category attributes
*/
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
private __propertyToAttribute;
/**
* Requests an update which is processed asynchronously. This should be called
* when an element should update based on some state not triggered by setting
* a reactive property. In this case, pass no arguments. It should also be
* called when manually implementing a property setter. In this case, pass the
* property `name` and `oldValue` to ensure that any configured property
* options are honored.
*
* @param name name of requesting property
* @param oldValue old value of requesting property
* @param options property options to use instead of the previously
* configured options
* @category updates
*/
requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: PropertyDeclaration): void;
/**
* Sets up the element to asynchronously update.
*/
private __enqueueUpdate;
/**
* Schedules an element update. You can override this method to change the
* timing of updates by returning a Promise. The update will await the
* returned Promise, and you should resolve the Promise to allow the update
* to proceed. If this method is overridden, `super.scheduleUpdate()`
* must be called.
*
* For instance, to schedule updates to occur just before the next frame:
*
* ```ts
* override protected async scheduleUpdate(): Promise<unknown> {
* await new Promise((resolve) => requestAnimationFrame(() => resolve()));
* super.scheduleUpdate();
* }
* ```
* @category updates
*/
protected scheduleUpdate(): void | Promise<unknown>;
/**
* Performs an element update. Note, if an exception is thrown during the
* update, `firstUpdated` and `updated` will not be called.
*
* Call `performUpdate()` to immediately process a pending update. This should
* generally not be needed, but it can be done in rare cases when you need to
* update synchronously.
*
* Note: To ensure `performUpdate()` synchronously completes a pending update,
* it should not be overridden. In LitElement 2.x it was suggested to override
* `performUpdate()` to also customizing update scheduling. Instead, you should now
* override `scheduleUpdate()`. For backwards compatibility with LitElement 2.x,
* scheduling updates via `performUpdate()` continues to work, but will make
* also calling `performUpdate()` to synchronously process updates difficult.
*
* @category updates
*/
protected performUpdate(): void | Promise<unknown>;
/**
* Invoked before `update()` to compute values needed during the update.
*
* Implement `willUpdate` to compute property values that depend on other
* properties and are used in the rest of the update process.
*
* ```ts
* willUpdate(changedProperties) {
* // only need to check changed properties for an expensive computation.
* if (changedProperties.has('firstName') || changedProperties.has('lastName')) {
* this.sha = computeSHA(`${this.firstName} ${this.lastName}`);
* }
* }
*
* render() {
* return html`SHA: ${this.sha}`;
* }
* ```
*
* @category updates
*/
protected willUpdate(_changedProperties: PropertyValues): void;
private __markUpdated;
/**
* Returns a Promise that resolves when the element has completed updating.
* The Promise value is a boolean that is `true` if the element completed the
* update without triggering another update. The Promise result is `false` if
* a property was set inside `updated()`. If the Promise is rejected, an
* exception was thrown during the update.
*
* To await additional asynchronous work, override the `getUpdateComplete`
* method. For example, it is sometimes useful to await a rendered element
* before fulfilling this Promise. To do this, first await
* `super.getUpdateComplete()`, then any subsequent state.
*
* @return A promise of a boolean that resolves to true if the update completed
* without triggering another update.
* @category updates
*/
get updateComplete(): Promise<boolean>;
/**
* Override point for the `updateComplete` promise.
*
* It is not safe to override the `updateComplete` getter directly due to a
* limitation in TypeScript which means it is not possible to call a
* superclass getter (e.g. `super.updateComplete.then(...)`) when the target
* language is ES5 (https://github.com/microsoft/TypeScript/issues/338).
* This method should be overridden instead. For example:
*
* ```ts
* class MyElement extends LitElement {
* override async getUpdateComplete() {
* const result = await super.getUpdateComplete();
* await this._myChild.updateComplete;
* return result;
* }
* }
* ```
*
* @return A promise of a boolean that resolves to true if the update completed
* without triggering another update.
* @category updates
*/
protected getUpdateComplete(): Promise<boolean>;
/**
* Controls whether or not `update()` should be called when the element requests
* an update. By default, this method always returns `true`, but this can be
* customized to control when to update.
*
* @param _changedProperties Map of changed properties with old values
* @category updates
*/
protected shouldUpdate(_changedProperties: PropertyValues): boolean;
/**
* Updates the element. This method reflects property values to attributes.
* It can be overridden to render and keep updated element DOM.
* Setting properties inside this method will *not* trigger
* another update.
*
* @param _changedProperties Map of changed properties with old values
* @category updates
*/
protected update(_changedProperties: PropertyValues): void;
/**
* Invoked whenever the element is updated. Implement to perform
* post-updating tasks via DOM APIs, for example, focusing an element.
*
* Setting properties inside this method will trigger the element to update
* again after this update cycle completes.
*
* @param _changedProperties Map of changed properties with old values
* @category updates
*/
protected updated(_changedProperties: PropertyValues): void;
/**
* Invoked when the element is first updated. Implement to perform one time
* work on the element after update.
*
* ```ts
* firstUpdated() {
* this.renderRoot.getElementById('my-text-area').focus();
* }
* ```
*
* Setting properties inside this method will trigger the element to update
* again after this update cycle completes.
*
* @param _changedProperties Map of changed properties with old values
* @category updates
*/
protected firstUpdated(_changedProperties: PropertyValues): void;
}
//# sourceMappingURL=reactive-element.d.ts.map

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long