@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/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
- * Smart Style Setter (Batch).
11
- * Only writes to the DOM if the value has actually changed.
12
- * @param el The element to style
13
- * @param styles An object of CSS properties and values
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 applyStyles(el: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
28
+ export declare function setStyle(el: HTMLElement | SVGElement, prop: string, value: string | number): void;
16
29
  /**
17
- * Smart Style Setter (Single).
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 setStyle(el: HTMLElement, property: keyof CSSStyleDeclaration, value: string | number): void;
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,SAQnD,CAAC;AAKF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,QAgBhF;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,EAAE,EAAE,WAAW,EACf,QAAQ,EAAE,MAAM,mBAAmB,EACnC,KAAK,EAAE,MAAM,GAAG,MAAM,QAGvB;AAED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AgB,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
- export { math, dom, effects };
5
- export * from './layers';
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,cAAc,UAAU,CAAC"}
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"}