@neptune3d/dom 0.0.8 → 0.0.9

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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Helper classes and functions for fluent DOM manipulation, styling, and event handling.
4
4
 
5
+ [![NPM Version](https://img.shields.io/npm/v/%40neptune3d%2Fdom)](https://www.npmjs.com/package/@neptune3d/dom)
6
+
5
7
  ## 🚀 Getting Started
6
8
 
7
9
  Install the package:
@@ -54,16 +56,16 @@ $body().add(checkbox);
54
56
  ## 🎯 Popover API
55
57
 
56
58
  ```ts
57
- const pop = $("div")
59
+ const popup = $("div")
58
60
  .text("Popover content")
59
61
  .popover("manual")
60
- .css("", { padding: "1rem", background: "#222", color: "#fff" });
62
+ .style({ padding: "1rem", background: "#222", color: "#fff" });
61
63
 
62
- $body().add(pop);
64
+ $body().add(popup);
63
65
 
64
66
  // Show/hide programmatically
65
- pop.showPopover();
66
- pop.hidePopover();
67
+ popup.showPopover();
68
+ popup.hidePopover();
67
69
  ```
68
70
 
69
71
  ## 🎨 Stylesheet Rules
@@ -73,17 +75,24 @@ import { StyleSheet } from "neptune3d/dom";
73
75
 
74
76
  const sheet = StyleSheet.getSheet();
75
77
 
76
- // Insert a global rule
78
+ // insert a css rule
77
79
  const rule = sheet.cssRule(".list-item");
78
- rule.p("0.5rem").style({
79
- borderBottom: "1px solid #ccc",
80
- });
80
+ rule.p("0.5rem").bb("1px solid #ccc");
81
81
 
82
- // Insert a media query block
82
+ // insert a media rule
83
83
  const media = sheet.mediaRule("screen and (max-width: 600px)");
84
- media.cssRule(".list-item").style({
85
- background: "#f0f0f0",
86
- });
84
+
85
+ // insert a css rule into the media rule
86
+ media.cssRule(".list-item").textAlign("center").fontSize(24);
87
+
88
+ // extend a css rule
89
+ rule.extend("> div.child").opacity(0.6);
90
+
91
+ // predefined extensions for common pseudo selectors / elements
92
+
93
+ rule.hover().bgColor("red");
94
+
95
+ rule.focus().outline("1px dashed blue");
87
96
  ```
88
97
 
89
98
  ## 🌍 Global Event Wrappers
package/dist/index.d.ts CHANGED
@@ -44,14 +44,113 @@ declare class InputNumber extends DomElement<"input"> {
44
44
  }
45
45
  //#endregion
46
46
  //#region src/InputRange.d.ts
47
+ /**
48
+ * Represents a styled `<input type="range">` element with fluent configuration methods.
49
+ * Inherits DOM manipulation and style capabilities from `DomElement`, `BaseDom`, and `BaseStyle`.
50
+ * Provides ergonomic setters for common range input attributes (`min`, `max`, `step`, `value`, `name`),
51
+ * and exposes a typed `getValue()` accessor for reading the current numeric value.
52
+ *
53
+ * Designed for declarative UI composition and chaining, with full support for styling, layout, and interactivity.
54
+ *
55
+ * Example usage:
56
+ * new InputRange()
57
+ * .min(0)
58
+ * .max(100)
59
+ * .step(5)
60
+ * .value(50)
61
+ * .bWidth(1)
62
+ * .bStyle("solid")
63
+ * .bColor("#ccc");
64
+ */
47
65
  declare class InputRange extends DomElement<"input"> {
48
66
  constructor();
67
+ /**
68
+ * Returns the current numeric value of the range input.
69
+ * Converts the underlying string value to a number for type-safe access.
70
+ * Useful for reading user-selected values in event handlers or form logic.
71
+ *
72
+ * @return The current value as a number.
73
+ */
74
+ getValue(): number;
75
+ /**
76
+ * Returns the configured minimum value of the range input.
77
+ * Converts the string `min` attribute to a number.
78
+ * Useful for validation, clamping, or dynamic UI feedback.
79
+ *
80
+ * @return The minimum value as a number.
81
+ */
82
+ getMin(): number;
83
+ /**
84
+ * Returns the configured maximum value of the range input.
85
+ * Converts the string `max` attribute to a number.
86
+ * Useful for validation, clamping, or dynamic UI feedback.
87
+ *
88
+ * @return The maximum value as a number.
89
+ */
90
+ getMax(): number;
91
+ /**
92
+ * Returns the configured step increment of the range input.
93
+ * Converts the string `step` attribute to a number.
94
+ * Useful for calculating snap points or enforcing input granularity.
95
+ *
96
+ * @return The step value as a number.
97
+ */
98
+ getStep(): number;
99
+ /**
100
+ * Sets the `name` attribute of the range input.
101
+ * Useful for form serialization, accessibility, and identifying the input in event handlers or submissions.
102
+ *
103
+ * @param value - The name to assign to the input element.
104
+ * @return This instance for chaining.
105
+ */
49
106
  name(value: string): this;
107
+ /**
108
+ * Sets the current value of the range input.
109
+ * Converts the number to a string for DOM compatibility.
110
+ * Useful for initializing or programmatically updating the slider position.
111
+ *
112
+ * @param value - The numeric value to assign to the input.
113
+ * @return This instance for chaining.
114
+ */
50
115
  value(value: number): this;
51
- getValue(): number;
116
+ /**
117
+ * Sets the `min` attribute of the range input.
118
+ * Defines the lowest selectable value in the range.
119
+ * Converts the number to a string for DOM compatibility.
120
+ *
121
+ * @param value - The minimum value allowed by the input.
122
+ * @return This instance for chaining.
123
+ */
52
124
  min(value: number): this;
125
+ /**
126
+ * Sets the `max` attribute of the range input.
127
+ * Defines the highest selectable value in the range.
128
+ * Converts the number to a string for DOM compatibility.
129
+ *
130
+ * @param value - The maximum value allowed by the input.
131
+ * @return This instance for chaining.
132
+ */
53
133
  max(value: number): this;
134
+ /**
135
+ * Sets the `step` attribute of the range input.
136
+ * Controls the increment between selectable values.
137
+ * Converts the number to a string for DOM compatibility.
138
+ *
139
+ * @param value - The step size between values.
140
+ * @return This instance for chaining.
141
+ */
54
142
  step(value: number): this;
143
+ /**
144
+ * Sets the `min`, `max`, and `step` attributes of the range input.
145
+ * Accepts individual numeric parameters for ergonomic and explicit configuration.
146
+ * Useful for declaratively defining the full range boundaries.
147
+ *
148
+ * @param min - The minimum value of the range.
149
+ * @param max - The maximum value of the range.
150
+ * @param step - The step increment between values.
151
+ * @return This instance for chaining.
152
+ */
153
+ bounds(min: number, max: number, step: number): this;
55
154
  }
56
155
  //#endregion
57
156
  //#region src/InputText.d.ts
@@ -155,7 +254,7 @@ declare abstract class BaseStyle {
155
254
  * @param value - The padding value to apply, or `undefined` to remove it.
156
255
  * @return This instance for chaining.
157
256
  */
158
- p(value: Property.Padding | undefined): this;
257
+ p(value: Property.Padding | number | undefined): this;
159
258
  /**
160
259
  * Sets or clears the `padding-top` style of the element.
161
260
  * Accepts any valid CSS value (e.g., "10px", "1em").
@@ -227,7 +326,7 @@ declare abstract class BaseStyle {
227
326
  * @param value - The top margin value to apply, or `undefined` to remove it.
228
327
  * @return This instance for chaining.
229
328
  */
230
- mt(value: Property.MarginTop | undefined): this;
329
+ mt(value: Property.MarginTop | number | undefined): this;
231
330
  /**
232
331
  * Sets or clears the `margin-right` style of the element.
233
332
  * Accepts any valid CSS value (e.g., "10px", "auto").
@@ -236,7 +335,7 @@ declare abstract class BaseStyle {
236
335
  * @param value - The right margin value to apply, or `undefined` to remove it.
237
336
  * @return This instance for chaining.
238
337
  */
239
- mr(value: Property.MarginRight | undefined): this;
338
+ mr(value: Property.MarginRight | number | undefined): this;
240
339
  /**
241
340
  * Sets or clears the `margin-bottom` style of the element.
242
341
  * Accepts any valid CSS value (e.g., "10px", "auto").
@@ -245,7 +344,7 @@ declare abstract class BaseStyle {
245
344
  * @param value - The bottom margin value to apply, or `undefined` to remove it.
246
345
  * @return This instance for chaining.
247
346
  */
248
- mb(value: Property.MarginBottom | undefined): this;
347
+ mb(value: Property.MarginBottom | number | undefined): this;
249
348
  /**
250
349
  * Sets or clears the `margin-left` style of the element.
251
350
  * Accepts any valid CSS value (e.g., "10px", "auto").
@@ -254,75 +353,75 @@ declare abstract class BaseStyle {
254
353
  * @param value - The left margin value to apply, or `undefined` to remove it.
255
354
  * @return This instance for chaining.
256
355
  */
257
- ml(value: Property.MarginLeft | undefined): this;
356
+ ml(value: Property.MarginLeft | number | undefined): this;
258
357
  /**
259
358
  * Sets the overall border radius.
260
359
  * @param value - The CSS border-radius value (e.g., "8px", "50%").
261
360
  * @return This instance for chaining.
262
361
  */
263
- radius(value: Property.BorderRadius | undefined): this;
362
+ radius(value: Property.BorderRadius | number | undefined): this;
264
363
  /**
265
364
  * Sets the top-left corner border radius.
266
365
  * @param value - The CSS border-top-left-radius value.
267
366
  * @return This instance for chaining.
268
367
  */
269
- radiusTopLeft(value: Property.BorderTopLeftRadius | undefined): this;
368
+ radiusTopLeft(value: Property.BorderTopLeftRadius | number | undefined): this;
270
369
  /**
271
370
  * Sets the top-right corner border radius.
272
371
  * @param value - The CSS border-top-right-radius value.
273
372
  * @return This instance for chaining.
274
373
  */
275
- radiusTopRight(value: Property.BorderTopRightRadius | undefined): this;
374
+ radiusTopRight(value: Property.BorderTopRightRadius | number | undefined): this;
276
375
  /**
277
376
  * Sets the bottom-left corner border radius.
278
377
  * @param value - The CSS border-bottom-left-radius value.
279
378
  * @return This instance for chaining.
280
379
  */
281
- radiusBottomLeft(value: Property.BorderBottomLeftRadius | undefined): this;
380
+ radiusBottomLeft(value: Property.BorderBottomLeftRadius | number | undefined): this;
282
381
  /**
283
382
  * Sets the bottom-right corner border radius.
284
383
  * @param value - The CSS border-bottom-right-radius value.
285
384
  * @return This instance for chaining.
286
385
  */
287
- radiusBottomRight(value: Property.BorderBottomRightRadius | undefined): this;
386
+ radiusBottomRight(value: Property.BorderBottomRightRadius | number | undefined): this;
288
387
  /**
289
388
  * Sets the border radius for both top corners.
290
389
  * @param value - The CSS border-radius value to apply to top-left and top-right corners.
291
390
  * @return This instance for chaining.
292
391
  */
293
- radiusTop(value: Property.BorderTopLeftRadius | undefined): this;
392
+ radiusTop(value: Property.BorderTopLeftRadius | number | undefined): this;
294
393
  /**
295
394
  * Sets the border radius for both bottom corners.
296
395
  * @param value - The CSS border-radius value to apply to bottom-left and bottom-right corners.
297
396
  * @return This instance for chaining.
298
397
  */
299
- radiusBottom(value: Property.BorderBottomLeftRadius | undefined): this;
398
+ radiusBottom(value: Property.BorderBottomLeftRadius | number | undefined): this;
300
399
  /**
301
400
  * Sets the border radius for both left corners.
302
401
  * @param value - The CSS border-radius value to apply to top-left and bottom-left corners.
303
402
  * @return This instance for chaining.
304
403
  */
305
- radiusLeft(value: Property.BorderTopLeftRadius | undefined): this;
404
+ radiusLeft(value: Property.BorderTopLeftRadius | number | undefined): this;
306
405
  /**
307
406
  * Sets the border radius for both right corners.
308
407
  * @param value - The CSS border-radius value to apply to top-right and bottom-right corners.
309
408
  * @return This instance for chaining.
310
409
  */
311
- radiusRight(value: Property.BorderTopRightRadius | undefined): this;
410
+ radiusRight(value: Property.BorderTopRightRadius | number | undefined): this;
312
411
  /**
313
412
  * Sets the border radius for both left and right sides (horizontal corners).
314
413
  * Applies to top-left, top-right, bottom-left, and bottom-right corners on the X axis.
315
414
  * @param value - The CSS border-radius value to apply horizontally.
316
415
  * @return This instance for chaining.
317
416
  */
318
- radiusX(value: Property.BorderRadius | undefined): this;
417
+ radiusX(value: Property.BorderRadius | number | undefined): this;
319
418
  /**
320
419
  * Sets the border radius for both top and bottom sides (vertical corners).
321
420
  * Applies to top-left, top-right, bottom-left, and bottom-right corners on the Y axis.
322
421
  * @param value - The CSS border-radius value to apply vertically.
323
422
  * @return This instance for chaining.
324
423
  */
325
- radiusY(value: Property.BorderRadius | undefined): this;
424
+ radiusY(value: Property.BorderRadius | number | undefined): this;
326
425
  /**
327
426
  * Sets the `display` style of the element.
328
427
  * Common values include "block", "inline", "flex", "grid", or "none".
@@ -424,30 +523,170 @@ declare abstract class BaseStyle {
424
523
  * @return This instance for chaining.
425
524
  */
426
525
  b(value: Property.Border | undefined): this;
526
+ /**
527
+ * Sets the `border-width` of the element.
528
+ * Controls the thickness of the border. Accepts any valid CSS length (e.g., "1px", "0.2em") or a number (interpreted as pixels).
529
+ * Passing `undefined` removes the border width.
530
+ *
531
+ * @param value - The border width to apply, or `undefined` to remove it.
532
+ * @return This instance for chaining.
533
+ */
534
+ bWidth(value: Property.BorderWidth | number | undefined): this;
535
+ /**
536
+ * Sets the `border-style` of the element.
537
+ * Controls the visual style of the border (e.g., solid, dashed, dotted, double).
538
+ * Accepts any valid CSS border-style value, or `undefined` to remove the style.
539
+ *
540
+ * @param value - The border style to apply (e.g., "solid", "dashed", "none"), or `undefined` to remove it.
541
+ * @return This instance for chaining.
542
+ */
543
+ bStyle(value: Property.BorderStyle | undefined): this;
544
+ /**
545
+ * Sets the `border-color` of the element.
546
+ * Controls the color of the element’s border.
547
+ * Accepts named colors, hex codes, RGB/RGBA values, or CSS variables.
548
+ * Passing `undefined` removes the border color.
549
+ *
550
+ * @param value - The border color to apply (e.g., "#000", "rgba(0,0,0,0.2)", "var(--border-color)"), or `undefined` to remove it.
551
+ * @return This instance for chaining.
552
+ */
553
+ bColor(value: Property.BorderColor | undefined): this;
427
554
  /**
428
555
  * Sets the top border style.
429
556
  * @param value - The CSS border-top value.
430
557
  * @return This instance for chaining.
431
558
  */
432
559
  bt(value: Property.BorderTop | undefined): this;
560
+ /**
561
+ * Sets the `border-top-width` of the element.
562
+ * Controls the thickness of the top border. Accepts any valid CSS length or a number (interpreted as pixels).
563
+ * Passing `undefined` removes the top border width.
564
+ *
565
+ * @param value - The top border width to apply, or `undefined` to remove it.
566
+ * @return This instance for chaining.
567
+ */
568
+ btWidth(value: Property.BorderTopWidth | number | undefined): this;
569
+ /**
570
+ * Sets the `border-top-style` of the element.
571
+ * Controls the visual style of the top border (e.g., solid, dashed, dotted).
572
+ * Passing `undefined` removes the top border style.
573
+ *
574
+ * @param value - The top border style to apply, or `undefined` to remove it.
575
+ * @return This instance for chaining.
576
+ */
577
+ btStyle(value: Property.BorderTopStyle | undefined): this;
578
+ /**
579
+ * Sets the `border-top-color` of the element.
580
+ * Controls the color of the top border.
581
+ * Accepts named colors, hex codes, RGB/RGBA values, or CSS variables.
582
+ * Passing `undefined` removes the top border color.
583
+ *
584
+ * @param value - The top border color to apply, or `undefined` to remove it.
585
+ * @return This instance for chaining.
586
+ */
587
+ btColor(value: Property.BorderTopColor | undefined): this;
433
588
  /**
434
589
  * Sets the right border style.
435
590
  * @param value - The CSS border-right value.
436
591
  * @return This instance for chaining.
437
592
  */
438
593
  br(value: Property.BorderRight | undefined): this;
594
+ /**
595
+ * Sets the `border-right-width` of the element.
596
+ * Controls the thickness of the right border. Accepts any valid CSS length or a number (interpreted as pixels).
597
+ * Passing `undefined` removes the right border width.
598
+ *
599
+ * @param value - The right border width to apply, or `undefined` to remove it.
600
+ * @return This instance for chaining.
601
+ */
602
+ brWidth(value: Property.BorderRightWidth | number | undefined): this;
603
+ /**
604
+ * Sets the `border-right-style` of the element.
605
+ * Controls the visual style of the right border (e.g., solid, dashed, dotted).
606
+ * Passing `undefined` removes the right border style.
607
+ *
608
+ * @param value - The right border style to apply, or `undefined` to remove it.
609
+ * @return This instance for chaining.
610
+ */
611
+ brStyle(value: Property.BorderRightStyle | undefined): this;
612
+ /**
613
+ * Sets the `border-right-color` of the element.
614
+ * Controls the color of the right border.
615
+ * Accepts named colors, hex codes, RGB/RGBA values, or CSS variables.
616
+ * Passing `undefined` removes the right border color.
617
+ *
618
+ * @param value - The right border color to apply, or `undefined` to remove it.
619
+ * @return This instance for chaining.
620
+ */
621
+ brColor(value: Property.BorderRightColor | undefined): this;
439
622
  /**
440
623
  * Sets the bottom border style.
441
624
  * @param value - The CSS border-bottom value.
442
625
  * @return This instance for chaining.
443
626
  */
444
627
  bb(value: Property.BorderBottom | undefined): this;
628
+ /**
629
+ * Sets the `border-bottom-width` of the element.
630
+ * Controls the thickness of the bottom border. Accepts any valid CSS length or a number (interpreted as pixels).
631
+ * Passing `undefined` removes the bottom border width.
632
+ *
633
+ * @param value - The bottom border width to apply, or `undefined` to remove it.
634
+ * @return This instance for chaining.
635
+ */
636
+ bbWidth(value: Property.BorderBottomWidth | number | undefined): this;
637
+ /**
638
+ * Sets the `border-bottom-style` of the element.
639
+ * Controls the visual style of the bottom border (e.g., solid, dashed, dotted).
640
+ * Passing `undefined` removes the bottom border style.
641
+ *
642
+ * @param value - The bottom border style to apply, or `undefined` to remove it.
643
+ * @return This instance for chaining.
644
+ */
645
+ bbStyle(value: Property.BorderBottomStyle | undefined): this;
646
+ /**
647
+ * Sets the `border-bottom-color` of the element.
648
+ * Controls the color of the bottom border.
649
+ * Accepts named colors, hex codes, RGB/RGBA values, or CSS variables.
650
+ * Passing `undefined` removes the bottom border color.
651
+ *
652
+ * @param value - The bottom border color to apply, or `undefined` to remove it.
653
+ * @return This instance for chaining.
654
+ */
655
+ bbColor(value: Property.BorderBottomColor | undefined): this;
445
656
  /**
446
657
  * Sets the left border style.
447
658
  * @param value - The CSS border-left value.
448
659
  * @return This instance for chaining.
449
660
  */
450
661
  bl(value: Property.BorderLeft | undefined): this;
662
+ /**
663
+ * Sets the `border-left-width` of the element.
664
+ * Controls the thickness of the left border. Accepts any valid CSS length or a number (interpreted as pixels).
665
+ * Passing `undefined` removes the left border width.
666
+ *
667
+ * @param value - The left border width to apply, or `undefined` to remove it.
668
+ * @return This instance for chaining.
669
+ */
670
+ blWidth(value: Property.BorderLeftWidth | number | undefined): this;
671
+ /**
672
+ * Sets the `border-left-style` of the element.
673
+ * Controls the visual style of the left border (e.g., solid, dashed, dotted).
674
+ * Passing `undefined` removes the left border style.
675
+ *
676
+ * @param value - The left border style to apply, or `undefined` to remove it.
677
+ * @return This instance for chaining.
678
+ */
679
+ blStyle(value: Property.BorderLeftStyle | undefined): this;
680
+ /**
681
+ * Sets the `border-left-color` of the element.
682
+ * Controls the color of the left border.
683
+ * Accepts named colors, hex codes, RGB/RGBA values, or CSS variables.
684
+ * Passing `undefined` removes the left border color.
685
+ *
686
+ * @param value - The left border color to apply, or `undefined` to remove it.
687
+ * @return This instance for chaining.
688
+ */
689
+ blColor(value: Property.BorderLeftColor | undefined): this;
451
690
  /**
452
691
  * Sets the left and right border styles.
453
692
  * @param value - The CSS border value to apply to both left and right sides.
@@ -864,6 +1103,62 @@ declare abstract class BaseStyle {
864
1103
  * @return This instance for chaining.
865
1104
  */
866
1105
  boxShadow(value: Property.BoxShadow | undefined): this;
1106
+ /**
1107
+ * Sets the `box-sizing` style of the element.
1108
+ * Controls how the element’s total width and height are calculated — either including or excluding padding and border.
1109
+ * Accepts any valid CSS box-sizing value (e.g., `"border-box"`, `"content-box"`), or `undefined` to remove it.
1110
+ *
1111
+ * @param value - The box-sizing value to apply, or `undefined` to remove the style.
1112
+ * @return This instance for chaining.
1113
+ */
1114
+ boxSizing(value: Property.BoxSizing | undefined): this;
1115
+ /**
1116
+ * Sets the `background` shorthand style of the element.
1117
+ * Accepts any valid CSS background value, including colors, gradients, images, positions, and repeat modes.
1118
+ * Useful for applying complex background styles in a single declaration.
1119
+ * Passing `undefined` removes the background style.
1120
+ *
1121
+ * @param value - The background value to apply (e.g., "#fff", "linear-gradient(...)", "url(...)", "center/cover"), or `undefined` to remove it.
1122
+ * @return This instance for chaining.
1123
+ */
1124
+ background(value: Property.Background | undefined): this;
1125
+ /**
1126
+ * Sets the `outline` shorthand property of the element.
1127
+ * Controls the outline's width, style, and color in a single call.
1128
+ * Unlike borders, outlines do not affect layout and can extend beyond element bounds.
1129
+ * Passing `undefined` removes the outline.
1130
+ *
1131
+ * @param value - A valid CSS outline shorthand (e.g. "2px dashed red"), or `undefined` to remove it.
1132
+ * @return This instance for chaining.
1133
+ */
1134
+ outline(value: Property.Outline | undefined): this;
1135
+ /**
1136
+ * Sets the `outline-width` of the element.
1137
+ * Controls the thickness of the outline. Accepts any valid CSS length or a number (interpreted as pixels).
1138
+ * Passing `undefined` removes the outline width.
1139
+ *
1140
+ * @param value - The outline width to apply, or `undefined` to remove it.
1141
+ * @return This instance for chaining.
1142
+ */
1143
+ outlineWidth(value: Property.OutlineWidth | number | undefined): this;
1144
+ /**
1145
+ * Sets the `outline-style` of the element.
1146
+ * Controls the visual style of the outline (e.g., solid, dashed, dotted).
1147
+ * Passing `undefined` removes the outline style.
1148
+ *
1149
+ * @param value - The outline style to apply, or `undefined` to remove it.
1150
+ * @return This instance for chaining.
1151
+ */
1152
+ outlineStyle(value: Property.OutlineStyle | undefined): this;
1153
+ /**
1154
+ * Sets the `outline-color` of the element.
1155
+ * Controls the color of the outline. Accepts named colors, hex codes, RGB/RGBA values, or CSS variables.
1156
+ * Passing `undefined` removes the outline color.
1157
+ *
1158
+ * @param value - The outline color to apply, or `undefined` to remove it.
1159
+ * @return This instance for chaining.
1160
+ */
1161
+ outlineColor(value: Property.OutlineColor | undefined): this;
867
1162
  /**
868
1163
  * Applies CSS styles to truncate overflowing text with an ellipsis.
869
1164
  * Ensures the text stays on a single line and hides overflow.
@@ -878,6 +1173,16 @@ declare abstract class BaseStyle {
878
1173
  * @return This instance for chaining.
879
1174
  */
880
1175
  overflowEllipsis(): this;
1176
+ /**
1177
+ * Sets the `background` style to a linear gradient.
1178
+ * Accepts a direction and one or more color stops to construct a valid CSS `linear-gradient(...)` string.
1179
+ * Automatically joins color stops and applies the full gradient string to `background`.
1180
+ *
1181
+ * @param direction - The gradient direction (e.g., `"to right"`, `"45deg"`).
1182
+ * @param stops - An array of color stops (e.g., `"#0ea5e9"`, `"#3b82f6 50%"`, `"rgba(0,0,0,0.2)"`).
1183
+ * @return This instance for chaining.
1184
+ */
1185
+ linearGradient(direction: string, ...stops: string[]): this;
881
1186
  /**
882
1187
  * Applies a batch of CSS style properties to the element.
883
1188
  * Delegates each property to `setStyleProp`, which handles value normalization and kebab-case conversion.
@@ -964,8 +1269,9 @@ declare abstract class BaseDom<E extends HTMLElement | SVGElement> extends BaseS
964
1269
  * @param type - The event type to remove.
965
1270
  * @param handler - The original handler function.
966
1271
  * @param options - Optional event listener options.
1272
+ * @return This DomElement instance for chaining.
967
1273
  */
968
- off<T extends keyof DomElementEventMap>(type: T, handler: (ev: DomElementEventMap[T]) => void, options?: boolean | EventListenerOptions): void;
1274
+ off<T extends keyof DomElementEventMap>(type: T, handler: (ev: DomElementEventMap[T]) => void, options?: boolean | EventListenerOptions): this;
969
1275
  /**
970
1276
  * Appends one or more child nodes to the element.
971
1277
  * Accepts DomElement instances, regular DOM Nodes, strings, or numbers.
@@ -1560,8 +1866,9 @@ declare class DomDocument {
1560
1866
  * @param type - The event type to remove.
1561
1867
  * @param handler - The original handler function.
1562
1868
  * @param options - Optional event listener options.
1869
+ * @return This instance for chaining.
1563
1870
  */
1564
- off<T extends keyof DocumentEventMap>(type: T, handler: (ev: DocumentEventMap[T]) => void, options?: boolean | EventListenerOptions): void;
1871
+ off<T extends keyof DocumentEventMap>(type: T, handler: (ev: DocumentEventMap[T]) => void, options?: boolean | EventListenerOptions): this;
1565
1872
  /**
1566
1873
  * Dispatches a DOM event on the document object.
1567
1874
  *
@@ -1601,8 +1908,9 @@ declare class DomWindow {
1601
1908
  * @param type - The event type to remove.
1602
1909
  * @param handler - The original handler function.
1603
1910
  * @param options - Optional event listener options.
1911
+ * @return This DomElement instance for chaining.
1604
1912
  */
1605
- off<T extends keyof WindowEventMap>(type: T, handler: (ev: WindowEventMap[T]) => void, options?: boolean | EventListenerOptions): void;
1913
+ off<T extends keyof WindowEventMap>(type: T, handler: (ev: WindowEventMap[T]) => void, options?: boolean | EventListenerOptions): this;
1606
1914
  /**
1607
1915
  * Dispatches a DOM event on the window object.
1608
1916
  *
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var e=class{p(e){return this.setStyleProp(`padding`,e)}pt(e){return this.setStyleProp(`paddingTop`,e)}pr(e){return this.setStyleProp(`paddingRight`,e)}pb(e){return this.setStyleProp(`paddingBottom`,e)}pl(e){return this.setStyleProp(`paddingLeft`,e)}px(e){return this.pl(e).pr(e)}py(e){return this.pt(e).pb(e)}m(e){return this.setStyleProp(`margin`,e)}mt(e){return this.setStyleProp(`marginTop`,e)}mr(e){return this.setStyleProp(`marginRight`,e)}mb(e){return this.setStyleProp(`marginBottom`,e)}ml(e){return this.setStyleProp(`marginLeft`,e)}radius(e){return this.setStyleProp(`borderRadius`,e)}radiusTopLeft(e){return this.setStyleProp(`borderTopLeftRadius`,e)}radiusTopRight(e){return this.setStyleProp(`borderTopRightRadius`,e)}radiusBottomLeft(e){return this.setStyleProp(`borderBottomLeftRadius`,e)}radiusBottomRight(e){return this.setStyleProp(`borderBottomRightRadius`,e)}radiusTop(e){return this.radiusTopLeft(e).radiusTopRight(e)}radiusBottom(e){return this.radiusBottomLeft(e).radiusBottomRight(e)}radiusLeft(e){return this.radiusTopLeft(e).radiusBottomLeft(e)}radiusRight(e){return this.radiusTopRight(e).radiusBottomRight(e)}radiusX(e){return this.radiusLeft(e).radiusRight(e)}radiusY(e){return this.radiusTop(e).radiusBottom(e)}display(e){return this.setStyleProp(`display`,e)}flexShrink(e){return this.setStyleProp(`flexShrink`,e)}flex(e){return this.setStyleProp(`flex`,e)}bgColor(e){return this.setStyleProp(`backgroundColor`,e)}color(e){return this.setStyleProp(`color`,e)}w(e){return this.setStyleProp(`width`,e)}h(e){return this.setStyleProp(`height`,e)}minW(e){return this.setStyleProp(`minWidth`,e)}maxW(e){return this.setStyleProp(`maxWidth`,e)}minH(e){return this.setStyleProp(`minHeight`,e)}maxH(e){return this.setStyleProp(`maxHeight`,e)}b(e){return this.setStyleProp(`border`,e)}bt(e){return this.setStyleProp(`borderTop`,e)}br(e){return this.setStyleProp(`borderRight`,e)}bb(e){return this.setStyleProp(`borderBottom`,e)}bl(e){return this.setStyleProp(`borderLeft`,e)}bx(e){return this.setStyleProp(`borderLeft`,e),this.setStyleProp(`borderRight`,e),this}by(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderBottom`,e),this}btl(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderLeft`,e),this}btr(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderRight`,e),this}bbl(e){return this.setStyleProp(`borderBottom`,e),this.setStyleProp(`borderLeft`,e),this}bbr(e){return this.setStyleProp(`borderBottom`,e),this.setStyleProp(`borderRight`,e),this}overflow(e){return this.setStyleProp(`overflow`,e)}overflowY(e){return this.setStyleProp(`overflowY`,e)}overflowX(e){return this.setStyleProp(`overflowX`,e)}fontSize(e){return this.setStyleProp(`fontSize`,e)}fontWeight(e){return this.setStyleProp(`fontWeight`,e)}fontFamily(e){return this.setStyleProp(`fontFamily`,e)}fontStyle(e){return this.setStyleProp(`fontStyle`,e)}textAlign(e){return this.setStyleProp(`textAlign`,e)}textDecoration(e){return this.setStyleProp(`textDecoration`,e)}pos(e){return this.setStyleProp(`position`,e)}top(e){return this.setStyleProp(`top`,e)}bottom(e){return this.setStyleProp(`bottom`,e)}left(e){return this.setStyleProp(`left`,e)}right(e){return this.setStyleProp(`right`,e)}cursor(e){return this.setStyleProp(`cursor`,e)}alignItems(e){return this.setStyleProp(`alignItems`,e)}justifyContent(e){return this.setStyleProp(`justifyContent`,e)}gap(e){return this.setStyleProp(`gap`,e)}flexDirection(e){return this.setStyleProp(`flexDirection`,e)}templateColumns(e){return this.setStyleProp(`gridTemplateColumns`,e)}templateRows(e){return this.setStyleProp(`gridTemplateRows`,e)}appearance(e){return this.setStyleProp(`appearance`,e)}userSelect(e){return this.setStyleProp(`userSelect`,e)}verticalAlign(e){return this.setStyleProp(`verticalAlign`,e)}whiteSpace(e){return this.setStyleProp(`whiteSpace`,e)}textOverflow(e){return this.setStyleProp(`textOverflow`,e)}zIndex(e){return this.setStyleProp(`zIndex`,e)}opacity(e){return this.setStyleProp(`opacity`,e)}transform(e){return this.setStyleProp(`transform`,e)}translate(e,t){let n=typeof e==`number`?`${e}px`:e,r=typeof t==`number`?`${t}px`:t;return this.setStyleProp(`transform`,`translate(${n}, ${r})`)}translateX(e){let t=typeof e==`number`?`${e}px`:e;return this.setStyleProp(`transform`,`translateX(${t})`)}translateY(e){let t=typeof e==`number`?`${e}px`:e;return this.setStyleProp(`transform`,`translateY(${t})`)}scale(e,t){let n=typeof e==`number`?e.toString():e,r=typeof t==`number`?t.toString():t;return this.setStyleProp(`transform`,`scale(${n}, ${r})`)}scaleX(e){let t=typeof e==`number`?e.toString():e;return this.setStyleProp(`transform`,`scaleX(${t})`)}scaleY(e){let t=typeof e==`number`?e.toString():e;return this.setStyleProp(`transform`,`scaleY(${t})`)}rotate(e){let t=typeof e==`number`?`${e}deg`:e;return this.setStyleProp(`transform`,`rotate(${t})`)}rotateX(e){let t=typeof e==`number`?`${e}deg`:e;return this.setStyleProp(`transform`,`rotateX(${t})`)}rotateY(e){let t=typeof e==`number`?`${e}deg`:e;return this.setStyleProp(`transform`,`rotateY(${t})`)}rotateZ(e){let t=typeof e==`number`?`${e}deg`:e;return this.setStyleProp(`transform`,`rotateZ(${t})`)}transformOrigin(e){return this.setStyleProp(`transformOrigin`,e)}transition(e){return this.setStyleProp(`transition`,e)}willChange(e){return this.setStyleProp(`willChange`,e)}boxShadow(e){return this.setStyleProp(`boxShadow`,e)}overflowEllipsis(){return this.overflow(`hidden`).whiteSpace(`nowrap`).textOverflow(`ellipsis`)}style(e){for(let t of Object.keys(e))this.setStyleProp(t,e[t]);return this}};const t={opacity:1,zIndex:1,fontWeight:1,lineHeight:1,flexGrow:1,flexShrink:1,order:1,zoom:1,scale:1,counterIncrement:1,counterReset:1,tabSize:1,orphans:1,widows:1,columns:1,columnCount:1,gridRow:1,gridColumn:1},n={WebkitAppearance:1},r=`svg.svgA.animate.animateMotion.animateTransform.circle.clipPath.defs.desc.ellipse.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.filter.foreignObject.g.image.line.linearGradient.marker.mask.metadata.mpath.path.pattern.polygon.polyline.radialGradient.rect.script.set.stop.style.switch.symbol.text.textPath.title.tspan.use.view`.split(`.`),i={svgA:`a`};function a(){return`${Date.now().toString(36)}-${(o++).toString(36)}`}let o=0;function s(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}function c(e,n){return typeof n==`number`?t[e]?String(n):`${n}px`:n}const l=Symbol(`BaseDomIdentity`);var u=class t extends e{[l]=!0;getClientWidth(){return this.dom.clientWidth??0}getClientHeight(){return this.dom.clientHeight??0}getRect(){return this.dom.getBoundingClientRect()}getComputedStyle(){return window.getComputedStyle(this.dom)}className(e){return e==null?this.dom.removeAttribute(`class`):this.dom.setAttribute(`class`,e),this}toggleClass(e,t){return this.dom.classList.toggle(e,t),this}on(e,t,n){return this.dom.addEventListener(e,t,n),this}off(e,t,n){this.dom.removeEventListener(e,t,n)}add(...e){return this.dom.append(...e.map(e=>this.resolveNode(e))),this}insertAtIndex(e,...t){let n=Array.from(this.dom.children),r=Math.max(0,Math.min(e,n.length));for(let e of t){let t=n[r]??null;this.dom.insertBefore(this.resolveNode(e),t),r++}return this}setChildren(...e){return this.clear().add(...e)}setChildrenFromIndex(e,...t){let n=Array.from(this.dom.children),r=n.length,i=Math.max(0,Math.min(e,r));for(let e=i;e<r;e++)this.dom.removeChild(n[e]);let a=this.dom.children[i]??null;for(let e of t)this.dom.insertBefore(this.resolveNode(e),a);return this}clear(e,t){let n=Array.from(this.dom.children),r=Math.max(0,e??0),i=Math.min(n.length,t??n.length);for(let e=r;e<i;e++)this.dom.removeChild(n[e]);return this}contains(e){let n=e instanceof t?e.dom:e;return this.dom.contains(n)}ref(e){return e(this),this}resolveNode(e){return typeof e==`string`||typeof e==`number`?document.createTextNode(String(e)):t.isBaseDom(e)?e.dom:e}setStyleProp(e,t){return t===void 0?(this.dom.style.removeProperty(s(e)),this):(this.dom.style.setProperty(s(e),c(e,t)),this)}static isBaseDom(e){return typeof e!=`object`||!e?!1:Object.getOwnPropertySymbols(e).includes(l)}},d=class extends u{constructor(e,t){super(),this._tag=i[e]??e,this._isSvg=r.includes(this._tag),this._dom=t??(this._isSvg?document.createElementNS(`http://www.w3.org/2000/svg`,this._tag):document.createElement(this._tag))}_tag;_isSvg;_dom;get tag(){return this._tag}get isSvg(){return this._isSvg}get dom(){return this._dom}getText(){return this._dom.textContent}text(e){return this._dom.textContent=e==null?``:String(e),this}remove(){this.dom.remove()}getAttr(e){return this.dom.getAttribute(e)}attr(e,t){return t===void 0?this.dom.removeAttribute(e):this.dom.setAttribute(e,String(t)),this}attrs(e){for(let[t,n]of Object.entries(e))this.attr(t,n);return this}getProp(e){return this.dom[e]}prop(e,t){return this.dom[e]=t,this}props(e){for(let[t,n]of Object.entries(e))this.prop(t,n);return this}id(e){return this._dom.id=e??``,this}htmlFor(e){return this.tag===`label`&&(this.dom.htmlFor=e??``),this}title(e){return e===void 0?this.dom.removeAttribute(`title`):this.dom.setAttribute(`title`,e),this}disabled(e){return e?this.dom.setAttribute(`disabled`,``):this.dom.removeAttribute(`disabled`),this}disable(){return this.disabled(!0)}enable(){return this.disabled(!1)}popover(e){return e===void 0?this.dom.removeAttribute(`popover`):this.dom.setAttribute(`popover`,e),this}showPopover(){return this.dom.showPopover(),this}hidePopover(){return this.dom.hidePopover(),this}};function f(e){return new d(e)}function p(e){let t=document.querySelector(e);return new d(t.tagName.toLowerCase(),t)}var m=class extends d{constructor(){super(`a`)}href(e){return this.dom.href=e,this}};function h(){return new m}var g=class extends d{constructor(){super(`button`)}type(e){return this.dom.type=e,this}};function _(){return new g}var v=class extends d{constructor(e){super(`canvas`,e)}_size={width:this.dom.width,height:this.dom.height};getWidth(){return this.dom.width}getHeight(){return this.dom.height}width(e){return this.dom.width=e,this}height(e){return this.dom.height=e,this}setSize(e,t){return this.dom.width=e,this.dom.height=t,this}getSize(){return this._size.width=this.dom.width,this._size.height=this.dom.height,this._size}getAspect(){return this.dom.width/this.dom.height}getAspectScale(e){let t=this.dom.width/this.dom.height,n,r,i;return t>=1?(n=1/t,r=1,i=1):(n=1,r=t,i=1),e.x=n,e.y=r,e.z=i,e}};function y(){return new v}var b=class extends e{constructor(e,t,n){super(),this._sheet=e,this._index=t,this._rule=n}_sheet;_index;_rule;get sheet(){return this._sheet}get index(){return this._index}get rule(){return this._rule}get selectorText(){return this._rule.selectorText}remove(){this._sheet.removeRule(this)}extend(e){return this.sheet.cssRule(`${this.selectorText}${e}`)}hover(){return this.extend(`:hover`)}focus(){return this.extend(`:focus`)}focusWithin(){return this.extend(`:focus-within`)}active(){return this.extend(`:active`)}disabled(){return this.extend(`:disabled`)}setStyleProp(e,t){return t===void 0?(this.rule.style.removeProperty(s(e)),this):(this.rule.style.setProperty(s(e),c(e,t)),this)}},x=class extends u{get dom(){return document.body}};function S(){return new x}var C=class{on(e,t,n){return document.addEventListener(e,t,n),this}off(e,t,n){document.removeEventListener(e,t,n)}dispatch(e){return document.dispatchEvent(e),this}};function w(){return new C}var T=class{on(e,t,n){return window.addEventListener(e,t,n),this}off(e,t,n){window.removeEventListener(e,t,n)}dispatch(e){return window.dispatchEvent(e),this}};function E(){return new T}var D=class extends d{constructor(){super(`iframe`)}src(e){return this.dom.src=e,this}allowFullscreen(e=!0){return this.dom.allowFullscreen=e,this}width(e){return this.dom.width=c(`width`,e),this}height(e){return this.dom.height=c(`height`,e),this}setSize(e,t){return this.dom.width=c(`width`,e),this.dom.height=c(`height`,t),this}reload(){this.dom.src=this.dom.src}};function O(){return new D}var k=class extends d{constructor(){super(`img`)}getNaturalWidth(){return this.dom.naturalWidth??0}getNaturalHeight(){return this.dom.naturalHeight??0}src(e){return this.dom.src=e,this}width(e){return this.dom.width=e,this}height(e){return this.dom.height=e,this}setSize(e,t){return this.width(e).height(t)}alt(e){return this.dom.alt=e,this}};function A(){return new k}var j=class extends d{constructor(){super(`input`),this.dom.type=`checkbox`}name(e){return this.dom.name=e,this}checked(e){return this.prop(`checked`,e),this}isChecked(){return this.getProp(`checked`)}},M=class extends d{constructor(){super(`input`),this._dom.type=`color`}_rgb={r:1,g:1,b:1};name(e){return this._dom.name=e,this}value(e){return this._dom.value=e,this}getValue(){return this._dom.value}getRGB(){let e=this._dom.value,t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return this._rgb.r=t,this._rgb.g=n,this._rgb.b=r,this._rgb}getNormalizedRGB(){let e=this._dom.value,t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return this._rgb.r=t/255,this._rgb.g=n/255,this._rgb.b=r/255,this._rgb}},N=class extends d{constructor(){super(`input`),this.dom.type=`number`}name(e){return this.dom.name=e,this}value(e){return this.dom.value=String(e),this}getValue(){return Number(this.dom.value)}min(e){return this.dom.min=String(e),this}max(e){return this.dom.max=String(e),this}step(e){return this.dom.step=String(e),this}placeholder(e){return this.dom.placeholder=e,this}},P=class extends d{constructor(){super(`input`),this.dom.type=`range`}name(e){return this.dom.name=e,this}value(e){return this.dom.value=String(e),this}getValue(){return Number(this.dom.value)}min(e){return this.dom.min=String(e),this}max(e){return this.dom.max=String(e),this}step(e){return this.dom.step=String(e),this}},F=class extends d{constructor(){super(`input`),this.dom.type=`text`}name(e){return this.dom.name=e,this}value(e){return this.dom.value=e,this}getValue(){return this.dom.value}placeholder(e){return this.dom.placeholder=e,this}};function I(e){switch(e){case`text`:return new F;case`number`:return new N;case`checkbox`:return new j;case`color`:return new M;case`range`:return new P}}var L=class{constructor(e,t,n){this._sheet=e,this._index=t,this._rule=n}_sheet;_index;_rule;get sheet(){return this._sheet}get index(){return this._index}get rule(){return this._rule}get length(){return this._rule.cssRules.length}get mediaText(){return this._rule.media.mediaText}cssRule(e){let t=this.length;return this.rule.insertRule(`${e}{}`,t),new b(this.sheet,t,this.rule.cssRules.item(t))}remove(){this.sheet.removeRule(this)}removeRule(e){this.rule.deleteRule(e.index)}},R=class extends d{constructor(){super(`option`)}value(e){return this.dom.value=String(e),this}getValue(){return this.dom.value}};function z(){return new R}var B=class extends d{constructor(){super(`progress`)}value(e){return this.dom.value=e,this}getValue(){return this.dom.value}max(e){return this.dom.max=e,this}getMax(){return this.dom.max}indeterminate(){return this.dom.removeAttribute(`value`),this}};function V(){return new B}var H=class extends d{constructor(){super(`select`)}name(e){return this.dom.name=e,this}value(e){return this.dom.value=String(e),this}getValue(){return this.dom.value}};function U(){return new H}var W=class e{constructor(e){this._dom=e}_dom;get dom(){return this._dom}get sheet(){return this.dom.sheet}get length(){return this.sheet.cssRules.length}cssRule(e){let t=this.length;return this.sheet.insertRule(`${e}{}`,t),new b(this,t,this.sheet.cssRules.item(t))}mediaRule(e){let t=this.length;return this.sheet.insertRule(`@media(${e}){}`,t),new L(this,t,this.sheet.cssRules.item(t))}mediaMinWidth(e){return this.mediaRule(`min-width: ${c(`min-width`,e)}`)}mediaMaxWidth(e){return this.mediaRule(`max-width: ${c(`max-width`,e)}`)}removeRule(e){this.sheet.deleteRule(e.index)}static getSheet(t=e.DEFAULT_STYLE_ID){let n=document.head.querySelector(`#${t}`);if(n==null){let n=document.createElement(`style`);return n.id=t,n.setAttribute(`type`,`text/css`),document.head.append(n),new e(n)}else return new e(n)}static DEFAULT_STYLE_ID=`__neptune-style__`};export{f as $,h as $a,S as $body,_ as $btn,y as $canvas,w as $document,O as $iframe,A as $img,I as $input,z as $option,V as $progress,p as $query,U as $select,E as $window,m as AnchorElement,u as BaseDom,e as BaseStyle,g as Button,v as Canvas,b as CssRule,x as DomBody,C as DomDocument,d as DomElement,T as DomWindow,D as IFrame,k as ImageElement,j as InputCheckbox,M as InputColor,N as InputNumber,P as InputRange,F as InputText,L as MediaRule,R as OptionElement,B as ProgressElement,r as SVG_TAGS,H as SelectElement,W as StyleSheet,i as TAG_ALIAS,t as UNITLESS_CSS_PROPS,n as VENDOR_CSS_PROPS,s as camelToKebab,c as getStyleValue,a as uniqueId};
1
+ var e=class{p(e){return this.setStyleProp(`padding`,e)}pt(e){return this.setStyleProp(`paddingTop`,e)}pr(e){return this.setStyleProp(`paddingRight`,e)}pb(e){return this.setStyleProp(`paddingBottom`,e)}pl(e){return this.setStyleProp(`paddingLeft`,e)}px(e){return this.pl(e).pr(e)}py(e){return this.pt(e).pb(e)}m(e){return this.setStyleProp(`margin`,e)}mt(e){return this.setStyleProp(`marginTop`,e)}mr(e){return this.setStyleProp(`marginRight`,e)}mb(e){return this.setStyleProp(`marginBottom`,e)}ml(e){return this.setStyleProp(`marginLeft`,e)}radius(e){return this.setStyleProp(`borderRadius`,e)}radiusTopLeft(e){return this.setStyleProp(`borderTopLeftRadius`,e)}radiusTopRight(e){return this.setStyleProp(`borderTopRightRadius`,e)}radiusBottomLeft(e){return this.setStyleProp(`borderBottomLeftRadius`,e)}radiusBottomRight(e){return this.setStyleProp(`borderBottomRightRadius`,e)}radiusTop(e){return this.radiusTopLeft(e).radiusTopRight(e)}radiusBottom(e){return this.radiusBottomLeft(e).radiusBottomRight(e)}radiusLeft(e){return this.radiusTopLeft(e).radiusBottomLeft(e)}radiusRight(e){return this.radiusTopRight(e).radiusBottomRight(e)}radiusX(e){return this.radiusLeft(e).radiusRight(e)}radiusY(e){return this.radiusTop(e).radiusBottom(e)}display(e){return this.setStyleProp(`display`,e)}flexShrink(e){return this.setStyleProp(`flexShrink`,e)}flex(e){return this.setStyleProp(`flex`,e)}bgColor(e){return this.setStyleProp(`backgroundColor`,e)}color(e){return this.setStyleProp(`color`,e)}w(e){return this.setStyleProp(`width`,e)}h(e){return this.setStyleProp(`height`,e)}minW(e){return this.setStyleProp(`minWidth`,e)}maxW(e){return this.setStyleProp(`maxWidth`,e)}minH(e){return this.setStyleProp(`minHeight`,e)}maxH(e){return this.setStyleProp(`maxHeight`,e)}b(e){return this.setStyleProp(`border`,e)}bWidth(e){let t=typeof e==`number`?`${e}px`:e;return this.setStyleProp(`borderWidth`,t)}bStyle(e){return this.setStyleProp(`borderStyle`,e)}bColor(e){return this.setStyleProp(`borderColor`,e)}bt(e){return this.setStyleProp(`borderTop`,e)}btWidth(e){let t=typeof e==`number`?`${e}px`:e;return this.setStyleProp(`borderTopWidth`,t)}btStyle(e){return this.setStyleProp(`borderTopStyle`,e)}btColor(e){return this.setStyleProp(`borderTopColor`,e)}br(e){return this.setStyleProp(`borderRight`,e)}brWidth(e){let t=typeof e==`number`?`${e}px`:e;return this.setStyleProp(`borderRightWidth`,t)}brStyle(e){return this.setStyleProp(`borderRightStyle`,e)}brColor(e){return this.setStyleProp(`borderRightColor`,e)}bb(e){return this.setStyleProp(`borderBottom`,e)}bbWidth(e){let t=typeof e==`number`?`${e}px`:e;return this.setStyleProp(`borderBottomWidth`,t)}bbStyle(e){return this.setStyleProp(`borderBottomStyle`,e)}bbColor(e){return this.setStyleProp(`borderBottomColor`,e)}bl(e){return this.setStyleProp(`borderLeft`,e)}blWidth(e){let t=typeof e==`number`?`${e}px`:e;return this.setStyleProp(`borderLeftWidth`,t)}blStyle(e){return this.setStyleProp(`borderLeftStyle`,e)}blColor(e){return this.setStyleProp(`borderLeftColor`,e)}bx(e){return this.setStyleProp(`borderLeft`,e),this.setStyleProp(`borderRight`,e),this}by(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderBottom`,e),this}btl(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderLeft`,e),this}btr(e){return this.setStyleProp(`borderTop`,e),this.setStyleProp(`borderRight`,e),this}bbl(e){return this.setStyleProp(`borderBottom`,e),this.setStyleProp(`borderLeft`,e),this}bbr(e){return this.setStyleProp(`borderBottom`,e),this.setStyleProp(`borderRight`,e),this}overflow(e){return this.setStyleProp(`overflow`,e)}overflowY(e){return this.setStyleProp(`overflowY`,e)}overflowX(e){return this.setStyleProp(`overflowX`,e)}fontSize(e){return this.setStyleProp(`fontSize`,e)}fontWeight(e){return this.setStyleProp(`fontWeight`,e)}fontFamily(e){return this.setStyleProp(`fontFamily`,e)}fontStyle(e){return this.setStyleProp(`fontStyle`,e)}textAlign(e){return this.setStyleProp(`textAlign`,e)}textDecoration(e){return this.setStyleProp(`textDecoration`,e)}pos(e){return this.setStyleProp(`position`,e)}top(e){return this.setStyleProp(`top`,e)}bottom(e){return this.setStyleProp(`bottom`,e)}left(e){return this.setStyleProp(`left`,e)}right(e){return this.setStyleProp(`right`,e)}cursor(e){return this.setStyleProp(`cursor`,e)}alignItems(e){return this.setStyleProp(`alignItems`,e)}justifyContent(e){return this.setStyleProp(`justifyContent`,e)}gap(e){return this.setStyleProp(`gap`,e)}flexDirection(e){return this.setStyleProp(`flexDirection`,e)}templateColumns(e){return this.setStyleProp(`gridTemplateColumns`,e)}templateRows(e){return this.setStyleProp(`gridTemplateRows`,e)}appearance(e){return this.setStyleProp(`appearance`,e)}userSelect(e){return this.setStyleProp(`userSelect`,e)}verticalAlign(e){return this.setStyleProp(`verticalAlign`,e)}whiteSpace(e){return this.setStyleProp(`whiteSpace`,e)}textOverflow(e){return this.setStyleProp(`textOverflow`,e)}zIndex(e){return this.setStyleProp(`zIndex`,e)}opacity(e){return this.setStyleProp(`opacity`,e)}transform(e){return this.setStyleProp(`transform`,e)}translate(e,t){let n=typeof e==`number`?`${e}px`:e,r=typeof t==`number`?`${t}px`:t;return this.setStyleProp(`transform`,`translate(${n}, ${r})`)}translateX(e){let t=typeof e==`number`?`${e}px`:e;return this.setStyleProp(`transform`,`translateX(${t})`)}translateY(e){let t=typeof e==`number`?`${e}px`:e;return this.setStyleProp(`transform`,`translateY(${t})`)}scale(e,t){let n=typeof e==`number`?e.toString():e,r=typeof t==`number`?t.toString():t;return this.setStyleProp(`transform`,`scale(${n}, ${r})`)}scaleX(e){let t=typeof e==`number`?e.toString():e;return this.setStyleProp(`transform`,`scaleX(${t})`)}scaleY(e){let t=typeof e==`number`?e.toString():e;return this.setStyleProp(`transform`,`scaleY(${t})`)}rotate(e){let t=typeof e==`number`?`${e}deg`:e;return this.setStyleProp(`transform`,`rotate(${t})`)}rotateX(e){let t=typeof e==`number`?`${e}deg`:e;return this.setStyleProp(`transform`,`rotateX(${t})`)}rotateY(e){let t=typeof e==`number`?`${e}deg`:e;return this.setStyleProp(`transform`,`rotateY(${t})`)}rotateZ(e){let t=typeof e==`number`?`${e}deg`:e;return this.setStyleProp(`transform`,`rotateZ(${t})`)}transformOrigin(e){return this.setStyleProp(`transformOrigin`,e)}transition(e){return this.setStyleProp(`transition`,e)}willChange(e){return this.setStyleProp(`willChange`,e)}boxShadow(e){return this.setStyleProp(`boxShadow`,e)}boxSizing(e){return this.setStyleProp(`boxSizing`,e)}background(e){return this.setStyleProp(`background`,e)}outline(e){return this.setStyleProp(`outline`,e)}outlineWidth(e){let t=typeof e==`number`?`${e}px`:e;return this.setStyleProp(`outlineWidth`,t)}outlineStyle(e){return this.setStyleProp(`outlineStyle`,e)}outlineColor(e){return this.setStyleProp(`outlineColor`,e)}overflowEllipsis(){return this.overflow(`hidden`).whiteSpace(`nowrap`).textOverflow(`ellipsis`)}linearGradient(e,...t){let n=`linear-gradient(${e}, ${t.join(`, `)})`;return this.setStyleProp(`background`,n)}style(e){for(let t of Object.keys(e))this.setStyleProp(t,e[t]);return this}};const t={opacity:1,zIndex:1,fontWeight:1,lineHeight:1,flexGrow:1,flexShrink:1,order:1,zoom:1,scale:1,counterIncrement:1,counterReset:1,tabSize:1,orphans:1,widows:1,columns:1,columnCount:1,gridRow:1,gridColumn:1},n={WebkitAppearance:1},r=`svg.svgA.animate.animateMotion.animateTransform.circle.clipPath.defs.desc.ellipse.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.filter.foreignObject.g.image.line.linearGradient.marker.mask.metadata.mpath.path.pattern.polygon.polyline.radialGradient.rect.script.set.stop.style.switch.symbol.text.textPath.title.tspan.use.view`.split(`.`),i={svgA:`a`};function a(){return`${Date.now().toString(36)}-${(o++).toString(36)}`}let o=0;function s(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}function c(e,n){return typeof n==`number`?t[e]?String(n):`${n}px`:n}const l=Symbol(`BaseDomIdentity`);var u=class t extends e{[l]=!0;getClientWidth(){return this.dom.clientWidth??0}getClientHeight(){return this.dom.clientHeight??0}getRect(){return this.dom.getBoundingClientRect()}getComputedStyle(){return window.getComputedStyle(this.dom)}className(e){return e==null?this.dom.removeAttribute(`class`):this.dom.setAttribute(`class`,e),this}toggleClass(e,t){return this.dom.classList.toggle(e,t),this}on(e,t,n){return this.dom.addEventListener(e,t,n),this}off(e,t,n){return this.dom.removeEventListener(e,t,n),this}add(...e){return this.dom.append(...e.map(e=>this.resolveNode(e))),this}insertAtIndex(e,...t){let n=Array.from(this.dom.children),r=Math.max(0,Math.min(e,n.length));for(let e of t){let t=n[r]??null;this.dom.insertBefore(this.resolveNode(e),t),r++}return this}setChildren(...e){return this.clear().add(...e)}setChildrenFromIndex(e,...t){let n=Array.from(this.dom.children),r=n.length,i=Math.max(0,Math.min(e,r));for(let e=i;e<r;e++)this.dom.removeChild(n[e]);let a=this.dom.children[i]??null;for(let e of t)this.dom.insertBefore(this.resolveNode(e),a);return this}clear(e,t){let n=Array.from(this.dom.children),r=Math.max(0,e??0),i=Math.min(n.length,t??n.length);for(let e=r;e<i;e++)this.dom.removeChild(n[e]);return this}contains(e){let n=e instanceof t?e.dom:e;return this.dom.contains(n)}ref(e){return e(this),this}resolveNode(e){return typeof e==`string`||typeof e==`number`?document.createTextNode(String(e)):t.isBaseDom(e)?e.dom:e}setStyleProp(e,t){return t===void 0?(this.dom.style.removeProperty(s(e)),this):(this.dom.style.setProperty(s(e),c(e,t)),this)}static isBaseDom(e){return typeof e!=`object`||!e?!1:Object.getOwnPropertySymbols(e).includes(l)}},d=class extends u{constructor(e,t){super(),this._tag=i[e]??e,this._isSvg=r.includes(this._tag),this._dom=t??(this._isSvg?document.createElementNS(`http://www.w3.org/2000/svg`,this._tag):document.createElement(this._tag))}_tag;_isSvg;_dom;get tag(){return this._tag}get isSvg(){return this._isSvg}get dom(){return this._dom}getText(){return this._dom.textContent}text(e){return this._dom.textContent=e==null?``:String(e),this}remove(){this.dom.remove()}getAttr(e){return this.dom.getAttribute(e)}attr(e,t){return t===void 0?this.dom.removeAttribute(e):this.dom.setAttribute(e,String(t)),this}attrs(e){for(let[t,n]of Object.entries(e))this.attr(t,n);return this}getProp(e){return this.dom[e]}prop(e,t){return this.dom[e]=t,this}props(e){for(let[t,n]of Object.entries(e))this.prop(t,n);return this}id(e){return this._dom.id=e??``,this}htmlFor(e){return this.tag===`label`&&(this.dom.htmlFor=e??``),this}title(e){return e===void 0?this.dom.removeAttribute(`title`):this.dom.setAttribute(`title`,e),this}disabled(e){return e?this.dom.setAttribute(`disabled`,``):this.dom.removeAttribute(`disabled`),this}disable(){return this.disabled(!0)}enable(){return this.disabled(!1)}popover(e){return e===void 0?this.dom.removeAttribute(`popover`):this.dom.setAttribute(`popover`,e),this}showPopover(){return this.dom.showPopover(),this}hidePopover(){return this.dom.hidePopover(),this}};function f(e){return new d(e)}function p(e){let t=document.querySelector(e);return new d(t.tagName.toLowerCase(),t)}var m=class extends d{constructor(){super(`a`)}href(e){return this.dom.href=e,this}};function h(){return new m}var g=class extends d{constructor(){super(`button`)}type(e){return this.dom.type=e,this}};function _(){return new g}var v=class extends d{constructor(e){super(`canvas`,e)}_size={width:this.dom.width,height:this.dom.height};getWidth(){return this.dom.width}getHeight(){return this.dom.height}width(e){return this.dom.width=e,this}height(e){return this.dom.height=e,this}setSize(e,t){return this.dom.width=e,this.dom.height=t,this}getSize(){return this._size.width=this.dom.width,this._size.height=this.dom.height,this._size}getAspect(){return this.dom.width/this.dom.height}getAspectScale(e){let t=this.dom.width/this.dom.height,n,r,i;return t>=1?(n=1/t,r=1,i=1):(n=1,r=t,i=1),e.x=n,e.y=r,e.z=i,e}};function y(){return new v}var b=class extends e{constructor(e,t,n){super(),this._sheet=e,this._index=t,this._rule=n}_sheet;_index;_rule;get sheet(){return this._sheet}get index(){return this._index}get rule(){return this._rule}get selectorText(){return this._rule.selectorText}remove(){this._sheet.removeRule(this)}extend(e){return this.sheet.cssRule(`${this.selectorText}${e}`)}hover(){return this.extend(`:hover`)}focus(){return this.extend(`:focus`)}focusWithin(){return this.extend(`:focus-within`)}active(){return this.extend(`:active`)}disabled(){return this.extend(`:disabled`)}setStyleProp(e,t){return t===void 0?(this.rule.style.removeProperty(s(e)),this):(this.rule.style.setProperty(s(e),c(e,t)),this)}},x=class extends u{get dom(){return document.body}};function S(){return new x}var C=class{on(e,t,n){return document.addEventListener(e,t,n),this}off(e,t,n){return document.removeEventListener(e,t,n),this}dispatch(e){return document.dispatchEvent(e),this}};function w(){return new C}var T=class{on(e,t,n){return window.addEventListener(e,t,n),this}off(e,t,n){return window.removeEventListener(e,t,n),this}dispatch(e){return window.dispatchEvent(e),this}};function E(){return new T}var D=class extends d{constructor(){super(`iframe`)}src(e){return this.dom.src=e,this}allowFullscreen(e=!0){return this.dom.allowFullscreen=e,this}width(e){return this.dom.width=c(`width`,e),this}height(e){return this.dom.height=c(`height`,e),this}setSize(e,t){return this.dom.width=c(`width`,e),this.dom.height=c(`height`,t),this}reload(){this.dom.src=this.dom.src}};function O(){return new D}var k=class extends d{constructor(){super(`img`)}getNaturalWidth(){return this.dom.naturalWidth??0}getNaturalHeight(){return this.dom.naturalHeight??0}src(e){return this.dom.src=e,this}width(e){return this.dom.width=e,this}height(e){return this.dom.height=e,this}setSize(e,t){return this.width(e).height(t)}alt(e){return this.dom.alt=e,this}};function A(){return new k}var j=class extends d{constructor(){super(`input`),this.dom.type=`checkbox`}name(e){return this.dom.name=e,this}checked(e){return this.prop(`checked`,e),this}isChecked(){return this.getProp(`checked`)}},M=class extends d{constructor(){super(`input`),this._dom.type=`color`}_rgb={r:1,g:1,b:1};name(e){return this._dom.name=e,this}value(e){return this._dom.value=e,this}getValue(){return this._dom.value}getRGB(){let e=this._dom.value,t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return this._rgb.r=t,this._rgb.g=n,this._rgb.b=r,this._rgb}getNormalizedRGB(){let e=this._dom.value,t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return this._rgb.r=t/255,this._rgb.g=n/255,this._rgb.b=r/255,this._rgb}},N=class extends d{constructor(){super(`input`),this.dom.type=`number`}name(e){return this.dom.name=e,this}value(e){return this.dom.value=String(e),this}getValue(){return Number(this.dom.value)}min(e){return this.dom.min=String(e),this}max(e){return this.dom.max=String(e),this}step(e){return this.dom.step=String(e),this}placeholder(e){return this.dom.placeholder=e,this}},P=class extends d{constructor(){super(`input`),this.dom.type=`range`}getValue(){return Number(this.dom.value)}getMin(){return Number(this.dom.min)}getMax(){return Number(this.dom.max)}getStep(){return Number(this.dom.step)}name(e){return this.dom.name=e,this}value(e){return this.dom.value=String(e),this}min(e){return this.dom.min=String(e),this}max(e){return this.dom.max=String(e),this}step(e){return this.dom.step=String(e),this}bounds(e,t,n){return this.min(e).max(t).step(n)}},F=class extends d{constructor(){super(`input`),this.dom.type=`text`}name(e){return this.dom.name=e,this}value(e){return this.dom.value=e,this}getValue(){return this.dom.value}placeholder(e){return this.dom.placeholder=e,this}};function I(e){switch(e){case`text`:return new F;case`number`:return new N;case`checkbox`:return new j;case`color`:return new M;case`range`:return new P}}var L=class{constructor(e,t,n){this._sheet=e,this._index=t,this._rule=n}_sheet;_index;_rule;get sheet(){return this._sheet}get index(){return this._index}get rule(){return this._rule}get length(){return this._rule.cssRules.length}get mediaText(){return this._rule.media.mediaText}cssRule(e){let t=this.length;return this.rule.insertRule(`${e}{}`,t),new b(this.sheet,t,this.rule.cssRules.item(t))}remove(){this.sheet.removeRule(this)}removeRule(e){this.rule.deleteRule(e.index)}},R=class extends d{constructor(){super(`option`)}value(e){return this.dom.value=String(e),this}getValue(){return this.dom.value}};function z(){return new R}var B=class extends d{constructor(){super(`progress`)}value(e){return this.dom.value=e,this}getValue(){return this.dom.value}max(e){return this.dom.max=e,this}getMax(){return this.dom.max}indeterminate(){return this.dom.removeAttribute(`value`),this}};function V(){return new B}var H=class extends d{constructor(){super(`select`)}name(e){return this.dom.name=e,this}value(e){return this.dom.value=String(e),this}getValue(){return this.dom.value}};function U(){return new H}var W=class e{constructor(e){this._dom=e}_dom;get dom(){return this._dom}get sheet(){return this.dom.sheet}get length(){return this.sheet.cssRules.length}cssRule(e){let t=this.length;return this.sheet.insertRule(`${e}{}`,t),new b(this,t,this.sheet.cssRules.item(t))}mediaRule(e){let t=this.length;return this.sheet.insertRule(`@media(${e}){}`,t),new L(this,t,this.sheet.cssRules.item(t))}mediaMinWidth(e){return this.mediaRule(`min-width: ${c(`min-width`,e)}`)}mediaMaxWidth(e){return this.mediaRule(`max-width: ${c(`max-width`,e)}`)}removeRule(e){this.sheet.deleteRule(e.index)}static getSheet(t=e.DEFAULT_STYLE_ID){let n=document.head.querySelector(`#${t}`);if(n==null){let n=document.createElement(`style`);return n.id=t,n.setAttribute(`type`,`text/css`),document.head.append(n),new e(n)}else return new e(n)}static DEFAULT_STYLE_ID=`__neptune-style__`};export{f as $,h as $a,S as $body,_ as $btn,y as $canvas,w as $document,O as $iframe,A as $img,I as $input,z as $option,V as $progress,p as $query,U as $select,E as $window,m as AnchorElement,u as BaseDom,e as BaseStyle,g as Button,v as Canvas,b as CssRule,x as DomBody,C as DomDocument,d as DomElement,T as DomWindow,D as IFrame,k as ImageElement,j as InputCheckbox,M as InputColor,N as InputNumber,P as InputRange,F as InputText,L as MediaRule,R as OptionElement,B as ProgressElement,r as SVG_TAGS,H as SelectElement,W as StyleSheet,i as TAG_ALIAS,t as UNITLESS_CSS_PROPS,n as VENDOR_CSS_PROPS,s as camelToKebab,c as getStyleValue,a as uniqueId};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neptune3d/dom",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Helper classes and functions for the DOM.",
5
5
  "type": "module",
6
6
  "license": "MIT",