@neptune3d/dom 0.0.7 → 0.0.8

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
@@ -75,8 +75,7 @@ const sheet = StyleSheet.getSheet();
75
75
 
76
76
  // Insert a global rule
77
77
  const rule = sheet.cssRule(".list-item");
78
- rule.style({
79
- padding: "0.5rem",
78
+ rule.p("0.5rem").style({
80
79
  borderBottom: "1px solid #ccc",
81
80
  });
82
81
 
package/dist/index.d.ts CHANGED
@@ -382,6 +382,42 @@ declare abstract class BaseStyle {
382
382
  * @return This instance for chaining.
383
383
  */
384
384
  h(value: Property.Height | number | undefined): this;
385
+ /**
386
+ * Sets or clears the `min-width` style of the element.
387
+ * Accepts CSS width values (e.g., "100px", "50%") or numeric pixel values.
388
+ * Passing `undefined` removes the min-width style.
389
+ *
390
+ * @param value - The minimum width value to apply, or `undefined` to remove it.
391
+ * @return This instance for chaining.
392
+ */
393
+ minW(value: Property.MinWidth | number | undefined): this;
394
+ /**
395
+ * Sets or clears the `max-width` style of the element.
396
+ * Accepts CSS width values (e.g., "100px", "100%") or numeric pixel values.
397
+ * Passing `undefined` removes the max-width style.
398
+ *
399
+ * @param value - The maximum width value to apply, or `undefined` to remove it.
400
+ * @return This instance for chaining.
401
+ */
402
+ maxW(value: Property.MaxWidth | number | undefined): this;
403
+ /**
404
+ * Sets or clears the `min-height` style of the element.
405
+ * Accepts CSS height values (e.g., "100px", "50vh") or numeric pixel values.
406
+ * Passing `undefined` removes the min-height style.
407
+ *
408
+ * @param value - The minimum height value to apply, or `undefined` to remove it.
409
+ * @return This instance for chaining.
410
+ */
411
+ minH(value: Property.MinHeight | number | undefined): this;
412
+ /**
413
+ * Sets or clears the `max-height` style of the element.
414
+ * Accepts CSS height values (e.g., "100px", "100%") or numeric pixel values.
415
+ * Passing `undefined` removes the max-height style.
416
+ *
417
+ * @param value - The maximum height value to apply, or `undefined` to remove it.
418
+ * @return This instance for chaining.
419
+ */
420
+ maxH(value: Property.MaxHeight | number | undefined): this;
385
421
  /**
386
422
  * Sets the full border style.
387
423
  * @param value - The CSS border value (e.g., "1px solid #ccc").
@@ -534,25 +570,25 @@ declare abstract class BaseStyle {
534
570
  * @param value - The top offset value (e.g., "10px", "50%").
535
571
  * @return This instance for chaining.
536
572
  */
537
- posTop(value: Property.Top | number | undefined): this;
573
+ top(value: Property.Top | number | undefined): this;
538
574
  /**
539
575
  * Sets the CSS `bottom` offset.
540
576
  * @param value - The bottom offset value (e.g., "0", "2rem").
541
577
  * @return This instance for chaining.
542
578
  */
543
- posBottom(value: Property.Bottom | number | undefined): this;
579
+ bottom(value: Property.Bottom | number | undefined): this;
544
580
  /**
545
581
  * Sets the CSS `left` offset.
546
582
  * @param value - The left offset value (e.g., "5px", "auto").
547
583
  * @return This instance for chaining.
548
584
  */
549
- posLeft(value: Property.Left | number | undefined): this;
585
+ left(value: Property.Left | number | undefined): this;
550
586
  /**
551
587
  * Sets the CSS `right` offset.
552
588
  * @param value - The right offset value (e.g., "1em", "0").
553
589
  * @return This instance for chaining.
554
590
  */
555
- posRight(value: Property.Right | number | undefined): this;
591
+ right(value: Property.Right | number | undefined): this;
556
592
  /**
557
593
  * Sets the `cursor` style of the element.
558
594
  * Controls the mouse cursor appearance when hovering over the element.
@@ -675,6 +711,159 @@ declare abstract class BaseStyle {
675
711
  * @return This instance for chaining.
676
712
  */
677
713
  opacity(value: Property.Opacity | undefined): this;
714
+ /**
715
+ * Sets the `transform` style of the element.
716
+ * Applies visual transformations such as translation, rotation, scaling, or skewing.
717
+ * Accepts any valid CSS transform string (e.g., `"translateX(10px)"`, `"scale(1.2)"`), or `undefined` to remove it.
718
+ *
719
+ * @param value - The transform string to apply, or `undefined` to remove the style.
720
+ * @return This instance for chaining.
721
+ */
722
+ transform(value: Property.Transform | undefined): this;
723
+ /**
724
+ * Sets the `transform` style to a `translate(x, y)` value.
725
+ * Accepts either pixel numbers or full CSS unit strings (e.g., `"10px"`, `"50%"`, `"2em"`).
726
+ * Automatically appends `"px"` to numeric values.
727
+ * Overwrites any existing `transform` style — use with care if combining multiple transforms.
728
+ *
729
+ * @param x - Horizontal offset as a number (pixels) or CSS string.
730
+ * @param y - Vertical offset as a number (pixels) or CSS string.
731
+ * @return This instance for chaining.
732
+ */
733
+ translate(x: string | number, y: string | number): this;
734
+ /**
735
+ * Sets the `transform` style to a `translateX(x)` value.
736
+ * Moves the element horizontally using pixel or CSS units.
737
+ * Accepts either a number (pixels) or a full CSS unit string (e.g., `"50%"`, `"2em"`).
738
+ * Overwrites any existing `transform` style — use with care if combining multiple transforms.
739
+ *
740
+ * @param x - Horizontal offset as a number or CSS string.
741
+ * @return This instance for chaining.
742
+ */
743
+ translateX(x: string | number): this;
744
+ /**
745
+ * Sets the `transform` style to a `translateY(y)` value.
746
+ * Moves the element vertically using pixel or CSS units.
747
+ * Accepts either a number (pixels) or a full CSS unit string (e.g., `"50%"`, `"2em"`).
748
+ * Overwrites any existing `transform` style — use with care if combining multiple transforms.
749
+ *
750
+ * @param y - Vertical offset as a number or CSS string.
751
+ * @return This instance for chaining.
752
+ */
753
+ translateY(y: string | number): this;
754
+ /**
755
+ * Sets the `transform` style to a `scale(x, y)` value.
756
+ * Scales the element along the X and Y axes.
757
+ * Accepts either numeric scale factors (e.g., `1.2`) or full CSS unit strings (e.g., `"1.5"`).
758
+ * Automatically converts numeric values to string format.
759
+ * Overwrites any existing `transform` style — use with care if combining multiple transforms.
760
+ *
761
+ * @param x - Horizontal scale factor as a number or string.
762
+ * @param y - Vertical scale factor as a number or string.
763
+ * @return This instance for chaining.
764
+ */
765
+ scale(x: string | number, y: string | number): this;
766
+ /**
767
+ * Sets the `transform` style to a `scaleX(x)` value.
768
+ * Scales the element horizontally. Accepts numeric scale factors (e.g., `1.2`) or string values (e.g., `"1.5"`).
769
+ * Automatically converts numeric values to string format.
770
+ * Overwrites any existing `transform` style — use with care if combining multiple transforms.
771
+ *
772
+ * @param x - Horizontal scale factor as a number or string.
773
+ * @return This instance for chaining.
774
+ */
775
+ scaleX(x: string | number): this;
776
+ /**
777
+ * Sets the `transform` style to a `scaleY(y)` value.
778
+ * Scales the element vertically. Accepts numeric scale factors (e.g., `0.8`) or string values (e.g., `"1.25"`).
779
+ * Automatically converts numeric values to string format.
780
+ * Overwrites any existing `transform` style — use with care if combining multiple transforms.
781
+ *
782
+ * @param y - Vertical scale factor as a number or string.
783
+ * @return This instance for chaining.
784
+ */
785
+ scaleY(y: string | number): this;
786
+ /**
787
+ * Sets the `transform` style to a `rotate(angle)` value.
788
+ * Rotates the element clockwise by the specified angle.
789
+ * Accepts either a number (interpreted as degrees) or a full CSS angle string (e.g., `"45deg"`, `"0.5turn"`).
790
+ * Automatically appends `"deg"` to numeric values.
791
+ * Overwrites any existing `transform` style — use with care if combining multiple transforms.
792
+ *
793
+ * @param angle - Rotation angle as a number (degrees) or CSS string.
794
+ * @return This instance for chaining.
795
+ */
796
+ rotate(angle: string | number): this;
797
+ /**
798
+ * Sets the `transform` style to a `rotateX(angle)` value.
799
+ * Rotates the element around the X-axis in 3D space.
800
+ * Accepts either a number (degrees) or a full CSS angle string (e.g., `"45deg"`, `"1rad"`).
801
+ * Automatically appends `"deg"` to numeric values.
802
+ * Overwrites any existing `transform` style — use with care if combining multiple transforms.
803
+ *
804
+ * @param angle - Rotation angle as a number or CSS string.
805
+ * @return This instance for chaining.
806
+ */
807
+ rotateX(angle: string | number): this;
808
+ /**
809
+ * Sets the `transform` style to a `rotateY(angle)` value.
810
+ * Rotates the element around the Y-axis in 3D space.
811
+ * Accepts either a number (degrees) or a full CSS angle string (e.g., `"90deg"`, `"0.5turn"`).
812
+ * Automatically appends `"deg"` to numeric values.
813
+ * Overwrites any existing `transform` style — use with care if combining multiple transforms.
814
+ *
815
+ * @param angle - Rotation angle as a number or CSS string.
816
+ * @return This instance for chaining.
817
+ */
818
+ rotateY(angle: string | number): this;
819
+ /**
820
+ * Sets the `transform` style to a `rotateZ(angle)` value.
821
+ * Rotates the element around the Z-axis in 3D space (same as 2D rotation).
822
+ * Accepts either a number (degrees) or a full CSS angle string (e.g., `"30deg"`, `"1rad"`).
823
+ * Automatically appends `"deg"` to numeric values.
824
+ * Overwrites any existing `transform` style — use with care if combining multiple transforms.
825
+ *
826
+ * @param angle - Rotation angle as a number or CSS string.
827
+ * @return This instance for chaining.
828
+ */
829
+ rotateZ(angle: string | number): this;
830
+ /**
831
+ * Sets the `transform-origin` style of the element.
832
+ * Defines the pivot point for CSS transforms such as rotation, scaling, or skewing.
833
+ * Accepts any valid CSS origin string (e.g., `"center"`, `"top left"`, `"50% 50%"`), or `undefined` to remove it.
834
+ *
835
+ * @param value - The transform origin to apply, or `undefined` to remove the style.
836
+ * @return This instance for chaining.
837
+ */
838
+ transformOrigin(value: Property.TransformOrigin | undefined): this;
839
+ /**
840
+ * Sets the `transition` style of the element.
841
+ * Defines how style changes are animated over time, including duration, timing function, and delay.
842
+ * Accepts any valid CSS transition string (e.g., `"opacity 0.3s ease"`, `"all 200ms linear"`), or `undefined` to remove it.
843
+ *
844
+ * @param value - The transition string to apply, or `undefined` to remove the style.
845
+ * @return This instance for chaining.
846
+ */
847
+ transition(value: Property.Transition | undefined): this;
848
+ /**
849
+ * Sets the `will-change` style of the element.
850
+ * Provides a hint to the browser about which properties are likely to change,
851
+ * allowing it to optimize rendering and performance ahead of time.
852
+ * Accepts any valid CSS property name or list (e.g., `"transform"`, `"opacity, left"`), or `undefined` to remove it.
853
+ *
854
+ * @param value - The will-change hint to apply, or `undefined` to remove the style.
855
+ * @return This instance for chaining.
856
+ */
857
+ willChange(value: Property.WillChange | undefined): this;
858
+ /**
859
+ * Sets the `box-shadow` style of the element.
860
+ * Applies shadow effects around the element's frame, supporting offsets, blur radius, spread, and color.
861
+ * Accepts any valid CSS box-shadow string (e.g., `"0 2px 4px rgba(0,0,0,0.1)"`), or `undefined` to remove it.
862
+ *
863
+ * @param value - The box-shadow value to apply, or `undefined` to remove the style.
864
+ * @return This instance for chaining.
865
+ */
866
+ boxShadow(value: Property.BoxShadow | undefined): this;
678
867
  /**
679
868
  * Applies CSS styles to truncate overflowing text with an ellipsis.
680
869
  * Ensures the text stays on a single line and hides overflow.
@@ -704,12 +893,42 @@ declare abstract class BaseStyle {
704
893
  }
705
894
  //#endregion
706
895
  //#region src/BaseDom.d.ts
896
+ declare const _isBaseDom: unique symbol;
707
897
  /**
708
898
  * Base class for DOM-backed elements with style and event utilities.
709
899
  * Supports both HTML and SVG elements via generic parameter `E`.
710
900
  */
711
901
  declare abstract class BaseDom<E extends HTMLElement | SVGElement> extends BaseStyle {
902
+ protected readonly [_isBaseDom] = true;
712
903
  abstract dom: E;
904
+ /**
905
+ * Returns the `clientWidth` of the element.
906
+ * For HTML elements, this is the inner width excluding borders and scrollbars.
907
+ * For SVG elements, this may return `0` unless the element has layout box dimensions.
908
+ */
909
+ getClientWidth(): number;
910
+ /**
911
+ * Returns the `clientHeight` of the element.
912
+ * For HTML elements, this is the inner height excluding borders and scrollbars.
913
+ * For SVG elements, this may return `0` unless the element has layout box dimensions.
914
+ */
915
+ getClientHeight(): number;
916
+ /**
917
+ * Returns the bounding box of the element using `getBoundingClientRect()`.
918
+ * Works reliably for both HTML and SVG elements.
919
+ *
920
+ * @return A DOMRect object with `width`, `height`, `top`, `left`, etc.
921
+ */
922
+ getRect(): DOMRect;
923
+ /**
924
+ * Returns the computed styles of this element.
925
+ * Useful for reading resolved values of inherited, cascaded, or shorthand CSS properties.
926
+ *
927
+ * Wraps `window.getComputedStyle()` and returns a `CSSStyleDeclaration` for inspection.
928
+ *
929
+ * @return The computed style object for this element.
930
+ */
931
+ getComputedStyle(): CSSStyleDeclaration;
713
932
  /**
714
933
  * Sets or removes the user-defined class name and applies it alongside the internal CSS class.
715
934
  * Uses `setAttribute("class", ...)` for both HTML and SVG elements.
@@ -720,6 +939,16 @@ declare abstract class BaseDom<E extends HTMLElement | SVGElement> extends BaseS
720
939
  * @return This DomElement instance for chaining.
721
940
  */
722
941
  className(value: string | undefined): this;
942
+ /**
943
+ * Toggles a CSS class on the element.
944
+ * Adds the class if it’s not present, removes it if it is.
945
+ * Uses `classList.toggle()` for safe DOM-backed mutation.
946
+ *
947
+ * @param className - The class name to toggle.
948
+ * @param force - Optional boolean to force add (`true`) or remove (`false`) the class.
949
+ * @return This instance for chaining.
950
+ */
951
+ toggleClass(className: string, force?: boolean): this;
723
952
  /**
724
953
  * Adds an event listener to the element.
725
954
  * @param type - The event type (e.g., "click", "input", "mouseenter").
@@ -784,9 +1013,27 @@ declare abstract class BaseDom<E extends HTMLElement | SVGElement> extends BaseS
784
1013
  * @returns This DomElement instance.
785
1014
  */
786
1015
  clear(from?: number, to?: number): this;
1016
+ /**
1017
+ * Checks whether this element contains the given target node.
1018
+ * Accepts either a raw DOM node or another `BaseDom` instance.
1019
+ *
1020
+ * Useful for containment checks, event delegation, or visibility logic.
1021
+ *
1022
+ * @param target - A DOM node or `BaseDom` instance to test.
1023
+ * @return `true` if this element contains the target, otherwise `false`.
1024
+ */
1025
+ contains(target: Node | BaseDom<any>): boolean;
787
1026
  ref(refFn: (el: this) => void): this;
788
1027
  protected resolveNode(child: DomElementChild): Node;
789
1028
  protected setStyleProp(name: Autocomplete<keyof CssProperties>, value: string | number | undefined): this;
1029
+ /**
1030
+ * Checks whether a value is a `BaseDom` instance.
1031
+ * Uses a symbol-based identity marker and avoids the `in` operator.
1032
+ *
1033
+ * @param value - The value to check.
1034
+ * @return `true` if the value is a `BaseDom` instance, otherwise `false`.
1035
+ */
1036
+ static isBaseDom(value: unknown): value is BaseDom<HTMLElement | SVGElement>;
790
1037
  }
791
1038
  //#endregion
792
1039
  //#region src/DomElement.d.ts
@@ -1226,13 +1473,14 @@ declare class CssRule extends BaseStyle {
1226
1473
  */
1227
1474
  remove(): void;
1228
1475
  /**
1229
- * Creates a new CssRule for a pseudo-selector extending this rule’s selector.
1230
- * For example, `.btn:hover`, `.input:focus`, `.card:active`.
1476
+ * Creates a new `CssRule` by extending this rule’s selector.
1477
+ * Appends the given selector fragment to the current selector.
1478
+ * Useful for pseudo-classes (e.g., `:hover`), combinators (e.g., ` > span`), or attribute filters (e.g., `[data-active]`).
1231
1479
  *
1232
- * @param pseudo - The pseudo-class to append (e.g., ":hover", ":focus").
1233
- * @return A new CssRule instance targeting the extended selector.
1480
+ * @param extension - The selector fragment to append (e.g., `:hover`, ` > span`, `[data-active]`).
1481
+ * @return A new `CssRule` instance targeting the extended selector.
1234
1482
  */
1235
- pseudo(pseudo: `:${string}`): CssRule;
1483
+ extend(extension: string): CssRule;
1236
1484
  /**
1237
1485
  * Creates a `:hover` rule for this selector.
1238
1486
  * @return A new CssRule instance for the `:hover` state.
@@ -1386,14 +1634,79 @@ declare class IFrame extends DomElement<"iframe"> {
1386
1634
  declare function $iframe(): IFrame;
1387
1635
  //#endregion
1388
1636
  //#region src/ImageElement.d.ts
1637
+ /**
1638
+ * Fluent wrapper for an `<img>` element.
1639
+ * Provides chainable methods for setting image source, dimensions, and alt text.
1640
+ * Inherits style and event utilities from `DomElement` and `BaseDom`.
1641
+ *
1642
+ * Useful for programmatically constructing image elements with ergonomic, declarative syntax.
1643
+ */
1389
1644
  declare class ImageElement extends DomElement<"img"> {
1390
1645
  constructor();
1646
+ /**
1647
+ * Returns the `naturalWidth` of the image.
1648
+ * This is the intrinsic width of the image resource in pixels, unaffected by CSS or layout.
1649
+ * Returns `0` if the image has not loaded or failed to decode.
1650
+ *
1651
+ * @return The natural width in pixels.
1652
+ */
1653
+ getNaturalWidth(): number;
1654
+ /**
1655
+ * Returns the `naturalHeight` of the image.
1656
+ * This is the intrinsic height of the image resource in pixels, unaffected by CSS or layout.
1657
+ * Returns `0` if the image has not loaded or failed to decode.
1658
+ *
1659
+ * @return The natural height in pixels.
1660
+ */
1661
+ getNaturalHeight(): number;
1662
+ /**
1663
+ * Sets the `src` attribute of the `<img>` element.
1664
+ * Defines the image source URL or path to be loaded.
1665
+ *
1666
+ * @param value - The image source (e.g., "/logo.png", "https://example.com/photo.jpg").
1667
+ * @return This instance for chaining.
1668
+ */
1391
1669
  src(value: string): this;
1670
+ /**
1671
+ * Sets the `width` attribute of the `<img>` element in pixels.
1672
+ * This controls the rendered width of the image, independent of its intrinsic size.
1673
+ *
1674
+ * @param value - The width in pixels.
1675
+ * @return This instance for chaining.
1676
+ */
1392
1677
  width(value: number): this;
1678
+ /**
1679
+ * Sets the `height` attribute of the `<img>` element in pixels.
1680
+ * This controls the rendered height of the image, independent of its intrinsic size.
1681
+ *
1682
+ * @param value - The height in pixels.
1683
+ * @return This instance for chaining.
1684
+ */
1393
1685
  height(value: number): this;
1686
+ /**
1687
+ * Sets both the `width` and `height` attributes of the `<img>` element in pixels.
1688
+ * Useful for explicitly sizing the image without relying on CSS.
1689
+ *
1690
+ * @param width - The width in pixels.
1691
+ * @param height - The height in pixels.
1692
+ * @return This instance for chaining.
1693
+ */
1394
1694
  setSize(width: number, height: number): this;
1695
+ /**
1696
+ * Sets the `alt` attribute of the `<img>` element.
1697
+ * Provides alternative text for accessibility and fallback rendering.
1698
+ *
1699
+ * @param value - The alt text (e.g., "User avatar", "Company logo").
1700
+ * @return This instance for chaining.
1701
+ */
1395
1702
  alt(value: string): this;
1396
1703
  }
1704
+ /**
1705
+ * Creates a new `ImageElement` instance.
1706
+ * Equivalent to: `new ImageElement()`, but more expressive in fluent DOM construction.
1707
+ *
1708
+ * @return A new `ImageElement` instance.
1709
+ */
1397
1710
  declare function $img(): ImageElement;
1398
1711
  //#endregion
1399
1712
  //#region src/input.d.ts
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)}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)}posTop(e){return this.setStyleProp(`top`,e)}posBottom(e){return this.setStyleProp(`bottom`,e)}posLeft(e){return this.setStyleProp(`left`,e)}posRight(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)}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}var l=class extends e{className(e){return e==null?this.dom.removeAttribute(`class`):this.dom.setAttribute(`class`,e),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}ref(e){return e(this),this}resolveNode(e){return typeof e==`string`||typeof e==`number`?document.createTextNode(String(e)):`dom`in 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)}},u=class extends l{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 d(e){return new u(e)}function f(e){let t=document.querySelector(e);return new u(t.tagName.toLowerCase(),t)}var p=class extends u{constructor(){super(`a`)}href(e){return this.dom.href=e,this}};function m(){return new p}var h=class extends u{constructor(){super(`button`)}type(e){return this.dom.type=e,this}};function g(){return new h}var _=class extends u{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 v(){return new _}var y=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)}pseudo(e){return this.sheet.cssRule(`${this.selectorText}${e}`)}hover(){return this.pseudo(`:hover`)}focus(){return this.pseudo(`:focus`)}focusWithin(){return this.pseudo(`:focus-within`)}active(){return this.pseudo(`:active`)}disabled(){return this.pseudo(`: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)}},b=class extends l{get dom(){return document.body}};function x(){return new b}var S=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 C(){return new S}var w=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 T(){return new w}var E=class extends u{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 D(){return new E}var O=class extends u{constructor(){super(`img`)}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.dom.width=e,this.dom.height=t,this}alt(e){return this.dom.alt=e,this}};function k(){return new O}var A=class extends u{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`)}},j=class extends u{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}},M=class extends u{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}},N=class extends u{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}},P=class extends u{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 F(e){switch(e){case`text`:return new P;case`number`:return new M;case`checkbox`:return new A;case`color`:return new j;case`range`:return new N}}var I=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 y(this.sheet,t,this.rule.cssRules.item(t))}remove(){this.sheet.removeRule(this)}removeRule(e){this.rule.deleteRule(e.index)}},L=class extends u{constructor(){super(`option`)}value(e){return this.dom.value=String(e),this}getValue(){return this.dom.value}};function R(){return new L}var z=class extends u{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 B(){return new z}var V=class extends u{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 H(){return new V}var U=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 y(this,t,this.sheet.cssRules.item(t))}mediaRule(e){let t=this.length;return this.sheet.insertRule(`@media(${e}){}`,t),new I(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{d as $,m as $a,x as $body,g as $btn,v as $canvas,C as $document,D as $iframe,k as $img,F as $input,R as $option,B as $progress,f as $query,H as $select,T as $window,p as AnchorElement,l as BaseDom,e as BaseStyle,h as Button,_ as Canvas,y as CssRule,b as DomBody,S as DomDocument,u as DomElement,w as DomWindow,E as IFrame,O as ImageElement,A as InputCheckbox,j as InputColor,M as InputNumber,N as InputRange,P as InputText,I as MediaRule,L as OptionElement,z as ProgressElement,r as SVG_TAGS,V as SelectElement,U 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)}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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neptune3d/dom",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Helper classes and functions for the DOM.",
5
5
  "type": "module",
6
6
  "license": "MIT",