@slickgrid-universal/utils 5.10.2 → 9.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.
Files changed (62) hide show
  1. package/dist/{types/domUtils.d.ts → domUtils.d.ts} +1 -1
  2. package/dist/domUtils.d.ts.map +1 -0
  3. package/dist/{esm/domUtils.js → domUtils.js} +23 -41
  4. package/dist/domUtils.js.map +1 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/models/interfaces.d.ts.map +1 -0
  8. package/dist/{cjs/models → models}/interfaces.js.map +1 -1
  9. package/dist/models/types.d.ts.map +1 -0
  10. package/dist/{cjs/models → models}/types.js.map +1 -1
  11. package/dist/nodeExtend.d.ts.map +1 -0
  12. package/dist/{esm/nodeExtend.js → nodeExtend.js} +4 -2
  13. package/dist/nodeExtend.js.map +1 -0
  14. package/dist/stripTagsUtil.d.ts.map +1 -0
  15. package/dist/{esm/stripTagsUtil.js → stripTagsUtil.js} +2 -2
  16. package/dist/stripTagsUtil.js.map +1 -0
  17. package/dist/utils.d.ts.map +1 -0
  18. package/dist/{esm/utils.js → utils.js} +26 -18
  19. package/dist/utils.js.map +1 -0
  20. package/package.json +7 -9
  21. package/src/domUtils.ts +48 -58
  22. package/src/index.ts +1 -1
  23. package/src/models/types.ts +2 -5
  24. package/src/nodeExtend.ts +5 -3
  25. package/src/stripTagsUtil.ts +9 -9
  26. package/src/utils.ts +31 -20
  27. package/dist/cjs/domUtils.js +0 -259
  28. package/dist/cjs/domUtils.js.map +0 -1
  29. package/dist/cjs/index.js +0 -21
  30. package/dist/cjs/index.js.map +0 -1
  31. package/dist/cjs/models/interfaces.js +0 -3
  32. package/dist/cjs/models/types.js +0 -3
  33. package/dist/cjs/nodeExtend.js +0 -123
  34. package/dist/cjs/nodeExtend.js.map +0 -1
  35. package/dist/cjs/stripTagsUtil.js +0 -175
  36. package/dist/cjs/stripTagsUtil.js.map +0 -1
  37. package/dist/cjs/utils.js +0 -370
  38. package/dist/cjs/utils.js.map +0 -1
  39. package/dist/esm/domUtils.js.map +0 -1
  40. package/dist/esm/index.js.map +0 -1
  41. package/dist/esm/models/interfaces.js.map +0 -1
  42. package/dist/esm/models/types.js.map +0 -1
  43. package/dist/esm/nodeExtend.js.map +0 -1
  44. package/dist/esm/stripTagsUtil.js.map +0 -1
  45. package/dist/esm/utils.js.map +0 -1
  46. package/dist/tsconfig.tsbuildinfo +0 -1
  47. package/dist/types/domUtils.d.ts.map +0 -1
  48. package/dist/types/index.d.ts.map +0 -1
  49. package/dist/types/models/interfaces.d.ts.map +0 -1
  50. package/dist/types/models/types.d.ts.map +0 -1
  51. package/dist/types/nodeExtend.d.ts.map +0 -1
  52. package/dist/types/stripTagsUtil.d.ts.map +0 -1
  53. package/dist/types/utils.d.ts.map +0 -1
  54. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
  55. /package/dist/{esm/index.js → index.js} +0 -0
  56. /package/dist/{types/models → models}/interfaces.d.ts +0 -0
  57. /package/dist/{esm/models → models}/interfaces.js +0 -0
  58. /package/dist/{types/models → models}/types.d.ts +0 -0
  59. /package/dist/{esm/models → models}/types.js +0 -0
  60. /package/dist/{types/nodeExtend.d.ts → nodeExtend.d.ts} +0 -0
  61. /package/dist/{types/stripTagsUtil.d.ts → stripTagsUtil.d.ts} +0 -0
  62. /package/dist/{types/utils.d.ts → utils.d.ts} +0 -0
@@ -1,6 +1,3 @@
1
+ export type InferDOMType<T> = T extends CSSStyleDeclaration ? Partial<CSSStyleDeclaration> : T extends infer R ? R : any;
1
2
 
2
- export type InferDOMType<T> =
3
- T extends CSSStyleDeclaration ? Partial<CSSStyleDeclaration> :
4
- T extends infer R ? R : any;
5
-
6
- export type AnyFunction = (...args: any[]) => any;
3
+ export type AnyFunction = (...args: any[]) => any;
package/src/nodeExtend.ts CHANGED
@@ -38,7 +38,9 @@ const isPlainObject = function isPlainObject(obj: any) {
38
38
 
39
39
  // Own properties are enumerated firstly, so to speed up, if last one is own, then all properties are own.
40
40
  let key;
41
- for (key in obj) { /**/ }
41
+ for (key in obj) {
42
+ /**/
43
+ }
42
44
 
43
45
  return typeof key === 'undefined' || hasOwn.call(obj, key);
44
46
  };
@@ -50,7 +52,7 @@ const setProperty = function setProperty(target: any, options: any) {
50
52
  enumerable: true,
51
53
  configurable: true,
52
54
  value: options.newValue,
53
- writable: true
55
+ writable: true,
54
56
  });
55
57
  } else {
56
58
  target[options.name] = options.newValue;
@@ -128,4 +130,4 @@ export function extend<T = any>(...args: any[]): T {
128
130
 
129
131
  // Return the modified object
130
132
  return target;
131
- }
133
+ }
@@ -28,8 +28,11 @@ interface Context {
28
28
  in_quote_char: string;
29
29
  }
30
30
 
31
- export function stripTags(htmlText: string | number | boolean | HTMLElement, allowableTags?: string | string[], tagReplacement?: string): string {
32
-
31
+ export function stripTags(
32
+ htmlText: string | number | boolean | HTMLElement,
33
+ allowableTags?: string | string[],
34
+ tagReplacement?: string
35
+ ): string {
33
36
  /** main init function that will be executed when calling the global function */
34
37
  function init(html: string | number | boolean | HTMLElement, allowable_tags?: string | string[], tag_replacement?: string) {
35
38
  // number/boolean should be accepted but converted to string and returned on the spot
@@ -44,10 +47,7 @@ export function stripTags(htmlText: string | number | boolean | HTMLElement, all
44
47
  throw new TypeError(`'html' parameter must be a string`);
45
48
  }
46
49
 
47
- return striptags_internal(
48
- html || '',
49
- init_context(allowable_tags || '', tag_replacement || '')
50
- );
50
+ return striptags_internal(html || '', init_context(allowable_tags || '', tag_replacement || ''));
51
51
  }
52
52
 
53
53
  function init_context(allowable_tags: string | string[], tag_replacement: string): Context {
@@ -57,7 +57,7 @@ export function stripTags(htmlText: string | number | boolean | HTMLElement, all
57
57
  state: STATE_PLAINTEXT,
58
58
  tag_buffer: '',
59
59
  depth: 0,
60
- in_quote_char: ''
60
+ in_quote_char: '',
61
61
  };
62
62
  }
63
63
 
@@ -117,7 +117,7 @@ export function stripTags(htmlText: string | number | boolean | HTMLElement, all
117
117
  tag_buffer = '';
118
118
  break;
119
119
  case '"':
120
- case '\'':
120
+ case "'":
121
121
  // catch both single and double quotes
122
122
  if (char === in_quote_char) {
123
123
  in_quote_char = '';
@@ -191,4 +191,4 @@ export function stripTags(htmlText: string | number | boolean | HTMLElement, all
191
191
 
192
192
  // init
193
193
  return init(htmlText, allowableTags, tagReplacement);
194
- }
194
+ }
package/src/utils.ts CHANGED
@@ -74,10 +74,10 @@ export function deepMerge(target: any, ...sources: any[]): any {
74
74
  const source = sources.shift();
75
75
 
76
76
  // when target is not an object but source is an object, then we'll assign as object
77
- target = (!isObject(target) && isObject(source)) ? {} : target;
77
+ target = !isObject(target) && isObject(source) ? {} : target;
78
78
 
79
79
  if (isObject(target) && isObject(source)) {
80
- Object.keys(source).forEach(prop => {
80
+ Object.keys(source).forEach((prop) => {
81
81
  if (source.hasOwnProperty(prop)) {
82
82
  if (prop in target) {
83
83
  // handling merging of two properties with equal names
@@ -112,7 +112,7 @@ export function deepMerge(target: any, ...sources: any[]): any {
112
112
  */
113
113
  export function emptyObject(obj: any): any {
114
114
  if (isObject(obj)) {
115
- Object.keys(obj).forEach(key => {
115
+ Object.keys(obj).forEach((key) => {
116
116
  if (obj.hasOwnProperty(key)) {
117
117
  delete obj[key];
118
118
  }
@@ -131,7 +131,10 @@ export function emptyObject(obj: any): any {
131
131
  * @param {Boolean} [addReturn] - when using ES6 function as single liner, we could add the missing `return ...`
132
132
  * @returns
133
133
  */
134
- export function getFunctionDetails(fn: AnyFunction, addReturn = true): {
134
+ export function getFunctionDetails(
135
+ fn: AnyFunction,
136
+ addReturn = true
137
+ ): {
135
138
  params: string[];
136
139
  body: string;
137
140
  isAsync: boolean;
@@ -143,13 +146,13 @@ export function getFunctionDetails(fn: AnyFunction, addReturn = true): {
143
146
  isAsyncFn = fnStr.includes('async ');
144
147
 
145
148
  // when fn is one liner arrow fn returning an object in brackets e.g. `() => ({ hello: 'world' })`
146
- if ((fnStr.replaceAll(' ', '').includes('=>({'))) {
149
+ if (fnStr.replaceAll(' ', '').includes('=>({')) {
147
150
  const matches = fnStr.match(/(({.*}))/g) || [];
148
151
  return matches.length >= 1 ? `return ${matches[0]!.trimStart()}` : fnStr;
149
152
  }
150
- const isOneLinerArrowFn = (!fnStr.includes('{') && fnStr.includes('=>'));
153
+ const isOneLinerArrowFn = !fnStr.includes('{') && fnStr.includes('=>');
151
154
  const body = fnStr.substring(
152
- (fnStr.indexOf('{') + 1) || (fnStr.indexOf('=>') + 2),
155
+ fnStr.indexOf('{') + 1 || fnStr.indexOf('=>') + 2,
153
156
  fnStr.includes('}') ? fnStr.lastIndexOf('}') : fnStr.length
154
157
  );
155
158
  if (addReturn && isOneLinerArrowFn && !body.startsWith('return')) {
@@ -159,7 +162,7 @@ export function getFunctionDetails(fn: AnyFunction, addReturn = true): {
159
162
  };
160
163
 
161
164
  const getFunctionParams = (func: AnyFunction): string[] => {
162
- const STRIP_COMMENTS = /(\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s*=[^,)]*(('(?:\\'|[^'\r\n])*')|("(?:\\"|[^"\r\n])*"))|(\s*=[^,)]*))/mg;
165
+ const STRIP_COMMENTS = /(\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s*=[^,)]*(('(?:\\'|[^'\r\n])*')|("(?:\\"|[^"\r\n])*"))|(\s*=[^,)]*))/gm;
163
166
  const ARG_NAMES = /([^\s,]+)/g;
164
167
  const fnStr = func.toString().replace(STRIP_COMMENTS, '');
165
168
  return fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')).match(ARG_NAMES) ?? [];
@@ -222,9 +225,9 @@ export function isPrimitiveOrHTML(val: any): boolean {
222
225
  */
223
226
  export function isNumber(value: any, strict = false): value is number {
224
227
  if (strict) {
225
- return (value === null || value === undefined || typeof value === 'string') ? false : !isNaN(value);
228
+ return value === null || value === undefined || typeof value === 'string' ? false : !isNaN(value);
226
229
  }
227
- return (value === null || value === undefined || value === '') ? false : !isNaN(+value);
230
+ return value === null || value === undefined || value === '' ? false : !isNaN(+value);
228
231
  }
229
232
 
230
233
  /** Check if an object is empty, it will also be considered empty when the input is null, undefined or isn't an object */
@@ -244,7 +247,7 @@ export function parseBoolean(input: any): boolean {
244
247
  * @returns
245
248
  */
246
249
  export function removeAccentFromText(text: string, shouldLowerCase = false): string {
247
- const normalizedText = (typeof text.normalize === 'function') ? text.normalize('NFD').replace(/[\u0300-\u036f]/g, '') : text;
250
+ const normalizedText = typeof text.normalize === 'function' ? text.normalize('NFD').replace(/[\u0300-\u036f]/g, '') : text;
248
251
  return shouldLowerCase ? normalizedText.toLowerCase() : normalizedText;
249
252
  }
250
253
 
@@ -258,15 +261,16 @@ export function setDeepValue<T = unknown>(obj: T, path: string | string[], value
258
261
  const e = path.shift() as keyof T;
259
262
  if (obj && e !== undefined) {
260
263
  setDeepValue(
261
- (obj)[e] = (isDefined(obj[e]) && (Array.isArray(obj[e]) || Object.prototype.toString.call((obj)[e]) === '[object Object]'))
262
- ? (obj)[e]
263
- : {} as any,
264
+ (obj[e] =
265
+ isDefined(obj[e]) && (Array.isArray(obj[e]) || Object.prototype.toString.call(obj[e]) === '[object Object]')
266
+ ? obj[e]
267
+ : ({} as any)),
264
268
  path,
265
269
  value
266
270
  );
267
271
  }
268
272
  } else if (obj && path[0]) {
269
- (obj)[path[0] as keyof T] = value;
273
+ obj[path[0] as keyof T] = value;
270
274
  }
271
275
  }
272
276
 
@@ -314,7 +318,9 @@ export function toCamelCase(inputStr: string): string {
314
318
  */
315
319
  export function toKebabCase(inputStr: string): string {
316
320
  if (typeof inputStr === 'string') {
317
- return toCamelCase(inputStr).replace(/([A-Z])|([-_])/g, '-$1').toLowerCase();
321
+ return toCamelCase(inputStr)
322
+ .replace(/([A-Z])|([-_])/g, '-$1')
323
+ .toLowerCase();
318
324
  }
319
325
  return inputStr;
320
326
  }
@@ -326,7 +332,10 @@ export function toKebabCase(inputStr: string): string {
326
332
  */
327
333
  export function toSentenceCase(inputStr: string): string {
328
334
  if (typeof inputStr === 'string') {
329
- const result = inputStr.replace(/([A-Z])|([-_])/g, ' $1').replace(/\s+/g, ' ').trim();
335
+ const result = inputStr
336
+ .replace(/([A-Z])|([-_])/g, ' $1')
337
+ .replace(/\s+/g, ' ')
338
+ .trim();
330
339
  return result.charAt(0).toUpperCase() + result.slice(1);
331
340
  }
332
341
  return inputStr;
@@ -339,7 +348,9 @@ export function toSentenceCase(inputStr: string): string {
339
348
  */
340
349
  export function toSnakeCase(inputStr: string): string {
341
350
  if (typeof inputStr === 'string') {
342
- return toCamelCase(inputStr).replace(/([A-Z])/g, '_$1').toLowerCase();
351
+ return toCamelCase(inputStr)
352
+ .replace(/([A-Z])/g, '_$1')
353
+ .toLowerCase();
343
354
  }
344
355
  return inputStr;
345
356
  }
@@ -372,10 +383,10 @@ export function uniqueObjectArray(arr: any[], propertyName = 'id'): any[] {
372
383
 
373
384
  for (const item of arr) {
374
385
  if (item && !map.has(item[propertyName])) {
375
- map.set(item[propertyName], true); // set any value to Map
386
+ map.set(item[propertyName], true); // set any value to Map
376
387
  result.push({
377
388
  id: item[propertyName],
378
- name: item.name
389
+ name: item.name,
379
390
  });
380
391
  }
381
392
  }
@@ -1,259 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateAvailableSpace = calculateAvailableSpace;
4
- exports.createDomElement = createDomElement;
5
- exports.classNameToList = classNameToList;
6
- exports.destroyAllElementProps = destroyAllElementProps;
7
- exports.emptyElement = emptyElement;
8
- exports.getHtmlStringOutput = getHtmlStringOutput;
9
- exports.getOffsetRelativeToParent = getOffsetRelativeToParent;
10
- exports.getOffset = getOffset;
11
- exports.getInnerSize = getInnerSize;
12
- exports.getStyleProp = getStyleProp;
13
- exports.findFirstAttribute = findFirstAttribute;
14
- exports.findWidthOrDefault = findWidthOrDefault;
15
- exports.htmlEncode = htmlEncode;
16
- exports.htmlEntityDecode = htmlEntityDecode;
17
- exports.htmlEncodeWithPadding = htmlEncodeWithPadding;
18
- exports.insertAfterElement = insertAfterElement;
19
- exports.windowScrollPosition = windowScrollPosition;
20
- /** calculate available space for each side of the DOM element */
21
- function calculateAvailableSpace(element) {
22
- let bottom = 0;
23
- let top = 0;
24
- let left = 0;
25
- let right = 0;
26
- const windowHeight = window.innerHeight || 0;
27
- const windowWidth = window.innerWidth || 0;
28
- const scrollPosition = windowScrollPosition();
29
- const pageScrollTop = scrollPosition.top;
30
- const pageScrollLeft = scrollPosition.left;
31
- const elmOffset = getOffset(element);
32
- if (elmOffset) {
33
- const elementOffsetTop = elmOffset.top;
34
- const elementOffsetLeft = elmOffset.left;
35
- top = elementOffsetTop - pageScrollTop;
36
- left = elementOffsetLeft - pageScrollLeft;
37
- bottom = windowHeight - (elementOffsetTop - pageScrollTop + element.clientHeight);
38
- right = windowWidth - (elementOffsetLeft - pageScrollLeft + element.clientWidth);
39
- }
40
- return { top, bottom, left, right };
41
- }
42
- /**
43
- * Create a DOM Element with any optional attributes or properties.
44
- * It will only accept valid DOM element properties that `createElement` would accept.
45
- * For example: `createDomElement('div', { className: 'my-css-class' })`,
46
- * for style or dataset you need to use nested object `{ style: { display: 'none' }}
47
- * The last argument is to optionally append the created element to a parent container element.
48
- * @param {String} tagName - html tag
49
- * @param {Object} options - element properties
50
- * @param {[Element]} appendToParent - parent element to append to
51
- */
52
- function createDomElement(tagName, elementOptions, appendToParent) {
53
- const elm = document.createElement(tagName);
54
- if (elementOptions) {
55
- Object.keys(elementOptions).forEach((elmOptionKey) => {
56
- if (elmOptionKey === 'innerHTML') {
57
- console.warn(`[Slickgrid-Universal] For better CSP (Content Security Policy) support, do not use "innerHTML" directly in "createDomElement('${tagName}', { innerHTML: 'some html'})", ` +
58
- `it is better as separate assignment: "const elm = createDomElement('span'); elm.innerHTML = 'some html';"`);
59
- }
60
- const elmValue = elementOptions[elmOptionKey];
61
- if (typeof elmValue === 'object') {
62
- Object.assign(elm[elmOptionKey], elmValue);
63
- }
64
- else {
65
- elm[elmOptionKey] = elementOptions[elmOptionKey];
66
- }
67
- });
68
- }
69
- if (appendToParent?.appendChild) {
70
- appendToParent.appendChild(elm);
71
- }
72
- return elm;
73
- }
74
- /**
75
- * Accepts string containing the class or space-separated list of classes, and
76
- * returns list of individual classes.
77
- * Method properly takes into account extra whitespaces in the `className`
78
- * e.g.: " class1 class2 " => will result in `['class1', 'class2']`.
79
- * @param {String} className - space separated list of class names
80
- */
81
- function classNameToList(className = '') {
82
- return className.split(' ').filter(cls => cls); // filter will remove whitespace entries
83
- }
84
- /**
85
- * Loop through all properties of an object and nullify any properties that are instanceof HTMLElement,
86
- * if we detect an array then use recursion to go inside it and apply same logic
87
- * @param obj - object containing 1 or more properties with DOM Elements
88
- */
89
- function destroyAllElementProps(obj) {
90
- if (typeof obj === 'object') {
91
- Object.keys(obj).forEach(key => {
92
- if (Array.isArray(obj[key])) {
93
- destroyAllElementProps(obj[key]);
94
- }
95
- if (obj[key] instanceof HTMLElement) {
96
- obj[key] = null;
97
- }
98
- });
99
- }
100
- }
101
- /**
102
- * Empty a DOM element by removing all of its DOM element children leaving with an empty element (basically an empty shell)
103
- * @return {object} element - updated element
104
- */
105
- function emptyElement(element) {
106
- while (element?.firstChild) {
107
- element.removeChild(element.firstChild);
108
- }
109
- return element;
110
- }
111
- /**
112
- * 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)
113
- * When detecting HTMLElement/DocumentFragment, we can also specify which HTML type to retrieve innerHTML or outerHTML.
114
- * We can get the HTML by looping through all fragment `childNodes`
115
- * @param {DocumentFragment | HTMLElement | string | number} input
116
- * @param {'innerHTML' | 'outerHTML'} [type] - when the input is a DocumentFragment or HTMLElement, which type of HTML do you want to return? 'innerHTML' or 'outerHTML'
117
- * @returns {String}
118
- */
119
- function getHtmlStringOutput(input, type = 'innerHTML') {
120
- if (input instanceof DocumentFragment) {
121
- // a DocumentFragment doesn't have innerHTML/outerHTML, but we can loop through all children and concatenate them all to an HTML string
122
- return [].map.call(input.childNodes, (x) => x[type]).join('') || input.textContent || '';
123
- }
124
- else if (input instanceof HTMLElement) {
125
- return input[type];
126
- }
127
- return String(input ?? ''); // reaching this line means it's already a string (or number) so just return it as string
128
- }
129
- /** Get offset of HTML element relative to a parent element */
130
- function getOffsetRelativeToParent(parentElm, childElm) {
131
- if (!parentElm || !childElm) {
132
- return undefined;
133
- }
134
- const parentPos = parentElm.getBoundingClientRect();
135
- const childPos = childElm.getBoundingClientRect();
136
- return {
137
- top: childPos.top - parentPos.top,
138
- right: childPos.right - parentPos.right,
139
- bottom: childPos.bottom - parentPos.bottom,
140
- left: childPos.left - parentPos.left,
141
- };
142
- }
143
- /** Get HTML element offset with pure JS */
144
- function getOffset(elm) {
145
- let top = 0;
146
- let left = 0;
147
- let bottom = 0;
148
- let right = 0;
149
- if (!elm || !elm.getBoundingClientRect) {
150
- return { top, bottom, left, right };
151
- }
152
- const box = elm.getBoundingClientRect();
153
- const docElem = document.documentElement;
154
- if (box?.top !== undefined && box.left !== undefined) {
155
- top = box.top + window.pageYOffset - docElem.clientTop;
156
- left = box.left + window.pageXOffset - docElem.clientLeft;
157
- right = box.right;
158
- bottom = box.bottom;
159
- }
160
- return { top, left, bottom, right };
161
- }
162
- function getInnerSize(elm, type) {
163
- let size = 0;
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
- /** Get a DOM element style property value by calling getComputedStyle() on the element */
176
- function getStyleProp(elm, property) {
177
- if (elm) {
178
- return window.getComputedStyle(elm).getPropertyValue(property);
179
- }
180
- return null;
181
- }
182
- function findFirstAttribute(inputElm, attributes) {
183
- if (inputElm) {
184
- for (const attribute of attributes) {
185
- const attrData = inputElm.getAttribute(attribute);
186
- if (attrData) {
187
- return attrData;
188
- }
189
- }
190
- }
191
- return null;
192
- }
193
- /**
194
- * 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).
195
- * @param {Number|String} inputWidth - input width, could be a string or number
196
- * @param {Number | String} defaultValue [defaultValue=auto] - optional default value or use "auto" when nothing is provided
197
- * @returns {String} string output
198
- */
199
- function findWidthOrDefault(inputWidth, defaultValue = 'auto') {
200
- return (/^[0-9]+$/i.test(`${inputWidth}`) ? `${+inputWidth}px` : inputWidth) || defaultValue;
201
- }
202
- /**
203
- * HTML encode using a plain <div>
204
- * Create a in-memory div, set it's inner text(which a div can encode)
205
- * then grab the encoded contents back out. The div never exists on the page.
206
- * @param {String} inputValue - input value to be encoded
207
- * @return {String}
208
- */
209
- function htmlEncode(inputValue) {
210
- const val = typeof inputValue === 'string' ? inputValue : String(inputValue);
211
- const entityMap = {
212
- '&': '&amp;',
213
- '<': '&lt;',
214
- '>': '&gt;',
215
- '"': '&quot;',
216
- '\'': '&#39;',
217
- };
218
- return (val || '').toString().replace(/[&<>"']/g, (s) => entityMap[s]);
219
- }
220
- /**
221
- * Decode text into html entity
222
- * @param string text: input text
223
- * @param string text: output text
224
- */
225
- function htmlEntityDecode(input) {
226
- return input.replace(/&#(\d+);/g, (_match, dec) => {
227
- return String.fromCharCode(dec);
228
- });
229
- }
230
- /**
231
- * Encode string to html special char and add html space padding defined
232
- * @param {string} inputStr - input string
233
- * @param {number} paddingLength - padding to add
234
- */
235
- function htmlEncodeWithPadding(inputStr, paddingLength) {
236
- const inputStrLn = inputStr.length;
237
- let outputStr = htmlEncode(inputStr);
238
- if (inputStrLn < paddingLength) {
239
- for (let i = inputStrLn; i < paddingLength; i++) {
240
- outputStr += `&nbsp;`;
241
- }
242
- }
243
- return outputStr;
244
- }
245
- /** insert an HTML Element after a target Element in the DOM */
246
- function insertAfterElement(referenceNode, newNode) {
247
- referenceNode.parentNode?.insertBefore(newNode, referenceNode.nextSibling);
248
- }
249
- /**
250
- * Get the Window Scroll top/left Position
251
- * @returns
252
- */
253
- function windowScrollPosition() {
254
- return {
255
- left: window.pageXOffset || document.documentElement.scrollLeft || 0,
256
- top: window.pageYOffset || document.documentElement.scrollTop || 0,
257
- };
258
- }
259
- //# sourceMappingURL=domUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"domUtils.js","sourceRoot":"","sources":["../../src/domUtils.ts"],"names":[],"mappings":";;AAIA,0DAuBC;AAYD,4CAyBC;AASD,0CAEC;AAOD,wDAWC;AAMD,oCAKC;AAUD,kDAQC;AAGD,8DAiBC;AAGD,8BAmBC;AAED,oCAaC;AAGD,oCAKC;AAED,gDAUC;AAQD,gDAEC;AASD,gCAUC;AAOD,4CAIC;AAOD,sDAUC;AAGD,gDAEC;AAMD,oDAKC;AA7QD,iEAAiE;AACjE,SAAgB,uBAAuB,CAAC,OAAoB;IAC1D,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC;IAC3C,MAAM,cAAc,GAAG,oBAAoB,EAAE,CAAC;IAC9C,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC;IACzC,MAAM,cAAc,GAAG,cAAc,CAAC,IAAI,CAAC;IAC3C,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAErC,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,gBAAgB,GAAG,SAAS,CAAC,GAAG,CAAC;QACvC,MAAM,iBAAiB,GAAG,SAAS,CAAC,IAAI,CAAC;QACzC,GAAG,GAAG,gBAAgB,GAAG,aAAa,CAAC;QACvC,IAAI,GAAG,iBAAiB,GAAG,cAAc,CAAC;QAC1C,MAAM,GAAG,YAAY,GAA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AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,QAAgB,EAAE,aAAqB;IAC3E,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;IACnC,IAAI,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAErC,IAAI,UAAU,GAAG,aAAa,EAAE,CAAC;QAC/B,KAAK,IAAI,CAAC,GAAG,UAAU,EAAE,CAAC,GAAG,aAAa,EAAE,CAAC,EAAE,EAAE,CAAC;YAChD,SAAS,IAAI,QAAQ,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,+DAA+D;AAC/D,SAAgB,kBAAkB,CAAC,aAA0B,EAAE,OAAoB;IACjF,aAAa,CAAC,UAAU,EAAE,YAAY,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;AAC7E,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB;IAClC,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,WAAW,IAAI,QAAQ,CAAC,eAAe,CAAC,UAAU,IAAI,CAAC;QACpE,GAAG,EAAE,MAAM,CAAC,WAAW,IAAI,QAAQ,CAAC,eAAe,CAAC,SAAS,IAAI,CAAC;KACnE,CAAC;AACJ,CAAC"}
package/dist/cjs/index.js DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./domUtils.js"), exports);
18
- __exportStar(require("./nodeExtend.js"), exports);
19
- __exportStar(require("./stripTagsUtil.js"), exports);
20
- __exportStar(require("./utils.js"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,kDAAgC;AAChC,qDAAmC;AAGnC,6CAA2B"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=interfaces.js.map
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1,123 +0,0 @@
1
- "use strict";
2
- /**
3
- * This extend function is a reimplementation of the npm package `extend` (also named `node-extend`).
4
- * The reason for the reimplementation was mostly because the original project is not ESM compatible
5
- * and written with old ES6 IIFE syntax, the goal was to reimplement and fix these old syntax and build problems.
6
- * e.g. it used `var` everywhere, it used `arguments` to get function arguments, ...
7
- * See `jQuery.extend()` for multiple usage demos: https://api.jquery.com/jquery.extend/
8
- *
9
- * The previous lib can be found here at this Github link:
10
- * https://github.com/justmoon/node-extend
11
- * With an MIT licence that and can be found at
12
- * https://github.com/justmoon/node-extend/blob/main/LICENSE
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.extend = extend;
16
- const hasOwn = Object.prototype.hasOwnProperty;
17
- const toStr = Object.prototype.toString;
18
- const defineProperty = Object.defineProperty;
19
- const gOPD = Object.getOwnPropertyDescriptor;
20
- const isArray = function isArray(arr) {
21
- if (typeof Array.isArray === 'function') {
22
- return Array.isArray(arr);
23
- }
24
- /* v8 ignore next 2 */
25
- return toStr.call(arr) === '[object Array]';
26
- };
27
- const isPlainObject = function isPlainObject(obj) {
28
- if (!obj || toStr.call(obj) !== '[object Object]') {
29
- return false;
30
- }
31
- const hasOwnConstructor = hasOwn.call(obj, 'constructor');
32
- const hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
33
- // Not own constructor property must be Object
34
- if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
35
- return false;
36
- }
37
- // Own properties are enumerated firstly, so to speed up, if last one is own, then all properties are own.
38
- let key;
39
- for (key in obj) { /**/ }
40
- return typeof key === 'undefined' || hasOwn.call(obj, key);
41
- };
42
- // If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target
43
- const setProperty = function setProperty(target, options) {
44
- if (defineProperty && options.name === '__proto__') {
45
- defineProperty(target, options.name, {
46
- enumerable: true,
47
- configurable: true,
48
- value: options.newValue,
49
- writable: true
50
- });
51
- }
52
- else {
53
- target[options.name] = options.newValue;
54
- }
55
- };
56
- // Return undefined instead of __proto__ if '__proto__' is not an own property
57
- const getProperty = function getProperty(obj, name) {
58
- if (name === '__proto__') {
59
- if (!hasOwn.call(obj, name)) {
60
- return void 0;
61
- }
62
- else if (gOPD) {
63
- // In early versions of node, obj['__proto__'] is buggy when obj has __proto__ as an own property. Object.getOwnPropertyDescriptor() works.
64
- return gOPD(obj, name).value;
65
- }
66
- }
67
- return obj[name];
68
- };
69
- function extend(...args) {
70
- let options;
71
- let name;
72
- let src;
73
- let copy;
74
- let copyIsArray;
75
- let clone;
76
- let target = args[0];
77
- let i = 1;
78
- const length = args.length;
79
- let deep = false;
80
- // Handle a deep copy situation
81
- if (typeof target === 'boolean') {
82
- deep = target;
83
- target = args[1] || {};
84
- // skip the boolean and the target
85
- i = 2;
86
- }
87
- if (target === null || target === undefined || (typeof target !== 'object' && typeof target !== 'function')) {
88
- target = {};
89
- }
90
- for (; i < length; ++i) {
91
- options = args[i];
92
- // Only deal with non-null/undefined values
93
- if (options !== null && options !== undefined) {
94
- // Extend the base object
95
- for (name in options) {
96
- src = getProperty(target, name);
97
- copy = getProperty(options, name);
98
- // Prevent never-ending loop
99
- if (target !== copy) {
100
- // Recurse if we're merging plain objects or arrays
101
- if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
102
- if (copyIsArray) {
103
- copyIsArray = false;
104
- clone = src && isArray(src) ? src : [];
105
- }
106
- else {
107
- clone = src && isPlainObject(src) ? src : {};
108
- }
109
- // Never move original objects, clone them
110
- setProperty(target, { name, newValue: extend(deep, clone, copy) });
111
- // Don't bring in undefined values
112
- }
113
- else if (typeof copy !== 'undefined') {
114
- setProperty(target, { name, newValue: copy });
115
- }
116
- }
117
- }
118
- }
119
- }
120
- // Return the modified object
121
- return target;
122
- }
123
- //# sourceMappingURL=nodeExtend.js.map