@medyll/idae-be 0.77.0 → 0.79.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 +8 -8
- package/dist/modules/styles.js +41 -35
- 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
|
@@ -3,15 +3,12 @@ import type { CommonHandler } from '../types.js';
|
|
|
3
3
|
declare enum beStyleMethods {
|
|
4
4
|
set = "set",
|
|
5
5
|
get = "get",
|
|
6
|
-
|
|
7
|
-
getKey = "getKey"
|
|
6
|
+
unset = "unset"
|
|
8
7
|
}
|
|
9
8
|
export interface BeStylesHandler {
|
|
10
9
|
set?: Record<string, string> | string;
|
|
11
|
-
value?: string;
|
|
12
10
|
get?: string;
|
|
13
|
-
|
|
14
|
-
getKey?: string;
|
|
11
|
+
unset?: string;
|
|
15
12
|
}
|
|
16
13
|
export type BeStylesHandlerMethods = keyof typeof beStyleMethods;
|
|
17
14
|
export declare class StylesHandler implements CommonHandler<StylesHandler> {
|
|
@@ -27,11 +24,14 @@ export declare class StylesHandler implements CommonHandler<StylesHandler> {
|
|
|
27
24
|
* @returns The Be instance for method chaining.
|
|
28
25
|
*/
|
|
29
26
|
set(styles: Record<string, string> | string, value?: string): Be;
|
|
27
|
+
/**
|
|
28
|
+
* getStyle Gets the value of a CSS property for the first matched element.
|
|
29
|
+
* @param key The CSS property name.
|
|
30
|
+
* @returns The value of the CSS property, or null if not found.
|
|
31
|
+
*/
|
|
30
32
|
get(key: string): string | null;
|
|
31
33
|
unset(key: string): string | null;
|
|
32
|
-
getKey(key: string): string | null;
|
|
33
|
-
delete(key: string): string | null;
|
|
34
|
-
private handlerFor;
|
|
35
34
|
private applyStyle;
|
|
35
|
+
getKey(key: string): string | null;
|
|
36
36
|
}
|
|
37
37
|
export {};
|
package/dist/modules/styles.js
CHANGED
|
@@ -3,8 +3,7 @@ var beStyleMethods;
|
|
|
3
3
|
(function (beStyleMethods) {
|
|
4
4
|
beStyleMethods["set"] = "set";
|
|
5
5
|
beStyleMethods["get"] = "get";
|
|
6
|
-
beStyleMethods["
|
|
7
|
-
beStyleMethods["getKey"] = "getKey";
|
|
6
|
+
beStyleMethods["unset"] = "unset";
|
|
8
7
|
})(beStyleMethods || (beStyleMethods = {}));
|
|
9
8
|
export class StylesHandler {
|
|
10
9
|
beElement;
|
|
@@ -26,10 +25,6 @@ export class StylesHandler {
|
|
|
26
25
|
this.applyStyle(property, propertyValue);
|
|
27
26
|
}
|
|
28
27
|
});
|
|
29
|
-
// If value is provided, treat it as a single property setting
|
|
30
|
-
/* if (value !== undefined) {
|
|
31
|
-
this.applyStyle(styles, value);
|
|
32
|
-
} */
|
|
33
28
|
}
|
|
34
29
|
else if (typeof args === 'object') {
|
|
35
30
|
// Handle object input
|
|
@@ -37,14 +32,15 @@ export class StylesHandler {
|
|
|
37
32
|
this.applyStyle(prop, val);
|
|
38
33
|
});
|
|
39
34
|
}
|
|
40
|
-
|
|
35
|
+
else {
|
|
36
|
+
console.warn('Invalid argument type for set method');
|
|
37
|
+
}
|
|
41
38
|
break;
|
|
42
39
|
case 'get':
|
|
43
|
-
|
|
44
|
-
break;
|
|
45
|
-
case 'delete':
|
|
40
|
+
return this.get(args);
|
|
46
41
|
break;
|
|
47
|
-
case '
|
|
42
|
+
case 'unset':
|
|
43
|
+
this.unset(args);
|
|
48
44
|
break;
|
|
49
45
|
}
|
|
50
46
|
});
|
|
@@ -69,17 +65,15 @@ export class StylesHandler {
|
|
|
69
65
|
*/
|
|
70
66
|
set(styles, value) {
|
|
71
67
|
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);
|
|
68
|
+
// Handle string input, if contains ':' and use cssText
|
|
69
|
+
if (styles.includes(':')) {
|
|
70
|
+
this.beElement.eachNode((el) => {
|
|
71
|
+
el.style.cssText = styles;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// If value is provided, treat it as a single property setting
|
|
76
|
+
this.applyStyle(styles, value ?? '');
|
|
83
77
|
}
|
|
84
78
|
}
|
|
85
79
|
else if (typeof styles === 'object') {
|
|
@@ -90,23 +84,28 @@ export class StylesHandler {
|
|
|
90
84
|
}
|
|
91
85
|
return this.beElement;
|
|
92
86
|
}
|
|
93
|
-
|
|
87
|
+
/**
|
|
88
|
+
* getStyle Gets the value of a CSS property for the first matched element.
|
|
89
|
+
* @param key The CSS property name.
|
|
90
|
+
* @returns The value of the CSS property, or null if not found.
|
|
91
|
+
*/
|
|
94
92
|
get(key) {
|
|
95
|
-
|
|
93
|
+
let css = null;
|
|
94
|
+
this.beElement.eachNode((el) => {
|
|
95
|
+
css = el.style[key] || null;
|
|
96
|
+
if (!css) {
|
|
97
|
+
const computedStyle = window.getComputedStyle(el);
|
|
98
|
+
css = computedStyle.getPropertyValue(key).trim();
|
|
99
|
+
}
|
|
100
|
+
}, true);
|
|
101
|
+
return css || null;
|
|
96
102
|
}
|
|
97
103
|
// unset style
|
|
98
104
|
unset(key) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return '';
|
|
104
|
-
}
|
|
105
|
-
delete(key) {
|
|
106
|
-
return '';
|
|
107
|
-
}
|
|
108
|
-
handlerFor(command) {
|
|
109
|
-
return (content, callback) => this.handle({ [command]: content, callback });
|
|
105
|
+
this.beElement.eachNode((el) => {
|
|
106
|
+
el.style.removeProperty(key);
|
|
107
|
+
});
|
|
108
|
+
return null;
|
|
110
109
|
}
|
|
111
110
|
applyStyle(property, value) {
|
|
112
111
|
this.beElement.eachNode((el) => {
|
|
@@ -115,4 +114,11 @@ export class StylesHandler {
|
|
|
115
114
|
// console.log(`Setting style ${property}: ${value}`);
|
|
116
115
|
});
|
|
117
116
|
}
|
|
117
|
+
getKey(key) {
|
|
118
|
+
let value = null;
|
|
119
|
+
this.beElement.eachNode((el) => {
|
|
120
|
+
value = el.style.getPropertyValue(key) || null;
|
|
121
|
+
});
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
118
124
|
}
|
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.79.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",
|