@iframe-resizer/child 6.0.0-beta.1 → 6.0.0-beta.11

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/index.d.ts ADDED
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Type definitions for @iframe-resizer/child
3
+ */
4
+
5
+ import type { IFrameVersion } from '@iframe-resizer/common'
6
+
7
+ /** Configuration options set via window.iframeResizer before loading the child script. */
8
+ export interface PageOptions {
9
+ /** Restrict which elements are checked for resizing. */
10
+ ignoreSelector?: string
11
+ /** Offset added to the calculated size. */
12
+ offsetSize?: number
13
+ /** CSS selector for elements to use for size calculation. */
14
+ sizeSelector?: string
15
+ /** Restrict which parent origins can communicate with the iframe. */
16
+ targetOrigin?: string | string[]
17
+ /** Called before new size is set. Return a number to modify the new size. */
18
+ onBeforeResize?(newSize: number): number
19
+ /** Receive message posted from the parent page. */
20
+ onMessage?(message: any): void
21
+ /** Called once iframe-resizer has been initialized. */
22
+ onReady?(): void
23
+ }
24
+
25
+ /** Parent page properties returned by getParentProps(). */
26
+ export interface ParentProps {
27
+ /** Values from iframe.getBoundingClientRect() */
28
+ iframe: {
29
+ x: number
30
+ y: number
31
+ width: number
32
+ height: number
33
+ top: number
34
+ right: number
35
+ bottom: number
36
+ left: number
37
+ }
38
+ /** Document scroll dimensions */
39
+ document: {
40
+ scrollWidth: number
41
+ scrollHeight: number
42
+ }
43
+ /** Visual viewport properties */
44
+ viewport: {
45
+ width: number
46
+ height: number
47
+ offsetLeft: number
48
+ offsetTop: number
49
+ pageLeft: number
50
+ pageTop: number
51
+ scale: number
52
+ }
53
+ }
54
+
55
+ /** Child public API available at window.parentIframe. */
56
+ export interface ParentIframe {
57
+ /** Turn autoResizing of the iframe on and off. Returns current state. */
58
+ autoResize(resize?: boolean): boolean
59
+ /** Remove the iframe from the parent page. */
60
+ close(): void
61
+ /** Returns the ID of the iframe. */
62
+ getId(): string
63
+ /** Returns the child and parent iframe-resizer versions. */
64
+ getVersion(): IFrameVersion
65
+ /** Returns the origin of the parent page. */
66
+ getParentOrigin(): string
67
+ /**
68
+ * Request parent page properties. Your callback is recalled on
69
+ * parent scroll/resize. Returns an unsubscribe function.
70
+ */
71
+ getParentProps(callback: (data: ParentProps) => void): () => void
72
+ /** Move to anchor in parent page. */
73
+ moveToAnchor(hash: string): void
74
+ /**
75
+ * Manually force iframe to resize. Disable autoResize first to use
76
+ * passed arguments. Enable sizeWidth to set the width.
77
+ */
78
+ resize(customHeight?: number, customWidth?: number): void
79
+ /** Scroll the parent page by x and y. */
80
+ scrollBy(x: number, y: number): void
81
+ /** Scroll the parent page to the coordinates x and y. */
82
+ scrollTo(x: number, y: number): void
83
+ /** Scroll the parent page to x and y relative to the iframe position. */
84
+ scrollToOffset(x: number, y: number): void
85
+ /** Send data to the containing page. */
86
+ sendMessage(message: any, targetOrigin?: string): void
87
+ /** Set offset added to the calculated size. */
88
+ setOffsetSize(offsetSize: number): void
89
+ /** Set default target origin for postMessage. */
90
+ setTargetOrigin(targetOrigin: string): void
91
+ }
92
+
93
+ declare global {
94
+ interface Window {
95
+ iframeResizer: PageOptions
96
+ parentIframe: ParentIframe
97
+ }
98
+ }