@medyll/idae-be 0.85.0 → 0.86.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.
@@ -15,6 +15,9 @@ var domMethods;
15
15
  domMethods["replace"] = "replace";
16
16
  domMethods["clear"] = "clear";
17
17
  })(domMethods || (domMethods = {}));
18
+ /**
19
+ * Handles DOM manipulation operations for Be elements.
20
+ */
18
21
  export class DomHandler {
19
22
  beElement;
20
23
  static methods = Object.values(domMethods);
@@ -64,6 +67,16 @@ export class DomHandler {
64
67
  });
65
68
  return this.beElement;
66
69
  }
70
+ /**
71
+ * Updates the content of the element(s).
72
+ * @param content - The new content to set.
73
+ * @param callback - Optional callback function.
74
+ * @returns The Be instance for method chaining.
75
+ * @example
76
+ * // HTML: <div id="test"></div>
77
+ * const beInstance = be('#test');
78
+ * beInstance.update('<p>Updated content</p>'); // Updates the content of the element
79
+ */
67
80
  update(content, callback) {
68
81
  this.beElement.eachNode((el) => {
69
82
  if (el) {
@@ -77,6 +90,16 @@ export class DomHandler {
77
90
  });
78
91
  return this.beElement;
79
92
  }
93
+ /**
94
+ * Appends content to the element(s).
95
+ * @param content - The content to append (string, HTMLElement, or Be instance).
96
+ * @param callback - Optional callback function to execute after appending.
97
+ * @returns The Be instance for method chaining.
98
+ * @example
99
+ * // HTML: <div id="test"></div>
100
+ * const beInstance = be('#test');
101
+ * beInstance.append('<span>Appended</span>'); // Appends content to the element
102
+ */
80
103
  append(content, callback) {
81
104
  const ret = [];
82
105
  this.beElement.eachNode((el) => {
@@ -96,6 +119,16 @@ export class DomHandler {
96
119
  });
97
120
  return this.beElement;
98
121
  }
122
+ /**
123
+ * Prepends content to the element(s).
124
+ * @param content - The content to prepend (string, HTMLElement, or Be instance).
125
+ * @param callback - Optional callback function to execute after prepending.
126
+ * @returns The Be instance for method chaining.
127
+ * @example
128
+ * // HTML: <div id="test"></div>
129
+ * const beInstance = be('#test');
130
+ * beInstance.prepend('<span>Prepended</span>'); // Prepends content to the element
131
+ */
99
132
  prepend(content, callback) {
100
133
  const ret = [];
101
134
  this.beElement.eachNode((el) => {
@@ -115,6 +148,17 @@ export class DomHandler {
115
148
  });
116
149
  return this.beElement;
117
150
  }
151
+ /**
152
+ * Inserts content into the element(s) at a specified position.
153
+ * @param mode - The position to insert the content ('afterbegin', 'afterend', 'beforebegin', 'beforeend').
154
+ * @param element - The content to insert (string, HTMLElement, or Be instance).
155
+ * @param callback - Optional callback function to execute after insertion.
156
+ * @returns The Be instance for method chaining.
157
+ * @example
158
+ * // HTML: <div id="test"></div>
159
+ * const beInstance = be('#test');
160
+ * beInstance.insert('afterbegin', '<span>Inserted</span>'); // Inserts content at the beginning
161
+ */
118
162
  insert(mode, element, callback) {
119
163
  switch (mode) {
120
164
  case 'afterbegin':
@@ -129,6 +173,12 @@ export class DomHandler {
129
173
  throw new Error(`Invalid mode: ${mode}`);
130
174
  }
131
175
  }
176
+ /**
177
+ * Inserts content at the beginning of the element(s).
178
+ * @param content - The content to insert (string, HTMLElement, or Be instance).
179
+ * @param callback - Optional callback function to execute after insertion.
180
+ * @returns The Be instance for method chaining.
181
+ */
132
182
  afterBegin(content, callback) {
133
183
  this.beElement.eachNode((el) => {
134
184
  this.adjacentElement(el, content, 'afterbegin');
@@ -140,6 +190,12 @@ export class DomHandler {
140
190
  });
141
191
  return this.beElement;
142
192
  }
193
+ /**
194
+ * Inserts content after the element(s).
195
+ * @param content - The content to insert (string, HTMLElement, or Be instance).
196
+ * @param callback - Optional callback function to execute after insertion.
197
+ * @returns The Be instance for method chaining.
198
+ */
143
199
  afterEnd(content, callback) {
144
200
  this.beElement.eachNode((el) => {
145
201
  // Insérer après l'élément cible
@@ -152,6 +208,12 @@ export class DomHandler {
152
208
  });
153
209
  return this.beElement;
154
210
  }
211
+ /**
212
+ * Inserts content before the element(s).
213
+ * @param content - The content to insert (string, HTMLElement, or Be instance).
214
+ * @param callback - Optional callback function to execute after insertion.
215
+ * @returns The Be instance for method chaining.
216
+ */
155
217
  beforeBegin(content, callback) {
156
218
  this.beElement.eachNode((el) => {
157
219
  // Insérer avant l'élément cible
@@ -164,6 +226,12 @@ export class DomHandler {
164
226
  });
165
227
  return this.beElement;
166
228
  }
229
+ /**
230
+ * Inserts content at the end of the element(s).
231
+ * @param content - The content to insert (string, HTMLElement, or Be instance).
232
+ * @param callback - Optional callback function to execute after insertion.
233
+ * @returns The Be instance for method chaining.
234
+ */
167
235
  beforeEnd(content, callback) {
168
236
  this.beElement.eachNode((el) => {
169
237
  // Insérer à la fin de l'élément cible
@@ -176,6 +244,12 @@ export class DomHandler {
176
244
  });
177
245
  return this.beElement;
178
246
  }
247
+ /**
248
+ * Replaces the element(s) with new content.
249
+ * @param content - The content to replace the element(s) with (string, HTMLElement, or Be instance).
250
+ * @param callback - Optional callback function to execute after replacement.
251
+ * @returns The Be instance for method chaining.
252
+ */
179
253
  replace(content, callback) {
180
254
  const ret = [];
181
255
  this.beElement.eachNode((el) => {
@@ -195,6 +269,15 @@ export class DomHandler {
195
269
  });
196
270
  return this.beElement;
197
271
  }
272
+ /**
273
+ * Removes the element(s) from the DOM.
274
+ * @param callback - Optional callback function to execute after removal.
275
+ * @returns The Be instance for method chaining.
276
+ * @example
277
+ * // HTML: <div id="test"><span>To be removed</span></div>
278
+ * const beInstance = be('#test span');
279
+ * beInstance.remove(); // Removes the span element
280
+ */
198
281
  remove(callback) {
199
282
  this.beElement.eachNode((el) => {
200
283
  el.remove();
@@ -206,6 +289,15 @@ export class DomHandler {
206
289
  });
207
290
  return this.beElement;
208
291
  }
292
+ /**
293
+ * Clears the content of the element(s).
294
+ * @param callback - Optional callback function to execute after clearing.
295
+ * @returns The Be instance for method chaining.
296
+ * @example
297
+ * // HTML: <div id="test"><span>Content</span></div>
298
+ * const beInstance = be('#test');
299
+ * beInstance.clear(); // Clears the content of the div
300
+ */
209
301
  clear(callback) {
210
302
  this.beElement.eachNode((el) => {
211
303
  const fragment = el.innerHTML;
@@ -218,6 +310,11 @@ export class DomHandler {
218
310
  });
219
311
  return this.beElement;
220
312
  }
313
+ /**
314
+ * Normalizes the content of the element(s).
315
+ * @param callback - Optional callback function to execute after normalization.
316
+ * @returns The Be instance for method chaining.
317
+ */
221
318
  normalize(callback) {
222
319
  this.beElement.eachNode((el) => {
223
320
  el.normalize();
@@ -229,6 +326,16 @@ export class DomHandler {
229
326
  });
230
327
  return this.beElement;
231
328
  }
329
+ /**
330
+ * Wraps the element(s) with a new element.
331
+ * @param tag - The tag name of the wrapper element (default is 'div').
332
+ * @param callback - Optional callback function to execute after wrapping.
333
+ * @returns The Be instance for method chaining.
334
+ * @example
335
+ * // HTML: <div id="test"></div>
336
+ * const beInstance = be('#test');
337
+ * beInstance.wrap('section'); // Wraps the div with a <section> element
338
+ */
232
339
  wrap(tag = 'div', callback) {
233
340
  // wrap in tag
234
341
  this.beElement.eachNode((el) => {
@@ -35,8 +35,46 @@ export declare class EventsHandler implements CommonHandler<EventsHandler> {
35
35
  * @returns The Be instance for method chaining.
36
36
  */
37
37
  handle(actions: EventHandlerHandle): Be;
38
+ /**
39
+ * Adds an event listener to the element(s).
40
+ * @param eventName - The name of the event to listen for.
41
+ * @param handler - The event handler function.
42
+ * @param options - Optional event listener options.
43
+ * @param callback - Optional callback function to execute after adding the event listener.
44
+ * @returns The Be instance for method chaining.
45
+ * @example
46
+ * // HTML: <div id="test"></div>
47
+ * const beInstance = be('#test');
48
+ * beInstance.on('click', () => console.log('Clicked!')); // Adds a click event listener
49
+ */
38
50
  on(eventName: string, handler: EventListener, options?: boolean | AddEventListenerOptions, callback?: HandlerCallBackFn): Be;
51
+ /**
52
+ * Removes an event listener from the element(s).
53
+ * @param eventName - The name of the event to remove.
54
+ * @param handler - The event handler function.
55
+ * @param options - Optional event listener options.
56
+ * @param callback - Optional callback function to execute after removing the event listener.
57
+ * @returns The Be instance for method chaining.
58
+ * @example
59
+ * // HTML: <div id="test"></div>
60
+ * const beInstance = be('#test');
61
+ * const handler = () => console.log('Clicked!');
62
+ * beInstance.on('click', handler); // Adds a click event listener
63
+ * beInstance.off('click', handler); // Removes the click event listener
64
+ */
39
65
  off(eventName: string, handler: EventListener, options?: boolean | AddEventListenerOptions, callback?: HandlerCallBackFn): Be;
66
+ /**
67
+ * Dispatches a custom event on the element(s).
68
+ * @param eventName - The name of the custom event to dispatch.
69
+ * @param detail - Optional data to include in the event.
70
+ * @param options - Optional event initialization options.
71
+ * @param callback - Optional callback function to execute after dispatching the event.
72
+ * @returns The Be instance for method chaining.
73
+ * @example
74
+ * // HTML: <div id="test"></div>
75
+ * const beInstance = be('#test');
76
+ * beInstance.fire('customEvent', { key: 'value' }); // Dispatches a custom event with data
77
+ */
40
78
  fire(eventName: string, detail: unknown, options?: EventInit, callback?: HandlerCallBackFn): Be;
41
79
  }
42
80
  export {};
@@ -34,6 +34,18 @@ export class EventsHandler {
34
34
  });
35
35
  return this.beElement;
36
36
  }
37
+ /**
38
+ * Adds an event listener to the element(s).
39
+ * @param eventName - The name of the event to listen for.
40
+ * @param handler - The event handler function.
41
+ * @param options - Optional event listener options.
42
+ * @param callback - Optional callback function to execute after adding the event listener.
43
+ * @returns The Be instance for method chaining.
44
+ * @example
45
+ * // HTML: <div id="test"></div>
46
+ * const beInstance = be('#test');
47
+ * beInstance.on('click', () => console.log('Clicked!')); // Adds a click event listener
48
+ */
37
49
  on(eventName, handler, options, callback) {
38
50
  this.beElement.eachNode((el) => {
39
51
  el.addEventListener(eventName, handler, options);
@@ -45,6 +57,20 @@ export class EventsHandler {
45
57
  });
46
58
  return this.beElement;
47
59
  }
60
+ /**
61
+ * Removes an event listener from the element(s).
62
+ * @param eventName - The name of the event to remove.
63
+ * @param handler - The event handler function.
64
+ * @param options - Optional event listener options.
65
+ * @param callback - Optional callback function to execute after removing the event listener.
66
+ * @returns The Be instance for method chaining.
67
+ * @example
68
+ * // HTML: <div id="test"></div>
69
+ * const beInstance = be('#test');
70
+ * const handler = () => console.log('Clicked!');
71
+ * beInstance.on('click', handler); // Adds a click event listener
72
+ * beInstance.off('click', handler); // Removes the click event listener
73
+ */
48
74
  off(eventName, handler, options, callback) {
49
75
  this.beElement.eachNode((el) => {
50
76
  el.removeEventListener(eventName, handler, options);
@@ -56,6 +82,18 @@ export class EventsHandler {
56
82
  });
57
83
  return this.beElement;
58
84
  }
85
+ /**
86
+ * Dispatches a custom event on the element(s).
87
+ * @param eventName - The name of the custom event to dispatch.
88
+ * @param detail - Optional data to include in the event.
89
+ * @param options - Optional event initialization options.
90
+ * @param callback - Optional callback function to execute after dispatching the event.
91
+ * @returns The Be instance for method chaining.
92
+ * @example
93
+ * // HTML: <div id="test"></div>
94
+ * const beInstance = be('#test');
95
+ * beInstance.fire('customEvent', { key: 'value' }); // Dispatches a custom event with data
96
+ */
59
97
  fire(eventName, detail, options, callback) {
60
98
  this.beElement.eachNode((el) => {
61
99
  el.dispatchEvent(new CustomEvent(eventName, { ...options, detail }));
@@ -27,12 +27,17 @@ export declare class PositionHandler implements CommonHandler<PositionHandler, P
27
27
  handle(actions: PositionHandlerHandle): Be;
28
28
  /**
29
29
  * Clones the position of a source element to this element.
30
- * @param source The element or selector of the element whose position is to be cloned.
31
- * @param options Additional options for positioning.
32
- * @param options.offsetX Horizontal offset from the source position.
33
- * @param options.offsetY Vertical offset from the source position.
34
- * @param options.useTransform Whether to use CSS transform for positioning.
30
+ * @param source - The element or selector of the element whose position is to be cloned.
31
+ * @param options - Additional options for positioning.
32
+ * @param options.offsetX - Horizontal offset from the source position.
33
+ * @param options.offsetY - Vertical offset from the source position.
34
+ * @param options.useTransform - Whether to use CSS transform for positioning.
35
+ * @param callback - Optional callback function to execute after cloning the position.
35
36
  * @returns The Be instance for method chaining.
37
+ * @example
38
+ * // HTML: <div id="source"></div><div id="target"></div>
39
+ * const beInstance = be('#target');
40
+ * beInstance.clonePosition('#source', { offsetX: 10, offsetY: 20 });
36
41
  */
37
42
  clonePosition(source: string | HTMLElement, options?: {
38
43
  offsetX?: number;
@@ -41,12 +46,17 @@ export declare class PositionHandler implements CommonHandler<PositionHandler, P
41
46
  }, callback?: HandlerCallBackFn): Be;
42
47
  /**
43
48
  * Positions this element to overlap a target element.
44
- * @param targetElement The element or selector of the element to overlap.
45
- * @param options Additional options for positioning.
46
- * @param options.alignment The alignment of this element relative to the target.
47
- * @param options.offset The distance to offset from the target element.
48
- * @param options.useTransform Whether to use CSS transform for positioning.
49
+ * @param targetElement - The element or selector of the element to overlap.
50
+ * @param options - Additional options for positioning.
51
+ * @param options.alignment - The alignment of this element relative to the target.
52
+ * @param options.offset - The distance to offset from the target element.
53
+ * @param options.useTransform - Whether to use CSS transform for positioning.
54
+ * @param callback - Optional callback function to execute after positioning.
49
55
  * @returns The Be instance for method chaining.
56
+ * @example
57
+ * // HTML: <div id="source"></div><div id="target"></div>
58
+ * const beInstance = be('#target');
59
+ * beInstance.overlapPosition('#source', { alignment: 'center', offset: 10 });
50
60
  */
51
61
  overlapPosition(targetElement: string | HTMLElement, options?: {
52
62
  alignment?: 'center' | 'top' | 'bottom' | 'left' | 'right';
@@ -55,12 +65,21 @@ export declare class PositionHandler implements CommonHandler<PositionHandler, P
55
65
  }, callback?: HandlerCallBackFn): Be;
56
66
  /**
57
67
  * Snaps the element to a target element with specified anchor points.
58
- * @param targetElement The element or selector of the element to snap to.
59
- * @param options Snapping options.
60
- * @param options.sourceAnchor The anchor point on the source element.
61
- * @param options.targetAnchor The anchor point on the target element.
62
- * @param options.offset Optional offset from the target anchor point.
68
+ * @param targetElement - The element or selector of the element to snap to.
69
+ * @param options - Snapping options.
70
+ * @param options.sourceAnchor - The anchor point on the source element.
71
+ * @param options.targetAnchor - The anchor point on the target element.
72
+ * @param options.offset - Optional offset from the target anchor point.
73
+ * @param callback - Optional callback function to execute after snapping.
63
74
  * @returns The Be instance for method chaining.
75
+ * @example
76
+ * // HTML: <div id="source"></div><div id="target"></div>
77
+ * const beInstance = be('#target');
78
+ * beInstance.snapTo('#source', {
79
+ * sourceAnchor: 'center',
80
+ * targetAnchor: 'top left',
81
+ * offset: { x: 10, y: 20 }
82
+ * });
64
83
  */
65
84
  snapTo(targetElement: string | HTMLElement, options: {
66
85
  sourceAnchor: PositionSnapOptions;
@@ -31,12 +31,17 @@ export class PositionHandler {
31
31
  }
32
32
  /**
33
33
  * Clones the position of a source element to this element.
34
- * @param source The element or selector of the element whose position is to be cloned.
35
- * @param options Additional options for positioning.
36
- * @param options.offsetX Horizontal offset from the source position.
37
- * @param options.offsetY Vertical offset from the source position.
38
- * @param options.useTransform Whether to use CSS transform for positioning.
34
+ * @param source - The element or selector of the element whose position is to be cloned.
35
+ * @param options - Additional options for positioning.
36
+ * @param options.offsetX - Horizontal offset from the source position.
37
+ * @param options.offsetY - Vertical offset from the source position.
38
+ * @param options.useTransform - Whether to use CSS transform for positioning.
39
+ * @param callback - Optional callback function to execute after cloning the position.
39
40
  * @returns The Be instance for method chaining.
41
+ * @example
42
+ * // HTML: <div id="source"></div><div id="target"></div>
43
+ * const beInstance = be('#target');
44
+ * beInstance.clonePosition('#source', { offsetX: 10, offsetY: 20 });
40
45
  */
41
46
  clonePosition(source, options = {}, callback) {
42
47
  if (this.beElement.isWhat !== 'element')
@@ -68,12 +73,17 @@ export class PositionHandler {
68
73
  }
69
74
  /**
70
75
  * Positions this element to overlap a target element.
71
- * @param targetElement The element or selector of the element to overlap.
72
- * @param options Additional options for positioning.
73
- * @param options.alignment The alignment of this element relative to the target.
74
- * @param options.offset The distance to offset from the target element.
75
- * @param options.useTransform Whether to use CSS transform for positioning.
76
+ * @param targetElement - The element or selector of the element to overlap.
77
+ * @param options - Additional options for positioning.
78
+ * @param options.alignment - The alignment of this element relative to the target.
79
+ * @param options.offset - The distance to offset from the target element.
80
+ * @param options.useTransform - Whether to use CSS transform for positioning.
81
+ * @param callback - Optional callback function to execute after positioning.
76
82
  * @returns The Be instance for method chaining.
83
+ * @example
84
+ * // HTML: <div id="source"></div><div id="target"></div>
85
+ * const beInstance = be('#target');
86
+ * beInstance.overlapPosition('#source', { alignment: 'center', offset: 10 });
77
87
  */
78
88
  overlapPosition(targetElement, options = {}, callback) {
79
89
  if (this.beElement.isWhat !== 'element')
@@ -125,12 +135,21 @@ export class PositionHandler {
125
135
  }
126
136
  /**
127
137
  * Snaps the element to a target element with specified anchor points.
128
- * @param targetElement The element or selector of the element to snap to.
129
- * @param options Snapping options.
130
- * @param options.sourceAnchor The anchor point on the source element.
131
- * @param options.targetAnchor The anchor point on the target element.
132
- * @param options.offset Optional offset from the target anchor point.
138
+ * @param targetElement - The element or selector of the element to snap to.
139
+ * @param options - Snapping options.
140
+ * @param options.sourceAnchor - The anchor point on the source element.
141
+ * @param options.targetAnchor - The anchor point on the target element.
142
+ * @param options.offset - Optional offset from the target anchor point.
143
+ * @param callback - Optional callback function to execute after snapping.
133
144
  * @returns The Be instance for method chaining.
145
+ * @example
146
+ * // HTML: <div id="source"></div><div id="target"></div>
147
+ * const beInstance = be('#target');
148
+ * beInstance.snapTo('#source', {
149
+ * sourceAnchor: 'center',
150
+ * targetAnchor: 'top left',
151
+ * offset: { x: 10, y: 20 }
152
+ * });
134
153
  */
135
154
  snapTo(targetElement, options, callback) {
136
155
  if (this.beElement.isWhat !== 'element')
@@ -146,7 +165,6 @@ export class PositionHandler {
146
165
  // Calculate final position
147
166
  const x = targetX - sourceX + offset.x;
148
167
  const y = targetY - sourceY + offset.y;
149
- console.log('Calculated position:', { x, y }, [sourceX, sourceY], { sourceRect });
150
168
  // Apply position
151
169
  this.beElement.eachNode((el) => {
152
170
  const computedStyle = window.getComputedStyle(el);
@@ -20,19 +20,38 @@ export declare class StylesHandler implements CommonHandler<StylesHandler> {
20
20
  handle(actions: BeStylesHandler): Be;
21
21
  private resolveIndirection;
22
22
  /**
23
- * setStyle Sets one or more CSS styles for the selected element(s), including CSS custom properties.
24
- * @param styles An object of CSS properties and values, or a string of CSS properties and values.
25
- * @param value The value for a single CSS property when styles is a property name string.
23
+ * Sets one or more CSS styles for the selected element(s), including CSS custom properties.
24
+ * @param styles - An object of CSS properties and values, or a string of CSS properties and values.
25
+ * @param value - The value for a single CSS property when styles is a property name string.
26
26
  * @returns The Be instance for method chaining.
27
+ * @example
28
+ * // HTML: <div id="test"></div>
29
+ * const beInstance = be('#test');
30
+ * beInstance.setStyle({ color: 'red', backgroundColor: 'blue' }); // Sets multiple styles
31
+ * beInstance.setStyle('color', 'green'); // Sets a single style
27
32
  */
28
33
  set(styles: Record<string, string> | string, value?: string): Be;
29
34
  /**
30
- * getStyle Gets the value of a CSS property for the first matched element.
31
- * @param key The CSS property name.
35
+ * Gets the value of a CSS property for the first matched element.
36
+ * @param key - The CSS property name.
32
37
  * @returns The value of the CSS property, or null if not found.
38
+ * @example
39
+ * // HTML: <div id="test" style="color: red;"></div>
40
+ * const beInstance = be('#test');
41
+ * const color = beInstance.getStyle('color');
42
+ * console.log(color); // Output: "red"
33
43
  */
34
44
  get(key: string): string | null;
35
- unset(key: string): string | null;
45
+ /**
46
+ * Removes a CSS property from the selected element(s).
47
+ * @param key - The CSS property name to remove.
48
+ * @returns The Be instance for method chaining.
49
+ * @example
50
+ * // HTML: <div id="test" style="color: red;"></div>
51
+ * const beInstance = be('#test');
52
+ * beInstance.unsetStyle('color'); // Removes the "color" style
53
+ */
54
+ unset(key: string): Be;
36
55
  private applyStyle;
37
56
  getKey(key: string): string | null;
38
57
  }
@@ -63,10 +63,15 @@ export class StylesHandler {
63
63
  return { method: method, args };
64
64
  }
65
65
  /**
66
- * setStyle Sets one or more CSS styles for the selected element(s), including CSS custom properties.
67
- * @param styles An object of CSS properties and values, or a string of CSS properties and values.
68
- * @param value The value for a single CSS property when styles is a property name string.
66
+ * Sets one or more CSS styles for the selected element(s), including CSS custom properties.
67
+ * @param styles - An object of CSS properties and values, or a string of CSS properties and values.
68
+ * @param value - The value for a single CSS property when styles is a property name string.
69
69
  * @returns The Be instance for method chaining.
70
+ * @example
71
+ * // HTML: <div id="test"></div>
72
+ * const beInstance = be('#test');
73
+ * beInstance.setStyle({ color: 'red', backgroundColor: 'blue' }); // Sets multiple styles
74
+ * beInstance.setStyle('color', 'green'); // Sets a single style
70
75
  */
71
76
  set(styles, value) {
72
77
  if (typeof styles === 'string') {
@@ -90,9 +95,14 @@ export class StylesHandler {
90
95
  return this.beElement;
91
96
  }
92
97
  /**
93
- * getStyle Gets the value of a CSS property for the first matched element.
94
- * @param key The CSS property name.
98
+ * Gets the value of a CSS property for the first matched element.
99
+ * @param key - The CSS property name.
95
100
  * @returns The value of the CSS property, or null if not found.
101
+ * @example
102
+ * // HTML: <div id="test" style="color: red;"></div>
103
+ * const beInstance = be('#test');
104
+ * const color = beInstance.getStyle('color');
105
+ * console.log(color); // Output: "red"
96
106
  */
97
107
  get(key) {
98
108
  let css = null;
@@ -107,12 +117,20 @@ export class StylesHandler {
107
117
  }, true);
108
118
  return css || null;
109
119
  }
110
- // unset style
120
+ /**
121
+ * Removes a CSS property from the selected element(s).
122
+ * @param key - The CSS property name to remove.
123
+ * @returns The Be instance for method chaining.
124
+ * @example
125
+ * // HTML: <div id="test" style="color: red;"></div>
126
+ * const beInstance = be('#test');
127
+ * beInstance.unsetStyle('color'); // Removes the "color" style
128
+ */
111
129
  unset(key) {
112
130
  this.beElement.eachNode((el) => {
113
131
  el.style.removeProperty(key);
114
132
  });
115
- return null;
133
+ return this.beElement;
116
134
  }
117
135
  applyStyle(property, value) {
118
136
  this.beElement.eachNode((el) => {
@@ -28,13 +28,90 @@ export declare class TextHandler implements CommonHandler<TextHandler> {
28
28
  methods: string[] | keyof TextHandler;
29
29
  get text(): string | null;
30
30
  handle(actions: TextHandlerHandle): Be;
31
+ /**
32
+ * Updates the text content of the element(s).
33
+ * @param content - The new text content to set.
34
+ * @param callback - Optional callback function.
35
+ * @returns The Be instance for method chaining.
36
+ * @example
37
+ * // HTML: <div id="test">Original</div>
38
+ * const beInstance = be('#test');
39
+ * beInstance.updateText('Updated'); // Updates the text content to "Updated"
40
+ */
31
41
  update(content: TextHandlerHandle['update'], callback?: HandlerCallBackFn): Be;
42
+ /**
43
+ * Appends text content to the element(s).
44
+ * @param content - The text content to append.
45
+ * @param callback - Optional callback function.
46
+ * @returns The Be instance for method chaining.
47
+ * @example
48
+ * // HTML: <div id="test">Original</div>
49
+ * const beInstance = be('#test');
50
+ * beInstance.appendText(' Appended'); // Appends " Appended" to the text content
51
+ */
32
52
  append(content: TextHandlerHandle['append'], callback?: HandlerCallBackFn): Be;
53
+ /**
54
+ * Prepends text content to the element(s).
55
+ * @param content - The text content to prepend.
56
+ * @param callback - Optional callback function.
57
+ * @returns The Be instance for method chaining.
58
+ * @example
59
+ * // HTML: <div id="test">Original</div>
60
+ * const beInstance = be('#test');
61
+ * beInstance.prependText('Prepended '); // Prepends "Prepended " to the text content
62
+ */
33
63
  prepend(content: TextHandlerHandle['prepend'], callback?: HandlerCallBackFn): Be;
64
+ /**
65
+ * Replaces the text content of the element(s).
66
+ * @param content - The new text content to replace with.
67
+ * @param callback - Optional callback function.
68
+ * @returns The Be instance for method chaining.
69
+ * @example
70
+ * // HTML: <div id="test">Original</div>
71
+ * const beInstance = be('#test');
72
+ * beInstance.replaceText('Replaced'); // Replaces the text content with "Replaced"
73
+ */
34
74
  replace(content: TextHandlerHandle['replace'], callback?: HandlerCallBackFn): Be;
75
+ /**
76
+ * Removes the element(s) from the DOM.
77
+ * @param callback - Optional callback function.
78
+ * @returns The Be instance for method chaining.
79
+ * @example
80
+ * // HTML: <div id="test">To be removed</div>
81
+ * const beInstance = be('#test');
82
+ * beInstance.removeText(); // Removes the element
83
+ */
35
84
  remove(callback?: HandlerCallBackFn): Be;
85
+ /**
86
+ * Clears the text content of the element(s).
87
+ * @param callback - Optional callback function.
88
+ * @returns The Be instance for method chaining.
89
+ * @example
90
+ * // HTML: <div id="test">Content</div>
91
+ * const beInstance = be('#test');
92
+ * beInstance.clearText(); // Clears the text content
93
+ */
36
94
  clear(callback?: HandlerCallBackFn): Be;
95
+ /**
96
+ * Normalizes the text content of the element(s).
97
+ * @param callback - Optional callback function.
98
+ * @returns The Be instance for method chaining.
99
+ * @example
100
+ * // HTML: <div id="test">Text <span>Fragment</span> Text</div>
101
+ * const beInstance = be('#test');
102
+ * beInstance.normalizeText(); // Normalizes the text content
103
+ */
37
104
  normalize(callback?: HandlerCallBackFn): Be;
105
+ /**
106
+ * Wraps the element(s) with a new element.
107
+ * @param content - The wrapper element as a string or HTMLElement.
108
+ * @param callback - Optional callback function.
109
+ * @returns The Be instance for method chaining.
110
+ * @example
111
+ * // HTML: <div id="test">Content</div>
112
+ * const beInstance = be('#test');
113
+ * beInstance.wrapText('<div class="wrapper"></div>'); // Wraps the element with a <div>
114
+ */
38
115
  wrap(content: TextHandlerHandle['wrap'], callback?: HandlerCallBackFn): Be;
39
116
  valueOf(): string | null;
40
117
  }