@slickgrid-universal/utils 4.7.0 → 5.0.0-beta.1

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/src/domUtils.ts CHANGED
@@ -1,275 +1,267 @@
1
- import type { HtmlElementPosition, InferDOMType } from './models/index';
2
-
3
- /** calculate available space for each side of the DOM element */
4
- export function calculateAvailableSpace(element: HTMLElement): { top: number; bottom: number; left: number; right: number; } {
5
- let bottom = 0;
6
- let top = 0;
7
- let left = 0;
8
- let right = 0;
9
-
10
- const windowHeight = window.innerHeight ?? 0;
11
- const windowWidth = window.innerWidth ?? 0;
12
- const scrollPosition = windowScrollPosition();
13
- const pageScrollTop = scrollPosition.top;
14
- const pageScrollLeft = scrollPosition.left;
15
- const elmOffset = getOffset(element);
16
-
17
- if (elmOffset) {
18
- const elementOffsetTop = elmOffset.top ?? 0;
19
- const elementOffsetLeft = elmOffset.left ?? 0;
20
- top = elementOffsetTop - pageScrollTop;
21
- bottom = windowHeight - (elementOffsetTop - pageScrollTop);
22
- left = elementOffsetLeft - pageScrollLeft;
23
- right = windowWidth - (elementOffsetLeft - pageScrollLeft);
24
- }
25
-
26
- return { top, bottom, left, right };
27
- }
28
-
29
- /**
30
- * Create a DOM Element with any optional attributes or properties.
31
- * It will only accept valid DOM element properties that `createElement` would accept.
32
- * For example: `createDomElement('div', { className: 'my-css-class' })`,
33
- * for style or dataset you need to use nested object `{ style: { display: 'none' }}
34
- * The last argument is to optionally append the created element to a parent container element.
35
- * @param {String} tagName - html tag
36
- * @param {Object} options - element properties
37
- * @param {[Element]} appendToParent - parent element to append to
38
- */
39
- export function createDomElement<T extends keyof HTMLElementTagNameMap, K extends keyof HTMLElementTagNameMap[T]>(
40
- tagName: T,
41
- elementOptions?: null | { [P in K]: InferDOMType<HTMLElementTagNameMap[T][P]> },
42
- appendToParent?: Element
43
- ): HTMLElementTagNameMap[T] {
44
- const elm = document.createElement<T>(tagName);
45
-
46
- if (elementOptions) {
47
- Object.keys(elementOptions).forEach((elmOptionKey) => {
48
- if (elmOptionKey === 'innerHTML') {
49
- console.warn(`[Slickgrid-Universal] For better CSP (Content Security Policy) support, do not use "innerHTML" directly in "createDomElement('${tagName}', { innerHTML: 'some html'})", ` +
50
- `it is better as separate assignment: "const elm = createDomElement('span'); elm.innerHTML = 'some html';"`);
51
- }
52
- const elmValue = elementOptions[elmOptionKey as keyof typeof elementOptions];
53
- if (typeof elmValue === 'object') {
54
- Object.assign(elm[elmOptionKey as K] as object, elmValue);
55
- } else {
56
- elm[elmOptionKey as K] = (elementOptions as any)[elmOptionKey as keyof typeof elementOptions];
57
- }
58
- });
59
- }
60
- if (appendToParent?.appendChild) {
61
- appendToParent.appendChild(elm);
62
- }
63
- return elm;
64
- }
65
-
66
- /**
67
- * Accepts string containing the class or space-separated list of classes, and
68
- * returns list of individual classes.
69
- * Method properly takes into account extra whitespaces in the `className`
70
- * e.g.: " class1 class2 " => will result in `['class1', 'class2']`.
71
- * @param {String} className - space separated list of class names
72
- */
73
- export function classNameToList(className = ''): string[] {
74
- return className.split(' ').filter(cls => cls); // filter will remove whitespace entries
75
- }
76
-
77
- /**
78
- * Loop through all properties of an object and nullify any properties that are instanceof HTMLElement,
79
- * if we detect an array then use recursion to go inside it and apply same logic
80
- * @param obj - object containing 1 or more properties with DOM Elements
81
- */
82
- export function destroyAllElementProps(obj: any) {
83
- if (typeof obj === 'object') {
84
- Object.keys(obj).forEach(key => {
85
- if (Array.isArray(obj[key])) {
86
- destroyAllElementProps(obj[key]);
87
- }
88
- if (obj[key] instanceof HTMLElement) {
89
- obj[key] = null;
90
- }
91
- });
92
- }
93
- }
94
-
95
- /**
96
- * Empty a DOM element by removing all of its DOM element children leaving with an empty element (basically an empty shell)
97
- * @return {object} element - updated element
98
- */
99
- export function emptyElement<T extends Element = Element>(element?: T | null): T | undefined | null {
100
- while (element?.firstChild) {
101
- element.removeChild(element.firstChild);
102
- }
103
- return element;
104
- }
105
-
106
- /**
107
- * @deprecated @see `getHtmlStringOutput()`
108
- * This function is now deprecated and is an alias to the new `getHtmlStringOutput()`, so please use this new function instead which works with various type of inputs.
109
- */
110
- export function getHTMLFromFragment(input: DocumentFragment | HTMLElement | string | number, type: 'innerHTML' | 'outerHTML' = 'innerHTML'): string {
111
- return getHtmlStringOutput(input, type);
112
- }
113
-
114
- /**
115
- * From any input provided, return the HTML string (when a string is provided, it will be returned "as is" but when it's a number it will be converted to string)
116
- * When detecting HTMLElement/DocumentFragment, we can also specify which HTML type to retrieve innerHTML or outerHTML.
117
- * We can get the HTML by looping through all fragment `childNodes`
118
- * @param {DocumentFragment | HTMLElement | string | number} input
119
- * @param {'innerHTML' | 'outerHTML'} [type] - when the input is a DocumentFragment or HTMLElement, which type of HTML do you want to return? 'innerHTML' or 'outerHTML'
120
- * @returns {String}
121
- */
122
- export function getHtmlStringOutput(input: DocumentFragment | HTMLElement | string | number, type: 'innerHTML' | 'outerHTML' = 'innerHTML'): string {
123
- if (input instanceof DocumentFragment) {
124
- // a DocumentFragment doesn't have innerHTML/outerHTML, but we can loop through all children and concatenate them all to an HTML string
125
- return [].map.call(input.childNodes, (x: HTMLElement) => x[type]).join('') || input.textContent || '';
126
- } else if (input instanceof HTMLElement) {
127
- return input[type];
128
- }
129
- return String(input ?? ''); // reaching this line means it's already a string (or number) so just return it as string
130
- }
131
-
132
- /** Get offset of HTML element relative to a parent element */
133
- export function getOffsetRelativeToParent(parentElm: HTMLElement | null, childElm: HTMLElement | null) {
134
- if (!parentElm || !childElm) {
135
- return undefined;
136
- }
137
- const parentPos = parentElm.getBoundingClientRect();
138
- const childPos = childElm.getBoundingClientRect();
139
- return {
140
- top: childPos.top - parentPos.top,
141
- right: childPos.right - parentPos.right,
142
- bottom: childPos.bottom - parentPos.bottom,
143
- left: childPos.left - parentPos.left,
144
- };
145
- }
146
-
147
- /** Get HTML element offset with pure JS */
148
- export function getOffset(elm?: HTMLElement | null): HtmlElementPosition | undefined {
149
- if (!elm || !elm.getBoundingClientRect) {
150
- return undefined;
151
- }
152
- const box = elm.getBoundingClientRect();
153
- const docElem = document.documentElement;
154
-
155
- let top = 0;
156
- let left = 0;
157
- let bottom = 0;
158
- let right = 0;
159
-
160
- if (box?.top !== undefined && box.left !== undefined) {
161
- top = box.top + window.pageYOffset - docElem.clientTop;
162
- left = box.left + window.pageXOffset - docElem.clientLeft;
163
- right = box.right;
164
- bottom = box.bottom;
165
- }
166
- return { top, left, bottom, right };
167
- }
168
-
169
- export function getInnerSize(elm: HTMLElement, type: 'height' | 'width') {
170
- let size = 0;
171
-
172
- if (elm) {
173
- const clientSize = type === 'height' ? 'clientHeight' : 'clientWidth';
174
- const sides = type === 'height' ? ['top', 'bottom'] : ['left', 'right'];
175
- size = elm[clientSize];
176
- for (const side of sides) {
177
- const sideSize = (parseFloat(getStyleProp(elm, `padding-${side}`) || '') || 0);
178
- size -= sideSize;
179
- }
180
- }
181
- return size;
182
- }
183
-
184
- /** Get a DOM element style property value by calling getComputedStyle() on the element */
185
- export function getStyleProp(elm: HTMLElement, property: string) {
186
- if (elm) {
187
- return window.getComputedStyle(elm).getPropertyValue(property);
188
- }
189
- return null;
190
- }
191
-
192
- export function findFirstAttribute(inputElm: Element | null | undefined, attributes: string[]): string | null {
193
- if (inputElm) {
194
- for (const attribute of attributes) {
195
- const attrData = inputElm.getAttribute(attribute);
196
- if (attrData) {
197
- return attrData;
198
- }
199
- }
200
- }
201
- return null;
202
- }
203
-
204
- /**
205
- * Provide a width as a number or a string and find associated value in valid css style format or use default value when provided (or "auto" otherwise).
206
- * @param {Number|String} inputWidth - input width, could be a string or number
207
- * @param {Number | String} defaultValue [defaultValue=auto] - optional default value or use "auto" when nothing is provided
208
- * @returns {String} string output
209
- */
210
- export function findWidthOrDefault(inputWidth?: number | string | null, defaultValue = 'auto'): string {
211
- return (/^[0-9]+$/i.test(`${inputWidth}`) ? `${+(inputWidth as number)}px` : inputWidth as string) || defaultValue;
212
- }
213
-
214
- /**
215
- * HTML encode using a plain <div>
216
- * Create a in-memory div, set it's inner text(which a div can encode)
217
- * then grab the encoded contents back out. The div never exists on the page.
218
- * @param {String} inputValue - input value to be encoded
219
- * @return {String}
220
- */
221
- export function htmlEncode(inputValue: string): string {
222
- const val = typeof inputValue === 'string' ? inputValue : String(inputValue);
223
- const entityMap: { [char: string]: string; } = {
224
- '&': '&amp;',
225
- '<': '&lt;',
226
- '>': '&gt;',
227
- '"': '&quot;',
228
- '\'': '&#39;',
229
- };
230
- return (val || '').toString().replace(/[&<>"']/g, (s) => entityMap[s as keyof { [char: string]: string; }]);
231
- }
232
-
233
- /**
234
- * Decode text into html entity
235
- * @param string text: input text
236
- * @param string text: output text
237
- */
238
- export function htmlEntityDecode(input: string): string {
239
- return input.replace(/&#(\d+);/g, (_match, dec) => {
240
- return String.fromCharCode(dec);
241
- });
242
- }
243
-
244
- /**
245
- * Encode string to html special char and add html space padding defined
246
- * @param {string} inputStr - input string
247
- * @param {number} paddingLength - padding to add
248
- */
249
- export function htmlEncodeWithPadding(inputStr: string, paddingLength: number): string {
250
- const inputStrLn = inputStr.length;
251
- let outputStr = htmlEncode(inputStr);
252
-
253
- if (inputStrLn < paddingLength) {
254
- for (let i = inputStrLn; i < paddingLength; i++) {
255
- outputStr += `&nbsp;`;
256
- }
257
- }
258
- return outputStr;
259
- }
260
-
261
- /** insert an HTML Element after a target Element in the DOM */
262
- export function insertAfterElement(referenceNode: HTMLElement, newNode: HTMLElement) {
263
- referenceNode.parentNode?.insertBefore(newNode, referenceNode.nextSibling);
264
- }
265
-
266
- /**
267
- * Get the Window Scroll top/left Position
268
- * @returns
269
- */
270
- export function windowScrollPosition(): { left: number; top: number; } {
271
- return {
272
- left: window.pageXOffset || document.documentElement.scrollLeft || 0,
273
- top: window.pageYOffset || document.documentElement.scrollTop || 0,
274
- };
1
+ import type { HtmlElementPosition, InferDOMType } from './models/index';
2
+
3
+ /** calculate available space for each side of the DOM element */
4
+ export function calculateAvailableSpace(element: HTMLElement): { top: number; bottom: number; left: number; right: number; } {
5
+ let bottom = 0;
6
+ let top = 0;
7
+ let left = 0;
8
+ let right = 0;
9
+
10
+ const windowHeight = window.innerHeight ?? 0;
11
+ const windowWidth = window.innerWidth ?? 0;
12
+ const scrollPosition = windowScrollPosition();
13
+ const pageScrollTop = scrollPosition.top;
14
+ const pageScrollLeft = scrollPosition.left;
15
+ const elmOffset = getOffset(element);
16
+
17
+ if (elmOffset) {
18
+ const elementOffsetTop = elmOffset.top ?? 0;
19
+ const elementOffsetLeft = elmOffset.left ?? 0;
20
+ top = elementOffsetTop - pageScrollTop;
21
+ bottom = windowHeight - (elementOffsetTop - pageScrollTop);
22
+ left = elementOffsetLeft - pageScrollLeft;
23
+ right = windowWidth - (elementOffsetLeft - pageScrollLeft);
24
+ }
25
+
26
+ return { top, bottom, left, right };
27
+ }
28
+
29
+ /**
30
+ * Create a DOM Element with any optional attributes or properties.
31
+ * It will only accept valid DOM element properties that `createElement` would accept.
32
+ * For example: `createDomElement('div', { className: 'my-css-class' })`,
33
+ * for style or dataset you need to use nested object `{ style: { display: 'none' }}
34
+ * The last argument is to optionally append the created element to a parent container element.
35
+ * @param {String} tagName - html tag
36
+ * @param {Object} options - element properties
37
+ * @param {[Element]} appendToParent - parent element to append to
38
+ */
39
+ export function createDomElement<T extends keyof HTMLElementTagNameMap, K extends keyof HTMLElementTagNameMap[T]>(
40
+ tagName: T,
41
+ elementOptions?: null | { [P in K]: InferDOMType<HTMLElementTagNameMap[T][P]> },
42
+ appendToParent?: Element
43
+ ): HTMLElementTagNameMap[T] {
44
+ const elm = document.createElement<T>(tagName);
45
+
46
+ if (elementOptions) {
47
+ Object.keys(elementOptions).forEach((elmOptionKey) => {
48
+ if (elmOptionKey === 'innerHTML') {
49
+ console.warn(`[Slickgrid-Universal] For better CSP (Content Security Policy) support, do not use "innerHTML" directly in "createDomElement('${tagName}', { innerHTML: 'some html'})", ` +
50
+ `it is better as separate assignment: "const elm = createDomElement('span'); elm.innerHTML = 'some html';"`);
51
+ }
52
+ const elmValue = elementOptions[elmOptionKey as keyof typeof elementOptions];
53
+ if (typeof elmValue === 'object') {
54
+ Object.assign(elm[elmOptionKey as K] as object, elmValue);
55
+ } else {
56
+ elm[elmOptionKey as K] = (elementOptions as any)[elmOptionKey as keyof typeof elementOptions];
57
+ }
58
+ });
59
+ }
60
+ if (appendToParent?.appendChild) {
61
+ appendToParent.appendChild(elm);
62
+ }
63
+ return elm;
64
+ }
65
+
66
+ /**
67
+ * Accepts string containing the class or space-separated list of classes, and
68
+ * returns list of individual classes.
69
+ * Method properly takes into account extra whitespaces in the `className`
70
+ * e.g.: " class1 class2 " => will result in `['class1', 'class2']`.
71
+ * @param {String} className - space separated list of class names
72
+ */
73
+ export function classNameToList(className = ''): string[] {
74
+ return className.split(' ').filter(cls => cls); // filter will remove whitespace entries
75
+ }
76
+
77
+ /**
78
+ * Loop through all properties of an object and nullify any properties that are instanceof HTMLElement,
79
+ * if we detect an array then use recursion to go inside it and apply same logic
80
+ * @param obj - object containing 1 or more properties with DOM Elements
81
+ */
82
+ export function destroyAllElementProps(obj: any) {
83
+ if (typeof obj === 'object') {
84
+ Object.keys(obj).forEach(key => {
85
+ if (Array.isArray(obj[key])) {
86
+ destroyAllElementProps(obj[key]);
87
+ }
88
+ if (obj[key] instanceof HTMLElement) {
89
+ obj[key] = null;
90
+ }
91
+ });
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Empty a DOM element by removing all of its DOM element children leaving with an empty element (basically an empty shell)
97
+ * @return {object} element - updated element
98
+ */
99
+ export function emptyElement<T extends Element = Element>(element?: T | null): T | undefined | null {
100
+ while (element?.firstChild) {
101
+ element.removeChild(element.firstChild);
102
+ }
103
+ return element;
104
+ }
105
+
106
+ /**
107
+ * From any input provided, return the HTML string (when a string is provided, it will be returned "as is" but when it's a number it will be converted to string)
108
+ * When detecting HTMLElement/DocumentFragment, we can also specify which HTML type to retrieve innerHTML or outerHTML.
109
+ * We can get the HTML by looping through all fragment `childNodes`
110
+ * @param {DocumentFragment | HTMLElement | string | number} input
111
+ * @param {'innerHTML' | 'outerHTML'} [type] - when the input is a DocumentFragment or HTMLElement, which type of HTML do you want to return? 'innerHTML' or 'outerHTML'
112
+ * @returns {String}
113
+ */
114
+ export function getHtmlStringOutput(input: DocumentFragment | HTMLElement | string | number, type: 'innerHTML' | 'outerHTML' = 'innerHTML'): string {
115
+ if (input instanceof DocumentFragment) {
116
+ // a DocumentFragment doesn't have innerHTML/outerHTML, but we can loop through all children and concatenate them all to an HTML string
117
+ return [].map.call(input.childNodes, (x: HTMLElement) => x[type]).join('') || input.textContent || '';
118
+ } else if (input instanceof HTMLElement) {
119
+ return input[type];
120
+ }
121
+ return String(input ?? ''); // reaching this line means it's already a string (or number) so just return it as string
122
+ }
123
+
124
+ /** Get offset of HTML element relative to a parent element */
125
+ export function getOffsetRelativeToParent(parentElm: HTMLElement | null, childElm: HTMLElement | null) {
126
+ if (!parentElm || !childElm) {
127
+ return undefined;
128
+ }
129
+ const parentPos = parentElm.getBoundingClientRect();
130
+ const childPos = childElm.getBoundingClientRect();
131
+ return {
132
+ top: childPos.top - parentPos.top,
133
+ right: childPos.right - parentPos.right,
134
+ bottom: childPos.bottom - parentPos.bottom,
135
+ left: childPos.left - parentPos.left,
136
+ };
137
+ }
138
+
139
+ /** Get HTML element offset with pure JS */
140
+ export function getOffset(elm?: HTMLElement | null): HtmlElementPosition | undefined {
141
+ if (!elm || !elm.getBoundingClientRect) {
142
+ return undefined;
143
+ }
144
+ const box = elm.getBoundingClientRect();
145
+ const docElem = document.documentElement;
146
+
147
+ let top = 0;
148
+ let left = 0;
149
+ let bottom = 0;
150
+ let right = 0;
151
+
152
+ if (box?.top !== undefined && box.left !== undefined) {
153
+ top = box.top + window.pageYOffset - docElem.clientTop;
154
+ left = box.left + window.pageXOffset - docElem.clientLeft;
155
+ right = box.right;
156
+ bottom = box.bottom;
157
+ }
158
+ return { top, left, bottom, right };
159
+ }
160
+
161
+ export function getInnerSize(elm: HTMLElement, type: 'height' | 'width') {
162
+ let size = 0;
163
+
164
+ if (elm) {
165
+ const clientSize = type === 'height' ? 'clientHeight' : 'clientWidth';
166
+ const sides = type === 'height' ? ['top', 'bottom'] : ['left', 'right'];
167
+ size = elm[clientSize];
168
+ for (const side of sides) {
169
+ const sideSize = (parseFloat(getStyleProp(elm, `padding-${side}`) || '') || 0);
170
+ size -= sideSize;
171
+ }
172
+ }
173
+ return size;
174
+ }
175
+
176
+ /** Get a DOM element style property value by calling getComputedStyle() on the element */
177
+ export function getStyleProp(elm: HTMLElement, property: string) {
178
+ if (elm) {
179
+ return window.getComputedStyle(elm).getPropertyValue(property);
180
+ }
181
+ return null;
182
+ }
183
+
184
+ export function findFirstAttribute(inputElm: Element | null | undefined, attributes: string[]): string | null {
185
+ if (inputElm) {
186
+ for (const attribute of attributes) {
187
+ const attrData = inputElm.getAttribute(attribute);
188
+ if (attrData) {
189
+ return attrData;
190
+ }
191
+ }
192
+ }
193
+ return null;
194
+ }
195
+
196
+ /**
197
+ * Provide a width as a number or a string and find associated value in valid css style format or use default value when provided (or "auto" otherwise).
198
+ * @param {Number|String} inputWidth - input width, could be a string or number
199
+ * @param {Number | String} defaultValue [defaultValue=auto] - optional default value or use "auto" when nothing is provided
200
+ * @returns {String} string output
201
+ */
202
+ export function findWidthOrDefault(inputWidth?: number | string | null, defaultValue = 'auto'): string {
203
+ return (/^[0-9]+$/i.test(`${inputWidth}`) ? `${+(inputWidth as number)}px` : inputWidth as string) || defaultValue;
204
+ }
205
+
206
+ /**
207
+ * HTML encode using a plain <div>
208
+ * Create a in-memory div, set it's inner text(which a div can encode)
209
+ * then grab the encoded contents back out. The div never exists on the page.
210
+ * @param {String} inputValue - input value to be encoded
211
+ * @return {String}
212
+ */
213
+ export function htmlEncode(inputValue: string): string {
214
+ const val = typeof inputValue === 'string' ? inputValue : String(inputValue);
215
+ const entityMap: { [char: string]: string; } = {
216
+ '&': '&amp;',
217
+ '<': '&lt;',
218
+ '>': '&gt;',
219
+ '"': '&quot;',
220
+ '\'': '&#39;',
221
+ };
222
+ return (val || '').toString().replace(/[&<>"']/g, (s) => entityMap[s as keyof { [char: string]: string; }]);
223
+ }
224
+
225
+ /**
226
+ * Decode text into html entity
227
+ * @param string text: input text
228
+ * @param string text: output text
229
+ */
230
+ export function htmlEntityDecode(input: string): string {
231
+ return input.replace(/&#(\d+);/g, (_match, dec) => {
232
+ return String.fromCharCode(dec);
233
+ });
234
+ }
235
+
236
+ /**
237
+ * Encode string to html special char and add html space padding defined
238
+ * @param {string} inputStr - input string
239
+ * @param {number} paddingLength - padding to add
240
+ */
241
+ export function htmlEncodeWithPadding(inputStr: string, paddingLength: number): string {
242
+ const inputStrLn = inputStr.length;
243
+ let outputStr = htmlEncode(inputStr);
244
+
245
+ if (inputStrLn < paddingLength) {
246
+ for (let i = inputStrLn; i < paddingLength; i++) {
247
+ outputStr += `&nbsp;`;
248
+ }
249
+ }
250
+ return outputStr;
251
+ }
252
+
253
+ /** insert an HTML Element after a target Element in the DOM */
254
+ export function insertAfterElement(referenceNode: HTMLElement, newNode: HTMLElement) {
255
+ referenceNode.parentNode?.insertBefore(newNode, referenceNode.nextSibling);
256
+ }
257
+
258
+ /**
259
+ * Get the Window Scroll top/left Position
260
+ * @returns
261
+ */
262
+ export function windowScrollPosition(): { left: number; top: number; } {
263
+ return {
264
+ left: window.pageXOffset || document.documentElement.scrollLeft || 0,
265
+ top: window.pageYOffset || document.documentElement.scrollTop || 0,
266
+ };
275
267
  }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './domUtils';
2
- export * from './nodeExtend';
3
- export * from './stripTagsUtil';
4
- export * from './models';
1
+ export * from './domUtils';
2
+ export * from './nodeExtend';
3
+ export * from './stripTagsUtil';
4
+ export * from './models';
5
5
  export * from './utils';
@@ -1,2 +1,2 @@
1
- export * from './interfaces';
2
- export * from './types';
1
+ export * from './interfaces';
2
+ export * from './types';
@@ -1,6 +1,6 @@
1
- export interface HtmlElementPosition {
2
- top: number;
3
- bottom: number;
4
- left: number;
5
- right: number;
6
- }
1
+ export interface HtmlElementPosition {
2
+ top: number;
3
+ bottom: number;
4
+ left: number;
5
+ right: number;
6
+ }
@@ -1,6 +1,6 @@
1
-
2
- export type InferDOMType<T> =
3
- T extends CSSStyleDeclaration ? Partial<CSSStyleDeclaration> :
4
- T extends infer R ? R : any;
5
-
1
+
2
+ export type InferDOMType<T> =
3
+ T extends CSSStyleDeclaration ? Partial<CSSStyleDeclaration> :
4
+ T extends infer R ? R : any;
5
+
6
6
  export type AnyFunction = (...args: any[]) => any;