@supermousejs/utils 2.3.1 → 2.4.1
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/CHANGELOG.md +35 -0
- package/README.md +613 -8
- package/dist/css.d.ts +14 -0
- package/dist/css.d.ts.map +1 -1
- package/dist/doctor.d.ts +7 -4
- package/dist/doctor.d.ts.map +1 -1
- package/dist/dom.d.ts +24 -14
- package/dist/dom.d.ts.map +1 -1
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +425 -131
- package/dist/index.umd.js +5 -1
- package/dist/math.d.ts +1 -0
- package/dist/math.d.ts.map +1 -1
- package/dist/options.d.ts +30 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/plugin.d.ts +99 -22
- package/dist/plugin.d.ts.map +1 -1
- package/dist/svg.d.ts +36 -0
- package/dist/svg.d.ts.map +1 -0
- package/package.json +6 -4
- package/src/css.ts +18 -0
- package/src/doctor.ts +285 -32
- package/src/dom.ts +53 -31
- package/src/index.ts +15 -11
- package/src/math.ts +4 -0
- package/src/options.ts +65 -22
- package/src/plugin.ts +183 -119
- package/src/svg.ts +119 -0
- package/dist/layers.d.ts +0 -15
- package/dist/layers.d.ts.map +0 -1
- package/src/layers.ts +0 -17
package/dist/dom.d.ts
CHANGED
|
@@ -6,21 +6,30 @@
|
|
|
6
6
|
* @param css A string of CSS rules to inject.
|
|
7
7
|
*/
|
|
8
8
|
export declare const injectStyles: (id: string, css: string) => void;
|
|
9
|
+
type CSSProperties = {
|
|
10
|
+
[K in keyof CSSStyleDeclaration as CSSStyleDeclaration[K] extends (...args: any) => any ? never : K]?: string | number;
|
|
11
|
+
};
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
13
|
+
* Applies CSS properties to an element. Only touches the DOM when a value
|
|
14
|
+
* has actually changed.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* css(el, {
|
|
18
|
+
* width: `${size}px`,
|
|
19
|
+
* height: `${size}px`,
|
|
20
|
+
* opacity: state.isHover ? 1 : 0,
|
|
21
|
+
* backgroundColor: state.interaction.color || "#000",
|
|
22
|
+
* });
|
|
23
|
+
*/
|
|
24
|
+
export declare function css(el: HTMLElement | SVGElement, styles: CSSProperties): void;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use `dom.css()` instead. This function will be removed in future versions.
|
|
14
27
|
*/
|
|
15
|
-
export declare function
|
|
28
|
+
export declare function setStyle(el: HTMLElement | SVGElement, prop: string, value: string | number): void;
|
|
16
29
|
/**
|
|
17
|
-
*
|
|
18
|
-
* Proxies to applyStyles for consistency.
|
|
19
|
-
* @param el The element to style
|
|
20
|
-
* @param property The CSS property to set
|
|
21
|
-
* @param value The value to set for the property
|
|
30
|
+
* @deprecated Use `dom.css()` instead. This function will be removed in future versions.
|
|
22
31
|
*/
|
|
23
|
-
export declare function
|
|
32
|
+
export declare function applyStyles(el: HTMLElement | SVGElement, styles: Record<string, string | number>): void;
|
|
24
33
|
/**
|
|
25
34
|
* Universal Transform Setter.
|
|
26
35
|
* Handles centering (-50%) automatically.
|
|
@@ -34,18 +43,18 @@ export declare function setStyle(el: HTMLElement, property: keyof CSSStyleDeclar
|
|
|
34
43
|
* @param skewX Skew X (deg) - Default 0
|
|
35
44
|
* @param skewY Skew Y (deg) - Default 0
|
|
36
45
|
*/
|
|
37
|
-
export declare function setTransform(el: HTMLElement, x: number, y: number, rotation?: number, scaleX?: number, scaleY?: number, skewX?: number, skewY?: number): void;
|
|
46
|
+
export declare function setTransform(el: HTMLElement | SVGElement, x: number, y: number, rotation?: number, scaleX?: number, scaleY?: number, skewX?: number, skewY?: number): void;
|
|
38
47
|
/**
|
|
39
48
|
* Calculates the bounding rectangle of an element relative to a container.
|
|
40
49
|
*/
|
|
41
|
-
export declare function projectRect(element: HTMLElement, container?: HTMLElement): DOMRect;
|
|
50
|
+
export declare function projectRect(element: HTMLElement | SVGSVGElement, container?: HTMLElement | SVGSVGElement): DOMRect;
|
|
42
51
|
/**
|
|
43
52
|
* Creates a standard Supermouse actor element with optimal performance settings.
|
|
44
53
|
* Includes absolute positioning, pointer-events: none, and will-change: transform.
|
|
45
54
|
*
|
|
46
55
|
* @param tagName The HTML tag to create (default: 'div')
|
|
47
56
|
*/
|
|
48
|
-
export declare function createActor(tagName?: string): HTMLElement;
|
|
57
|
+
export declare function createActor(tagName?: string): HTMLElement | SVGSVGElement;
|
|
49
58
|
/**
|
|
50
59
|
* Creates a circular HTML div using the standard actor base.
|
|
51
60
|
*/
|
|
@@ -55,4 +64,5 @@ export declare function createCircle(size: number, color: string): HTMLDivElemen
|
|
|
55
64
|
* @deprecated Use createActor() instead.
|
|
56
65
|
*/
|
|
57
66
|
export declare function createDiv(): HTMLDivElement;
|
|
67
|
+
export {};
|
|
58
68
|
//# sourceMappingURL=dom.d.ts.map
|
package/dist/dom.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,EAAE,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,EAAE,KAAK,MAAM,KAAG,IAQtD,CAAC;AAIF,KAAK,aAAa,GAAG;KAClB,CAAC,IAAI,MAAM,mBAAmB,IAAI,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,GACnF,KAAK,GACL,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;CACzB,CAAC;AAMF;;;;;;;;;;;GAWG;AACH,wBAAgB,GAAG,CAAC,EAAE,EAAE,WAAW,GAAG,UAAU,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAkB7E;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,WAAW,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEjG;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,EAAE,EAAE,WAAW,GAAG,UAAU,EAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACtC,IAAI,CAEN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,WAAW,GAAG,UAAU,EAC5B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,GAAE,MAAU,EACpB,MAAM,GAAE,MAAU,EAClB,MAAM,GAAE,MAAU,EAClB,KAAK,GAAE,MAAU,EACjB,KAAK,GAAE,MAAU,GAChB,IAAI,CAIN;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,WAAW,GAAG,aAAa,EACpC,SAAS,GAAE,WAAW,GAAG,aAA6B,GACrD,OAAO,CAYT;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,MAAc,GAAG,WAAW,GAAG,aAAa,CAYhF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CASxE;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,cAAc,CAE1C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
export * from './math';
|
|
2
|
+
export * from './dom';
|
|
3
|
+
export * from './effects';
|
|
4
|
+
export * from './options';
|
|
5
|
+
export * from './doctor';
|
|
6
|
+
export * from './plugin';
|
|
7
|
+
export * from './svg';
|
|
8
|
+
export * from './css';
|
|
1
9
|
import * as math from "./math";
|
|
2
10
|
import * as dom from "./dom";
|
|
3
11
|
import * as effects from "./effects";
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export * from './css';
|
|
7
|
-
export { definePlugin } from './plugin';
|
|
8
|
-
export type { BasePluginOptions } from './plugin';
|
|
9
|
-
export { normalize } from './options';
|
|
10
|
-
export * from './doctor';
|
|
12
|
+
import * as svg from "./svg";
|
|
13
|
+
export { math, dom, effects, svg };
|
|
11
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AAEtB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC"}
|