@hn250424/aero 0.1.0

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.
package/lib/aero.es.js ADDED
@@ -0,0 +1,1043 @@
1
+ class n extends HTMLElement {
2
+ /**
3
+ * The shadow root for this element.
4
+ * @protected
5
+ */
6
+ shadow;
7
+ /**
8
+ * @param {string} htmlTemplate - The HTML string to be used as the template for the shadow DOM.
9
+ * @protected
10
+ */
11
+ constructor(t) {
12
+ super();
13
+ const e = document.createElement("template");
14
+ e.innerHTML = t, this.shadow = this.attachShadow({ mode: "open" }), this.shadow.appendChild(e.content.cloneNode(!0));
15
+ }
16
+ /**
17
+ * Queries the shadow DOM for an element matching the given selector.
18
+ * @param {string} selector - The CSS selector to match.
19
+ * @returns {T} The first element matching the selector.
20
+ * @protected
21
+ */
22
+ query(t) {
23
+ return this.shadow.querySelector(t);
24
+ }
25
+ /**
26
+ * Applies a string of CSS to the shadow DOM by creating and appending a `<style>` tag.
27
+ * @param {string} style - The CSS string to apply.
28
+ * @protected
29
+ */
30
+ applyStyles(t) {
31
+ const e = document.createElement("style");
32
+ e.textContent = t, this.shadow.appendChild(e);
33
+ }
34
+ /**
35
+ * Dispatches a standard DOM event from this custom element.
36
+ * @param {string} type - The type of the event to dispatch (e.g., 'click', 'input').
37
+ * @protected
38
+ */
39
+ forwardNativeEvent(t) {
40
+ this.dispatchEvent(
41
+ new Event(t, {
42
+ bubbles: !0,
43
+ composed: !0
44
+ })
45
+ );
46
+ }
47
+ /**
48
+ * Dispatches a custom event with an optional detail payload.
49
+ * @param {string} type - The name of the custom event.
50
+ * @param {object} [options] - Options for the custom event.
51
+ * @param {*} [options.detail] - The data payload to send with the event.
52
+ * @param {Event} [options.originalEvent] - The original event that triggered this custom event.
53
+ * @protected
54
+ */
55
+ forwardCustomEvent(t, e) {
56
+ this.dispatchEvent(
57
+ new CustomEvent(
58
+ t,
59
+ {
60
+ detail: e?.detail,
61
+ bubbles: !0,
62
+ composed: !0
63
+ }
64
+ )
65
+ );
66
+ }
67
+ }
68
+ class a extends n {
69
+ /**
70
+ * The underlying HTML input element.
71
+ * @private
72
+ */
73
+ _input;
74
+ /**
75
+ * The HTML input element's value.
76
+ * @private
77
+ */
78
+ _value;
79
+ /**
80
+ * The minimum allowed value.
81
+ * @private
82
+ */
83
+ _min;
84
+ /**
85
+ * The maximum allowed value.
86
+ * @private
87
+ */
88
+ _max;
89
+ /**
90
+ * The stepping interval.
91
+ * @private
92
+ */
93
+ _step;
94
+ /**
95
+ * The number of decimal places to round to, inferred from the `step` value.
96
+ * @private
97
+ */
98
+ _decimalPlaces;
99
+ /**
100
+ * @param {string} htmlTemplate - The HTML string to be used as the template for the shadow DOM.
101
+ * @protected
102
+ */
103
+ constructor(t) {
104
+ super(t), this.initializeInput(), this.dispatchInputEvents(), this.updateInputValue(this.getAttribute("value")), this.updateMinValue(this.getAttribute("min")), this.updateMaxValue(this.getAttribute("max")), this.updateStepValue(this.getAttribute("step"));
105
+ }
106
+ /**
107
+ * Initializes the `_input` property by querying the shadow DOM.
108
+ * @private
109
+ */
110
+ initializeInput() {
111
+ this._input = this.query(this.getInputSelector());
112
+ }
113
+ /**
114
+ * Validates and sanitizes a given value according to the `min`, `max`, and `step` properties.
115
+ * @param {string} value - The value to validate.
116
+ * @returns {string} The validated and sanitized value.
117
+ * @protected
118
+ */
119
+ getValidateValue(t) {
120
+ return Math.min(
121
+ Number(this._max),
122
+ Math.max(
123
+ Number(this._min),
124
+ Math.round(Number(t) / Number(this._step)) * Number(this._step)
125
+ )
126
+ ).toFixed(Number(this._decimalPlaces));
127
+ }
128
+ /**
129
+ * Sets up event listeners on the input element to forward native events.
130
+ * @private
131
+ */
132
+ dispatchInputEvents() {
133
+ this._input.addEventListener("input", (t) => {
134
+ t.stopImmediatePropagation(), this.forwardNativeEvent("input");
135
+ }), this._input.addEventListener("change", (t) => {
136
+ t.stopImmediatePropagation();
137
+ const e = this.getValidateValue(this._input.value);
138
+ this.value = e, this.forwardNativeEvent("change");
139
+ }), this._input.addEventListener("focusin", (t) => {
140
+ t.stopImmediatePropagation(), this.forwardNativeEvent("focusin");
141
+ }), this._input.addEventListener("focusout", (t) => {
142
+ t.stopImmediatePropagation();
143
+ const e = this.getValidateValue(this._input.value);
144
+ this.value = e, this.forwardNativeEvent("focusout");
145
+ });
146
+ }
147
+ /**
148
+ * Specifies the observed attributes for the custom element.
149
+ * @returns {string[]} An array of attribute names to observe.
150
+ */
151
+ static get observedAttributes() {
152
+ return ["value", "min", "max", "step"];
153
+ }
154
+ /**
155
+ * Called when an observed attribute has been added, removed, or changed.
156
+ * @param {string} name - The name of the attribute that changed.
157
+ * @param {string | null} _oldValue - The old value of the attribute.
158
+ * @param {string | null} newValue - The new value of the attribute.
159
+ */
160
+ attributeChangedCallback(t, e, i) {
161
+ this.baseAeroNumericInputAttributeHandlers[t]?.(i);
162
+ }
163
+ /**
164
+ * A map of attribute names to their respective handler functions.
165
+ * @private
166
+ */
167
+ baseAeroNumericInputAttributeHandlers = {
168
+ value: (t) => {
169
+ this.updateInputValue(t);
170
+ },
171
+ min: (t) => {
172
+ this.updateMinValue(t);
173
+ },
174
+ max: (t) => {
175
+ this.updateMaxValue(t);
176
+ },
177
+ step: (t) => {
178
+ this.updateStepValue(t);
179
+ }
180
+ };
181
+ /**
182
+ * Updates the internal `_value` value.
183
+ * @param {string | null} val - The new input value.
184
+ * @private
185
+ */
186
+ updateInputValue(t) {
187
+ this._value = t ? this.getValidateValue(t) : "0", this._input.value = this._value;
188
+ }
189
+ /**
190
+ * Updates the internal `_min` value.
191
+ * @param {string | null} val - The new minimum value.
192
+ * @private
193
+ */
194
+ updateMinValue(t) {
195
+ this._min = t || "0";
196
+ }
197
+ /**
198
+ * Updates the internal `_max` value.
199
+ * @param {string | null} val - The new maximum value.
200
+ * @private
201
+ */
202
+ updateMaxValue(t) {
203
+ this._max = t || "100";
204
+ }
205
+ /**
206
+ * Updates the internal `_step` value and calculates the number of decimal places.
207
+ * @param {string | null} val - The new step value.
208
+ * @private
209
+ */
210
+ updateStepValue(t) {
211
+ this._step = t || "1", this._decimalPlaces = this._step.toString().split(".")[1]?.length.toString() || "0";
212
+ }
213
+ /**
214
+ * The underlying HTML input element.
215
+ * @type {HTMLInputElement}
216
+ * @readonly
217
+ */
218
+ get input() {
219
+ return this._input;
220
+ }
221
+ /**
222
+ * The current value of the numeric input.
223
+ * @type {string}
224
+ * @attr
225
+ * @default "0"
226
+ */
227
+ get value() {
228
+ return this._value;
229
+ }
230
+ set value(t) {
231
+ this.setAttribute("value", t);
232
+ }
233
+ /**
234
+ * The minimum allowed value.
235
+ * @type {string}
236
+ * @attr
237
+ * @default "0"
238
+ */
239
+ get min() {
240
+ return this._min;
241
+ }
242
+ set min(t) {
243
+ this.setAttribute("min", t);
244
+ }
245
+ /**
246
+ * The maximum allowed value.
247
+ * @type {string}
248
+ * @attr
249
+ * @default "100"
250
+ */
251
+ get max() {
252
+ return this._max;
253
+ }
254
+ set max(t) {
255
+ this.setAttribute("max", t);
256
+ }
257
+ /**
258
+ * The stepping interval for the numeric input.
259
+ * @type {string}
260
+ * @attr
261
+ * @default "1"
262
+ */
263
+ get step() {
264
+ return this._step;
265
+ }
266
+ set step(t) {
267
+ this.setAttribute("step", t);
268
+ }
269
+ /**
270
+ * The number of decimal places, derived from the `step` attribute.
271
+ * @type {string}
272
+ * @readonly
273
+ * @protected
274
+ */
275
+ get decimalPlaces() {
276
+ return this._decimalPlaces;
277
+ }
278
+ }
279
+ const h = `<style>\r
280
+ :host {\r
281
+ border: 1px solid #ccc;\r
282
+ display: block;\r
283
+ \r
284
+ width: 100px;\r
285
+ height: 30px;\r
286
+ }\r
287
+ \r
288
+ #input {\r
289
+ width: 100%;\r
290
+ height: 100%;\r
291
+ padding: 0;\r
292
+ border: none;\r
293
+ \r
294
+ text-align: inherit;\r
295
+ font-size: inherit;\r
296
+ color: inherit;\r
297
+ }\r
298
+ \r
299
+ #input:focus {\r
300
+ outline: none;\r
301
+ }\r
302
+ #input::-webkit-inner-spin-button {\r
303
+ appearance: none;\r
304
+ }\r
305
+ </style>\r
306
+ \r
307
+ <input id="input" type="number" />\r
308
+ `;
309
+ class u extends a {
310
+ constructor() {
311
+ super(h);
312
+ }
313
+ /**
314
+ * Returns the CSS selector for the internal input element.
315
+ * @returns {string} The CSS selector.
316
+ * @protected
317
+ */
318
+ getInputSelector() {
319
+ return "#input";
320
+ }
321
+ }
322
+ customElements.define("aero-numeric-input", u);
323
+ const d = `<style>\r
324
+ :host {\r
325
+ border: 1px solid #ccc;\r
326
+ display: block;\r
327
+ \r
328
+ width: 130px;\r
329
+ height: 30px;\r
330
+ }\r
331
+ \r
332
+ #spinbox {\r
333
+ display: grid;\r
334
+ }\r
335
+ \r
336
+ #spinbox,\r
337
+ #spinbox > * {\r
338
+ width: 100%;\r
339
+ height: 100%;\r
340
+ border: none;\r
341
+ font-size: inherit;\r
342
+ color: inherit;\r
343
+ }\r
344
+ \r
345
+ #spinbox > button {\r
346
+ cursor: pointer;\r
347
+ }\r
348
+ \r
349
+ #input {\r
350
+ padding: 0;\r
351
+ text-align: center;\r
352
+ }\r
353
+ \r
354
+ #input:focus {\r
355
+ outline: none;\r
356
+ }\r
357
+ #input::-webkit-inner-spin-button {\r
358
+ appearance: none;\r
359
+ }\r
360
+ </style>\r
361
+ \r
362
+ <div id="spinbox">\r
363
+ <button id="minus">-</button>\r
364
+ <input id="input" type="number" />\r
365
+ <button id="plus">+</button>\r
366
+ </div>\r
367
+ `;
368
+ class l extends a {
369
+ /**
370
+ * The decrement button element.
371
+ * @private
372
+ */
373
+ minus;
374
+ /**
375
+ * The increment button element.
376
+ * @private
377
+ */
378
+ plus;
379
+ constructor() {
380
+ super(d), this.minus = this.query("#minus"), this.plus = this.query("#plus"), this.minus.addEventListener("click", this.decrement.bind(this)), this.plus.addEventListener("click", this.increment.bind(this)), this.updateButtonBackgrondColor(
381
+ this.getAttribute("button-backgroundcolor")
382
+ ), this.updateMinuxText(this.getAttribute("minus-text")), this.updatePlusText(this.getAttribute("plus-text")), this.updateHeight(parseInt(getComputedStyle(this).height)), new ResizeObserver((e) => {
383
+ for (const i of e) {
384
+ const s = i.contentRect.height;
385
+ this.applyStyles(
386
+ `#spinbox {
387
+ grid-template-columns: ${s}px 1fr ${s}px;
388
+ }`
389
+ );
390
+ }
391
+ }).observe(this);
392
+ }
393
+ /**
394
+ * Returns the CSS selector for the internal input element.
395
+ * @returns {string} The CSS selector.
396
+ * @protected
397
+ */
398
+ getInputSelector() {
399
+ return "#input";
400
+ }
401
+ /**
402
+ * Specifies the observed attributes for the custom element.
403
+ * @returns {string[]} An array of attribute names to observe.
404
+ */
405
+ static get observedAttributes() {
406
+ return [
407
+ ...super.observedAttributes,
408
+ "minus-text",
409
+ "plus-text",
410
+ "button-backgroundcolor"
411
+ ];
412
+ }
413
+ /**
414
+ * Called when an observed attribute has been added, removed, or changed.
415
+ * @param {string} name - The name of the attribute that changed.
416
+ * @param {string | null} _oldValue - The old value of the attribute.
417
+ * @param {string | null} newValue - The new value of the attribute.
418
+ */
419
+ attributeChangedCallback(t, e, i) {
420
+ super.attributeChangedCallback(t, e, i), this.aeroSpinboxAttributeHandlers[t]?.(i);
421
+ }
422
+ /**
423
+ * A map of attribute names to their respective handler functions for this component.
424
+ * @private
425
+ */
426
+ aeroSpinboxAttributeHandlers = {
427
+ "minus-text": (t) => {
428
+ this.updateMinuxText(t);
429
+ },
430
+ "plus-text": (t) => {
431
+ this.updatePlusText(t);
432
+ },
433
+ "button-backgroundcolor": (t) => {
434
+ this.updateButtonBackgrondColor(t);
435
+ }
436
+ };
437
+ /**
438
+ * Updates the text content of the decrement button.
439
+ * @param {string | null} val - The new text.
440
+ * @private
441
+ */
442
+ updateMinuxText(t) {
443
+ this.minus.textContent = t || "-";
444
+ }
445
+ /**
446
+ * Updates the text content of the increment button.
447
+ * @param {string | null} val - The new text.
448
+ * @private
449
+ */
450
+ updatePlusText(t) {
451
+ this.plus.textContent = t || "+";
452
+ }
453
+ /**
454
+ * Updates the background color of the buttons.
455
+ * @param {string | null} val - The new color.
456
+ * @private
457
+ */
458
+ updateButtonBackgrondColor(t) {
459
+ this.applyStyles(
460
+ `#spinbox > button {
461
+ background-color: ${t || "#ccc"};
462
+ }`
463
+ );
464
+ }
465
+ /**
466
+ * Adjusts the grid layout based on the component's height.
467
+ * @param {number | null} val - The new height.
468
+ * @private
469
+ */
470
+ updateHeight(t) {
471
+ t = t || 30, this.applyStyles(
472
+ `#spinbox {
473
+ grid-template-columns: ${t}px 1fr ${t}px;
474
+ }`
475
+ );
476
+ }
477
+ /**
478
+ * The background color of the increment and decrement buttons.
479
+ * @param {string} color - The color value.
480
+ * @type {string}
481
+ * @attr button-backgroundcolor
482
+ * @default "#ccc"
483
+ */
484
+ set buttonBackgroundColor(t) {
485
+ this.setAttribute("button-backgroundcolor", t);
486
+ }
487
+ /**
488
+ * The text content for the decrement button.
489
+ * @param {string} text - The text to display.
490
+ * @type {string}
491
+ * @attr minus-text
492
+ * @default "-"
493
+ */
494
+ set minusText(t) {
495
+ this.setAttribute("minus-text", t);
496
+ }
497
+ /**
498
+ * The text content for the increment button.
499
+ * @param {string} text - The text to display.
500
+ * @type {string}
501
+ * @attr plus-text
502
+ * @default "+"
503
+ */
504
+ set plusText(t) {
505
+ this.setAttribute("plus-text", t);
506
+ }
507
+ /**
508
+ * Decrements the input value by the step amount.
509
+ */
510
+ decrement() {
511
+ const t = Number(this.input.value) - Number(this.step);
512
+ this.value = this.getValidateValue(t.toString());
513
+ }
514
+ /**
515
+ * Increments the input value by the step amount.
516
+ */
517
+ increment() {
518
+ const t = Number(this.input.value) + Number(this.step);
519
+ this.value = this.getValidateValue(t.toString());
520
+ }
521
+ }
522
+ customElements.define("aero-spinbox", l);
523
+ const p = `<style>\r
524
+ @keyframes spin {\r
525
+ 0% {\r
526
+ transform: rotate(0deg);\r
527
+ }\r
528
+ \r
529
+ 100% {\r
530
+ transform: rotate(360deg);\r
531
+ }\r
532
+ }\r
533
+ </style>\r
534
+ `;
535
+ class g extends n {
536
+ constructor() {
537
+ super(p), this.updateSpinnerStyles();
538
+ }
539
+ /**
540
+ * Specifies the observed attributes for the custom element.
541
+ * @returns {string[]} An array of attribute names to observe.
542
+ */
543
+ static get observedAttributes() {
544
+ return ["width", "height", "background", "color", "cycle"];
545
+ }
546
+ /**
547
+ * Called when an observed attribute has been added, removed, or changed.
548
+ */
549
+ attributeChangedCallback(t, e, i) {
550
+ this.updateSpinnerStyles();
551
+ }
552
+ /**
553
+ * Updates the spinner's styles based on its current attributes.
554
+ * Using :host instead of an inner element means styles are applied to the custom element itself.
555
+ * Re-appending styles multiple times can cause conflicts or unexpected behavior.
556
+ * @private
557
+ */
558
+ updateSpinnerStyles() {
559
+ const t = this.getAttribute("width") || "50", e = this.getAttribute("height") || "50", i = this.getAttribute("background") || "white", s = this.getAttribute("color") || "black", o = this.getAttribute("cycle") || "1";
560
+ this.applyStyles(`
561
+ :host {
562
+ width: ${t}px;
563
+ height: ${e}px;
564
+ border: 5px solid ${i};
565
+ border-top-color: ${s};
566
+ border-radius: 50%;
567
+ animation: spin ${o}s linear infinite;
568
+ box-sizing: border-box;
569
+ }
570
+
571
+ @keyframes spin {
572
+ 0% { transform: rotate(0deg); }
573
+ 100% { transform: rotate(360deg); }
574
+ }
575
+ `);
576
+ }
577
+ /**
578
+ * The width of the spinner in pixels.
579
+ * @param {string} val - The width value.
580
+ * @attr
581
+ * @default "50"
582
+ */
583
+ set width(t) {
584
+ this.setAttribute("width", t);
585
+ }
586
+ /**
587
+ * The height of the spinner in pixels.
588
+ * @param {string} val - The height value.
589
+ * @attr
590
+ * @default "50"
591
+ */
592
+ set height(t) {
593
+ this.setAttribute("height", t);
594
+ }
595
+ /**
596
+ * The color of the spinner's track.
597
+ * @param {string} val - The background color value.
598
+ * @attr
599
+ * @default "white"
600
+ */
601
+ set background(t) {
602
+ this.setAttribute("background", t);
603
+ }
604
+ /**
605
+ * The color of the spinner's moving part.
606
+ * @param {string} val - The color value.
607
+ * @attr
608
+ * @default "black"
609
+ */
610
+ set color(t) {
611
+ this.setAttribute("color", t);
612
+ }
613
+ /**
614
+ * The duration of one spin cycle in seconds.
615
+ * @param {string} val - The cycle duration.
616
+ * @attr
617
+ * @default "1"
618
+ */
619
+ set cycle(t) {
620
+ this.setAttribute("cycle", t);
621
+ }
622
+ }
623
+ customElements.define("aero-progress-spinner", g);
624
+ const m = `<style>\r
625
+ :host {\r
626
+ position: relative;\r
627
+ }\r
628
+ \r
629
+ .resizer {\r
630
+ position: absolute;\r
631
+ background-color: transparent;\r
632
+ transition: background-color 0.3s ease;\r
633
+ }\r
634
+ \r
635
+ .horizontal {\r
636
+ width: 3px;\r
637
+ height: 100%;\r
638
+ cursor: ew-resize;\r
639
+ }\r
640
+ \r
641
+ .vertical {\r
642
+ width: 100%;\r
643
+ height: 3px;\r
644
+ cursor: ns-resize;\r
645
+ }\r
646
+ \r
647
+ #top {\r
648
+ left: 0;\r
649
+ top: 0;\r
650
+ }\r
651
+ \r
652
+ #bottom {\r
653
+ left: 0;\r
654
+ bottom: 0;\r
655
+ }\r
656
+ \r
657
+ #left {\r
658
+ top: 0;\r
659
+ left: 0;\r
660
+ }\r
661
+ \r
662
+ #right {\r
663
+ top: 0;\r
664
+ right: 0;\r
665
+ }\r
666
+ </style>\r
667
+ \r
668
+ <slot></slot>\r
669
+ <div id="top" class="resizer vertical"></div>\r
670
+ <div id="bottom" class="resizer vertical"></div>\r
671
+ <div id="left" class="resizer horizontal"></div>\r
672
+ <div id="right" class="resizer horizontal"></div>\r
673
+ `;
674
+ class c extends n {
675
+ _topResizer;
676
+ _bottomResizer;
677
+ _leftResizer;
678
+ _rightResizer;
679
+ _hasTopResizer;
680
+ _hasBottomResizer;
681
+ _hasLeftResizer;
682
+ _hasRightResizer;
683
+ _nMinWidth;
684
+ _nMaxWidth;
685
+ _nMinHeight;
686
+ _nMaxHeight;
687
+ isTopDragging = !1;
688
+ isBottomDragging = !1;
689
+ isLeftDragging = !1;
690
+ isRightDragging = !1;
691
+ isDragging = !1;
692
+ animationFrameId = null;
693
+ resizerHandlers = {
694
+ top: (t) => this.processMousedownEvent(t, "top"),
695
+ bottom: (t) => this.processMousedownEvent(t, "bottom"),
696
+ left: (t) => this.processMousedownEvent(t, "left"),
697
+ right: (t) => this.processMousedownEvent(t, "right")
698
+ };
699
+ constructor() {
700
+ super(m), this._topResizer = this.query("#top"), this._bottomResizer = this.query("#bottom"), this._leftResizer = this.query("#left"), this._rightResizer = this.query("#right"), this.updateMinWidthValue(this.getAttribute("min-width")), this.updateMaxWidthValue(this.getAttribute("max-width")), this.updateMinHeightValue(this.getAttribute("min-height")), this.updateMaxHeightValue(this.getAttribute("max-height")), this.updateTopResizerState(this.hasAttribute("resize-top")), this.updateBottomResizerState(this.hasAttribute("resize-bottom")), this.updateLeftResizerState(this.hasAttribute("resize-left")), this.updateRightResizerState(this.hasAttribute("resize-right")), document.addEventListener("mousemove", (t) => {
701
+ this.isDragging && (this.animationFrameId && cancelAnimationFrame(this.animationFrameId), this.animationFrameId = requestAnimationFrame(() => {
702
+ const e = this.getBoundingClientRect();
703
+ if (this.isTopDragging) {
704
+ const i = e.bottom - t.clientY, s = Math.min(
705
+ Math.max(i, this._nMinHeight),
706
+ this._nMaxHeight
707
+ );
708
+ this.style.height = `${s}px`, this.emitResize(null, s);
709
+ } else if (this.isBottomDragging) {
710
+ const i = t.clientY - e.top, s = Math.min(
711
+ Math.max(i, this._nMinHeight),
712
+ this._nMaxHeight
713
+ );
714
+ this.style.height = `${s}px`, this.emitResize(null, s);
715
+ } else if (this.isLeftDragging) {
716
+ const i = e.right - t.clientX, s = Math.min(
717
+ Math.max(i, this._nMinWidth),
718
+ this._nMaxWidth
719
+ );
720
+ this.style.width = `${s}px`, this.emitResize(s, null);
721
+ } else if (this.isRightDragging) {
722
+ const i = t.clientX - e.left, s = Math.min(
723
+ Math.max(i, this._nMinWidth),
724
+ this._nMaxWidth
725
+ );
726
+ this.style.width = `${s}px`, this.emitResize(s, null);
727
+ }
728
+ }));
729
+ }), document.addEventListener("mouseup", () => {
730
+ this.isDragging && (this.forwardCustomEvent("aero-resize-end", {
731
+ detail: {
732
+ width: this.offsetWidth,
733
+ height: this.offsetHeight
734
+ }
735
+ }), this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), document.body.style.cursor = "default", document.body.style.userSelect = "auto", this.isDragging = !1, this.isTopDragging = !1, this.isBottomDragging = !1, this.isLeftDragging = !1, this.isRightDragging = !1);
736
+ });
737
+ }
738
+ /**
739
+ * Handles the mousedown event on a resizer element.
740
+ * @param {MouseEvent} e - The mouse event.
741
+ * @param {"top" | "bottom" | "left" | "right"} resizer - The resizer that was clicked.
742
+ * @private
743
+ */
744
+ processMousedownEvent = (t, e) => {
745
+ switch (t.preventDefault(), document.body.style.userSelect = "none", this.isDragging = !0, this.forwardCustomEvent("aero-resize-start", {
746
+ detail: {
747
+ width: this.offsetWidth,
748
+ height: this.offsetHeight,
749
+ edge: e
750
+ }
751
+ }), e) {
752
+ case "top":
753
+ this.isTopDragging = !0, document.body.style.cursor = "ns-resize";
754
+ break;
755
+ case "bottom":
756
+ this.isBottomDragging = !0, document.body.style.cursor = "ns-resize";
757
+ break;
758
+ case "left":
759
+ this.isLeftDragging = !0, document.body.style.cursor = "ew-resize";
760
+ break;
761
+ case "right":
762
+ this.isRightDragging = !0, document.body.style.cursor = "ew-resize";
763
+ break;
764
+ }
765
+ };
766
+ /**
767
+ * Emits the 'aero-resize' custom event.
768
+ * @param {number | null} width - The new width, or null if not changed.
769
+ * @param {number | null} height - The new height, or null if not changed.
770
+ * @private
771
+ */
772
+ emitResize(t, e) {
773
+ this.forwardCustomEvent("aero-resize", {
774
+ detail: {
775
+ width: t,
776
+ height: e
777
+ }
778
+ });
779
+ }
780
+ /**
781
+ * Specifies the observed attributes for the custom element.
782
+ * @returns {string[]} An array of attribute names to observe.
783
+ */
784
+ static get observedAttributes() {
785
+ return [
786
+ "min-width",
787
+ "max-width",
788
+ "min-height",
789
+ "max-height",
790
+ "resize-top",
791
+ "resize-bottom",
792
+ "resize-left",
793
+ "resize-right",
794
+ "resizer-color"
795
+ ];
796
+ }
797
+ /**
798
+ * Called when an observed attribute has been added, removed, or changed.
799
+ * @param {string} name - The name of the attribute that changed.
800
+ * @param {string | null} _oldValue - The old value of the attribute.
801
+ * @param {string | null} newValue - The new value of the attribute.
802
+ */
803
+ attributeChangedCallback(t, e, i) {
804
+ this.baseAeroResizeBoxAttributeHandlers[t]?.(i);
805
+ }
806
+ /**
807
+ * A map of attribute names to their respective handler functions.
808
+ * @private
809
+ */
810
+ baseAeroResizeBoxAttributeHandlers = {
811
+ "min-width": (t) => {
812
+ this.updateMinWidthValue(t);
813
+ },
814
+ "max-width": (t) => {
815
+ this.updateMaxWidthValue(t);
816
+ },
817
+ "min-height": (t) => {
818
+ this.updateMinHeightValue(t);
819
+ },
820
+ "max-height": (t) => {
821
+ this.updateMaxHeightValue(t);
822
+ },
823
+ "resize-top": (t) => {
824
+ this.updateTopResizerState(t !== null);
825
+ },
826
+ "resize-bottom": (t) => {
827
+ this.updateBottomResizerState(t !== null);
828
+ },
829
+ "resize-left": (t) => {
830
+ this.updateLeftResizerState(t !== null);
831
+ },
832
+ "resize-right": (t) => {
833
+ this.updateRightResizerState(t !== null);
834
+ },
835
+ "resizer-color": (t) => {
836
+ const e = t ?? "#ccc";
837
+ this.applyStyles(`.resizer:hover { background-color: ${e}; }`);
838
+ }
839
+ };
840
+ /**
841
+ * Enables or disables the top resizer.
842
+ * @param {boolean} enabled - Whether the resizer should be enabled.
843
+ * @private
844
+ */
845
+ updateTopResizerState(t) {
846
+ this._hasTopResizer = t, this.updateResizeState(
847
+ this._topResizer,
848
+ this._hasTopResizer,
849
+ this.resizerHandlers.top
850
+ );
851
+ }
852
+ /**
853
+ * Enables or disables the bottom resizer.
854
+ * @param {boolean} enabled - Whether the resizer should be enabled.
855
+ * @private
856
+ */
857
+ updateBottomResizerState(t) {
858
+ this._hasBottomResizer = t, this.updateResizeState(
859
+ this._bottomResizer,
860
+ this._hasBottomResizer,
861
+ this.resizerHandlers.bottom
862
+ );
863
+ }
864
+ /**
865
+ * Enables or disables the left resizer.
866
+ * @param {boolean} enabled - Whether the resizer should be enabled.
867
+ * @private
868
+ */
869
+ updateLeftResizerState(t) {
870
+ this._hasLeftResizer = t, this.updateResizeState(
871
+ this._leftResizer,
872
+ this._hasLeftResizer,
873
+ this.resizerHandlers.left
874
+ );
875
+ }
876
+ /**
877
+ * Enables or disables the right resizer.
878
+ * @param {boolean} enabled - Whether the resizer should be enabled.
879
+ * @private
880
+ */
881
+ updateRightResizerState(t) {
882
+ this._hasRightResizer = t, this.updateResizeState(
883
+ this._rightResizer,
884
+ this._hasRightResizer,
885
+ this.resizerHandlers.right
886
+ );
887
+ }
888
+ /**
889
+ * A helper function to add or remove the mousedown event listener for a resizer.
890
+ * @param {HTMLElement} resizer - The resizer element.
891
+ * @param {boolean} enabled - Whether the resizer is enabled.
892
+ * @param {(e: MouseEvent) => void} handler - The event handler.
893
+ * @private
894
+ */
895
+ updateResizeState(t, e, i) {
896
+ t.hidden = !e, e ? t.addEventListener("mousedown", i) : t.removeEventListener("mousedown", i);
897
+ }
898
+ /**
899
+ * Updates the internal minimum width value.
900
+ * @param {string | null} val - The new value.
901
+ * @private
902
+ */
903
+ updateMinWidthValue(t) {
904
+ this._nMinWidth = t ? Number(t) : 0;
905
+ }
906
+ /**
907
+ * Updates the internal maximum width value.
908
+ * @param {string | null} val - The new value.
909
+ * @private
910
+ */
911
+ updateMaxWidthValue(t) {
912
+ this._nMaxWidth = t ? Number(t) : 2e3;
913
+ }
914
+ /**
915
+ * Updates the internal minimum height value.
916
+ * @param {string | null} val - The new value.
917
+ * @private
918
+ */
919
+ updateMinHeightValue(t) {
920
+ this._nMinHeight = t ? Number(t) : 0;
921
+ }
922
+ /**
923
+ * Updates the internal maximum height value.
924
+ * @param {string | null} val - The new value.
925
+ * @private
926
+ */
927
+ updateMaxHeightValue(t) {
928
+ this._nMaxHeight = t ? Number(t) : 2e3;
929
+ }
930
+ /**
931
+ * The color of the resizer handles on hover.
932
+ * @param {string} color - The color value.
933
+ * @type {string}
934
+ * @attr
935
+ * @default "#ccc"
936
+ */
937
+ set resizerColor(t) {
938
+ this.setAttribute("resizer-color", t);
939
+ }
940
+ /**
941
+ * The minimum width of the box.
942
+ * @type {string}
943
+ * @attr min-width
944
+ * @default "0"
945
+ */
946
+ get minWidth() {
947
+ return this._nMinWidth.toString();
948
+ }
949
+ set minWidth(t) {
950
+ this.setAttribute("min-width", t);
951
+ }
952
+ /**
953
+ * The maximum width of the box.
954
+ * @type {string}
955
+ * @attr max-width
956
+ * @default "2000"
957
+ */
958
+ get maxWidth() {
959
+ return this._nMaxWidth.toString();
960
+ }
961
+ set maxWidth(t) {
962
+ this.setAttribute("max-width", t);
963
+ }
964
+ /**
965
+ * The minimum height of the box.
966
+ * @type {string}
967
+ * @attr min-height
968
+ * @default "0"
969
+ */
970
+ get minHeight() {
971
+ return this._nMinHeight.toString();
972
+ }
973
+ set minHeight(t) {
974
+ this.setAttribute("min-height", t);
975
+ }
976
+ /**
977
+ * The maximum height of the box.
978
+ * @type {string}
979
+ * @attr max-height
980
+ * @default "2000"
981
+ */
982
+ get maxHeight() {
983
+ return this._nMaxHeight.toString();
984
+ }
985
+ set maxHeight(t) {
986
+ this.setAttribute("max-height", t);
987
+ }
988
+ /**
989
+ * Enables the top resizer.
990
+ */
991
+ addTopResizer() {
992
+ this.setAttribute("resize-top", "");
993
+ }
994
+ /**
995
+ * Disables the top resizer.
996
+ */
997
+ removeTopResizer() {
998
+ this.removeAttribute("resize-top");
999
+ }
1000
+ /**
1001
+ * Enables the bottom resizer.
1002
+ */
1003
+ addBottomResizer() {
1004
+ this.setAttribute("resize-bottom", "");
1005
+ }
1006
+ /**
1007
+ * Disables the bottom resizer.
1008
+ */
1009
+ removeBottomResizer() {
1010
+ this.removeAttribute("resize-bottom");
1011
+ }
1012
+ /**
1013
+ * Enables the left resizer.
1014
+ */
1015
+ addLeftResizer() {
1016
+ this.setAttribute("resize-left", "");
1017
+ }
1018
+ /**
1019
+ * Disables the left resizer.
1020
+ */
1021
+ removeLeftResizer() {
1022
+ this.removeAttribute("resize-left");
1023
+ }
1024
+ /**
1025
+ * Enables the right resizer.
1026
+ */
1027
+ addRightResizer() {
1028
+ this.setAttribute("resize-right", "");
1029
+ }
1030
+ /**
1031
+ * Disables the right resizer.
1032
+ */
1033
+ removeRightResizer() {
1034
+ this.removeAttribute("resize-right");
1035
+ }
1036
+ }
1037
+ customElements.define("aero-resize-box", c);
1038
+ export {
1039
+ u as AeroNumericInput,
1040
+ g as AeroProgressSpinner,
1041
+ c as AeroResizeBox,
1042
+ l as AeroSpinbox
1043
+ };