@neptune3d/dom 0.0.4 → 0.0.6

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
@@ -1,6 +1,6 @@
1
1
  # neptune3d/dom
2
2
 
3
- Helper classes and functions for the DOM.
3
+ Helper classes and functions for fluent DOM manipulation, styling, and event handling.
4
4
 
5
5
  ## 🚀 Getting Started
6
6
 
@@ -10,22 +10,22 @@ Install the package:
10
10
  npm install neptune3d/dom
11
11
  ```
12
12
 
13
- Import and create elements:
13
+ ## Create Elements
14
14
 
15
15
  ```ts
16
16
  import { $, $body } from "neptune3d/dom";
17
17
 
18
18
  const div = $("div")
19
19
  .text("Hello world")
20
- .css("", { padding: "1rem", background: "#eee" })
20
+ .px("1rem")
21
+ .bgColor("#eee")
22
+ .title("Click me")
21
23
  .on("click", () => console.log("Clicked!"));
22
24
 
23
- const body = $body();
24
-
25
- body.appendChild(div.dom);
25
+ $body().add(div);
26
26
  ```
27
27
 
28
- Use SVG elements:
28
+ ## 🖼 SVG Support
29
29
 
30
30
  ```ts
31
31
  const circle = $("circle")
@@ -34,25 +34,74 @@ const circle = $("circle")
34
34
  .attr("r", "40")
35
35
  .attr("fill", "red");
36
36
 
37
- const svg = $("svg").attr("width", "100").attr("height", "100").append(circle);
37
+ const svg = $("svg").attr("width", "100").attr("height", "100").add(circle);
38
+
39
+ $body().add(svg);
40
+ ```
41
+
42
+ ## 📋 Input Helpers
43
+
44
+ ```ts
45
+ import { $input } from "neptune3d/dom";
46
+
47
+ const checkbox = $input("checkbox").on("change", (e) => {
48
+ console.log("Checked:", checkbox.getChecked());
49
+ });
50
+
51
+ $body().add(checkbox);
52
+ ```
53
+
54
+ ## 🎯 Popover API
38
55
 
39
- body.appendChild(svg.dom);
56
+ ```ts
57
+ const pop = $("div")
58
+ .text("Popover content")
59
+ .popover("manual")
60
+ .css("", { padding: "1rem", background: "#222", color: "#fff" });
61
+
62
+ $body().add(pop);
63
+
64
+ // Show/hide programmatically
65
+ pop.showPopover();
66
+ pop.hidePopover();
40
67
  ```
41
68
 
42
- Define global styles:
69
+ ## 🎨 Stylesheet Rules
43
70
 
44
71
  ```ts
45
72
  import { StyleSheet } from "neptune3d/dom";
46
73
 
47
- StyleSheet.getSheet().globalCss(".list-item", {
74
+ const sheet = StyleSheet.getSheet();
75
+
76
+ // Insert a global rule
77
+ const rule = sheet.cssRule(".list-item");
78
+ rule.style({
48
79
  padding: "0.5rem",
49
80
  borderBottom: "1px solid #ccc",
50
81
  });
82
+
83
+ // Insert a media query block
84
+ const media = sheet.mediaRule("screen and (max-width: 600px)");
85
+ media.cssRule(".list-item").style({
86
+ background: "#f0f0f0",
87
+ });
88
+ ```
89
+
90
+ ## 🌍 Global Event Wrappers
91
+
92
+ ```ts
93
+ import { $window, $document } from "neptune3d/dom";
94
+
95
+ $window().on("resize", (e) => console.log("Window resized"));
96
+ $document().on("visibilitychange", () => console.log("Visibility changed"));
51
97
  ```
52
98
 
53
99
  ## 📦 Features
54
100
 
55
101
  - Chainable DOM manipulation
102
+ - Typed input element helpers
103
+ - Popover API support
56
104
  - Scoped and global CSS rule injection
57
- - Media query support
58
- - Event listener helpers
105
+ - Media query management
106
+ - Window and document event wrappers
107
+ - SVG and HTML element abstraction