@medyll/idae-dom-events 0.66.0 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +100 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,3 +1,101 @@
1
- ```markdown
2
- "description": "dom-events is a powerful library for observing and reacting to DOM changes in web applications. It provides tools to track CSS changes, monitor DOM mutations, and handle various events efficiently, making it ideal for dynamic web applications."
1
+ # @medyll/idae-dom-events
2
+
3
+ `@medyll/idae-dom-events` is a library for observing and reacting to changes in the DOM of web applications. It provides tools to track CSS changes, monitor DOM mutations, and manage various events efficiently, making it an ideal choice for dynamic web applications.
4
+
5
+ ## Features
6
+
7
+ - **CSS Change Tracking**: Use `CssObserver` to monitor animations, style changes, and resize events.
8
+ - **DOM Mutation Observation**: Use `DomObserver` to track DOM mutations, such as attribute changes, child list modifications, and character data updates.
9
+ - **Event Management**: Efficiently manage DOM-related events.
10
+
11
+ ## Installation
12
+
13
+ Install the library using npm:
14
+
15
+ ```bash
16
+ npm install @medyll/idae-dom-events
3
17
  ```
18
+
19
+ ## Usage
20
+
21
+ ### CSS Change Tracking
22
+
23
+ ```typescript
24
+ import { cssDom } from '@medyll/idae-dom-events';
25
+
26
+ // Track CSS changes on elements with the attribute data-cssDom
27
+ cssDom('[data-cssDom]', {
28
+ trackChildList: true,
29
+ trackAttributes: true,
30
+ trackResize: true
31
+ }).each((element, changes) => {
32
+ console.log('Modified element:', element);
33
+
34
+ if (changes.attributes) {
35
+ console.log('Attribute changes:', changes.attributes);
36
+ }
37
+
38
+ if (changes.childList) {
39
+ console.log('Child list modifications:', changes.childList);
40
+ }
41
+
42
+ if (changes.characterData) {
43
+ console.log('Character data changes:', changes.characterData);
44
+ }
45
+
46
+ if (changes.resize) {
47
+ console.log('Resize detected:', changes.resize);
48
+ }
49
+ });
50
+ ```
51
+
52
+ ### DOM Mutation Observation
53
+
54
+ ```typescript
55
+ import { htmlDom } from '@medyll/idae-dom-events';
56
+
57
+ htmlDom.track('#widget', {
58
+ onAttributesChange: (element, mutation) => {
59
+ console.log('Modified attribute:', mutation);
60
+ },
61
+ onChildListChange: (mutation) => {
62
+ console.log('Child list modified:', mutation);
63
+ },
64
+ onCharacterDataChange: (mutation) => {
65
+ console.log('Character data modified:', mutation);
66
+ }
67
+ });
68
+ ```
69
+
70
+ ## API
71
+
72
+ ### `cssDom(selector, options)`
73
+
74
+ - **`selector`**: CSS selector to target elements.
75
+ - **`options`**: Options to configure tracking, such as `trackChildList`, `trackAttributes`, or `trackResize`.
76
+
77
+ #### Methods
78
+
79
+ - **`each(callback)`**: Tracks changes for each matching element.
80
+ - **`summary(callback)`**: Provides a summary of affected elements.
81
+
82
+ ### `htmlDom.track(selector, options)`
83
+
84
+ - **`selector`**: Selector or DOM element to observe.
85
+ - **`options`**: Options to configure the types of mutations to track (`onAttributesChange`, `onChildListChange`, etc.).
86
+
87
+ ## Scripts
88
+
89
+ The following npm scripts are available for development and testing:
90
+
91
+ - `npm run dev`: Starts the development server.
92
+ - `npm run build`: Compiles the library for production.
93
+ - `npm run test`: Runs unit tests.
94
+
95
+ ## Contribution
96
+
97
+ Contributions are welcome! Feel free to submit a pull request or open an issue to report bugs or propose features.
98
+
99
+ ## License
100
+
101
+ This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for more details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medyll/idae-dom-events",
3
- "version": "0.66.0",
3
+ "version": "0.68.0",
4
4
  "scope": "@medyll",
5
5
  "description": "dom-events is a powerful library for observing and reacting to DOM changes in web applications. It provides tools to track CSS changes, monitor DOM mutations, and handle various events efficiently, making it ideal for dynamic web applications.",
6
6
  "scripts": {