1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export interface PolymerElementPropertiesMeta {
|
10 | type?: Function;
|
11 | value?: any;
|
12 | readOnly?: boolean;
|
13 | computed?: string;
|
14 | reflectToAttribute?: boolean;
|
15 | notify?: boolean;
|
16 | observer?: string|((val: any, old: any) => void);
|
17 | }
|
18 |
|
19 | export type PolymerElementProperties = {
|
20 | [key: string]: PolymerElementPropertiesMeta|Function;
|
21 | };
|
22 |
|
23 | // TODO Document these properties.
|
24 | export interface PolymerInit {
|
25 | is: string;
|
26 | extends?: string;
|
27 | properties?: PolymerElementProperties;
|
28 | observers?: string[];
|
29 | _template?: HTMLTemplateElement|(() => HTMLTemplateElement);
|
30 | hostAttributes?: {[key: string]: any};
|
31 | listeners?: {[key: string]: string};
|
32 | behaviors?: BehaviorInit | BehaviorInit[];
|
33 |
|
34 | // Lifecycle methods
|
35 | registered?(): void;
|
36 | created?(): void;
|
37 | attached?(): void;
|
38 | detached?(): void;
|
39 | ready?(): void;
|
40 | attributeChanged?(name: string, old?: string, value?: string): void;
|
41 |
|
42 | // Allow any other user-defined properties
|
43 | [others: string]: any;
|
44 | }
|
45 |
|
46 | export type BehaviorInit = Pick<
|
47 | PolymerInit,
|
48 | Exclude<keyof PolymerInit, "is" | "extends" | "_template">
|
49 | >;
|
50 |
|
51 | /**
|
52 | * The object passed to ".*" wildcard obsevers. A record of a change made to an
|
53 | * object.
|
54 | * @template B The object matching the non-wildcard portion of the path.
|
55 | * @template V Additional types that could be set at the path.
|
56 | */
|
57 | export interface PolymerDeepPropertyChange<B, V> {
|
58 | /** Path to the property that changed. */
|
59 | path: string;
|
60 | /** The object matching the non-wildcard portion of the path. */
|
61 | base: B;
|
62 | /** New value of the path that changed. */
|
63 | value: B|V;
|
64 | }
|
65 |
|
66 | /**
|
67 | * A record of changes made to an array.
|
68 | * @template T The type of the array being observed.
|
69 | */
|
70 | export interface PolymerSplice<T extends Array<{}|null|undefined>> {
|
71 | /** Position where the splice started. */
|
72 | index: number;
|
73 | /** Array of removed items. */
|
74 | removed: T;
|
75 | /** Number of new items inserted at index. */
|
76 | addedCount: number;
|
77 | /** A reference to the array in question. */
|
78 | object: T;
|
79 | /** The string literal 'splice'. */
|
80 | type: 'splice';
|
81 | }
|
82 |
|
83 | /**
|
84 | * The object passed to ".splices" observers. A set of mutations made to the
|
85 | * array.
|
86 | * @template T The type of the array being observed.
|
87 | */
|
88 | export interface PolymerSpliceChange<T extends Array<{}|null|undefined>> {
|
89 | indexSplices: Array<PolymerSplice<T>>;
|
90 | }
|
91 |
|
92 | // Types from "externs/polymer-internal-shared-types.js"
|
93 |
|
94 | export interface StampedTemplate extends DocumentFragment {
|
95 | __noInsertionPoint: boolean;
|
96 | nodeList: Node[];
|
97 | $: {[key: string]: Node};
|
98 | templateInfo?: TemplateInfo;
|
99 | }
|
100 |
|
101 | export interface NodeInfo {
|
102 | id: string;
|
103 | events: {name: string, value: string}[];
|
104 | hasInsertionPoint: boolean;
|
105 | templateInfo: TemplateInfo;
|
106 | parentInfo: NodeInfo;
|
107 | parentIndex: number;
|
108 | infoIndex: number;
|
109 | bindings: Binding[];
|
110 | }
|
111 |
|
112 | export interface TemplateInfo {
|
113 | nodeInfoList: NodeInfo[];
|
114 | nodeList: Node[];
|
115 | stripWhitespace: boolean;
|
116 | hasInsertionPoint?: boolean;
|
117 | hostProps: Object;
|
118 | propertyEffects: Object;
|
119 | childNodes: Node[];
|
120 | wasPreBound: boolean;
|
121 | }
|
122 |
|
123 | export interface LiteralBindingPart {
|
124 | literal: string;
|
125 | compoundIndex?: number;
|
126 | }
|
127 |
|
128 | export interface MethodArg {
|
129 | literal: boolean;
|
130 | name: string;
|
131 | value: string|number;
|
132 | rootProperty?: string;
|
133 | structured?: boolean;
|
134 | wildcard?: boolean;
|
135 | }
|
136 |
|
137 | export interface MethodSignature {
|
138 | methodName: string;
|
139 | static: boolean;
|
140 | args: MethodArg[];
|
141 | dynamicFn?: boolean;
|
142 | }
|
143 |
|
144 | export interface ExpressionBindingPart {
|
145 | mode: string;
|
146 | negate: boolean;
|
147 | source: string;
|
148 | dependencies: Array<MethodArg|string>;
|
149 | customEvent: boolean;
|
150 | signature: Object|null;
|
151 | event: string;
|
152 | }
|
153 |
|
154 | export type BindingPart = LiteralBindingPart|ExpressionBindingPart;
|
155 |
|
156 | export interface Binding {
|
157 | kind: string;
|
158 | target: string;
|
159 | parts: BindingPart[];
|
160 | literal?: string;
|
161 | isCompound: boolean;
|
162 | listenerEvent?: string;
|
163 | listenerNegate?: boolean;
|
164 | }
|
165 |
|
166 | export interface AsyncInterface {
|
167 | run: (fn: Function, delay?: number) => number;
|
168 | cancel: (handle: number) => void;
|
169 | }
|
170 |
|
171 |
|
172 |
|
173 | export interface GestureRecognizer {
|
174 | reset: () => void;
|
175 | mousedown?: (e: MouseEvent) => void;
|
176 | mousemove?: (e: MouseEvent) => void;
|
177 | mouseup?: (e: MouseEvent) => void;
|
178 | touchstart?: (e: TouchEvent) => void;
|
179 | touchmove?: (e: TouchEvent) => void;
|
180 | touchend?: (e: TouchEvent) => void;
|
181 | click?: (e: MouseEvent) => void;
|
182 | }
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 | export interface IdleDeadline {
|
189 | didTimeout: boolean;
|
190 | timeRemaining(): number;
|
191 | }
|
192 |
|
193 | export interface PolymerElementConstructor {
|
194 | new (): HTMLElement;
|
195 | is?: string;
|
196 | extends?: string;
|
197 | properties?: PolymerElementProperties;
|
198 | observers?: string[];
|
199 | template?: string|HTMLTemplateElement|null;
|
200 | }
|