@medyll/idae-be 0.78.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.
@@ -3,15 +3,12 @@ import type { CommonHandler } from '../types.js';
3
3
  declare enum beStyleMethods {
4
4
  set = "set",
5
5
  get = "get",
6
- delete = "delete",
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
- delete?: string;
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,10 +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
34
  private applyStyle;
35
+ getKey(key: string): string | null;
35
36
  }
36
37
  export {};
@@ -3,8 +3,7 @@ var beStyleMethods;
3
3
  (function (beStyleMethods) {
4
4
  beStyleMethods["set"] = "set";
5
5
  beStyleMethods["get"] = "get";
6
- beStyleMethods["delete"] = "delete";
7
- beStyleMethods["getKey"] = "getKey";
6
+ beStyleMethods["unset"] = "unset";
8
7
  })(beStyleMethods || (beStyleMethods = {}));
9
8
  export class StylesHandler {
10
9
  beElement;
@@ -13,11 +12,8 @@ export class StylesHandler {
13
12
  }
14
13
  static methods = Object.values(beStyleMethods);
15
14
  handle(actions) {
16
- console.log('StylesHandler.handle', actions);
17
15
  const { method, args } = this.resolveIndirection(actions);
18
- console.log({ method, args });
19
16
  this.beElement.eachNode((el) => {
20
- console.log({ method, args });
21
17
  switch (method) {
22
18
  case 'set':
23
19
  if (typeof args === 'string') {
@@ -29,10 +25,6 @@ export class StylesHandler {
29
25
  this.applyStyle(property, propertyValue);
30
26
  }
31
27
  });
32
- // If value is provided, treat it as a single property setting
33
- /* if (value !== undefined) {
34
- this.applyStyle(styles, value);
35
- } */
36
28
  }
37
29
  else if (typeof args === 'object') {
38
30
  // Handle object input
@@ -40,18 +32,18 @@ export class StylesHandler {
40
32
  this.applyStyle(prop, val);
41
33
  });
42
34
  }
43
- console.log({ method, args });
35
+ else {
36
+ console.warn('Invalid argument type for set method');
37
+ }
44
38
  break;
45
39
  case 'get':
46
- console.log({ method, args });
47
- break;
48
- case 'delete':
40
+ return this.get(args);
49
41
  break;
50
- case 'getKey':
42
+ case 'unset':
43
+ this.unset(args);
51
44
  break;
52
45
  }
53
46
  });
54
- console.log('StylesHandler.handle end');
55
47
  return this.beElement;
56
48
  }
57
49
  resolveIndirection(actions) {
@@ -92,7 +84,11 @@ export class StylesHandler {
92
84
  }
93
85
  return this.beElement;
94
86
  }
95
- // get style
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
+ */
96
92
  get(key) {
97
93
  let css = null;
98
94
  this.beElement.eachNode((el) => {
@@ -101,19 +97,15 @@ export class StylesHandler {
101
97
  const computedStyle = window.getComputedStyle(el);
102
98
  css = computedStyle.getPropertyValue(key).trim();
103
99
  }
104
- });
100
+ }, true);
105
101
  return css || null;
106
102
  }
107
103
  // unset style
108
104
  unset(key) {
109
- return '';
110
- }
111
- //
112
- getKey(key) {
113
- return '';
114
- }
115
- delete(key) {
116
- return '';
105
+ this.beElement.eachNode((el) => {
106
+ el.style.removeProperty(key);
107
+ });
108
+ return null;
117
109
  }
118
110
  applyStyle(property, value) {
119
111
  this.beElement.eachNode((el) => {
@@ -122,4 +114,11 @@ export class StylesHandler {
122
114
  // console.log(`Setting style ${property}: ${value}`);
123
115
  });
124
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
+ }
125
124
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@medyll/idae-be",
3
3
  "scope": "@medyll",
4
- "version": "0.78.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",