@medyll/idae-be 0.76.0 → 0.78.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/be.d.ts +1 -7
- package/dist/be.js +8 -8
- package/dist/modules/styles.d.ts +0 -1
- package/dist/modules/styles.js +22 -15
- package/package.json +1 -1
package/dist/be.d.ts
CHANGED
|
@@ -108,19 +108,13 @@ export declare class Be {
|
|
|
108
108
|
static toBe(str: string | HTMLElement, options?: {
|
|
109
109
|
tag?: string;
|
|
110
110
|
}): Be;
|
|
111
|
-
/**
|
|
112
|
-
* setStyle Sets one or more CSS styles for the selected element(s), including CSS custom properties.
|
|
113
|
-
* @param styles An object of CSS properties and values, or a string of CSS properties and values.
|
|
114
|
-
* @param value The value for a single CSS property when styles is a property name string.
|
|
115
|
-
* @returns The Be instance for method chaining.
|
|
116
|
-
*/
|
|
117
111
|
fetch<T extends object>(options: {
|
|
118
112
|
url: string;
|
|
119
113
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | 'CONNECT' | 'TRACE';
|
|
120
114
|
data?: T;
|
|
121
115
|
headers?: Record<string, string>;
|
|
122
116
|
}): Promise<any>;
|
|
123
|
-
eachNode(callback: (el: HTMLElement) => void): void;
|
|
117
|
+
eachNode(callback: (el: HTMLElement) => void, firstChild?: boolean): void;
|
|
124
118
|
/** DOM
|
|
125
119
|
* Handles various DOM operations on the element(s).
|
|
126
120
|
* @param actions An object specifying the DOM actions to perform.
|
package/dist/be.js
CHANGED
|
@@ -232,12 +232,6 @@ export class Be {
|
|
|
232
232
|
}
|
|
233
233
|
return beElem;
|
|
234
234
|
}
|
|
235
|
-
/**
|
|
236
|
-
* setStyle Sets one or more CSS styles for the selected element(s), including CSS custom properties.
|
|
237
|
-
* @param styles An object of CSS properties and values, or a string of CSS properties and values.
|
|
238
|
-
* @param value The value for a single CSS property when styles is a property name string.
|
|
239
|
-
* @returns The Be instance for method chaining.
|
|
240
|
-
*/
|
|
241
235
|
fetch(options) {
|
|
242
236
|
return fetch(options.url, {
|
|
243
237
|
method: options.method || 'GET',
|
|
@@ -245,7 +239,7 @@ export class Be {
|
|
|
245
239
|
headers: options.headers || {}
|
|
246
240
|
}).then((response) => response.json());
|
|
247
241
|
}
|
|
248
|
-
eachNode(callback) {
|
|
242
|
+
eachNode(callback, firstChild) {
|
|
249
243
|
switch (this.isWhat) {
|
|
250
244
|
case 'element':
|
|
251
245
|
BeUtils.applyCallback(this.node, callback);
|
|
@@ -253,10 +247,16 @@ export class Be {
|
|
|
253
247
|
case 'array':
|
|
254
248
|
this.node.forEach((lo) => {
|
|
255
249
|
BeUtils.applyCallback(lo, callback);
|
|
250
|
+
if (firstChild)
|
|
251
|
+
return;
|
|
256
252
|
});
|
|
257
253
|
break;
|
|
258
254
|
case 'qy':
|
|
259
|
-
document.querySelectorAll(this.node).forEach((el) =>
|
|
255
|
+
document.querySelectorAll(this.node).forEach((el) => {
|
|
256
|
+
callback(el);
|
|
257
|
+
if (firstChild)
|
|
258
|
+
return;
|
|
259
|
+
});
|
|
260
260
|
break;
|
|
261
261
|
}
|
|
262
262
|
}
|
package/dist/modules/styles.d.ts
CHANGED
package/dist/modules/styles.js
CHANGED
|
@@ -13,8 +13,11 @@ export class StylesHandler {
|
|
|
13
13
|
}
|
|
14
14
|
static methods = Object.values(beStyleMethods);
|
|
15
15
|
handle(actions) {
|
|
16
|
+
console.log('StylesHandler.handle', actions);
|
|
16
17
|
const { method, args } = this.resolveIndirection(actions);
|
|
18
|
+
console.log({ method, args });
|
|
17
19
|
this.beElement.eachNode((el) => {
|
|
20
|
+
console.log({ method, args });
|
|
18
21
|
switch (method) {
|
|
19
22
|
case 'set':
|
|
20
23
|
if (typeof args === 'string') {
|
|
@@ -48,6 +51,7 @@ export class StylesHandler {
|
|
|
48
51
|
break;
|
|
49
52
|
}
|
|
50
53
|
});
|
|
54
|
+
console.log('StylesHandler.handle end');
|
|
51
55
|
return this.beElement;
|
|
52
56
|
}
|
|
53
57
|
resolveIndirection(actions) {
|
|
@@ -69,17 +73,15 @@ export class StylesHandler {
|
|
|
69
73
|
*/
|
|
70
74
|
set(styles, value) {
|
|
71
75
|
if (typeof styles === 'string') {
|
|
72
|
-
// Handle string input
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (value !== undefined) {
|
|
82
|
-
this.applyStyle(styles, value);
|
|
76
|
+
// Handle string input, if contains ':' and use cssText
|
|
77
|
+
if (styles.includes(':')) {
|
|
78
|
+
this.beElement.eachNode((el) => {
|
|
79
|
+
el.style.cssText = styles;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// If value is provided, treat it as a single property setting
|
|
84
|
+
this.applyStyle(styles, value ?? '');
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
else if (typeof styles === 'object') {
|
|
@@ -92,7 +94,15 @@ export class StylesHandler {
|
|
|
92
94
|
}
|
|
93
95
|
// get style
|
|
94
96
|
get(key) {
|
|
95
|
-
|
|
97
|
+
let css = null;
|
|
98
|
+
this.beElement.eachNode((el) => {
|
|
99
|
+
css = el.style[key] || null;
|
|
100
|
+
if (!css) {
|
|
101
|
+
const computedStyle = window.getComputedStyle(el);
|
|
102
|
+
css = computedStyle.getPropertyValue(key).trim();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return css || null;
|
|
96
106
|
}
|
|
97
107
|
// unset style
|
|
98
108
|
unset(key) {
|
|
@@ -105,9 +115,6 @@ export class StylesHandler {
|
|
|
105
115
|
delete(key) {
|
|
106
116
|
return '';
|
|
107
117
|
}
|
|
108
|
-
handlerFor(command) {
|
|
109
|
-
return (content, callback) => this.handle({ [command]: content, callback });
|
|
110
|
-
}
|
|
111
118
|
applyStyle(property, value) {
|
|
112
119
|
this.beElement.eachNode((el) => {
|
|
113
120
|
el.style[property] = value;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medyll/idae-be",
|
|
3
3
|
"scope": "@medyll",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.78.0",
|
|
5
5
|
"description": "A powerful DOM manipulation library with a callback-based approach for precise element targeting. Provides consistent chaining, comprehensive DOM traversal, event handling, style management, and more. Written in TypeScript for modern browsers.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite dev",
|