mirror of
https://github.com/Polymer/polymer.git
synced 2024-07-07 04:43:03 -05:00
Track TypeScript declarations.
This commit is contained in:
parent
39d5a95382
commit
ec7b7c5541
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -18,7 +18,3 @@ analysis.json
|
|||
|
||||
# NPM artifact
|
||||
polymer-polymer-*.tgz
|
||||
|
||||
# Typings are generated upon publish to NPM, except for one.
|
||||
*.d.ts
|
||||
!interfaces.d.ts
|
||||
|
|
224
lib/elements/array-selector.d.ts
vendored
Normal file
224
lib/elements/array-selector.d.ts
vendored
Normal file
|
@ -0,0 +1,224 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/elements/array-selector.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {PolymerElement} from '../../polymer-element.js';
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
import {calculateSplices} from '../utils/array-splice.js';
|
||||
|
||||
import {ElementMixin} from '../mixins/element-mixin.js';
|
||||
|
||||
|
||||
/**
|
||||
* Element mixin for recording dynamic associations between item paths in a
|
||||
* master `items` array and a `selected` array such that path changes to the
|
||||
* master array (at the host) element or elsewhere via data-binding) are
|
||||
* correctly propagated to items in the selected array and vice-versa.
|
||||
*
|
||||
* The `items` property accepts an array of user data, and via the
|
||||
* `select(item)` and `deselect(item)` API, updates the `selected` property
|
||||
* which may be bound to other parts of the application, and any changes to
|
||||
* sub-fields of `selected` item(s) will be kept in sync with items in the
|
||||
* `items` array. When `multi` is false, `selected` is a property
|
||||
* representing the last selected item. When `multi` is true, `selected`
|
||||
* is an array of multiply selected items.
|
||||
*/
|
||||
declare function ArraySelectorMixin<T extends new (...args: any[]) => {}>(base: T): T & ArraySelectorMixinConstructor & ElementMixinConstructor & PropertyEffectsConstructor & TemplateStampConstructor & PropertyAccessorsConstructor & PropertiesChangedConstructor & PropertiesMixinConstructor;
|
||||
|
||||
import {ElementMixinConstructor} from '../mixins/element-mixin.js';
|
||||
|
||||
import {PropertyEffectsConstructor, PropertyEffects} from '../mixins/property-effects.js';
|
||||
|
||||
import {TemplateStampConstructor, TemplateStamp} from '../mixins/template-stamp.js';
|
||||
|
||||
import {PropertyAccessorsConstructor, PropertyAccessors} from '../mixins/property-accessors.js';
|
||||
|
||||
import {PropertiesChangedConstructor, PropertiesChanged} from '../mixins/properties-changed.js';
|
||||
|
||||
import {PropertiesMixinConstructor, PropertiesMixin} from '../mixins/properties-mixin.js';
|
||||
|
||||
interface ArraySelectorMixinConstructor {
|
||||
new(...args: any[]): ArraySelectorMixin;
|
||||
}
|
||||
|
||||
export {ArraySelectorMixinConstructor};
|
||||
|
||||
interface ArraySelectorMixin extends ElementMixin, PropertyEffects, TemplateStamp, PropertyAccessors, PropertiesChanged, PropertiesMixin {
|
||||
|
||||
/**
|
||||
* An array containing items from which selection will be made.
|
||||
*/
|
||||
items: any[]|null|undefined;
|
||||
|
||||
/**
|
||||
* When `true`, multiple items may be selected at once (in this case,
|
||||
* `selected` is an array of currently selected items). When `false`,
|
||||
* only one item may be selected at a time.
|
||||
*/
|
||||
multi: boolean|null|undefined;
|
||||
|
||||
/**
|
||||
* When `multi` is true, this is an array that contains any selected.
|
||||
* When `multi` is false, this is the currently selected item, or `null`
|
||||
* if no item is selected.
|
||||
*/
|
||||
selected: object|object[]|null;
|
||||
|
||||
/**
|
||||
* When `multi` is false, this is the currently selected item, or `null`
|
||||
* if no item is selected.
|
||||
*/
|
||||
selectedItem: object|null;
|
||||
|
||||
/**
|
||||
* When `true`, calling `select` on an item that is already selected
|
||||
* will deselect the item.
|
||||
*/
|
||||
toggle: boolean|null|undefined;
|
||||
|
||||
/**
|
||||
* Clears the selection state.
|
||||
*/
|
||||
clearSelection(): void;
|
||||
|
||||
/**
|
||||
* Returns whether the item is currently selected.
|
||||
*
|
||||
* @param item Item from `items` array to test
|
||||
* @returns Whether the item is selected
|
||||
*/
|
||||
isSelected(item: any): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether the item is currently selected.
|
||||
*
|
||||
* @param idx Index from `items` array to test
|
||||
* @returns Whether the item is selected
|
||||
*/
|
||||
isIndexSelected(idx: number): boolean;
|
||||
|
||||
/**
|
||||
* Deselects the given item if it is already selected.
|
||||
*
|
||||
* @param item Item from `items` array to deselect
|
||||
*/
|
||||
deselect(item: any): void;
|
||||
|
||||
/**
|
||||
* Deselects the given index if it is already selected.
|
||||
*
|
||||
* @param idx Index from `items` array to deselect
|
||||
*/
|
||||
deselectIndex(idx: number): void;
|
||||
|
||||
/**
|
||||
* Selects the given item. When `toggle` is true, this will automatically
|
||||
* deselect the item if already selected.
|
||||
*
|
||||
* @param item Item from `items` array to select
|
||||
*/
|
||||
select(item: any): void;
|
||||
|
||||
/**
|
||||
* Selects the given index. When `toggle` is true, this will automatically
|
||||
* deselect the item if already selected.
|
||||
*
|
||||
* @param idx Index from `items` array to select
|
||||
*/
|
||||
selectIndex(idx: number): void;
|
||||
}
|
||||
|
||||
export {ArraySelectorMixin};
|
||||
|
||||
/**
|
||||
* Element implementing the `ArraySelector` mixin, which records
|
||||
* dynamic associations between item paths in a master `items` array and a
|
||||
* `selected` array such that path changes to the master array (at the host)
|
||||
* element or elsewhere via data-binding) are correctly propagated to items
|
||||
* in the selected array and vice-versa.
|
||||
*
|
||||
* The `items` property accepts an array of user data, and via the
|
||||
* `select(item)` and `deselect(item)` API, updates the `selected` property
|
||||
* which may be bound to other parts of the application, and any changes to
|
||||
* sub-fields of `selected` item(s) will be kept in sync with items in the
|
||||
* `items` array. When `multi` is false, `selected` is a property
|
||||
* representing the last selected item. When `multi` is true, `selected`
|
||||
* is an array of multiply selected items.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* import {PolymerElement} from '@polymer/polymer';
|
||||
* import '@polymer/polymer/lib/elements/array-selector.js';
|
||||
*
|
||||
* class EmployeeList extends PolymerElement {
|
||||
* static get _template() {
|
||||
* return html`
|
||||
* <div> Employee list: </div>
|
||||
* <dom-repeat id="employeeList" items="{{employees}}">
|
||||
* <template>
|
||||
* <div>First name: <span>{{item.first}}</span></div>
|
||||
* <div>Last name: <span>{{item.last}}</span></div>
|
||||
* <button on-click="toggleSelection">Select</button>
|
||||
* </template>
|
||||
* </dom-repeat>
|
||||
*
|
||||
* <array-selector id="selector"
|
||||
* items="{{employees}}"
|
||||
* selected="{{selected}}"
|
||||
* multi toggle></array-selector>
|
||||
*
|
||||
* <div> Selected employees: </div>
|
||||
* <dom-repeat items="{{selected}}">
|
||||
* <template>
|
||||
* <div>First name: <span>{{item.first}}</span></div>
|
||||
* <div>Last name: <span>{{item.last}}</span></div>
|
||||
* </template>
|
||||
* </dom-repeat>`;
|
||||
* }
|
||||
* static get is() { return 'employee-list'; }
|
||||
* static get properties() {
|
||||
* return {
|
||||
* employees: {
|
||||
* value() {
|
||||
* return [
|
||||
* {first: 'Bob', last: 'Smith'},
|
||||
* {first: 'Sally', last: 'Johnson'},
|
||||
* ...
|
||||
* ];
|
||||
* }
|
||||
* }
|
||||
* };
|
||||
* }
|
||||
* toggleSelection(e) {
|
||||
* const item = this.$.employeeList.itemForElement(e.target);
|
||||
* this.$.selector.select(item);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare class ArraySelector extends
|
||||
ArraySelectorMixin(
|
||||
PolymerElement) {
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
interface HTMLElementTagNameMap {
|
||||
"array-selector": ArraySelector;
|
||||
}
|
||||
}
|
||||
|
||||
export {ArraySelector};
|
76
lib/elements/custom-style.d.ts
vendored
Normal file
76
lib/elements/custom-style.d.ts
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/elements/custom-style.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
import {cssFromModules} from '../utils/style-gather.js';
|
||||
|
||||
export {CustomStyle};
|
||||
|
||||
/**
|
||||
* Custom element for defining styles in the main document that can take
|
||||
* advantage of [shady DOM](https://github.com/webcomponents/shadycss) shims
|
||||
* for style encapsulation, custom properties, and custom mixins.
|
||||
*
|
||||
* - Document styles defined in a `<custom-style>` are shimmed to ensure they
|
||||
* do not leak into local DOM when running on browsers without native
|
||||
* Shadow DOM.
|
||||
* - Custom properties can be defined in a `<custom-style>`. Use the `html` selector
|
||||
* to define custom properties that apply to all custom elements.
|
||||
* - Custom mixins can be defined in a `<custom-style>`, if you import the optional
|
||||
* [apply shim](https://github.com/webcomponents/shadycss#about-applyshim)
|
||||
* (`shadycss/apply-shim.html`).
|
||||
*
|
||||
* To use:
|
||||
*
|
||||
* - Import `custom-style.html`.
|
||||
* - Place a `<custom-style>` element in the main document, wrapping an inline `<style>` tag that
|
||||
* contains the CSS rules you want to shim.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* ```html
|
||||
* <!-- import apply shim--only required if using mixins -->
|
||||
* <link rel="import" href="bower_components/shadycss/apply-shim.html">
|
||||
* <!-- import custom-style element -->
|
||||
* <link rel="import" href="bower_components/polymer/lib/elements/custom-style.html">
|
||||
*
|
||||
* <custom-style>
|
||||
* <style>
|
||||
* html {
|
||||
* --custom-color: blue;
|
||||
* --custom-mixin: {
|
||||
* font-weight: bold;
|
||||
* color: red;
|
||||
* };
|
||||
* }
|
||||
* </style>
|
||||
* </custom-style>
|
||||
* ```
|
||||
*/
|
||||
declare class CustomStyle extends HTMLElement {
|
||||
|
||||
/**
|
||||
* Returns the light-DOM `<style>` child this element wraps. Upon first
|
||||
* call any style modules referenced via the `include` attribute will be
|
||||
* concatenated to this element's `<style>`.
|
||||
*
|
||||
* @returns This element's light-DOM `<style>`
|
||||
*/
|
||||
getStyle(): HTMLStyleElement|null;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
interface HTMLElementTagNameMap {
|
||||
"custom-style": CustomStyle;
|
||||
}
|
||||
}
|
62
lib/elements/dom-bind.d.ts
vendored
Normal file
62
lib/elements/dom-bind.d.ts
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/elements/dom-bind.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
import {PropertyEffects} from '../mixins/property-effects.js';
|
||||
|
||||
import {OptionalMutableData} from '../mixins/mutable-data.js';
|
||||
|
||||
import {GestureEventListeners} from '../mixins/gesture-event-listeners.js';
|
||||
|
||||
import {hideElementsGlobally} from '../utils/hide-template-controls.js';
|
||||
|
||||
export {DomBind};
|
||||
|
||||
/**
|
||||
* Custom element to allow using Polymer's template features (data binding,
|
||||
* declarative event listeners, etc.) in the main document without defining
|
||||
* a new custom element.
|
||||
*
|
||||
* `<template>` tags utilizing bindings may be wrapped with the `<dom-bind>`
|
||||
* element, which will immediately stamp the wrapped template into the main
|
||||
* document and bind elements to the `dom-bind` element itself as the
|
||||
* binding scope.
|
||||
*/
|
||||
declare class DomBind extends
|
||||
PropertyEffects(
|
||||
OptionalMutableData(
|
||||
GestureEventListeners(
|
||||
HTMLElement))) {
|
||||
|
||||
/**
|
||||
* @param name Name of attribute that changed
|
||||
* @param old Old attribute value
|
||||
* @param value New attribute value
|
||||
* @param namespace Attribute namespace.
|
||||
*/
|
||||
attributeChangedCallback(name: string, old: string|null, value: string|null, namespace: string|null): void;
|
||||
connectedCallback(): void;
|
||||
disconnectedCallback(): void;
|
||||
|
||||
/**
|
||||
* Forces the element to render its content. This is typically only
|
||||
* necessary to call if HTMLImports with the async attribute are used.
|
||||
*/
|
||||
render(): void;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
interface HTMLElementTagNameMap {
|
||||
"dom-bind": DomBind;
|
||||
}
|
||||
}
|
180
lib/elements/dom-if.d.ts
vendored
Normal file
180
lib/elements/dom-if.d.ts
vendored
Normal file
|
@ -0,0 +1,180 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/elements/dom-if.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
import {PolymerElement} from '../../polymer-element.js';
|
||||
|
||||
import {Debouncer} from '../utils/debounce.js';
|
||||
|
||||
import {enqueueDebouncer, flush} from '../utils/flush.js';
|
||||
|
||||
import {microTask} from '../utils/async.js';
|
||||
|
||||
import {root} from '../utils/path.js';
|
||||
|
||||
import {hideElementsGlobally} from '../utils/hide-template-controls.js';
|
||||
|
||||
import {showHideChildren, templatize} from '../utils/templatize.js';
|
||||
|
||||
declare class DomIfBase extends PolymerElement {
|
||||
_templateInfo: TemplateInfo|undefined;
|
||||
|
||||
/**
|
||||
* A boolean indicating whether this template should stamp.
|
||||
*/
|
||||
if: boolean|null|undefined;
|
||||
|
||||
/**
|
||||
* When true, elements will be removed from DOM and discarded when `if`
|
||||
* becomes false and re-created and added back to the DOM when `if`
|
||||
* becomes true. By default, stamped elements will be hidden but left
|
||||
* in the DOM when `if` becomes false, which is generally results
|
||||
* in better performance.
|
||||
*/
|
||||
restamp: boolean|null|undefined;
|
||||
|
||||
/**
|
||||
* When the global `suppressTemplateNotifications` setting is used, setting
|
||||
* `notifyDomChange: true` will enable firing `dom-change` events on this
|
||||
* element.
|
||||
*/
|
||||
notifyDomChange: boolean|null|undefined;
|
||||
connectedCallback(): void;
|
||||
disconnectedCallback(): void;
|
||||
|
||||
/**
|
||||
* Forces the element to render its content. Normally rendering is
|
||||
* asynchronous to a provoking change. This is done for efficiency so
|
||||
* that multiple changes trigger only a single render. The render method
|
||||
* should be called if, for example, template rendering is required to
|
||||
* validate application state.
|
||||
*/
|
||||
render(): void;
|
||||
|
||||
/**
|
||||
* Abstract API to be implemented by subclass: Returns true if a template
|
||||
* instance has been created and inserted.
|
||||
*
|
||||
* @returns True when an instance has been created.
|
||||
*/
|
||||
__hasInstance(): boolean;
|
||||
|
||||
/**
|
||||
* Abstract API to be implemented by subclass: Returns the child nodes stamped
|
||||
* from a template instance.
|
||||
*
|
||||
* @returns Array of child nodes stamped from the template
|
||||
* instance.
|
||||
*/
|
||||
__getInstanceNodes(): Array<Node|null>|null;
|
||||
|
||||
/**
|
||||
* Abstract API to be implemented by subclass: Creates an instance of the
|
||||
* template and inserts it into the given parent node.
|
||||
*
|
||||
* @param parentNode The parent node to insert the instance into
|
||||
*/
|
||||
__createAndInsertInstance(parentNode: Node|null): void;
|
||||
|
||||
/**
|
||||
* Abstract API to be implemented by subclass: Removes nodes created by an
|
||||
* instance of a template and any associated cleanup.
|
||||
*/
|
||||
__teardownInstance(): void;
|
||||
|
||||
/**
|
||||
* Abstract API to be implemented by subclass: Shows or hides any template
|
||||
* instance childNodes based on the `if` state of the element and its
|
||||
* `__hideTemplateChildren__` property.
|
||||
*/
|
||||
_showHideChildren(): void;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
interface HTMLElementTagNameMap {
|
||||
"dom-if": DomIfBase;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The version of DomIf used when `fastDomIf` setting is in use, which is
|
||||
* optimized for first-render (but adds a tax to all subsequent property updates
|
||||
* on the host, whether they were used in a given `dom-if` or not).
|
||||
*
|
||||
* This implementation avoids use of `Templatizer`, which introduces a new scope
|
||||
* (a non-element PropertyEffects instance), which is not strictly necessary
|
||||
* since `dom-if` never introduces new properties to its scope (unlike
|
||||
* `dom-repeat`). Taking advantage of this fact, the `dom-if` reaches up to its
|
||||
* `__dataHost` and stamps the template directly from the host using the host's
|
||||
* runtime `_stampTemplate` API, which binds the property effects of the
|
||||
* template directly to the host. This both avoids the intermediary
|
||||
* `Templatizer` instance, but also avoids the need to bind host properties to
|
||||
* the `<template>` element and forward those into the template instance.
|
||||
*
|
||||
* In this version of `dom-if`, the `this.__instance` method is the
|
||||
* `DocumentFragment` returned from `_stampTemplate`, which also serves as the
|
||||
* handle for later removing it using the `_removeBoundDom` method.
|
||||
*/
|
||||
declare class DomIfFast extends DomIfBase {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Implementation of abstract API needed by DomIfBase.
|
||||
*
|
||||
* Shows or hides the template instance top level child nodes. For
|
||||
* text nodes, `textContent` is removed while "hidden" and replaced when
|
||||
* "shown."
|
||||
*/
|
||||
_showHideChildren(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* The "legacy" implementation of `dom-if`, implemented using `Templatizer`.
|
||||
*
|
||||
* In this version, `this.__instance` is the `TemplateInstance` returned
|
||||
* from the templatized constructor.
|
||||
*/
|
||||
declare class DomIfLegacy extends DomIfBase {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Implementation of abstract API needed by DomIfBase.
|
||||
*
|
||||
* Shows or hides the template instance top level child elements. For
|
||||
* text nodes, `textContent` is removed while "hidden" and replaced when
|
||||
* "shown."
|
||||
*/
|
||||
_showHideChildren(): void;
|
||||
}
|
||||
|
||||
export {DomIf};
|
||||
|
||||
/**
|
||||
* The `<dom-if>` element will stamp a light-dom `<template>` child when
|
||||
* the `if` property becomes truthy, and the template can use Polymer
|
||||
* data-binding and declarative event features when used in the context of
|
||||
* a Polymer element's template.
|
||||
*
|
||||
* When `if` becomes falsy, the stamped content is hidden but not
|
||||
* removed from dom. When `if` subsequently becomes truthy again, the content
|
||||
* is simply re-shown. This approach is used due to its favorable performance
|
||||
* characteristics: the expense of creating template content is paid only
|
||||
* once and lazily.
|
||||
*
|
||||
* Set the `restamp` property to true to force the stamped content to be
|
||||
* created / destroyed when the `if` condition changes.
|
||||
*/
|
||||
declare class DomIf extends DomIfBase {
|
||||
}
|
||||
|
||||
import {TemplateInfo} from '../../interfaces';
|
88
lib/elements/dom-module.d.ts
vendored
Normal file
88
lib/elements/dom-module.d.ts
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/elements/dom-module.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {resolveUrl, pathFromUrl} from '../utils/resolve-url.js';
|
||||
|
||||
export {DomModule};
|
||||
|
||||
/**
|
||||
* The `dom-module` element registers the dom it contains to the name given
|
||||
* by the module's id attribute. It provides a unified database of dom
|
||||
* accessible via its static `import` API.
|
||||
*
|
||||
* A key use case of `dom-module` is for providing custom element `<template>`s
|
||||
* via HTML imports that are parsed by the native HTML parser, that can be
|
||||
* relocated during a bundling pass and still looked up by `id`.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* <dom-module id="foo">
|
||||
* <img src="stuff.png">
|
||||
* </dom-module>
|
||||
*
|
||||
* Then in code in some other location that cannot access the dom-module above
|
||||
*
|
||||
* let img = customElements.get('dom-module').import('foo', 'img');
|
||||
*/
|
||||
declare class DomModule extends HTMLElement {
|
||||
|
||||
/**
|
||||
* The absolute URL of the original location of this `dom-module`.
|
||||
*
|
||||
* This value will differ from this element's `ownerDocument` in the
|
||||
* following ways:
|
||||
* - Takes into account any `assetpath` attribute added during bundling
|
||||
* to indicate the original location relative to the bundled location
|
||||
* - Uses the HTMLImports polyfill's `importForElement` API to ensure
|
||||
* the path is relative to the import document's location since
|
||||
* `ownerDocument` is not currently polyfilled
|
||||
*
|
||||
*/
|
||||
readonly assetpath: any;
|
||||
|
||||
/**
|
||||
* Retrieves the element specified by the css `selector` in the module
|
||||
* registered by `id`. For example, this.import('foo', 'img');
|
||||
*
|
||||
* @param id The id of the dom-module in which to search.
|
||||
* @param selector The css selector by which to find the element.
|
||||
* @returns Returns the element which matches `selector` in the
|
||||
* module registered at the specified `id`.
|
||||
*/
|
||||
static import(id: string, selector?: string): Element|null;
|
||||
|
||||
/**
|
||||
* @param name Name of attribute.
|
||||
* @param old Old value of attribute.
|
||||
* @param value Current value of attribute.
|
||||
* @param namespace Attribute namespace.
|
||||
*/
|
||||
attributeChangedCallback(name: string, old: string|null, value: string|null, namespace: string|null): void;
|
||||
|
||||
/**
|
||||
* Registers the dom-module at a given id. This method should only be called
|
||||
* when a dom-module is imperatively created. For
|
||||
* example, `document.createElement('dom-module').register('foo')`.
|
||||
*
|
||||
* @param id The id at which to register the dom-module.
|
||||
*/
|
||||
register(id?: string): void;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
interface HTMLElementTagNameMap {
|
||||
"dom-module": DomModule;
|
||||
}
|
||||
}
|
325
lib/elements/dom-repeat.d.ts
vendored
Normal file
325
lib/elements/dom-repeat.d.ts
vendored
Normal file
|
@ -0,0 +1,325 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/elements/dom-repeat.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {PolymerElement} from '../../polymer-element.js';
|
||||
|
||||
import {TemplateInstanceBase, templatize, modelForElement} from '../utils/templatize.js';
|
||||
|
||||
import {Debouncer} from '../utils/debounce.js';
|
||||
|
||||
import {enqueueDebouncer, flush} from '../utils/flush.js';
|
||||
|
||||
import {OptionalMutableData} from '../mixins/mutable-data.js';
|
||||
|
||||
import {matches, translate} from '../utils/path.js';
|
||||
|
||||
import {timeOut, microTask} from '../utils/async.js';
|
||||
|
||||
import {hideElementsGlobally} from '../utils/hide-template-controls.js';
|
||||
|
||||
export {DomRepeat};
|
||||
|
||||
/**
|
||||
* The `<dom-repeat>` element will automatically stamp and binds one instance
|
||||
* of template content to each object in a user-provided array.
|
||||
* `dom-repeat` accepts an `items` property, and one instance of the template
|
||||
* is stamped for each item into the DOM at the location of the `dom-repeat`
|
||||
* element. The `item` property will be set on each instance's binding
|
||||
* scope, thus templates should bind to sub-properties of `item`.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```html
|
||||
* <dom-module id="employee-list">
|
||||
*
|
||||
* <template>
|
||||
*
|
||||
* <div> Employee list: </div>
|
||||
* <dom-repeat items="{{employees}}">
|
||||
* <template>
|
||||
* <div>First name: <span>{{item.first}}</span></div>
|
||||
* <div>Last name: <span>{{item.last}}</span></div>
|
||||
* </template>
|
||||
* </dom-repeat>
|
||||
*
|
||||
* </template>
|
||||
*
|
||||
* </dom-module>
|
||||
* ```
|
||||
*
|
||||
* With the following custom element definition:
|
||||
*
|
||||
* ```js
|
||||
* class EmployeeList extends PolymerElement {
|
||||
* static get is() { return 'employee-list'; }
|
||||
* static get properties() {
|
||||
* return {
|
||||
* employees: {
|
||||
* value() {
|
||||
* return [
|
||||
* {first: 'Bob', last: 'Smith'},
|
||||
* {first: 'Sally', last: 'Johnson'},
|
||||
* ...
|
||||
* ];
|
||||
* }
|
||||
* }
|
||||
* };
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Notifications for changes to items sub-properties will be forwarded to template
|
||||
* instances, which will update via the normal structured data notification system.
|
||||
*
|
||||
* Mutations to the `items` array itself should be made using the Array
|
||||
* mutation API's on the PropertyEffects mixin (`push`, `pop`, `splice`,
|
||||
* `shift`, `unshift`), and template instances will be kept in sync with the
|
||||
* data in the array.
|
||||
*
|
||||
* Events caught by event handlers within the `dom-repeat` template will be
|
||||
* decorated with a `model` property, which represents the binding scope for
|
||||
* each template instance. The model should be used to manipulate data on the
|
||||
* instance, for example `event.model.set('item.checked', true);`.
|
||||
*
|
||||
* Alternatively, the model for a template instance for an element stamped by
|
||||
* a `dom-repeat` can be obtained using the `modelForElement` API on the
|
||||
* `dom-repeat` that stamped it, for example
|
||||
* `this.$.domRepeat.modelForElement(event.target).set('item.checked', true);`.
|
||||
* This may be useful for manipulating instance data of event targets obtained
|
||||
* by event handlers on parents of the `dom-repeat` (event delegation).
|
||||
*
|
||||
* A view-specific filter/sort may be applied to each `dom-repeat` by supplying a
|
||||
* `filter` and/or `sort` property. This may be a string that names a function on
|
||||
* the host, or a function may be assigned to the property directly. The functions
|
||||
* should implemented following the standard `Array` filter/sort API.
|
||||
*
|
||||
* In order to re-run the filter or sort functions based on changes to sub-fields
|
||||
* of `items`, the `observe` property may be set as a space-separated list of
|
||||
* `item` sub-fields that should cause a re-filter/sort when modified. If
|
||||
* the filter or sort function depends on properties not contained in `items`,
|
||||
* the user should observe changes to those properties and call `render` to update
|
||||
* the view based on the dependency change.
|
||||
*
|
||||
* For example, for an `dom-repeat` with a filter of the following:
|
||||
*
|
||||
* ```js
|
||||
* isEngineer(item) {
|
||||
* return item.type == 'engineer' || item.manager.type == 'engineer';
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Then the `observe` property should be configured as follows:
|
||||
*
|
||||
* ```html
|
||||
* <dom-repeat items="{{employees}}" filter="isEngineer" observe="type manager.type">
|
||||
* ```
|
||||
*/
|
||||
declare class DomRepeat extends
|
||||
OptionalMutableData(
|
||||
PolymerElement) {
|
||||
_templateInfo: TemplateInfo|null;
|
||||
|
||||
/**
|
||||
* An array containing items determining how many instances of the template
|
||||
* to stamp and that that each template instance should bind to.
|
||||
*/
|
||||
items: any[]|null|undefined;
|
||||
|
||||
/**
|
||||
* The name of the variable to add to the binding scope for the array
|
||||
* element associated with a given template instance.
|
||||
*/
|
||||
as: string|null|undefined;
|
||||
|
||||
/**
|
||||
* The name of the variable to add to the binding scope with the index
|
||||
* of the instance in the sorted and filtered list of rendered items.
|
||||
* Note, for the index in the `this.items` array, use the value of the
|
||||
* `itemsIndexAs` property.
|
||||
*/
|
||||
indexAs: string|null|undefined;
|
||||
|
||||
/**
|
||||
* The name of the variable to add to the binding scope with the index
|
||||
* of the instance in the `this.items` array. Note, for the index of
|
||||
* this instance in the sorted and filtered list of rendered items,
|
||||
* use the value of the `indexAs` property.
|
||||
*/
|
||||
itemsIndexAs: string|null|undefined;
|
||||
|
||||
/**
|
||||
* A function that should determine the sort order of the items. This
|
||||
* property should either be provided as a string, indicating a method
|
||||
* name on the element's host, or else be an actual function. The
|
||||
* function should match the sort function passed to `Array.sort`.
|
||||
* Using a sort function has no effect on the underlying `items` array.
|
||||
*/
|
||||
sort: Function|null|undefined;
|
||||
|
||||
/**
|
||||
* A function that can be used to filter items out of the view. This
|
||||
* property should either be provided as a string, indicating a method
|
||||
* name on the element's host, or else be an actual function. The
|
||||
* function should match the sort function passed to `Array.filter`.
|
||||
* Using a filter function has no effect on the underlying `items` array.
|
||||
*/
|
||||
filter: Function|null|undefined;
|
||||
|
||||
/**
|
||||
* When using a `filter` or `sort` function, the `observe` property
|
||||
* should be set to a space-separated list of the names of item
|
||||
* sub-fields that should trigger a re-sort or re-filter when changed.
|
||||
* These should generally be fields of `item` that the sort or filter
|
||||
* function depends on.
|
||||
*/
|
||||
observe: string|null|undefined;
|
||||
|
||||
/**
|
||||
* When using a `filter` or `sort` function, the `delay` property
|
||||
* determines a debounce time in ms after a change to observed item
|
||||
* properties that must pass before the filter or sort is re-run.
|
||||
* This is useful in rate-limiting shuffling of the view when
|
||||
* item changes may be frequent.
|
||||
*/
|
||||
delay: number|null|undefined;
|
||||
|
||||
/**
|
||||
* Count of currently rendered items after `filter` (if any) has been applied.
|
||||
* If "chunking mode" is enabled, `renderedItemCount` is updated each time a
|
||||
* set of template instances is rendered.
|
||||
*/
|
||||
readonly renderedItemCount: number|null|undefined;
|
||||
|
||||
/**
|
||||
* When greater than zero, defines an initial count of template instances
|
||||
* to render after setting the `items` array, before the next paint, and
|
||||
* puts the `dom-repeat` into "chunking mode". The remaining items (and
|
||||
* any future items as a result of pushing onto the array) will be created
|
||||
* and rendered incrementally at each animation frame thereof until all
|
||||
* instances have been rendered.
|
||||
*/
|
||||
initialCount: number|null|undefined;
|
||||
|
||||
/**
|
||||
* When `initialCount` is used, this property defines a frame rate (in
|
||||
* fps) to target by throttling the number of instances rendered each
|
||||
* frame to not exceed the budget for the target frame rate. The
|
||||
* framerate is effectively the number of `requestAnimationFrame`s that
|
||||
* it tries to allow to actually fire in a given second. It does this
|
||||
* by measuring the time between `rAF`s and continuously adjusting the
|
||||
* number of items created each `rAF` to maintain the target framerate.
|
||||
* Setting this to a higher number allows lower latency and higher
|
||||
* throughput for event handlers and other tasks, but results in a
|
||||
* longer time for the remaining items to complete rendering.
|
||||
*/
|
||||
targetFramerate: number|null|undefined;
|
||||
readonly _targetFrameTime: number|null|undefined;
|
||||
|
||||
/**
|
||||
* When the global `suppressTemplateNotifications` setting is used, setting
|
||||
* `notifyDomChange: true` will enable firing `dom-change` events on this
|
||||
* element.
|
||||
*/
|
||||
notifyDomChange: boolean|null|undefined;
|
||||
|
||||
/**
|
||||
* When chunking is enabled via `initialCount` and the `items` array is
|
||||
* set to a new array, this flag controls whether the previously rendered
|
||||
* instances are reused or not.
|
||||
*
|
||||
* When `true`, any previously rendered template instances are updated in
|
||||
* place to their new item values synchronously in one shot, and then any
|
||||
* further items (if any) are chunked out. When `false`, the list is
|
||||
* returned back to its `initialCount` (any instances over the initial
|
||||
* count are discarded) and the remainder of the list is chunked back in.
|
||||
* Set this to `true` to avoid re-creating the list and losing scroll
|
||||
* position, although note that when changing the list to completely
|
||||
* different data the render thread will be blocked until all existing
|
||||
* instances are updated to their new data.
|
||||
*/
|
||||
reuseChunkedInstances: boolean|null|undefined;
|
||||
connectedCallback(): void;
|
||||
disconnectedCallback(): void;
|
||||
|
||||
/**
|
||||
* Forces the element to render its content. Normally rendering is
|
||||
* asynchronous to a provoking change. This is done for efficiency so
|
||||
* that multiple changes trigger only a single render. The render method
|
||||
* should be called if, for example, template rendering is required to
|
||||
* validate application state.
|
||||
*/
|
||||
render(): void;
|
||||
|
||||
/**
|
||||
* Shows or hides the template instance top level child elements. For
|
||||
* text nodes, `textContent` is removed while "hidden" and replaced when
|
||||
* "shown."
|
||||
*
|
||||
* @param hidden Set to true to hide the children;
|
||||
* set to false to show them.
|
||||
*/
|
||||
_showHideChildren(hidden: boolean): void;
|
||||
|
||||
/**
|
||||
* Returns the item associated with a given element stamped by
|
||||
* this `dom-repeat`.
|
||||
*
|
||||
* Note, to modify sub-properties of the item,
|
||||
* `modelForElement(el).set('item.<sub-prop>', value)`
|
||||
* should be used.
|
||||
*
|
||||
* @param el Element for which to return the item.
|
||||
* @returns Item associated with the element.
|
||||
*/
|
||||
itemForElement(el: HTMLElement): any;
|
||||
|
||||
/**
|
||||
* Returns the inst index for a given element stamped by this `dom-repeat`.
|
||||
* If `sort` is provided, the index will reflect the sorted order (rather
|
||||
* than the original array order).
|
||||
*
|
||||
* @param el Element for which to return the index.
|
||||
* @returns Row index associated with the element (note this may
|
||||
* not correspond to the array index if a user `sort` is applied).
|
||||
*/
|
||||
indexForElement(el: HTMLElement): number|null;
|
||||
|
||||
/**
|
||||
* Returns the template "model" associated with a given element, which
|
||||
* serves as the binding scope for the template instance the element is
|
||||
* contained in. A template model
|
||||
* should be used to manipulate data associated with this template instance.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* let model = modelForElement(el);
|
||||
* if (model.index < 10) {
|
||||
* model.set('item.checked', true);
|
||||
* }
|
||||
*
|
||||
* @param el Element for which to return a template model.
|
||||
* @returns Model representing the binding scope for
|
||||
* the element.
|
||||
*/
|
||||
modelForElement(el: HTMLElement): TemplateInstanceBase|null;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
interface HTMLElementTagNameMap {
|
||||
"dom-repeat": DomRepeat;
|
||||
}
|
||||
}
|
||||
|
||||
import {TemplateInfo} from '../../interfaces';
|
102
lib/legacy/class.d.ts
vendored
Normal file
102
lib/legacy/class.d.ts
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/legacy/class.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {LegacyElementMixin} from './legacy-element-mixin.js';
|
||||
|
||||
export {mixinBehaviors};
|
||||
|
||||
|
||||
/**
|
||||
* Applies a "legacy" behavior or array of behaviors to the provided class.
|
||||
*
|
||||
* Note: this method will automatically also apply the `LegacyElementMixin`
|
||||
* to ensure that any legacy behaviors can rely on legacy Polymer API on
|
||||
* the underlying element.
|
||||
*
|
||||
* @returns Returns a new Element class extended by the
|
||||
* passed in `behaviors` and also by `LegacyElementMixin`.
|
||||
*/
|
||||
declare function mixinBehaviors<T>(behaviors: object|object[], klass: {new(): T}): any;
|
||||
|
||||
export {Class};
|
||||
|
||||
|
||||
/**
|
||||
* Generates a class that extends `LegacyElement` based on the
|
||||
* provided info object. Metadata objects on the `info` object
|
||||
* (`properties`, `observers`, `listeners`, `behaviors`, `is`) are used
|
||||
* for Polymer's meta-programming systems, and any functions are copied
|
||||
* to the generated class.
|
||||
*
|
||||
* Valid "metadata" values are as follows:
|
||||
*
|
||||
* `is`: String providing the tag name to register the element under. In
|
||||
* addition, if a `dom-module` with the same id exists, the first template
|
||||
* in that `dom-module` will be stamped into the shadow root of this element,
|
||||
* with support for declarative event listeners (`on-...`), Polymer data
|
||||
* bindings (`[[...]]` and `{{...}}`), and id-based node finding into
|
||||
* `this.$`.
|
||||
*
|
||||
* `properties`: Object describing property-related metadata used by Polymer
|
||||
* features (key: property names, value: object containing property metadata).
|
||||
* Valid keys in per-property metadata include:
|
||||
* - `type` (String|Number|Object|Array|...): Used by
|
||||
* `attributeChangedCallback` to determine how string-based attributes
|
||||
* are deserialized to JavaScript property values.
|
||||
* - `notify` (boolean): Causes a change in the property to fire a
|
||||
* non-bubbling event called `<property>-changed`. Elements that have
|
||||
* enabled two-way binding to the property use this event to observe changes.
|
||||
* - `readOnly` (boolean): Creates a getter for the property, but no setter.
|
||||
* To set a read-only property, use the private setter method
|
||||
* `_setProperty(property, value)`.
|
||||
* - `observer` (string): Observer method name that will be called when
|
||||
* the property changes. The arguments of the method are
|
||||
* `(value, previousValue)`.
|
||||
* - `computed` (string): String describing method and dependent properties
|
||||
* for computing the value of this property (e.g. `'computeFoo(bar, zot)'`).
|
||||
* Computed properties are read-only by default and can only be changed
|
||||
* via the return value of the computing method.
|
||||
*
|
||||
* `observers`: Array of strings describing multi-property observer methods
|
||||
* and their dependent properties (e.g. `'observeABC(a, b, c)'`).
|
||||
*
|
||||
* `listeners`: Object describing event listeners to be added to each
|
||||
* instance of this element (key: event name, value: method name).
|
||||
*
|
||||
* `behaviors`: Array of additional `info` objects containing metadata
|
||||
* and callbacks in the same format as the `info` object here which are
|
||||
* merged into this element.
|
||||
*
|
||||
* `hostAttributes`: Object listing attributes to be applied to the host
|
||||
* once created (key: attribute name, value: attribute value). Values
|
||||
* are serialized based on the type of the value. Host attributes should
|
||||
* generally be limited to attributes such as `tabIndex` and `aria-...`.
|
||||
* Attributes in `hostAttributes` are only applied if a user-supplied
|
||||
* attribute is not already present (attributes in markup override
|
||||
* `hostAttributes`).
|
||||
*
|
||||
* In addition, the following Polymer-specific callbacks may be provided:
|
||||
* - `registered`: called after first instance of this element,
|
||||
* - `created`: called during `constructor`
|
||||
* - `attached`: called during `connectedCallback`
|
||||
* - `detached`: called during `disconnectedCallback`
|
||||
* - `ready`: called before first `attached`, after all properties of
|
||||
* this element have been propagated to its template and all observers
|
||||
* have run
|
||||
*
|
||||
* @returns Generated class
|
||||
*/
|
||||
declare function Class<T>(info: PolymerInit, mixin: (p0: T) => T): {new(): HTMLElement};
|
||||
|
||||
import {PolymerInit} from '../../interfaces';
|
67
lib/legacy/legacy-data-mixin.d.ts
vendored
Normal file
67
lib/legacy/legacy-data-mixin.d.ts
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/legacy/legacy-data-mixin.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {Class} from './class.js';
|
||||
|
||||
import {Polymer} from '../../polymer-legacy.js';
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
import {templatize} from '../utils/templatize.js';
|
||||
|
||||
declare class UndefinedArgumentError extends Error {
|
||||
constructor(message: any, arg: any);
|
||||
}
|
||||
|
||||
export {LegacyDataMixin};
|
||||
|
||||
|
||||
/**
|
||||
* Mixin to selectively add back Polymer 1.x's `undefined` rules
|
||||
* governing when observers & computing functions run based
|
||||
* on all arguments being defined (reference https://www.polymer-project.org/1.0/docs/devguide/observers#multi-property-observers).
|
||||
*
|
||||
* When loaded, all legacy elements (defined with `Polymer({...})`)
|
||||
* will have the mixin applied. The mixin only restores legacy data handling
|
||||
* if `_legacyUndefinedCheck: true` is set on the element's prototype.
|
||||
*
|
||||
* This mixin is intended for use to help migration from Polymer 1.x to
|
||||
* 2.x+ by allowing legacy code to work while identifying observers and
|
||||
* computing functions that need undefined checks to work without
|
||||
* the mixin in Polymer 2.
|
||||
*/
|
||||
declare function LegacyDataMixin<T extends new (...args: any[]) => {}>(base: T): T & LegacyDataMixinConstructor;
|
||||
|
||||
interface LegacyDataMixinConstructor {
|
||||
new(...args: any[]): LegacyDataMixin;
|
||||
}
|
||||
|
||||
export {LegacyDataMixinConstructor};
|
||||
|
||||
interface LegacyDataMixin {
|
||||
}
|
||||
|
||||
declare function TemplatizeMixin<T extends new (...args: any[]) => {}>(base: T): T & TemplatizeMixinConstructor;
|
||||
|
||||
interface TemplatizeMixinConstructor {
|
||||
new(...args: any[]): TemplatizeMixin;
|
||||
}
|
||||
|
||||
export {TemplatizeMixinConstructor};
|
||||
|
||||
interface TemplatizeMixin {
|
||||
}
|
||||
|
||||
declare class legacyBase extends HTMLElement {
|
||||
}
|
668
lib/legacy/legacy-element-mixin.d.ts
vendored
Normal file
668
lib/legacy/legacy-element-mixin.d.ts
vendored
Normal file
|
@ -0,0 +1,668 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/legacy/legacy-element-mixin.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {ElementMixin} from '../mixins/element-mixin.js';
|
||||
|
||||
import {GestureEventListeners} from '../mixins/gesture-event-listeners.js';
|
||||
|
||||
import {DirMixin} from '../mixins/dir-mixin.js';
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
import {dom, matchesSelector} from './polymer.dom.js';
|
||||
|
||||
import {setTouchAction} from '../utils/gestures.js';
|
||||
|
||||
import {Debouncer} from '../utils/debounce.js';
|
||||
|
||||
import {timeOut, microTask} from '../utils/async.js';
|
||||
|
||||
import {get} from '../utils/path.js';
|
||||
|
||||
import {scopeSubtree} from '../utils/scope-subtree.js';
|
||||
|
||||
import {findObservedAttributesGetter} from '../mixins/disable-upgrade-mixin.js';
|
||||
|
||||
import {register} from '../utils/telemetry.js';
|
||||
|
||||
export {LegacyElementMixin};
|
||||
|
||||
|
||||
/**
|
||||
* Element class mixin that provides Polymer's "legacy" API intended to be
|
||||
* backward-compatible to the greatest extent possible with the API
|
||||
* found on the Polymer 1.x `Polymer.Base` prototype applied to all elements
|
||||
* defined using the `Polymer({...})` function.
|
||||
*/
|
||||
declare function LegacyElementMixin<T extends new (...args: any[]) => {}>(base: T): T & LegacyElementMixinConstructor & ElementMixinConstructor & PropertyEffectsConstructor & TemplateStampConstructor & PropertyAccessorsConstructor & PropertiesChangedConstructor & PropertiesMixinConstructor & GestureEventListenersConstructor & DirMixinConstructor;
|
||||
|
||||
import {ElementMixinConstructor} from '../mixins/element-mixin.js';
|
||||
|
||||
import {PropertyEffectsConstructor, PropertyEffects} from '../mixins/property-effects.js';
|
||||
|
||||
import {TemplateStampConstructor, TemplateStamp} from '../mixins/template-stamp.js';
|
||||
|
||||
import {PropertyAccessorsConstructor, PropertyAccessors} from '../mixins/property-accessors.js';
|
||||
|
||||
import {PropertiesChangedConstructor, PropertiesChanged} from '../mixins/properties-changed.js';
|
||||
|
||||
import {PropertiesMixinConstructor, PropertiesMixin} from '../mixins/properties-mixin.js';
|
||||
|
||||
import {GestureEventListenersConstructor} from '../mixins/gesture-event-listeners.js';
|
||||
|
||||
import {DirMixinConstructor} from '../mixins/dir-mixin.js';
|
||||
|
||||
interface LegacyElementMixinConstructor {
|
||||
new(...args: any[]): LegacyElementMixin;
|
||||
}
|
||||
|
||||
export {LegacyElementMixinConstructor};
|
||||
|
||||
interface LegacyElementMixin extends ElementMixin, PropertyEffects, TemplateStamp, PropertyAccessors, PropertiesChanged, PropertiesMixin, GestureEventListeners, DirMixin {
|
||||
isAttached: boolean;
|
||||
_debouncers: {[key: string]: Function|null}|null;
|
||||
_legacyForceObservedAttributes: boolean|undefined;
|
||||
|
||||
/**
|
||||
* Return the element whose local dom within which this element
|
||||
* is contained. This is a shorthand for
|
||||
* `this.getRootNode().host`.
|
||||
*/
|
||||
readonly domHost: Node|null;
|
||||
is: string;
|
||||
|
||||
/**
|
||||
* Overrides the default `Polymer.PropertyEffects` implementation to
|
||||
* add support for installing `hostAttributes` and `listeners`.
|
||||
*/
|
||||
ready(): void;
|
||||
|
||||
/**
|
||||
* Overrides the default `Polymer.PropertyEffects` implementation to
|
||||
* add support for class initialization via the `_registered` callback.
|
||||
* This is called only when the first instance of the element is created.
|
||||
*/
|
||||
_initializeProperties(): void;
|
||||
_enableProperties(): void;
|
||||
|
||||
/**
|
||||
* Provides an override implementation of `attributeChangedCallback`
|
||||
* which adds the Polymer legacy API's `attributeChanged` method.
|
||||
*
|
||||
* @param name Name of attribute.
|
||||
* @param old Old value of attribute.
|
||||
* @param value Current value of attribute.
|
||||
* @param namespace Attribute namespace.
|
||||
*/
|
||||
attributeChangedCallback(name: string, old: string|null, value: string|null, namespace: string|null): void;
|
||||
|
||||
/**
|
||||
* Provides an implementation of `connectedCallback`
|
||||
* which adds Polymer legacy API's `attached` method.
|
||||
*/
|
||||
connectedCallback(): void;
|
||||
|
||||
/**
|
||||
* Provides an implementation of `disconnectedCallback`
|
||||
* which adds Polymer legacy API's `detached` method.
|
||||
*/
|
||||
disconnectedCallback(): void;
|
||||
_canApplyPropertyDefault(property: any): any;
|
||||
|
||||
/**
|
||||
* Legacy callback called during the `constructor`, for overriding
|
||||
* by the user.
|
||||
*/
|
||||
created(): void;
|
||||
|
||||
/**
|
||||
* Removes an attribute.
|
||||
*
|
||||
* @param name The name of the attribute to remove.
|
||||
*/
|
||||
removeAttribute(name: string): void;
|
||||
|
||||
/**
|
||||
* Legacy callback called during `connectedCallback`, for overriding
|
||||
* by the user.
|
||||
*/
|
||||
attached(): void;
|
||||
|
||||
/**
|
||||
* Legacy callback called during `disconnectedCallback`, for overriding
|
||||
* by the user.
|
||||
*/
|
||||
detached(): void;
|
||||
|
||||
/**
|
||||
* Legacy callback called during `attributeChangedChallback`, for overriding
|
||||
* by the user.
|
||||
*
|
||||
* @param name Name of attribute.
|
||||
* @param old Old value of attribute.
|
||||
* @param value Current value of attribute.
|
||||
*/
|
||||
attributeChanged(name: string, old: string|null, value: string|null): void;
|
||||
_takeAttributes(): void;
|
||||
|
||||
/**
|
||||
* Called automatically when an element is initializing.
|
||||
* Users may override this method to perform class registration time
|
||||
* work. The implementation should ensure the work is performed
|
||||
* only once for the class.
|
||||
*/
|
||||
_registered(): void;
|
||||
|
||||
/**
|
||||
* Ensures an element has required attributes. Called when the element
|
||||
* is being readied via `ready`. Users should override to set the
|
||||
* element's required attributes. The implementation should be sure
|
||||
* to check and not override existing attributes added by
|
||||
* the user of the element. Typically, setting attributes should be left
|
||||
* to the element user and not done here; reasonable exceptions include
|
||||
* setting aria roles and focusability.
|
||||
*/
|
||||
_ensureAttributes(): void;
|
||||
|
||||
/**
|
||||
* Adds element event listeners. Called when the element
|
||||
* is being readied via `ready`. Users should override to
|
||||
* add any required element event listeners.
|
||||
* In performance critical elements, the work done here should be kept
|
||||
* to a minimum since it is done before the element is rendered. In
|
||||
* these elements, consider adding listeners asynchronously so as not to
|
||||
* block render.
|
||||
*/
|
||||
_applyListeners(): void;
|
||||
|
||||
/**
|
||||
* Converts a typed JavaScript value to a string.
|
||||
*
|
||||
* Note this method is provided as backward-compatible legacy API
|
||||
* only. It is not directly called by any Polymer features. To customize
|
||||
* how properties are serialized to attributes for attribute bindings and
|
||||
* `reflectToAttribute: true` properties as well as this method, override
|
||||
* the `_serializeValue` method provided by `Polymer.PropertyAccessors`.
|
||||
*
|
||||
* @param value Value to deserialize
|
||||
* @returns Serialized value
|
||||
*/
|
||||
serialize(value: any): string|undefined;
|
||||
|
||||
/**
|
||||
* Converts a string to a typed JavaScript value.
|
||||
*
|
||||
* Note this method is provided as backward-compatible legacy API
|
||||
* only. It is not directly called by any Polymer features. To customize
|
||||
* how attributes are deserialized to properties for in
|
||||
* `attributeChangedCallback`, override `_deserializeValue` method
|
||||
* provided by `Polymer.PropertyAccessors`.
|
||||
*
|
||||
* @param value String to deserialize
|
||||
* @param type Type to deserialize the string to
|
||||
* @returns Returns the deserialized value in the `type` given.
|
||||
*/
|
||||
deserialize(value: string, type: any): any;
|
||||
|
||||
/**
|
||||
* Serializes a property to its associated attribute.
|
||||
*
|
||||
* Note this method is provided as backward-compatible legacy API
|
||||
* only. It is not directly called by any Polymer features.
|
||||
*
|
||||
* @param property Property name to reflect.
|
||||
* @param attribute Attribute name to reflect.
|
||||
* @param value Property value to reflect.
|
||||
*/
|
||||
reflectPropertyToAttribute(property: string, attribute?: string, value?: any): void;
|
||||
|
||||
/**
|
||||
* Sets a typed value to an HTML attribute on a node.
|
||||
*
|
||||
* Note this method is provided as backward-compatible legacy API
|
||||
* only. It is not directly called by any Polymer features.
|
||||
*
|
||||
* @param value Value to serialize.
|
||||
* @param attribute Attribute name to serialize to.
|
||||
* @param node Element to set attribute to.
|
||||
*/
|
||||
serializeValueToAttribute(value: any, attribute: string, node: Element|null): void;
|
||||
|
||||
/**
|
||||
* Copies own properties (including accessor descriptors) from a source
|
||||
* object to a target object.
|
||||
*
|
||||
* @param prototype Target object to copy properties to.
|
||||
* @param api Source object to copy properties from.
|
||||
* @returns prototype object that was passed as first argument.
|
||||
*/
|
||||
extend(prototype: object|null, api: object|null): object|null;
|
||||
|
||||
/**
|
||||
* Copies props from a source object to a target object.
|
||||
*
|
||||
* Note, this method uses a simple `for...in` strategy for enumerating
|
||||
* properties. To ensure only `ownProperties` are copied from source
|
||||
* to target and that accessor implementations are copied, use `extend`.
|
||||
*
|
||||
* @param target Target object to copy properties to.
|
||||
* @param source Source object to copy properties from.
|
||||
* @returns Target object that was passed as first argument.
|
||||
*/
|
||||
mixin(target: object, source: object): object;
|
||||
|
||||
/**
|
||||
* Sets the prototype of an object.
|
||||
*
|
||||
* Note this method is provided as backward-compatible legacy API
|
||||
* only. It is not directly called by any Polymer features.
|
||||
*
|
||||
* @param object The object on which to set the prototype.
|
||||
* @param prototype The prototype that will be set on the given
|
||||
* `object`.
|
||||
* @returns Returns the given `object` with its prototype set
|
||||
* to the given `prototype` object.
|
||||
*/
|
||||
chainObject(object: object|null, prototype: object|null): object|null;
|
||||
|
||||
/**
|
||||
* Calls `importNode` on the `content` of the `template` specified and
|
||||
* returns a document fragment containing the imported content.
|
||||
*
|
||||
* @param template HTML template element to instance.
|
||||
* @returns Document fragment containing the imported
|
||||
* template content.
|
||||
*/
|
||||
instanceTemplate(template: HTMLTemplateElement|null): DocumentFragment;
|
||||
|
||||
/**
|
||||
* Dispatches a custom event with an optional detail value.
|
||||
*
|
||||
* @param type Name of event type.
|
||||
* @param detail Detail value containing event-specific
|
||||
* payload.
|
||||
* @param options Object specifying options. These may include:
|
||||
* `bubbles` (boolean, defaults to `true`),
|
||||
* `cancelable` (boolean, defaults to false), and
|
||||
* `node` on which to fire the event (HTMLElement, defaults to `this`).
|
||||
* @returns The new event that was fired.
|
||||
*/
|
||||
fire(type: string, detail?: any, options?: {bubbles?: boolean, cancelable?: boolean, composed?: boolean}): Event;
|
||||
|
||||
/**
|
||||
* Convenience method to add an event listener on a given element,
|
||||
* late bound to a named method on this element.
|
||||
*
|
||||
* @param node Element to add event listener to.
|
||||
* @param eventName Name of event to listen for.
|
||||
* @param methodName Name of handler method on `this` to call.
|
||||
*/
|
||||
listen(node: EventTarget|null, eventName: string, methodName: string): void;
|
||||
|
||||
/**
|
||||
* Convenience method to remove an event listener from a given element,
|
||||
* late bound to a named method on this element.
|
||||
*
|
||||
* @param node Element to remove event listener from.
|
||||
* @param eventName Name of event to stop listening to.
|
||||
* @param methodName Name of handler method on `this` to not call
|
||||
* anymore.
|
||||
*/
|
||||
unlisten(node: EventTarget|null, eventName: string, methodName: string): void;
|
||||
|
||||
/**
|
||||
* Override scrolling behavior to all direction, one direction, or none.
|
||||
*
|
||||
* Valid scroll directions:
|
||||
* - 'all': scroll in any direction
|
||||
* - 'x': scroll only in the 'x' direction
|
||||
* - 'y': scroll only in the 'y' direction
|
||||
* - 'none': disable scrolling for this node
|
||||
*
|
||||
* @param direction Direction to allow scrolling
|
||||
* Defaults to `all`.
|
||||
* @param node Element to apply scroll direction setting.
|
||||
* Defaults to `this`.
|
||||
*/
|
||||
setScrollDirection(direction?: string, node?: Element|null): void;
|
||||
|
||||
/**
|
||||
* Convenience method to run `querySelector` on this local DOM scope.
|
||||
*
|
||||
* This function calls `Polymer.dom(this.root).querySelector(slctr)`.
|
||||
*
|
||||
* @param slctr Selector to run on this local DOM scope
|
||||
* @returns Element found by the selector, or null if not found.
|
||||
*/
|
||||
$$(slctr: string): Element|null;
|
||||
|
||||
/**
|
||||
* Force this element to distribute its children to its local dom.
|
||||
* This should not be necessary as of Polymer 2.0.2 and is provided only
|
||||
* for backwards compatibility.
|
||||
*/
|
||||
distributeContent(): void;
|
||||
|
||||
/**
|
||||
* Returns a list of nodes that are the effective childNodes. The effective
|
||||
* childNodes list is the same as the element's childNodes except that
|
||||
* any `<content>` elements are replaced with the list of nodes distributed
|
||||
* to the `<content>`, the result of its `getDistributedNodes` method.
|
||||
*
|
||||
* @returns List of effective child nodes.
|
||||
*/
|
||||
getEffectiveChildNodes(): Node[];
|
||||
|
||||
/**
|
||||
* Returns a list of nodes distributed within this element that match
|
||||
* `selector`. These can be dom children or elements distributed to
|
||||
* children that are insertion points.
|
||||
*
|
||||
* @param selector Selector to run.
|
||||
* @returns List of distributed elements that match selector.
|
||||
*/
|
||||
queryDistributedElements(selector: string): Node[];
|
||||
|
||||
/**
|
||||
* Returns a list of elements that are the effective children. The effective
|
||||
* children list is the same as the element's children except that
|
||||
* any `<content>` elements are replaced with the list of elements
|
||||
* distributed to the `<content>`.
|
||||
*
|
||||
* @returns List of effective children.
|
||||
*/
|
||||
getEffectiveChildren(): Node[];
|
||||
|
||||
/**
|
||||
* Returns a string of text content that is the concatenation of the
|
||||
* text content's of the element's effective childNodes (the elements
|
||||
* returned by <a href="#getEffectiveChildNodes>getEffectiveChildNodes</a>.
|
||||
*
|
||||
* @returns List of effective children.
|
||||
*/
|
||||
getEffectiveTextContent(): string;
|
||||
|
||||
/**
|
||||
* Returns the first effective childNode within this element that
|
||||
* match `selector`. These can be dom child nodes or elements distributed
|
||||
* to children that are insertion points.
|
||||
*
|
||||
* @param selector Selector to run.
|
||||
* @returns First effective child node that matches selector.
|
||||
*/
|
||||
queryEffectiveChildren(selector: string): Node|null;
|
||||
|
||||
/**
|
||||
* Returns a list of effective childNodes within this element that
|
||||
* match `selector`. These can be dom child nodes or elements distributed
|
||||
* to children that are insertion points.
|
||||
*
|
||||
* @param selector Selector to run.
|
||||
* @returns List of effective child nodes that match
|
||||
* selector.
|
||||
*/
|
||||
queryAllEffectiveChildren(selector: string): Node[];
|
||||
|
||||
/**
|
||||
* Returns a list of nodes distributed to this element's `<slot>`.
|
||||
*
|
||||
* If this element contains more than one `<slot>` in its local DOM,
|
||||
* an optional selector may be passed to choose the desired content.
|
||||
*
|
||||
* @param slctr CSS selector to choose the desired
|
||||
* `<slot>`. Defaults to `content`.
|
||||
* @returns List of distributed nodes for the `<slot>`.
|
||||
*/
|
||||
getContentChildNodes(slctr?: string): Node[];
|
||||
|
||||
/**
|
||||
* Returns a list of element children distributed to this element's
|
||||
* `<slot>`.
|
||||
*
|
||||
* If this element contains more than one `<slot>` in its
|
||||
* local DOM, an optional selector may be passed to choose the desired
|
||||
* content. This method differs from `getContentChildNodes` in that only
|
||||
* elements are returned.
|
||||
*
|
||||
* @param slctr CSS selector to choose the desired
|
||||
* `<content>`. Defaults to `content`.
|
||||
* @returns List of distributed nodes for the
|
||||
* `<slot>`.
|
||||
*/
|
||||
getContentChildren(slctr?: string): HTMLElement[];
|
||||
|
||||
/**
|
||||
* Checks whether an element is in this element's light DOM tree.
|
||||
*
|
||||
* @param node The element to be checked.
|
||||
* @returns true if node is in this element's light DOM tree.
|
||||
*/
|
||||
isLightDescendant(node: Node|null): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether an element is in this element's local DOM tree.
|
||||
*
|
||||
* @param node The element to be checked.
|
||||
* @returns true if node is in this element's local DOM tree.
|
||||
*/
|
||||
isLocalDescendant(node: Element): boolean;
|
||||
|
||||
/**
|
||||
* No-op for backwards compatibility. This should now be handled by
|
||||
* ShadyCss library.
|
||||
*
|
||||
* @param container Container element to scope
|
||||
* @param shouldObserve if true, start a mutation observer for added nodes to the container
|
||||
* @returns Returns a new MutationObserver on `container` if `shouldObserve` is true.
|
||||
*/
|
||||
scopeSubtree(container: Element, shouldObserve?: boolean): MutationObserver|null;
|
||||
|
||||
/**
|
||||
* Returns the computed style value for the given property.
|
||||
*
|
||||
* @param property The css property name.
|
||||
* @returns Returns the computed css property value for the given
|
||||
* `property`.
|
||||
*/
|
||||
getComputedStyleValue(property: string): string;
|
||||
|
||||
/**
|
||||
* Call `debounce` to collapse multiple requests for a named task into
|
||||
* one invocation which is made after the wait time has elapsed with
|
||||
* no new request. If no wait time is given, the callback will be called
|
||||
* at microtask timing (guaranteed before paint).
|
||||
*
|
||||
* debouncedClickAction(e) {
|
||||
* // will not call `processClick` more than once per 100ms
|
||||
* this.debounce('click', function() {
|
||||
* this.processClick();
|
||||
* } 100);
|
||||
* }
|
||||
*
|
||||
* @param jobName String to identify the debounce job.
|
||||
* @param callback Function that is called (with `this`
|
||||
* context) when the wait time elapses.
|
||||
* @param wait Optional wait time in milliseconds (ms) after the
|
||||
* last signal that must elapse before invoking `callback`
|
||||
* @returns Returns a debouncer object on which exists the
|
||||
* following methods: `isActive()` returns true if the debouncer is
|
||||
* active; `cancel()` cancels the debouncer if it is active;
|
||||
* `flush()` immediately invokes the debounced callback if the debouncer
|
||||
* is active.
|
||||
*/
|
||||
debounce(jobName: string, callback: () => void, wait?: number): object;
|
||||
|
||||
/**
|
||||
* Returns whether a named debouncer is active.
|
||||
*
|
||||
* @param jobName The name of the debouncer started with `debounce`
|
||||
* @returns Whether the debouncer is active (has not yet fired).
|
||||
*/
|
||||
isDebouncerActive(jobName: string): boolean;
|
||||
|
||||
/**
|
||||
* Immediately calls the debouncer `callback` and inactivates it.
|
||||
*
|
||||
* @param jobName The name of the debouncer started with `debounce`
|
||||
*/
|
||||
flushDebouncer(jobName: string): void;
|
||||
|
||||
/**
|
||||
* Cancels an active debouncer. The `callback` will not be called.
|
||||
*
|
||||
* @param jobName The name of the debouncer started with `debounce`
|
||||
*/
|
||||
cancelDebouncer(jobName: string): void;
|
||||
|
||||
/**
|
||||
* Runs a callback function asynchronously.
|
||||
*
|
||||
* By default (if no waitTime is specified), async callbacks are run at
|
||||
* microtask timing, which will occur before paint.
|
||||
*
|
||||
* @param callback The callback function to run, bound to
|
||||
* `this`.
|
||||
* @param waitTime Time to wait before calling the
|
||||
* `callback`. If unspecified or 0, the callback will be run at microtask
|
||||
* timing (before paint).
|
||||
* @returns Handle that may be used to cancel the async job.
|
||||
*/
|
||||
async(callback: Function, waitTime?: number): number;
|
||||
|
||||
/**
|
||||
* Cancels an async operation started with `async`.
|
||||
*
|
||||
* @param handle Handle returned from original `async` call to
|
||||
* cancel.
|
||||
*/
|
||||
cancelAsync(handle: number): void;
|
||||
|
||||
/**
|
||||
* Convenience method for creating an element and configuring it.
|
||||
*
|
||||
* @param tag HTML element tag to create.
|
||||
* @param props Object of properties to configure on the
|
||||
* instance.
|
||||
* @returns Newly created and configured element.
|
||||
*/
|
||||
create(tag: string, props?: object|null): Element;
|
||||
|
||||
/**
|
||||
* Polyfill for Element.prototype.matches, which is sometimes still
|
||||
* prefixed.
|
||||
*
|
||||
* @param selector Selector to test.
|
||||
* @param node Element to test the selector against.
|
||||
* @returns Whether the element matches the selector.
|
||||
*/
|
||||
elementMatches(selector: string, node?: Element): boolean;
|
||||
|
||||
/**
|
||||
* Toggles an HTML attribute on or off.
|
||||
*
|
||||
* @param name HTML attribute name
|
||||
* @param bool Boolean to force the attribute on or off.
|
||||
* When unspecified, the state of the attribute will be reversed.
|
||||
* @returns true if the attribute now exists
|
||||
*/
|
||||
toggleAttribute(name: string, bool?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Toggles a CSS class on or off.
|
||||
*
|
||||
* @param name CSS class name
|
||||
* @param bool Boolean to force the class on or off.
|
||||
* When unspecified, the state of the class will be reversed.
|
||||
* @param node Node to target. Defaults to `this`.
|
||||
*/
|
||||
toggleClass(name: string, bool?: boolean, node?: Element|null): void;
|
||||
|
||||
/**
|
||||
* Cross-platform helper for setting an element's CSS `transform` property.
|
||||
*
|
||||
* @param transformText Transform setting.
|
||||
* @param node Element to apply the transform to.
|
||||
* Defaults to `this`
|
||||
*/
|
||||
transform(transformText: string, node?: Element|null): void;
|
||||
|
||||
/**
|
||||
* Cross-platform helper for setting an element's CSS `translate3d`
|
||||
* property.
|
||||
*
|
||||
* @param x X offset.
|
||||
* @param y Y offset.
|
||||
* @param z Z offset.
|
||||
* @param node Element to apply the transform to.
|
||||
* Defaults to `this`.
|
||||
*/
|
||||
translate3d(x: number|string, y: number|string, z: number|string, node?: Element|null): void;
|
||||
|
||||
/**
|
||||
* Removes an item from an array, if it exists.
|
||||
*
|
||||
* If the array is specified by path, a change notification is
|
||||
* generated, so that observers, data bindings and computed
|
||||
* properties watching that path can update.
|
||||
*
|
||||
* If the array is passed directly, **no change
|
||||
* notification is generated**.
|
||||
*
|
||||
* @param arrayOrPath Path to array from
|
||||
* which to remove the item
|
||||
* (or the array itself).
|
||||
* @param item Item to remove.
|
||||
* @returns Array containing item removed.
|
||||
*/
|
||||
arrayDelete(arrayOrPath: string|Array<number|string>, item: any): any[]|null;
|
||||
|
||||
/**
|
||||
* Facades `console.log`/`warn`/`error` as override point.
|
||||
*
|
||||
* @param level One of 'log', 'warn', 'error'
|
||||
* @param args Array of strings or objects to log
|
||||
*/
|
||||
_logger(level: string, args: any[]|null): void;
|
||||
|
||||
/**
|
||||
* Facades `console.log` as an override point.
|
||||
*
|
||||
* @param args Array of strings or objects to log
|
||||
*/
|
||||
_log(...args: any[]): void;
|
||||
|
||||
/**
|
||||
* Facades `console.warn` as an override point.
|
||||
*
|
||||
* @param args Array of strings or objects to log
|
||||
*/
|
||||
_warn(...args: any[]): void;
|
||||
|
||||
/**
|
||||
* Facades `console.error` as an override point.
|
||||
*
|
||||
* @param args Array of strings or objects to log
|
||||
*/
|
||||
_error(...args: any[]): void;
|
||||
|
||||
/**
|
||||
* Formats a message using the element type an a method name.
|
||||
*
|
||||
* @param methodName Method name to associate with message
|
||||
* @param args Array of strings or objects to log
|
||||
* @returns Array with formatting information for `console`
|
||||
* logging.
|
||||
*/
|
||||
_logf(methodName: string, ...args: any[]): any[];
|
||||
}
|
140
lib/legacy/mutable-data-behavior.d.ts
vendored
Normal file
140
lib/legacy/mutable-data-behavior.d.ts
vendored
Normal file
|
@ -0,0 +1,140 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/legacy/mutable-data-behavior.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {MutableData} from '../mixins/mutable-data.js';
|
||||
|
||||
export {MutableDataBehavior};
|
||||
|
||||
/**
|
||||
* Legacy element behavior to skip strict dirty-checking for objects and arrays,
|
||||
* (always consider them to be "dirty") for use on legacy API Polymer elements.
|
||||
*
|
||||
* By default, `Polymer.PropertyEffects` performs strict dirty checking on
|
||||
* objects, which means that any deep modifications to an object or array will
|
||||
* not be propagated unless "immutable" data patterns are used (i.e. all object
|
||||
* references from the root to the mutation were changed).
|
||||
*
|
||||
* Polymer also provides a proprietary data mutation and path notification API
|
||||
* (e.g. `notifyPath`, `set`, and array mutation API's) that allow efficient
|
||||
* mutation and notification of deep changes in an object graph to all elements
|
||||
* bound to the same object graph.
|
||||
*
|
||||
* In cases where neither immutable patterns nor the data mutation API can be
|
||||
* used, applying this mixin will cause Polymer to skip dirty checking for
|
||||
* objects and arrays (always consider them to be "dirty"). This allows a
|
||||
* user to make a deep modification to a bound object graph, and then either
|
||||
* simply re-set the object (e.g. `this.items = this.items`) or call `notifyPath`
|
||||
* (e.g. `this.notifyPath('items')`) to update the tree. Note that all
|
||||
* elements that wish to be updated based on deep mutations must apply this
|
||||
* mixin or otherwise skip strict dirty checking for objects/arrays.
|
||||
* Specifically, any elements in the binding tree between the source of a
|
||||
* mutation and the consumption of it must apply this behavior or enable the
|
||||
* `Polymer.OptionalMutableDataBehavior`.
|
||||
*
|
||||
* In order to make the dirty check strategy configurable, see
|
||||
* `Polymer.OptionalMutableDataBehavior`.
|
||||
*
|
||||
* Note, the performance characteristics of propagating large object graphs
|
||||
* will be worse as opposed to using strict dirty checking with immutable
|
||||
* patterns or Polymer's path notification API.
|
||||
*/
|
||||
interface MutableDataBehavior {
|
||||
|
||||
/**
|
||||
* Overrides `Polymer.PropertyEffects` to provide option for skipping
|
||||
* strict equality checking for Objects and Arrays.
|
||||
*
|
||||
* This method pulls the value to dirty check against from the `__dataTemp`
|
||||
* cache (rather than the normal `__data` cache) for Objects. Since the temp
|
||||
* cache is cleared at the end of a turn, this implementation allows
|
||||
* side-effects of deep object changes to be processed by re-setting the
|
||||
* same object (using the temp cache as an in-turn backstop to prevent
|
||||
* cycles due to 2-way notification).
|
||||
*
|
||||
* @param property Property name
|
||||
* @param value New property value
|
||||
* @param old Previous property value
|
||||
* @returns Whether the property should be considered a change
|
||||
*/
|
||||
_shouldPropertyChange(property: string, value: any, old: any): boolean;
|
||||
}
|
||||
|
||||
declare const MutableDataBehavior: object;
|
||||
|
||||
export {OptionalMutableDataBehavior};
|
||||
|
||||
/**
|
||||
* Legacy element behavior to add the optional ability to skip strict
|
||||
* dirty-checking for objects and arrays (always consider them to be
|
||||
* "dirty") by setting a `mutable-data` attribute on an element instance.
|
||||
*
|
||||
* By default, `Polymer.PropertyEffects` performs strict dirty checking on
|
||||
* objects, which means that any deep modifications to an object or array will
|
||||
* not be propagated unless "immutable" data patterns are used (i.e. all object
|
||||
* references from the root to the mutation were changed).
|
||||
*
|
||||
* Polymer also provides a proprietary data mutation and path notification API
|
||||
* (e.g. `notifyPath`, `set`, and array mutation API's) that allow efficient
|
||||
* mutation and notification of deep changes in an object graph to all elements
|
||||
* bound to the same object graph.
|
||||
*
|
||||
* In cases where neither immutable patterns nor the data mutation API can be
|
||||
* used, applying this mixin will allow Polymer to skip dirty checking for
|
||||
* objects and arrays (always consider them to be "dirty"). This allows a
|
||||
* user to make a deep modification to a bound object graph, and then either
|
||||
* simply re-set the object (e.g. `this.items = this.items`) or call `notifyPath`
|
||||
* (e.g. `this.notifyPath('items')`) to update the tree. Note that all
|
||||
* elements that wish to be updated based on deep mutations must apply this
|
||||
* mixin or otherwise skip strict dirty checking for objects/arrays.
|
||||
* Specifically, any elements in the binding tree between the source of a
|
||||
* mutation and the consumption of it must enable this behavior or apply the
|
||||
* `Polymer.OptionalMutableDataBehavior`.
|
||||
*
|
||||
* While this behavior adds the ability to forgo Object/Array dirty checking,
|
||||
* the `mutableData` flag defaults to false and must be set on the instance.
|
||||
*
|
||||
* Note, the performance characteristics of propagating large object graphs
|
||||
* will be worse by relying on `mutableData: true` as opposed to using
|
||||
* strict dirty checking with immutable patterns or Polymer's path notification
|
||||
* API.
|
||||
*/
|
||||
interface OptionalMutableDataBehavior {
|
||||
|
||||
/**
|
||||
* Instance-level flag for configuring the dirty-checking strategy
|
||||
* for this element. When true, Objects and Arrays will skip dirty
|
||||
* checking, otherwise strict equality checking will be used.
|
||||
*/
|
||||
mutableData: boolean|null|undefined;
|
||||
|
||||
/**
|
||||
* Overrides `Polymer.PropertyEffects` to skip strict equality checking
|
||||
* for Objects and Arrays.
|
||||
*
|
||||
* Pulls the value to dirty check against from the `__dataTemp` cache
|
||||
* (rather than the normal `__data` cache) for Objects. Since the temp
|
||||
* cache is cleared at the end of a turn, this implementation allows
|
||||
* side-effects of deep object changes to be processed by re-setting the
|
||||
* same object (using the temp cache as an in-turn backstop to prevent
|
||||
* cycles due to 2-way notification).
|
||||
*
|
||||
* @param property Property name
|
||||
* @param value New property value
|
||||
* @param old Previous property value
|
||||
* @returns Whether the property should be considered a change
|
||||
*/
|
||||
_shouldPropertyChange(property: string, value: any, old: any): boolean;
|
||||
}
|
||||
|
||||
declare const OptionalMutableDataBehavior: object;
|
34
lib/legacy/polymer-fn.d.ts
vendored
Normal file
34
lib/legacy/polymer-fn.d.ts
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/legacy/polymer-fn.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
import {Class} from './class.js';
|
||||
|
||||
|
||||
/**
|
||||
* Legacy class factory and registration helper for defining Polymer
|
||||
* elements.
|
||||
*
|
||||
* This method is equivalent to
|
||||
*
|
||||
* import {Class} from '@polymer/polymer/lib/legacy/class.js';
|
||||
* customElements.define(info.is, Class(info));
|
||||
*
|
||||
* See `Class` for details on valid legacy metadata format for `info`.
|
||||
*
|
||||
* @returns Generated class
|
||||
*/
|
||||
declare function Polymer(info: PolymerInit): {new(): HTMLElement};
|
||||
|
||||
export {Polymer};
|
||||
|
||||
import {PolymerInit} from '../../interfaces';
|
196
lib/legacy/polymer.dom.d.ts
vendored
Normal file
196
lib/legacy/polymer.dom.d.ts
vendored
Normal file
|
@ -0,0 +1,196 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/legacy/polymer.dom.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {FlattenedNodesObserver} from '../utils/flattened-nodes-observer.js';
|
||||
|
||||
export {flush, enqueueDebouncer as addDebouncer} from '../utils/flush.js';
|
||||
|
||||
import {Debouncer} from '../utils/debounce.js';
|
||||
|
||||
export {matchesSelector};
|
||||
|
||||
|
||||
/**
|
||||
* Cross-platform `element.matches` shim.
|
||||
*
|
||||
* @returns True if node matched selector
|
||||
*/
|
||||
declare function matchesSelector(node: Node, selector: string): boolean;
|
||||
|
||||
/**
|
||||
* Node API wrapper class returned from `Polymer.dom.(target)` when
|
||||
* `target` is a `Node`.
|
||||
*/
|
||||
declare class DomApiNative {
|
||||
|
||||
/**
|
||||
* For shadow roots, returns the currently focused element within this
|
||||
* shadow root.
|
||||
*
|
||||
* return {Node|undefined} Currently focused element
|
||||
*/
|
||||
readonly activeElement: any;
|
||||
parentNode: Node|null;
|
||||
firstChild: Node|null;
|
||||
lastChild: Node|null;
|
||||
nextSibling: Node|null;
|
||||
previousSibling: Node|null;
|
||||
firstElementChild: HTMLElement|null;
|
||||
lastElementChild: HTMLElement|null;
|
||||
nextElementSibling: HTMLElement|null;
|
||||
previousElementSibling: HTMLElement|null;
|
||||
childNodes: Node[];
|
||||
children: HTMLElement[];
|
||||
classList: DOMTokenList|null;
|
||||
textContent: string;
|
||||
innerHTML: string;
|
||||
|
||||
/**
|
||||
* @param node Node for which to create a Polymer.dom helper object.
|
||||
*/
|
||||
constructor(node: Node);
|
||||
|
||||
/**
|
||||
* Returns an instance of `FlattenedNodesObserver` that
|
||||
* listens for node changes on this element.
|
||||
*
|
||||
* @param callback Called when direct or distributed children
|
||||
* of this element changes
|
||||
* @returns Observer instance
|
||||
*/
|
||||
observeNodes(callback: (p0: {target: HTMLElement, addedNodes: Element[], removedNodes: Element[]}) => void): FlattenedNodesObserver;
|
||||
|
||||
/**
|
||||
* Disconnects an observer previously created via `observeNodes`
|
||||
*
|
||||
* @param observerHandle Observer instance
|
||||
* to disconnect.
|
||||
*/
|
||||
unobserveNodes(observerHandle: FlattenedNodesObserver): void;
|
||||
|
||||
/**
|
||||
* Provided as a backwards-compatible API only. This method does nothing.
|
||||
*/
|
||||
notifyObserver(): void;
|
||||
|
||||
/**
|
||||
* Returns true if the provided node is contained with this element's
|
||||
* light-DOM children or shadow root, including any nested shadow roots
|
||||
* of children therein.
|
||||
*
|
||||
* @param node Node to test
|
||||
* @returns Returns true if the given `node` is contained within
|
||||
* this element's light or shadow DOM.
|
||||
*/
|
||||
deepContains(node: Node|null): boolean;
|
||||
|
||||
/**
|
||||
* Returns the root node of this node. Equivalent to `getRootNode()`.
|
||||
*
|
||||
* @returns Top most element in the dom tree in which the node
|
||||
* exists. If the node is connected to a document this is either a
|
||||
* shadowRoot or the document; otherwise, it may be the node
|
||||
* itself or a node or document fragment containing it.
|
||||
*/
|
||||
getOwnerRoot(): Node;
|
||||
|
||||
/**
|
||||
* For slot elements, returns the nodes assigned to the slot; otherwise
|
||||
* an empty array. It is equivalent to `<slot>.addignedNodes({flatten:true})`.
|
||||
*
|
||||
* @returns Array of assigned nodes
|
||||
*/
|
||||
getDistributedNodes(): Node[];
|
||||
|
||||
/**
|
||||
* Returns an array of all slots this element was distributed to.
|
||||
*
|
||||
* @returns Description
|
||||
*/
|
||||
getDestinationInsertionPoints(): HTMLSlotElement[];
|
||||
|
||||
/**
|
||||
* Calls `importNode` on the `ownerDocument` for this node.
|
||||
*
|
||||
* @param node Node to import
|
||||
* @param deep True if the node should be cloned deeply during
|
||||
* import
|
||||
* @returns Clone of given node imported to this owner document
|
||||
*/
|
||||
importNode(node: Node, deep: boolean): Node|null;
|
||||
|
||||
/**
|
||||
* @returns Returns a flattened list of all child nodes and
|
||||
* nodes assigned to child slots.
|
||||
*/
|
||||
getEffectiveChildNodes(): Node[];
|
||||
|
||||
/**
|
||||
* Returns a filtered list of flattened child elements for this element based
|
||||
* on the given selector.
|
||||
*
|
||||
* @param selector Selector to filter nodes against
|
||||
* @returns List of flattened child elements
|
||||
*/
|
||||
queryDistributedElements(selector: string): HTMLElement[];
|
||||
cloneNode(deep?: boolean): Node;
|
||||
appendChild(node: Node): Node;
|
||||
insertBefore(newChild: Node, refChild: Node|null): Node;
|
||||
removeChild(node: Node): Node;
|
||||
replaceChild(oldChild: Node, newChild: Node): Node;
|
||||
removeAttribute(name: string): void;
|
||||
querySelector(selector: string): Element|null;
|
||||
querySelectorAll(selector: string): NodeListOf<Element>;
|
||||
}
|
||||
|
||||
export {EventApi};
|
||||
|
||||
/**
|
||||
* Event API wrapper class returned from `dom.(target)` when
|
||||
* `target` is an `Event`.
|
||||
*/
|
||||
declare class EventApi {
|
||||
|
||||
/**
|
||||
* Returns the first node on the `composedPath` of this event.
|
||||
*/
|
||||
readonly rootTarget: EventTarget;
|
||||
|
||||
/**
|
||||
* Returns the local (re-targeted) target for this event.
|
||||
*/
|
||||
readonly localTarget: EventTarget;
|
||||
|
||||
/**
|
||||
* Returns the `composedPath` for this event.
|
||||
*/
|
||||
readonly path: EventTarget[];
|
||||
constructor(event: any);
|
||||
}
|
||||
|
||||
export {dom};
|
||||
|
||||
|
||||
/**
|
||||
* Legacy DOM and Event manipulation API wrapper factory used to abstract
|
||||
* differences between native Shadow DOM and "Shady DOM" when polyfilling on
|
||||
* older browsers.
|
||||
*
|
||||
* Note that in Polymer 2.x use of `Polymer.dom` is no longer required and
|
||||
* in the majority of cases simply facades directly to the standard native
|
||||
* API.
|
||||
*
|
||||
* @returns Wrapper providing either node API or event API
|
||||
*/
|
||||
declare function dom(obj?: Node|Event|DomApiNative|EventApi|null): DomApiNative|EventApi;
|
119
lib/legacy/templatizer-behavior.d.ts
vendored
Normal file
119
lib/legacy/templatizer-behavior.d.ts
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/legacy/templatizer-behavior.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
import {TemplateInstanceBase, templatize, modelForElement} from '../utils/templatize.js';
|
||||
|
||||
export {Templatizer};
|
||||
|
||||
/**
|
||||
* The `Templatizer` behavior adds methods to generate instances of
|
||||
* templates that are each managed by an anonymous `PropertyEffects`
|
||||
* instance where data-bindings in the stamped template content are bound to
|
||||
* accessors on itself.
|
||||
*
|
||||
* This behavior is provided in Polymer 2.x-3.x as a hybrid-element convenience
|
||||
* only. For non-hybrid usage, the `Templatize` library
|
||||
* should be used instead.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||
* // Get a template from somewhere, e.g. light DOM
|
||||
* let template = this.querySelector('template');
|
||||
* // Prepare the template
|
||||
* this.templatize(template);
|
||||
* // Instance the template with an initial data model
|
||||
* let instance = this.stamp({myProp: 'initial'});
|
||||
* // Insert the instance's DOM somewhere, e.g. light DOM
|
||||
* dom(this).appendChild(instance.root);
|
||||
* // Changing a property on the instance will propagate to bindings
|
||||
* // in the template
|
||||
* instance.myProp = 'new value';
|
||||
*
|
||||
* Users of `Templatizer` may need to implement the following abstract
|
||||
* API's to determine how properties and paths from the host should be
|
||||
* forwarded into to instances:
|
||||
*
|
||||
* _forwardHostPropV2: function(prop, value)
|
||||
*
|
||||
* Likewise, users may implement these additional abstract API's to determine
|
||||
* how instance-specific properties that change on the instance should be
|
||||
* forwarded out to the host, if necessary.
|
||||
*
|
||||
* _notifyInstancePropV2: function(inst, prop, value)
|
||||
*
|
||||
* In order to determine which properties are instance-specific and require
|
||||
* custom notification via `_notifyInstanceProp`, define an `_instanceProps`
|
||||
* object containing keys for each instance prop, for example:
|
||||
*
|
||||
* _instanceProps: {
|
||||
* item: true,
|
||||
* index: true
|
||||
* }
|
||||
*
|
||||
* Any properties used in the template that are not defined in _instanceProp
|
||||
* will be forwarded out to the Templatize `owner` automatically.
|
||||
*
|
||||
* Users may also implement the following abstract function to show or
|
||||
* hide any DOM generated using `stamp`:
|
||||
*
|
||||
* _showHideChildren: function(shouldHide)
|
||||
*
|
||||
* Note that some callbacks are suffixed with `V2` in the Polymer 2.x behavior
|
||||
* as the implementations will need to differ from the callbacks required
|
||||
* by the 1.x Templatizer API due to changes in the `TemplateInstance` API
|
||||
* between versions 1.x and 2.x.
|
||||
*/
|
||||
interface Templatizer {
|
||||
|
||||
/**
|
||||
* Generates an anonymous `TemplateInstance` class (stored as `this.ctor`)
|
||||
* for the provided template. This method should be called once per
|
||||
* template to prepare an element for stamping the template, followed
|
||||
* by `stamp` to create new instances of the template.
|
||||
*
|
||||
* @param template Template to prepare
|
||||
* @param mutableData When `true`, the generated class will skip
|
||||
* strict dirty-checking for objects and arrays (always consider them to
|
||||
* be "dirty"). Defaults to false.
|
||||
*/
|
||||
templatize(template: HTMLTemplateElement, mutableData?: boolean): void;
|
||||
|
||||
/**
|
||||
* Creates an instance of the template prepared by `templatize`. The object
|
||||
* returned is an instance of the anonymous class generated by `templatize`
|
||||
* whose `root` property is a document fragment containing newly cloned
|
||||
* template content, and which has property accessors corresponding to
|
||||
* properties referenced in template bindings.
|
||||
*
|
||||
* @param model Object containing initial property values to
|
||||
* populate into the template bindings.
|
||||
* @returns Returns the created instance of
|
||||
* the template prepared by `templatize`.
|
||||
*/
|
||||
stamp(model?: object|null): TemplateInstanceBase|null;
|
||||
|
||||
/**
|
||||
* Returns the template "model" (`TemplateInstance`) associated with
|
||||
* a given element, which serves as the binding scope for the template
|
||||
* instance the element is contained in. A template model should be used
|
||||
* to manipulate data associated with this template instance.
|
||||
*
|
||||
* @param el Element for which to return a template model.
|
||||
* @returns Model representing the binding scope for
|
||||
* the element.
|
||||
*/
|
||||
modelForElement(el: HTMLElement|null): TemplateInstanceBase|null;
|
||||
}
|
||||
|
||||
declare const Templatizer: object;
|
72
lib/mixins/dir-mixin.d.ts
vendored
Normal file
72
lib/mixins/dir-mixin.d.ts
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/mixins/dir-mixin.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {PropertyAccessors} from './property-accessors.js';
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
export {DirMixin};
|
||||
|
||||
|
||||
/**
|
||||
* Element class mixin that allows elements to use the `:dir` CSS Selector to
|
||||
* have text direction specific styling.
|
||||
*
|
||||
* With this mixin, any stylesheet provided in the template will transform
|
||||
* `:dir` into `:host([dir])` and sync direction with the page via the
|
||||
* element's `dir` attribute.
|
||||
*
|
||||
* Elements can opt out of the global page text direction by setting the `dir`
|
||||
* attribute directly in `ready()` or in HTML.
|
||||
*
|
||||
* Caveats:
|
||||
* - Applications must set `<html dir="ltr">` or `<html dir="rtl">` to sync
|
||||
* direction
|
||||
* - Automatic left-to-right or right-to-left styling is sync'd with the
|
||||
* `<html>` element only.
|
||||
* - Changing `dir` at runtime is supported.
|
||||
* - Opting out of the global direction styling is permanent
|
||||
*/
|
||||
declare function DirMixin<T extends new (...args: any[]) => {}>(base: T): T & DirMixinConstructor & PropertyAccessorsConstructor & PropertiesChangedConstructor;
|
||||
|
||||
import {PropertyAccessorsConstructor} from './property-accessors.js';
|
||||
|
||||
import {PropertiesChangedConstructor, PropertiesChanged} from './properties-changed.js';
|
||||
|
||||
interface DirMixinConstructor {
|
||||
new(...args: any[]): DirMixin;
|
||||
|
||||
/**
|
||||
* @param cssText .
|
||||
* @param baseURI .
|
||||
* @returns .
|
||||
*/
|
||||
_processStyleText(cssText: string, baseURI: string): string;
|
||||
|
||||
/**
|
||||
* Replace `:dir` in the given CSS text
|
||||
*
|
||||
* @param text CSS text to replace DIR
|
||||
* @returns Modified CSS
|
||||
*/
|
||||
_replaceDirInCssText(text: string): string;
|
||||
}
|
||||
|
||||
export {DirMixinConstructor};
|
||||
|
||||
interface DirMixin extends PropertyAccessors, PropertiesChanged {
|
||||
ready(): void;
|
||||
connectedCallback(): void;
|
||||
disconnectedCallback(): void;
|
||||
}
|
80
lib/mixins/disable-upgrade-mixin.d.ts
vendored
Normal file
80
lib/mixins/disable-upgrade-mixin.d.ts
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/mixins/disable-upgrade-mixin.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {ElementMixin} from './element-mixin.js';
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
export {findObservedAttributesGetter};
|
||||
|
||||
declare function findObservedAttributesGetter(): any;
|
||||
|
||||
export {DisableUpgradeMixin};
|
||||
|
||||
|
||||
/**
|
||||
* Element class mixin that allows the element to boot up in a non-enabled
|
||||
* state when the `disable-upgrade` attribute is present. This mixin is
|
||||
* designed to be used with element classes like PolymerElement that perform
|
||||
* initial startup work when they are first connected. When the
|
||||
* `disable-upgrade` attribute is removed, if the element is connected, it
|
||||
* boots up and "enables" as it otherwise would; if it is not connected, the
|
||||
* element boots up when it is next connected.
|
||||
*
|
||||
* Using `disable-upgrade` with PolymerElement prevents any data propagation
|
||||
* to the element, any element DOM from stamping, or any work done in
|
||||
* connected/disconnctedCallback from occuring, but it does not prevent work
|
||||
* done in the element constructor.
|
||||
*
|
||||
* Note, this mixin must be applied on top of any element class that
|
||||
* itself implements a `connectedCallback` so that it can control the work
|
||||
* done in `connectedCallback`. For example,
|
||||
*
|
||||
* MyClass = DisableUpgradeMixin(class extends BaseClass {...});
|
||||
*/
|
||||
declare function DisableUpgradeMixin<T extends new (...args: any[]) => {}>(base: T): T & DisableUpgradeMixinConstructor & ElementMixinConstructor & PropertyEffectsConstructor & TemplateStampConstructor & PropertyAccessorsConstructor & PropertiesChangedConstructor & PropertiesMixinConstructor;
|
||||
|
||||
import {ElementMixinConstructor} from './element-mixin.js';
|
||||
|
||||
import {PropertyEffectsConstructor, PropertyEffects} from './property-effects.js';
|
||||
|
||||
import {TemplateStampConstructor, TemplateStamp} from './template-stamp.js';
|
||||
|
||||
import {PropertyAccessorsConstructor, PropertyAccessors} from './property-accessors.js';
|
||||
|
||||
import {PropertiesChangedConstructor, PropertiesChanged} from './properties-changed.js';
|
||||
|
||||
import {PropertiesMixinConstructor, PropertiesMixin} from './properties-mixin.js';
|
||||
|
||||
interface DisableUpgradeMixinConstructor {
|
||||
new(...args: any[]): DisableUpgradeMixin;
|
||||
}
|
||||
|
||||
export {DisableUpgradeMixinConstructor};
|
||||
|
||||
interface DisableUpgradeMixin extends ElementMixin, PropertyEffects, TemplateStamp, PropertyAccessors, PropertiesChanged, PropertiesMixin {
|
||||
_initializeProperties(): void;
|
||||
_enableProperties(): void;
|
||||
|
||||
/**
|
||||
* @param name Attribute name.
|
||||
* @param old The previous value for the attribute.
|
||||
* @param value The new value for the attribute.
|
||||
* @param namespace The XML namespace for the attribute.
|
||||
*/
|
||||
attributeChangedCallback(name: string, old: string|null, value: string|null, namespace: string|null): void;
|
||||
connectedCallback(): void;
|
||||
disconnectedCallback(): void;
|
||||
_canApplyPropertyDefault(property: any): any;
|
||||
}
|
295
lib/mixins/element-mixin.d.ts
vendored
Normal file
295
lib/mixins/element-mixin.d.ts
vendored
Normal file
|
@ -0,0 +1,295 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/mixins/element-mixin.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
import {stylesFromTemplate, stylesFromModuleImports} from '../utils/style-gather.js';
|
||||
|
||||
import {pathFromUrl, resolveCss, resolveUrl} from '../utils/resolve-url.js';
|
||||
|
||||
import {DomModule} from '../elements/dom-module.js';
|
||||
|
||||
import {PropertyEffects} from './property-effects.js';
|
||||
|
||||
import {PropertiesMixin} from './properties-mixin.js';
|
||||
|
||||
export {ElementMixin};
|
||||
|
||||
|
||||
/**
|
||||
* Element class mixin that provides the core API for Polymer's meta-programming
|
||||
* features including template stamping, data-binding, attribute deserialization,
|
||||
* and property change observation.
|
||||
*
|
||||
* Subclassers may provide the following static getters to return metadata
|
||||
* used to configure Polymer's features for the class:
|
||||
*
|
||||
* - `static get is()`: When the template is provided via a `dom-module`,
|
||||
* users should return the `dom-module` id from a static `is` getter. If
|
||||
* no template is needed or the template is provided directly via the
|
||||
* `template` getter, there is no need to define `is` for the element.
|
||||
*
|
||||
* - `static get template()`: Users may provide the template directly (as
|
||||
* opposed to via `dom-module`) by implementing a static `template` getter.
|
||||
* The getter must return an `HTMLTemplateElement`.
|
||||
*
|
||||
* - `static get properties()`: Should return an object describing
|
||||
* property-related metadata used by Polymer features (key: property name
|
||||
* value: object containing property metadata). Valid keys in per-property
|
||||
* metadata include:
|
||||
* - `type` (String|Number|Object|Array|...): Used by
|
||||
* `attributeChangedCallback` to determine how string-based attributes
|
||||
* are deserialized to JavaScript property values.
|
||||
* - `notify` (boolean): Causes a change in the property to fire a
|
||||
* non-bubbling event called `<property>-changed`. Elements that have
|
||||
* enabled two-way binding to the property use this event to observe changes.
|
||||
* - `readOnly` (boolean): Creates a getter for the property, but no setter.
|
||||
* To set a read-only property, use the private setter method
|
||||
* `_setProperty(property, value)`.
|
||||
* - `observer` (string): Observer method name that will be called when
|
||||
* the property changes. The arguments of the method are
|
||||
* `(value, previousValue)`.
|
||||
* - `computed` (string): String describing method and dependent properties
|
||||
* for computing the value of this property (e.g. `'computeFoo(bar, zot)'`).
|
||||
* Computed properties are read-only by default and can only be changed
|
||||
* via the return value of the computing method.
|
||||
*
|
||||
* - `static get observers()`: Array of strings describing multi-property
|
||||
* observer methods and their dependent properties (e.g.
|
||||
* `'observeABC(a, b, c)'`).
|
||||
*
|
||||
* The base class provides default implementations for the following standard
|
||||
* custom element lifecycle callbacks; users may override these, but should
|
||||
* call the super method to ensure
|
||||
* - `constructor`: Run when the element is created or upgraded
|
||||
* - `connectedCallback`: Run each time the element is connected to the
|
||||
* document
|
||||
* - `disconnectedCallback`: Run each time the element is disconnected from
|
||||
* the document
|
||||
* - `attributeChangedCallback`: Run each time an attribute in
|
||||
* `observedAttributes` is set or removed (note: this element's default
|
||||
* `observedAttributes` implementation will automatically return an array
|
||||
* of dash-cased attributes based on `properties`)
|
||||
*/
|
||||
declare function ElementMixin<T extends new (...args: any[]) => {}>(base: T): T & ElementMixinConstructor & PropertyEffectsConstructor & TemplateStampConstructor & PropertyAccessorsConstructor & PropertiesChangedConstructor & PropertiesMixinConstructor;
|
||||
|
||||
import {PropertyEffectsConstructor} from './property-effects.js';
|
||||
|
||||
import {TemplateStampConstructor, TemplateStamp} from './template-stamp.js';
|
||||
|
||||
import {PropertyAccessorsConstructor, PropertyAccessors} from './property-accessors.js';
|
||||
|
||||
import {PropertiesChangedConstructor, PropertiesChanged} from './properties-changed.js';
|
||||
|
||||
import {PropertiesMixinConstructor} from './properties-mixin.js';
|
||||
|
||||
interface ElementMixinConstructor {
|
||||
new(...args: any[]): ElementMixin;
|
||||
|
||||
/**
|
||||
* Overrides `PropertyEffects` to add map of dynamic functions on
|
||||
* template info, for consumption by `PropertyEffects` template binding
|
||||
* code. This map determines which method templates should have accessors
|
||||
* created for them.
|
||||
*
|
||||
* @param template Template
|
||||
* @param templateInfo Template metadata for current template
|
||||
* @param nodeInfo Node metadata for current template.
|
||||
* @returns .
|
||||
*/
|
||||
_parseTemplateContent(template: HTMLTemplateElement, templateInfo: TemplateInfo, nodeInfo: NodeInfo): boolean;
|
||||
|
||||
/**
|
||||
* Override of PropertiesChanged createProperties to create accessors
|
||||
* and property effects for all of the properties.
|
||||
*
|
||||
* @param props .
|
||||
*/
|
||||
createProperties(props: object): void;
|
||||
|
||||
/**
|
||||
* Overrides `PropertyEffects` to warn on use of undeclared properties in
|
||||
* template.
|
||||
*
|
||||
* @param templateInfo Template metadata to add effect to
|
||||
* @param prop Property that should trigger the effect
|
||||
* @param effect Effect metadata object
|
||||
*/
|
||||
_addTemplatePropertyEffect(templateInfo: object|null, prop: string, effect?: object|null): void;
|
||||
|
||||
/**
|
||||
* Override of PropertiesMixin _finalizeClass to create observers and
|
||||
* find the template.
|
||||
*/
|
||||
_finalizeClass(): void;
|
||||
_prepareTemplate(): void;
|
||||
|
||||
/**
|
||||
* Creates observers for the given `observers` array.
|
||||
* Leverages `PropertyEffects` to create observers.
|
||||
*
|
||||
* @param observers Array of observer descriptors for
|
||||
* this class
|
||||
* @param dynamicFns Object containing keys for any properties
|
||||
* that are functions and should trigger the effect when the function
|
||||
* reference is changed
|
||||
*/
|
||||
createObservers(observers: object|null, dynamicFns: object|null): void;
|
||||
|
||||
/**
|
||||
* Gather style text for a style element in the template.
|
||||
*
|
||||
* @param cssText Text containing styling to process
|
||||
* @param baseURI Base URI to rebase CSS paths against
|
||||
* @returns The processed CSS text
|
||||
*/
|
||||
_processStyleText(cssText: string, baseURI: string): string;
|
||||
|
||||
/**
|
||||
* Configures an element `proto` to function with a given `template`.
|
||||
* The element name `is` and extends `ext` must be specified for ShadyCSS
|
||||
* style scoping.
|
||||
*
|
||||
* @param is Tag name (or type extension name) for this element
|
||||
*/
|
||||
_finalizeTemplate(is: string): void;
|
||||
}
|
||||
|
||||
export {ElementMixinConstructor};
|
||||
|
||||
interface ElementMixin extends PropertyEffects, TemplateStamp, PropertyAccessors, PropertiesChanged, PropertiesMixin {
|
||||
_template: HTMLTemplateElement|null;
|
||||
_importPath: string;
|
||||
rootPath: string;
|
||||
importPath: string;
|
||||
root: StampedTemplate|HTMLElement|ShadowRoot|null;
|
||||
$: {[key: string]: Element};
|
||||
|
||||
/**
|
||||
* Stamps the element template.
|
||||
*/
|
||||
ready(): void;
|
||||
|
||||
/**
|
||||
* Overrides the default `PropertyAccessors` to ensure class
|
||||
* metaprogramming related to property accessors and effects has
|
||||
* completed (calls `finalize`).
|
||||
*
|
||||
* It also initializes any property defaults provided via `value` in
|
||||
* `properties` metadata.
|
||||
*/
|
||||
_initializeProperties(): void;
|
||||
|
||||
/**
|
||||
* Implements `PropertyEffects`'s `_readyClients` call. Attaches
|
||||
* element dom by calling `_attachDom` with the dom stamped from the
|
||||
* element's template via `_stampTemplate`. Note that this allows
|
||||
* client dom to be attached to the element prior to any observers
|
||||
* running.
|
||||
*/
|
||||
_readyClients(): void;
|
||||
|
||||
/**
|
||||
* Provides a default implementation of the standard Custom Elements
|
||||
* `connectedCallback`.
|
||||
*
|
||||
* The default implementation enables the property effects system and
|
||||
* flushes any pending properties, and updates shimmed CSS properties
|
||||
* when using the ShadyCSS scoping/custom properties polyfill.
|
||||
*/
|
||||
connectedCallback(): void;
|
||||
|
||||
/**
|
||||
* Determines if a property dfeault can be applied. For example, this
|
||||
* prevents a default from being applied when a property that has no
|
||||
* accessor is overridden by its host before upgrade (e.g. via a binding).
|
||||
*
|
||||
* @param property Name of the property
|
||||
* @returns Returns true if the property default can be applied.
|
||||
*/
|
||||
_canApplyPropertyDefault(property: string): boolean;
|
||||
|
||||
/**
|
||||
* Attaches an element's stamped dom to itself. By default,
|
||||
* this method creates a `shadowRoot` and adds the dom to it.
|
||||
* However, this method may be overridden to allow an element
|
||||
* to put its dom in another location.
|
||||
*
|
||||
* @param dom to attach to the element.
|
||||
* @returns node to which the dom has been attached.
|
||||
*/
|
||||
_attachDom(dom: StampedTemplate|null): ShadowRoot|null;
|
||||
|
||||
/**
|
||||
* When using the ShadyCSS scoping and custom property shim, causes all
|
||||
* shimmed styles in this element (and its subtree) to be updated
|
||||
* based on current custom property values.
|
||||
*
|
||||
* The optional parameter overrides inline custom property styles with an
|
||||
* object of properties where the keys are CSS properties, and the values
|
||||
* are strings.
|
||||
*
|
||||
* Example: `this.updateStyles({'--color': 'blue'})`
|
||||
*
|
||||
* These properties are retained unless a value of `null` is set.
|
||||
*
|
||||
* Note: This function does not support updating CSS mixins.
|
||||
* You can not dynamically change the value of an `@apply`.
|
||||
*
|
||||
* @param properties Bag of custom property key/values to
|
||||
* apply to this element.
|
||||
*/
|
||||
updateStyles(properties?: object|null): void;
|
||||
|
||||
/**
|
||||
* Rewrites a given URL relative to a base URL. The base URL defaults to
|
||||
* the original location of the document containing the `dom-module` for
|
||||
* this element. This method will return the same URL before and after
|
||||
* bundling.
|
||||
*
|
||||
* Note that this function performs no resolution for URLs that start
|
||||
* with `/` (absolute URLs) or `#` (hash identifiers). For general purpose
|
||||
* URL resolution, use `window.URL`.
|
||||
*
|
||||
* @param url URL to resolve.
|
||||
* @param base Optional base URL to resolve against, defaults
|
||||
* to the element's `importPath`
|
||||
* @returns Rewritten URL relative to base
|
||||
*/
|
||||
resolveUrl(url: string, base?: string): string;
|
||||
}
|
||||
|
||||
export {updateStyles};
|
||||
|
||||
|
||||
/**
|
||||
* When using the ShadyCSS scoping and custom property shim, causes all
|
||||
* shimmed `styles` (via `custom-style`) in the document (and its subtree)
|
||||
* to be updated based on current custom property values.
|
||||
*
|
||||
* The optional parameter overrides inline custom property styles with an
|
||||
* object of properties where the keys are CSS properties, and the values
|
||||
* are strings.
|
||||
*
|
||||
* Example: `updateStyles({'--color': 'blue'})`
|
||||
*
|
||||
* These properties are retained unless a value of `null` is set.
|
||||
*/
|
||||
declare function updateStyles(props?: object|null): void;
|
||||
|
||||
import {TemplateInfo} from '../../interfaces';
|
||||
|
||||
import {NodeInfo} from '../../interfaces';
|
||||
|
||||
import {StampedTemplate} from '../../interfaces';
|
58
lib/mixins/gesture-event-listeners.d.ts
vendored
Normal file
58
lib/mixins/gesture-event-listeners.d.ts
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/mixins/gesture-event-listeners.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
import {addListener, removeListener} from '../utils/gestures.js';
|
||||
|
||||
export {GestureEventListeners};
|
||||
|
||||
|
||||
/**
|
||||
* Element class mixin that provides API for adding Polymer's cross-platform
|
||||
* gesture events to nodes.
|
||||
*
|
||||
* The API is designed to be compatible with override points implemented
|
||||
* in `TemplateStamp` such that declarative event listeners in
|
||||
* templates will support gesture events when this mixin is applied along with
|
||||
* `TemplateStamp`.
|
||||
*/
|
||||
declare function GestureEventListeners<T extends new (...args: any[]) => {}>(base: T): T & GestureEventListenersConstructor;
|
||||
|
||||
interface GestureEventListenersConstructor {
|
||||
new(...args: any[]): GestureEventListeners;
|
||||
}
|
||||
|
||||
export {GestureEventListenersConstructor};
|
||||
|
||||
interface GestureEventListeners {
|
||||
|
||||
/**
|
||||
* Add the event listener to the node if it is a gestures event.
|
||||
*
|
||||
* @param node Node to add event listener to
|
||||
* @param eventName Name of event
|
||||
* @param handler Listener function to add
|
||||
*/
|
||||
_addEventListenerToNode(node: EventTarget, eventName: string, handler: (p0: Event) => void): void;
|
||||
|
||||
/**
|
||||
* Remove the event listener to the node if it is a gestures event.
|
||||
*
|
||||
* @param node Node to remove event listener from
|
||||
* @param eventName Name of event
|
||||
* @param handler Listener function to remove
|
||||
*/
|
||||
_removeEventListenerFromNode(node: EventTarget, eventName: string, handler: (p0: Event) => void): void;
|
||||
}
|
156
lib/mixins/mutable-data.d.ts
vendored
Normal file
156
lib/mixins/mutable-data.d.ts
vendored
Normal file
|
@ -0,0 +1,156 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/mixins/mutable-data.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
export {MutableData};
|
||||
|
||||
|
||||
/**
|
||||
* Element class mixin to skip strict dirty-checking for objects and arrays
|
||||
* (always consider them to be "dirty"), for use on elements utilizing
|
||||
* `PropertyEffects`
|
||||
*
|
||||
* By default, `PropertyEffects` performs strict dirty checking on
|
||||
* objects, which means that any deep modifications to an object or array will
|
||||
* not be propagated unless "immutable" data patterns are used (i.e. all object
|
||||
* references from the root to the mutation were changed).
|
||||
*
|
||||
* Polymer also provides a proprietary data mutation and path notification API
|
||||
* (e.g. `notifyPath`, `set`, and array mutation API's) that allow efficient
|
||||
* mutation and notification of deep changes in an object graph to all elements
|
||||
* bound to the same object graph.
|
||||
*
|
||||
* In cases where neither immutable patterns nor the data mutation API can be
|
||||
* used, applying this mixin will cause Polymer to skip dirty checking for
|
||||
* objects and arrays (always consider them to be "dirty"). This allows a
|
||||
* user to make a deep modification to a bound object graph, and then either
|
||||
* simply re-set the object (e.g. `this.items = this.items`) or call `notifyPath`
|
||||
* (e.g. `this.notifyPath('items')`) to update the tree. Note that all
|
||||
* elements that wish to be updated based on deep mutations must apply this
|
||||
* mixin or otherwise skip strict dirty checking for objects/arrays.
|
||||
* Specifically, any elements in the binding tree between the source of a
|
||||
* mutation and the consumption of it must apply this mixin or enable the
|
||||
* `OptionalMutableData` mixin.
|
||||
*
|
||||
* In order to make the dirty check strategy configurable, see
|
||||
* `OptionalMutableData`.
|
||||
*
|
||||
* Note, the performance characteristics of propagating large object graphs
|
||||
* will be worse as opposed to using strict dirty checking with immutable
|
||||
* patterns or Polymer's path notification API.
|
||||
*/
|
||||
declare function MutableData<T extends new (...args: any[]) => {}>(base: T): T & MutableDataConstructor;
|
||||
|
||||
interface MutableDataConstructor {
|
||||
new(...args: any[]): MutableData;
|
||||
}
|
||||
|
||||
export {MutableDataConstructor};
|
||||
|
||||
interface MutableData {
|
||||
|
||||
/**
|
||||
* Overrides `PropertyEffects` to provide option for skipping
|
||||
* strict equality checking for Objects and Arrays.
|
||||
*
|
||||
* This method pulls the value to dirty check against from the `__dataTemp`
|
||||
* cache (rather than the normal `__data` cache) for Objects. Since the temp
|
||||
* cache is cleared at the end of a turn, this implementation allows
|
||||
* side-effects of deep object changes to be processed by re-setting the
|
||||
* same object (using the temp cache as an in-turn backstop to prevent
|
||||
* cycles due to 2-way notification).
|
||||
*
|
||||
* @param property Property name
|
||||
* @param value New property value
|
||||
* @param old Previous property value
|
||||
* @returns Whether the property should be considered a change
|
||||
*/
|
||||
_shouldPropertyChange(property: string, value: any, old: any): boolean;
|
||||
}
|
||||
|
||||
export {OptionalMutableData};
|
||||
|
||||
|
||||
/**
|
||||
* Element class mixin to add the optional ability to skip strict
|
||||
* dirty-checking for objects and arrays (always consider them to be
|
||||
* "dirty") by setting a `mutable-data` attribute on an element instance.
|
||||
*
|
||||
* By default, `PropertyEffects` performs strict dirty checking on
|
||||
* objects, which means that any deep modifications to an object or array will
|
||||
* not be propagated unless "immutable" data patterns are used (i.e. all object
|
||||
* references from the root to the mutation were changed).
|
||||
*
|
||||
* Polymer also provides a proprietary data mutation and path notification API
|
||||
* (e.g. `notifyPath`, `set`, and array mutation API's) that allow efficient
|
||||
* mutation and notification of deep changes in an object graph to all elements
|
||||
* bound to the same object graph.
|
||||
*
|
||||
* In cases where neither immutable patterns nor the data mutation API can be
|
||||
* used, applying this mixin will allow Polymer to skip dirty checking for
|
||||
* objects and arrays (always consider them to be "dirty"). This allows a
|
||||
* user to make a deep modification to a bound object graph, and then either
|
||||
* simply re-set the object (e.g. `this.items = this.items`) or call `notifyPath`
|
||||
* (e.g. `this.notifyPath('items')`) to update the tree. Note that all
|
||||
* elements that wish to be updated based on deep mutations must apply this
|
||||
* mixin or otherwise skip strict dirty checking for objects/arrays.
|
||||
* Specifically, any elements in the binding tree between the source of a
|
||||
* mutation and the consumption of it must enable this mixin or apply the
|
||||
* `MutableData` mixin.
|
||||
*
|
||||
* While this mixin adds the ability to forgo Object/Array dirty checking,
|
||||
* the `mutableData` flag defaults to false and must be set on the instance.
|
||||
*
|
||||
* Note, the performance characteristics of propagating large object graphs
|
||||
* will be worse by relying on `mutableData: true` as opposed to using
|
||||
* strict dirty checking with immutable patterns or Polymer's path notification
|
||||
* API.
|
||||
*/
|
||||
declare function OptionalMutableData<T extends new (...args: any[]) => {}>(base: T): T & OptionalMutableDataConstructor;
|
||||
|
||||
interface OptionalMutableDataConstructor {
|
||||
new(...args: any[]): OptionalMutableData;
|
||||
}
|
||||
|
||||
export {OptionalMutableDataConstructor};
|
||||
|
||||
interface OptionalMutableData {
|
||||
|
||||
/**
|
||||
* Instance-level flag for configuring the dirty-checking strategy
|
||||
* for this element. When true, Objects and Arrays will skip dirty
|
||||
* checking, otherwise strict equality checking will be used.
|
||||
*/
|
||||
mutableData: boolean|null|undefined;
|
||||
|
||||
/**
|
||||
* Overrides `PropertyEffects` to provide option for skipping
|
||||
* strict equality checking for Objects and Arrays.
|
||||
*
|
||||
* When `this.mutableData` is true on this instance, this method
|
||||
* pulls the value to dirty check against from the `__dataTemp` cache
|
||||
* (rather than the normal `__data` cache) for Objects. Since the temp
|
||||
* cache is cleared at the end of a turn, this implementation allows
|
||||
* side-effects of deep object changes to be processed by re-setting the
|
||||
* same object (using the temp cache as an in-turn backstop to prevent
|
||||
* cycles due to 2-way notification).
|
||||
*
|
||||
* @param property Property name
|
||||
* @param value New property value
|
||||
* @param old Previous property value
|
||||
* @returns Whether the property should be considered a change
|
||||
*/
|
||||
_shouldPropertyChange(property: string, value: any, old: any): boolean;
|
||||
}
|
316
lib/mixins/properties-changed.d.ts
vendored
Normal file
316
lib/mixins/properties-changed.d.ts
vendored
Normal file
|
@ -0,0 +1,316 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/mixins/properties-changed.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
import {microTask} from '../utils/async.js';
|
||||
|
||||
export {PropertiesChanged};
|
||||
|
||||
|
||||
/**
|
||||
* Element class mixin that provides basic meta-programming for creating one
|
||||
* or more property accessors (getter/setter pair) that enqueue an async
|
||||
* (batched) `_propertiesChanged` callback.
|
||||
*
|
||||
* For basic usage of this mixin, call `MyClass.createProperties(props)`
|
||||
* once at class definition time to create property accessors for properties
|
||||
* named in props, implement `_propertiesChanged` to react as desired to
|
||||
* property changes, and implement `static get observedAttributes()` and
|
||||
* include lowercase versions of any property names that should be set from
|
||||
* attributes. Last, call `this._enableProperties()` in the element's
|
||||
* `connectedCallback` to enable the accessors.
|
||||
*/
|
||||
declare function PropertiesChanged<T extends new (...args: any[]) => {}>(base: T): T & PropertiesChangedConstructor;
|
||||
|
||||
interface PropertiesChangedConstructor {
|
||||
new(...args: any[]): PropertiesChanged;
|
||||
|
||||
/**
|
||||
* Creates property accessors for the given property names.
|
||||
*
|
||||
* @param props Object whose keys are names of accessors.
|
||||
*/
|
||||
createProperties(props: object): void;
|
||||
|
||||
/**
|
||||
* Returns an attribute name that corresponds to the given property.
|
||||
* The attribute name is the lowercased property name. Override to
|
||||
* customize this mapping.
|
||||
*
|
||||
* @param property Property to convert
|
||||
* @returns Attribute name corresponding to the given property.
|
||||
*/
|
||||
attributeNameForProperty(property: string): string;
|
||||
|
||||
/**
|
||||
* Override point to provide a type to which to deserialize a value to
|
||||
* a given property.
|
||||
*
|
||||
* @param name Name of property
|
||||
*/
|
||||
typeForProperty(name: string): void;
|
||||
}
|
||||
|
||||
export {PropertiesChangedConstructor};
|
||||
|
||||
interface PropertiesChanged {
|
||||
|
||||
/**
|
||||
* Creates a setter/getter pair for the named property with its own
|
||||
* local storage. The getter returns the value in the local storage,
|
||||
* and the setter calls `_setProperty`, which updates the local storage
|
||||
* for the property and enqueues a `_propertiesChanged` callback.
|
||||
*
|
||||
* This method may be called on a prototype or an instance. Calling
|
||||
* this method may overwrite a property value that already exists on
|
||||
* the prototype/instance by creating the accessor.
|
||||
*
|
||||
* @param property Name of the property
|
||||
* @param readOnly When true, no setter is created; the
|
||||
* protected `_setProperty` function must be used to set the property
|
||||
*/
|
||||
_createPropertyAccessor(property: string, readOnly?: boolean): void;
|
||||
|
||||
/**
|
||||
* Adds the given `property` to a map matching attribute names
|
||||
* to property names, using `attributeNameForProperty`. This map is
|
||||
* used when deserializing attribute values to properties.
|
||||
*
|
||||
* @param property Name of the property
|
||||
*/
|
||||
_addPropertyToAttributeMap(property: string): any;
|
||||
|
||||
/**
|
||||
* Defines a property accessor for the given property.
|
||||
*
|
||||
* @param property Name of the property
|
||||
* @param readOnly When true, no setter is created
|
||||
*/
|
||||
_definePropertyAccessor(property: string, readOnly?: boolean): void;
|
||||
|
||||
/**
|
||||
* Lifecycle callback called when properties are enabled via
|
||||
* `_enableProperties`.
|
||||
*
|
||||
* Users may override this function to implement behavior that is
|
||||
* dependent on the element having its property data initialized, e.g.
|
||||
* from defaults (initialized from `constructor`, `_initializeProperties`),
|
||||
* `attributeChangedCallback`, or values propagated from host e.g. via
|
||||
* bindings. `super.ready()` must be called to ensure the data system
|
||||
* becomes enabled.
|
||||
*/
|
||||
ready(): void;
|
||||
|
||||
/**
|
||||
* Initializes the local storage for property accessors.
|
||||
*
|
||||
* Provided as an override point for performing any setup work prior
|
||||
* to initializing the property accessor system.
|
||||
*/
|
||||
_initializeProperties(): void;
|
||||
|
||||
/**
|
||||
* Called at ready time with bag of instance properties that overwrote
|
||||
* accessors when the element upgraded.
|
||||
*
|
||||
* The default implementation sets these properties back into the
|
||||
* setter at ready time. This method is provided as an override
|
||||
* point for customizing or providing more efficient initialization.
|
||||
*
|
||||
* @param props Bag of property values that were overwritten
|
||||
* when creating property accessors.
|
||||
*/
|
||||
_initializeInstanceProperties(props: object|null): void;
|
||||
|
||||
/**
|
||||
* Updates the local storage for a property (via `_setPendingProperty`)
|
||||
* and enqueues a `_proeprtiesChanged` callback.
|
||||
*
|
||||
* @param property Name of the property
|
||||
* @param value Value to set
|
||||
*/
|
||||
_setProperty(property: string, value: any): void;
|
||||
|
||||
/**
|
||||
* Returns the value for the given property.
|
||||
*
|
||||
* @param property Name of property
|
||||
* @returns Value for the given property
|
||||
*/
|
||||
_getProperty(property: string): any;
|
||||
|
||||
/**
|
||||
* Updates the local storage for a property, records the previous value,
|
||||
* and adds it to the set of "pending changes" that will be passed to the
|
||||
* `_propertiesChanged` callback. This method does not enqueue the
|
||||
* `_propertiesChanged` callback.
|
||||
*
|
||||
* @param property Name of the property
|
||||
* @param value Value to set
|
||||
* @param ext Not used here; affordance for closure
|
||||
* @returns Returns true if the property changed
|
||||
*/
|
||||
_setPendingProperty(property: string, value: any, ext?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* @param property Name of the property
|
||||
* @returns Returns true if the property is pending.
|
||||
*/
|
||||
_isPropertyPending(property: string): boolean;
|
||||
|
||||
/**
|
||||
* Marks the properties as invalid, and enqueues an async
|
||||
* `_propertiesChanged` callback.
|
||||
*/
|
||||
_invalidateProperties(): void;
|
||||
|
||||
/**
|
||||
* Call to enable property accessor processing. Before this method is
|
||||
* called accessor values will be set but side effects are
|
||||
* queued. When called, any pending side effects occur immediately.
|
||||
* For elements, generally `connectedCallback` is a normal spot to do so.
|
||||
* It is safe to call this method multiple times as it only turns on
|
||||
* property accessors once.
|
||||
*/
|
||||
_enableProperties(): void;
|
||||
|
||||
/**
|
||||
* Calls the `_propertiesChanged` callback with the current set of
|
||||
* pending changes (and old values recorded when pending changes were
|
||||
* set), and resets the pending set of changes. Generally, this method
|
||||
* should not be called in user code.
|
||||
*/
|
||||
_flushProperties(): void;
|
||||
|
||||
/**
|
||||
* Called in `_flushProperties` to determine if `_propertiesChanged`
|
||||
* should be called. The default implementation returns true if
|
||||
* properties are pending. Override to customize when
|
||||
* `_propertiesChanged` is called.
|
||||
*
|
||||
* @param currentProps Bag of all current accessor values
|
||||
* @param changedProps Bag of properties changed since the last
|
||||
* call to `_propertiesChanged`
|
||||
* @param oldProps Bag of previous values for each property
|
||||
* in `changedProps`
|
||||
* @returns true if changedProps is truthy
|
||||
*/
|
||||
_shouldPropertiesChange(currentProps: object, changedProps: object|null, oldProps: object|null): boolean;
|
||||
|
||||
/**
|
||||
* Callback called when any properties with accessors created via
|
||||
* `_createPropertyAccessor` have been set.
|
||||
*
|
||||
* @param currentProps Bag of all current accessor values
|
||||
* @param changedProps Bag of properties changed since the last
|
||||
* call to `_propertiesChanged`
|
||||
* @param oldProps Bag of previous values for each property
|
||||
* in `changedProps`
|
||||
*/
|
||||
_propertiesChanged(currentProps: object, changedProps: object|null, oldProps: object|null): void;
|
||||
|
||||
/**
|
||||
* Method called to determine whether a property value should be
|
||||
* considered as a change and cause the `_propertiesChanged` callback
|
||||
* to be enqueued.
|
||||
*
|
||||
* The default implementation returns `true` if a strict equality
|
||||
* check fails. The method always returns false for `NaN`.
|
||||
*
|
||||
* Override this method to e.g. provide stricter checking for
|
||||
* Objects/Arrays when using immutable patterns.
|
||||
*
|
||||
* @param property Property name
|
||||
* @param value New property value
|
||||
* @param old Previous property value
|
||||
* @returns Whether the property should be considered a change
|
||||
* and enqueue a `_proeprtiesChanged` callback
|
||||
*/
|
||||
_shouldPropertyChange(property: string, value: any, old: any): boolean;
|
||||
|
||||
/**
|
||||
* Implements native Custom Elements `attributeChangedCallback` to
|
||||
* set an attribute value to a property via `_attributeToProperty`.
|
||||
*
|
||||
* @param name Name of attribute that changed
|
||||
* @param old Old attribute value
|
||||
* @param value New attribute value
|
||||
* @param namespace Attribute namespace.
|
||||
*/
|
||||
attributeChangedCallback(name: string, old: string|null, value: string|null, namespace: string|null): void;
|
||||
|
||||
/**
|
||||
* Deserializes an attribute to its associated property.
|
||||
*
|
||||
* This method calls the `_deserializeValue` method to convert the string to
|
||||
* a typed value.
|
||||
*
|
||||
* @param attribute Name of attribute to deserialize.
|
||||
* @param value of the attribute.
|
||||
* @param type type to deserialize to, defaults to the value
|
||||
* returned from `typeForProperty`
|
||||
*/
|
||||
_attributeToProperty(attribute: string, value: string|null, type?: any): void;
|
||||
|
||||
/**
|
||||
* Serializes a property to its associated attribute.
|
||||
*
|
||||
* @param property Property name to reflect.
|
||||
* @param attribute Attribute name to reflect to.
|
||||
* @param value Property value to refect.
|
||||
*/
|
||||
_propertyToAttribute(property: string, attribute?: string, value?: any): void;
|
||||
|
||||
/**
|
||||
* Sets a typed value to an HTML attribute on a node.
|
||||
*
|
||||
* This method calls the `_serializeValue` method to convert the typed
|
||||
* value to a string. If the `_serializeValue` method returns `undefined`,
|
||||
* the attribute will be removed (this is the default for boolean
|
||||
* type `false`).
|
||||
*
|
||||
* @param node Element to set attribute to.
|
||||
* @param value Value to serialize.
|
||||
* @param attribute Attribute name to serialize to.
|
||||
*/
|
||||
_valueToNodeAttribute(node: Element|null, value: any, attribute: string): void;
|
||||
|
||||
/**
|
||||
* Converts a typed JavaScript value to a string.
|
||||
*
|
||||
* This method is called when setting JS property values to
|
||||
* HTML attributes. Users may override this method to provide
|
||||
* serialization for custom types.
|
||||
*
|
||||
* @param value Property value to serialize.
|
||||
* @returns String serialized from the provided
|
||||
* property value.
|
||||
*/
|
||||
_serializeValue(value: any): string|undefined;
|
||||
|
||||
/**
|
||||
* Converts a string to a typed JavaScript value.
|
||||
*
|
||||
* This method is called when reading HTML attribute values to
|
||||
* JS properties. Users may override this method to provide
|
||||
* deserialization for custom `type`s. Types for `Boolean`, `String`,
|
||||
* and `Number` convert attributes to the expected types.
|
||||
*
|
||||
* @param value Value to deserialize.
|
||||
* @param type Type to deserialize the string to.
|
||||
* @returns Typed value deserialized from the provided string.
|
||||
*/
|
||||
_deserializeValue(value: string|null, type?: any): any;
|
||||
}
|
88
lib/mixins/properties-mixin.d.ts
vendored
Normal file
88
lib/mixins/properties-mixin.d.ts
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/mixins/properties-mixin.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
import {register, incrementInstanceCount} from '../utils/telemetry.js';
|
||||
|
||||
import {PropertiesChanged} from './properties-changed.js';
|
||||
|
||||
export {PropertiesMixin};
|
||||
|
||||
|
||||
/**
|
||||
* Mixin that provides a minimal starting point to using the PropertiesChanged
|
||||
* mixin by providing a mechanism to declare properties in a static
|
||||
* getter (e.g. static get properties() { return { foo: String } }). Changes
|
||||
* are reported via the `_propertiesChanged` method.
|
||||
*
|
||||
* This mixin provides no specific support for rendering. Users are expected
|
||||
* to create a ShadowRoot and put content into it and update it in whatever
|
||||
* way makes sense. This can be done in reaction to properties changing by
|
||||
* implementing `_propertiesChanged`.
|
||||
*/
|
||||
declare function PropertiesMixin<T extends new (...args: any[]) => {}>(base: T): T & PropertiesMixinConstructor & PropertiesChangedConstructor;
|
||||
|
||||
import {PropertiesChangedConstructor} from './properties-changed.js';
|
||||
|
||||
interface PropertiesMixinConstructor {
|
||||
new(...args: any[]): PropertiesMixin;
|
||||
|
||||
/**
|
||||
* Overrides `PropertiesChanged` method to return type specified in the
|
||||
* static `properties` object for the given property.
|
||||
*
|
||||
* @param name Name of property
|
||||
* @returns Type to which to deserialize attribute
|
||||
*/
|
||||
typeForProperty(name: string): any;
|
||||
|
||||
/**
|
||||
* Finalizes an element definition, including ensuring any super classes
|
||||
* are also finalized. This includes ensuring property
|
||||
* accessors exist on the element prototype. This method calls
|
||||
* `_finalizeClass` to finalize each constructor in the prototype chain.
|
||||
*/
|
||||
finalize(): void;
|
||||
|
||||
/**
|
||||
* Finalize an element class. This includes ensuring property
|
||||
* accessors exist on the element prototype. This method is called by
|
||||
* `finalize` and finalizes the class constructor.
|
||||
*/
|
||||
_finalizeClass(): void;
|
||||
}
|
||||
|
||||
export {PropertiesMixinConstructor};
|
||||
|
||||
interface PropertiesMixin extends PropertiesChanged {
|
||||
|
||||
/**
|
||||
* Overrides `PropertiesChanged` method and adds a call to
|
||||
* `finalize` which lazily configures the element's property accessors.
|
||||
*/
|
||||
_initializeProperties(): void;
|
||||
|
||||
/**
|
||||
* Called when the element is added to a document.
|
||||
* Calls `_enableProperties` to turn on property system from
|
||||
* `PropertiesChanged`.
|
||||
*/
|
||||
connectedCallback(): void;
|
||||
|
||||
/**
|
||||
* Called when the element is removed from a document
|
||||
*/
|
||||
disconnectedCallback(): void;
|
||||
}
|
163
lib/mixins/property-accessors.d.ts
vendored
Normal file
163
lib/mixins/property-accessors.d.ts
vendored
Normal file
|
@ -0,0 +1,163 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/mixins/property-accessors.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
import {camelToDashCase, dashToCamelCase} from '../utils/case-map.js';
|
||||
|
||||
import {PropertiesChanged} from './properties-changed.js';
|
||||
|
||||
export {PropertyAccessors};
|
||||
|
||||
|
||||
/**
|
||||
* Element class mixin that provides basic meta-programming for creating one
|
||||
* or more property accessors (getter/setter pair) that enqueue an async
|
||||
* (batched) `_propertiesChanged` callback.
|
||||
*
|
||||
* For basic usage of this mixin:
|
||||
*
|
||||
* - Declare attributes to observe via the standard `static get
|
||||
* observedAttributes()`. Use `dash-case` attribute names to represent
|
||||
* `camelCase` property names.
|
||||
* - Implement the `_propertiesChanged` callback on the class.
|
||||
* - Call `MyClass.createPropertiesForAttributes()` **once** on the class to
|
||||
* generate property accessors for each observed attribute. This must be
|
||||
* called before the first instance is created, for example, by calling it
|
||||
* before calling `customElements.define`. It can also be called lazily from
|
||||
* the element's `constructor`, as long as it's guarded so that the call is
|
||||
* only made once, when the first instance is created.
|
||||
* - Call `this._enableProperties()` in the element's `connectedCallback` to
|
||||
* enable the accessors.
|
||||
*
|
||||
* Any `observedAttributes` will automatically be
|
||||
* deserialized via `attributeChangedCallback` and set to the associated
|
||||
* property using `dash-case`-to-`camelCase` convention.
|
||||
*/
|
||||
declare function PropertyAccessors<T extends new (...args: any[]) => {}>(base: T): T & PropertyAccessorsConstructor & PropertiesChangedConstructor;
|
||||
|
||||
import {PropertiesChangedConstructor} from './properties-changed.js';
|
||||
|
||||
interface PropertyAccessorsConstructor {
|
||||
new(...args: any[]): PropertyAccessors;
|
||||
|
||||
/**
|
||||
* Returns an attribute name that corresponds to the given property.
|
||||
* By default, converts camel to dash case, e.g. `fooBar` to `foo-bar`.
|
||||
*
|
||||
* @param property Property to convert
|
||||
* @returns Attribute name corresponding to the given property.
|
||||
*/
|
||||
attributeNameForProperty(property: string): string;
|
||||
|
||||
/**
|
||||
* Generates property accessors for all attributes in the standard
|
||||
* static `observedAttributes` array.
|
||||
*
|
||||
* Attribute names are mapped to property names using the `dash-case` to
|
||||
* `camelCase` convention
|
||||
*/
|
||||
createPropertiesForAttributes(): void;
|
||||
}
|
||||
|
||||
export {PropertyAccessorsConstructor};
|
||||
|
||||
interface PropertyAccessors extends PropertiesChanged {
|
||||
|
||||
/**
|
||||
* Overrides PropertiesChanged implementation to save existing prototype
|
||||
* property value so that it can be reset.
|
||||
*
|
||||
* @param property Name of the property
|
||||
* @param readOnly When true, no setter is created
|
||||
*
|
||||
* When calling on a prototype, any overwritten values are saved in
|
||||
* `__dataProto`, and it is up to the subclasser to decide how/when
|
||||
* to set those properties back into the accessor. When calling on an
|
||||
* instance, the overwritten value is set via `_setPendingProperty`,
|
||||
* and the user should call `_invalidateProperties` or `_flushProperties`
|
||||
* for the values to take effect.
|
||||
*/
|
||||
_definePropertyAccessor(property: string, readOnly?: boolean): void;
|
||||
|
||||
/**
|
||||
* Overrides PropertiesChanged implementation to initialize values for
|
||||
* accessors created for values that already existed on the element
|
||||
* prototype.
|
||||
*/
|
||||
_initializeProperties(): void;
|
||||
|
||||
/**
|
||||
* Returns true if the specified property has a pending change.
|
||||
*
|
||||
* @param prop Property name
|
||||
* @returns True if property has a pending change
|
||||
*/
|
||||
_isPropertyPending(prop: string): boolean;
|
||||
|
||||
/**
|
||||
* Overrides PropertiesChanged implemention to serialize objects as JSON.
|
||||
*
|
||||
* @param value Property value to serialize.
|
||||
* @returns String serialized from the provided property
|
||||
* value.
|
||||
*/
|
||||
_serializeValue(value: any): string|undefined;
|
||||
|
||||
/**
|
||||
* Converts a string to a typed JavaScript value.
|
||||
*
|
||||
* This method is called by Polymer when reading HTML attribute values to
|
||||
* JS properties. Users may override this method on Polymer element
|
||||
* prototypes to provide deserialization for custom `type`s. Note,
|
||||
* the `type` argument is the value of the `type` field provided in the
|
||||
* `properties` configuration object for a given property, and is
|
||||
* by convention the constructor for the type to deserialize.
|
||||
*
|
||||
* @param value Attribute value to deserialize.
|
||||
* @param type Type to deserialize the string to.
|
||||
* @returns Typed value deserialized from the provided string.
|
||||
*/
|
||||
_deserializeValue(value: string|null, type?: any): any;
|
||||
|
||||
/**
|
||||
* Called at instance time with bag of properties that were overwritten
|
||||
* by accessors on the prototype when accessors were created.
|
||||
*
|
||||
* The default implementation sets these properties back into the
|
||||
* setter at instance time. This method is provided as an override
|
||||
* point for customizing or providing more efficient initialization.
|
||||
*
|
||||
* @param props Bag of property values that were overwritten
|
||||
* when creating property accessors.
|
||||
*/
|
||||
_initializeProtoProperties(props: object|null): void;
|
||||
|
||||
/**
|
||||
* Ensures the element has the given attribute. If it does not,
|
||||
* assigns the given value to the attribute.
|
||||
*
|
||||
* @param attribute Name of attribute to ensure is set.
|
||||
* @param value of the attribute.
|
||||
*/
|
||||
_ensureAttribute(attribute: string, value: string): void;
|
||||
|
||||
/**
|
||||
* Returns true if this library created an accessor for the given property.
|
||||
*
|
||||
* @param property Property name
|
||||
* @returns True if an accessor was created
|
||||
*/
|
||||
_hasAccessor(property: string): boolean;
|
||||
}
|
882
lib/mixins/property-effects.d.ts
vendored
Normal file
882
lib/mixins/property-effects.d.ts
vendored
Normal file
|
@ -0,0 +1,882 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/mixins/property-effects.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
import {root, isAncestor, isDescendant, get, translate, isPath, set, normalize} from '../utils/path.js';
|
||||
|
||||
import {camelToDashCase, dashToCamelCase} from '../utils/case-map.js';
|
||||
|
||||
import {PropertyAccessors} from './property-accessors.js';
|
||||
|
||||
import {TemplateStamp} from './template-stamp.js';
|
||||
|
||||
export {PropertyEffects};
|
||||
|
||||
|
||||
/**
|
||||
* Element class mixin that provides meta-programming for Polymer's template
|
||||
* binding and data observation (collectively, "property effects") system.
|
||||
*
|
||||
* This mixin uses provides the following key static methods for adding
|
||||
* property effects to an element class:
|
||||
* - `addPropertyEffect`
|
||||
* - `createPropertyObserver`
|
||||
* - `createMethodObserver`
|
||||
* - `createNotifyingProperty`
|
||||
* - `createReadOnlyProperty`
|
||||
* - `createReflectedProperty`
|
||||
* - `createComputedProperty`
|
||||
* - `bindTemplate`
|
||||
*
|
||||
* Each method creates one or more property accessors, along with metadata
|
||||
* used by this mixin's implementation of `_propertiesChanged` to perform
|
||||
* the property effects.
|
||||
*
|
||||
* Underscored versions of the above methods also exist on the element
|
||||
* prototype for adding property effects on instances at runtime.
|
||||
*
|
||||
* Note that this mixin overrides several `PropertyAccessors` methods, in
|
||||
* many cases to maintain guarantees provided by the Polymer 1.x features;
|
||||
* notably it changes property accessors to be synchronous by default
|
||||
* whereas the default when using `PropertyAccessors` standalone is to be
|
||||
* async by default.
|
||||
*/
|
||||
declare function PropertyEffects<T extends new (...args: any[]) => {}>(base: T): T & PropertyEffectsConstructor & TemplateStampConstructor & PropertyAccessorsConstructor & PropertiesChangedConstructor;
|
||||
|
||||
import {TemplateStampConstructor} from './template-stamp.js';
|
||||
|
||||
import {PropertyAccessorsConstructor} from './property-accessors.js';
|
||||
|
||||
import {PropertiesChangedConstructor, PropertiesChanged} from './properties-changed.js';
|
||||
|
||||
interface PropertyEffectsConstructor {
|
||||
new(...args: any[]): PropertyEffects;
|
||||
|
||||
/**
|
||||
* Overrides default `TemplateStamp` implementation to add support for
|
||||
* parsing bindings from `TextNode`'s' `textContent`. A `bindings`
|
||||
* array is added to `nodeInfo` and populated with binding metadata
|
||||
* with information capturing the binding target, and a `parts` array
|
||||
* with one or more metadata objects capturing the source(s) of the
|
||||
* binding.
|
||||
*
|
||||
* @param node Node to parse
|
||||
* @param templateInfo Template metadata for current template
|
||||
* @param nodeInfo Node metadata for current template node
|
||||
* @returns `true` if the visited node added node-specific
|
||||
* metadata to `nodeInfo`
|
||||
*/
|
||||
_parseTemplateNode(node: Node|null, templateInfo: TemplateInfo|null, nodeInfo: NodeInfo|null): boolean;
|
||||
|
||||
/**
|
||||
* Overrides default `TemplateStamp` implementation to add support for
|
||||
* binding the properties that a nested template depends on to the template
|
||||
* as `_host_<property>`.
|
||||
*
|
||||
* @param node Node to parse
|
||||
* @param templateInfo Template metadata for current template
|
||||
* @param nodeInfo Node metadata for current template node
|
||||
* @returns `true` if the visited node added node-specific
|
||||
* metadata to `nodeInfo`
|
||||
*/
|
||||
_parseTemplateNestedTemplate(node: Node|null, templateInfo: TemplateInfo|null, nodeInfo: NodeInfo|null): boolean;
|
||||
|
||||
/**
|
||||
* Overrides default `TemplateStamp` implementation to add support for
|
||||
* parsing bindings from attributes. A `bindings`
|
||||
* array is added to `nodeInfo` and populated with binding metadata
|
||||
* with information capturing the binding target, and a `parts` array
|
||||
* with one or more metadata objects capturing the source(s) of the
|
||||
* binding.
|
||||
*
|
||||
* @param node Node to parse
|
||||
* @param templateInfo Template metadata for current template
|
||||
* @param nodeInfo Node metadata for current template node
|
||||
* @param name Attribute name
|
||||
* @param value Attribute value
|
||||
* @returns `true` if the visited node added node-specific
|
||||
* metadata to `nodeInfo`
|
||||
*/
|
||||
_parseTemplateNodeAttribute(node: Element|null, templateInfo: TemplateInfo|null, nodeInfo: NodeInfo|null, name: string, value: string): boolean;
|
||||
|
||||
/**
|
||||
* Ensures an accessor exists for the specified property, and adds
|
||||
* to a list of "property effects" that will run when the accessor for
|
||||
* the specified property is set. Effects are grouped by "type", which
|
||||
* roughly corresponds to a phase in effect processing. The effect
|
||||
* metadata should be in the following form:
|
||||
*
|
||||
* {
|
||||
* fn: effectFunction, // Reference to function to call to perform effect
|
||||
* info: { ... } // Effect metadata passed to function
|
||||
* trigger: { // Optional triggering metadata; if not provided
|
||||
* name: string // the property is treated as a wildcard
|
||||
* structured: boolean
|
||||
* wildcard: boolean
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* Effects are called from `_propertiesChanged` in the following order by
|
||||
* type:
|
||||
*
|
||||
* 1. COMPUTE
|
||||
* 2. PROPAGATE
|
||||
* 3. REFLECT
|
||||
* 4. OBSERVE
|
||||
* 5. NOTIFY
|
||||
*
|
||||
* Effect functions are called with the following signature:
|
||||
*
|
||||
* effectFunction(inst, path, props, oldProps, info, hasPaths)
|
||||
*
|
||||
* @param property Property that should trigger the effect
|
||||
* @param type Effect type, from this.PROPERTY_EFFECT_TYPES
|
||||
* @param effect Effect metadata object
|
||||
*/
|
||||
addPropertyEffect(property: string, type: string, effect?: object|null): void;
|
||||
|
||||
/**
|
||||
* Creates a single-property observer for the given property.
|
||||
*
|
||||
* @param property Property name
|
||||
* @param method Function or name of observer method to call
|
||||
* @param dynamicFn Whether the method name should be included as
|
||||
* a dependency to the effect.
|
||||
*/
|
||||
createPropertyObserver(property: string, method: string|((p0: any, p1: any) => any), dynamicFn?: boolean): void;
|
||||
|
||||
/**
|
||||
* Creates a multi-property "method observer" based on the provided
|
||||
* expression, which should be a string in the form of a normal JavaScript
|
||||
* function signature: `'methodName(arg1, [..., argn])'`. Each argument
|
||||
* should correspond to a property or path in the context of this
|
||||
* prototype (or instance), or may be a literal string or number.
|
||||
*
|
||||
* @param expression Method expression
|
||||
* @param dynamicFn Boolean or object map indicating
|
||||
* @returns whether method names should be included as a dependency to the effect.
|
||||
*/
|
||||
createMethodObserver(expression: string, dynamicFn?: boolean|object|null): void;
|
||||
|
||||
/**
|
||||
* Causes the setter for the given property to dispatch `<property>-changed`
|
||||
* events to notify of changes to the property.
|
||||
*
|
||||
* @param property Property name
|
||||
*/
|
||||
createNotifyingProperty(property: string): void;
|
||||
|
||||
/**
|
||||
* Creates a read-only accessor for the given property.
|
||||
*
|
||||
* To set the property, use the protected `_setProperty` API.
|
||||
* To create a custom protected setter (e.g. `_setMyProp()` for
|
||||
* property `myProp`), pass `true` for `protectedSetter`.
|
||||
*
|
||||
* Note, if the property will have other property effects, this method
|
||||
* should be called first, before adding other effects.
|
||||
*
|
||||
* @param property Property name
|
||||
* @param protectedSetter Creates a custom protected setter
|
||||
* when `true`.
|
||||
*/
|
||||
createReadOnlyProperty(property: string, protectedSetter?: boolean): void;
|
||||
|
||||
/**
|
||||
* Causes the setter for the given property to reflect the property value
|
||||
* to a (dash-cased) attribute of the same name.
|
||||
*
|
||||
* @param property Property name
|
||||
*/
|
||||
createReflectedProperty(property: string): void;
|
||||
|
||||
/**
|
||||
* Creates a computed property whose value is set to the result of the
|
||||
* method described by the given `expression` each time one or more
|
||||
* arguments to the method changes. The expression should be a string
|
||||
* in the form of a normal JavaScript function signature:
|
||||
* `'methodName(arg1, [..., argn])'`
|
||||
*
|
||||
* @param property Name of computed property to set
|
||||
* @param expression Method expression
|
||||
* @param dynamicFn Boolean or object map indicating whether
|
||||
* method names should be included as a dependency to the effect.
|
||||
*/
|
||||
createComputedProperty(property: string, expression: string, dynamicFn?: boolean|object|null): void;
|
||||
|
||||
/**
|
||||
* Parses the provided template to ensure binding effects are created
|
||||
* for them, and then ensures property accessors are created for any
|
||||
* dependent properties in the template. Binding effects for bound
|
||||
* templates are stored in a linked list on the instance so that
|
||||
* templates can be efficiently stamped and unstamped.
|
||||
*
|
||||
* @param template Template containing binding
|
||||
* bindings
|
||||
* @returns Template metadata object
|
||||
*/
|
||||
bindTemplate(template: HTMLTemplateElement): TemplateInfo;
|
||||
|
||||
/**
|
||||
* Adds a property effect to the given template metadata, which is run
|
||||
* at the "propagate" stage of `_propertiesChanged` when the template
|
||||
* has been bound to the element via `_bindTemplate`.
|
||||
*
|
||||
* The `effect` object should match the format in `_addPropertyEffect`.
|
||||
*
|
||||
* @param templateInfo Template metadata to add effect to
|
||||
* @param prop Property that should trigger the effect
|
||||
* @param effect Effect metadata object
|
||||
*/
|
||||
_addTemplatePropertyEffect(templateInfo: object|null, prop: string, effect?: object|null): void;
|
||||
|
||||
/**
|
||||
* Called to parse text in a template (either attribute values or
|
||||
* textContent) into binding metadata.
|
||||
*
|
||||
* Any overrides of this method should return an array of binding part
|
||||
* metadata representing one or more bindings found in the provided text
|
||||
* and any "literal" text in between. Any non-literal parts will be passed
|
||||
* to `_evaluateBinding` when any dependencies change. The only required
|
||||
* fields of each "part" in the returned array are as follows:
|
||||
*
|
||||
* - `dependencies` - Array containing trigger metadata for each property
|
||||
* that should trigger the binding to update
|
||||
* - `literal` - String containing text if the part represents a literal;
|
||||
* in this case no `dependencies` are needed
|
||||
*
|
||||
* Additional metadata for use by `_evaluateBinding` may be provided in
|
||||
* each part object as needed.
|
||||
*
|
||||
* The default implementation handles the following types of bindings
|
||||
* (one or more may be intermixed with literal strings):
|
||||
* - Property binding: `[[prop]]`
|
||||
* - Path binding: `[[object.prop]]`
|
||||
* - Negated property or path bindings: `[[!prop]]` or `[[!object.prop]]`
|
||||
* - Two-way property or path bindings (supports negation):
|
||||
* `{{prop}}`, `{{object.prop}}`, `{{!prop}}` or `{{!object.prop}}`
|
||||
* - Inline computed method (supports negation):
|
||||
* `[[compute(a, 'literal', b)]]`, `[[!compute(a, 'literal', b)]]`
|
||||
*
|
||||
* The default implementation uses a regular expression for best
|
||||
* performance. However, the regular expression uses a white-list of
|
||||
* allowed characters in a data-binding, which causes problems for
|
||||
* data-bindings that do use characters not in this white-list.
|
||||
*
|
||||
* Instead of updating the white-list with all allowed characters,
|
||||
* there is a StrictBindingParser (see lib/mixins/strict-binding-parser)
|
||||
* that uses a state machine instead. This state machine is able to handle
|
||||
* all characters. However, it is slightly less performant, therefore we
|
||||
* extracted it into a separate optional mixin.
|
||||
*
|
||||
* @param text Text to parse from attribute or textContent
|
||||
* @param templateInfo Current template metadata
|
||||
* @returns Array of binding part metadata
|
||||
*/
|
||||
_parseBindings(text: string, templateInfo: object|null): BindingPart[]|null;
|
||||
|
||||
/**
|
||||
* Called to evaluate a previously parsed binding part based on a set of
|
||||
* one or more changed dependencies.
|
||||
*
|
||||
* @param inst Element that should be used as
|
||||
* scope for binding dependencies
|
||||
* @param part Binding part metadata
|
||||
* @param path Property/path that triggered this effect
|
||||
* @param props Bag of current property changes
|
||||
* @param oldProps Bag of previous values for changed properties
|
||||
* @param hasPaths True with `props` contains one or more paths
|
||||
* @returns Value the binding part evaluated to
|
||||
*/
|
||||
_evaluateBinding(inst: PropertyEffects, part: BindingPart|null, path: string, props: object|null, oldProps: object|null, hasPaths: boolean): any;
|
||||
}
|
||||
|
||||
export {PropertyEffectsConstructor};
|
||||
|
||||
interface PropertyEffects extends TemplateStamp, PropertyAccessors, PropertiesChanged {
|
||||
_overrideLegacyUndefined: boolean;
|
||||
readonly PROPERTY_EFFECT_TYPES: any;
|
||||
|
||||
/**
|
||||
* Stamps the provided template and performs instance-time setup for
|
||||
* Polymer template features, including data bindings, declarative event
|
||||
* listeners, and the `this.$` map of `id`'s to nodes. A document fragment
|
||||
* is returned containing the stamped DOM, ready for insertion into the
|
||||
* DOM.
|
||||
*
|
||||
* This method may be called more than once; however note that due to
|
||||
* `shadycss` polyfill limitations, only styles from templates prepared
|
||||
* using `ShadyCSS.prepareTemplate` will be correctly polyfilled (scoped
|
||||
* to the shadow root and support CSS custom properties), and note that
|
||||
* `ShadyCSS.prepareTemplate` may only be called once per element. As such,
|
||||
* any styles required by in runtime-stamped templates must be included
|
||||
* in the main element template.
|
||||
*
|
||||
* @param template Template to stamp
|
||||
* @param templateInfo Optional bound template info associated
|
||||
* with the template to be stamped; if omitted the template will be
|
||||
* automatically bound.
|
||||
* @returns Cloned template content
|
||||
*/
|
||||
_stampTemplate(template: HTMLTemplateElement, templateInfo?: TemplateInfo|null): StampedTemplate;
|
||||
|
||||
/**
|
||||
* Overrides `PropertyAccessors` so that property accessor
|
||||
* side effects are not enabled until after client dom is fully ready.
|
||||
* Also calls `_flushClients` callback to ensure client dom is enabled
|
||||
* that was not enabled as a result of flushing properties.
|
||||
*/
|
||||
ready(): void;
|
||||
_initializeProperties(): void;
|
||||
|
||||
/**
|
||||
* Overrides `PropertyAccessors` implementation to avoid setting
|
||||
* `_setProperty`'s `shouldNotify: true`.
|
||||
*
|
||||
* @param props Properties to initialize on the instance
|
||||
*/
|
||||
_initializeInstanceProperties(props: object|null): void;
|
||||
|
||||
/**
|
||||
* Overrides base implementation to ensure all accessors set `shouldNotify`
|
||||
* to true, for per-property notification tracking.
|
||||
*
|
||||
* @param property Name of the property
|
||||
* @param value Value to set
|
||||
*/
|
||||
_setProperty(property: string, value: any): void;
|
||||
|
||||
/**
|
||||
* Overrides the `PropertiesChanged` implementation to introduce special
|
||||
* dirty check logic depending on the property & value being set:
|
||||
*
|
||||
* 1. Any value set to a path (e.g. 'obj.prop': 42 or 'obj.prop': {...})
|
||||
* Stored in `__dataTemp`, dirty checked against `__dataTemp`
|
||||
* 2. Object set to simple property (e.g. 'prop': {...})
|
||||
* Stored in `__dataTemp` and `__data`, dirty checked against
|
||||
* `__dataTemp` by default implementation of `_shouldPropertyChange`
|
||||
* 3. Primitive value set to simple property (e.g. 'prop': 42)
|
||||
* Stored in `__data`, dirty checked against `__data`
|
||||
*
|
||||
* The dirty-check is important to prevent cycles due to two-way
|
||||
* notification, but paths and objects are only dirty checked against any
|
||||
* previous value set during this turn via a "temporary cache" that is
|
||||
* cleared when the last `_propertiesChanged` exits. This is so:
|
||||
* a. any cached array paths (e.g. 'array.3.prop') may be invalidated
|
||||
* due to array mutations like shift/unshift/splice; this is fine
|
||||
* since path changes are dirty-checked at user entry points like `set`
|
||||
* b. dirty-checking for objects only lasts one turn to allow the user
|
||||
* to mutate the object in-place and re-set it with the same identity
|
||||
* and have all sub-properties re-propagated in a subsequent turn.
|
||||
*
|
||||
* The temp cache is not necessarily sufficient to prevent invalid array
|
||||
* paths, since a splice can happen during the same turn (with pathological
|
||||
* user code); we could introduce a "fixup" for temporarily cached array
|
||||
* paths if needed: https://github.com/Polymer/polymer/issues/4227
|
||||
*
|
||||
* @param property Name of the property
|
||||
* @param value Value to set
|
||||
* @param shouldNotify True if property should fire notification
|
||||
* event (applies only for `notify: true` properties)
|
||||
* @returns Returns true if the property changed
|
||||
*/
|
||||
_setPendingProperty(property: string, value: any, shouldNotify?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Overrides `PropertyAccessor`'s default async queuing of
|
||||
* `_propertiesChanged`: if `__dataReady` is false (has not yet been
|
||||
* manually flushed), the function no-ops; otherwise flushes
|
||||
* `_propertiesChanged` synchronously.
|
||||
*/
|
||||
_invalidateProperties(): void;
|
||||
|
||||
/**
|
||||
* Implements `PropertyAccessors`'s properties changed callback.
|
||||
*
|
||||
* Runs each class of effects for the batch of changed properties in
|
||||
* a specific order (compute, propagate, reflect, observe, notify).
|
||||
*
|
||||
* @param currentProps Bag of all current accessor values
|
||||
* @param changedProps Bag of properties changed since the last
|
||||
* call to `_propertiesChanged`
|
||||
* @param oldProps Bag of previous values for each property
|
||||
* in `changedProps`
|
||||
*/
|
||||
_propertiesChanged(currentProps: object, changedProps: object|null, oldProps: object|null): void;
|
||||
|
||||
/**
|
||||
* Overrides `PropertyAccessors` implementation to provide a
|
||||
* more efficient implementation of initializing properties from
|
||||
* the prototype on the instance.
|
||||
*
|
||||
* @param props Properties to initialize on the prototype
|
||||
*/
|
||||
_initializeProtoProperties(props: object|null): void;
|
||||
_registerHost(): void;
|
||||
|
||||
/**
|
||||
* Equivalent to static `addPropertyEffect` API but can be called on
|
||||
* an instance to add effects at runtime. See that method for
|
||||
* full API docs.
|
||||
*
|
||||
* @param property Property that should trigger the effect
|
||||
* @param type Effect type, from this.PROPERTY_EFFECT_TYPES
|
||||
* @param effect Effect metadata object
|
||||
*/
|
||||
_addPropertyEffect(property: string, type: string, effect?: object|null): void;
|
||||
|
||||
/**
|
||||
* Removes the given property effect.
|
||||
*
|
||||
* @param property Property the effect was associated with
|
||||
* @param type Effect type, from this.PROPERTY_EFFECT_TYPES
|
||||
* @param effect Effect metadata object to remove
|
||||
*/
|
||||
_removePropertyEffect(property: string, type: string, effect?: object|null): void;
|
||||
|
||||
/**
|
||||
* Returns whether the current prototype/instance has a property effect
|
||||
* of a certain type.
|
||||
*
|
||||
* @param property Property name
|
||||
* @param type Effect type, from this.PROPERTY_EFFECT_TYPES
|
||||
* @returns True if the prototype/instance has an effect of this
|
||||
* type
|
||||
*/
|
||||
_hasPropertyEffect(property: string, type?: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether the current prototype/instance has a "read only"
|
||||
* accessor for the given property.
|
||||
*
|
||||
* @param property Property name
|
||||
* @returns True if the prototype/instance has an effect of this
|
||||
* type
|
||||
*/
|
||||
_hasReadOnlyEffect(property: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether the current prototype/instance has a "notify"
|
||||
* property effect for the given property.
|
||||
*
|
||||
* @param property Property name
|
||||
* @returns True if the prototype/instance has an effect of this
|
||||
* type
|
||||
*/
|
||||
_hasNotifyEffect(property: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether the current prototype/instance has a "reflect to
|
||||
* attribute" property effect for the given property.
|
||||
*
|
||||
* @param property Property name
|
||||
* @returns True if the prototype/instance has an effect of this
|
||||
* type
|
||||
*/
|
||||
_hasReflectEffect(property: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether the current prototype/instance has a "computed"
|
||||
* property effect for the given property.
|
||||
*
|
||||
* @param property Property name
|
||||
* @returns True if the prototype/instance has an effect of this
|
||||
* type
|
||||
*/
|
||||
_hasComputedEffect(property: string): boolean;
|
||||
|
||||
/**
|
||||
* Sets a pending property or path. If the root property of the path in
|
||||
* question had no accessor, the path is set, otherwise it is enqueued
|
||||
* via `_setPendingProperty`.
|
||||
*
|
||||
* This function isolates relatively expensive functionality necessary
|
||||
* for the public API (`set`, `setProperties`, `notifyPath`, and property
|
||||
* change listeners via {{...}} bindings), such that it is only done
|
||||
* when paths enter the system, and not at every propagation step. It
|
||||
* also sets a `__dataHasPaths` flag on the instance which is used to
|
||||
* fast-path slower path-matching code in the property effects host paths.
|
||||
*
|
||||
* `path` can be a path string or array of path parts as accepted by the
|
||||
* public API.
|
||||
*
|
||||
* @param path Path to set
|
||||
* @param value Value to set
|
||||
* @param shouldNotify Set to true if this change should
|
||||
* cause a property notification event dispatch
|
||||
* @param isPathNotification If the path being set is a path
|
||||
* notification of an already changed value, as opposed to a request
|
||||
* to set and notify the change. In the latter `false` case, a dirty
|
||||
* check is performed and then the value is set to the path before
|
||||
* enqueuing the pending property change.
|
||||
* @returns Returns true if the property/path was enqueued in
|
||||
* the pending changes bag.
|
||||
*/
|
||||
_setPendingPropertyOrPath(path: string|Array<number|string>, value: any, shouldNotify?: boolean, isPathNotification?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Applies a value to a non-Polymer element/node's property.
|
||||
*
|
||||
* The implementation makes a best-effort at binding interop:
|
||||
* Some native element properties have side-effects when
|
||||
* re-setting the same value (e.g. setting `<input>.value` resets the
|
||||
* cursor position), so we do a dirty-check before setting the value.
|
||||
* However, for better interop with non-Polymer custom elements that
|
||||
* accept objects, we explicitly re-set object changes coming from the
|
||||
* Polymer world (which may include deep object changes without the
|
||||
* top reference changing), erring on the side of providing more
|
||||
* information.
|
||||
*
|
||||
* Users may override this method to provide alternate approaches.
|
||||
*
|
||||
* @param node The node to set a property on
|
||||
* @param prop The property to set
|
||||
* @param value The value to set
|
||||
*/
|
||||
_setUnmanagedPropertyToNode(node: Node, prop: string, value: any): void;
|
||||
|
||||
/**
|
||||
* Enqueues the given client on a list of pending clients, whose
|
||||
* pending property changes can later be flushed via a call to
|
||||
* `_flushClients`.
|
||||
*
|
||||
* @param client PropertyEffects client to enqueue
|
||||
*/
|
||||
_enqueueClient(client: object|null): void;
|
||||
|
||||
/**
|
||||
* Flushes any clients previously enqueued via `_enqueueClient`, causing
|
||||
* their `_flushProperties` method to run.
|
||||
*/
|
||||
_flushClients(): void;
|
||||
|
||||
/**
|
||||
* Perform any initial setup on client dom. Called before the first
|
||||
* `_flushProperties` call on client dom and before any element
|
||||
* observers are called.
|
||||
*/
|
||||
_readyClients(): void;
|
||||
|
||||
/**
|
||||
* Sets a bag of property changes to this instance, and
|
||||
* synchronously processes all effects of the properties as a batch.
|
||||
*
|
||||
* Property names must be simple properties, not paths. Batched
|
||||
* path propagation is not supported.
|
||||
*
|
||||
* @param props Bag of one or more key-value pairs whose key is
|
||||
* a property and value is the new value to set for that property.
|
||||
* @param setReadOnly When true, any private values set in
|
||||
* `props` will be set. By default, `setProperties` will not set
|
||||
* `readOnly: true` root properties.
|
||||
*/
|
||||
setProperties(props: object|null, setReadOnly?: boolean): void;
|
||||
|
||||
/**
|
||||
* Called to propagate any property changes to stamped template nodes
|
||||
* managed by this element.
|
||||
*
|
||||
* @param changedProps Bag of changed properties
|
||||
* @param oldProps Bag of previous values for changed properties
|
||||
* @param hasPaths True with `props` contains one or more paths
|
||||
*/
|
||||
_propagatePropertyChanges(changedProps: object|null, oldProps: object|null, hasPaths: boolean): void;
|
||||
_runEffectsForTemplate(templateInfo: any, changedProps: any, oldProps: any, hasPaths: any): void;
|
||||
|
||||
/**
|
||||
* Aliases one data path as another, such that path notifications from one
|
||||
* are routed to the other.
|
||||
*
|
||||
* @param to Target path to link.
|
||||
* @param from Source path to link.
|
||||
*/
|
||||
linkPaths(to: string|Array<string|number>, from: string|Array<string|number>): void;
|
||||
|
||||
/**
|
||||
* Removes a data path alias previously established with `_linkPaths`.
|
||||
*
|
||||
* Note, the path to unlink should be the target (`to`) used when
|
||||
* linking the paths.
|
||||
*
|
||||
* @param path Target path to unlink.
|
||||
*/
|
||||
unlinkPaths(path: string|Array<string|number>): void;
|
||||
|
||||
/**
|
||||
* Notify that an array has changed.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* this.items = [ {name: 'Jim'}, {name: 'Todd'}, {name: 'Bill'} ];
|
||||
* ...
|
||||
* this.items.splice(1, 1, {name: 'Sam'});
|
||||
* this.items.push({name: 'Bob'});
|
||||
* this.notifySplices('items', [
|
||||
* { index: 1, removed: [{name: 'Todd'}], addedCount: 1,
|
||||
* object: this.items, type: 'splice' },
|
||||
* { index: 3, removed: [], addedCount: 1,
|
||||
* object: this.items, type: 'splice'}
|
||||
* ]);
|
||||
*
|
||||
* @param path Path that should be notified.
|
||||
* @param splices Array of splice records indicating ordered
|
||||
* changes that occurred to the array. Each record should have the
|
||||
* following fields:
|
||||
* * index: index at which the change occurred
|
||||
* * removed: array of items that were removed from this index
|
||||
* * addedCount: number of new items added at this index
|
||||
* * object: a reference to the array in question
|
||||
* * type: the string literal 'splice'
|
||||
*
|
||||
* Note that splice records _must_ be normalized such that they are
|
||||
* reported in index order (raw results from `Object.observe` are not
|
||||
* ordered and must be normalized/merged before notifying).
|
||||
*/
|
||||
notifySplices(path: string, splices: any[]|null): void;
|
||||
|
||||
/**
|
||||
* Convenience method for reading a value from a path.
|
||||
*
|
||||
* Note, if any part in the path is undefined, this method returns
|
||||
* `undefined` (this method does not throw when dereferencing undefined
|
||||
* paths).
|
||||
*
|
||||
* @param path Path to the value
|
||||
* to read. The path may be specified as a string (e.g. `foo.bar.baz`)
|
||||
* or an array of path parts (e.g. `['foo.bar', 'baz']`). Note that
|
||||
* bracketed expressions are not supported; string-based path parts
|
||||
* *must* be separated by dots. Note that when dereferencing array
|
||||
* indices, the index may be used as a dotted part directly
|
||||
* (e.g. `users.12.name` or `['users', 12, 'name']`).
|
||||
* @param root Root object from which the path is evaluated.
|
||||
* @returns Value at the path, or `undefined` if any part of the path
|
||||
* is undefined.
|
||||
*/
|
||||
get(path: string|Array<string|number>, root?: object|null): any;
|
||||
|
||||
/**
|
||||
* Convenience method for setting a value to a path and notifying any
|
||||
* elements bound to the same path.
|
||||
*
|
||||
* Note, if any part in the path except for the last is undefined,
|
||||
* this method does nothing (this method does not throw when
|
||||
* dereferencing undefined paths).
|
||||
*
|
||||
* @param path Path to the value
|
||||
* to write. The path may be specified as a string (e.g. `'foo.bar.baz'`)
|
||||
* or an array of path parts (e.g. `['foo.bar', 'baz']`). Note that
|
||||
* bracketed expressions are not supported; string-based path parts
|
||||
* *must* be separated by dots. Note that when dereferencing array
|
||||
* indices, the index may be used as a dotted part directly
|
||||
* (e.g. `'users.12.name'` or `['users', 12, 'name']`).
|
||||
* @param value Value to set at the specified path.
|
||||
* @param root Root object from which the path is evaluated.
|
||||
* When specified, no notification will occur.
|
||||
*/
|
||||
set(path: string|Array<string|number>, value: any, root?: object|null): void;
|
||||
|
||||
/**
|
||||
* Adds items onto the end of the array at the path specified.
|
||||
*
|
||||
* The arguments after `path` and return value match that of
|
||||
* `Array.prototype.push`.
|
||||
*
|
||||
* This method notifies other paths to the same array that a
|
||||
* splice occurred to the array.
|
||||
*
|
||||
* @param path Path to array.
|
||||
* @param items Items to push onto array
|
||||
* @returns New length of the array.
|
||||
*/
|
||||
push(path: string|Array<string|number>, ...items: any[]): number;
|
||||
|
||||
/**
|
||||
* Removes an item from the end of array at the path specified.
|
||||
*
|
||||
* The arguments after `path` and return value match that of
|
||||
* `Array.prototype.pop`.
|
||||
*
|
||||
* This method notifies other paths to the same array that a
|
||||
* splice occurred to the array.
|
||||
*
|
||||
* @param path Path to array.
|
||||
* @returns Item that was removed.
|
||||
*/
|
||||
pop(path: string|Array<string|number>): any;
|
||||
|
||||
/**
|
||||
* Starting from the start index specified, removes 0 or more items
|
||||
* from the array and inserts 0 or more new items in their place.
|
||||
*
|
||||
* The arguments after `path` and return value match that of
|
||||
* `Array.prototype.splice`.
|
||||
*
|
||||
* This method notifies other paths to the same array that a
|
||||
* splice occurred to the array.
|
||||
*
|
||||
* @param path Path to array.
|
||||
* @param start Index from which to start removing/inserting.
|
||||
* @param deleteCount Number of items to remove.
|
||||
* @param items Items to insert into array.
|
||||
* @returns Array of removed items.
|
||||
*/
|
||||
splice(path: string|Array<string|number>, start: number, deleteCount?: number, ...items: any[]): any[];
|
||||
|
||||
/**
|
||||
* Removes an item from the beginning of array at the path specified.
|
||||
*
|
||||
* The arguments after `path` and return value match that of
|
||||
* `Array.prototype.pop`.
|
||||
*
|
||||
* This method notifies other paths to the same array that a
|
||||
* splice occurred to the array.
|
||||
*
|
||||
* @param path Path to array.
|
||||
* @returns Item that was removed.
|
||||
*/
|
||||
shift(path: string|Array<string|number>): any;
|
||||
|
||||
/**
|
||||
* Adds items onto the beginning of the array at the path specified.
|
||||
*
|
||||
* The arguments after `path` and return value match that of
|
||||
* `Array.prototype.push`.
|
||||
*
|
||||
* This method notifies other paths to the same array that a
|
||||
* splice occurred to the array.
|
||||
*
|
||||
* @param path Path to array.
|
||||
* @param items Items to insert info array
|
||||
* @returns New length of the array.
|
||||
*/
|
||||
unshift(path: string|Array<string|number>, ...items: any[]): number;
|
||||
|
||||
/**
|
||||
* Notify that a path has changed.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* this.item.user.name = 'Bob';
|
||||
* this.notifyPath('item.user.name');
|
||||
*
|
||||
* @param path Path that should be notified.
|
||||
* @param value Value at the path (optional).
|
||||
*/
|
||||
notifyPath(path: string, value?: any): void;
|
||||
|
||||
/**
|
||||
* Equivalent to static `createReadOnlyProperty` API but can be called on
|
||||
* an instance to add effects at runtime. See that method for
|
||||
* full API docs.
|
||||
*
|
||||
* @param property Property name
|
||||
* @param protectedSetter Creates a custom protected setter
|
||||
* when `true`.
|
||||
*/
|
||||
_createReadOnlyProperty(property: string, protectedSetter?: boolean): void;
|
||||
|
||||
/**
|
||||
* Equivalent to static `createPropertyObserver` API but can be called on
|
||||
* an instance to add effects at runtime. See that method for
|
||||
* full API docs.
|
||||
*
|
||||
* @param property Property name
|
||||
* @param method Function or name of observer method
|
||||
* to call
|
||||
* @param dynamicFn Whether the method name should be included as
|
||||
* a dependency to the effect.
|
||||
*/
|
||||
_createPropertyObserver(property: string, method: string|((p0: any, p1: any) => any), dynamicFn?: boolean): void;
|
||||
|
||||
/**
|
||||
* Equivalent to static `createMethodObserver` API but can be called on
|
||||
* an instance to add effects at runtime. See that method for
|
||||
* full API docs.
|
||||
*
|
||||
* @param expression Method expression
|
||||
* @param dynamicFn Boolean or object map indicating
|
||||
* whether method names should be included as a dependency to the effect.
|
||||
*/
|
||||
_createMethodObserver(expression: string, dynamicFn?: boolean|object|null): void;
|
||||
|
||||
/**
|
||||
* Equivalent to static `createNotifyingProperty` API but can be called on
|
||||
* an instance to add effects at runtime. See that method for
|
||||
* full API docs.
|
||||
*
|
||||
* @param property Property name
|
||||
*/
|
||||
_createNotifyingProperty(property: string): void;
|
||||
|
||||
/**
|
||||
* Equivalent to static `createReflectedProperty` API but can be called on
|
||||
* an instance to add effects at runtime. See that method for
|
||||
* full API docs.
|
||||
*
|
||||
* @param property Property name
|
||||
*/
|
||||
_createReflectedProperty(property: string): void;
|
||||
|
||||
/**
|
||||
* Equivalent to static `createComputedProperty` API but can be called on
|
||||
* an instance to add effects at runtime. See that method for
|
||||
* full API docs.
|
||||
*
|
||||
* @param property Name of computed property to set
|
||||
* @param expression Method expression
|
||||
* @param dynamicFn Boolean or object map indicating
|
||||
* whether method names should be included as a dependency to the effect.
|
||||
*/
|
||||
_createComputedProperty(property: string, expression: string, dynamicFn?: boolean|object|null): void;
|
||||
|
||||
/**
|
||||
* Equivalent to static `bindTemplate` API but can be called on an instance
|
||||
* to add effects at runtime. See that method for full API docs.
|
||||
*
|
||||
* This method may be called on the prototype (for prototypical template
|
||||
* binding, to avoid creating accessors every instance) once per prototype,
|
||||
* and will be called with `runtimeBinding: true` by `_stampTemplate` to
|
||||
* create and link an instance of the template metadata associated with a
|
||||
* particular stamping.
|
||||
*
|
||||
* @param template Template containing binding
|
||||
* bindings
|
||||
* @param instanceBinding When false (default), performs
|
||||
* "prototypical" binding of the template and overwrites any previously
|
||||
* bound template for the class. When true (as passed from
|
||||
* `_stampTemplate`), the template info is instanced and linked into the
|
||||
* list of bound templates.
|
||||
* @returns Template metadata object; for `runtimeBinding`,
|
||||
* this is an instance of the prototypical template info
|
||||
*/
|
||||
_bindTemplate(template: HTMLTemplateElement, instanceBinding?: boolean): TemplateInfo;
|
||||
|
||||
/**
|
||||
* Removes and unbinds the nodes previously contained in the provided
|
||||
* DocumentFragment returned from `_stampTemplate`.
|
||||
*
|
||||
* @param dom DocumentFragment previously returned
|
||||
* from `_stampTemplate` associated with the nodes to be removed
|
||||
*/
|
||||
_removeBoundDom(dom: StampedTemplate): void;
|
||||
}
|
||||
|
||||
import {TemplateInfo} from '../../interfaces';
|
||||
|
||||
import {NodeInfo} from '../../interfaces';
|
||||
|
||||
import {BindingPart} from '../../interfaces';
|
||||
|
||||
import {StampedTemplate} from '../../interfaces';
|
83
lib/mixins/strict-binding-parser.d.ts
vendored
Normal file
83
lib/mixins/strict-binding-parser.d.ts
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/mixins/strict-binding-parser.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {isPath} from '../utils/path.js';
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
import {PropertyEffects} from './property-effects.js';
|
||||
|
||||
|
||||
/**
|
||||
* Mixin that parses binding expressions and generates corresponding metadata.
|
||||
* The implementation is different than in `property-effects`, as it uses a
|
||||
* state machine instead of a regex. As such, this implementation is able to
|
||||
* handle more cases, with the potential performance hit.
|
||||
*/
|
||||
declare function StrictBindingParser<T extends new (...args: any[]) => {}>(base: T): T & StrictBindingParserConstructor & PropertyEffectsConstructor & TemplateStampConstructor & PropertyAccessorsConstructor & PropertiesChangedConstructor;
|
||||
|
||||
import {PropertyEffectsConstructor} from './property-effects.js';
|
||||
|
||||
import {TemplateStampConstructor, TemplateStamp} from './template-stamp.js';
|
||||
|
||||
import {PropertyAccessorsConstructor, PropertyAccessors} from './property-accessors.js';
|
||||
|
||||
import {PropertiesChangedConstructor, PropertiesChanged} from './properties-changed.js';
|
||||
|
||||
interface StrictBindingParserConstructor {
|
||||
new(...args: any[]): StrictBindingParser;
|
||||
|
||||
/**
|
||||
* Called to parse text in a template (either attribute values or
|
||||
* textContent) into binding metadata.
|
||||
*
|
||||
* Any overrides of this method should return an array of binding part
|
||||
* metadata representing one or more bindings found in the provided text
|
||||
* and any "literal" text in between. Any non-literal parts will be passed
|
||||
* to `_evaluateBinding` when any dependencies change. The only required
|
||||
* fields of each "part" in the returned array are as follows:
|
||||
*
|
||||
* - `dependencies` - Array containing trigger metadata for each property
|
||||
* that should trigger the binding to update
|
||||
* - `literal` - String containing text if the part represents a literal;
|
||||
* in this case no `dependencies` are needed
|
||||
*
|
||||
* Additional metadata for use by `_evaluateBinding` may be provided in
|
||||
* each part object as needed.
|
||||
*
|
||||
* The default implementation handles the following types of bindings
|
||||
* (one or more may be intermixed with literal strings):
|
||||
* - Property binding: `[[prop]]`
|
||||
* - Path binding: `[[object.prop]]`
|
||||
* - Negated property or path bindings: `[[!prop]]` or `[[!object.prop]]`
|
||||
* - Two-way property or path bindings (supports negation):
|
||||
* `{{prop}}`, `{{object.prop}}`, `{{!prop}}` or `{{!object.prop}}`
|
||||
* - Inline computed method (supports negation):
|
||||
* `[[compute(a, 'literal', b)]]`, `[[!compute(a, 'literal', b)]]`
|
||||
*
|
||||
* @param text Text to parse from attribute or textContent
|
||||
* @param templateInfo Current template metadata
|
||||
* @returns Array of binding part metadata
|
||||
*/
|
||||
_parseBindings(text: string, templateInfo: object|null): BindingPart[]|null;
|
||||
}
|
||||
|
||||
export {StrictBindingParserConstructor};
|
||||
|
||||
interface StrictBindingParser extends PropertyEffects, TemplateStamp, PropertyAccessors, PropertiesChanged {
|
||||
}
|
||||
|
||||
export {StrictBindingParser};
|
||||
|
||||
import {BindingPart} from '../../interfaces';
|
281
lib/mixins/template-stamp.d.ts
vendored
Normal file
281
lib/mixins/template-stamp.d.ts
vendored
Normal file
|
@ -0,0 +1,281 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/mixins/template-stamp.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {dedupingMixin} from '../utils/mixin.js';
|
||||
|
||||
export {TemplateStamp};
|
||||
|
||||
|
||||
/**
|
||||
* Element mixin that provides basic template parsing and stamping, including
|
||||
* the following template-related features for stamped templates:
|
||||
*
|
||||
* - Declarative event listeners (`on-eventname="listener"`)
|
||||
* - Map of node id's to stamped node instances (`this.$.id`)
|
||||
* - Nested template content caching/removal and re-installation (performance
|
||||
* optimization)
|
||||
*/
|
||||
declare function TemplateStamp<T extends new (...args: any[]) => {}>(base: T): T & TemplateStampConstructor;
|
||||
|
||||
interface TemplateStampConstructor {
|
||||
new(...args: any[]): TemplateStamp;
|
||||
|
||||
/**
|
||||
* Scans a template to produce template metadata.
|
||||
*
|
||||
* Template-specific metadata are stored in the object returned, and node-
|
||||
* specific metadata are stored in objects in its flattened `nodeInfoList`
|
||||
* array. Only nodes in the template that were parsed as nodes of
|
||||
* interest contain an object in `nodeInfoList`. Each `nodeInfo` object
|
||||
* contains an `index` (`childNodes` index in parent) and optionally
|
||||
* `parent`, which points to node info of its parent (including its index).
|
||||
*
|
||||
* The template metadata object returned from this method has the following
|
||||
* structure (many fields optional):
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* // Flattened list of node metadata (for nodes that generated metadata)
|
||||
* nodeInfoList: [
|
||||
* {
|
||||
* // `id` attribute for any nodes with id's for generating `$` map
|
||||
* id: {string},
|
||||
* // `on-event="handler"` metadata
|
||||
* events: [
|
||||
* {
|
||||
* name: {string}, // event name
|
||||
* value: {string}, // handler method name
|
||||
* }, ...
|
||||
* ],
|
||||
* // Notes when the template contained a `<slot>` for shady DOM
|
||||
* // optimization purposes
|
||||
* hasInsertionPoint: {boolean},
|
||||
* // For nested `<template>`` nodes, nested template metadata
|
||||
* templateInfo: {object}, // nested template metadata
|
||||
* // Metadata to allow efficient retrieval of instanced node
|
||||
* // corresponding to this metadata
|
||||
* parentInfo: {number}, // reference to parent nodeInfo>
|
||||
* parentIndex: {number}, // index in parent's `childNodes` collection
|
||||
* infoIndex: {number}, // index of this `nodeInfo` in `templateInfo.nodeInfoList`
|
||||
* },
|
||||
* ...
|
||||
* ],
|
||||
* // When true, the template had the `strip-whitespace` attribute
|
||||
* // or was nested in a template with that setting
|
||||
* stripWhitespace: {boolean},
|
||||
* // For nested templates, nested template content is moved into
|
||||
* // a document fragment stored here; this is an optimization to
|
||||
* // avoid the cost of nested template cloning
|
||||
* content: {DocumentFragment}
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* This method kicks off a recursive treewalk as follows:
|
||||
*
|
||||
* ```
|
||||
* _parseTemplate <---------------------+
|
||||
* _parseTemplateContent |
|
||||
* _parseTemplateNode <------------|--+
|
||||
* _parseTemplateNestedTemplate --+ |
|
||||
* _parseTemplateChildNodes ---------+
|
||||
* _parseTemplateNodeAttributes
|
||||
* _parseTemplateNodeAttribute
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* These methods may be overridden to add custom metadata about templates
|
||||
* to either `templateInfo` or `nodeInfo`.
|
||||
*
|
||||
* Note that this method may be destructive to the template, in that
|
||||
* e.g. event annotations may be removed after being noted in the
|
||||
* template metadata.
|
||||
*
|
||||
* @param template Template to parse
|
||||
* @param outerTemplateInfo Template metadata from the outer
|
||||
* template, for parsing nested templates
|
||||
* @returns Parsed template metadata
|
||||
*/
|
||||
_parseTemplate(template: HTMLTemplateElement, outerTemplateInfo?: TemplateInfo|null): TemplateInfo;
|
||||
|
||||
/**
|
||||
* See docs for _parseTemplateNode.
|
||||
*
|
||||
* @param template .
|
||||
* @param templateInfo .
|
||||
* @param nodeInfo .
|
||||
* @returns .
|
||||
*/
|
||||
_parseTemplateContent(template: HTMLTemplateElement, templateInfo: TemplateInfo, nodeInfo: NodeInfo): boolean;
|
||||
|
||||
/**
|
||||
* Parses template node and adds template and node metadata based on
|
||||
* the current node, and its `childNodes` and `attributes`.
|
||||
*
|
||||
* This method may be overridden to add custom node or template specific
|
||||
* metadata based on this node.
|
||||
*
|
||||
* @param node Node to parse
|
||||
* @param templateInfo Template metadata for current template
|
||||
* @param nodeInfo Node metadata for current template.
|
||||
* @returns `true` if the visited node added node-specific
|
||||
* metadata to `nodeInfo`
|
||||
*/
|
||||
_parseTemplateNode(node: Node|null, templateInfo: TemplateInfo, nodeInfo: NodeInfo): boolean;
|
||||
|
||||
/**
|
||||
* Parses template child nodes for the given root node.
|
||||
*
|
||||
* This method also wraps whitelisted legacy template extensions
|
||||
* (`is="dom-if"` and `is="dom-repeat"`) with their equivalent element
|
||||
* wrappers, collapses text nodes, and strips whitespace from the template
|
||||
* if the `templateInfo.stripWhitespace` setting was provided.
|
||||
*
|
||||
* @param root Root node whose `childNodes` will be parsed
|
||||
* @param templateInfo Template metadata for current template
|
||||
* @param nodeInfo Node metadata for current template.
|
||||
*/
|
||||
_parseTemplateChildNodes(root: Node|null, templateInfo: TemplateInfo, nodeInfo: NodeInfo): void;
|
||||
|
||||
/**
|
||||
* Parses template content for the given nested `<template>`.
|
||||
*
|
||||
* Nested template info is stored as `templateInfo` in the current node's
|
||||
* `nodeInfo`. `template.content` is removed and stored in `templateInfo`.
|
||||
* It will then be the responsibility of the host to set it back to the
|
||||
* template and for users stamping nested templates to use the
|
||||
* `_contentForTemplate` method to retrieve the content for this template
|
||||
* (an optimization to avoid the cost of cloning nested template content).
|
||||
*
|
||||
* @param node Node to parse (a <template>)
|
||||
* @param outerTemplateInfo Template metadata for current template
|
||||
* that includes the template `node`
|
||||
* @param nodeInfo Node metadata for current template.
|
||||
* @returns `true` if the visited node added node-specific
|
||||
* metadata to `nodeInfo`
|
||||
*/
|
||||
_parseTemplateNestedTemplate(node: HTMLTemplateElement|null, outerTemplateInfo: TemplateInfo|null, nodeInfo: NodeInfo): boolean;
|
||||
|
||||
/**
|
||||
* Parses template node attributes and adds node metadata to `nodeInfo`
|
||||
* for nodes of interest.
|
||||
*
|
||||
* @param node Node to parse
|
||||
* @param templateInfo Template metadata for current
|
||||
* template
|
||||
* @param nodeInfo Node metadata for current template.
|
||||
* @returns `true` if the visited node added node-specific
|
||||
* metadata to `nodeInfo`
|
||||
*/
|
||||
_parseTemplateNodeAttributes(node: Element|null, templateInfo: TemplateInfo, nodeInfo: NodeInfo): boolean;
|
||||
|
||||
/**
|
||||
* Parses a single template node attribute and adds node metadata to
|
||||
* `nodeInfo` for attributes of interest.
|
||||
*
|
||||
* This implementation adds metadata for `on-event="handler"` attributes
|
||||
* and `id` attributes.
|
||||
*
|
||||
* @param node Node to parse
|
||||
* @param templateInfo Template metadata for current template
|
||||
* @param nodeInfo Node metadata for current template.
|
||||
* @param name Attribute name
|
||||
* @param value Attribute value
|
||||
* @returns `true` if the visited node added node-specific
|
||||
* metadata to `nodeInfo`
|
||||
*/
|
||||
_parseTemplateNodeAttribute(node: Element|null, templateInfo: TemplateInfo, nodeInfo: NodeInfo, name: string, value: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns the `content` document fragment for a given template.
|
||||
*
|
||||
* For nested templates, Polymer performs an optimization to cache nested
|
||||
* template content to avoid the cost of cloning deeply nested templates.
|
||||
* This method retrieves the cached content for a given template.
|
||||
*
|
||||
* @param template Template to retrieve `content` for
|
||||
* @returns Content fragment
|
||||
*/
|
||||
_contentForTemplate(template: HTMLTemplateElement|null): DocumentFragment|null;
|
||||
}
|
||||
|
||||
export {TemplateStampConstructor};
|
||||
|
||||
interface TemplateStamp {
|
||||
|
||||
/**
|
||||
* Clones the provided template content and returns a document fragment
|
||||
* containing the cloned dom.
|
||||
*
|
||||
* The template is parsed (once and memoized) using this library's
|
||||
* template parsing features, and provides the following value-added
|
||||
* features:
|
||||
* * Adds declarative event listeners for `on-event="handler"` attributes
|
||||
* * Generates an "id map" for all nodes with id's under `$` on returned
|
||||
* document fragment
|
||||
* * Passes template info including `content` back to templates as
|
||||
* `_templateInfo` (a performance optimization to avoid deep template
|
||||
* cloning)
|
||||
*
|
||||
* Note that the memoized template parsing process is destructive to the
|
||||
* template: attributes for bindings and declarative event listeners are
|
||||
* removed after being noted in notes, and any nested `<template>.content`
|
||||
* is removed and stored in notes as well.
|
||||
*
|
||||
* @param template Template to stamp
|
||||
* @param templateInfo Optional template info associated
|
||||
* with the template to be stamped; if omitted the template will be
|
||||
* automatically parsed.
|
||||
* @returns Cloned template content
|
||||
*/
|
||||
_stampTemplate(template: HTMLTemplateElement, templateInfo?: TemplateInfo|null): StampedTemplate;
|
||||
|
||||
/**
|
||||
* Adds an event listener by method name for the event provided.
|
||||
*
|
||||
* This method generates a handler function that looks up the method
|
||||
* name at handling time.
|
||||
*
|
||||
* @param node Node to add listener on
|
||||
* @param eventName Name of event
|
||||
* @param methodName Name of method
|
||||
* @param context Context the method will be called on (defaults
|
||||
* to `node`)
|
||||
* @returns Generated handler function
|
||||
*/
|
||||
_addMethodEventListenerToNode(node: EventTarget, eventName: string, methodName: string, context?: any): Function|null;
|
||||
|
||||
/**
|
||||
* Override point for adding custom or simulated event handling.
|
||||
*
|
||||
* @param node Node to add event listener to
|
||||
* @param eventName Name of event
|
||||
* @param handler Listener function to add
|
||||
*/
|
||||
_addEventListenerToNode(node: EventTarget, eventName: string, handler: (p0: Event) => void): void;
|
||||
|
||||
/**
|
||||
* Override point for adding custom or simulated event handling.
|
||||
*
|
||||
* @param node Node to remove event listener from
|
||||
* @param eventName Name of event
|
||||
* @param handler Listener function to remove
|
||||
*/
|
||||
_removeEventListenerFromNode(node: EventTarget, eventName: string, handler: (p0: Event) => void): void;
|
||||
}
|
||||
|
||||
import {TemplateInfo} from '../../interfaces';
|
||||
|
||||
import {NodeInfo} from '../../interfaces';
|
||||
|
||||
import {StampedTemplate} from '../../interfaces';
|
44
lib/utils/array-splice.d.ts
vendored
Normal file
44
lib/utils/array-splice.d.ts
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/array-splice.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
export {calculateSplices};
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of splice records indicating the minimum edits required
|
||||
* to transform the `previous` array into the `current` array.
|
||||
*
|
||||
* Splice records are ordered by index and contain the following fields:
|
||||
* - `index`: index where edit started
|
||||
* - `removed`: array of removed items from this index
|
||||
* - `addedCount`: number of items added at this index
|
||||
*
|
||||
* This function is based on the Levenshtein "minimum edit distance"
|
||||
* algorithm. Note that updates are treated as removal followed by addition.
|
||||
*
|
||||
* The worst-case time complexity of this algorithm is `O(l * p)`
|
||||
* l: The length of the current array
|
||||
* p: The length of the previous array
|
||||
*
|
||||
* However, the worst-case complexity is reduced by an `O(n)` optimization
|
||||
* to detect any shared prefix & suffix between the two arrays and only
|
||||
* perform the more expensive minimum edit distance calculation over the
|
||||
* non-shared portions of the arrays.
|
||||
*
|
||||
* @returns Returns an array of splice record objects. Each of these
|
||||
* contains: `index` the location where the splice occurred; `removed`
|
||||
* the array of removed items from this location; `addedCount` the number
|
||||
* of items added at this location.
|
||||
*/
|
||||
declare function calculateSplices(current: any[], previous: any[]): any[];
|
120
lib/utils/async.d.ts
vendored
Normal file
120
lib/utils/async.d.ts
vendored
Normal file
|
@ -0,0 +1,120 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/async.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
/**
|
||||
* Async interface wrapper around `setTimeout`.
|
||||
*/
|
||||
declare namespace timeOut {
|
||||
|
||||
|
||||
/**
|
||||
* Returns a sub-module with the async interface providing the provided
|
||||
* delay.
|
||||
*
|
||||
* @returns An async timeout interface
|
||||
*/
|
||||
function after(delay?: number): AsyncInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Enqueues a function called in the next task.
|
||||
*
|
||||
* @returns Handle used for canceling task
|
||||
*/
|
||||
function run(fn: Function, delay?: number): number;
|
||||
|
||||
|
||||
/**
|
||||
* Cancels a previously enqueued `timeOut` callback.
|
||||
*/
|
||||
function cancel(handle: number): void;
|
||||
}
|
||||
|
||||
export {timeOut};
|
||||
|
||||
/**
|
||||
* Async interface wrapper around `requestAnimationFrame`.
|
||||
*/
|
||||
declare namespace animationFrame {
|
||||
|
||||
|
||||
/**
|
||||
* Enqueues a function called at `requestAnimationFrame` timing.
|
||||
*
|
||||
* @returns Handle used for canceling task
|
||||
*/
|
||||
function run(fn: (p0: number) => void): number;
|
||||
|
||||
|
||||
/**
|
||||
* Cancels a previously enqueued `animationFrame` callback.
|
||||
*/
|
||||
function cancel(handle: number): void;
|
||||
}
|
||||
|
||||
export {animationFrame};
|
||||
|
||||
/**
|
||||
* Async interface wrapper around `requestIdleCallback`. Falls back to
|
||||
* `setTimeout` on browsers that do not support `requestIdleCallback`.
|
||||
*/
|
||||
declare namespace idlePeriod {
|
||||
|
||||
|
||||
/**
|
||||
* Enqueues a function called at `requestIdleCallback` timing.
|
||||
*
|
||||
* @returns Handle used for canceling task
|
||||
*/
|
||||
function run(fn: (p0: IdleDeadline) => void): number;
|
||||
|
||||
|
||||
/**
|
||||
* Cancels a previously enqueued `idlePeriod` callback.
|
||||
*/
|
||||
function cancel(handle: number): void;
|
||||
}
|
||||
|
||||
export {idlePeriod};
|
||||
|
||||
/**
|
||||
* Async interface for enqueuing callbacks that run at microtask timing.
|
||||
*
|
||||
* Note that microtask timing is achieved via a single `MutationObserver`,
|
||||
* and thus callbacks enqueued with this API will all run in a single
|
||||
* batch, and not interleaved with other microtasks such as promises.
|
||||
* Promises are avoided as an implementation choice for the time being
|
||||
* due to Safari bugs that cause Promises to lack microtask guarantees.
|
||||
*/
|
||||
declare namespace microTask {
|
||||
|
||||
|
||||
/**
|
||||
* Enqueues a function called at microtask timing.
|
||||
*
|
||||
* @returns Handle used for canceling task
|
||||
*/
|
||||
function run(callback?: Function): number;
|
||||
|
||||
|
||||
/**
|
||||
* Cancels a previously enqueued `microTask` callback.
|
||||
*/
|
||||
function cancel(handle: number): void;
|
||||
}
|
||||
|
||||
export {microTask};
|
||||
|
||||
import {AsyncInterface} from '../../interfaces';
|
||||
|
||||
import {IdleDeadline} from '../../interfaces';
|
15
lib/utils/boot.d.ts
vendored
Normal file
15
lib/utils/boot.d.ts
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/boot.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
|
||||
export {};
|
34
lib/utils/case-map.d.ts
vendored
Normal file
34
lib/utils/case-map.d.ts
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/case-map.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
export {dashToCamelCase};
|
||||
|
||||
|
||||
/**
|
||||
* Converts "dash-case" identifier (e.g. `foo-bar-baz`) to "camelCase"
|
||||
* (e.g. `fooBarBaz`).
|
||||
*
|
||||
* @returns Camel-case representation of the identifier
|
||||
*/
|
||||
declare function dashToCamelCase(dash: string): string;
|
||||
|
||||
export {camelToDashCase};
|
||||
|
||||
|
||||
/**
|
||||
* Converts "camelCase" identifier (e.g. `fooBarBaz`) to "dash-case"
|
||||
* (e.g. `foo-bar-baz`).
|
||||
*
|
||||
* @returns Dash-case representation of the identifier
|
||||
*/
|
||||
declare function camelToDashCase(camel: string): string;
|
107
lib/utils/debounce.d.ts
vendored
Normal file
107
lib/utils/debounce.d.ts
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/debounce.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
export {Debouncer};
|
||||
|
||||
declare class Debouncer {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Creates a debouncer if no debouncer is passed as a parameter
|
||||
* or it cancels an active debouncer otherwise. The following
|
||||
* example shows how a debouncer can be called multiple times within a
|
||||
* microtask and "debounced" such that the provided callback function is
|
||||
* called once. Add this method to a custom element:
|
||||
*
|
||||
* ```js
|
||||
* import {microTask} from '@polymer/polymer/lib/utils/async.js';
|
||||
* import {Debouncer} from '@polymer/polymer/lib/utils/debounce.js';
|
||||
* // ...
|
||||
*
|
||||
* _debounceWork() {
|
||||
* this._debounceJob = Debouncer.debounce(this._debounceJob,
|
||||
* microTask, () => this._doWork());
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* If the `_debounceWork` method is called multiple times within the same
|
||||
* microtask, the `_doWork` function will be called only once at the next
|
||||
* microtask checkpoint.
|
||||
*
|
||||
* Note: In testing it is often convenient to avoid asynchrony. To accomplish
|
||||
* this with a debouncer, you can use `enqueueDebouncer` and
|
||||
* `flush`. For example, extend the above example by adding
|
||||
* `enqueueDebouncer(this._debounceJob)` at the end of the
|
||||
* `_debounceWork` method. Then in a test, call `flush` to ensure
|
||||
* the debouncer has completed.
|
||||
*
|
||||
* @param debouncer Debouncer object.
|
||||
* @param asyncModule Object with Async interface
|
||||
* @param callback Callback to run.
|
||||
* @returns Returns a debouncer object.
|
||||
*/
|
||||
static debounce(debouncer: Debouncer|null, asyncModule: AsyncInterface, callback: () => any): Debouncer;
|
||||
|
||||
/**
|
||||
* Sets the scheduler; that is, a module with the Async interface,
|
||||
* a callback and optional arguments to be passed to the run function
|
||||
* from the async module.
|
||||
*
|
||||
* @param asyncModule Object with Async interface.
|
||||
* @param callback Callback to run.
|
||||
*/
|
||||
setConfig(asyncModule: AsyncInterface, callback: () => any): void;
|
||||
|
||||
/**
|
||||
* Cancels an active debouncer and returns a reference to itself.
|
||||
*/
|
||||
cancel(): void;
|
||||
|
||||
/**
|
||||
* Cancels a debouncer's async callback.
|
||||
*/
|
||||
_cancelAsync(): void;
|
||||
|
||||
/**
|
||||
* Flushes an active debouncer and returns a reference to itself.
|
||||
*/
|
||||
flush(): void;
|
||||
|
||||
/**
|
||||
* Returns true if the debouncer is active.
|
||||
*
|
||||
* @returns True if active.
|
||||
*/
|
||||
isActive(): boolean;
|
||||
}
|
||||
|
||||
export {enqueueDebouncer};
|
||||
|
||||
|
||||
/**
|
||||
* Adds a `Debouncer` to a list of globally flushable tasks.
|
||||
*/
|
||||
declare function enqueueDebouncer(debouncer: Debouncer): void;
|
||||
|
||||
export {flushDebouncers};
|
||||
|
||||
|
||||
/**
|
||||
* Flushes any enqueued debouncers
|
||||
*
|
||||
* @returns Returns whether any debouncers were flushed
|
||||
*/
|
||||
declare function flushDebouncers(): boolean;
|
||||
|
||||
import {AsyncInterface} from '../../interfaces';
|
95
lib/utils/flattened-nodes-observer.d.ts
vendored
Normal file
95
lib/utils/flattened-nodes-observer.d.ts
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/flattened-nodes-observer.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {calculateSplices} from './array-splice.js';
|
||||
|
||||
import {microTask} from './async.js';
|
||||
|
||||
export {FlattenedNodesObserver};
|
||||
|
||||
/**
|
||||
* Class that listens for changes (additions or removals) to
|
||||
* "flattened nodes" on a given `node`. The list of flattened nodes consists
|
||||
* of a node's children and, for any children that are `<slot>` elements,
|
||||
* the expanded flattened list of `assignedNodes`.
|
||||
* For example, if the observed node has children `<a></a><slot></slot><b></b>`
|
||||
* and the `<slot>` has one `<div>` assigned to it, then the flattened
|
||||
* nodes list is `<a></a><div></div><b></b>`. If the `<slot>` has other
|
||||
* `<slot>` elements assigned to it, these are flattened as well.
|
||||
*
|
||||
* The provided `callback` is called whenever any change to this list
|
||||
* of flattened nodes occurs, where an addition or removal of a node is
|
||||
* considered a change. The `callback` is called with one argument, an object
|
||||
* containing an array of any `addedNodes` and `removedNodes`.
|
||||
*
|
||||
* Note: the callback is called asynchronous to any changes
|
||||
* at a microtask checkpoint. This is because observation is performed using
|
||||
* `MutationObserver` and the `<slot>` element's `slotchange` event which
|
||||
* are asynchronous.
|
||||
*
|
||||
* An example:
|
||||
* ```js
|
||||
* class TestSelfObserve extends PolymerElement {
|
||||
* static get is() { return 'test-self-observe';}
|
||||
* connectedCallback() {
|
||||
* super.connectedCallback();
|
||||
* this._observer = new FlattenedNodesObserver(this, (info) => {
|
||||
* this.info = info;
|
||||
* });
|
||||
* }
|
||||
* disconnectedCallback() {
|
||||
* super.disconnectedCallback();
|
||||
* this._observer.disconnect();
|
||||
* }
|
||||
* }
|
||||
* customElements.define(TestSelfObserve.is, TestSelfObserve);
|
||||
* ```
|
||||
*/
|
||||
declare class FlattenedNodesObserver {
|
||||
|
||||
/**
|
||||
* eslint-disable-next-line
|
||||
*/
|
||||
constructor(target: any, callback: any);
|
||||
|
||||
/**
|
||||
* eslint-disable-next-line
|
||||
*/
|
||||
static getFlattenedNodes(node: any): any;
|
||||
|
||||
/**
|
||||
* Activates an observer. This method is automatically called when
|
||||
* a `FlattenedNodesObserver` is created. It should only be called to
|
||||
* re-activate an observer that has been deactivated via the `disconnect` method.
|
||||
*/
|
||||
connect(): void;
|
||||
|
||||
/**
|
||||
* Deactivates the flattened nodes observer. After calling this method
|
||||
* the observer callback will not be called when changes to flattened nodes
|
||||
* occur. The `connect` method may be subsequently called to reactivate
|
||||
* the observer.
|
||||
*/
|
||||
disconnect(): void;
|
||||
|
||||
/**
|
||||
* Flushes the observer causing any pending changes to be immediately
|
||||
* delivered the observer callback. By default these changes are delivered
|
||||
* asynchronously at the next microtask checkpoint.
|
||||
*
|
||||
* @returns Returns true if any pending changes caused the observer
|
||||
* callback to run.
|
||||
*/
|
||||
flush(): boolean;
|
||||
}
|
26
lib/utils/flush.d.ts
vendored
Normal file
26
lib/utils/flush.d.ts
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/flush.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
import {enqueueDebouncer, flushDebouncers} from '../utils/debounce.js';
|
||||
|
||||
export {enqueueDebouncer};
|
||||
|
||||
export {flush};
|
||||
|
||||
|
||||
/**
|
||||
* Forces several classes of asynchronously queued tasks to flush:
|
||||
* - Debouncers added via `enqueueDebouncer`
|
||||
* - ShadyDOM distribution
|
||||
*/
|
||||
declare function flush(): void;
|
92
lib/utils/gestures.d.ts
vendored
Normal file
92
lib/utils/gestures.d.ts
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/gestures.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
import {timeOut, microTask} from './async.js';
|
||||
|
||||
import {Debouncer} from './debounce.js';
|
||||
|
||||
export {deepTargetFind};
|
||||
|
||||
|
||||
/**
|
||||
* Finds the element rendered on the screen at the provided coordinates.
|
||||
*
|
||||
* Similar to `document.elementFromPoint`, but pierces through
|
||||
* shadow roots.
|
||||
*
|
||||
* @returns Returns the deepest shadowRoot inclusive element
|
||||
* found at the screen position given.
|
||||
*/
|
||||
declare function deepTargetFind(x: number, y: number): Element|null;
|
||||
|
||||
export {addListener};
|
||||
|
||||
|
||||
/**
|
||||
* Adds an event listener to a node for the given gesture type.
|
||||
*
|
||||
* @returns Returns true if a gesture event listener was added.
|
||||
*/
|
||||
declare function addListener(node: EventTarget, evType: string, handler: (p0: Event) => void): boolean;
|
||||
|
||||
export {removeListener};
|
||||
|
||||
|
||||
/**
|
||||
* Removes an event listener from a node for the given gesture type.
|
||||
*
|
||||
* @returns Returns true if a gesture event listener was removed.
|
||||
*/
|
||||
declare function removeListener(node: EventTarget, evType: string, handler: (p0: Event) => void): boolean;
|
||||
|
||||
export {register};
|
||||
|
||||
|
||||
/**
|
||||
* Registers a new gesture event recognizer for adding new custom
|
||||
* gesture event types.
|
||||
*/
|
||||
declare function register(recog: GestureRecognizer): void;
|
||||
|
||||
export {setTouchAction};
|
||||
|
||||
|
||||
/**
|
||||
* Sets scrolling direction on node.
|
||||
*
|
||||
* This value is checked on first move, thus it should be called prior to
|
||||
* adding event listeners.
|
||||
*/
|
||||
declare function setTouchAction(node: EventTarget, value: string): void;
|
||||
|
||||
export {prevent};
|
||||
|
||||
|
||||
/**
|
||||
* Prevents the dispatch and default action of the given event name.
|
||||
*/
|
||||
declare function prevent(evName: string): void;
|
||||
|
||||
export {resetMouseCanceller};
|
||||
|
||||
|
||||
/**
|
||||
* Reset the 2500ms timeout on processing mouse input after detecting touch input.
|
||||
*
|
||||
* Touch inputs create synthesized mouse inputs anywhere from 0 to 2000ms after the touch.
|
||||
* This method should only be called during testing with simulated touch inputs.
|
||||
* Calling this method in production may cause duplicate taps or other Gestures.
|
||||
*/
|
||||
declare function resetMouseCanceller(): void;
|
||||
|
||||
import {GestureRecognizer} from '../../interfaces';
|
20
lib/utils/hide-template-controls.d.ts
vendored
Normal file
20
lib/utils/hide-template-controls.d.ts
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/hide-template-controls.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
export {hideElementsGlobally};
|
||||
|
||||
|
||||
/**
|
||||
* @returns True if elements will be hidden globally
|
||||
*/
|
||||
declare function hideElementsGlobally(): boolean;
|
92
lib/utils/html-tag.d.ts
vendored
Normal file
92
lib/utils/html-tag.d.ts
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/html-tag.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
/**
|
||||
* Class representing a static string value which can be used to filter
|
||||
* strings by asseting that they have been created via this class. The
|
||||
* `value` property returns the string passed to the constructor.
|
||||
*/
|
||||
declare class LiteralString {
|
||||
value: string;
|
||||
constructor(string: any);
|
||||
|
||||
/**
|
||||
* @returns LiteralString string value
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
export {html};
|
||||
|
||||
|
||||
/**
|
||||
* A template literal tag that creates an HTML <template> element from the
|
||||
* contents of the string.
|
||||
*
|
||||
* This allows you to write a Polymer Template in JavaScript.
|
||||
*
|
||||
* Templates can be composed by interpolating `HTMLTemplateElement`s in
|
||||
* expressions in the JavaScript template literal. The nested template's
|
||||
* `innerHTML` is included in the containing template. The only other
|
||||
* values allowed in expressions are those returned from `htmlLiteral`
|
||||
* which ensures only literal values from JS source ever reach the HTML, to
|
||||
* guard against XSS risks.
|
||||
*
|
||||
* All other values are disallowed in expressions to help prevent XSS
|
||||
* attacks; however, `htmlLiteral` can be used to compose static
|
||||
* string values into templates. This is useful to compose strings into
|
||||
* places that do not accept html, like the css text of a `style`
|
||||
* element.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* static get template() {
|
||||
* return html`
|
||||
* <style>:host{ content:"..." }</style>
|
||||
* <div class="shadowed">${this.partialTemplate}</div>
|
||||
* ${super.template}
|
||||
* `;
|
||||
* }
|
||||
* static get partialTemplate() { return html`<span>Partial!</span>`; }
|
||||
*
|
||||
* @returns Constructed HTMLTemplateElement
|
||||
*/
|
||||
declare function html(strings: TemplateStringsArray, ...values: any[]): HTMLTemplateElement;
|
||||
|
||||
export {htmlLiteral};
|
||||
|
||||
|
||||
/**
|
||||
* An html literal tag that can be used with `html` to compose.
|
||||
* a literal string.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* static get template() {
|
||||
* return html`
|
||||
* <style>
|
||||
* :host { display: block; }
|
||||
* ${this.styleTemplate()}
|
||||
* </style>
|
||||
* <div class="shadowed">${staticValue}</div>
|
||||
* ${super.template}
|
||||
* `;
|
||||
* }
|
||||
* static get styleTemplate() {
|
||||
* return htmlLiteral`.shadowed { background: gray; }`;
|
||||
* }
|
||||
*
|
||||
* @returns Constructed literal string
|
||||
*/
|
||||
declare function htmlLiteral(strings: TemplateStringsArray, ...values: any[]): LiteralString;
|
22
lib/utils/mixin.d.ts
vendored
Normal file
22
lib/utils/mixin.d.ts
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/mixin.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
export {dedupingMixin};
|
||||
|
||||
|
||||
/**
|
||||
* Wraps an ES6 class expression mixin such that the mixin is only applied
|
||||
* if it has not already been applied its base argument. Also memoizes mixin
|
||||
* applications.
|
||||
*/
|
||||
declare function dedupingMixin<T>(mixin: T): T;
|
170
lib/utils/path.d.ts
vendored
Normal file
170
lib/utils/path.d.ts
vendored
Normal file
|
@ -0,0 +1,170 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/path.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
export {isPath};
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the given string is a structured data path (has dots).
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```
|
||||
* isPath('foo.bar.baz') // true
|
||||
* isPath('foo') // false
|
||||
* ```
|
||||
*
|
||||
* @returns True if the string contained one or more dots
|
||||
*/
|
||||
declare function isPath(path: string): boolean;
|
||||
|
||||
export {root};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the root property name for the given path.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```
|
||||
* root('foo.bar.baz') // 'foo'
|
||||
* root('foo') // 'foo'
|
||||
* ```
|
||||
*
|
||||
* @returns Root property name
|
||||
*/
|
||||
declare function root(path: string): string;
|
||||
|
||||
export {isAncestor};
|
||||
|
||||
|
||||
/**
|
||||
* Given `base` is `foo.bar`, `foo` is an ancestor, `foo.bar` is not
|
||||
* Returns true if the given path is an ancestor of the base path.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```
|
||||
* isAncestor('foo.bar', 'foo') // true
|
||||
* isAncestor('foo.bar', 'foo.bar') // false
|
||||
* isAncestor('foo.bar', 'foo.bar.baz') // false
|
||||
* ```
|
||||
*
|
||||
* @returns True if `path` is an ancestor of `base`.
|
||||
*/
|
||||
declare function isAncestor(base: string, path: string): boolean;
|
||||
|
||||
export {isDescendant};
|
||||
|
||||
|
||||
/**
|
||||
* Given `base` is `foo.bar`, `foo.bar.baz` is an descendant
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```
|
||||
* isDescendant('foo.bar', 'foo.bar.baz') // true
|
||||
* isDescendant('foo.bar', 'foo.bar') // false
|
||||
* isDescendant('foo.bar', 'foo') // false
|
||||
* ```
|
||||
*
|
||||
* @returns True if `path` is a descendant of `base`.
|
||||
*/
|
||||
declare function isDescendant(base: string, path: string): boolean;
|
||||
|
||||
export {translate};
|
||||
|
||||
|
||||
/**
|
||||
* Replaces a previous base path with a new base path, preserving the
|
||||
* remainder of the path.
|
||||
*
|
||||
* User must ensure `path` has a prefix of `base`.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```
|
||||
* translate('foo.bar', 'zot', 'foo.bar.baz') // 'zot.baz'
|
||||
* ```
|
||||
*
|
||||
* @returns Translated string
|
||||
*/
|
||||
declare function translate(base: string, newBase: string, path: string): string;
|
||||
|
||||
export {matches};
|
||||
|
||||
|
||||
/**
|
||||
* @returns True if `path` is equal to `base`
|
||||
*/
|
||||
declare function matches(base: string, path: string): boolean;
|
||||
|
||||
export {normalize};
|
||||
|
||||
|
||||
/**
|
||||
* Converts array-based paths to flattened path. String-based paths
|
||||
* are returned as-is.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```
|
||||
* normalize(['foo.bar', 0, 'baz']) // 'foo.bar.0.baz'
|
||||
* normalize('foo.bar.0.baz') // 'foo.bar.0.baz'
|
||||
* ```
|
||||
*
|
||||
* @returns Flattened path
|
||||
*/
|
||||
declare function normalize(path: string|Array<string|number>): string;
|
||||
|
||||
export {split};
|
||||
|
||||
|
||||
/**
|
||||
* Splits a path into an array of property names. Accepts either arrays
|
||||
* of path parts or strings.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```
|
||||
* split(['foo.bar', 0, 'baz']) // ['foo', 'bar', '0', 'baz']
|
||||
* split('foo.bar.0.baz') // ['foo', 'bar', '0', 'baz']
|
||||
* ```
|
||||
*
|
||||
* @returns Array of path parts
|
||||
*/
|
||||
declare function split(path: string|Array<string|number>): string[];
|
||||
|
||||
export {get};
|
||||
|
||||
|
||||
/**
|
||||
* Reads a value from a path. If any sub-property in the path is `undefined`,
|
||||
* this method returns `undefined` (will never throw.
|
||||
*
|
||||
* @returns Value at path, or `undefined` if the path could not be
|
||||
* fully dereferenced.
|
||||
*/
|
||||
declare function get(root: object|null, path: string|Array<string|number>, info?: object|null): any;
|
||||
|
||||
export {set};
|
||||
|
||||
|
||||
/**
|
||||
* Sets a value to a path. If any sub-property in the path is `undefined`,
|
||||
* this method will no-op.
|
||||
*
|
||||
* @returns The normalized version of the input path
|
||||
*/
|
||||
declare function set(root: object|null, path: string|Array<string|number>, value: any): string|undefined;
|
51
lib/utils/render-status.d.ts
vendored
Normal file
51
lib/utils/render-status.d.ts
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/render-status.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
export {flush};
|
||||
|
||||
|
||||
/**
|
||||
* Flushes all `beforeNextRender` tasks, followed by all `afterNextRender`
|
||||
* tasks.
|
||||
*/
|
||||
declare function flush(): void;
|
||||
|
||||
export {beforeNextRender};
|
||||
|
||||
|
||||
/**
|
||||
* Enqueues a callback which will be run before the next render, at
|
||||
* `requestAnimationFrame` timing.
|
||||
*
|
||||
* This method is useful for enqueuing work that requires DOM measurement,
|
||||
* since measurement may not be reliable in custom element callbacks before
|
||||
* the first render, as well as for batching measurement tasks in general.
|
||||
*
|
||||
* Tasks in this queue may be flushed by calling `flush()`.
|
||||
*/
|
||||
declare function beforeNextRender(context: any, callback: (...p0: any[]) => void, args?: any[]): void;
|
||||
|
||||
export {afterNextRender};
|
||||
|
||||
|
||||
/**
|
||||
* Enqueues a callback which will be run after the next render, equivalent
|
||||
* to one task (`setTimeout`) after the next `requestAnimationFrame`.
|
||||
*
|
||||
* This method is useful for tuning the first-render performance of an
|
||||
* element or application by deferring non-critical work until after the
|
||||
* first paint. Typical non-render-critical work may include adding UI
|
||||
* event listeners and aria attributes.
|
||||
*/
|
||||
declare function afterNextRender(context: any, callback: (...p0: any[]) => void, args?: any[]): void;
|
48
lib/utils/resolve-url.d.ts
vendored
Normal file
48
lib/utils/resolve-url.d.ts
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/resolve-url.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
export {resolveUrl};
|
||||
|
||||
|
||||
/**
|
||||
* Resolves the given URL against the provided `baseUri'.
|
||||
*
|
||||
* Note that this function performs no resolution for URLs that start
|
||||
* with `/` (absolute URLs) or `#` (hash identifiers). For general purpose
|
||||
* URL resolution, use `window.URL`.
|
||||
*
|
||||
* @returns resolved URL
|
||||
*/
|
||||
declare function resolveUrl(url: string, baseURI?: string|null): string;
|
||||
|
||||
export {resolveCss};
|
||||
|
||||
|
||||
/**
|
||||
* Resolves any relative URL's in the given CSS text against the provided
|
||||
* `ownerDocument`'s `baseURI`.
|
||||
*
|
||||
* @returns Processed CSS text with resolved URL's
|
||||
*/
|
||||
declare function resolveCss(cssText: string, baseURI: string): string;
|
||||
|
||||
export {pathFromUrl};
|
||||
|
||||
|
||||
/**
|
||||
* Returns a path from a given `url`. The path includes the trailing
|
||||
* `/` from the url.
|
||||
*
|
||||
* @returns resolved path
|
||||
*/
|
||||
declare function pathFromUrl(url: string): string;
|
24
lib/utils/scope-subtree.d.ts
vendored
Normal file
24
lib/utils/scope-subtree.d.ts
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/scope-subtree.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
export {scopeSubtree};
|
||||
|
||||
|
||||
/**
|
||||
* Ensure that elements in a ShadowDOM container are scoped correctly.
|
||||
* This function is only needed when ShadyDOM is used and unpatched DOM APIs are used in third party code.
|
||||
* This can happen in noPatch mode or when specialized APIs like ranges or tables are used to mutate DOM.
|
||||
*
|
||||
* @returns Returns a new MutationObserver on `container` if `shouldObserve` is true.
|
||||
*/
|
||||
declare function scopeSubtree(container: Element, shouldObserve?: boolean): MutationObserver|null;
|
161
lib/utils/settings.d.ts
vendored
Normal file
161
lib/utils/settings.d.ts
vendored
Normal file
|
@ -0,0 +1,161 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/settings.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {pathFromUrl} from './resolve-url.js';
|
||||
|
||||
export {setRootPath};
|
||||
|
||||
|
||||
/**
|
||||
* Sets the global rootPath property used by `ElementMixin` and
|
||||
* available via `rootPath`.
|
||||
*/
|
||||
declare function setRootPath(path: string): void;
|
||||
|
||||
export {setSanitizeDOMValue};
|
||||
|
||||
|
||||
/**
|
||||
* Sets the global sanitizeDOMValue available via this module's exported
|
||||
* `sanitizeDOMValue` variable.
|
||||
*/
|
||||
declare function setSanitizeDOMValue(newSanitizeDOMValue: ((p0: any, p1: string, p2: string, p3: Node|null) => any)|undefined): void;
|
||||
|
||||
export {getSanitizeDOMValue};
|
||||
|
||||
|
||||
/**
|
||||
* Gets sanitizeDOMValue, for environments that don't well support `export let`.
|
||||
*
|
||||
* @returns sanitizeDOMValue
|
||||
*/
|
||||
declare function getSanitizeDOMValue(): ((p0: any, p1: string, p2: string, p3: Node|null) => any)|undefined;
|
||||
|
||||
export {setPassiveTouchGestures};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `passiveTouchGestures` globally for all elements using Polymer Gestures.
|
||||
*/
|
||||
declare function setPassiveTouchGestures(usePassive: boolean): void;
|
||||
|
||||
export {setStrictTemplatePolicy};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `strictTemplatePolicy` globally for all elements
|
||||
*/
|
||||
declare function setStrictTemplatePolicy(useStrictPolicy: boolean): void;
|
||||
|
||||
export {setAllowTemplateFromDomModule};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `lookupTemplateFromDomModule` globally for all elements
|
||||
*/
|
||||
declare function setAllowTemplateFromDomModule(allowDomModule: boolean): void;
|
||||
|
||||
export {setLegacyOptimizations};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `legacyOptimizations` globally for all elements to enable optimizations
|
||||
* when only legacy based elements are used.
|
||||
*/
|
||||
declare function setLegacyOptimizations(useLegacyOptimizations: boolean): void;
|
||||
|
||||
export {setLegacyWarnings};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `legacyWarnings` globally for all elements to migration warnings.
|
||||
*/
|
||||
declare function setLegacyWarnings(useLegacyWarnings: boolean): void;
|
||||
|
||||
export {setSyncInitialRender};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `syncInitialRender` globally for all elements to enable synchronous
|
||||
* initial rendering.
|
||||
*/
|
||||
declare function setSyncInitialRender(useSyncInitialRender: boolean): void;
|
||||
|
||||
export {setLegacyUndefined};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `legacyUndefined` globally for all elements to enable legacy
|
||||
* multi-property behavior for undefined values.
|
||||
*/
|
||||
declare function setLegacyUndefined(useLegacyUndefined: boolean): void;
|
||||
|
||||
export {setOrderedComputed};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `orderedComputed` globally for all elements to enable ordered computed
|
||||
* property computation.
|
||||
*/
|
||||
declare function setOrderedComputed(useOrderedComputed: boolean): void;
|
||||
|
||||
export {setCancelSyntheticClickEvents};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `setCancelSyntheticEvents` globally for all elements to cancel synthetic click events.
|
||||
*/
|
||||
declare function setCancelSyntheticClickEvents(useCancelSyntheticClickEvents: boolean): void;
|
||||
|
||||
export {setRemoveNestedTemplates};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `removeNestedTemplates` globally, to eliminate nested templates
|
||||
* inside `dom-if` and `dom-repeat` as part of template parsing.
|
||||
*/
|
||||
declare function setRemoveNestedTemplates(useRemoveNestedTemplates: boolean): void;
|
||||
|
||||
export {setFastDomIf};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `fastDomIf` globally, to put `dom-if` in a performance-optimized mode.
|
||||
*/
|
||||
declare function setFastDomIf(useFastDomIf: boolean): void;
|
||||
|
||||
export {setSuppressTemplateNotifications};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `suppressTemplateNotifications` globally, to disable `dom-change` and
|
||||
* `rendered-item-count` events from `dom-if` and `dom-repeat`.
|
||||
*/
|
||||
declare function setSuppressTemplateNotifications(suppress: boolean): void;
|
||||
|
||||
export {setLegacyNoObservedAttributes};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `legacyNoObservedAttributes` globally, to disable `observedAttributes`.
|
||||
*/
|
||||
declare function setLegacyNoObservedAttributes(noObservedAttributes: boolean): void;
|
||||
|
||||
export {setUseAdoptedStyleSheetsWithBuiltCSS};
|
||||
|
||||
|
||||
/**
|
||||
* Sets `useAdoptedStyleSheetsWithBuiltCSS` globally.
|
||||
*/
|
||||
declare function setUseAdoptedStyleSheetsWithBuiltCSS(value: boolean): void;
|
112
lib/utils/style-gather.d.ts
vendored
Normal file
112
lib/utils/style-gather.d.ts
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/style-gather.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
import {DomModule} from '../elements/dom-module.js';
|
||||
|
||||
import {resolveCss} from './resolve-url.js';
|
||||
|
||||
export {stylesFromModules};
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of <style> elements in a space-separated list of `dom-module`s.
|
||||
*
|
||||
* @returns Array of contained <style> elements
|
||||
*/
|
||||
declare function stylesFromModules(moduleIds: string): HTMLStyleElement[];
|
||||
|
||||
export {stylesFromModule};
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of <style> elements in a given `dom-module`.
|
||||
* Styles in a `dom-module` can come either from `<style>`s within the
|
||||
* first `<template>`, or else from one or more
|
||||
* `<link rel="import" type="css">` links outside the template.
|
||||
*
|
||||
* @returns Array of contained styles.
|
||||
*/
|
||||
declare function stylesFromModule(moduleId: string): HTMLStyleElement[];
|
||||
|
||||
export {stylesFromTemplate};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the `<style>` elements within a given template.
|
||||
*
|
||||
* @returns Array of styles
|
||||
*/
|
||||
declare function stylesFromTemplate(template: HTMLTemplateElement, baseURI?: string): HTMLStyleElement[];
|
||||
|
||||
export {stylesFromModuleImports};
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of <style> elements from stylesheets loaded via `<link rel="import" type="css">` links within the specified `dom-module`.
|
||||
*
|
||||
* @returns Array of contained styles.
|
||||
*/
|
||||
declare function stylesFromModuleImports(moduleId: string): HTMLStyleElement[];
|
||||
|
||||
export {cssFromModules};
|
||||
|
||||
|
||||
/**
|
||||
* Returns CSS text of styles in a space-separated list of `dom-module`s.
|
||||
* Note: This method is deprecated, use `stylesFromModules` instead.
|
||||
*
|
||||
* @returns Concatenated CSS content from specified `dom-module`s
|
||||
*/
|
||||
declare function cssFromModules(moduleIds: string): string;
|
||||
|
||||
export {cssFromModule};
|
||||
|
||||
|
||||
/**
|
||||
* Returns CSS text of styles in a given `dom-module`. CSS in a `dom-module`
|
||||
* can come either from `<style>`s within the first `<template>`, or else
|
||||
* from one or more `<link rel="import" type="css">` links outside the
|
||||
* template.
|
||||
*
|
||||
* Any `<styles>` processed are removed from their original location.
|
||||
* Note: This method is deprecated, use `styleFromModule` instead.
|
||||
*
|
||||
* @returns Concatenated CSS content from specified `dom-module`
|
||||
*/
|
||||
declare function cssFromModule(moduleId: string): string;
|
||||
|
||||
export {cssFromTemplate};
|
||||
|
||||
|
||||
/**
|
||||
* Returns CSS text of `<styles>` within a given template.
|
||||
*
|
||||
* Any `<styles>` processed are removed from their original location.
|
||||
* Note: This method is deprecated, use `styleFromTemplate` instead.
|
||||
*
|
||||
* @returns Concatenated CSS content from specified template
|
||||
*/
|
||||
declare function cssFromTemplate(template: HTMLTemplateElement, baseURI: string): string;
|
||||
|
||||
export {cssFromModuleImports};
|
||||
|
||||
|
||||
/**
|
||||
* Returns CSS text from stylesheets loaded via `<link rel="import" type="css">`
|
||||
* links within the specified `dom-module`.
|
||||
*
|
||||
* Note: This method is deprecated, use `stylesFromModuleImports` instead.
|
||||
*
|
||||
* @returns Concatenated CSS content from links in specified `dom-module`
|
||||
*/
|
||||
declare function cssFromModuleImports(moduleId: string): string;
|
34
lib/utils/telemetry.d.ts
vendored
Normal file
34
lib/utils/telemetry.d.ts
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/telemetry.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
export {incrementInstanceCount};
|
||||
|
||||
declare function incrementInstanceCount(): void;
|
||||
|
||||
export {register};
|
||||
|
||||
|
||||
/**
|
||||
* Registers a class prototype for telemetry purposes.
|
||||
*/
|
||||
declare function register(prototype: PolymerElementConstructor): void;
|
||||
|
||||
export {dumpRegistrations};
|
||||
|
||||
|
||||
/**
|
||||
* Logs all elements registered with an `is` to the console.
|
||||
*/
|
||||
declare function dumpRegistrations(): void;
|
||||
|
||||
import {PolymerElementConstructor} from '../../interfaces';
|
197
lib/utils/templatize.d.ts
vendored
Normal file
197
lib/utils/templatize.d.ts
vendored
Normal file
|
@ -0,0 +1,197 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/templatize.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
// tslint:disable:no-any describes the API as best we are able today
|
||||
|
||||
import {PropertyEffects} from '../mixins/property-effects.js';
|
||||
|
||||
import {MutableData} from '../mixins/mutable-data.js';
|
||||
|
||||
export {showHideChildren};
|
||||
|
||||
declare function showHideChildren(): void;
|
||||
|
||||
declare class TemplateInstanceBase extends
|
||||
PropertyEffects(
|
||||
HTMLElement) {
|
||||
root: StampedTemplate;
|
||||
children: any;
|
||||
|
||||
/**
|
||||
* Find the parent model of this template instance. The parent model
|
||||
* is either another templatize instance that had option `parentModel: true`,
|
||||
* or else the host element.
|
||||
*/
|
||||
readonly parentModel: PropertyEffects;
|
||||
_methodHost: PropertyEffects;
|
||||
|
||||
/**
|
||||
* Override point for adding custom or simulated event handling.
|
||||
*
|
||||
* @param node Node to add event listener to
|
||||
* @param eventName Name of event
|
||||
* @param handler Listener function to add
|
||||
*/
|
||||
_addEventListenerToNode(node: Node, eventName: string, handler: (p0: Event) => void): void;
|
||||
|
||||
/**
|
||||
* Overrides default property-effects implementation to intercept
|
||||
* textContent bindings while children are "hidden" and cache in
|
||||
* private storage for later retrieval.
|
||||
*
|
||||
* @param node The node to set a property on
|
||||
* @param prop The property to set
|
||||
* @param value The value to set
|
||||
*/
|
||||
_setUnmanagedPropertyToNode(node: Node, prop: string, value: any): void;
|
||||
|
||||
/**
|
||||
* Forwards a host property to this instance. This method should be
|
||||
* called on instances from the `options.forwardHostProp` callback
|
||||
* to propagate changes of host properties to each instance.
|
||||
*
|
||||
* Note this method enqueues the change, which are flushed as a batch.
|
||||
*
|
||||
* @param prop Property or path name
|
||||
* @param value Value of the property to forward
|
||||
*/
|
||||
forwardHostProp(prop: string, value: any): void;
|
||||
|
||||
/**
|
||||
* Shows or hides the template instance top level child elements. For
|
||||
* text nodes, `textContent` is removed while "hidden" and replaced when
|
||||
* "shown."
|
||||
*
|
||||
* @param hide Set to true to hide the children;
|
||||
* set to false to show them.
|
||||
*/
|
||||
_showHideChildren(hide: boolean): void;
|
||||
|
||||
/**
|
||||
* Stub of HTMLElement's `dispatchEvent`, so that effects that may
|
||||
* dispatch events safely no-op.
|
||||
*
|
||||
* @param event Event to dispatch
|
||||
* @returns Always true.
|
||||
*/
|
||||
dispatchEvent(event: Event|null): boolean;
|
||||
}
|
||||
|
||||
declare class templatizerBase extends TemplateInstanceBase {
|
||||
}
|
||||
|
||||
export {templatize};
|
||||
|
||||
|
||||
/**
|
||||
* Returns an anonymous `PropertyEffects` class bound to the
|
||||
* `<template>` provided. Instancing the class will result in the
|
||||
* template being stamped into a document fragment stored as the instance's
|
||||
* `root` property, after which it can be appended to the DOM.
|
||||
*
|
||||
* Templates may utilize all Polymer data-binding features as well as
|
||||
* declarative event listeners. Event listeners and inline computing
|
||||
* functions in the template will be called on the host of the template.
|
||||
*
|
||||
* The constructor returned takes a single argument dictionary of initial
|
||||
* property values to propagate into template bindings. Additionally
|
||||
* host properties can be forwarded in, and instance properties can be
|
||||
* notified out by providing optional callbacks in the `options` dictionary.
|
||||
*
|
||||
* Valid configuration in `options` are as follows:
|
||||
*
|
||||
* - `forwardHostProp(property, value)`: Called when a property referenced
|
||||
* in the template changed on the template's host. As this library does
|
||||
* not retain references to templates instanced by the user, it is the
|
||||
* templatize owner's responsibility to forward host property changes into
|
||||
* user-stamped instances. The `instance.forwardHostProp(property, value)`
|
||||
* method on the generated class should be called to forward host
|
||||
* properties into the template to prevent unnecessary property-changed
|
||||
* notifications. Any properties referenced in the template that are not
|
||||
* defined in `instanceProps` will be notified up to the template's host
|
||||
* automatically.
|
||||
* - `instanceProps`: Dictionary of property names that will be added
|
||||
* to the instance by the templatize owner. These properties shadow any
|
||||
* host properties, and changes within the template to these properties
|
||||
* will result in `notifyInstanceProp` being called.
|
||||
* - `mutableData`: When `true`, the generated class will skip strict
|
||||
* dirty-checking for objects and arrays (always consider them to be
|
||||
* "dirty").
|
||||
* - `notifyInstanceProp(instance, property, value)`: Called when
|
||||
* an instance property changes. Users may choose to call `notifyPath`
|
||||
* on e.g. the owner to notify the change.
|
||||
* - `parentModel`: When `true`, events handled by declarative event listeners
|
||||
* (`on-event="handler"`) will be decorated with a `model` property pointing
|
||||
* to the template instance that stamped it. It will also be returned
|
||||
* from `instance.parentModel` in cases where template instance nesting
|
||||
* causes an inner model to shadow an outer model.
|
||||
*
|
||||
* All callbacks are called bound to the `owner`. Any context
|
||||
* needed for the callbacks (such as references to `instances` stamped)
|
||||
* should be stored on the `owner` such that they can be retrieved via
|
||||
* `this`.
|
||||
*
|
||||
* When `options.forwardHostProp` is declared as an option, any properties
|
||||
* referenced in the template will be automatically forwarded from the host of
|
||||
* the `<template>` to instances, with the exception of any properties listed in
|
||||
* the `options.instanceProps` object. `instanceProps` are assumed to be
|
||||
* managed by the owner of the instances, either passed into the constructor
|
||||
* or set after the fact. Note, any properties passed into the constructor will
|
||||
* always be set to the instance (regardless of whether they would normally
|
||||
* be forwarded from the host).
|
||||
*
|
||||
* Note that `templatize()` can be run only once for a given `<template>`.
|
||||
* Further calls will result in an error. Also, there is a special
|
||||
* behavior if the template was duplicated through a mechanism such as
|
||||
* `<dom-repeat>` or `<test-fixture>`. In this case, all calls to
|
||||
* `templatize()` return the same class for all duplicates of a template.
|
||||
* The class returned from `templatize()` is generated only once using
|
||||
* the `options` from the first call. This means that any `options`
|
||||
* provided to subsequent calls will be ignored. Therefore, it is very
|
||||
* important not to close over any variables inside the callbacks. Also,
|
||||
* arrow functions must be avoided because they bind the outer `this`.
|
||||
* Inside the callbacks, any contextual information can be accessed
|
||||
* through `this`, which points to the `owner`.
|
||||
*
|
||||
* @returns Generated class bound
|
||||
* to the template provided
|
||||
*/
|
||||
declare function templatize(template: HTMLTemplateElement, owner?: PropertyEffects|null, options?: object|null): {new(p0?: object|null): TemplateInstanceBase};
|
||||
|
||||
declare class baseClass extends TemplateInstanceBase {
|
||||
}
|
||||
|
||||
export {modelForElement};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the template "model" associated with a given element, which
|
||||
* serves as the binding scope for the template instance the element is
|
||||
* contained in. A template model is an instance of
|
||||
* `TemplateInstanceBase`, and should be used to manipulate data
|
||||
* associated with this template instance.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* let model = modelForElement(el);
|
||||
* if (model.index < 10) {
|
||||
* model.set('item.checked', true);
|
||||
* }
|
||||
*
|
||||
* @returns Template instance representing the
|
||||
* binding scope for the element
|
||||
*/
|
||||
declare function modelForElement(template: HTMLElement|null, node?: Node|null): TemplateInstanceBase|null;
|
||||
|
||||
export {TemplateInstanceBase};
|
||||
|
||||
import {StampedTemplate} from '../../interfaces';
|
15
lib/utils/unresolved.d.ts
vendored
Normal file
15
lib/utils/unresolved.d.ts
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/unresolved.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
|
||||
export {};
|
15
lib/utils/wrap.d.ts
vendored
Normal file
15
lib/utils/wrap.d.ts
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* lib/utils/wrap.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
|
||||
export {};
|
28
polymer-element.d.ts
vendored
Normal file
28
polymer-element.d.ts
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* polymer-element.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
import {ElementMixin} from './lib/mixins/element-mixin.js';
|
||||
|
||||
export {html} from './lib/utils/html-tag.js';
|
||||
|
||||
export {PolymerElement};
|
||||
|
||||
/**
|
||||
* Base class that provides the core API for Polymer's meta-programming
|
||||
* features including template stamping, data-binding, attribute deserialization,
|
||||
* and property change observation.
|
||||
*/
|
||||
declare class PolymerElement extends
|
||||
ElementMixin(
|
||||
HTMLElement) {
|
||||
}
|
18
polymer-legacy.d.ts
vendored
Normal file
18
polymer-legacy.d.ts
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* DO NOT EDIT
|
||||
*
|
||||
* This file was automatically generated by
|
||||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
||||
*
|
||||
* To modify these typings, edit the source file(s):
|
||||
* polymer-legacy.js
|
||||
*/
|
||||
|
||||
|
||||
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
||||
|
||||
import {LegacyElementMixin} from './lib/legacy/legacy-element-mixin.js';
|
||||
|
||||
export {Polymer} from './lib/legacy/polymer-fn.js';
|
||||
|
||||
export {html} from './lib/utils/html-tag.js';
|
Loading…
Reference in New Issue
Block a user