tiny-essentials 1.22.10 → 1.22.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.
@@ -815,6 +815,8 @@ class TinyHtml {
815
815
  }
816
816
 
817
817
  /**
818
+ * @deprecated Use the {@link createFromHTML} instead.
819
+ *
818
820
  * Creates an HTMLElement or TextNode from an HTML string.
819
821
  * Supports both elements and plain text.
820
822
  *
@@ -836,6 +838,24 @@ class TinyHtml {
836
838
  return new TinyHtml(template.content.firstChild);
837
839
  }
838
840
 
841
+ /**
842
+ * Creates an HTMLElement or TextNode from an HTML string.
843
+ * Supports both elements and plain text.
844
+ *
845
+ * @param {string} htmlString - The HTML string to convert.
846
+ * @returns {TinyHtml<Element>} - A single HTMLElement or TextNode.
847
+ */
848
+ static createFromHTML(htmlString) {
849
+ const template = document.createElement('template');
850
+ htmlString = htmlString.trim();
851
+
852
+ template.innerHTML = htmlString;
853
+ const elems = Array.from(template.content.childNodes);
854
+ if (!elems.every((item) => item instanceof Element || item instanceof Text))
855
+ throw new Error('The HTML string must contain a valid HTML element.');
856
+ return new TinyHtml(elems);
857
+ }
858
+
839
859
  ///////////////////////////////////////////////////
840
860
  // TITLE: Query Script
841
861
 
@@ -2164,7 +2184,7 @@ class TinyHtml {
2164
2184
  if (typeof item === 'undefined' || item === null || item === false) continue;
2165
2185
  if (typeof item !== 'string' && typeof item !== 'number') {
2166
2186
  if (item instanceof Node || item instanceof TinyHtml)
2167
- results.push(TinyHtml._preNodeElems(item, where)[0]);
2187
+ results.push(...TinyHtml._preNodeElems(item, where));
2168
2188
  else if (Array.isArray(item)) results.push(...TinyHtml._appendChecker(where, ...item));
2169
2189
  else {
2170
2190
  for (const name in item) {
@@ -473,6 +473,8 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
473
473
  */
474
474
  static createTextNode(value: string): TinyHtml<Text>;
475
475
  /**
476
+ * @deprecated Use the {@link createFromHTML} instead.
477
+ *
476
478
  * Creates an HTMLElement or TextNode from an HTML string.
477
479
  * Supports both elements and plain text.
478
480
  *
@@ -480,6 +482,14 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
480
482
  * @returns {TinyHtml<Element>} - A single HTMLElement or TextNode.
481
483
  */
482
484
  static createElementFromHTML(htmlString: string): TinyHtml<Element>;
485
+ /**
486
+ * Creates an HTMLElement or TextNode from an HTML string.
487
+ * Supports both elements and plain text.
488
+ *
489
+ * @param {string} htmlString - The HTML string to convert.
490
+ * @returns {TinyHtml<Element>} - A single HTMLElement or TextNode.
491
+ */
492
+ static createFromHTML(htmlString: string): TinyHtml<Element>;
483
493
  /**
484
494
  * Queries the document for the first element matching the CSS selector and wraps it in a TinyHtml instance.
485
495
  *
@@ -702,6 +702,8 @@ class TinyHtml {
702
702
  return new TinyHtml(document.createTextNode(value));
703
703
  }
704
704
  /**
705
+ * @deprecated Use the {@link createFromHTML} instead.
706
+ *
705
707
  * Creates an HTMLElement or TextNode from an HTML string.
706
708
  * Supports both elements and plain text.
707
709
  *
@@ -720,6 +722,22 @@ class TinyHtml {
720
722
  throw new Error('The HTML string must contain a valid HTML element.');
721
723
  return new TinyHtml(template.content.firstChild);
722
724
  }
725
+ /**
726
+ * Creates an HTMLElement or TextNode from an HTML string.
727
+ * Supports both elements and plain text.
728
+ *
729
+ * @param {string} htmlString - The HTML string to convert.
730
+ * @returns {TinyHtml<Element>} - A single HTMLElement or TextNode.
731
+ */
732
+ static createFromHTML(htmlString) {
733
+ const template = document.createElement('template');
734
+ htmlString = htmlString.trim();
735
+ template.innerHTML = htmlString;
736
+ const elems = Array.from(template.content.childNodes);
737
+ if (!elems.every((item) => item instanceof Element || item instanceof Text))
738
+ throw new Error('The HTML string must contain a valid HTML element.');
739
+ return new TinyHtml(elems);
740
+ }
723
741
  ///////////////////////////////////////////////////
724
742
  // TITLE: Query Script
725
743
  /**
@@ -1889,7 +1907,7 @@ class TinyHtml {
1889
1907
  continue;
1890
1908
  if (typeof item !== 'string' && typeof item !== 'number') {
1891
1909
  if (item instanceof Node || item instanceof TinyHtml)
1892
- results.push(TinyHtml._preNodeElems(item, where)[0]);
1910
+ results.push(...TinyHtml._preNodeElems(item, where));
1893
1911
  else if (Array.isArray(item))
1894
1912
  results.push(...TinyHtml._appendChecker(where, ...item));
1895
1913
  else {
@@ -702,16 +702,16 @@ This method is useful when you want to insert raw text content into the DOM with
702
702
 
703
703
  ---
704
704
 
705
- ### `TinyHtml.createElementFromHTML(htmlString)`
705
+ ### `TinyHtml.createFromHTML(htmlString)`
706
706
 
707
- Creates an `HTMLElement` or `TextNode` from an HTML string.
707
+ Creates an `HTMLElement` from an HTML string.
708
708
  Supports both elements and plain text.
709
709
 
710
710
  * **Parameters**:
711
711
 
712
712
  * `htmlString` *(string)* — The HTML string to convert.
713
713
 
714
- * **Returns**: `TinyHtml` — A `TinyHtml` instance wrapping the resulting `HTMLElement` or `TextNode`.
714
+ * **Returns**: `TinyHtml` — A `TinyHtml` instance wrapping the resulting `HTMLElement`.
715
715
 
716
716
  * **Throws**:
717
717
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-essentials",
3
- "version": "1.22.10",
3
+ "version": "1.22.11",
4
4
  "description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
5
5
  "scripts": {
6
6
  "test": "npm run test:mjs && npm run test:cjs && npm run test:js",
@@ -38,6 +38,10 @@
38
38
  "types": "./dist/v1/index.d.mts",
39
39
  "ethereum": "jasmindreasond.x",
40
40
  "exports": {
41
+ "./css/aiMarker.min.css": "./dist/v1/css/aiMarker.min.css",
42
+ "./css/TinyCookieConsent.min.css": "./dist/v1/css/TinyCookieConsent.min.css",
43
+ "./css/TinyDraggerExample.min.css": "./dist/v1/css/TinyDraggerExample.min.css",
44
+ "./css/TinyNotify.min.css": "./dist/v1/css/TinyNotify.min.css",
41
45
  ".": {
42
46
  "require": "./dist/v1/index.cjs",
43
47
  "import": "./dist/v1/index.mjs"