@neovici/cosmoz-utils 4.0.0-beta.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array.d.ts +1 -0
- package/dist/array.js +24 -0
- package/dist/date.d.ts +39 -0
- package/dist/date.js +147 -0
- package/dist/directives/lazy-until.d.ts +46 -0
- package/dist/directives/lazy-until.js +143 -0
- package/dist/directives/measure.d.ts +9 -0
- package/dist/directives/measure.js +23 -0
- package/dist/directives/portal.d.ts +12 -0
- package/dist/directives/portal.js +51 -0
- package/dist/directives/spread-props.d.ts +8 -0
- package/dist/directives/spread-props.js +21 -0
- package/dist/elements/cz-icon.d.ts +8 -0
- package/dist/elements/cz-icon.js +15 -0
- package/dist/elements/cz-spinner.d.ts +1 -0
- package/dist/elements/cz-spinner.js +22 -0
- package/dist/elements/index.d.ts +2 -0
- package/dist/elements/index.js +2 -0
- package/dist/function.d.ts +5 -0
- package/dist/function.js +4 -0
- package/dist/haunted-polymer.d.ts +341 -0
- package/dist/haunted-polymer.js +83 -0
- package/dist/hooks/use-debounce-raf.d.ts +16 -0
- package/dist/hooks/use-debounce-raf.js +36 -0
- package/dist/hooks/use-dropped-files.d.ts +1 -0
- package/dist/hooks/use-dropped-files.js +7 -0
- package/dist/hooks/use-handle-drop.d.ts +1 -0
- package/dist/hooks/use-handle-drop.js +18 -0
- package/dist/hooks/use-host-bounds.d.ts +2 -0
- package/dist/hooks/use-host-bounds.js +12 -0
- package/dist/hooks/use-host.d.ts +3 -0
- package/dist/hooks/use-host.js +6 -0
- package/dist/hooks/use-imperative-api.d.ts +1 -0
- package/dist/hooks/use-imperative-api.js +17 -0
- package/dist/hooks/use-meta.d.ts +8 -0
- package/{lib → dist}/hooks/use-meta.js +3 -5
- package/dist/hooks/use-notify-property.d.ts +2 -0
- package/dist/hooks/use-notify-property.js +17 -0
- package/dist/hooks/use-promise.d.ts +1 -0
- package/dist/hooks/use-promise.js +42 -0
- package/dist/index.d.ts +26 -0
- package/{index.js → dist/index.js} +14 -24
- package/dist/money.d.ts +47 -0
- package/dist/money.js +86 -0
- package/dist/object.d.ts +21 -0
- package/dist/object.js +56 -0
- package/dist/promise.d.ts +10 -0
- package/dist/promise.js +66 -0
- package/dist/reduce/action.d.ts +8 -0
- package/dist/reduce/action.js +10 -0
- package/dist/reduce/index.d.ts +2 -0
- package/{lib → dist}/reduce/index.js +0 -0
- package/dist/reduce/reduce.d.ts +1 -0
- package/dist/reduce/reduce.js +12 -0
- package/dist/tag.d.ts +23 -0
- package/dist/tag.js +28 -0
- package/dist/tagged.d.ts +1 -0
- package/{lib → dist}/tagged.js +0 -0
- package/dist/template.d.ts +47 -0
- package/dist/template.js +66 -0
- package/package.json +20 -6
- package/lib/array.js +0 -27
- package/lib/date.js +0 -176
- package/lib/directives/lazy-until.js +0 -163
- package/lib/directives/measure.js +0 -32
- package/lib/directives/portal.js +0 -65
- package/lib/function.js +0 -21
- package/lib/haunted-polymer.js +0 -93
- package/lib/hooks/use-debounce-raf.js +0 -49
- package/lib/hooks/use-dropped-files.js +0 -12
- package/lib/hooks/use-handle-drop.js +0 -22
- package/lib/hooks/use-host-bounds.js +0 -21
- package/lib/hooks/use-host.js +0 -9
- package/lib/hooks/use-imperative-api.js +0 -22
- package/lib/hooks/use-notify-property.js +0 -26
- package/lib/hooks/use-promise.js +0 -74
- package/lib/money.js +0 -105
- package/lib/object.js +0 -26
- package/lib/promise.js +0 -88
- package/lib/reduce/action.js +0 -16
- package/lib/reduce/reduce.js +0 -16
- package/lib/tag.js +0 -34
- package/lib/template.js +0 -89
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { BaseScheduler, GenericRenderer, ComponentOrVirtualComponent } from 'haunted';
|
|
2
|
+
import { ChildPart } from 'lit-html';
|
|
3
|
+
declare class Scheduler<P extends object, T extends HTMLElement | ChildPart, R extends GenericRenderer<T, P>, H extends ComponentOrVirtualComponent<T, P>, C extends (result: unknown) => void> extends BaseScheduler<P, T, R, H> {
|
|
4
|
+
_commit: C;
|
|
5
|
+
constructor(renderer: R, host: H, commitCallback: C);
|
|
6
|
+
commit(result: unknown): void;
|
|
7
|
+
}
|
|
8
|
+
interface PElement extends HTMLElement {
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
disconnectedCallback(): void;
|
|
11
|
+
set<T>(path: string, value: T): void;
|
|
12
|
+
setProperties<T>(props: T): void;
|
|
13
|
+
_propertiesChanged<P, C, O>(currentProps: P, changedProps: C, oldProps: O): void;
|
|
14
|
+
_hauntedUpdateFrameHandle: ReturnType<typeof requestAnimationFrame>;
|
|
15
|
+
_onlyHauntedPropertiesChanged<T>(changedProps: T): boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare type Constructor<T> = new (...args: any[]) => T;
|
|
18
|
+
declare type Hook = <T>(a: T) => void;
|
|
19
|
+
declare type Obj = Record<string, any>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a mixin that mixes a haunted hook with a polymer component.
|
|
22
|
+
*
|
|
23
|
+
* @param {String} outputPath The property where the result of the hook will be stored (deprecated)
|
|
24
|
+
* @param {Function} hook A haunted hook
|
|
25
|
+
* @returns {Function} The mixin
|
|
26
|
+
*/
|
|
27
|
+
export declare const hauntedPolymer: (outputPath: string | Hook, hook?: Hook) => (base: Constructor<PElement>) => {
|
|
28
|
+
new (): {
|
|
29
|
+
_scheduler: Scheduler<object, HTMLElement | ChildPart, () => void, any, (result: unknown) => void>;
|
|
30
|
+
connectedCallback(): void;
|
|
31
|
+
disconnectedCallback(): void;
|
|
32
|
+
_propertiesChanged<P extends Obj, C extends Obj, O>(currentProps: P, changedProps: C, oldProps: O): void;
|
|
33
|
+
_onlyHauntedPropertiesChanged<C_1 extends Obj>(changedProps: C_1): boolean;
|
|
34
|
+
renderLitTo(part: ChildPart | (() => ChildPart), outlet: HTMLElement): void;
|
|
35
|
+
set<T>(path: string, value: T): void;
|
|
36
|
+
setProperties<T_1>(props: T_1): void;
|
|
37
|
+
_hauntedUpdateFrameHandle: ReturnType<typeof requestAnimationFrame>;
|
|
38
|
+
accessKey: string;
|
|
39
|
+
readonly accessKeyLabel: string;
|
|
40
|
+
autocapitalize: string;
|
|
41
|
+
dir: string;
|
|
42
|
+
draggable: boolean;
|
|
43
|
+
hidden: boolean;
|
|
44
|
+
innerText: string;
|
|
45
|
+
lang: string;
|
|
46
|
+
readonly offsetHeight: number;
|
|
47
|
+
readonly offsetLeft: number;
|
|
48
|
+
readonly offsetParent: Element | null;
|
|
49
|
+
readonly offsetTop: number;
|
|
50
|
+
readonly offsetWidth: number;
|
|
51
|
+
outerText: string;
|
|
52
|
+
spellcheck: boolean;
|
|
53
|
+
title: string;
|
|
54
|
+
translate: boolean;
|
|
55
|
+
attachInternals(): ElementInternals;
|
|
56
|
+
click(): void;
|
|
57
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
58
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
59
|
+
removeEventListener<K_1 extends keyof HTMLElementEventMap>(type: K_1, listener: (this: HTMLElement, ev: HTMLElementEventMap[K_1]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
60
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
61
|
+
readonly attributes: NamedNodeMap;
|
|
62
|
+
readonly classList: DOMTokenList;
|
|
63
|
+
className: string;
|
|
64
|
+
readonly clientHeight: number;
|
|
65
|
+
readonly clientLeft: number;
|
|
66
|
+
readonly clientTop: number;
|
|
67
|
+
readonly clientWidth: number;
|
|
68
|
+
id: string;
|
|
69
|
+
readonly localName: string;
|
|
70
|
+
readonly namespaceURI: string | null;
|
|
71
|
+
onfullscreenchange: ((this: Element, ev: Event) => any) | null;
|
|
72
|
+
onfullscreenerror: ((this: Element, ev: Event) => any) | null;
|
|
73
|
+
outerHTML: string;
|
|
74
|
+
readonly ownerDocument: Document;
|
|
75
|
+
readonly part: DOMTokenList;
|
|
76
|
+
readonly prefix: string | null;
|
|
77
|
+
readonly scrollHeight: number;
|
|
78
|
+
scrollLeft: number;
|
|
79
|
+
scrollTop: number;
|
|
80
|
+
readonly scrollWidth: number;
|
|
81
|
+
readonly shadowRoot: ShadowRoot | null;
|
|
82
|
+
slot: string;
|
|
83
|
+
readonly tagName: string;
|
|
84
|
+
attachShadow(init: ShadowRootInit): ShadowRoot;
|
|
85
|
+
closest<K_2 extends keyof HTMLElementTagNameMap>(selector: K_2): HTMLElementTagNameMap[K_2] | null;
|
|
86
|
+
closest<K_3 extends keyof SVGElementTagNameMap>(selector: K_3): SVGElementTagNameMap[K_3] | null;
|
|
87
|
+
closest<E extends Element = Element>(selectors: string): E | null;
|
|
88
|
+
getAttribute(qualifiedName: string): string | null;
|
|
89
|
+
getAttributeNS(namespace: string | null, localName: string): string | null;
|
|
90
|
+
getAttributeNames(): string[];
|
|
91
|
+
getAttributeNode(qualifiedName: string): Attr | null;
|
|
92
|
+
getAttributeNodeNS(namespace: string | null, localName: string): Attr | null;
|
|
93
|
+
getBoundingClientRect(): DOMRect;
|
|
94
|
+
getClientRects(): DOMRectList;
|
|
95
|
+
getElementsByClassName(classNames: string): HTMLCollectionOf<Element>;
|
|
96
|
+
getElementsByTagName<K_4 extends keyof HTMLElementTagNameMap>(qualifiedName: K_4): HTMLCollectionOf<HTMLElementTagNameMap[K_4]>;
|
|
97
|
+
getElementsByTagName<K_5 extends keyof SVGElementTagNameMap>(qualifiedName: K_5): HTMLCollectionOf<SVGElementTagNameMap[K_5]>;
|
|
98
|
+
getElementsByTagName(qualifiedName: string): HTMLCollectionOf<Element>;
|
|
99
|
+
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf<HTMLElement>;
|
|
100
|
+
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>;
|
|
101
|
+
getElementsByTagNameNS(namespace: string | null, localName: string): HTMLCollectionOf<Element>;
|
|
102
|
+
hasAttribute(qualifiedName: string): boolean;
|
|
103
|
+
hasAttributeNS(namespace: string | null, localName: string): boolean;
|
|
104
|
+
hasAttributes(): boolean;
|
|
105
|
+
hasPointerCapture(pointerId: number): boolean;
|
|
106
|
+
insertAdjacentElement(where: InsertPosition, element: Element): Element | null;
|
|
107
|
+
insertAdjacentHTML(position: InsertPosition, text: string): void;
|
|
108
|
+
insertAdjacentText(where: InsertPosition, data: string): void;
|
|
109
|
+
matches(selectors: string): boolean;
|
|
110
|
+
releasePointerCapture(pointerId: number): void;
|
|
111
|
+
removeAttribute(qualifiedName: string): void;
|
|
112
|
+
removeAttributeNS(namespace: string | null, localName: string): void;
|
|
113
|
+
removeAttributeNode(attr: Attr): Attr;
|
|
114
|
+
requestFullscreen(options?: FullscreenOptions | undefined): Promise<void>;
|
|
115
|
+
requestPointerLock(): void;
|
|
116
|
+
scroll(options?: ScrollToOptions | undefined): void;
|
|
117
|
+
scroll(x: number, y: number): void;
|
|
118
|
+
scrollBy(options?: ScrollToOptions | undefined): void;
|
|
119
|
+
scrollBy(x: number, y: number): void;
|
|
120
|
+
scrollIntoView(arg?: boolean | ScrollIntoViewOptions | undefined): void;
|
|
121
|
+
scrollTo(options?: ScrollToOptions | undefined): void;
|
|
122
|
+
scrollTo(x: number, y: number): void;
|
|
123
|
+
setAttribute(qualifiedName: string, value: string): void;
|
|
124
|
+
setAttributeNS(namespace: string | null, qualifiedName: string, value: string): void;
|
|
125
|
+
setAttributeNode(attr: Attr): Attr | null;
|
|
126
|
+
setAttributeNodeNS(attr: Attr): Attr | null;
|
|
127
|
+
setPointerCapture(pointerId: number): void;
|
|
128
|
+
toggleAttribute(qualifiedName: string, force?: boolean | undefined): boolean;
|
|
129
|
+
webkitMatchesSelector(selectors: string): boolean;
|
|
130
|
+
readonly baseURI: string;
|
|
131
|
+
readonly childNodes: NodeListOf<ChildNode>;
|
|
132
|
+
readonly firstChild: ChildNode | null;
|
|
133
|
+
readonly isConnected: boolean;
|
|
134
|
+
readonly lastChild: ChildNode | null;
|
|
135
|
+
readonly nextSibling: ChildNode | null;
|
|
136
|
+
readonly nodeName: string;
|
|
137
|
+
readonly nodeType: number;
|
|
138
|
+
nodeValue: string | null;
|
|
139
|
+
readonly parentElement: HTMLElement | null;
|
|
140
|
+
readonly parentNode: ParentNode | null;
|
|
141
|
+
readonly previousSibling: ChildNode | null;
|
|
142
|
+
textContent: string | null;
|
|
143
|
+
appendChild<T_2 extends Node>(node: T_2): T_2;
|
|
144
|
+
cloneNode(deep?: boolean | undefined): Node;
|
|
145
|
+
compareDocumentPosition(other: Node): number;
|
|
146
|
+
contains(other: Node | null): boolean;
|
|
147
|
+
getRootNode(options?: GetRootNodeOptions | undefined): Node;
|
|
148
|
+
hasChildNodes(): boolean;
|
|
149
|
+
insertBefore<T_3 extends Node>(node: T_3, child: Node | null): T_3;
|
|
150
|
+
isDefaultNamespace(namespace: string | null): boolean;
|
|
151
|
+
isEqualNode(otherNode: Node | null): boolean;
|
|
152
|
+
isSameNode(otherNode: Node | null): boolean;
|
|
153
|
+
lookupNamespaceURI(prefix: string | null): string | null;
|
|
154
|
+
lookupPrefix(namespace: string | null): string | null;
|
|
155
|
+
normalize(): void;
|
|
156
|
+
removeChild<T_4 extends Node>(child: T_4): T_4;
|
|
157
|
+
replaceChild<T_5 extends Node>(node: Node, child: T_5): T_5;
|
|
158
|
+
readonly ATTRIBUTE_NODE: number;
|
|
159
|
+
readonly CDATA_SECTION_NODE: number;
|
|
160
|
+
readonly COMMENT_NODE: number;
|
|
161
|
+
readonly DOCUMENT_FRAGMENT_NODE: number;
|
|
162
|
+
readonly DOCUMENT_NODE: number;
|
|
163
|
+
readonly DOCUMENT_POSITION_CONTAINED_BY: number;
|
|
164
|
+
readonly DOCUMENT_POSITION_CONTAINS: number;
|
|
165
|
+
readonly DOCUMENT_POSITION_DISCONNECTED: number;
|
|
166
|
+
readonly DOCUMENT_POSITION_FOLLOWING: number;
|
|
167
|
+
readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number;
|
|
168
|
+
readonly DOCUMENT_POSITION_PRECEDING: number;
|
|
169
|
+
readonly DOCUMENT_TYPE_NODE: number;
|
|
170
|
+
readonly ELEMENT_NODE: number;
|
|
171
|
+
readonly ENTITY_NODE: number;
|
|
172
|
+
readonly ENTITY_REFERENCE_NODE: number;
|
|
173
|
+
readonly NOTATION_NODE: number;
|
|
174
|
+
readonly PROCESSING_INSTRUCTION_NODE: number;
|
|
175
|
+
readonly TEXT_NODE: number;
|
|
176
|
+
dispatchEvent(event: Event): boolean;
|
|
177
|
+
ariaAtomic: string | null;
|
|
178
|
+
ariaAutoComplete: string | null;
|
|
179
|
+
ariaBusy: string | null;
|
|
180
|
+
ariaChecked: string | null;
|
|
181
|
+
ariaColCount: string | null;
|
|
182
|
+
ariaColIndex: string | null;
|
|
183
|
+
ariaColSpan: string | null;
|
|
184
|
+
ariaCurrent: string | null;
|
|
185
|
+
ariaDisabled: string | null;
|
|
186
|
+
ariaExpanded: string | null;
|
|
187
|
+
ariaHasPopup: string | null;
|
|
188
|
+
ariaHidden: string | null;
|
|
189
|
+
ariaKeyShortcuts: string | null;
|
|
190
|
+
ariaLabel: string | null;
|
|
191
|
+
ariaLevel: string | null;
|
|
192
|
+
ariaLive: string | null;
|
|
193
|
+
ariaModal: string | null;
|
|
194
|
+
ariaMultiLine: string | null;
|
|
195
|
+
ariaMultiSelectable: string | null;
|
|
196
|
+
ariaOrientation: string | null;
|
|
197
|
+
ariaPlaceholder: string | null;
|
|
198
|
+
ariaPosInSet: string | null;
|
|
199
|
+
ariaPressed: string | null;
|
|
200
|
+
ariaReadOnly: string | null;
|
|
201
|
+
ariaRequired: string | null;
|
|
202
|
+
ariaRoleDescription: string | null;
|
|
203
|
+
ariaRowCount: string | null;
|
|
204
|
+
ariaRowIndex: string | null;
|
|
205
|
+
ariaRowSpan: string | null;
|
|
206
|
+
ariaSelected: string | null;
|
|
207
|
+
ariaSetSize: string | null;
|
|
208
|
+
ariaSort: string | null;
|
|
209
|
+
ariaValueMax: string | null;
|
|
210
|
+
ariaValueMin: string | null;
|
|
211
|
+
ariaValueNow: string | null;
|
|
212
|
+
ariaValueText: string | null;
|
|
213
|
+
animate(keyframes: PropertyIndexedKeyframes | Keyframe[] | null, options?: number | KeyframeAnimationOptions | undefined): Animation;
|
|
214
|
+
getAnimations(options?: GetAnimationsOptions | undefined): Animation[];
|
|
215
|
+
after(...nodes: (string | Node)[]): void;
|
|
216
|
+
before(...nodes: (string | Node)[]): void;
|
|
217
|
+
remove(): void;
|
|
218
|
+
replaceWith(...nodes: (string | Node)[]): void;
|
|
219
|
+
innerHTML: string;
|
|
220
|
+
readonly nextElementSibling: Element | null;
|
|
221
|
+
readonly previousElementSibling: Element | null;
|
|
222
|
+
readonly childElementCount: number;
|
|
223
|
+
readonly children: HTMLCollection;
|
|
224
|
+
readonly firstElementChild: Element | null;
|
|
225
|
+
readonly lastElementChild: Element | null;
|
|
226
|
+
append(...nodes: (string | Node)[]): void;
|
|
227
|
+
prepend(...nodes: (string | Node)[]): void;
|
|
228
|
+
querySelector<K_6 extends keyof HTMLElementTagNameMap>(selectors: K_6): HTMLElementTagNameMap[K_6] | null;
|
|
229
|
+
querySelector<K_7 extends keyof SVGElementTagNameMap>(selectors: K_7): SVGElementTagNameMap[K_7] | null;
|
|
230
|
+
querySelector<E_1 extends Element = Element>(selectors: string): E_1 | null;
|
|
231
|
+
querySelectorAll<K_8 extends keyof HTMLElementTagNameMap>(selectors: K_8): NodeListOf<HTMLElementTagNameMap[K_8]>;
|
|
232
|
+
querySelectorAll<K_9 extends keyof SVGElementTagNameMap>(selectors: K_9): NodeListOf<SVGElementTagNameMap[K_9]>;
|
|
233
|
+
querySelectorAll<E_2 extends Element = Element>(selectors: string): NodeListOf<E_2>;
|
|
234
|
+
replaceChildren(...nodes: (string | Node)[]): void;
|
|
235
|
+
readonly assignedSlot: HTMLSlotElement | null;
|
|
236
|
+
oncopy: ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
237
|
+
oncut: ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
238
|
+
onpaste: ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
239
|
+
readonly style: CSSStyleDeclaration;
|
|
240
|
+
contentEditable: string;
|
|
241
|
+
enterKeyHint: string;
|
|
242
|
+
inputMode: string;
|
|
243
|
+
readonly isContentEditable: boolean;
|
|
244
|
+
onabort: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
|
|
245
|
+
onanimationcancel: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
|
|
246
|
+
onanimationend: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
|
|
247
|
+
onanimationiteration: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
|
|
248
|
+
onanimationstart: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
|
|
249
|
+
onauxclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
250
|
+
onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
|
|
251
|
+
oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
252
|
+
oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
253
|
+
onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
254
|
+
onclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
255
|
+
onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
256
|
+
oncontextmenu: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
257
|
+
oncuechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
258
|
+
ondblclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
259
|
+
ondrag: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
260
|
+
ondragend: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
261
|
+
ondragenter: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
262
|
+
ondragleave: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
263
|
+
ondragover: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
264
|
+
ondragstart: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
265
|
+
ondrop: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
266
|
+
ondurationchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
267
|
+
onemptied: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
268
|
+
onended: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
269
|
+
onerror: OnErrorEventHandler;
|
|
270
|
+
onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
|
|
271
|
+
onformdata: ((this: GlobalEventHandlers, ev: FormDataEvent) => any) | null;
|
|
272
|
+
ongotpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
273
|
+
oninput: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
274
|
+
oninvalid: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
275
|
+
onkeydown: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
276
|
+
onkeypress: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
277
|
+
onkeyup: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
278
|
+
onload: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
279
|
+
onloadeddata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
280
|
+
onloadedmetadata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
281
|
+
onloadstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
282
|
+
onlostpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
283
|
+
onmousedown: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
284
|
+
onmouseenter: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
285
|
+
onmouseleave: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
286
|
+
onmousemove: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
287
|
+
onmouseout: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
288
|
+
onmouseover: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
289
|
+
onmouseup: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
290
|
+
onpause: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
291
|
+
onplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
292
|
+
onplaying: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
293
|
+
onpointercancel: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
294
|
+
onpointerdown: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
295
|
+
onpointerenter: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
296
|
+
onpointerleave: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
297
|
+
onpointermove: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
298
|
+
onpointerout: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
299
|
+
onpointerover: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
300
|
+
onpointerup: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
301
|
+
onprogress: ((this: GlobalEventHandlers, ev: ProgressEvent<EventTarget>) => any) | null;
|
|
302
|
+
onratechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
303
|
+
onreset: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
304
|
+
onresize: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
|
|
305
|
+
onscroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
306
|
+
onsecuritypolicyviolation: ((this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any) | null;
|
|
307
|
+
onseeked: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
308
|
+
onseeking: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
309
|
+
onselect: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
310
|
+
onselectionchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
311
|
+
onselectstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
312
|
+
onslotchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
313
|
+
onstalled: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
314
|
+
onsubmit: ((this: GlobalEventHandlers, ev: SubmitEvent) => any) | null;
|
|
315
|
+
onsuspend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
316
|
+
ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
317
|
+
ontoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
318
|
+
ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
319
|
+
ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
320
|
+
ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
321
|
+
ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
322
|
+
ontransitioncancel: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
|
|
323
|
+
ontransitionend: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
|
|
324
|
+
ontransitionrun: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
|
|
325
|
+
ontransitionstart: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
|
|
326
|
+
onvolumechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
327
|
+
onwaiting: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
328
|
+
onwebkitanimationend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
329
|
+
onwebkitanimationiteration: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
330
|
+
onwebkitanimationstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
331
|
+
onwebkittransitionend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
332
|
+
onwheel: ((this: GlobalEventHandlers, ev: WheelEvent) => any) | null;
|
|
333
|
+
autofocus: boolean;
|
|
334
|
+
readonly dataset: DOMStringMap;
|
|
335
|
+
nonce?: string | undefined;
|
|
336
|
+
tabIndex: number;
|
|
337
|
+
blur(): void;
|
|
338
|
+
focus(options?: FocusOptions | undefined): void;
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { BaseScheduler, render, } from 'haunted';
|
|
2
|
+
class Scheduler extends BaseScheduler {
|
|
3
|
+
_commit;
|
|
4
|
+
constructor(renderer, host, commitCallback) {
|
|
5
|
+
super(renderer, host);
|
|
6
|
+
this._commit = commitCallback;
|
|
7
|
+
}
|
|
8
|
+
commit(result) {
|
|
9
|
+
this._commit(result);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a mixin that mixes a haunted hook with a polymer component.
|
|
14
|
+
*
|
|
15
|
+
* @param {String} outputPath The property where the result of the hook will be stored (deprecated)
|
|
16
|
+
* @param {Function} hook A haunted hook
|
|
17
|
+
* @returns {Function} The mixin
|
|
18
|
+
*/
|
|
19
|
+
export const hauntedPolymer =
|
|
20
|
+
// eslint-disable-next-line max-lines-per-function
|
|
21
|
+
(outputPath, hook) => (base) => {
|
|
22
|
+
const hasOutputPath = hook !== undefined, _hook = hasOutputPath ? hook : outputPath;
|
|
23
|
+
// TODO: drop outputPath support after all usages are fixed.
|
|
24
|
+
if (hasOutputPath) {
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.warn('Haunted Polymer: use of outputPath is deprecated. Instead have the hook return an object with the keys being property names to update.');
|
|
27
|
+
}
|
|
28
|
+
return class extends base {
|
|
29
|
+
_scheduler;
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
this._scheduler = new Scheduler(// whenever the state is updated
|
|
33
|
+
() => _hook(this), // run the hook with the element as input
|
|
34
|
+
this, // using the element as state host
|
|
35
|
+
(result) => hasOutputPath
|
|
36
|
+
? this.set(outputPath, result)
|
|
37
|
+
: this.setProperties(result) // and update the output path with the results
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
super.connectedCallback();
|
|
42
|
+
this._scheduler.update();
|
|
43
|
+
}
|
|
44
|
+
disconnectedCallback() {
|
|
45
|
+
super.disconnectedCallback();
|
|
46
|
+
this._scheduler.teardown();
|
|
47
|
+
}
|
|
48
|
+
_propertiesChanged(currentProps, changedProps, oldProps) {
|
|
49
|
+
super._propertiesChanged(currentProps, changedProps, oldProps);
|
|
50
|
+
// skip haunted state update if the only thing that has changed is the hook output path
|
|
51
|
+
if (hasOutputPath &&
|
|
52
|
+
Object.keys(changedProps).length === 1 &&
|
|
53
|
+
changedProps[outputPath] != null) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// update haunted state only if a polymer prop has changed
|
|
57
|
+
if (this._onlyHauntedPropertiesChanged(changedProps)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// trigger a haunted update loop
|
|
61
|
+
// do it in the next animation frame, so the current loop finishes processing first
|
|
62
|
+
cancelAnimationFrame(this._hauntedUpdateFrameHandle);
|
|
63
|
+
this._hauntedUpdateFrameHandle = requestAnimationFrame(() => this._scheduler.update());
|
|
64
|
+
}
|
|
65
|
+
_onlyHauntedPropertiesChanged(changedProps) {
|
|
66
|
+
const props = this.constructor
|
|
67
|
+
.__properties;
|
|
68
|
+
if (Object.keys(changedProps)
|
|
69
|
+
.map((prop) => prop.split('.')[0])
|
|
70
|
+
// props updated by haunted are not listed or have the `haunted` flag
|
|
71
|
+
.every((prop) => props[prop] == null || props[prop].haunted)) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
renderLitTo(part, outlet) {
|
|
77
|
+
// render in the next animation frame to allow the haunted scheduler to finish processing the current state update
|
|
78
|
+
// otherwise hooks might be updated twice
|
|
79
|
+
cancelAnimationFrame(outlet.__renderAF);
|
|
80
|
+
outlet.__renderAF = requestAnimationFrame(() => render(typeof part === 'function' ? part() : part, outlet));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debounces a value by updating it via a double requestAnimationFrame call.
|
|
3
|
+
*
|
|
4
|
+
* Double RAF is useful for ensuring that animations start before expensive rendering is done.
|
|
5
|
+
* It helps provide smoother user experience by making animations feel reactive.
|
|
6
|
+
* Normal rendering would block the animation from starting.
|
|
7
|
+
*
|
|
8
|
+
* In the context of haunted, the double RAF call makes sure the value is updated *after* all
|
|
9
|
+
* hooks have been processed and the rendering has been done. Effectively all rapid, intermediary
|
|
10
|
+
* state changes will be skipped.
|
|
11
|
+
*
|
|
12
|
+
* @template T
|
|
13
|
+
* @param {T} value the value to debounce
|
|
14
|
+
* @returns {T} the debounced value
|
|
15
|
+
*/
|
|
16
|
+
export declare const useDebounceRaf: <T>(value: T) => T;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useState, useEffect } from 'haunted';
|
|
2
|
+
/**
|
|
3
|
+
* Debounces a value by updating it via a double requestAnimationFrame call.
|
|
4
|
+
*
|
|
5
|
+
* Double RAF is useful for ensuring that animations start before expensive rendering is done.
|
|
6
|
+
* It helps provide smoother user experience by making animations feel reactive.
|
|
7
|
+
* Normal rendering would block the animation from starting.
|
|
8
|
+
*
|
|
9
|
+
* In the context of haunted, the double RAF call makes sure the value is updated *after* all
|
|
10
|
+
* hooks have been processed and the rendering has been done. Effectively all rapid, intermediary
|
|
11
|
+
* state changes will be skipped.
|
|
12
|
+
*
|
|
13
|
+
* @template T
|
|
14
|
+
* @param {T} value the value to debounce
|
|
15
|
+
* @returns {T} the debounced value
|
|
16
|
+
*/
|
|
17
|
+
export const useDebounceRaf = (value) => {
|
|
18
|
+
// State and setters for debounced value
|
|
19
|
+
const [debouncedValue, setDebouncedValue] = useState(() => value);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
let double;
|
|
22
|
+
// Update debounced value after double RAF
|
|
23
|
+
const handler = requestAnimationFrame(() => {
|
|
24
|
+
double = requestAnimationFrame(() => setDebouncedValue(value));
|
|
25
|
+
});
|
|
26
|
+
// Cancel the animation frames if value changes (also on unmount)
|
|
27
|
+
// This is how we prevent debounced value from updating if value is changed.
|
|
28
|
+
// RAF gets cleared and restarted.
|
|
29
|
+
return () => {
|
|
30
|
+
cancelAnimationFrame(handler);
|
|
31
|
+
cancelAnimationFrame(double);
|
|
32
|
+
};
|
|
33
|
+
}, [value] // Only re-call effect if value changes
|
|
34
|
+
);
|
|
35
|
+
return debouncedValue;
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function useDroppedFiles(el: any): never[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useState, useCallback } from 'haunted';
|
|
2
|
+
import { useHandleDrop } from './use-handle-drop';
|
|
3
|
+
export const useDroppedFiles = el => {
|
|
4
|
+
const [files, setFiles] = useState([]), handleDrop = useCallback(event => setFiles(event.dataTransfer.files), [setFiles]);
|
|
5
|
+
useHandleDrop(el, handleDrop);
|
|
6
|
+
return files;
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function useHandleDrop(el: any, callback: any): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect } from 'haunted';
|
|
2
|
+
export const useHandleDrop = (el, callback) => useEffect(() => {
|
|
3
|
+
const dragStop = event => {
|
|
4
|
+
event.stopPropagation();
|
|
5
|
+
event.preventDefault();
|
|
6
|
+
}, handleDrop = event => {
|
|
7
|
+
dragStop(event);
|
|
8
|
+
callback(event);
|
|
9
|
+
};
|
|
10
|
+
el.addEventListener('dragenter', dragStop);
|
|
11
|
+
el.addEventListener('dragover', dragStop);
|
|
12
|
+
el.addEventListener('drop', handleDrop);
|
|
13
|
+
return () => {
|
|
14
|
+
el.removeEventListener('dragenter', dragStop);
|
|
15
|
+
el.removeEventListener('dragover', dragStop);
|
|
16
|
+
el.removeEventListener('drop', handleDrop);
|
|
17
|
+
};
|
|
18
|
+
}, [el, callback]);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useLayoutEffect, useState } from 'haunted';
|
|
2
|
+
import { useHost } from './use-host';
|
|
3
|
+
const useHostBounds = () => {
|
|
4
|
+
const host = useHost(), [bounds, setBounds] = useState();
|
|
5
|
+
useLayoutEffect(() => {
|
|
6
|
+
const observer = new ResizeObserver((entries) => requestAnimationFrame(() => setBounds(entries[0]?.contentRect)));
|
|
7
|
+
observer.observe(host);
|
|
8
|
+
return () => observer.unobserve(host);
|
|
9
|
+
}, []);
|
|
10
|
+
return bounds;
|
|
11
|
+
};
|
|
12
|
+
export { useHostBounds };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const useImperativeApi: (api?: any, values?: any) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Hook, hook } from 'haunted';
|
|
2
|
+
export const useImperativeApi = hook(class extends Hook {
|
|
3
|
+
constructor(id, state, api, values) {
|
|
4
|
+
super(id, state);
|
|
5
|
+
Object.assign(state.host, api);
|
|
6
|
+
this.values = values;
|
|
7
|
+
}
|
|
8
|
+
update(api, values) {
|
|
9
|
+
if (this.hasChanged(values)) {
|
|
10
|
+
this.values = values;
|
|
11
|
+
Object.assign(this.state.host, api);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
hasChanged(values = []) {
|
|
15
|
+
return values.some((value, i) => this.values[i] !== value);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useMemo } from 'haunted';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Copies properties of an Object into a memoized object.
|
|
5
4
|
* Useful to create an object that does not change.
|
|
@@ -7,8 +6,7 @@ import { useMemo } from 'haunted';
|
|
|
7
6
|
* @param {Object} meta - The source object
|
|
8
7
|
* @returns {Object} The memoized object.
|
|
9
8
|
*/
|
|
10
|
-
export const useMeta = meta => {
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export const useMeta = (meta) => {
|
|
10
|
+
const ref = useMemo(() => ({}), []);
|
|
11
|
+
return useMemo(() => Object.assign(ref, meta), [ref, ...Object.values(meta)]);
|
|
13
12
|
};
|
|
14
|
-
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useEffect } from 'haunted';
|
|
2
|
+
import { useHost } from './use-host';
|
|
3
|
+
const UPPER = /([A-Z])/gu,
|
|
4
|
+
/* Emulate polymer notify props */
|
|
5
|
+
notifyProperty = (host, name, value) => {
|
|
6
|
+
// this is required to make polymer double-binding recognize the change
|
|
7
|
+
// @see https://github.com/Polymer/polymer/blob/76c71e186ecc605294c3575dd31ac7983a8b3ae3/lib/mixins/property-effects.js#L382
|
|
8
|
+
host[name] = value;
|
|
9
|
+
// emulate polymer notify event
|
|
10
|
+
host.dispatchEvent(new CustomEvent(name.replace(UPPER, '-$1').toLowerCase() + '-changed', { detail: { value } }));
|
|
11
|
+
}, useNotifyProperty = (name, value) => {
|
|
12
|
+
const host = useHost();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
notifyProperty(host, name, value);
|
|
15
|
+
}, [value]);
|
|
16
|
+
};
|
|
17
|
+
export { notifyProperty, useNotifyProperty };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function usePromise(promise: any): any[];
|