@medyll/idae-be 0.81.0 → 0.82.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 CHANGED
@@ -57,6 +57,12 @@ export declare class Be {
57
57
  private textHandler;
58
58
  appendText: TextHandler['append'];
59
59
  prependText: TextHandler['prepend'];
60
+ updateText: TextHandler['update'];
61
+ replaceText: TextHandler['replace'];
62
+ removeText: TextHandler['remove'];
63
+ clearText: TextHandler['clear'];
64
+ normalizeText: TextHandler['normalize'];
65
+ wrapText: TextHandler['wrap'];
60
66
  events: (actions: EventHandlerHandle) => Be;
61
67
  private eventHandler;
62
68
  on: EventsHandler['on'];
package/dist/be.js CHANGED
@@ -65,6 +65,12 @@ export class Be {
65
65
  textHandler;
66
66
  appendText;
67
67
  prependText;
68
+ updateText;
69
+ replaceText;
70
+ removeText;
71
+ clearText;
72
+ normalizeText;
73
+ wrapText;
68
74
  // events
69
75
  events;
70
76
  eventHandler;
@@ -32,6 +32,8 @@ export declare class ClassesHandler implements CommonHandler<ClassesHandler, Cla
32
32
  private beElement;
33
33
  static methods: classesMethods[];
34
34
  constructor(beElement: Be);
35
+ methods: string[] | keyof ClassesHandler;
36
+ valueOf(): string;
35
37
  handle(actions: ClassHandlerHandlerHandle): Be;
36
38
  add(className: string | string[]): Be;
37
39
  /**
@@ -1,4 +1,3 @@
1
- import { BeUtils } from '../utils.js';
2
1
  import { Be } from '../be.js';
3
2
  var classesMethods;
4
3
  (function (classesMethods) {
@@ -16,6 +15,10 @@ export class ClassesHandler {
16
15
  constructor(beElement) {
17
16
  this.beElement = beElement;
18
17
  }
18
+ methods = ClassesHandler.methods;
19
+ valueOf() {
20
+ return `[ClassesHandler: methods=${this.methods}]`;
21
+ }
19
22
  handle(actions) {
20
23
  if (!actions)
21
24
  return this.beElement;
@@ -26,25 +29,6 @@ export class ClassesHandler {
26
29
  break;
27
30
  }
28
31
  });
29
- /* this.beElement.eachNode((el) => {
30
- if (actions.replace) {
31
- let replacements: [string, string][];
32
- if (typeof actions.replace === 'string') {
33
- replacements = actions.replace
34
- .split(';')
35
- .map((pair) => pair.trim().split(' ') as [string, string]);
36
- } else if (Array.isArray(actions.replace) && actions.replace.every(Array.isArray)) {
37
- replacements = actions.replace as [string, string][];
38
- } else {
39
- replacements = [actions.replace.split(' ') as [string, string]];
40
- }
41
- replacements.forEach(([oldClass, newClass]) => {
42
- if (oldClass && newClass) {
43
- el.classList.replace(oldClass, newClass);
44
- }
45
- });
46
- }
47
- }); */
48
32
  return this.beElement;
49
33
  }
50
34
  add(className) {
@@ -6,19 +6,62 @@ declare enum dataMethods {
6
6
  delete = "delete",
7
7
  getKey = "getKey"
8
8
  }
9
+ /**
10
+ * Type definition for DataHandler actions.
11
+ */
9
12
  export type DataHandlerHandle = {
13
+ get: (keyOrObject: string | Record<string, string>, value?: string) => Be;
10
14
  set: (keyOrObject: string | Record<string, string>, value?: string) => Be;
11
15
  delete: (keyOrObject: string | Record<string, string>, value?: string) => Be;
16
+ getKey: (keyOrObject: string | Record<string, string>, value?: string) => Be;
12
17
  };
18
+ /**
19
+ * Handles operations on `data-*` attributes for Be elements.
20
+ */
13
21
  export declare class DataHandler implements CommonHandler<DataHandler> {
14
22
  private beElement;
15
23
  static methods: dataMethods[];
24
+ /**
25
+ * Initializes the DataHandler with a Be element.
26
+ * @param element - The Be element to operate on.
27
+ */
16
28
  constructor(element: Be);
29
+ methods: string[] | keyof DataHandler;
30
+ /**
31
+ * Handles dynamic method calls for data operations.
32
+ * @param actions - The action to perform (e.g., set, get, delete).
33
+ * @returns The Be element for chaining.
34
+ */
17
35
  handle(actions: Partial<DataHandlerHandle>): Be;
36
+ /**
37
+ * Retrieves the value of a `data-*` attribute.
38
+ * @param key - The key of the `data-*` attribute to retrieve.
39
+ * @returns The value of the attribute, or `null` if not found.
40
+ */
18
41
  get(key: string): string | null;
42
+ /**
43
+ * Sets one or more `data-*` attributes.
44
+ * @param keyOrObject - A key-value pair or an object containing multiple key-value pairs.
45
+ * @param value - The value to set if a single key is provided.
46
+ * @returns The Be element for chaining.
47
+ */
19
48
  set(keyOrObject: string | Record<string, string>, value?: string): Be;
20
- delete(keyOrObject: string | Record<string, string>, value?: string): Be;
49
+ /**
50
+ * Deletes one or more `data-*` attributes.
51
+ * @param keyOrObject - A key or an object containing multiple keys to delete.
52
+ * @returns The Be element for chaining.
53
+ */
54
+ delete(keyOrObject: string | Record<string, string>): Be;
55
+ /**
56
+ * Retrieves the value of a specific `data-*` attribute.
57
+ * @param key - The key of the `data-*` attribute to retrieve.
58
+ * @returns The value of the attribute, or `null` if not found.
59
+ */
21
60
  getKey(key: string | string[]): string | null;
61
+ /**
62
+ * Retrieves all `data-*` attributes as a DOMStringMap.
63
+ * @returns A DOMStringMap containing all `data-*` attributes, or `null` if not applicable.
64
+ */
22
65
  valueOf(): DOMStringMap | null;
23
66
  }
24
67
  export {};
@@ -7,14 +7,27 @@ var dataMethods;
7
7
  dataMethods["delete"] = "delete";
8
8
  dataMethods["getKey"] = "getKey";
9
9
  })(dataMethods || (dataMethods = {}));
10
+ /**
11
+ * Handles operations on `data-*` attributes for Be elements.
12
+ */
10
13
  export class DataHandler {
11
14
  beElement;
12
15
  static methods = Object.values(dataMethods);
16
+ /**
17
+ * Initializes the DataHandler with a Be element.
18
+ * @param element - The Be element to operate on.
19
+ */
13
20
  constructor(element) {
14
21
  this.beElement = element;
15
22
  }
23
+ methods = DataHandler.methods;
24
+ /**
25
+ * Handles dynamic method calls for data operations.
26
+ * @param actions - The action to perform (e.g., set, get, delete).
27
+ * @returns The Be element for chaining.
28
+ */
16
29
  handle(actions) {
17
- const { method, props } = BeUtils.resolveIndirection(DataHandler, actions);
30
+ const { method, props } = BeUtils.resolveIndirection(this, actions);
18
31
  switch (method) {
19
32
  case 'set':
20
33
  case 'delete':
@@ -23,12 +36,22 @@ export class DataHandler {
23
36
  }
24
37
  return this.beElement;
25
38
  }
39
+ /**
40
+ * Retrieves the value of a `data-*` attribute.
41
+ * @param key - The key of the `data-*` attribute to retrieve.
42
+ * @returns The value of the attribute, or `null` if not found.
43
+ */
26
44
  get(key) {
27
- // if space in string
28
45
  if (this.beElement.isWhat !== 'element')
29
46
  return null;
30
47
  return this.beElement.inputNode.dataset[key] || null;
31
48
  }
49
+ /**
50
+ * Sets one or more `data-*` attributes.
51
+ * @param keyOrObject - A key-value pair or an object containing multiple key-value pairs.
52
+ * @param value - The value to set if a single key is provided.
53
+ * @returns The Be element for chaining.
54
+ */
32
55
  set(keyOrObject, value) {
33
56
  this.beElement.eachNode((el) => {
34
57
  if (typeof keyOrObject === 'string' && value !== undefined) {
@@ -42,25 +65,40 @@ export class DataHandler {
42
65
  });
43
66
  return this.beElement;
44
67
  }
45
- delete(keyOrObject, value) {
68
+ /**
69
+ * Deletes one or more `data-*` attributes.
70
+ * @param keyOrObject - A key or an object containing multiple keys to delete.
71
+ * @returns The Be element for chaining.
72
+ */
73
+ delete(keyOrObject) {
46
74
  this.beElement.eachNode((el) => {
47
- if (typeof keyOrObject === 'string' && value !== undefined) {
48
- el.dataset[keyOrObject] = value;
75
+ if (typeof keyOrObject === 'string') {
76
+ // Deletes a single attribute
77
+ delete el.dataset[keyOrObject];
49
78
  }
50
79
  else if (typeof keyOrObject === 'object') {
51
- Object.entries(keyOrObject).forEach(([key, val]) => {
80
+ // Deletes multiple attributes
81
+ Object.keys(keyOrObject).forEach((key) => {
52
82
  delete el.dataset[key];
53
83
  });
54
84
  }
55
85
  });
56
86
  return this.beElement;
57
87
  }
88
+ /**
89
+ * Retrieves the value of a specific `data-*` attribute.
90
+ * @param key - The key of the `data-*` attribute to retrieve.
91
+ * @returns The value of the attribute, or `null` if not found.
92
+ */
58
93
  getKey(key) {
59
- // if spaces in string
60
94
  if (this.beElement.isWhat !== 'element')
61
95
  return null;
62
96
  return this.beElement.inputNode.dataset[key] || null;
63
97
  }
98
+ /**
99
+ * Retrieves all `data-*` attributes as a DOMStringMap.
100
+ * @returns A DOMStringMap containing all `data-*` attributes, or `null` if not applicable.
101
+ */
64
102
  valueOf() {
65
103
  if (this.beElement.isWhat !== 'element')
66
104
  return null;
@@ -70,6 +70,7 @@ export declare class DomHandler implements DomHandlerInterface, CommonHandler<Do
70
70
  private beElement;
71
71
  static methods: domMethods[];
72
72
  constructor(element: Be);
73
+ methods: string[] | keyof DomHandler;
73
74
  /**
74
75
  * Handles various DOM operations on the element(s).
75
76
  * @param actions An object specifying the DOM actions to perform.
@@ -21,6 +21,7 @@ export class DomHandler {
21
21
  constructor(element) {
22
22
  this.beElement = element;
23
23
  }
24
+ methods = DomHandler.methods;
24
25
  /**
25
26
  * Handles various DOM operations on the element(s).
26
27
  * @param actions An object specifying the DOM actions to perform.
@@ -23,6 +23,7 @@ export declare class PositionHandler implements CommonHandler<PositionHandler, P
23
23
  private beElement;
24
24
  static methods: positionMethods[];
25
25
  constructor(beElement: Be);
26
+ methods: string[] | keyof PositionHandler;
26
27
  handle(actions: PositionHandlerHandle): Be;
27
28
  /**
28
29
  * Clones the position of a source element to this element.
@@ -12,6 +12,7 @@ export class PositionHandler {
12
12
  constructor(beElement) {
13
13
  this.beElement = beElement;
14
14
  }
15
+ methods = PositionHandler.methods;
15
16
  handle(actions) {
16
17
  Object.entries(actions).forEach(([method, props]) => {
17
18
  switch (method) {
@@ -141,11 +142,8 @@ export class PositionHandler {
141
142
  const sourceRect = this.beElement.inputNode.getBoundingClientRect();
142
143
  const targetRect = targetEl.getBoundingClientRect();
143
144
  const { sourceAnchor, targetAnchor, offset = { x: 0, y: 0 } } = options;
144
- let sourceX, sourceY, targetX, targetY;
145
- // Calculate source anchor point
146
- [sourceX, sourceY] = BeUtils.calculateAnchorPoint(sourceRect, sourceAnchor);
147
- // Calculate target anchor point
148
- [targetX, targetY] = BeUtils.calculateAnchorPoint(targetRect, targetAnchor);
145
+ const [sourceX, sourceY] = BeUtils.calculateAnchorPoint(sourceRect, sourceAnchor);
146
+ const [targetX, targetY] = BeUtils.calculateAnchorPoint(targetRect, targetAnchor);
149
147
  // Calculate final position
150
148
  const x = targetX - sourceX + offset.x;
151
149
  const y = targetY - sourceY + offset.y;
@@ -17,7 +17,8 @@ export interface PropsHandlerHandle {
17
17
  export declare class PropsHandler implements CommonHandler<PropsHandler, PropsHandlerHandle> {
18
18
  private beElement;
19
19
  static methods: PropsMethods[];
20
- constructor(element: Be);
20
+ constructor(beElement: Be);
21
+ methods: (keyof PropsHandler)[];
21
22
  handle(actions: PropsHandlerHandle): Be;
22
23
  get(name: string, callback?: HandlerCallBackFn): any;
23
24
  set(nameOrObject: string | Record<string, any>, value?: any, callback?: HandlerCallBackFn): Be;
@@ -9,9 +9,10 @@ var PropsMethods;
9
9
  export class PropsHandler {
10
10
  beElement;
11
11
  static methods = Object.values(PropsMethods);
12
- constructor(element) {
13
- this.beElement = element;
12
+ constructor(beElement) {
13
+ this.beElement = beElement;
14
14
  }
15
+ methods = PropsHandler.methods;
15
16
  handle(actions) {
16
17
  if (!actions)
17
18
  return this.beElement;
@@ -14,6 +14,8 @@ export type BeStylesHandlerMethods = keyof typeof beStyleMethods;
14
14
  export declare class StylesHandler implements CommonHandler<StylesHandler> {
15
15
  private beElement;
16
16
  constructor(beElement: Be);
17
+ methods: string[];
18
+ valueOf(): string;
17
19
  static methods: beStyleMethods[];
18
20
  handle(actions: BeStylesHandler): Be;
19
21
  private resolveIndirection;
@@ -10,10 +10,14 @@ export class StylesHandler {
10
10
  constructor(beElement) {
11
11
  this.beElement = beElement;
12
12
  }
13
+ methods = Object.keys(beStyleMethods);
14
+ valueOf() {
15
+ return `[StylesHandler: ${this.methods.join(', ')}]`;
16
+ }
13
17
  static methods = Object.values(beStyleMethods);
14
18
  handle(actions) {
15
19
  const { method, args } = this.resolveIndirection(actions);
16
- this.beElement.eachNode((el) => {
20
+ this.beElement.eachNode(() => {
17
21
  switch (method) {
18
22
  case 'set':
19
23
  if (typeof args === 'string') {
@@ -37,7 +41,7 @@ export class StylesHandler {
37
41
  }
38
42
  break;
39
43
  case 'get':
40
- return this.get(args);
44
+ this.get(args);
41
45
  break;
42
46
  case 'unset':
43
47
  this.unset(args);
@@ -47,15 +51,16 @@ export class StylesHandler {
47
51
  return this.beElement;
48
52
  }
49
53
  resolveIndirection(actions) {
50
- let method;
54
+ let method = 'get'; // Default to 'get' or any valid method
51
55
  let args;
52
56
  Object.keys(actions).forEach((action) => {
53
- if (StylesHandler.methods.includes(action)) {
54
- method = action;
55
- args = actions[action];
57
+ const actionKey = action;
58
+ if (StylesHandler.methods.includes(actionKey)) {
59
+ method = actionKey;
60
+ args = actions[actionKey];
56
61
  }
57
62
  });
58
- return { method, args };
63
+ return { method: method, args };
59
64
  }
60
65
  /**
61
66
  * setStyle Sets one or more CSS styles for the selected element(s), including CSS custom properties.
@@ -92,7 +97,9 @@ export class StylesHandler {
92
97
  get(key) {
93
98
  let css = null;
94
99
  this.beElement.eachNode((el) => {
100
+ // Prioritize inline styles
95
101
  css = el.style[key] || null;
102
+ // Fallback to computed styles if inline style is not set
96
103
  if (!css) {
97
104
  const computedStyle = window.getComputedStyle(el);
98
105
  css = computedStyle.getPropertyValue(key).trim();
@@ -109,9 +116,8 @@ export class StylesHandler {
109
116
  }
110
117
  applyStyle(property, value) {
111
118
  this.beElement.eachNode((el) => {
112
- el.style[property] = value;
113
- // el.style.setProperty(property, value);
114
- // console.log(`Setting style ${property}: ${value}`);
119
+ const kebabProperty = toKebabCase(property);
120
+ el.style.setProperty(kebabProperty, value);
115
121
  });
116
122
  }
117
123
  getKey(key) {
@@ -122,3 +128,6 @@ export class StylesHandler {
122
128
  return value;
123
129
  }
124
130
  }
131
+ function toKebabCase(property) {
132
+ return property.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
133
+ }
@@ -25,17 +25,17 @@ export declare class TextHandler implements CommonHandler<TextHandler> {
25
25
  private beElement;
26
26
  static methods: textMethods[];
27
27
  constructor(element: Be);
28
+ methods: string[] | keyof TextHandler;
28
29
  get text(): string | null;
29
30
  handle(actions: TextHandlerHandle): Be;
30
- update(content: TextHandlerHandle['update'], callback?: HandlerCallBackFn): void;
31
- updateText(content: TextHandlerHandle['updateText'], callback?: HandlerCallBackFn): void;
31
+ update(content: TextHandlerHandle['update'], callback?: HandlerCallBackFn): Be;
32
32
  append(content: TextHandlerHandle['append'], callback?: HandlerCallBackFn): Be;
33
- prepend(content: TextHandlerHandle['prepend'], callback?: HandlerCallBackFn): void;
34
- replace(content: TextHandlerHandle['replace'], callback?: HandlerCallBackFn): void;
35
- remove(content: TextHandlerHandle['remove'], callback?: HandlerCallBackFn): void;
36
- clear(content: TextHandlerHandle['clear'], callback?: HandlerCallBackFn): void;
37
- normalize(content: TextHandlerHandle['normalize'], callback?: HandlerCallBackFn): void;
38
- wrap(content: TextHandlerHandle['wrap'], callback?: HandlerCallBackFn): void;
33
+ prepend(content: TextHandlerHandle['prepend'], callback?: HandlerCallBackFn): Be;
34
+ replace(content: TextHandlerHandle['replace'], callback?: HandlerCallBackFn): Be;
35
+ remove(callback?: HandlerCallBackFn): Be;
36
+ clear(callback?: HandlerCallBackFn): Be;
37
+ normalize(callback?: HandlerCallBackFn): Be;
38
+ wrap(content: TextHandlerHandle['wrap'], callback?: HandlerCallBackFn): Be;
39
39
  valueOf(): string | null;
40
40
  }
41
41
  export {};
@@ -17,6 +17,7 @@ export class TextHandler {
17
17
  constructor(element) {
18
18
  this.beElement = element;
19
19
  }
20
+ methods = TextHandler.methods;
20
21
  get text() {
21
22
  if (this.beElement.isWhat !== 'element')
22
23
  return null;
@@ -24,29 +25,57 @@ export class TextHandler {
24
25
  }
25
26
  handle(actions) {
26
27
  this.beElement.eachNode((el) => {
27
- const { method, props } = BeUtils.resolveIndirection(TextHandler, actions);
28
+ const { method, props } = BeUtils.resolveIndirection(new TextHandler(this.beElement), actions);
28
29
  switch (method) {
29
30
  case 'update':
30
- el.innerText = props;
31
+ if (typeof props === 'string') {
32
+ el.innerText = props;
33
+ }
31
34
  break;
32
- case 'prepend': // append to text content
33
- el.insertAdjacentHTML('beforebegin', props);
35
+ case 'prepend':
36
+ if (typeof props === 'string') {
37
+ el.insertAdjacentHTML('afterbegin', props);
38
+ }
39
+ else {
40
+ throw new Error('Invalid props for prepend: must be a string.');
41
+ }
34
42
  break;
35
43
  case 'append':
36
- el.insertAdjacentHTML('afterbegin', props);
44
+ if (typeof props === 'string') {
45
+ el.insertAdjacentHTML('beforeend', props);
46
+ }
47
+ else {
48
+ throw new Error('Invalid props for append: must be a string.');
49
+ }
37
50
  break;
38
51
  case 'replace':
39
- el.outerHTML = props;
52
+ if (typeof props === 'string') {
53
+ el.outerHTML = props;
54
+ }
55
+ else {
56
+ throw new Error('Invalid props for replace: must be a string.');
57
+ }
40
58
  break;
41
59
  case 'remove':
42
60
  el.remove();
43
61
  break;
44
62
  case 'clear':
45
- el.outerHTML = '';
63
+ el.innerHTML = '';
46
64
  break;
47
65
  case 'normalize':
48
66
  el.normalize();
49
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;
50
79
  }
51
80
  actions?.callback?.({
52
81
  fragment: props,
@@ -57,31 +86,28 @@ export class TextHandler {
57
86
  return this.beElement;
58
87
  }
59
88
  update(content, callback) {
60
- this.handle({ update: content, callback });
61
- }
62
- updateText(content, callback) {
63
- this.handle({ updateText: content, callback });
89
+ return this.handle({ update: content, callback });
64
90
  }
65
91
  append(content, callback) {
66
92
  return this.handle({ append: content, callback });
67
93
  }
68
94
  prepend(content, callback) {
69
- this.handle({ prepend: content, callback });
95
+ return this.handle({ prepend: content, callback });
70
96
  }
71
97
  replace(content, callback) {
72
- this.handle({ replace: content, callback });
98
+ return this.handle({ replace: content, callback });
73
99
  }
74
- remove(content, callback) {
75
- this.handle({ remove: content, callback });
100
+ remove(callback) {
101
+ return this.handle({ remove: undefined, callback });
76
102
  }
77
- clear(content, callback) {
78
- this.handle({ clear: content, callback });
103
+ clear(callback) {
104
+ return this.handle({ clear: undefined, callback });
79
105
  }
80
- normalize(content, callback) {
81
- this.handle({ normalize: content, callback });
106
+ normalize(callback) {
107
+ return this.handle({ normalize: undefined, callback });
82
108
  }
83
109
  wrap(content, callback) {
84
- this.handle({ wrap: content, callback });
110
+ return this.handle({ wrap: content, callback });
85
111
  }
86
112
  valueOf() {
87
113
  if (this.beElement.isWhat !== 'element')
@@ -15,10 +15,12 @@ export declare class TimersHandler implements CommonHandler<TimersHandler> {
15
15
  _timer: NodeJS.Timeout | null;
16
16
  _interval: NodeJS.Timeout | null;
17
17
  constructor(element: Be);
18
+ methods: string[] | keyof TimersHandler;
19
+ valueOf(): unknown;
18
20
  handle(actions: TimerHandlerHandle): Be;
19
21
  timeout(value: TimerHandlerHandle['timeout'], callback?: HandlerCallBackFn): Be;
20
22
  interval(value: TimerHandlerHandle['interval'], callback?: HandlerCallBackFn): Be;
21
- clearTimeout(callback?: HandlerCallBackFn): void;
22
- clearInterval(callback?: HandlerCallBackFn): void;
23
+ clearTimeout(callback?: HandlerCallBackFn): Be;
24
+ clearInterval(callback?: HandlerCallBackFn): Be;
23
25
  }
24
26
  export {};
@@ -14,6 +14,14 @@ export class TimersHandler {
14
14
  constructor(element) {
15
15
  this.beElement = element;
16
16
  }
17
+ methods = TimersHandler.methods;
18
+ valueOf() {
19
+ return {
20
+ methods: this.methods,
21
+ timer: this._timer,
22
+ interval: this._interval
23
+ };
24
+ }
17
25
  handle(actions) {
18
26
  if (!actions)
19
27
  return this.beElement;
@@ -32,7 +40,15 @@ export class TimersHandler {
32
40
  return this.beElement;
33
41
  }
34
42
  timeout(value, callback) {
35
- this.beElement.eachNode((el) => {
43
+ this.beElement.BeTimer = setTimeout(() => {
44
+ callback?.({
45
+ method: 'timeout',
46
+ fragment: this.beElement.BeTimer,
47
+ be: this.beElement,
48
+ root: this.beElement
49
+ });
50
+ }, value);
51
+ /* this.beElement.eachNode((el: HTMLElement) => {
36
52
  const aug = be(el);
37
53
  aug.BeTimer = setTimeout(() => {
38
54
  callback?.({
@@ -42,43 +58,65 @@ export class TimersHandler {
42
58
  root: this.beElement
43
59
  });
44
60
  }, value);
45
- });
61
+ }); */
46
62
  return this.beElement;
47
63
  }
48
64
  interval(value, callback) {
49
- this.beElement.eachNode((el) => {
65
+ this.beElement.BeInterval = setInterval(() => {
66
+ callback?.({
67
+ method: 'interval',
68
+ fragment: this.beElement.BeInterval,
69
+ be: this.beElement,
70
+ root: this.beElement
71
+ });
72
+ }, value);
73
+ /* this.beElement.eachNode((el: HTMLElement) => {
50
74
  const aug = be(el);
51
- aug.BeTimer = setInterval(() => {
75
+ aug.BeInterval = setInterval(() => {
52
76
  callback?.({
53
77
  method: 'interval',
54
- fragment: aug.BeTimer,
78
+ fragment: aug.BeInterval,
55
79
  be: be(el),
56
80
  root: this.beElement
57
81
  });
58
82
  }, value);
59
- });
83
+ }); */
60
84
  return this.beElement;
61
85
  }
62
86
  clearTimeout(callback) {
63
- this.beElement.eachNode((el) => {
64
- clearTimeout(be(el).BeTimer);
65
- callback?.({
66
- method: 'clearTimeout',
67
- fragment: be(el).BeTimer,
68
- be: be(el),
69
- root: this.beElement
70
- });
87
+ clearTimeout(this.beElement?.BeTimer);
88
+ this.beElement.BeTimer = null;
89
+ /* this.beElement.eachNode((el: HTMLElement) => {
90
+ const aug = be(el);
91
+ if (aug.BeTimer !== null) {
92
+ clearTimeout(aug.BeTimer);
93
+ aug.BeTimer = null;
94
+ }
95
+ }); */
96
+ callback?.({
97
+ method: 'clearTimeout',
98
+ fragment: null,
99
+ be: this.beElement,
100
+ root: this.beElement
71
101
  });
102
+ return this.beElement;
72
103
  }
73
104
  clearInterval(callback) {
74
- this.beElement.eachNode((el) => {
75
- clearInterval(be(el).BeTimer);
76
- callback?.({
77
- method: 'clearInterval',
78
- fragment: be(el).BeTimer,
79
- be: be(el),
80
- root: this.beElement
81
- });
105
+ clearInterval(this.beElement?.BeInterval);
106
+ this.beElement.BeInterval = null;
107
+ /* this.beElement.eachNode((el: HTMLElement) => {
108
+ const aug = be(el);
109
+ if (aug.BeInterval !== null) {
110
+ clearInterval(aug.BeInterval);
111
+ aug.BeInterval = null;
112
+ }
113
+ }); */
114
+ callback?.({
115
+ method: 'clearInterval',
116
+ fragment: null,
117
+ be: this.beElement,
118
+ root: this.beElement
82
119
  });
120
+ return this.beElement;
83
121
  }
84
122
  }
@@ -101,6 +101,8 @@ export declare class WalkHandler implements WalkHandlerInterface, CommonHandler<
101
101
  * @param beElement - The Be element to operate on.
102
102
  */
103
103
  constructor(beElement: Be);
104
+ methods: string[];
105
+ valueOf(): unknown;
104
106
  /**
105
107
  * Handles multiple walk operations.
106
108
  * @param actions - The actions to perform.
@@ -29,6 +29,10 @@ export class WalkHandler {
29
29
  constructor(beElement) {
30
30
  this.beElement = beElement;
31
31
  }
32
+ methods = WalkHandler.methods;
33
+ valueOf() {
34
+ return this.beElement;
35
+ }
32
36
  /**
33
37
  * Handles multiple walk operations.
34
38
  * @param actions - The actions to perform.
@@ -114,7 +118,6 @@ export class WalkHandler {
114
118
  this.beElement.eachNode((el) => {
115
119
  if (el.parentNode) {
116
120
  const siblings = Array.from(el.parentNode.children).filter((child) => child !== el);
117
- console.log('siblings found:', siblings); // Debug
118
121
  ret.push(...siblings.filter((sibling) => !qy || sibling.matches(qy)));
119
122
  }
120
123
  });
@@ -188,7 +191,6 @@ export class WalkHandler {
188
191
  const ret = [];
189
192
  this.beElement.eachNode((el) => {
190
193
  const found = el.querySelector(qy);
191
- console.log('find result:', found); // Debug
192
194
  if (found)
193
195
  ret.push(found);
194
196
  });
@@ -231,7 +233,6 @@ export class WalkHandler {
231
233
  const ret = [];
232
234
  this.beElement.eachNode((el) => {
233
235
  const result = this.selectWhile(el, method, qy);
234
- console.log(`methodize result for ${method}:`, typeof result, result); // Debug
235
236
  if (result)
236
237
  ret.push(...(Array.isArray(result) ? result : [result]));
237
238
  });
@@ -245,7 +246,7 @@ export class WalkHandler {
245
246
  return resultBe;
246
247
  }
247
248
  catch (e) {
248
- console.error(`Error in methodize for ${method}:`, e); // Debug
249
+ console.error(`Error in methodize for ${method}:`, e);
249
250
  }
250
251
  return this.beElement;
251
252
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@medyll/idae-be",
3
3
  "scope": "@medyll",
4
- "version": "0.81.0",
4
+ "version": "0.82.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",