tiny-essentials 1.16.0 → 1.16.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.
@@ -0,0 +1,196 @@
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ "use strict";
3
+ /******/ // The require scope
4
+ /******/ var __webpack_require__ = {};
5
+ /******/
6
+ /************************************************************************/
7
+ /******/ /* webpack/runtime/define property getters */
8
+ /******/ (() => {
9
+ /******/ // define getter functions for harmony exports
10
+ /******/ __webpack_require__.d = (exports, definition) => {
11
+ /******/ for(var key in definition) {
12
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14
+ /******/ }
15
+ /******/ }
16
+ /******/ };
17
+ /******/ })();
18
+ /******/
19
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
20
+ /******/ (() => {
21
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22
+ /******/ })();
23
+ /******/
24
+ /************************************************************************/
25
+ var __webpack_exports__ = {};
26
+
27
+ // EXPORTS
28
+ __webpack_require__.d(__webpack_exports__, {
29
+ TinyAfterScrollWatcher: () => (/* reexport */ libs_TinyAfterScrollWatcher)
30
+ });
31
+
32
+ ;// ./src/v1/libs/TinyAfterScrollWatcher.mjs
33
+ /**
34
+ * @typedef {(() => void)} FnData - Function with no arguments and no return value
35
+ */
36
+
37
+ /**
38
+ * A function that handles a scroll event.
39
+ * It receives a standard `Event` object when a scroll occurs.
40
+ *
41
+ * @typedef {(ev: Event) => void} OnScrollFunc
42
+ */
43
+
44
+ /**
45
+ * A scroll tracker that queues functions to be executed
46
+ * after the user stops scrolling a specific element or the window.
47
+ */
48
+ class TinyAfterScrollWatcher {
49
+ /** @type {Element|Window} */
50
+ #scrollTarget;
51
+
52
+ /** @type {number} */
53
+ lastScrollTime = 0;
54
+
55
+ /** @type {FnData[]} */
56
+ #afterScrollQueue = [];
57
+
58
+ /** @type {number} */
59
+ #inactivityTime = 100;
60
+
61
+ /** @type {Set<OnScrollFunc>} */
62
+ #externalScrollListeners = new Set();
63
+
64
+ /** @type {boolean} */
65
+ #destroyed = false;
66
+
67
+ /**
68
+ * @param {Element|Window} scrollTarget - The element or window to track scrolling on
69
+ * @param {number} [inactivityTime=100] - Time in milliseconds to wait after scroll ends before executing the queue
70
+ * @throws {TypeError} If scrollTarget is not a valid Element or Window
71
+ * @throws {TypeError} If inactivityTime is not a positive number
72
+ */
73
+ constructor(scrollTarget = window, inactivityTime = 100) {
74
+ if (!(scrollTarget instanceof Element) && !(scrollTarget instanceof Window))
75
+ throw new TypeError('scrollTarget must be an Element or the Window object.');
76
+ this.#scrollTarget = scrollTarget;
77
+
78
+ this._onScroll = this._onScroll.bind(this);
79
+ this._checkQueue = this._checkQueue.bind(this);
80
+
81
+ this.#scrollTarget.addEventListener('scroll', this._onScroll);
82
+ this.#inactivityTime = inactivityTime;
83
+
84
+ requestAnimationFrame(this._checkQueue);
85
+ }
86
+
87
+ /**
88
+ * Gets the current inactivity time in milliseconds.
89
+ * @returns {number}
90
+ */
91
+ get inactivityTime() {
92
+ return this.#inactivityTime;
93
+ }
94
+
95
+ /**
96
+ * Sets a new inactivity time.
97
+ * Must be a positive number (in milliseconds).
98
+ * @param {number} value
99
+ * @throws {Error} If value is not a positive number
100
+ */
101
+ set inactivityTime(value) {
102
+ if (typeof value !== 'number' || value <= 0 || !Number.isFinite(value))
103
+ throw new Error('inactivityTime must be a positive number in milliseconds.');
104
+ this.#inactivityTime = value;
105
+ }
106
+
107
+ /**
108
+ * Internal handler for scroll events.
109
+ * Updates the last scroll timestamp.
110
+ * @private
111
+ */
112
+ _onScroll() {
113
+ this.lastScrollTime = Date.now();
114
+ }
115
+
116
+ /**
117
+ * Continuously checks whether the user has stopped scrolling,
118
+ * and if so, runs all queued functions.
119
+ * @private
120
+ */
121
+ _checkQueue() {
122
+ if (this.#destroyed) return;
123
+ requestAnimationFrame(this._checkQueue);
124
+
125
+ if (Date.now() - this.lastScrollTime > this.#inactivityTime) {
126
+ while (this.#afterScrollQueue.length) {
127
+ const fn = this.#afterScrollQueue.pop();
128
+ if (typeof fn === 'function') fn();
129
+ }
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Adds a function to be executed after scroll has stopped.
135
+ * The scroll is considered "stopped" after the configured inactivity time.
136
+ *
137
+ * @param {() => void} fn - A function to execute once scrolling has stopped.
138
+ * @throws {TypeError} If the argument is not a function.
139
+ */
140
+ doAfterScroll(fn) {
141
+ if (typeof fn !== 'function') throw new TypeError('Argument must be a function.');
142
+ this.lastScrollTime = Date.now();
143
+ this.#afterScrollQueue.push(fn);
144
+ }
145
+
146
+ /**
147
+ * Registers an external scroll listener on the tracked element.
148
+ *
149
+ * @param {OnScrollFunc} fn - The scroll listener to add
150
+ * @throws {TypeError} If the argument is not a function.
151
+ */
152
+ onScroll(fn) {
153
+ if (typeof fn !== 'function') throw new TypeError('Argument must be a function.');
154
+ this.#scrollTarget.addEventListener('scroll', fn);
155
+ this.#externalScrollListeners.add(fn);
156
+ }
157
+
158
+ /**
159
+ * Removes a previously registered scroll listener from the tracked element.
160
+ *
161
+ * @param {OnScrollFunc} fn - The scroll listener to remove
162
+ * @throws {TypeError} If the argument is not a function.
163
+ */
164
+ offScroll(fn) {
165
+ if (typeof fn !== 'function') throw new TypeError('Argument must be a function.');
166
+ if (this.#externalScrollListeners.has(fn)) {
167
+ this.#scrollTarget.removeEventListener('scroll', fn);
168
+ this.#externalScrollListeners.delete(fn);
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Destroys the watcher by removing internal listeners and clearing data.
174
+ */
175
+ destroy() {
176
+ if (this.#destroyed) return;
177
+ this.#destroyed = true;
178
+
179
+ this.#scrollTarget.removeEventListener('scroll', this._onScroll);
180
+ for (const fn of this.#externalScrollListeners)
181
+ this.#scrollTarget.removeEventListener('scroll', fn);
182
+
183
+ this.#externalScrollListeners.clear();
184
+ }
185
+ }
186
+
187
+ /* harmony default export */ const libs_TinyAfterScrollWatcher = (TinyAfterScrollWatcher);
188
+
189
+ ;// ./src/v1/build/TinyAfterScrollWatcher.mjs
190
+
191
+
192
+
193
+
194
+ window.TinyAfterScrollWatcher = __webpack_exports__.TinyAfterScrollWatcher;
195
+ /******/ })()
196
+ ;
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{TinyAfterScrollWatcher:()=>r});const r=class{#e;lastScrollTime=0;#t=[];#r=100;#i=new Set;#o=!1;constructor(e=window,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#e=e,this._onScroll=this._onScroll.bind(this),this._checkQueue=this._checkQueue.bind(this),this.#e.addEventListener("scroll",this._onScroll),this.#r=t,requestAnimationFrame(this._checkQueue)}get inactivityTime(){return this.#r}set inactivityTime(e){if("number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#r=e}_onScroll(){this.lastScrollTime=Date.now()}_checkQueue(){if(!this.#o&&(requestAnimationFrame(this._checkQueue),Date.now()-this.lastScrollTime>this.#r))for(;this.#t.length;){const e=this.#t.pop();"function"==typeof e&&e()}}doAfterScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#t.push(e)}onScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#e.addEventListener("scroll",e),this.#i.add(e)}offScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#i.has(e)&&(this.#e.removeEventListener("scroll",e),this.#i.delete(e))}destroy(){if(!this.#o){this.#o=!0,this.#e.removeEventListener("scroll",this._onScroll);for(const e of this.#i)this.#e.removeEventListener("scroll",e);this.#i.clear()}}};window.TinyAfterScrollWatcher=t.TinyAfterScrollWatcher})();
@@ -5295,6 +5295,494 @@ class TinyHtml_TinyHtml {
5295
5295
 
5296
5296
  //////////////////////////////////////////////////////////////////////
5297
5297
 
5298
+ /**
5299
+ * Stores camelCase to kebab-case CSS property aliases.
5300
+ *
5301
+ * Used to normalize property names when interacting with `element.style` or `getComputedStyle`.
5302
+ *
5303
+ * ⚠️ This object should not be modified directly. Use `TinyHtml.cssPropAliases` instead to ensure reverse mappings stay in sync.
5304
+ *
5305
+ * Example of how to add a new alias:
5306
+ *
5307
+ * ```js
5308
+ * TinyHtml.cssPropAliases.tinyPudding = 'tiny-pudding';
5309
+ * ```
5310
+ *
5311
+ * This will automatically update `TinyHtml.cssPropRevAliases['tiny-pudding']` with `'tinyPudding'`.
5312
+ *
5313
+ * @type {Record<string | symbol, string>}
5314
+ */
5315
+ static #cssPropAliases = {
5316
+ alignContent: 'align-content',
5317
+ alignItems: 'align-items',
5318
+ alignSelf: 'align-self',
5319
+ animationDelay: 'animation-delay',
5320
+ animationDirection: 'animation-direction',
5321
+ animationDuration: 'animation-duration',
5322
+ animationFillMode: 'animation-fill-mode',
5323
+ animationIterationCount: 'animation-iteration-count',
5324
+ animationName: 'animation-name',
5325
+ animationPlayState: 'animation-play-state',
5326
+ animationTimingFunction: 'animation-timing-function',
5327
+ backfaceVisibility: 'backface-visibility',
5328
+ backgroundAttachment: 'background-attachment',
5329
+ backgroundBlendMode: 'background-blend-mode',
5330
+ backgroundClip: 'background-clip',
5331
+ backgroundColor: 'background-color',
5332
+ backgroundImage: 'background-image',
5333
+ backgroundOrigin: 'background-origin',
5334
+ backgroundPosition: 'background-position',
5335
+ backgroundRepeat: 'background-repeat',
5336
+ backgroundSize: 'background-size',
5337
+ borderBottom: 'border-bottom',
5338
+ borderBottomColor: 'border-bottom-color',
5339
+ borderBottomLeftRadius: 'border-bottom-left-radius',
5340
+ borderBottomRightRadius: 'border-bottom-right-radius',
5341
+ borderBottomStyle: 'border-bottom-style',
5342
+ borderBottomWidth: 'border-bottom-width',
5343
+ borderCollapse: 'border-collapse',
5344
+ borderColor: 'border-color',
5345
+ borderImage: 'border-image',
5346
+ borderImageOutset: 'border-image-outset',
5347
+ borderImageRepeat: 'border-image-repeat',
5348
+ borderImageSlice: 'border-image-slice',
5349
+ borderImageSource: 'border-image-source',
5350
+ borderImageWidth: 'border-image-width',
5351
+ borderLeft: 'border-left',
5352
+ borderLeftColor: 'border-left-color',
5353
+ borderLeftStyle: 'border-left-style',
5354
+ borderLeftWidth: 'border-left-width',
5355
+ borderRadius: 'border-radius',
5356
+ borderRight: 'border-right',
5357
+ borderRightColor: 'border-right-color',
5358
+ borderRightStyle: 'border-right-style',
5359
+ borderRightWidth: 'border-right-width',
5360
+ borderSpacing: 'border-spacing',
5361
+ borderStyle: 'border-style',
5362
+ borderTop: 'border-top',
5363
+ borderTopColor: 'border-top-color',
5364
+ borderTopLeftRadius: 'border-top-left-radius',
5365
+ borderTopRightRadius: 'border-top-right-radius',
5366
+ borderTopStyle: 'border-top-style',
5367
+ borderTopWidth: 'border-top-width',
5368
+ borderWidth: 'border-width',
5369
+ boxDecorationBreak: 'box-decoration-break',
5370
+ boxShadow: 'box-shadow',
5371
+ boxSizing: 'box-sizing',
5372
+ breakAfter: 'break-after',
5373
+ breakBefore: 'break-before',
5374
+ breakInside: 'break-inside',
5375
+ captionSide: 'caption-side',
5376
+ caretColor: 'caret-color',
5377
+ clipPath: 'clip-path',
5378
+ columnCount: 'column-count',
5379
+ columnFill: 'column-fill',
5380
+ columnGap: 'column-gap',
5381
+ columnRule: 'column-rule',
5382
+ columnRuleColor: 'column-rule-color',
5383
+ columnRuleStyle: 'column-rule-style',
5384
+ columnRuleWidth: 'column-rule-width',
5385
+ columnSpan: 'column-span',
5386
+ columnWidth: 'column-width',
5387
+ counterIncrement: 'counter-increment',
5388
+ counterReset: 'counter-reset',
5389
+ emptyCells: 'empty-cells',
5390
+ flexBasis: 'flex-basis',
5391
+ flexDirection: 'flex-direction',
5392
+ flexFlow: 'flex-flow',
5393
+ flexGrow: 'flex-grow',
5394
+ flexShrink: 'flex-shrink',
5395
+ flexWrap: 'flex-wrap',
5396
+ fontFamily: 'font-family',
5397
+ fontFeatureSettings: 'font-feature-settings',
5398
+ fontKerning: 'font-kerning',
5399
+ fontLanguageOverride: 'font-language-override',
5400
+ fontSize: 'font-size',
5401
+ fontSizeAdjust: 'font-size-adjust',
5402
+ fontStretch: 'font-stretch',
5403
+ fontStyle: 'font-style',
5404
+ fontSynthesis: 'font-synthesis',
5405
+ fontVariant: 'font-variant',
5406
+ fontVariantAlternates: 'font-variant-alternates',
5407
+ fontVariantCaps: 'font-variant-caps',
5408
+ fontVariantEastAsian: 'font-variant-east-asian',
5409
+ fontVariantLigatures: 'font-variant-ligatures',
5410
+ fontVariantNumeric: 'font-variant-numeric',
5411
+ fontVariantPosition: 'font-variant-position',
5412
+ fontWeight: 'font-weight',
5413
+ gridArea: 'grid-area',
5414
+ gridAutoColumns: 'grid-auto-columns',
5415
+ gridAutoFlow: 'grid-auto-flow',
5416
+ gridAutoRows: 'grid-auto-rows',
5417
+ gridColumn: 'grid-column',
5418
+ gridColumnEnd: 'grid-column-end',
5419
+ gridColumnGap: 'grid-column-gap',
5420
+ gridColumnStart: 'grid-column-start',
5421
+ gridGap: 'grid-gap',
5422
+ gridRow: 'grid-row',
5423
+ gridRowEnd: 'grid-row-end',
5424
+ gridRowGap: 'grid-row-gap',
5425
+ gridRowStart: 'grid-row-start',
5426
+ gridTemplate: 'grid-template',
5427
+ gridTemplateAreas: 'grid-template-areas',
5428
+ gridTemplateColumns: 'grid-template-columns',
5429
+ gridTemplateRows: 'grid-template-rows',
5430
+ imageRendering: 'image-rendering',
5431
+ justifyContent: 'justify-content',
5432
+ letterSpacing: 'letter-spacing',
5433
+ lineBreak: 'line-break',
5434
+ lineHeight: 'line-height',
5435
+ listStyle: 'list-style',
5436
+ listStyleImage: 'list-style-image',
5437
+ listStylePosition: 'list-style-position',
5438
+ listStyleType: 'list-style-type',
5439
+ marginBottom: 'margin-bottom',
5440
+ marginLeft: 'margin-left',
5441
+ marginRight: 'margin-right',
5442
+ marginTop: 'margin-top',
5443
+ maskClip: 'mask-clip',
5444
+ maskComposite: 'mask-composite',
5445
+ maskImage: 'mask-image',
5446
+ maskMode: 'mask-mode',
5447
+ maskOrigin: 'mask-origin',
5448
+ maskPosition: 'mask-position',
5449
+ maskRepeat: 'mask-repeat',
5450
+ maskSize: 'mask-size',
5451
+ maskType: 'mask-type',
5452
+ maxHeight: 'max-height',
5453
+ maxWidth: 'max-width',
5454
+ minHeight: 'min-height',
5455
+ minWidth: 'min-width',
5456
+ mixBlendMode: 'mix-blend-mode',
5457
+ objectFit: 'object-fit',
5458
+ objectPosition: 'object-position',
5459
+ offsetAnchor: 'offset-anchor',
5460
+ offsetDistance: 'offset-distance',
5461
+ offsetPath: 'offset-path',
5462
+ offsetRotate: 'offset-rotate',
5463
+ outlineColor: 'outline-color',
5464
+ outlineOffset: 'outline-offset',
5465
+ outlineStyle: 'outline-style',
5466
+ outlineWidth: 'outline-width',
5467
+ overflowAnchor: 'overflow-anchor',
5468
+ overflowWrap: 'overflow-wrap',
5469
+ overflowX: 'overflow-x',
5470
+ overflowY: 'overflow-y',
5471
+ paddingBottom: 'padding-bottom',
5472
+ paddingLeft: 'padding-left',
5473
+ paddingRight: 'padding-right',
5474
+ paddingTop: 'padding-top',
5475
+ pageBreakAfter: 'page-break-after',
5476
+ pageBreakBefore: 'page-break-before',
5477
+ pageBreakInside: 'page-break-inside',
5478
+ perspectiveOrigin: 'perspective-origin',
5479
+ placeContent: 'place-content',
5480
+ placeItems: 'place-items',
5481
+ placeSelf: 'place-self',
5482
+ pointerEvents: 'pointer-events',
5483
+ rowGap: 'row-gap',
5484
+ scrollBehavior: 'scroll-behavior',
5485
+ scrollMargin: 'scroll-margin',
5486
+ scrollMarginBlock: 'scroll-margin-block',
5487
+ scrollMarginBlockEnd: 'scroll-margin-block-end',
5488
+ scrollMarginBlockStart: 'scroll-margin-block-start',
5489
+ scrollMarginBottom: 'scroll-margin-bottom',
5490
+ scrollMarginInline: 'scroll-margin-inline',
5491
+ scrollMarginInlineEnd: 'scroll-margin-inline-end',
5492
+ scrollMarginInlineStart: 'scroll-margin-inline-start',
5493
+ scrollMarginLeft: 'scroll-margin-left',
5494
+ scrollMarginRight: 'scroll-margin-right',
5495
+ scrollMarginTop: 'scroll-margin-top',
5496
+ scrollPadding: 'scroll-padding',
5497
+ scrollPaddingBlock: 'scroll-padding-block',
5498
+ scrollPaddingBlockEnd: 'scroll-padding-block-end',
5499
+ scrollPaddingBlockStart: 'scroll-padding-block-start',
5500
+ scrollPaddingBottom: 'scroll-padding-bottom',
5501
+ scrollPaddingInline: 'scroll-padding-inline',
5502
+ scrollPaddingInlineEnd: 'scroll-padding-inline-end',
5503
+ scrollPaddingInlineStart: 'scroll-padding-inline-start',
5504
+ scrollPaddingLeft: 'scroll-padding-left',
5505
+ scrollPaddingRight: 'scroll-padding-right',
5506
+ scrollPaddingTop: 'scroll-padding-top',
5507
+ scrollSnapAlign: 'scroll-snap-align',
5508
+ scrollSnapStop: 'scroll-snap-stop',
5509
+ scrollSnapType: 'scroll-snap-type',
5510
+ shapeImageThreshold: 'shape-image-threshold',
5511
+ shapeMargin: 'shape-margin',
5512
+ shapeOutside: 'shape-outside',
5513
+ tabSize: 'tab-size',
5514
+ tableLayout: 'table-layout',
5515
+ textAlign: 'text-align',
5516
+ textAlignLast: 'text-align-last',
5517
+ textCombineUpright: 'text-combine-upright',
5518
+ textDecoration: 'text-decoration',
5519
+ textDecorationColor: 'text-decoration-color',
5520
+ textDecorationLine: 'text-decoration-line',
5521
+ textDecorationStyle: 'text-decoration-style',
5522
+ textIndent: 'text-indent',
5523
+ textJustify: 'text-justify',
5524
+ textOrientation: 'text-orientation',
5525
+ textOverflow: 'text-overflow',
5526
+ textShadow: 'text-shadow',
5527
+ textTransform: 'text-transform',
5528
+ transformBox: 'transform-box',
5529
+ transformOrigin: 'transform-origin',
5530
+ transformStyle: 'transform-style',
5531
+ transitionDelay: 'transition-delay',
5532
+ transitionDuration: 'transition-duration',
5533
+ transitionProperty: 'transition-property',
5534
+ transitionTimingFunction: 'transition-timing-function',
5535
+ unicodeBidi: 'unicode-bidi',
5536
+ userSelect: 'user-select',
5537
+ verticalAlign: 'vertical-align',
5538
+ whiteSpace: 'white-space',
5539
+ willChange: 'will-change',
5540
+ wordBreak: 'word-break',
5541
+ wordSpacing: 'word-spacing',
5542
+ wordWrap: 'word-wrap',
5543
+ writingMode: 'writing-mode',
5544
+ zIndex: 'z-index',
5545
+ WebkitTransform: '-webkit-transform',
5546
+ WebkitTransition: '-webkit-transition',
5547
+ WebkitBoxShadow: '-webkit-box-shadow',
5548
+ MozBoxShadow: '-moz-box-shadow',
5549
+ MozTransform: '-moz-transform',
5550
+ MozTransition: '-moz-transition',
5551
+ msTransform: '-ms-transform',
5552
+ msTransition: '-ms-transition',
5553
+ };
5554
+
5555
+ /** @type {Record<string | symbol, string>} */
5556
+ static cssPropAliases = new Proxy(TinyHtml_TinyHtml.#cssPropAliases, {
5557
+ set(target, camelCaseKey, kebabValue) {
5558
+ target[camelCaseKey] = kebabValue;
5559
+ // @ts-ignore
5560
+ TinyHtml_TinyHtml.cssPropRevAliases[kebabValue] = camelCaseKey;
5561
+ return true;
5562
+ },
5563
+ });
5564
+
5565
+ /** @type {Record<string | symbol, string>} */
5566
+ static cssPropRevAliases = Object.fromEntries(
5567
+ Object.entries(TinyHtml_TinyHtml.#cssPropAliases).map(([camel, kebab]) => [kebab, camel]),
5568
+ );
5569
+
5570
+ /**
5571
+ * Converts a camelCase string to kebab-case
5572
+ * @param {string} str
5573
+ * @returns {string}
5574
+ */
5575
+ static toStyleKc(str) {
5576
+ if (typeof TinyHtml_TinyHtml.cssPropAliases[str] === 'string') return TinyHtml_TinyHtml.cssPropAliases[str];
5577
+ return str;
5578
+ }
5579
+
5580
+ /**
5581
+ * Converts a kebab-case string to camelCase
5582
+ * @param {string} str
5583
+ * @returns {string}
5584
+ */
5585
+ static toStyleCc(str) {
5586
+ if (typeof TinyHtml_TinyHtml.cssPropRevAliases[str] === 'string') return TinyHtml_TinyHtml.cssPropRevAliases[str];
5587
+ return str;
5588
+ }
5589
+
5590
+ /**
5591
+ * Sets one or more CSS inline style properties on the given element(s).
5592
+ *
5593
+ * - If `prop` is a string, the `value` will be applied to that property.
5594
+ * - If `prop` is an object, each key-value pair will be applied as a CSS property and value.
5595
+ *
5596
+ * @param {TinyHtmlElement|TinyHtmlElement[]} el - The element to inspect.
5597
+ * @param {string|Object} prop - The property name or an object with key-value pairs
5598
+ * @param {string|null} [value=null] - The value to set (if `prop` is a string)
5599
+ */
5600
+ static setStyle(el, prop, value = null) {
5601
+ TinyHtml_TinyHtml._preHtmlElems(el, 'setStyle').forEach((elem) => {
5602
+ if (typeof prop === 'object') {
5603
+ for (const [k, v] of Object.entries(prop)) {
5604
+ elem.style.setProperty(
5605
+ TinyHtml_TinyHtml.toStyleKc(k),
5606
+ typeof v === 'string' ? v : typeof v === 'number' ? `${v}px` : String(v),
5607
+ );
5608
+ }
5609
+ } else elem.style.setProperty(TinyHtml_TinyHtml.toStyleKc(prop), value);
5610
+ });
5611
+ }
5612
+
5613
+ /**
5614
+ * Sets one or more CSS inline style properties on the given element(s).
5615
+ *
5616
+ * - If `prop` is a string, the `value` will be applied to that property.
5617
+ * - If `prop` is an object, each key-value pair will be applied as a CSS property and value.
5618
+ *
5619
+ * @param {string|Object} prop - The property name or an object with key-value pairs
5620
+ * @param {string|null} [value=null] - The value to set (if `prop` is a string)
5621
+ */
5622
+ setStyle(prop, value) {
5623
+ return TinyHtml_TinyHtml.setStyle(this, prop, value);
5624
+ }
5625
+
5626
+ /**
5627
+ * Gets the value of a specific inline style property.
5628
+ *
5629
+ * Returns only the value set directly via the `style` attribute.
5630
+ *
5631
+ * @param {TinyHtmlElement|TinyHtmlElement[]} el - A single element to inspect.
5632
+ * @param {string} prop - The style property name to retrieve.
5633
+ * @returns {string} The style value of the specified property.
5634
+ */
5635
+ static getStyle(el, prop) {
5636
+ return TinyHtml_TinyHtml._preHtmlElem(el, 'getStyle').style.getPropertyValue(TinyHtml_TinyHtml.toStyleKc(prop));
5637
+ }
5638
+
5639
+ /**
5640
+ * Gets the value of a specific inline style property.
5641
+ *
5642
+ * Returns only the value set directly via the `style` attribute.
5643
+ *
5644
+ * @param {string} prop - The style property name to retrieve.
5645
+ * @returns {string} The style value of the specified property.
5646
+ */
5647
+ getStyle(prop) {
5648
+ return TinyHtml_TinyHtml.getStyle(this, prop);
5649
+ }
5650
+
5651
+ /**
5652
+ * Gets all inline styles defined directly on the element (`style` attribute).
5653
+ *
5654
+ * Returns an object with all property-value pairs in kebab-case format.
5655
+ *
5656
+ * @param {TinyHtmlElement|TinyHtmlElement[]} el - A single element to inspect.
5657
+ * @param {Object} [settings={}] - Optional configuration settings.
5658
+ * @param {boolean} [settings.camelCase=false] - If `true`, the property names will be converted to camelCase.
5659
+ * @param {boolean} [settings.rawAttr=false] - If `true`, reads the style string from the `style` attribute instead of using the style object.
5660
+ * @returns {Record<string, string>} All inline styles as an object.
5661
+ *
5662
+ * @throws {TypeError} If `camelCase` or `rawAttr` is not a boolean.
5663
+ */
5664
+ static style(el, { camelCase = false, rawAttr = false } = {}) {
5665
+ if (typeof camelCase !== 'boolean')
5666
+ throw new TypeError(`"camelCase" must be a boolean. Received: ${typeof camelCase}`);
5667
+ if (typeof rawAttr !== 'boolean')
5668
+ throw new TypeError(`"rawAttr" must be a boolean. Received: ${typeof rawAttr}`);
5669
+
5670
+ const elem = TinyHtml_TinyHtml._preHtmlElem(el, 'style');
5671
+ /** @type {Record<string, string>} */
5672
+ const result = {};
5673
+
5674
+ if (rawAttr) {
5675
+ const raw = elem.getAttribute('style') || '';
5676
+ const entries = raw.split(';');
5677
+ for (const entry of entries) {
5678
+ const [rawProp, rawVal] = entry.split(':');
5679
+ if (!rawProp || !rawVal) continue;
5680
+
5681
+ const prop = rawProp.trim();
5682
+ const value = rawVal.trim();
5683
+ result[camelCase ? TinyHtml_TinyHtml.toStyleCc(prop) : prop] = value;
5684
+ }
5685
+ } else {
5686
+ const styles = elem.style;
5687
+ for (let i = 0; i < styles.length; i++) {
5688
+ const prop = styles[i]; // Already in kebab-case
5689
+ const value = styles.getPropertyValue(prop);
5690
+ result[camelCase ? TinyHtml_TinyHtml.toStyleCc(prop) : prop] = value;
5691
+ }
5692
+ }
5693
+
5694
+ return result;
5695
+ }
5696
+
5697
+ /**
5698
+ * Gets all inline styles defined directly on the element (`style` attribute).
5699
+ *
5700
+ * Returns an object with all property-value pairs in kebab-case format.
5701
+ *
5702
+ * @param {Object} [settings={}] - Optional configuration settings.
5703
+ * @param {boolean} [settings.camelCase=false] - If `true`, the property names will be converted to camelCase.
5704
+ * @param {boolean} [settings.rawAttr=false] - If `true`, reads the style string from the `style` attribute instead of using the style object.
5705
+ * @returns {Record<string, string>} All inline styles as an object.
5706
+ */
5707
+ style(settings) {
5708
+ return TinyHtml_TinyHtml.style(this, settings);
5709
+ }
5710
+
5711
+ /**
5712
+ * Removes one or more inline CSS properties from the given element(s).
5713
+ *
5714
+ * @param {TinyHtmlElement|TinyHtmlElement[]} el - A single element or an array of elements.
5715
+ * @param {string|string[]} prop - A property name or an array of property names to remove.
5716
+ */
5717
+ static removeStyle(el, prop) {
5718
+ TinyHtml_TinyHtml._preHtmlElems(el, 'removeStyle').forEach((elem) => {
5719
+ if (Array.isArray(prop)) {
5720
+ for (const p of prop) {
5721
+ elem.style.removeProperty(TinyHtml_TinyHtml.toStyleKc(p));
5722
+ }
5723
+ } else elem.style.removeProperty(TinyHtml_TinyHtml.toStyleKc(prop));
5724
+ });
5725
+ }
5726
+
5727
+ /**
5728
+ * Removes one or more inline CSS properties from the given element(s).
5729
+ *
5730
+ * @param {string|string[]} prop - A property name or an array of property names to remove.
5731
+ */
5732
+ removeStyle(prop) {
5733
+ return TinyHtml_TinyHtml.removeStyle(this, prop);
5734
+ }
5735
+
5736
+ /**
5737
+ * Toggles a CSS property value between two given values.
5738
+ *
5739
+ * The current computed value is compared to `val1`. If it matches, the property is set to `val2`. Otherwise, it is set to `val1`.
5740
+ *
5741
+ * @param {TinyHtmlElement|TinyHtmlElement[]} el - A single element or an array of elements.
5742
+ * @param {string} prop - The CSS property to toggle.
5743
+ * @param {string} val1 - The first value (used as "current" check).
5744
+ * @param {string} val2 - The second value (used as the "alternative").
5745
+ */
5746
+ static toggleStyle(el, prop, val1, val2) {
5747
+ TinyHtml_TinyHtml._preHtmlElems(el, 'toggleStyle').forEach((elem) => {
5748
+ const current = TinyHtml_TinyHtml.getStyle(elem, prop).trim();
5749
+ const newVal = current === TinyHtml_TinyHtml.toStyleKc(val1) ? val2 : val1;
5750
+ TinyHtml_TinyHtml.setStyle(elem, prop, newVal);
5751
+ });
5752
+ }
5753
+
5754
+ /**
5755
+ * Toggles a CSS property value between two given values.
5756
+ *
5757
+ * The current computed value is compared to `val1`. If it matches, the property is set to `val2`. Otherwise, it is set to `val1`.
5758
+ *
5759
+ * @param {string} prop - The CSS property to toggle.
5760
+ * @param {string} val1 - The first value (used as "current" check).
5761
+ * @param {string} val2 - The second value (used as the "alternative").
5762
+ */
5763
+ toggleStyle(prop, val1, val2) {
5764
+ return TinyHtml_TinyHtml.toggleStyle(this, prop, val1, val2);
5765
+ }
5766
+
5767
+ /**
5768
+ * Removes all inline styles (`style` attribute) from the given element(s).
5769
+ *
5770
+ * @param {TinyElement|TinyElement[]} el - A single element or an array of elements.
5771
+ */
5772
+ static clearStyle(el) {
5773
+ TinyHtml_TinyHtml._preElems(el, 'clearStyle').forEach((elem) => elem.removeAttribute('style'));
5774
+ }
5775
+
5776
+ /**
5777
+ * Removes all inline styles (`style` attribute) from the given element(s).
5778
+ *
5779
+ */
5780
+ clearStyle() {
5781
+ return TinyHtml_TinyHtml.clearStyle(this);
5782
+ }
5783
+
5784
+ //////////////////////////////////////////////////////////////////////
5785
+
5298
5786
  /**
5299
5787
  * Focus the element.
5300
5788
  *