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,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,7 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const e=(e,t,o)=>{Object.defineProperty(t,o,e)},t=(e,t)=>({kind:"method",placement:"prototype",key:t.key,descriptor:e}),o=({finisher:e,descriptor:t})=>(o,n)=>{var r;if(void 0===n){const n=null!==(r=o.originalKey)&&void 0!==r?r:o.key,i=null!=t?{kind:"method",placement:"prototype",key:n,descriptor:t(o.key)}:{...o,key:n};return null!=e&&(i.finisher=function(t){e(t,n)}),i}{const r=o.constructor;void 0!==t&&Object.defineProperty(o,n,t(n)),null==e||e(r,n)}};export{o as decorateProperty,e as legacyPrototypeMethod,t as standardPrototypeMethod};
//# sourceMappingURL=base.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"base.js","sources":["../src/decorators/base.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {ReactiveElement} from '../reactive-element.js';\n\n/**\n * Generates a public interface type that removes private and protected fields.\n * This allows accepting otherwise compatible versions of the type (e.g. from\n * multiple copies of the same package in `node_modules`).\n */\nexport type Interface<T> = {\n [K in keyof T]: T[K];\n};\n\nexport type Constructor<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n};\n\n// From the TC39 Decorators proposal\nexport interface ClassDescriptor {\n kind: 'class';\n elements: ClassElement[];\n finisher?: <T>(clazz: Constructor<T>) => void | Constructor<T>;\n}\n\n// From the TC39 Decorators proposal\nexport interface ClassElement {\n kind: 'field' | 'method';\n key: PropertyKey;\n placement: 'static' | 'prototype' | 'own';\n initializer?: Function;\n extras?: ClassElement[];\n finisher?: <T>(clazz: Constructor<T>) => void | Constructor<T>;\n descriptor?: PropertyDescriptor;\n}\n\nexport const legacyPrototypeMethod = (\n descriptor: PropertyDescriptor,\n proto: Object,\n name: PropertyKey\n) => {\n Object.defineProperty(proto, name, descriptor);\n};\n\nexport const standardPrototypeMethod = (\n descriptor: PropertyDescriptor,\n element: ClassElement\n) => ({\n kind: 'method',\n placement: 'prototype',\n key: element.key,\n descriptor,\n});\n\n/**\n * Helper for decorating a property that is compatible with both TypeScript\n * and Babel decorators. The optional `finisher` can be used to perform work on\n * the class. The optional `descriptor` should return a PropertyDescriptor\n * to install for the given property.\n *\n * @param finisher {function} Optional finisher method; receives the element\n * constructor and property key as arguments and has no return value.\n * @param descriptor {function} Optional descriptor method; receives the\n * property key as an argument and returns a property descriptor to define for\n * the given property.\n * @returns {ClassElement|void}\n */\nexport const decorateProperty =\n ({\n finisher,\n descriptor,\n }: {\n finisher?:\n | ((ctor: typeof ReactiveElement, property: PropertyKey) => void)\n | null;\n descriptor?: (property: PropertyKey) => PropertyDescriptor;\n }) =>\n (\n protoOrDescriptor: Interface<ReactiveElement> | ClassElement,\n name?: PropertyKey\n // Note TypeScript requires the return type to be `void|any`\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): void | any => {\n // TypeScript / Babel legacy mode\n if (name !== undefined) {\n const ctor = (protoOrDescriptor as ReactiveElement)\n .constructor as typeof ReactiveElement;\n if (descriptor !== undefined) {\n Object.defineProperty(protoOrDescriptor, name, descriptor(name));\n }\n finisher?.(ctor, name!);\n // Babel standard mode\n } else {\n // Note, the @property decorator saves `key` as `originalKey`\n // so try to use it here.\n const key =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (protoOrDescriptor as any).originalKey ??\n (protoOrDescriptor as ClassElement).key;\n const info: ClassElement =\n descriptor != undefined\n ? {\n kind: 'method',\n placement: 'prototype',\n key,\n descriptor: descriptor((protoOrDescriptor as ClassElement).key),\n }\n : {...(protoOrDescriptor as ClassElement), key};\n if (finisher != undefined) {\n info.finisher = function <ReactiveElement>(\n ctor: Constructor<ReactiveElement>\n ) {\n finisher(ctor as unknown as typeof ReactiveElement, key);\n };\n }\n return info;\n }\n };\n"],"names":["legacyPrototypeMethod","descriptor","proto","name","Object","defineProperty","standardPrototypeMethod","element","kind","placement","key","decorateProperty","finisher","protoOrDescriptor","undefined","_a","originalKey","info","ctor","constructor"],"mappings":";;;;;AAwCa,MAAAA,EAAwB,CACnCC,EACAC,EACAC,KAEAC,OAAOC,eAAeH,EAAOC,EAAMF,EAAW,EAGnCK,EAA0B,CACrCL,EACAM,KACI,CACJC,KAAM,SACNC,UAAW,YACXC,IAAKH,EAAQG,IACbT,eAgBWU,EACX,EACEC,WACAX,gBAOF,CACEY,EACAV,WAKA,QAAaW,IAATX,EAQG,CAGL,MAAMO,UAEJK,EAACF,EAA0BG,2BAC1BH,EAAmCH,IAChCO,EACUH,MAAdb,EACI,CACEO,KAAM,SACNC,UAAW,YACXC,MACAT,WAAYA,EAAYY,EAAmCH,MAE7D,IAAKG,EAAoCH,OAQ/C,OAPgBI,MAAZF,IACFK,EAAKL,SAAW,SACdM,GAEAN,EAASM,EAA2CR,EACtD,GAEKO,CACR,CAhCuB,CACtB,MAAMC,EAAQL,EACXM,iBACgBL,IAAfb,GACFG,OAAOC,eAAeQ,EAAmBV,EAAMF,EAAWE,IAE5DS,SAAAA,EAAWM,EAAMf,EAElB,CAwBA"}

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,7 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const e=e=>n=>"function"==typeof n?((e,n)=>(customElements.define(e,n),n))(e,n):((e,n)=>{const{kind:t,elements:s}=n;return{kind:t,elements:s,finisher(n){customElements.define(e,n)}}})(e,n);export{e as customElement};
//# sourceMappingURL=custom-element.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"custom-element.js","sources":["../src/decorators/custom-element.ts"],"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"],"names":["customElement","tagName","classOrDescriptor","clazz","customElements","define","legacyCustomElement","descriptor","kind","elements","finisher","standardCustomElement"],"mappings":";;;;;AAmBA,MAwCaA,EACVC,GACAC,GAC8B,mBAAtBA,EA3CiB,EAACD,EAAiBE,KAC5CC,eAAeC,OAAOJ,EAASE,GAOxBA,GAoCDG,CAAoBL,EAASC,GAjCP,EAC5BD,EACAM,KAEA,MAAMC,KAACA,EAAIC,SAAEA,GAAYF,EACzB,MAAO,CACLC,OACAC,WAEAC,SAASP,GACPC,eAAeC,OAAOJ,EAASE,EAChC,EACF,EAsBKQ,CAAsBV,EAASC"}

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,7 @@
import{decorateProperty as r}from"./base.js";
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function e(e){return r({finisher:(r,t)=>{Object.assign(r.prototype[t],e)}})}export{e as eventOptions};
//# sourceMappingURL=event-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"event-options.js","sources":["../src/decorators/event-options.ts"],"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"],"names":["eventOptions","options","decorateProperty","finisher","ctor","name","Object","assign","prototype"],"mappings":";;;;;GA8CM,SAAUA,EAAaC,GAC3B,OAAOC,EAAiB,CACtBC,SAAU,CAACC,EAA8BC,KACvCC,OAAOC,OAELH,EAAKI,UAAUH,GACfJ,EACD,GAGP"}

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,7 @@
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const i=(i,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(n){n.createProperty(e.key,i)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(n){n.createProperty(e.key,i)}},e=(i,e,n)=>{e.constructor.createProperty(n,i)};function n(n){return(t,o)=>void 0!==o?e(n,t,o):i(n,t)}export{n as property};
//# 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,7 @@
import{decorateProperty as r}from"./base.js";
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function e(e){return r({descriptor:r=>({get(){var r,o;return null!==(o=null===(r=this.renderRoot)||void 0===r?void 0:r.querySelectorAll(e))&&void 0!==o?o:[]},enumerable:!0,configurable:!0})})}export{e as queryAll};
//# sourceMappingURL=query-all.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query-all.js","sources":["../src/decorators/query-all.ts"],"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"],"names":["queryAll","selector","decorateProperty","descriptor","_name","get","_b","_a","this","renderRoot","querySelectorAll","enumerable","configurable"],"mappings":";;;;;GAwCM,SAAUA,EAASC,GACvB,OAAOC,EAAiB,CACtBC,WAAaC,IAAwB,CACnCC,cACE,OAAsD,QAA/CC,EAAe,QAAfC,EAAAC,KAAKC,kBAAU,IAAAF,OAAA,EAAAA,EAAEG,iBAAiBT,UAAa,IAAAK,EAAAA,EAAA,EACvD,EACDK,YAAY,EACZC,cAAc,KAGpB"}

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,7 @@
import{decorateProperty as o}from"./base.js";
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/var n;const e=null!=(null===(n=window.HTMLSlotElement)||void 0===n?void 0:n.prototype.assignedElements)?(o,n)=>o.assignedElements(n):(o,n)=>o.assignedNodes(n).filter((o=>o.nodeType===Node.ELEMENT_NODE));function l(n){const{slot:l,selector:t}=null!=n?n:{};return o({descriptor:o=>({get(){var o;const r="slot"+(l?`[name=${l}]`:":not([name])"),i=null===(o=this.renderRoot)||void 0===o?void 0:o.querySelector(r),s=null!=i?e(i,n):[];return t?s.filter((o=>o.matches(t))):s},enumerable:!0,configurable:!0})})}export{l as queryAssignedElements};
//# sourceMappingURL=query-assigned-elements.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query-assigned-elements.js","sources":["../src/decorators/query-assigned-elements.ts"],"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"],"names":["slotAssignedElements","_a","window","HTMLSlotElement","prototype","assignedElements","slot","opts","assignedNodes","filter","node","nodeType","Node","ELEMENT_NODE","queryAssignedElements","options","selector","decorateProperty","descriptor","_name","get","slotSelector","slotEl","this","renderRoot","querySelector","elements","matches","enumerable","configurable"],"mappings":";;;;;SAmBA,MAKMA,EACkD,OAAhC,QAAtBC,EANsCC,OAM/BC,uBAAe,IAAAF,OAAA,EAAAA,EAAEG,UAAUC,kBAC9B,CAACC,EAAuBC,IACtBD,EAAKD,iBAAiBE,GACxB,CAACD,EAAuBC,IACtBD,EACGE,cAAcD,GACdE,QACEC,GAA0BA,EAAKC,WAAaC,KAAKC,eA8CxD,SAAUC,EAAsBC,GACpC,MAAMT,KAACA,EAAIU,SAAEA,GAAYD,QAAAA,EAAW,GACpC,OAAOE,EAAiB,CACtBC,WAAaC,IAAwB,CACnCC,YACE,MAAMC,EAAe,QAAOf,EAAO,SAASA,KAAU,gBAChDgB,EACW,QAAfrB,EAAAsB,KAAKC,kBAAU,IAAAvB,OAAA,EAAAA,EAAEwB,cAA+BJ,GAC5CK,EACM,MAAVJ,EAAiBtB,EAAqBsB,EAAQP,GAAW,GAC3D,OAAIC,EACKU,EAASjB,QAAQC,GAASA,EAAKiB,QAAQX,KAEzCU,CACR,EACDE,YAAY,EACZC,cAAc,KAGpB"}

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,7 @@
import{decorateProperty as e}from"./base.js";import{queryAssignedElements as t}from"./query-assigned-elements.js";
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function o(o,n,r){let l,s=o;return"object"==typeof o?(s=o.slot,l=o):l={flatten:n},r?t({slot:s,flatten:n,selector:r}):e({descriptor:e=>({get(){var e,t;const o="slot"+(s?`[name=${s}]`:":not([name])"),n=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(o);return null!==(t=null==n?void 0:n.assignedNodes(l))&&void 0!==t?t:[]},enumerable:!0,configurable:!0})})}export{o as queryAssignedNodes};
//# 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,8 @@
import{decorateProperty as r}from"./base.js";
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
function e(e){return r({descriptor:r=>({async get(){var r;return await this.updateComplete,null===(r=this.renderRoot)||void 0===r?void 0:r.querySelector(e)},enumerable:!0,configurable:!0})})}export{e as queryAsync};
//# sourceMappingURL=query-async.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query-async.js","sources":["../src/decorators/query-async.ts"],"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"],"names":["queryAsync","selector","decorateProperty","descriptor","_name","async","this","updateComplete","_a","renderRoot","querySelector","enumerable","configurable"],"mappings":";;;;;;AAqDM,SAAUA,EAAWC,GACzB,OAAOC,EAAiB,CACtBC,WAAaC,IAAwB,CACnCC,kBAEE,aADMC,KAAKC,uBACJC,EAAAF,KAAKG,iCAAYC,cAAcT,EACvC,EACDU,YAAY,EACZC,cAAc,KAGpB"}

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,7 @@
import{decorateProperty as o}from"./base.js";
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function i(i,n){return o({descriptor:o=>{const t={get(){var o,n;return null!==(n=null===(o=this.renderRoot)||void 0===o?void 0:o.querySelector(i))&&void 0!==n?n:null},enumerable:!0,configurable:!0};if(n){const n="symbol"==typeof o?Symbol():"__"+o;t.get=function(){var o,t;return void 0===this[n]&&(this[n]=null!==(t=null===(o=this.renderRoot)||void 0===o?void 0:o.querySelector(i))&&void 0!==t?t:null),this[n]}}return t}})}export{i as query};
//# sourceMappingURL=query.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"query.js","sources":["../src/decorators/query.ts"],"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"],"names":["query","selector","cache","decorateProperty","descriptor","name","get","_b","_a","this","renderRoot","querySelector","enumerable","configurable","key","Symbol","undefined"],"mappings":";;;;;GAyCgB,SAAAA,EAAMC,EAAkBC,GACtC,OAAOC,EAAiB,CACtBC,WAAaC,IACX,MAAMD,EAAa,CACjBE,cACE,OAAmD,QAA5CC,EAAe,QAAfC,EAAAC,KAAKC,kBAAU,IAAAF,OAAA,EAAAA,EAAEG,cAAcV,UAAa,IAAAM,EAAAA,EAAA,IACpD,EACDK,YAAY,EACZC,cAAc,GAEhB,GAAIX,EAAO,CACT,MAAMY,EAAsB,iBAATT,EAAoBU,SAAW,KAAKV,EACvDD,EAAWE,IAAM,mBAUf,YANQU,IAFLP,KACCK,KAGDL,KACCK,GAC0C,QAAxCP,EAAe,UAAfE,KAAKC,kBAAU,IAAAF,OAAA,EAAAA,EAAEG,cAAcV,UAAS,IAAAM,EAAAA,EAAI,MAE1CE,KACNK,EAEJ,CACD,CACD,OAAOV,CAAU,GAGvB"}

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,7 @@
import{property as r}from"./property.js";
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function t(t){return r({...t,state:!0})}export{t as state};
//# sourceMappingURL=state.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"state.js","sources":["../src/decorators/state.ts"],"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"],"names":["state","options","property"],"mappings":";;;;;GAkCM,SAAUA,EAAMC,GACpB,OAAOC,EAAS,IACXD,EACHD,OAAO,GAEX"}