tiny-essentials 1.19.3 → 1.20.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.
Files changed (57) hide show
  1. package/dist/v1/TinyBasicsEs.min.js +1 -1
  2. package/dist/v1/TinyDragger.min.js +1 -1
  3. package/dist/v1/TinyEssentials.min.js +1 -1
  4. package/dist/v1/TinyHtml.min.js +1 -1
  5. package/dist/v1/TinyIframeEvents.min.js +1 -0
  6. package/dist/v1/TinyNewWinEvents.min.js +1 -0
  7. package/dist/v1/TinySmartScroller.min.js +1 -1
  8. package/dist/v1/TinyUploadClicker.min.js +1 -1
  9. package/dist/v1/build/TinyIframeEvents.cjs +7 -0
  10. package/dist/v1/build/TinyIframeEvents.d.mts +3 -0
  11. package/dist/v1/build/TinyIframeEvents.mjs +2 -0
  12. package/dist/v1/build/TinyNewWinEvents.cjs +7 -0
  13. package/dist/v1/build/TinyNewWinEvents.d.mts +3 -0
  14. package/dist/v1/build/TinyNewWinEvents.mjs +2 -0
  15. package/dist/v1/index.cjs +4 -0
  16. package/dist/v1/index.d.mts +3 -1
  17. package/dist/v1/index.mjs +3 -1
  18. package/dist/v1/libs/TinyDragger.cjs +1 -1
  19. package/dist/v1/libs/TinyDragger.mjs +1 -1
  20. package/dist/v1/libs/TinyHtml.cjs +292 -103
  21. package/dist/v1/libs/TinyHtml.d.mts +142 -39
  22. package/dist/v1/libs/TinyHtml.mjs +266 -94
  23. package/dist/v1/libs/TinyIframeEvents.cjs +410 -0
  24. package/dist/v1/libs/TinyIframeEvents.d.mts +193 -0
  25. package/dist/v1/libs/TinyIframeEvents.mjs +348 -0
  26. package/dist/v1/libs/TinyNewWinEvents.cjs +488 -0
  27. package/dist/v1/libs/TinyNewWinEvents.d.mts +241 -0
  28. package/dist/v1/libs/TinyNewWinEvents.mjs +437 -0
  29. package/docs/v1/README.md +2 -0
  30. package/docs/v1/libs/TinyHtml.md +128 -6
  31. package/docs/v1/libs/TinyIframeEvents.md +149 -0
  32. package/docs/v1/libs/TinyNewWinEvents.md +186 -0
  33. package/docs/v1/libs/TinyNotifyCenter.md +1 -1
  34. package/package.json +1 -1
  35. package/dist/v1/ColorSafeStringify.js +0 -235
  36. package/dist/v1/TinyAfterScrollWatcher.js +0 -219
  37. package/dist/v1/TinyBasicsEs.js +0 -9334
  38. package/dist/v1/TinyClipboard.js +0 -459
  39. package/dist/v1/TinyColorConverter.js +0 -617
  40. package/dist/v1/TinyDomReadyManager.js +0 -213
  41. package/dist/v1/TinyDragDropDetector.js +0 -307
  42. package/dist/v1/TinyDragger.js +0 -6569
  43. package/dist/v1/TinyEssentials.js +0 -19893
  44. package/dist/v1/TinyEvents.js +0 -402
  45. package/dist/v1/TinyHtml.js +0 -5545
  46. package/dist/v1/TinyLevelUp.js +0 -291
  47. package/dist/v1/TinyLocalStorage.js +0 -1440
  48. package/dist/v1/TinyNotifications.js +0 -408
  49. package/dist/v1/TinyNotifyCenter.js +0 -493
  50. package/dist/v1/TinyPromiseQueue.js +0 -299
  51. package/dist/v1/TinyRateLimiter.js +0 -611
  52. package/dist/v1/TinySmartScroller.js +0 -7039
  53. package/dist/v1/TinyTextRangeEditor.js +0 -497
  54. package/dist/v1/TinyTimeout.js +0 -233
  55. package/dist/v1/TinyToastNotify.js +0 -441
  56. package/dist/v1/TinyUploadClicker.js +0 -13456
  57. package/dist/v1/UltraRandomMsgGen.js +0 -995
@@ -277,15 +277,31 @@ declare class TinyHtml {
277
277
  y: number;
278
278
  };
279
279
  };
280
+ /**
281
+ * Creates a new TinyHtml element from a tag name and optional attributes.
282
+ *
283
+ * You can alias this method for convenience:
284
+ * ```js
285
+ * const createElement = TinyHtml.createFrom;
286
+ * const myDiv = createElement('div', { class: 'box' });
287
+ * ```
288
+ *
289
+ * @param {string} tagName - The HTML tag name (e.g., 'div', 'span', 'button').
290
+ * @param {Record<string, string|null>} [attrs] - Optional key-value pairs representing HTML attributes.
291
+ * If the value is `null`, the attribute will still be set with an empty value.
292
+ * @returns {TinyHtml} - A new instance of TinyHtml representing the created element.
293
+ * @throws {TypeError} - If `tagName` is not a string, or `attrs` is not a plain object when defined.
294
+ */
295
+ static createFrom(tagName: string, attrs?: Record<string, string | null>): TinyHtml;
280
296
  /**
281
297
  * Creates a new DOM element with the specified tag name and options, then wraps it in a TinyHtml instance.
282
298
  *
283
299
  * @param {string} tagName - The tag name of the element to create (e.g., 'div', 'span').
284
- * @param {ElementCreationOptions} ops - Optional settings for creating the element.
300
+ * @param {ElementCreationOptions} [ops] - Optional settings for creating the element.
285
301
  * @returns {TinyHtml} A TinyHtml instance wrapping the newly created DOM element.
286
302
  * @throws {TypeError} If tagName is not a string or ops is not an object.
287
303
  */
288
- static createElement(tagName: string, ops: ElementCreationOptions): TinyHtml;
304
+ static createElement(tagName: string, ops?: ElementCreationOptions): TinyHtml;
289
305
  /**
290
306
  * Creates a new TinyHtml instance that wraps a DOM TextNode.
291
307
  *
@@ -319,9 +335,9 @@ declare class TinyHtml {
319
335
  *
320
336
  * @param {string} selector - A valid CSS selector string.
321
337
  * @param {Document|Element} elem - Target element.
322
- * @returns {TinyHtml[]} An array of TinyHtml instances wrapping the matched elements.
338
+ * @returns {TinyHtml} An array of TinyHtml instances wrapping the matched elements.
323
339
  */
324
- static queryAll(selector: string, elem?: Document | Element): TinyHtml[];
340
+ static queryAll(selector: string, elem?: Document | Element): TinyHtml;
325
341
  /**
326
342
  * Retrieves an element by its ID and wraps it in a TinyHtml instance.
327
343
  *
@@ -334,16 +350,16 @@ declare class TinyHtml {
334
350
  *
335
351
  * @param {string} selector - The class name to search for.
336
352
  * @param {Document|Element} elem - Target element.
337
- * @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
353
+ * @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
338
354
  */
339
- static getByClassName(selector: string, elem?: Document | Element): TinyHtml[];
355
+ static getByClassName(selector: string, elem?: Document | Element): TinyHtml;
340
356
  /**
341
357
  * Retrieves all elements with the specified name attribute and wraps them in TinyHtml instances.
342
358
  *
343
359
  * @param {string} selector - The name attribute to search for.
344
- * @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
360
+ * @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
345
361
  */
346
- static getByName(selector: string): TinyHtml[];
362
+ static getByName(selector: string): TinyHtml;
347
363
  /**
348
364
  * Retrieves all elements with the specified local tag name within the given namespace URI,
349
365
  * and wraps them in TinyHtml instances.
@@ -351,25 +367,31 @@ declare class TinyHtml {
351
367
  * @param {string} localName - The local name (tag) of the elements to search for.
352
368
  * @param {string|null} [namespaceURI='http://www.w3.org/1999/xhtml'] - The namespace URI to search within.
353
369
  * @param {Document|Element} elem - Target element.
354
- * @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
370
+ * @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
355
371
  */
356
- static getByTagNameNS(localName: string, namespaceURI?: string | null, elem?: Document | Element): TinyHtml[];
372
+ static getByTagNameNS(localName: string, namespaceURI?: string | null, elem?: Document | Element): TinyHtml;
357
373
  /**
358
- * @param {TinyElement|EventTarget|null|(TinyElement|EventTarget|null)[]} elems
359
- * @param {string} where
360
- * @param {any[]} TheTinyElements
361
- * @param {string[]} elemName
362
- * @returns {any[]}
374
+ * Prepares and validates multiple elements against allowed types.
375
+ *
376
+ * @param {TinyElement | EventTarget | null | (TinyElement | EventTarget | null)[]} elems - The input elements to validate.
377
+ * @param {string} where - The method name or context calling this.
378
+ * @param {any[]} TheTinyElements - The list of allowed constructors (e.g., Element, Document).
379
+ * @param {string[]} elemName - The list of expected element names for error reporting.
380
+ * @returns {any[]} - A flat array of validated elements.
381
+ * @throws {Error} - If any element is not an instance of one of the allowed types.
363
382
  * @readonly
364
383
  */
365
384
  static readonly _preElemsTemplate(elems: TinyElement | EventTarget | null | (TinyElement | EventTarget | null)[], where: string, TheTinyElements: any[], elemName: string[]): any[];
366
385
  /**
367
- * @param {TinyElement|EventTarget|null|(TinyElement|EventTarget|null)[]} elems
368
- * @param {string} where
369
- * @param {any[]} TheTinyElements
370
- * @param {string[]} elemName
371
- * @param {boolean} [canNull=false]
372
- * @returns {any}
386
+ * Prepares and validates a single element against allowed types.
387
+ *
388
+ * @param {TinyElement | EventTarget | null | (TinyElement | EventTarget | null)[]} elems - The input element or list to validate.
389
+ * @param {string} where - The method name or context calling this.
390
+ * @param {any[]} TheTinyElements - The list of allowed constructors (e.g., Element, Document).
391
+ * @param {string[]} elemName - The list of expected element names for error reporting.
392
+ * @param {boolean} [canNull=false] - Whether `null` is allowed as a valid value.
393
+ * @returns {any} - The validated element or `null` if allowed.
394
+ * @throws {Error} - If the element is not valid or if multiple elements are provided.
373
395
  * @readonly
374
396
  */
375
397
  static readonly _preElemTemplate(elems: TinyElement | EventTarget | null | (TinyElement | EventTarget | null)[], where: string, TheTinyElements: any[], elemName: string[], canNull?: boolean): any;
@@ -941,9 +963,21 @@ declare class TinyHtml {
941
963
  * @type {Record<string | symbol, string>}
942
964
  */
943
965
  static "__#6@#cssPropAliases": Record<string | symbol, string>;
944
- /** @type {Record<string | symbol, string>} */
966
+ /**
967
+ * Public proxy to manage camelCase ➝ kebab-case CSS property aliasing.
968
+ *
969
+ * Modifying this object ensures that the reverse mapping in `cssPropRevAliases` is updated accordingly.
970
+ *
971
+ * @type {Record<string | symbol, string>}
972
+ */
945
973
  static cssPropAliases: Record<string | symbol, string>;
946
- /** @type {Record<string | symbol, string>} */
974
+ /**
975
+ * Reverse map of `cssPropAliases`, mapping kebab-case back to camelCase CSS property names.
976
+ *
977
+ * This enables consistent bidirectional lookups of style properties.
978
+ *
979
+ * @type {Record<string | symbol, string>}
980
+ */
947
981
  static cssPropRevAliases: Record<string | symbol, string>;
948
982
  /**
949
983
  * Converts a camelCase string to kebab-case
@@ -1629,13 +1663,52 @@ declare class TinyHtml {
1629
1663
  */
1630
1664
  static trigger(el: TinyEventTarget | TinyEventTarget[], event: string, payload?: Event | CustomEvent | CustomEventInit): TinyEventTarget | TinyEventTarget[];
1631
1665
  /**
1632
- * Property name normalization similar to jQuery's propFix.
1633
- * @readonly
1666
+ * Internal property name normalization map (similar to jQuery's `propFix`).
1667
+ * Maps attribute-like names to their JavaScript DOM property equivalents.
1668
+ *
1669
+ * Example: `'for'` ➝ `'htmlFor'`, `'class'` ➝ `'className'`.
1670
+ *
1671
+ * ⚠️ Do not modify this object directly. Use `TinyHtml.propFix` to ensure reverse mapping (`attrFix`) remains in sync.
1672
+ *
1673
+ * @type {Record<string | symbol, string>}
1634
1674
  */
1635
- static readonly _propFix: {
1636
- for: string;
1637
- class: string;
1638
- };
1675
+ static "__#6@#propFix": Record<string | symbol, string>;
1676
+ /**
1677
+ * Public proxy for normalized DOM property names.
1678
+ *
1679
+ * Setting a new entry here will also automatically update the reverse map in `TinyHtml.attrFix`.
1680
+ *
1681
+ * @type {Record<string | symbol, string>}
1682
+ */
1683
+ static propFix: Record<string | symbol, string>;
1684
+ /**
1685
+ * Reverse map of `propFix`, mapping property names back to their attribute equivalents.
1686
+ *
1687
+ * Used when converting DOM property names into HTML attribute names.
1688
+ *
1689
+ * @type {Record<string | symbol, string>}
1690
+ */
1691
+ static attrFix: Record<string | symbol, string>;
1692
+ /**
1693
+ * Normalizes an attribute name to its corresponding DOM property name.
1694
+ *
1695
+ * Example: `'class'` ➝ `'className'`, `'for'` ➝ `'htmlFor'`.
1696
+ * If the name is not mapped, it returns the original name.
1697
+ *
1698
+ * @param {string} name - The attribute name to normalize.
1699
+ * @returns {string} - The corresponding property name.
1700
+ */
1701
+ static getPropName(name: string): string;
1702
+ /**
1703
+ * Converts a DOM property name back to its corresponding attribute name.
1704
+ *
1705
+ * Example: `'className'` ➝ `'class'`, `'htmlFor'` ➝ `'for'`.
1706
+ * If the name is not mapped, it returns the original name.
1707
+ *
1708
+ * @param {string} name - The property name to convert.
1709
+ * @returns {string} - The corresponding attribute name.
1710
+ */
1711
+ static getAttrName(name: string): string;
1639
1712
  /**
1640
1713
  * Get an attribute on an element.
1641
1714
  * @param {TinyElement} el
@@ -1833,9 +1906,9 @@ declare class TinyHtml {
1833
1906
  /**
1834
1907
  * Creates an instance of TinyHtml for a specific Element.
1835
1908
  * Useful when you want to operate repeatedly on the same element using instance methods.
1836
- * @param {ConstructorElValues} el - The element to wrap and manipulate.
1909
+ * @param {ConstructorElValues|ConstructorElValues[]|NodeListOf<Element>|HTMLCollectionOf<Element>|NodeListOf<HTMLElement>} el - The element to wrap and manipulate.
1837
1910
  */
1838
- constructor(el: ConstructorElValues);
1911
+ constructor(el: ConstructorElValues | ConstructorElValues[] | NodeListOf<Element> | HTMLCollectionOf<Element> | NodeListOf<HTMLElement>);
1839
1912
  /**
1840
1913
  * Queries the element for the first element matching the CSS selector and wraps it in a TinyHtml instance.
1841
1914
  *
@@ -1847,39 +1920,69 @@ declare class TinyHtml {
1847
1920
  * Queries the element for all elements matching the CSS selector and wraps them in TinyHtml instances.
1848
1921
  *
1849
1922
  * @param {string} selector - A valid CSS selector string.
1850
- * @returns {TinyHtml[]} An array of TinyHtml instances wrapping the matched elements.
1923
+ * @returns {TinyHtml} An array of TinyHtml instances wrapping the matched elements.
1851
1924
  */
1852
- querySelectorAll(selector: string): TinyHtml[];
1925
+ querySelectorAll(selector: string): TinyHtml;
1853
1926
  /**
1854
1927
  * Retrieves all elements with the specified class name and wraps them in TinyHtml instances.
1855
1928
  *
1856
1929
  * @param {string} selector - The class name to search for.
1857
- * @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
1930
+ * @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
1858
1931
  */
1859
- getElementsByClassName(selector: string): TinyHtml[];
1932
+ getElementsByClassName(selector: string): TinyHtml;
1860
1933
  /**
1861
1934
  * Retrieves all elements with the specified local tag name within the given namespace URI,
1862
1935
  * and wraps them in TinyHtml instances.
1863
1936
  *
1864
1937
  * @param {string} localName - The local name (tag) of the elements to search for.
1865
1938
  * @param {string|null} [namespaceURI='http://www.w3.org/1999/xhtml'] - The namespace URI to search within.
1866
- * @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
1939
+ * @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
1867
1940
  */
1868
- getElementsByTagNameNS(localName: string, namespaceURI?: string | null): TinyHtml[];
1941
+ getElementsByTagNameNS(localName: string, namespaceURI?: string | null): TinyHtml;
1869
1942
  /**
1870
1943
  * Returns the current target held by this instance.
1871
1944
  *
1945
+ * @param {number} index - The index of the element to retrieve.
1872
1946
  * @returns {ConstructorElValues} - The instance's target element.
1873
1947
  */
1874
- get(): ConstructorElValues;
1948
+ get(index: number): ConstructorElValues;
1949
+ /**
1950
+ * Extracts a single DOM element from the internal list at the specified index.
1951
+ *
1952
+ * @param {number} index - The index of the element to extract.
1953
+ * @returns {TinyHtml} A new TinyHtml instance wrapping the extracted element.
1954
+ */
1955
+ extract(index: number): TinyHtml;
1956
+ /**
1957
+ * Checks whether the element exists at the given index.
1958
+ *
1959
+ * @param {number} index - The index to check.
1960
+ * @returns {boolean} - True if the element exists; otherwise, false.
1961
+ */
1962
+ exists(index: number): boolean;
1963
+ /**
1964
+ * Returns the current targets held by this instance.
1965
+ *
1966
+ * @returns {ConstructorElValues[]} - The instance's targets element.
1967
+ */
1968
+ getAll(): ConstructorElValues[];
1875
1969
  /**
1876
1970
  * Returns the current Element held by this instance.
1877
1971
  *
1878
1972
  * @param {string} where - The method name or context calling this.
1973
+ * @param {number} index - The index of the element to retrieve.
1879
1974
  * @returns {ConstructorElValues} - The instance's element.
1880
1975
  * @readonly
1881
1976
  */
1882
- readonly _getElement(where: string): ConstructorElValues;
1977
+ readonly _getElement(where: string, index: number): ConstructorElValues;
1978
+ /**
1979
+ * Returns the current Elements held by this instance.
1980
+ *
1981
+ * @param {string} where - The method name or context calling this.
1982
+ * @returns {ConstructorElValues[]} - The instance's elements.
1983
+ * @readonly
1984
+ */
1985
+ readonly _getElements(where: string): ConstructorElValues[];
1883
1986
  /**
1884
1987
  * Returns only the elements **not** matching the given selector or function.
1885
1988
  *