tiny-essentials 1.23.0 → 1.23.2

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.
@@ -1 +1 @@
1
- .loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.6);display:flex;justify-content:center;align-items:center;z-index:9999}.loading-overlay .loading-content{text-align:center;color:#fff;font-family:Arial,sans-serif}.loading-overlay .loading-spinner{border:4px solid hsla(0,0%,100%,.3);border-top:4px solid #fff;border-radius:50%;width:50px;height:50px;margin:0 auto 15px;animation:spin 1s linear infinite}.loading-overlay .loading-message{font-size:1.2em}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}
1
+ .loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.6);display:absolute;justify-content:center;align-items:center;z-index:9999}.loading-overlay .loading-container{height:100%;width:100%;display:flex;align-items:center}.loading-overlay .loading-content{text-align:center;color:#fff;font-family:Arial,sans-serif;margin:auto}.loading-overlay .loading-spinner{position:relative;border:4px solid hsla(0,0%,100%,.3);border-top:4px solid #fff;border-radius:50%;width:50px;height:50px;margin:0 auto 15px;animation:loading-spin 1s linear infinite}.loading-overlay .loading-spinner::after{content:"";position:absolute;top:50%;left:50%;width:20px;height:20px;transform:translate(-50%, -50%);border-radius:50%;background:rgba(0,0,0,0);pointer-events:none}.loading-overlay .loading-message{font-size:1.2em;user-select:none !important}@keyframes loading-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}
@@ -5281,6 +5281,26 @@ class TinyHtml {
5281
5281
 
5282
5282
  // TITLE: Class Stuff
5283
5283
 
5284
+ /** @type {boolean} */
5285
+ static #classCanWhitespace = false;
5286
+
5287
+ /**
5288
+ * Gets the value of classCanWhitespace.
5289
+ * @returns {boolean}
5290
+ */
5291
+ static get classCanWhitespace() {
5292
+ return this.#classCanWhitespace;
5293
+ }
5294
+
5295
+ /**
5296
+ * Sets the value of classCanWhitespace.
5297
+ * @param {boolean} value
5298
+ */
5299
+ static set classCanWhitespace(value) {
5300
+ if (typeof value !== 'boolean') throw new TypeError('classCanWhitespace must be a boolean');
5301
+ this.#classCanWhitespace = value;
5302
+ }
5303
+
5284
5304
  /**
5285
5305
  * Adds one or more CSS class names to the element.
5286
5306
  * @template {TinyElement|TinyElement[]} T
@@ -5289,7 +5309,17 @@ class TinyHtml {
5289
5309
  * @returns {T}
5290
5310
  */
5291
5311
  static addClass(el, ...args) {
5292
- TinyHtml._preElems(el, 'addClass').forEach((elem) => elem.classList.add(...args));
5312
+ /** @type {string[]} */
5313
+ const classes = [];
5314
+ for (const name of args) {
5315
+ if (!TinyHtml.#classCanWhitespace) classes.push(name);
5316
+ else {
5317
+ const classesList = name.split(' ');
5318
+ for (const name2 of classesList) classes.push(name2);
5319
+ }
5320
+ }
5321
+
5322
+ TinyHtml._preElems(el, 'addClass').forEach((elem) => elem.classList.add(...classes));
5293
5323
  return el;
5294
5324
  }
5295
5325
 
@@ -5310,7 +5340,17 @@ class TinyHtml {
5310
5340
  * @returns {T}
5311
5341
  */
5312
5342
  static removeClass(el, ...args) {
5313
- TinyHtml._preElems(el, 'removeClass').forEach((elem) => elem.classList.remove(...args));
5343
+ /** @type {string[]} */
5344
+ const classes = [];
5345
+ for (const name of args) {
5346
+ if (!TinyHtml.#classCanWhitespace) classes.push(name);
5347
+ else {
5348
+ const classesList = name.split(' ');
5349
+ for (const name2 of classesList) classes.push(name2);
5350
+ }
5351
+ }
5352
+
5353
+ TinyHtml._preElems(el, 'removeClass').forEach((elem) => elem.classList.remove(...classes));
5314
5354
  return el;
5315
5355
  }
5316
5356
 
@@ -1958,6 +1958,18 @@ declare class TinyHtml<TinyHtmlT extends TinyHtmlConstructor> {
1958
1958
  * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) paddings, and each side individually.
1959
1959
  */
1960
1960
  static padding(el: TinyElement): HtmlElBoxSides;
1961
+ /** @type {boolean} */
1962
+ static "__#8@#classCanWhitespace": boolean;
1963
+ /**
1964
+ * Sets the value of classCanWhitespace.
1965
+ * @param {boolean} value
1966
+ */
1967
+ static set classCanWhitespace(value: boolean);
1968
+ /**
1969
+ * Gets the value of classCanWhitespace.
1970
+ * @returns {boolean}
1971
+ */
1972
+ static get classCanWhitespace(): boolean;
1961
1973
  /**
1962
1974
  * Adds one or more CSS class names to the element.
1963
1975
  * @template {TinyElement|TinyElement[]} T
@@ -4714,6 +4714,24 @@ class TinyHtml {
4714
4714
  }
4715
4715
  /////////////////////////////////////////////
4716
4716
  // TITLE: Class Stuff
4717
+ /** @type {boolean} */
4718
+ static #classCanWhitespace = false;
4719
+ /**
4720
+ * Gets the value of classCanWhitespace.
4721
+ * @returns {boolean}
4722
+ */
4723
+ static get classCanWhitespace() {
4724
+ return this.#classCanWhitespace;
4725
+ }
4726
+ /**
4727
+ * Sets the value of classCanWhitespace.
4728
+ * @param {boolean} value
4729
+ */
4730
+ static set classCanWhitespace(value) {
4731
+ if (typeof value !== 'boolean')
4732
+ throw new TypeError('classCanWhitespace must be a boolean');
4733
+ this.#classCanWhitespace = value;
4734
+ }
4717
4735
  /**
4718
4736
  * Adds one or more CSS class names to the element.
4719
4737
  * @template {TinyElement|TinyElement[]} T
@@ -4722,7 +4740,18 @@ class TinyHtml {
4722
4740
  * @returns {T}
4723
4741
  */
4724
4742
  static addClass(el, ...args) {
4725
- TinyHtml._preElems(el, 'addClass').forEach((elem) => elem.classList.add(...args));
4743
+ /** @type {string[]} */
4744
+ const classes = [];
4745
+ for (const name of args) {
4746
+ if (!TinyHtml.#classCanWhitespace)
4747
+ classes.push(name);
4748
+ else {
4749
+ const classesList = name.split(' ');
4750
+ for (const name2 of classesList)
4751
+ classes.push(name2);
4752
+ }
4753
+ }
4754
+ TinyHtml._preElems(el, 'addClass').forEach((elem) => elem.classList.add(...classes));
4726
4755
  return el;
4727
4756
  }
4728
4757
  /**
@@ -4741,7 +4770,18 @@ class TinyHtml {
4741
4770
  * @returns {T}
4742
4771
  */
4743
4772
  static removeClass(el, ...args) {
4744
- TinyHtml._preElems(el, 'removeClass').forEach((elem) => elem.classList.remove(...args));
4773
+ /** @type {string[]} */
4774
+ const classes = [];
4775
+ for (const name of args) {
4776
+ if (!TinyHtml.#classCanWhitespace)
4777
+ classes.push(name);
4778
+ else {
4779
+ const classesList = name.split(' ');
4780
+ for (const name2 of classesList)
4781
+ classes.push(name2);
4782
+ }
4783
+ }
4784
+ TinyHtml._preElems(el, 'removeClass').forEach((elem) => elem.classList.remove(...classes));
4745
4785
  return el;
4746
4786
  }
4747
4787
  /**
@@ -267,6 +267,9 @@ class TinyLoadingScreen {
267
267
  this.#overlay.classList.add('loading-overlay');
268
268
  this.#overlay.style.zIndex = String(this.#options.zIndex);
269
269
 
270
+ const contentBase = document.createElement('div');
271
+ contentBase.classList.add('loading-container');
272
+
270
273
  const content = document.createElement('div');
271
274
  content.classList.add('loading-content');
272
275
 
@@ -278,7 +281,8 @@ class TinyLoadingScreen {
278
281
 
279
282
  content.appendChild(spinner);
280
283
  content.appendChild(this.#messageElement);
281
- this.#overlay.appendChild(content);
284
+ contentBase.appendChild(content);
285
+ this.#overlay.appendChild(contentBase);
282
286
  this.#container.appendChild(this.#overlay);
283
287
 
284
288
  // trigger fade in
@@ -227,6 +227,8 @@ class TinyLoadingScreen {
227
227
  this.#overlay = document.createElement('div');
228
228
  this.#overlay.classList.add('loading-overlay');
229
229
  this.#overlay.style.zIndex = String(this.#options.zIndex);
230
+ const contentBase = document.createElement('div');
231
+ contentBase.classList.add('loading-container');
230
232
  const content = document.createElement('div');
231
233
  content.classList.add('loading-content');
232
234
  const spinner = document.createElement('div');
@@ -235,7 +237,8 @@ class TinyLoadingScreen {
235
237
  this.#messageElement.classList.add('loading-message');
236
238
  content.appendChild(spinner);
237
239
  content.appendChild(this.#messageElement);
238
- this.#overlay.appendChild(content);
240
+ contentBase.appendChild(content);
241
+ this.#overlay.appendChild(contentBase);
239
242
  this.#container.appendChild(this.#overlay);
240
243
  // trigger fade in
241
244
  this._removeOldClasses();
@@ -69,6 +69,30 @@ const newDiv = $$$('<div class="box">Hello!</div>');
69
69
 
70
70
  ---
71
71
 
72
+ ## ⚙️ Controlling Whitespace in Class Names
73
+
74
+ TinyHtml includes a static flag called `classCanWhitespace`.
75
+ This allows you to decide whether **class names with whitespace** should be considered valid or not.
76
+
77
+ ```js
78
+ // Enable or disable whitespace in class names
79
+ TinyHtml.classCanWhitespace = true; // ✅ allows whitespace
80
+ console.log(TinyHtml.classCanWhitespace); // true
81
+
82
+ TinyHtml.classCanWhitespace = false; // 🚫 disallows whitespace
83
+ console.log(TinyHtml.classCanWhitespace); // false
84
+ ```
85
+
86
+ ⚠️ If you try to assign a non-boolean value, TinyHtml will throw an error:
87
+
88
+ ```js
89
+ // ❌ Throws TypeError
90
+ TinyHtml.classCanWhitespace = "yes";
91
+ // -> Uncaught TypeError: classCanWhitespace must be a boolean
92
+ ```
93
+
94
+ ---
95
+
72
96
  ## 🚀 Why Aliases?
73
97
 
74
98
  Aliases are especially handy when:
@@ -96,6 +120,9 @@ This makes your setup **cleaner, reusable, and consistent** across the whole pro
96
120
  // Enable debugging mode
97
121
  TinyHtml.elemDebug = true;
98
122
 
123
+ // Allow whitespace in class names
124
+ TinyHtml.classCanWhitespace = true;
125
+
99
126
  // jQuery-style single element selector
100
127
  export const $ = (queryString) => new TinyHtml(queryString);
101
128
 
@@ -133,6 +160,10 @@ newBox.mainDisplay = 'block';
133
160
  // Create an element
134
161
  const newBox2 = $$$('<div class="box">Hello!</div>');
135
162
  $('body').append(newBox);
163
+
164
+ // Control class whitespace support
165
+ console.log(TinyHtml.classCanWhitespace); // true
166
+ TinyHtml.classCanWhitespace = false; // disable whitespace
136
167
  ```
137
168
 
138
169
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-essentials",
3
- "version": "1.23.0",
3
+ "version": "1.23.2",
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",