@medyll/idae-be 1.18.0 → 1.20.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.
- package/dist/modules/attrs.js +2 -7
- package/dist/modules/text.js +91 -65
- package/dist/modules/timers.js +2 -11
- package/dist/modules/walk.js +5 -1
- package/package.json +1 -1
package/dist/modules/attrs.js
CHANGED
|
@@ -26,13 +26,8 @@ export class AttrHandler {
|
|
|
26
26
|
*/
|
|
27
27
|
handle(actions) {
|
|
28
28
|
Object.entries(actions).forEach(([method, props]) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.set(props);
|
|
32
|
-
break;
|
|
33
|
-
case 'delete':
|
|
34
|
-
this.delete(props);
|
|
35
|
-
break;
|
|
29
|
+
if (method in this) {
|
|
30
|
+
this[method](props);
|
|
36
31
|
}
|
|
37
32
|
});
|
|
38
33
|
return this.beElement;
|
package/dist/modules/text.js
CHANGED
|
@@ -24,64 +24,10 @@ export class TextHandler {
|
|
|
24
24
|
return this.beElement.inputNode.textContent;
|
|
25
25
|
}
|
|
26
26
|
handle(actions) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
case 'update':
|
|
31
|
-
if (typeof props === 'string') {
|
|
32
|
-
el.innerText = props;
|
|
33
|
-
}
|
|
34
|
-
break;
|
|
35
|
-
case 'prepend':
|
|
36
|
-
if (typeof props === 'string') {
|
|
37
|
-
el.insertAdjacentText('afterbegin', props);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
throw new Error('Invalid props for prepend: must be a string.');
|
|
41
|
-
}
|
|
42
|
-
break;
|
|
43
|
-
case 'append':
|
|
44
|
-
if (typeof props === 'string') {
|
|
45
|
-
el.insertAdjacentText('beforeend', props);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
throw new Error('Invalid props for append: must be a string.');
|
|
49
|
-
}
|
|
50
|
-
break;
|
|
51
|
-
case 'replace':
|
|
52
|
-
if (typeof props === 'string') {
|
|
53
|
-
el.textContent = props;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
throw new Error('Invalid props for replace: must be a string.');
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case 'remove':
|
|
60
|
-
el.remove();
|
|
61
|
-
break;
|
|
62
|
-
case 'clear':
|
|
63
|
-
el.innerHTML = '';
|
|
64
|
-
break;
|
|
65
|
-
case 'normalize':
|
|
66
|
-
el.normalize();
|
|
67
|
-
break;
|
|
68
|
-
case 'wrap':
|
|
69
|
-
if (typeof props === 'string') {
|
|
70
|
-
const wrapper = document.createElement('div');
|
|
71
|
-
wrapper.innerHTML = props.trim();
|
|
72
|
-
const parent = wrapper.firstElementChild;
|
|
73
|
-
if (parent) {
|
|
74
|
-
el.parentNode?.insertBefore(parent, el);
|
|
75
|
-
parent.appendChild(el);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
27
|
+
Object.entries(actions).forEach(([method, props]) => {
|
|
28
|
+
if (method in this) {
|
|
29
|
+
this[method](props);
|
|
79
30
|
}
|
|
80
|
-
actions?.callback?.({
|
|
81
|
-
fragment: props,
|
|
82
|
-
be: be(el),
|
|
83
|
-
root: this.beElement
|
|
84
|
-
});
|
|
85
31
|
});
|
|
86
32
|
return this.beElement;
|
|
87
33
|
}
|
|
@@ -96,7 +42,17 @@ export class TextHandler {
|
|
|
96
42
|
* beInstance.updateText('Updated'); // Updates the text content to "Updated"
|
|
97
43
|
*/
|
|
98
44
|
update(content, callback) {
|
|
99
|
-
|
|
45
|
+
this.beElement.eachNode((el) => {
|
|
46
|
+
if (typeof content === 'string') {
|
|
47
|
+
el.innerText = content;
|
|
48
|
+
}
|
|
49
|
+
callback?.({
|
|
50
|
+
fragment: content,
|
|
51
|
+
be: be(el),
|
|
52
|
+
root: this.beElement
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
return this.beElement;
|
|
100
56
|
}
|
|
101
57
|
/**
|
|
102
58
|
* Appends text content to the element(s).
|
|
@@ -109,7 +65,17 @@ export class TextHandler {
|
|
|
109
65
|
* beInstance.appendText(' Appended'); // Appends " Appended" to the text content
|
|
110
66
|
*/
|
|
111
67
|
append(content, callback) {
|
|
112
|
-
|
|
68
|
+
this.beElement.eachNode((el) => {
|
|
69
|
+
if (typeof content === 'string') {
|
|
70
|
+
el.insertAdjacentText('beforeend', content);
|
|
71
|
+
}
|
|
72
|
+
callback?.({
|
|
73
|
+
fragment: content,
|
|
74
|
+
be: be(el),
|
|
75
|
+
root: this.beElement
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
return this.beElement;
|
|
113
79
|
}
|
|
114
80
|
/**
|
|
115
81
|
* Prepends text content to the element(s).
|
|
@@ -122,7 +88,17 @@ export class TextHandler {
|
|
|
122
88
|
* beInstance.prependText('Prepended '); // Prepends "Prepended " to the text content
|
|
123
89
|
*/
|
|
124
90
|
prepend(content, callback) {
|
|
125
|
-
|
|
91
|
+
this.beElement.eachNode((el) => {
|
|
92
|
+
if (typeof content === 'string') {
|
|
93
|
+
el.insertAdjacentText('afterbegin', content);
|
|
94
|
+
}
|
|
95
|
+
callback?.({
|
|
96
|
+
fragment: content,
|
|
97
|
+
be: be(el),
|
|
98
|
+
root: this.beElement
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
return this.beElement;
|
|
126
102
|
}
|
|
127
103
|
/**
|
|
128
104
|
* Replaces the text content of the element(s).
|
|
@@ -135,7 +111,17 @@ export class TextHandler {
|
|
|
135
111
|
* beInstance.replaceText('Replaced'); // Replaces the text content with "Replaced"
|
|
136
112
|
*/
|
|
137
113
|
replace(content, callback) {
|
|
138
|
-
|
|
114
|
+
this.beElement.eachNode((el) => {
|
|
115
|
+
if (typeof content === 'string') {
|
|
116
|
+
el.textContent = content;
|
|
117
|
+
}
|
|
118
|
+
callback?.({
|
|
119
|
+
fragment: content,
|
|
120
|
+
be: be(el),
|
|
121
|
+
root: this.beElement
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
return this.beElement;
|
|
139
125
|
}
|
|
140
126
|
/**
|
|
141
127
|
* Removes the element(s) from the DOM.
|
|
@@ -147,7 +133,15 @@ export class TextHandler {
|
|
|
147
133
|
* beInstance.removeText(); // Removes the element
|
|
148
134
|
*/
|
|
149
135
|
remove(callback) {
|
|
150
|
-
|
|
136
|
+
this.beElement.eachNode((el) => {
|
|
137
|
+
el.remove();
|
|
138
|
+
callback?.({
|
|
139
|
+
fragment: undefined,
|
|
140
|
+
be: be(el),
|
|
141
|
+
root: this.beElement
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
return this.beElement;
|
|
151
145
|
}
|
|
152
146
|
/**
|
|
153
147
|
* Clears the text content of the element(s).
|
|
@@ -159,7 +153,15 @@ export class TextHandler {
|
|
|
159
153
|
* beInstance.clearText(); // Clears the text content
|
|
160
154
|
*/
|
|
161
155
|
clear(callback) {
|
|
162
|
-
|
|
156
|
+
this.beElement.eachNode((el) => {
|
|
157
|
+
el.innerHTML = '';
|
|
158
|
+
callback?.({
|
|
159
|
+
fragment: undefined,
|
|
160
|
+
be: be(el),
|
|
161
|
+
root: this.beElement
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
return this.beElement;
|
|
163
165
|
}
|
|
164
166
|
/**
|
|
165
167
|
* Normalizes the text content of the element(s).
|
|
@@ -171,7 +173,15 @@ export class TextHandler {
|
|
|
171
173
|
* beInstance.normalizeText(); // Normalizes the text content
|
|
172
174
|
*/
|
|
173
175
|
normalize(callback) {
|
|
174
|
-
|
|
176
|
+
this.beElement.eachNode((el) => {
|
|
177
|
+
el.normalize();
|
|
178
|
+
callback?.({
|
|
179
|
+
fragment: undefined,
|
|
180
|
+
be: be(el),
|
|
181
|
+
root: this.beElement
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
return this.beElement;
|
|
175
185
|
}
|
|
176
186
|
/**
|
|
177
187
|
* Wraps the element(s) with a new element.
|
|
@@ -184,7 +194,23 @@ export class TextHandler {
|
|
|
184
194
|
* beInstance.wrapText('<div class="wrapper"></div>'); // Wraps the element with a <div>
|
|
185
195
|
*/
|
|
186
196
|
wrap(content, callback) {
|
|
187
|
-
|
|
197
|
+
this.beElement.eachNode((el) => {
|
|
198
|
+
if (typeof content === 'string') {
|
|
199
|
+
const wrapper = document.createElement('div');
|
|
200
|
+
wrapper.innerHTML = content.trim();
|
|
201
|
+
const parent = wrapper.firstElementChild;
|
|
202
|
+
if (parent) {
|
|
203
|
+
el.parentNode?.insertBefore(parent, el);
|
|
204
|
+
parent.appendChild(el);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
callback?.({
|
|
208
|
+
fragment: content,
|
|
209
|
+
be: be(el),
|
|
210
|
+
root: this.beElement
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
return this.beElement;
|
|
188
214
|
}
|
|
189
215
|
valueOf() {
|
|
190
216
|
if (this.beElement.isWhat !== 'element')
|
package/dist/modules/timers.js
CHANGED
|
@@ -23,18 +23,9 @@ export class TimersHandler {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
handle(actions) {
|
|
26
|
-
if (!actions)
|
|
27
|
-
return this.beElement;
|
|
28
26
|
Object.entries(actions).forEach(([method, props]) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
case 'interval':
|
|
32
|
-
this[method](props, actions.callback);
|
|
33
|
-
break;
|
|
34
|
-
case 'clearTimeout':
|
|
35
|
-
case 'clearInterval':
|
|
36
|
-
this[method](actions.callback);
|
|
37
|
-
break;
|
|
27
|
+
if (method in this) {
|
|
28
|
+
this[method](props);
|
|
38
29
|
}
|
|
39
30
|
});
|
|
40
31
|
return this.beElement;
|
package/dist/modules/walk.js
CHANGED
|
@@ -39,7 +39,11 @@ export class WalkHandler {
|
|
|
39
39
|
* @returns The Be instance for method chaining.
|
|
40
40
|
*/
|
|
41
41
|
handle(actions) {
|
|
42
|
-
|
|
42
|
+
Object.entries(actions).forEach(([method, props]) => {
|
|
43
|
+
if (method in this) {
|
|
44
|
+
this[method](props);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
43
47
|
return this.beElement;
|
|
44
48
|
}
|
|
45
49
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medyll/idae-be",
|
|
3
3
|
"scope": "@medyll",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.20.0",
|
|
5
5
|
"description": "A modern, lightweight, and extensible DOM manipulation library built with TypeScript. Designed for precise element targeting and manipulation using a callback-based approach. Features include advanced DOM traversal, event handling, style management, attribute control, HTTP content loading, timers, and more. Ideal for developers seeking a modular and consistent API for dynamic web applications.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"DOM",
|