@neptune3d/dom 0.0.5 → 0.0.7
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 +61 -12
- package/dist/index.d.ts +991 -588
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# neptune3d/dom
|
|
2
2
|
|
|
3
|
-
Helper classes and functions for
|
|
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
|
-
|
|
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
|
-
.
|
|
20
|
+
.px("1rem")
|
|
21
|
+
.bgColor("#eee")
|
|
22
|
+
.title("Click me")
|
|
21
23
|
.on("click", () => console.log("Clicked!"));
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
body.append(div.dom);
|
|
25
|
+
$body().add(div);
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
## 🖼 SVG Support
|
|
29
29
|
|
|
30
30
|
```ts
|
|
31
31
|
const circle = $("circle")
|
|
@@ -36,23 +36,72 @@ const circle = $("circle")
|
|
|
36
36
|
|
|
37
37
|
const svg = $("svg").attr("width", "100").attr("height", "100").add(circle);
|
|
38
38
|
|
|
39
|
-
body.
|
|
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
|
|
55
|
+
|
|
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
|
-
|
|
69
|
+
## 🎨 Stylesheet Rules
|
|
43
70
|
|
|
44
71
|
```ts
|
|
45
72
|
import { StyleSheet } from "neptune3d/dom";
|
|
46
73
|
|
|
47
|
-
StyleSheet.getSheet()
|
|
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
|
|
58
|
-
-
|
|
105
|
+
- Media query management
|
|
106
|
+
- Window and document event wrappers
|
|
107
|
+
- SVG and HTML element abstraction
|