@medyll/idae-be 0.83.0 → 0.85.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.js +5 -2
- package/dist/modules/attrs.d.ts +2 -1
- package/dist/modules/attrs.js +13 -2
- package/dist/modules/position.d.ts +1 -2
- package/dist/modules/position.js +2 -2
- package/dist/types.d.ts +5 -5
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +29 -26
- package/package.json +1 -1
package/dist/be.js
CHANGED
|
@@ -127,7 +127,7 @@ export class Be {
|
|
|
127
127
|
// position
|
|
128
128
|
this.positionHandler = new PositionHandler(this);
|
|
129
129
|
this.position = this.handle(this.positionHandler);
|
|
130
|
-
this.attach(PositionHandler
|
|
130
|
+
this.attach(PositionHandler);
|
|
131
131
|
// text
|
|
132
132
|
this.textHandler = new TextHandler(this);
|
|
133
133
|
this.dom = this.handle(this.textHandler);
|
|
@@ -306,11 +306,14 @@ export class Be {
|
|
|
306
306
|
const fromMethods = Handler.methods || [];
|
|
307
307
|
fromMethods.forEach((method) => {
|
|
308
308
|
const handler = new Handler(this);
|
|
309
|
-
const methodName = method + suffix;
|
|
309
|
+
const methodName = suffix ? method + suffix : method;
|
|
310
310
|
if (!(method in handler)) {
|
|
311
311
|
console.error(`Method ${method} not found in ${Handler.name}`, handler);
|
|
312
312
|
}
|
|
313
313
|
else if (methodName in this) {
|
|
314
|
+
if (!handler) {
|
|
315
|
+
console.error(`Handler ${Handler.name} not found`, handler);
|
|
316
|
+
}
|
|
314
317
|
this[methodName] = (...args) => {
|
|
315
318
|
return handler[method].apply(handler, args);
|
|
316
319
|
};
|
package/dist/modules/attrs.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ declare enum attrMethods {
|
|
|
7
7
|
}
|
|
8
8
|
export type AttrHandlerHandle = {
|
|
9
9
|
set: AttrHandler['set'];
|
|
10
|
-
|
|
10
|
+
get: AttrHandler['get'];
|
|
11
|
+
delete: AttrHandler['delete'];
|
|
11
12
|
};
|
|
12
13
|
export declare class AttrHandler implements CommonHandler<AttrHandler, AttrHandler> {
|
|
13
14
|
private beElement;
|
package/dist/modules/attrs.js
CHANGED
|
@@ -12,12 +12,23 @@ export class AttrHandler {
|
|
|
12
12
|
this.beElement = element;
|
|
13
13
|
}
|
|
14
14
|
handle(actions) {
|
|
15
|
-
|
|
15
|
+
Object.entries(actions).forEach(([method, props]) => {
|
|
16
|
+
switch (method) {
|
|
17
|
+
case 'set':
|
|
18
|
+
this.set(props);
|
|
19
|
+
break;
|
|
20
|
+
case 'delete':
|
|
21
|
+
this.delete(props);
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
/* this.beElement.eachNode((el) => {
|
|
16
26
|
if (actions.delete) {
|
|
27
|
+
this.delete(actions.delete);
|
|
17
28
|
}
|
|
18
29
|
if (actions.set) {
|
|
19
30
|
}
|
|
20
|
-
});
|
|
31
|
+
}); */
|
|
21
32
|
return this.beElement;
|
|
22
33
|
}
|
|
23
34
|
get(name) {
|
|
@@ -62,8 +62,7 @@ export declare class PositionHandler implements CommonHandler<PositionHandler, P
|
|
|
62
62
|
* @param options.offset Optional offset from the target anchor point.
|
|
63
63
|
* @returns The Be instance for method chaining.
|
|
64
64
|
*/
|
|
65
|
-
snapTo(targetElement: string | HTMLElement,
|
|
66
|
-
options: {
|
|
65
|
+
snapTo(targetElement: string | HTMLElement, options: {
|
|
67
66
|
sourceAnchor: PositionSnapOptions;
|
|
68
67
|
targetAnchor: PositionSnapOptions;
|
|
69
68
|
offset?: {
|
package/dist/modules/position.js
CHANGED
|
@@ -132,8 +132,7 @@ export class PositionHandler {
|
|
|
132
132
|
* @param options.offset Optional offset from the target anchor point.
|
|
133
133
|
* @returns The Be instance for method chaining.
|
|
134
134
|
*/
|
|
135
|
-
snapTo(targetElement,
|
|
136
|
-
options, callback) {
|
|
135
|
+
snapTo(targetElement, options, callback) {
|
|
137
136
|
if (this.beElement.isWhat !== 'element')
|
|
138
137
|
return this.beElement;
|
|
139
138
|
const targetEl = typeof targetElement === 'string' ? document.querySelector(targetElement) : targetElement;
|
|
@@ -147,6 +146,7 @@ export class PositionHandler {
|
|
|
147
146
|
// Calculate final position
|
|
148
147
|
const x = targetX - sourceX + offset.x;
|
|
149
148
|
const y = targetY - sourceY + offset.y;
|
|
149
|
+
console.log('Calculated position:', { x, y }, [sourceX, sourceY], { sourceRect });
|
|
150
150
|
// Apply position
|
|
151
151
|
this.beElement.eachNode((el) => {
|
|
152
152
|
const computedStyle = window.getComputedStyle(el);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Be } from './be.js';
|
|
2
|
-
export type CombineElements<T extends string> = T extends
|
|
2
|
+
export type CombineElements<T extends string> = T extends unknown ? T | `${T} ${CombineElements<T>}` : never;
|
|
3
3
|
export type IsWhat = 'element' | 'array' | 'qy';
|
|
4
|
-
export type PositionSnapOptions = 'top' | 'right' | 'bottom' | 'left' | `${'top' | 'right' | '
|
|
4
|
+
export type PositionSnapOptions = 'top' | 'right' | 'bottom' | 'left' | 'center' | `${'top' | 'bottom'} ${'left' | 'right' | 'center'}` | `${'left' | 'right'} ${'top' | 'bottom' | 'center'}`;
|
|
5
5
|
export type HandlerCallbackProps = {
|
|
6
6
|
be: Be;
|
|
7
|
-
fragment:
|
|
7
|
+
fragment: unknown;
|
|
8
8
|
root: Be;
|
|
9
|
-
requested?:
|
|
9
|
+
requested?: unknown;
|
|
10
10
|
method?: string;
|
|
11
11
|
};
|
|
12
12
|
export type HandlerCallBackFn = (element: HandlerCallbackProps) => void;
|
|
@@ -16,7 +16,7 @@ export type HandlerCallBack = {
|
|
|
16
16
|
export type ExpandTyping<T> = T extends infer O ? {
|
|
17
17
|
[K in keyof O]: O[K];
|
|
18
18
|
} : never;
|
|
19
|
-
export interface CommonHandler<T =
|
|
19
|
+
export interface CommonHandler<T = unknown, H = unknown, V = unknown> {
|
|
20
20
|
handle: (actions: H) => Be;
|
|
21
21
|
methods: string[] | keyof T;
|
|
22
22
|
valueOf: () => V;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Be } from './be.js';
|
|
2
|
-
import type { CommonHandler } from './types.js';
|
|
2
|
+
import type { CommonHandler, PositionSnapOptions } from './types.js';
|
|
3
3
|
interface isHTMLReturn {
|
|
4
4
|
isHtml: boolean;
|
|
5
5
|
tag: string;
|
|
@@ -18,7 +18,7 @@ export declare class BeUtils {
|
|
|
18
18
|
returnHTMLelement?: boolean;
|
|
19
19
|
transformTextToHtml?: boolean;
|
|
20
20
|
}): isHTMLReturn;
|
|
21
|
-
static calculateAnchorPoint(rect: DOMRect, anchor:
|
|
21
|
+
static calculateAnchorPoint(rect: DOMRect, anchor: PositionSnapOptions): [number, number];
|
|
22
22
|
static applyStyle(beElement: Be, property: string, value: string): void;
|
|
23
23
|
static applyCallback(el: HTMLElement | HTMLCollection, callback: (el: HTMLElement) => void): void;
|
|
24
24
|
static resolveIndirection<T = CommonHandler>(classHandler: CommonHandler, actions: keyof T): {
|
package/dist/utils.js
CHANGED
|
@@ -62,33 +62,36 @@ export class BeUtils {
|
|
|
62
62
|
return result;
|
|
63
63
|
}
|
|
64
64
|
static calculateAnchorPoint(rect, anchor) {
|
|
65
|
-
|
|
66
|
-
let
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
let x = rect.left; // Valeur par défaut pour x
|
|
66
|
+
let y = rect.top; // Valeur par défaut pour y
|
|
67
|
+
if (typeof anchor === 'string') {
|
|
68
|
+
const [vertical, horizontal] = anchor.split(' ');
|
|
69
|
+
switch (vertical) {
|
|
70
|
+
case 'top':
|
|
71
|
+
y = rect.top;
|
|
72
|
+
break;
|
|
73
|
+
case 'bottom':
|
|
74
|
+
y = rect.bottom;
|
|
75
|
+
break;
|
|
76
|
+
case 'center':
|
|
77
|
+
y = rect.top + rect.height / 2;
|
|
78
|
+
x = rect.left + rect.width / 2;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
switch (horizontal) {
|
|
82
|
+
case 'left':
|
|
83
|
+
x = rect.left;
|
|
84
|
+
break;
|
|
85
|
+
case 'right':
|
|
86
|
+
x = rect.right;
|
|
87
|
+
break;
|
|
88
|
+
case 'center':
|
|
89
|
+
x = rect.left + rect.width / 2;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
79
92
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
x = rect.left;
|
|
83
|
-
break;
|
|
84
|
-
case 'right':
|
|
85
|
-
x = rect.right;
|
|
86
|
-
break;
|
|
87
|
-
case 'center':
|
|
88
|
-
x = rect.left + rect.width / 2;
|
|
89
|
-
break;
|
|
90
|
-
default:
|
|
91
|
-
x = rect.left;
|
|
93
|
+
else {
|
|
94
|
+
throw new Error('Invalid anchor type. Expected a string.');
|
|
92
95
|
}
|
|
93
96
|
return [x, y];
|
|
94
97
|
}
|
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.85.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",
|