tiny-essentials 1.28.1 → 1.28.3

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 (218) hide show
  1. package/changelog/1/28/2.md +43 -0
  2. package/changelog/1/28/3.md +9 -0
  3. package/dist/_/numbers.d.mts +91 -16
  4. package/dist/v1/TinyBasicsEs.min.js +1 -1
  5. package/dist/v1/TinyEssentials.min.js +1 -1
  6. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  7. package/dist/v1/TinyRadioFm.min.js +1 -1
  8. package/dist/v1/basics/array.d.mts +14 -14
  9. package/dist/v1/basics/clock.cjs +15 -15
  10. package/dist/v1/basics/clock.d.mts +21 -21
  11. package/dist/v1/basics/clock.mjs +15 -15
  12. package/dist/v1/basics/collision.d.mts +245 -104
  13. package/dist/v1/basics/deprecated/html.d.mts +33 -33
  14. package/dist/v1/basics/extendObjType/Buffer.d.mts +1 -1
  15. package/dist/v1/basics/fullScreen.d.mts +47 -7
  16. package/dist/v1/basics/html.d.mts +52 -61
  17. package/dist/v1/basics/index.cjs +2 -0
  18. package/dist/v1/basics/index.d.mts +11 -67
  19. package/dist/v1/basics/index.mjs +2 -2
  20. package/dist/v1/basics/mediaContent.cjs +65 -23
  21. package/dist/v1/basics/mediaContent.d.mts +144 -73
  22. package/dist/v1/basics/mediaContent.mjs +65 -23
  23. package/dist/v1/basics/objChecker.d.mts +2 -2
  24. package/dist/v1/basics/objFilter.cjs +50 -16
  25. package/dist/v1/basics/objFilter.d.mts +34 -13
  26. package/dist/v1/basics/objFilter.mjs +48 -16
  27. package/dist/v1/basics/simpleMath.d.mts +21 -21
  28. package/dist/v1/basics/text.d.mts +34 -46
  29. package/dist/v1/build/ColorSafeStringify.d.mts +1 -1
  30. package/dist/v1/build/TinyAdvancedRaffle.d.mts +1 -1
  31. package/dist/v1/build/TinyAfterScrollWatcher.d.mts +1 -1
  32. package/dist/v1/build/TinyAnalogClock.d.mts +1 -1
  33. package/dist/v1/build/TinyArrayComparator.d.mts +1 -1
  34. package/dist/v1/build/TinyArrayPaginator.d.mts +1 -1
  35. package/dist/v1/build/TinyClassManager.d.mts +1 -1
  36. package/dist/v1/build/TinyClipboard.d.mts +1 -1
  37. package/dist/v1/build/TinyColorConverter.d.mts +1 -1
  38. package/dist/v1/build/TinyColorValidator.d.mts +1 -1
  39. package/dist/v1/build/TinyCookieConsent.d.mts +1 -1
  40. package/dist/v1/build/TinyDayNightCycle.d.mts +1 -1
  41. package/dist/v1/build/TinyDomReadyManager.d.mts +1 -1
  42. package/dist/v1/build/TinyDragDropDetector.d.mts +1 -1
  43. package/dist/v1/build/TinyDragger.d.mts +1 -1
  44. package/dist/v1/build/TinyElementObserver.d.mts +1 -1
  45. package/dist/v1/build/TinyGamepad.d.mts +1 -1
  46. package/dist/v1/build/TinyHtml.d.mts +1 -1
  47. package/dist/v1/build/TinyI18.d.mts +1 -1
  48. package/dist/v1/build/TinyIframeEvents.d.mts +1 -1
  49. package/dist/v1/build/TinyInventory.d.mts +1 -1
  50. package/dist/v1/build/TinyInventoryTrader.d.mts +1 -1
  51. package/dist/v1/build/TinyLevelUp.d.mts +1 -1
  52. package/dist/v1/build/TinyLoadingScreen.d.mts +1 -1
  53. package/dist/v1/build/TinyLocalStorage.d.mts +1 -1
  54. package/dist/v1/build/TinyMediaPlayer.d.mts +1 -1
  55. package/dist/v1/build/TinyNeedBar.d.mts +1 -1
  56. package/dist/v1/build/TinyNewWinEvents.d.mts +1 -1
  57. package/dist/v1/build/TinyNotifications.d.mts +1 -1
  58. package/dist/v1/build/TinyNotifyCenter.d.mts +1 -1
  59. package/dist/v1/build/TinyPromiseQueue.d.mts +1 -1
  60. package/dist/v1/build/TinyRadioFm.d.mts +1 -1
  61. package/dist/v1/build/TinyRateLimiter.d.mts +1 -1
  62. package/dist/v1/build/TinySimpleDice.d.mts +1 -1
  63. package/dist/v1/build/TinySmartScroller.d.mts +1 -1
  64. package/dist/v1/build/TinyTextDiffer.d.mts +1 -1
  65. package/dist/v1/build/TinyTextRangeEditor.d.mts +1 -1
  66. package/dist/v1/build/TinyTextarea.d.mts +1 -1
  67. package/dist/v1/build/TinyTimeout.d.mts +1 -1
  68. package/dist/v1/build/TinyToastNotify.d.mts +1 -1
  69. package/dist/v1/build/TinyUploadClicker.d.mts +1 -1
  70. package/dist/v1/build/UltraRandomMsgGen.d.mts +1 -1
  71. package/dist/v1/fileManager/asyncFuncs.d.mts +13 -13
  72. package/dist/v1/fileManager/index.d.mts +3 -29
  73. package/dist/v1/fileManager/normalFuncs.d.mts +22 -22
  74. package/dist/v1/index.cjs +2 -0
  75. package/dist/v1/index.d.mts +53 -139
  76. package/dist/v1/index.mjs +2 -2
  77. package/dist/v1/libs/ColorSafeStringify.d.mts +3 -12
  78. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +60 -103
  79. package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +11 -18
  80. package/dist/v1/libs/TinyAnalogClock.d.mts +8 -11
  81. package/dist/v1/libs/TinyArrayComparator.d.mts +14 -20
  82. package/dist/v1/libs/TinyArrayPaginator.d.mts +22 -26
  83. package/dist/v1/libs/TinyClassManager/TinyPluginInliner.d.mts +8 -8
  84. package/dist/v1/libs/TinyClassManager.cjs +5 -7
  85. package/dist/v1/libs/TinyClassManager.d.mts +16 -16
  86. package/dist/v1/libs/TinyClassManager.mjs +5 -6
  87. package/dist/v1/libs/TinyClipboard.d.mts +8 -3
  88. package/dist/v1/libs/TinyColorConverter.d.mts +8 -31
  89. package/dist/v1/libs/TinyColorValidator.d.mts +145 -184
  90. package/dist/v1/libs/TinyCookieConsent.d.mts +17 -17
  91. package/dist/v1/libs/TinyDayNightCycle.d.mts +85 -110
  92. package/dist/v1/libs/TinyDomReadyManager.d.mts +8 -16
  93. package/dist/v1/libs/TinyDragDropDetector.d.mts +30 -30
  94. package/dist/v1/libs/TinyDragger.d.mts +82 -81
  95. package/dist/v1/libs/TinyElementObserver.d.mts +25 -28
  96. package/dist/v1/libs/TinyGamepad.cjs +0 -1
  97. package/dist/v1/libs/TinyGamepad.d.mts +50 -122
  98. package/dist/v1/libs/TinyGamepad.mjs +0 -1
  99. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.cjs +2 -25
  100. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.d.mts +19 -25
  101. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.mjs +3 -27
  102. package/dist/v1/libs/TinyHtml/TinyHtmlButton.cjs +2 -1
  103. package/dist/v1/libs/TinyHtml/TinyHtmlButton.d.mts +55 -55
  104. package/dist/v1/libs/TinyHtml/TinyHtmlButton.mjs +2 -1
  105. package/dist/v1/libs/TinyHtml/TinyHtmlCanvas.d.mts +6 -6
  106. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.cjs +8 -4
  107. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.d.mts +19 -21
  108. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.mjs +7 -4
  109. package/dist/v1/libs/TinyHtml/TinyHtmlEmbed.d.mts +8 -8
  110. package/dist/v1/libs/TinyHtml/TinyHtmlForm.d.mts +18 -18
  111. package/dist/v1/libs/TinyHtml/TinyHtmlIcon.d.mts +5 -6
  112. package/dist/v1/libs/TinyHtml/TinyHtmlIframe.d.mts +19 -19
  113. package/dist/v1/libs/TinyHtml/TinyHtmlImage.cjs +0 -28
  114. package/dist/v1/libs/TinyHtml/TinyHtmlImage.d.mts +22 -28
  115. package/dist/v1/libs/TinyHtml/TinyHtmlImage.mjs +1 -27
  116. package/dist/v1/libs/TinyHtml/TinyHtmlInput.d.mts +11 -11
  117. package/dist/v1/libs/TinyHtml/TinyHtmlLink.d.mts +23 -23
  118. package/dist/v1/libs/TinyHtml/TinyHtmlMedia.d.mts +26 -26
  119. package/dist/v1/libs/TinyHtml/TinyHtmlScript.cjs +4 -30
  120. package/dist/v1/libs/TinyHtml/TinyHtmlScript.d.mts +20 -26
  121. package/dist/v1/libs/TinyHtml/TinyHtmlScript.mjs +5 -32
  122. package/dist/v1/libs/TinyHtml/TinyHtmlSelect.d.mts +19 -19
  123. package/dist/v1/libs/TinyHtml/TinyHtmlStyle.d.mts +8 -8
  124. package/dist/v1/libs/TinyHtml/TinyHtmlTemplate.d.mts +26 -28
  125. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.cjs +14 -15
  126. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.d.mts +32 -32
  127. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.mjs +15 -15
  128. package/dist/v1/libs/TinyHtml/index.d.mts +102 -45
  129. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.cjs +11 -9
  130. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.d.mts +21 -21
  131. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.mjs +11 -9
  132. package/dist/v1/libs/TinyHtml/input/TinyHtmlFileInput.d.mts +11 -11
  133. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.cjs +4 -4
  134. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.d.mts +17 -13
  135. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.mjs +4 -4
  136. package/dist/v1/libs/TinyHtml/input/TinyHtmlImageInput.d.mts +21 -21
  137. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.cjs +5 -4
  138. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.d.mts +14 -14
  139. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.mjs +5 -4
  140. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.cjs +4 -3
  141. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.d.mts +10 -10
  142. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.mjs +4 -3
  143. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.cjs +4 -3
  144. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.d.mts +19 -19
  145. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.mjs +4 -3
  146. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.cjs +5 -4
  147. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.d.mts +11 -11
  148. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.mjs +5 -4
  149. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.cjs +4 -3
  150. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.d.mts +15 -11
  151. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.mjs +4 -3
  152. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.cjs +49 -21
  153. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.d.mts +34 -20
  154. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.mjs +45 -20
  155. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.cjs +1 -1
  156. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.d.mts +14 -14
  157. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.mjs +1 -1
  158. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.cjs +1 -1
  159. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.d.mts +14 -14
  160. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.mjs +1 -1
  161. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.cjs +48 -25
  162. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.d.mts +27 -21
  163. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.mjs +40 -27
  164. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.cjs +1 -1
  165. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.d.mts +14 -14
  166. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.mjs +1 -1
  167. package/dist/v1/libs/TinyHtml/input/number/TinyHtmlNumberInput.d.mts +14 -14
  168. package/dist/v1/libs/TinyHtml/input/number/TinyHtmlRangeInput.d.mts +14 -14
  169. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlEmailInput.d.mts +25 -21
  170. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlPasswordInput.d.mts +18 -18
  171. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlSearchInput.d.mts +33 -29
  172. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTelInput.d.mts +22 -22
  173. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTextInput.d.mts +18 -18
  174. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlUrlInput.d.mts +31 -27
  175. package/dist/v1/libs/TinyHtml/media/TinyHtmlAudio.d.mts +35 -11
  176. package/dist/v1/libs/TinyHtml/media/TinyHtmlObject.d.mts +10 -10
  177. package/dist/v1/libs/TinyHtml/media/TinyHtmlSource.d.mts +12 -12
  178. package/dist/v1/libs/TinyHtml/media/TinyHtmlVideo.d.mts +35 -27
  179. package/dist/v1/libs/TinyHtml.cjs +3 -4
  180. package/dist/v1/libs/TinyHtml.d.mts +1503 -1731
  181. package/dist/v1/libs/TinyHtml.mjs +3 -4
  182. package/dist/v1/libs/TinyI18.d.mts +23 -61
  183. package/dist/v1/libs/TinyIframeEvents.cjs +1 -1
  184. package/dist/v1/libs/TinyIframeEvents.d.mts +29 -38
  185. package/dist/v1/libs/TinyIframeEvents.mjs +1 -1
  186. package/dist/v1/libs/TinyInventory.d.mts +78 -141
  187. package/dist/v1/libs/TinyInventoryTrader.d.mts +19 -22
  188. package/dist/v1/libs/TinyLevelUp.d.mts +10 -13
  189. package/dist/v1/libs/TinyLoadingScreen.d.mts +21 -31
  190. package/dist/v1/libs/TinyLocalStorage.d.mts +11 -36
  191. package/dist/v1/libs/TinyMamdaniInferenceSystem.d.mts +37 -23
  192. package/dist/v1/libs/TinyMediaPlayer.cjs +5 -3
  193. package/dist/v1/libs/TinyMediaPlayer.d.mts +102 -109
  194. package/dist/v1/libs/TinyMediaPlayer.mjs +5 -3
  195. package/dist/v1/libs/TinyNeedBar.d.mts +25 -37
  196. package/dist/v1/libs/TinyNewWinEvents.d.mts +29 -32
  197. package/dist/v1/libs/TinyNotifications.d.mts +6 -6
  198. package/dist/v1/libs/TinyNotifyCenter.d.mts +15 -21
  199. package/dist/v1/libs/TinyPromiseQueue.d.mts +11 -11
  200. package/dist/v1/libs/TinyRadioFm.cjs +32 -12
  201. package/dist/v1/libs/TinyRadioFm.d.mts +44 -80
  202. package/dist/v1/libs/TinyRadioFm.mjs +29 -12
  203. package/dist/v1/libs/TinyRateLimiter.d.mts +26 -39
  204. package/dist/v1/libs/TinySimpleDice.d.mts +17 -36
  205. package/dist/v1/libs/TinySmartScroller.d.mts +50 -60
  206. package/dist/v1/libs/TinyTextDiffer.d.mts +11 -14
  207. package/dist/v1/libs/TinyTextRangeEditor.d.mts +8 -8
  208. package/dist/v1/libs/TinyTextarea.d.mts +31 -31
  209. package/dist/v1/libs/TinyTimeout.d.mts +14 -14
  210. package/dist/v1/libs/TinyToastNotify.cjs +1 -1
  211. package/dist/v1/libs/TinyToastNotify.d.mts +15 -23
  212. package/dist/v1/libs/TinyToastNotify.mjs +1 -1
  213. package/dist/v1/libs/TinyUploadClicker.d.mts +38 -14
  214. package/dist/v1/libs/UltraRandomMsgGen.d.mts +44 -84
  215. package/dist/v1/libs/utils.d.mts +5 -1
  216. package/docs/v1/basics/deprecated/objFilter.md +14 -0
  217. package/docs/v1/basics/objFilter.md +31 -17
  218. package/package.json +2 -2
@@ -2,6 +2,22 @@
2
2
 
3
3
  var TinyHtmlInput = require('../../TinyHtmlInput.cjs');
4
4
 
5
+ /**
6
+ * Validator to ensure the correct HTML5 date format (YYYY-MM-DD) and whether it is a real date.
7
+ * @param {string} str
8
+ * @returns {boolean}
9
+ */
10
+ const isValidDateString = (str) => {
11
+ if (typeof str !== 'string') return false;
12
+ if (str.length < 1) return true;
13
+ const dateRegex = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
14
+ if (!dateRegex.test(str)) return false;
15
+
16
+ // Checks if the date is real in the calendar (e.g. blocks 2025-02-30)
17
+ const date = new Date(str);
18
+ return !Number.isNaN(date.getTime()) && date.toISOString().slice(0, 10) === str;
19
+ };
20
+
5
21
  /**
6
22
  * TinyHtmlDateInput is a helper class for managing `<input type="date">` elements.
7
23
  * It provides validation and safe access to standard attributes such as `value`, `min`, `max`, `step`,
@@ -17,13 +33,28 @@ var TinyHtmlInput = require('../../TinyHtmlInput.cjs');
17
33
  * });
18
34
  */
19
35
  class TinyHtmlDateInput extends TinyHtmlInput {
36
+ /**
37
+ * Convert a Date to Date String.
38
+ * @param {Date} value
39
+ * @returns {string}
40
+ */
41
+ static dateToString(value) {
42
+ if (!(value instanceof Date)) throw new TypeError('TinyHtmlDateInput: "value" must be a date.');
43
+
44
+ const year = value.getFullYear();
45
+ const month = String(value.getMonth() + 1).padStart(2, '0');
46
+ const day = String(value.getDate()).padStart(2, '0');
47
+
48
+ return `${year}-${month}-${day}`;
49
+ }
50
+
20
51
  /**
21
52
  * Creates a new TinyHtmlDateInput instance.
22
53
  * @param {Object} config - Configuration object.
23
54
  * @param {string} [config.value] - Initial date value in `YYYY-MM-DD` format.
24
55
  * @param {string} [config.min] - Minimum allowed date (in `YYYY-MM-DD` format).
25
56
  * @param {string} [config.max] - Maximum allowed date (in `YYYY-MM-DD` format).
26
- * @param {number|string} [config.step] - Step value in days (number) or "any".
57
+ * @param {number|'any'} [config.step] - Step value in days (number) or "any".
27
58
  * @param {string} [config.name] - The name of the input.
28
59
  * @param {string} [config.placeholder] - Placeholder text.
29
60
  * @param {string} [config.autocomplete] - Autocomplete hint (e.g., "on", "off", "bday").
@@ -61,33 +92,26 @@ class TinyHtmlDateInput extends TinyHtmlInput {
61
92
  this.required = required;
62
93
  }
63
94
 
64
- /** @param {string|Date} value */
95
+ /** @param {string} value */
65
96
  set value(value) {
66
- if (typeof value !== 'string' && !(value instanceof Date))
97
+ if (!isValidDateString(value))
67
98
  throw new TypeError(
68
- 'TinyHtmlDateInput: "value" must be a string in YYYY-MM-DD format or date.',
99
+ 'TinyHtmlDateInput: "value" must be a valid real date string in YYYY-MM-DD format.',
69
100
  );
70
- if (value instanceof Date) {
71
- const year = value.getFullYear();
72
- const month = String(value.getMonth() + 1).padStart(2, '0');
73
- const day = String(value.getDate()).padStart(2, '0');
74
-
75
- const formatted = `${year}-${month}-${day}`;
76
- this.setVal(formatted);
77
- return;
78
- }
79
101
  this.setVal(value);
80
102
  }
81
103
 
82
104
  /** @returns {string|null} */
83
105
  get value() {
84
- return this.attrString('value');
106
+ return this.valTxt();
85
107
  }
86
108
 
87
109
  /** @param {string} min */
88
110
  set min(min) {
89
- if (typeof min !== 'string')
90
- throw new TypeError('TinyHtmlDateInput: "min" must be a string in YYYY-MM-DD format.');
111
+ if (!isValidDateString(min))
112
+ throw new TypeError(
113
+ 'TinyHtmlDateInput: "min" must be a valid real date string in YYYY-MM-DD format.',
114
+ );
91
115
  this.setAttr('min', min);
92
116
  }
93
117
 
@@ -98,8 +122,10 @@ class TinyHtmlDateInput extends TinyHtmlInput {
98
122
 
99
123
  /** @param {string} max */
100
124
  set max(max) {
101
- if (typeof max !== 'string')
102
- throw new TypeError('TinyHtmlDateInput: "max" must be a string in YYYY-MM-DD format.');
125
+ if (!isValidDateString(max))
126
+ throw new TypeError(
127
+ 'TinyHtmlDateInput: "max" must be a valid real date string in YYYY-MM-DD format.',
128
+ );
103
129
  this.setAttr('max', max);
104
130
  }
105
131
 
@@ -108,16 +134,18 @@ class TinyHtmlDateInput extends TinyHtmlInput {
108
134
  return this.attrString('max');
109
135
  }
110
136
 
111
- /** @param {number|string} step */
137
+ /** @param {number|'any'} step */
112
138
  set step(step) {
113
139
  if (!(typeof step === 'number' && step > 0) && step !== 'any')
114
140
  throw new TypeError('TinyHtmlDateInput: "step" must be a positive number or "any".');
115
141
  this.setAttr('step', step);
116
142
  }
117
143
 
118
- /** @returns {string|null} */
144
+ /** @returns {number|'any'|null} */
119
145
  get step() {
120
- return this.attrString('step');
146
+ const value = this.attrString('step');
147
+ if (value === null || value === 'any') return value;
148
+ return parseFloat(value);
121
149
  }
122
150
 
123
151
  /** @param {string} name */
@@ -1,4 +1,4 @@
1
- export default TinyHtmlDateInput;
1
+ import TinyHtmlInput from '../../TinyHtmlInput.mjs';
2
2
  /**
3
3
  * TinyHtmlDateInput is a helper class for managing `<input type="date">` elements.
4
4
  * It provides validation and safe access to standard attributes such as `value`, `min`, `max`, `step`,
@@ -14,13 +14,19 @@ export default TinyHtmlDateInput;
14
14
  * });
15
15
  */
16
16
  declare class TinyHtmlDateInput extends TinyHtmlInput {
17
+ /**
18
+ * Convert a Date to Date String.
19
+ * @param {Date} value
20
+ * @returns {string}
21
+ */
22
+ static dateToString(value: Date): string;
17
23
  /**
18
24
  * Creates a new TinyHtmlDateInput instance.
19
25
  * @param {Object} config - Configuration object.
20
26
  * @param {string} [config.value] - Initial date value in `YYYY-MM-DD` format.
21
27
  * @param {string} [config.min] - Minimum allowed date (in `YYYY-MM-DD` format).
22
28
  * @param {string} [config.max] - Maximum allowed date (in `YYYY-MM-DD` format).
23
- * @param {number|string} [config.step] - Step value in days (number) or "any".
29
+ * @param {number|'any'} [config.step] - Step value in days (number) or "any".
24
30
  * @param {string} [config.name] - The name of the input.
25
31
  * @param {string} [config.placeholder] - Placeholder text.
26
32
  * @param {string} [config.autocomplete] - Autocomplete hint (e.g., "on", "off", "bday").
@@ -32,21 +38,21 @@ declare class TinyHtmlDateInput extends TinyHtmlInput {
32
38
  * @throws {TypeError} If any attribute is of the wrong type.
33
39
  */
34
40
  constructor({ value, min, max, step, name, placeholder, autocomplete, list, readonly, required, tags, mainClass, }?: {
35
- value?: string | undefined;
36
- min?: string | undefined;
37
- max?: string | undefined;
38
- step?: string | number | undefined;
39
- name?: string | undefined;
40
- placeholder?: string | undefined;
41
- autocomplete?: string | undefined;
42
- list?: string | undefined;
43
- readonly?: boolean | undefined;
44
- required?: boolean | undefined;
45
- tags?: string | string[] | Set<string> | undefined;
46
- mainClass?: string | undefined;
41
+ value?: string;
42
+ min?: string;
43
+ max?: string;
44
+ step?: number | 'any';
45
+ name?: string;
46
+ placeholder?: string;
47
+ autocomplete?: string;
48
+ list?: string;
49
+ readonly?: boolean;
50
+ required?: boolean;
51
+ tags?: string | string[] | Set<string>;
52
+ mainClass?: string;
47
53
  });
48
- /** @param {string|Date} value */
49
- set value(value: string | Date);
54
+ /** @param {string} value */
55
+ set value(value: string);
50
56
  /** @returns {string|null} */
51
57
  get value(): string | null;
52
58
  /** @param {string} min */
@@ -57,10 +63,18 @@ declare class TinyHtmlDateInput extends TinyHtmlInput {
57
63
  set max(max: string);
58
64
  /** @returns {string|null} */
59
65
  get max(): string | null;
60
- /** @param {number|string} step */
61
- set step(step: number | string);
66
+ /** @param {number|'any'} step */
67
+ set step(step: number | 'any');
68
+ /** @returns {number|'any'|null} */
69
+ get step(): number | 'any' | null;
70
+ /** @param {string} name */
71
+ set name(name: string);
62
72
  /** @returns {string|null} */
63
- get step(): string | null;
73
+ get name(): string | null;
74
+ /** @param {string} placeholder */
75
+ set placeholder(placeholder: string);
76
+ /** @returns {string|null} */
77
+ get placeholder(): string | null;
64
78
  /** @param {string} autocomplete */
65
79
  set autocomplete(autocomplete: string);
66
80
  /** @returns {string|null} */
@@ -70,5 +84,5 @@ declare class TinyHtmlDateInput extends TinyHtmlInput {
70
84
  /** @returns {string|null} */
71
85
  get list(): string | null;
72
86
  }
73
- import TinyHtmlInput from '../../TinyHtmlInput.mjs';
87
+ export default TinyHtmlDateInput;
74
88
  //# sourceMappingURL=TinyHtmlDateInput.d.mts.map
@@ -1,4 +1,21 @@
1
1
  import TinyHtmlInput from '../../TinyHtmlInput.mjs';
2
+ /**
3
+ * Validator to ensure the correct HTML5 date format (YYYY-MM-DD) and whether it is a real date.
4
+ * @param {string} str
5
+ * @returns {boolean}
6
+ */
7
+ const isValidDateString = (str) => {
8
+ if (typeof str !== 'string')
9
+ return false;
10
+ if (str.length < 1)
11
+ return true;
12
+ const dateRegex = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
13
+ if (!dateRegex.test(str))
14
+ return false;
15
+ // Checks if the date is real in the calendar (e.g. blocks 2025-02-30)
16
+ const date = new Date(str);
17
+ return !Number.isNaN(date.getTime()) && date.toISOString().slice(0, 10) === str;
18
+ };
2
19
  /**
3
20
  * TinyHtmlDateInput is a helper class for managing `<input type="date">` elements.
4
21
  * It provides validation and safe access to standard attributes such as `value`, `min`, `max`, `step`,
@@ -14,13 +31,26 @@ import TinyHtmlInput from '../../TinyHtmlInput.mjs';
14
31
  * });
15
32
  */
16
33
  class TinyHtmlDateInput extends TinyHtmlInput {
34
+ /**
35
+ * Convert a Date to Date String.
36
+ * @param {Date} value
37
+ * @returns {string}
38
+ */
39
+ static dateToString(value) {
40
+ if (!(value instanceof Date))
41
+ throw new TypeError('TinyHtmlDateInput: "value" must be a date.');
42
+ const year = value.getFullYear();
43
+ const month = String(value.getMonth() + 1).padStart(2, '0');
44
+ const day = String(value.getDate()).padStart(2, '0');
45
+ return `${year}-${month}-${day}`;
46
+ }
17
47
  /**
18
48
  * Creates a new TinyHtmlDateInput instance.
19
49
  * @param {Object} config - Configuration object.
20
50
  * @param {string} [config.value] - Initial date value in `YYYY-MM-DD` format.
21
51
  * @param {string} [config.min] - Minimum allowed date (in `YYYY-MM-DD` format).
22
52
  * @param {string} [config.max] - Maximum allowed date (in `YYYY-MM-DD` format).
23
- * @param {number|string} [config.step] - Step value in days (number) or "any".
53
+ * @param {number|'any'} [config.step] - Step value in days (number) or "any".
24
54
  * @param {string} [config.name] - The name of the input.
25
55
  * @param {string} [config.placeholder] - Placeholder text.
26
56
  * @param {string} [config.autocomplete] - Autocomplete hint (e.g., "on", "off", "bday").
@@ -48,28 +78,20 @@ class TinyHtmlDateInput extends TinyHtmlInput {
48
78
  this.readonly = readonly;
49
79
  this.required = required;
50
80
  }
51
- /** @param {string|Date} value */
81
+ /** @param {string} value */
52
82
  set value(value) {
53
- if (typeof value !== 'string' && !(value instanceof Date))
54
- throw new TypeError('TinyHtmlDateInput: "value" must be a string in YYYY-MM-DD format or date.');
55
- if (value instanceof Date) {
56
- const year = value.getFullYear();
57
- const month = String(value.getMonth() + 1).padStart(2, '0');
58
- const day = String(value.getDate()).padStart(2, '0');
59
- const formatted = `${year}-${month}-${day}`;
60
- this.setVal(formatted);
61
- return;
62
- }
83
+ if (!isValidDateString(value))
84
+ throw new TypeError('TinyHtmlDateInput: "value" must be a valid real date string in YYYY-MM-DD format.');
63
85
  this.setVal(value);
64
86
  }
65
87
  /** @returns {string|null} */
66
88
  get value() {
67
- return this.attrString('value');
89
+ return this.valTxt();
68
90
  }
69
91
  /** @param {string} min */
70
92
  set min(min) {
71
- if (typeof min !== 'string')
72
- throw new TypeError('TinyHtmlDateInput: "min" must be a string in YYYY-MM-DD format.');
93
+ if (!isValidDateString(min))
94
+ throw new TypeError('TinyHtmlDateInput: "min" must be a valid real date string in YYYY-MM-DD format.');
73
95
  this.setAttr('min', min);
74
96
  }
75
97
  /** @returns {string|null} */
@@ -78,23 +100,26 @@ class TinyHtmlDateInput extends TinyHtmlInput {
78
100
  }
79
101
  /** @param {string} max */
80
102
  set max(max) {
81
- if (typeof max !== 'string')
82
- throw new TypeError('TinyHtmlDateInput: "max" must be a string in YYYY-MM-DD format.');
103
+ if (!isValidDateString(max))
104
+ throw new TypeError('TinyHtmlDateInput: "max" must be a valid real date string in YYYY-MM-DD format.');
83
105
  this.setAttr('max', max);
84
106
  }
85
107
  /** @returns {string|null} */
86
108
  get max() {
87
109
  return this.attrString('max');
88
110
  }
89
- /** @param {number|string} step */
111
+ /** @param {number|'any'} step */
90
112
  set step(step) {
91
113
  if (!(typeof step === 'number' && step > 0) && step !== 'any')
92
114
  throw new TypeError('TinyHtmlDateInput: "step" must be a positive number or "any".');
93
115
  this.setAttr('step', step);
94
116
  }
95
- /** @returns {string|null} */
117
+ /** @returns {number|'any'|null} */
96
118
  get step() {
97
- return this.attrString('step');
119
+ const value = this.attrString('step');
120
+ if (value === null || value === 'any')
121
+ return value;
122
+ return parseFloat(value);
98
123
  }
99
124
  /** @param {string} name */
100
125
  set name(name) {
@@ -78,7 +78,7 @@ class TinyHtmlDateTimeInput extends TinyHtmlInput {
78
78
 
79
79
  /** @returns {string|null} */
80
80
  get value() {
81
- return this.attrString('value');
81
+ return this.valTxt();
82
82
  }
83
83
 
84
84
  /** @param {string} min */
@@ -1,4 +1,4 @@
1
- export default TinyHtmlDateTimeInput;
1
+ import TinyHtmlInput from '../../TinyHtmlInput.mjs';
2
2
  /**
3
3
  * TinyHtmlDateTimeInput is a helper class for managing
4
4
  * `<input type="datetime-local">` elements with validation.
@@ -35,18 +35,18 @@ declare class TinyHtmlDateTimeInput extends TinyHtmlInput {
35
35
  * @throws {TypeError} If any attribute is of the wrong type.
36
36
  */
37
37
  constructor({ value, min, max, step, name, placeholder, autocomplete, list, readonly, required, tags, mainClass, }?: {
38
- value?: string | undefined;
39
- min?: string | undefined;
40
- max?: string | undefined;
41
- step?: number | undefined;
42
- name?: string | undefined;
43
- placeholder?: string | undefined;
44
- autocomplete?: string | undefined;
45
- list?: string | undefined;
46
- readonly?: boolean | undefined;
47
- required?: boolean | undefined;
48
- tags?: string | string[] | Set<string> | undefined;
49
- mainClass?: string | undefined;
38
+ value?: string;
39
+ min?: string;
40
+ max?: string;
41
+ step?: number;
42
+ name?: string;
43
+ placeholder?: string;
44
+ autocomplete?: string;
45
+ list?: string;
46
+ readonly?: boolean;
47
+ required?: boolean;
48
+ tags?: string | string[] | Set<string>;
49
+ mainClass?: string;
50
50
  });
51
51
  /** @param {string|number|Date} value */
52
52
  set value(value: string | number | Date);
@@ -73,5 +73,5 @@ declare class TinyHtmlDateTimeInput extends TinyHtmlInput {
73
73
  /** @returns {string|null} */
74
74
  get autocomplete(): string | null;
75
75
  }
76
- import TinyHtmlInput from '../../TinyHtmlInput.mjs';
76
+ export default TinyHtmlDateTimeInput;
77
77
  //# sourceMappingURL=TinyHtmlDateTimeInput.d.mts.map
@@ -65,7 +65,7 @@ class TinyHtmlDateTimeInput extends TinyHtmlInput {
65
65
  }
66
66
  /** @returns {string|null} */
67
67
  get value() {
68
- return this.attrString('value');
68
+ return this.valTxt();
69
69
  }
70
70
  /** @param {string} min */
71
71
  set min(min) {
@@ -79,7 +79,7 @@ class TinyHtmlMonthInput extends TinyHtmlInput {
79
79
 
80
80
  /** @returns {string|null} */
81
81
  get value() {
82
- return this.attrString('value');
82
+ return this.valTxt();
83
83
  }
84
84
 
85
85
  /** @param {string} min */
@@ -1,4 +1,4 @@
1
- export default TinyHtmlMonthInput;
1
+ import TinyHtmlInput from '../../TinyHtmlInput.mjs';
2
2
  /**
3
3
  * TinyHtmlMonthInput is a helper class for managing `<input type="month">` elements.
4
4
  * It provides validation and convenient getters/setters for standard attributes.
@@ -32,18 +32,18 @@ declare class TinyHtmlMonthInput extends TinyHtmlInput {
32
32
  * @throws {TypeError} If any attribute is of the wrong type.
33
33
  */
34
34
  constructor({ value, list, min, max, step, name, readonly, required, placeholder, autocomplete, tags, mainClass, }?: {
35
- value?: string | undefined;
36
- min?: string | undefined;
37
- max?: string | undefined;
38
- step?: number | undefined;
39
- name?: string | undefined;
40
- placeholder?: string | undefined;
41
- autocomplete?: string | undefined;
42
- list?: string | undefined;
43
- readonly?: boolean | undefined;
44
- required?: boolean | undefined;
45
- tags?: string | string[] | Set<string> | undefined;
46
- mainClass?: string | undefined;
35
+ value?: string;
36
+ min?: string;
37
+ max?: string;
38
+ step?: number;
39
+ name?: string;
40
+ placeholder?: string;
41
+ autocomplete?: string;
42
+ list?: string;
43
+ readonly?: boolean;
44
+ required?: boolean;
45
+ tags?: string | string[] | Set<string>;
46
+ mainClass?: string;
47
47
  });
48
48
  /** @param {string|Date} value */
49
49
  set value(value: string | Date);
@@ -70,5 +70,5 @@ declare class TinyHtmlMonthInput extends TinyHtmlInput {
70
70
  /** @returns {string|null} */
71
71
  get autocomplete(): string | null;
72
72
  }
73
- import TinyHtmlInput from '../../TinyHtmlInput.mjs';
73
+ export default TinyHtmlMonthInput;
74
74
  //# sourceMappingURL=TinyHtmlMonthInput.d.mts.map
@@ -64,7 +64,7 @@ class TinyHtmlMonthInput extends TinyHtmlInput {
64
64
  }
65
65
  /** @returns {string|null} */
66
66
  get value() {
67
- return this.attrString('value');
67
+ return this.valTxt();
68
68
  }
69
69
  /** @param {string} min */
70
70
  set min(min) {
@@ -2,6 +2,16 @@
2
2
 
3
3
  var TinyHtmlInput = require('../../TinyHtmlInput.cjs');
4
4
 
5
+ /**
6
+ * Validator to ensure the correct HTML5 time format (HH:MM or HH:MM:SS or HH:MM:SS.mmm)
7
+ * @param {string} str
8
+ * @returns {boolean}
9
+ */
10
+ const isValidTimeString = (str) => {
11
+ const timeRegex = /^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d(\.\d{1,3})?)?$/;
12
+ return typeof str === 'string' && (str.length < 1 || timeRegex.test(str));
13
+ };
14
+
5
15
  /**
6
16
  * TinyHtmlTimeInput is a helper class for managing `<input type="time">` elements.
7
17
  * It provides validated getters and setters for all relevant attributes such as
@@ -18,13 +28,29 @@ var TinyHtmlInput = require('../../TinyHtmlInput.cjs');
18
28
  * });
19
29
  */
20
30
  class TinyHtmlTimeInput extends TinyHtmlInput {
31
+ /**
32
+ * Convert a Date to Time String.
33
+ * @param {Date} value
34
+ * @returns {string}
35
+ */
36
+ static dateToString(value) {
37
+ if (!(value instanceof Date)) throw new TypeError('TinyHtmlTimeInput: "value" must be a date.');
38
+
39
+ const hours = String(value.getHours()).padStart(2, '0');
40
+ const minutes = String(value.getMinutes()).padStart(2, '0');
41
+ const seconds = String(value.getSeconds()).padStart(2, '0');
42
+ const milliSecondss = String(value.getMilliseconds()).padStart(3, '0');
43
+
44
+ return `${hours}:${minutes}:${seconds}.${milliSecondss}`;
45
+ }
46
+
21
47
  /**
22
48
  * Creates a new TinyHtmlTimeInput instance.
23
49
  * @param {Object} config - Configuration object.
24
50
  * @param {string} [config.value] - Initial time value in "HH:MM" format.
25
51
  * @param {string} [config.min] - Minimum allowed time (e.g., "08:00").
26
52
  * @param {string} [config.max] - Maximum allowed time (e.g., "18:00").
27
- * @param {number|string} [config.step] - Granularity in seconds (or "any").
53
+ * @param {number|'any'} [config.step] - Granularity in seconds (or "any").
28
54
  * @param {string} [config.name] - The name of the control.
29
55
  * @param {string} [config.placeholder] - Placeholder text.
30
56
  * @param {string} [config.autocomplete] - Autocomplete hint ("on", "off", or token list).
@@ -64,29 +90,26 @@ class TinyHtmlTimeInput extends TinyHtmlInput {
64
90
  this.required = required;
65
91
  }
66
92
 
67
- /** @param {string|Date|number} value */
93
+ /** @param {string} value */
68
94
  set value(value) {
69
- if (typeof value !== 'string' && typeof value !== 'number' && !(value instanceof Date))
70
- throw new TypeError('TinyHtmlTimeInput: "value" must be a string or date.');
71
- if (value instanceof Date) {
72
- const hours = String(value.getHours()).padStart(2, '0');
73
- const minutes = String(value.getMinutes()).padStart(2, '0');
74
-
75
- const formatted = `${hours}:${minutes}`;
76
- this.setVal(formatted);
77
- return;
78
- }
95
+ if (!isValidTimeString(value))
96
+ throw new TypeError(
97
+ 'TinyHtmlTimeInput: "value" must be a valid time string (HH:MM or HH:MM:SS).',
98
+ );
79
99
  this.setVal(value);
80
100
  }
81
101
 
82
102
  /** @returns {string|null} */
83
103
  get value() {
84
- return this.attrString('value');
104
+ return this.valTxt();
85
105
  }
86
106
 
87
107
  /** @param {string} min */
88
108
  set min(min) {
89
- if (typeof min !== 'string') throw new TypeError('TinyHtmlTimeInput: "min" must be a string.');
109
+ if (!isValidTimeString(min))
110
+ throw new TypeError(
111
+ 'TinyHtmlTimeInput: "min" must be a valid time string (HH:MM or HH:MM:SS).',
112
+ );
90
113
  this.setAttr('min', min);
91
114
  }
92
115
 
@@ -97,7 +120,10 @@ class TinyHtmlTimeInput extends TinyHtmlInput {
97
120
 
98
121
  /** @param {string} max */
99
122
  set max(max) {
100
- if (typeof max !== 'string') throw new TypeError('TinyHtmlTimeInput: "max" must be a string.');
123
+ if (!isValidTimeString(max))
124
+ throw new TypeError(
125
+ 'TinyHtmlTimeInput: "max" must be a valid time string (HH:MM or HH:MM:SS).',
126
+ );
101
127
  this.setAttr('max', max);
102
128
  }
103
129
 
@@ -106,21 +132,18 @@ class TinyHtmlTimeInput extends TinyHtmlInput {
106
132
  return this.attrString('max');
107
133
  }
108
134
 
109
- /** @param {number|string} step */
135
+ /** @param {number|'any'} step */
110
136
  set step(step) {
111
- if (typeof step === 'number') {
112
- if (!Number.isFinite(step) || step <= 0)
113
- throw new TypeError('TinyHtmlTimeInput: "step" must be a positive number or "any".');
114
- this.setAttr('step', String(step));
115
- return;
116
- }
117
- if (step !== 'any') throw new TypeError('TinyHtmlTimeInput: "step" must be a number or "any".');
137
+ if (!(typeof step === 'number' && step > 0) && step !== 'any')
138
+ throw new TypeError('TinyHtmlTimeInput: "step" must be a positive number or "any".');
118
139
  this.setAttr('step', step);
119
140
  }
120
141
 
121
- /** @returns {string|null} */
142
+ /** @returns {number|'any'|null} */
122
143
  get step() {
123
- return this.attrString('step');
144
+ const value = this.attrString('step');
145
+ if (value === null || value === 'any') return value;
146
+ return parseFloat(value);
124
147
  }
125
148
 
126
149
  /** @param {string} list */