@supermousejs/text 2.3.0 → 2.4.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @supermousejs/text
2
2
 
3
- Displays a contextual text label next to the cursor when hovering interactive elements.
3
+ Injects contextual text bubbles near the cursor on interaction. Works like a tooltip.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,27 +8,26 @@ Displays a contextual text label next to the cursor when hovering interactive el
8
8
  pnpm add @supermousejs/text
9
9
  ```
10
10
 
11
- ## Usage
11
+ ## Text
12
+
13
+ Injects contextual text bubbles near the cursor on interaction. Works like a tooltip.
14
+
15
+ ### Usage
12
16
 
13
17
  ```ts
14
18
  import { Supermouse } from "@supermousejs/core";
15
19
  import { Text } from "@supermousejs/text";
16
-
17
20
  const app = new Supermouse();
18
-
19
- app.use(
20
- Text({
21
- offset: [20, 20], // X, Y offset from cursor
22
- duration: 200 // Fade duration
23
- })
24
- );
21
+ app.use(Text({ duration: 200 }));
25
22
  ```
26
23
 
27
- **HTML:**
24
+ ### Options
28
25
 
29
- ```html
30
- <button data-supermouse-text="Click Me">Hover Here</button>
31
- ```
26
+ | Name | Type | Default | Description |
27
+ | --- | --- | --- | --- |
28
+ | className | string | 'supermouse-text' | CSS class added to container. |
29
+ | offset | [number, number] | [0, 24] | X/Y offset from cursor. |
30
+ | duration | number | 200 | Fade transition time in ms. |
32
31
 
33
32
  ## Documentation
34
33
 
package/dist/index.mjs CHANGED
@@ -1,29 +1,29 @@
1
- import { definePlugin as f, dom as e, Easings as p, Layers as u } from "@supermousejs/utils";
1
+ import { definePlugin as l, dom as e, Easings as u, Layers as x } from "@supermousejs/utils";
2
2
  const y = (s = {}) => {
3
- const r = s.className || "supermouse-text", [c, i] = s.offset || [0, 24], l = s.duration || 200;
4
- let a;
5
- return f(
3
+ const r = s.className || "supermouse-text", [c, i] = s.offset || [0, 24], d = s.duration || 200;
4
+ let o;
5
+ return l(
6
6
  {
7
7
  name: "text",
8
8
  selector: "[data-supermouse-text]",
9
9
  create: () => {
10
10
  const t = e.createActor("div");
11
- return e.applyStyles(t, {
12
- zIndex: u.OVERLAY,
11
+ return e.css(t, {
12
+ zIndex: x.OVERLAY,
13
13
  opacity: "0",
14
- transition: `opacity ${l}ms ${p.SMOOTH}`,
14
+ transition: `opacity ${d}ms ${u.SMOOTH}`,
15
15
  whiteSpace: "nowrap",
16
16
  pointerEvents: "none"
17
- }), t.classList.add(...r.split(" ").filter(Boolean)), a = document.createElement("span"), t.appendChild(a), e.setTransform(t, -100, -100), t;
17
+ }), t.classList.add(...r.split(" ").filter(Boolean)), o = document.createElement("span"), t.appendChild(o), e.setTransform(t, -100, -100), t;
18
18
  },
19
- update: (t, o) => {
19
+ update: (t, a) => {
20
20
  const n = t.state.interaction.text;
21
21
  if (t.state.isHover && n) {
22
- a.innerText = n, e.setStyle(o, "opacity", "1");
23
- const { x: d, y: m } = t.state.smooth;
24
- e.setTransform(o, d + c, m + i);
22
+ o.innerText = n, e.css(a, { opacity: "1" });
23
+ const { x: m, y: f } = t.state.smooth;
24
+ e.setTransform(a, m + c, f + i);
25
25
  } else
26
- e.setStyle(o, "opacity", "0");
26
+ e.css(a, { opacity: "0" });
27
27
  }
28
28
  },
29
29
  s
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(o,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("@supermousejs/utils")):typeof define=="function"&&define.amd?define(["exports","@supermousejs/utils"],e):(o=typeof globalThis<"u"?globalThis:o||self,e(o.SupermouseText={},o.SupermouseUtils))})(this,(function(o,e){"use strict";const d=(s={})=>{const i=s.className||"supermouse-text",[c,m]=s.offset||[0,24],f=s.duration||200;let n;return e.definePlugin({name:"text",selector:"[data-supermouse-text]",create:()=>{const t=e.dom.createActor("div");return e.dom.applyStyles(t,{zIndex:e.Layers.OVERLAY,opacity:"0",transition:`opacity ${f}ms ${e.Easings.SMOOTH}`,whiteSpace:"nowrap",pointerEvents:"none"}),t.classList.add(...i.split(" ").filter(Boolean)),n=document.createElement("span"),t.appendChild(n),e.dom.setTransform(t,-100,-100),t},update:(t,r)=>{const a=t.state.interaction.text;if(t.state.isHover&&a){n.innerText=a,e.dom.setStyle(r,"opacity","1");const{x:u,y:p}=t.state.smooth;e.dom.setTransform(r,u+c,p+m)}else e.dom.setStyle(r,"opacity","0")}},s)};o.Text=d,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("@supermousejs/utils")):typeof define=="function"&&define.amd?define(["exports","@supermousejs/utils"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.SupermouseText={},s.SupermouseUtils))})(this,(function(s,e){"use strict";const d=(o={})=>{const i=o.className||"supermouse-text",[c,m]=o.offset||[0,24],f=o.duration||200;let n;return e.definePlugin({name:"text",selector:"[data-supermouse-text]",create:()=>{const t=e.dom.createActor("div");return e.dom.css(t,{zIndex:e.Layers.OVERLAY,opacity:"0",transition:`opacity ${f}ms ${e.Easings.SMOOTH}`,whiteSpace:"nowrap",pointerEvents:"none"}),t.classList.add(...i.split(" ").filter(Boolean)),n=document.createElement("span"),t.appendChild(n),e.dom.setTransform(t,-100,-100),t},update:(t,r)=>{const a=t.state.interaction.text;if(t.state.isHover&&a){n.innerText=a,e.dom.css(r,{opacity:"1"});const{x:u,y:p}=t.state.smooth;e.dom.setTransform(r,u+c,p+m)}else e.dom.css(r,{opacity:"0"})}},o)};s.Text=d,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,20 +1,25 @@
1
1
  {
2
2
  "name": "@supermousejs/text",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "author": "O.S David",
5
5
  "url": "https://github.com/Whitestar14/supermouse-js",
6
+ "description": "Injects contextual text bubbles near the cursor on interaction. Works like a tooltip.",
6
7
  "license": "MIT",
7
8
  "dependencies": {
8
- "@supermousejs/utils": "2.3.0"
9
+ "@supermousejs/utils": "2.4.0"
9
10
  },
10
11
  "main": "dist/index.umd.js",
11
12
  "module": "dist/index.mjs",
12
13
  "types": "dist/index.d.ts",
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
13
18
  "peerDependencies": {
14
- "@supermousejs/core": "2.2.0"
19
+ "@supermousejs/core": "2.4.0"
15
20
  },
16
21
  "devDependencies": {
17
- "@supermousejs/core": "2.2.0"
22
+ "@supermousejs/core": "2.4.0"
18
23
  },
19
24
  "repository": {
20
25
  "type": "git",
package/CHANGELOG.md DELETED
@@ -1,90 +0,0 @@
1
- # @supermousejs/text
2
-
3
- ## 2.3.0
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [f6f44b2]
8
- - @supermousejs/core@2.2.0
9
- - @supermousejs/utils@2.3.0
10
-
11
- ## 2.2.0
12
-
13
- ### Patch Changes
14
-
15
- - 6d70c18: remove legacy package and update supermouse domain in readme
16
- - 14fb5b6: Updated tsconfig to be reference-compliant with core, utils and zoetrope when required
17
- - Updated dependencies [6d70c18]
18
- - Updated dependencies [2590af3]
19
- - Updated dependencies [14fb5b6]
20
- - Updated dependencies [9fe1a7b]
21
- - Updated dependencies [9fa6ece]
22
- - @supermousejs/core@2.1.0
23
- - @supermousejs/utils@2.2.0
24
-
25
- ## 2.1.1
26
-
27
- ### Patch Changes
28
-
29
- - 67f771b: Add relevant npm metadata to package.json file
30
- - Updated dependencies [67f771b]
31
- - @supermousejs/utils@2.1.1
32
- - @supermousejs/core@2.0.5
33
-
34
- ## 2.1.0
35
-
36
- ### Minor Changes
37
-
38
- - 0a1652d: fixed build architecture and updated plugin metadata
39
-
40
- ### Patch Changes
41
-
42
- - Updated dependencies [0a1652d]
43
- - @supermousejs/utils@2.1.0
44
-
45
- ## 2.0.4
46
-
47
- ### Patch Changes
48
-
49
- - 993dc67: Updated supemousejs packages with proper author, license and url descriptors to repo
50
- - Updated dependencies [993dc67]
51
- - @supermousejs/utils@2.0.4
52
- - @supermousejs/core@2.0.4
53
-
54
- ## 2.0.3
55
-
56
- ### Patch Changes
57
-
58
- - Updated dependencies
59
- - @supermousejs/core@2.0.3
60
- - @supermousejs/utils@2.0.3
61
-
62
- ## 2.0.2
63
-
64
- ### Patch Changes
65
-
66
- - ae219a0: Update READMEs with correct link to documentation
67
- - Updated dependencies [ae219a0]
68
- - @supermousejs/utils@2.0.2
69
- - @supermousejs/core@2.0.2
70
-
71
- ## 2.0.1
72
-
73
- ### Patch Changes
74
-
75
- - Add minimal README.md files to packages
76
- - Updated dependencies
77
- - @supermousejs/utils@2.0.1
78
- - @supermousejs/core@2.0.1
79
-
80
- ## 2.0.0
81
-
82
- ### Major Changes
83
-
84
- - Initial v2.0.0 release
85
-
86
- ### Patch Changes
87
-
88
- - Updated dependencies
89
- - @supermousejs/utils@2.0.0
90
- - @supermousejs/core@2.0.0
package/meta.json DELETED
@@ -1,32 +0,0 @@
1
- {
2
- "id": "text",
3
- "name": "Text",
4
- "package": "@supermousejs/text",
5
- "description": "Injects contextual text bubbles near the cursor on interaction.",
6
- "code": "app.use(Text({ font: 'Mono' }));",
7
- "recipeId": "text-cursor",
8
- "icon": "text",
9
- "options": [
10
- {
11
- "name": "className",
12
- "type": "string",
13
- "default": "'supermouse-text'",
14
- "description": "CSS class added to container.",
15
- "reactive": false
16
- },
17
- {
18
- "name": "offset",
19
- "type": "[number, number]",
20
- "default": "[0, 24]",
21
- "description": "X/Y offset from cursor.",
22
- "reactive": false
23
- },
24
- {
25
- "name": "duration",
26
- "type": "number",
27
- "default": "200",
28
- "description": "Fade transition time in ms.",
29
- "reactive": false
30
- }
31
- ]
32
- }
package/src/index.ts DELETED
@@ -1,62 +0,0 @@
1
- import type { Supermouse } from "@supermousejs/core";
2
- import { definePlugin, dom, Layers, Easings } from "@supermousejs/utils";
3
-
4
- export interface TextOptions {
5
- name?: string;
6
- isEnabled?: boolean;
7
- className?: string;
8
- offset?: [number, number];
9
- duration?: number;
10
- }
11
-
12
- export const Text = (options: TextOptions = {}) => {
13
- const className = options.className || "supermouse-text";
14
- const [offX, offY] = options.offset || [0, 24];
15
- const duration = options.duration || 200;
16
-
17
- let textNode: HTMLSpanElement;
18
-
19
- return definePlugin<HTMLDivElement, TextOptions>(
20
- {
21
- name: "text",
22
- selector: "[data-supermouse-text]",
23
-
24
- create: () => {
25
- const el = dom.createActor("div") as HTMLDivElement;
26
-
27
- dom.applyStyles(el, {
28
- zIndex: Layers.OVERLAY,
29
- opacity: "0",
30
- transition: `opacity ${duration}ms ${Easings.SMOOTH}`,
31
- whiteSpace: "nowrap",
32
- pointerEvents: "none"
33
- });
34
-
35
- if (className) {
36
- el.classList.add(...className.split(" ").filter(Boolean));
37
- }
38
-
39
- textNode = document.createElement("span");
40
- el.appendChild(textNode);
41
-
42
- dom.setTransform(el, -100, -100);
43
- return el;
44
- },
45
-
46
- update: (app: Supermouse, el: HTMLDivElement) => {
47
- const text = app.state.interaction.text;
48
-
49
- if (app.state.isHover && text) {
50
- textNode.innerText = text;
51
- dom.setStyle(el, "opacity", "1");
52
-
53
- const { x, y } = app.state.smooth;
54
- dom.setTransform(el, x + offX, y + offY);
55
- } else {
56
- dom.setStyle(el, "opacity", "0");
57
- }
58
- }
59
- },
60
- options
61
- );
62
- };
package/tsconfig.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.plugin.json",
3
- "include": ["src"]
4
- }
package/vite.config.ts DELETED
@@ -1,23 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import dts from "vite-plugin-dts";
3
- import path from "path";
4
-
5
- export default defineConfig({
6
- build: {
7
- lib: {
8
- entry: path.resolve(__dirname, "src/index.ts"),
9
- name: "SupermouseText",
10
- fileName: (format) => (format === "es" ? "index.mjs" : "index.umd.js")
11
- },
12
- rollupOptions: {
13
- external: ["@supermousejs/core", "@supermousejs/utils"],
14
- output: {
15
- globals: {
16
- "@supermousejs/core": "SupermouseCore",
17
- "@supermousejs/utils": "SupermouseUtils"
18
- }
19
- }
20
- }
21
- },
22
- plugins: [dts({ rollupTypes: true })]
23
- });