@supermousejs/ring 2.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @supermousejs/ring
2
+
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Initial v2.0.0 release
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @supermousejs/utils@2.0.0
13
+ - @supermousejs/core@2.0.0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sijibomi Olusunmbola
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,16 @@
1
+ import { SupermousePlugin } from '../../core/src/index.ts';
2
+ import { ValueOrGetter } from '../../core/src/index.ts';
3
+
4
+ export declare const Ring: (options?: RingOptions) => SupermousePlugin;
5
+
6
+ export declare interface RingOptions {
7
+ name?: string;
8
+ isEnabled?: boolean;
9
+ size?: ValueOrGetter<number>;
10
+ color?: ValueOrGetter<string>;
11
+ borderWidth?: ValueOrGetter<number>;
12
+ opacity?: ValueOrGetter<number>;
13
+ mixBlendMode?: string;
14
+ }
15
+
16
+ export { }
package/dist/index.mjs ADDED
@@ -0,0 +1,28 @@
1
+ import { normalize as s, definePlugin as m, dom as r, Layers as S } from "@supermousejs/utils";
2
+ const x = (o = {}) => {
3
+ const i = s(o.size, 20), c = s(o.color, "#ffffff"), d = s(o.borderWidth, 2), l = s(o.opacity, 1);
4
+ return m({
5
+ name: o.name || "ring",
6
+ selector: "[data-supermouse-color]",
7
+ create: (t) => {
8
+ const e = r.createCircle(i(t.state), "transparent");
9
+ return r.applyStyles(e, {
10
+ zIndex: S.FOLLOWER,
11
+ mixBlendMode: o.mixBlendMode || "difference",
12
+ borderStyle: "solid",
13
+ transition: "opacity 0.2s ease",
14
+ boxSizing: "border-box"
15
+ }), e;
16
+ },
17
+ update: (t, e) => {
18
+ const n = i(t.state);
19
+ let a = c(t.state);
20
+ t.state.interaction.color && (a = t.state.interaction.color), r.setStyle(e, "width", `${n}px`), r.setStyle(e, "height", `${n}px`), r.setStyle(e, "borderRadius", "50%"), r.setStyle(e, "borderColor", a), r.setStyle(e, "borderWidth", `${d(t.state)}px`), r.setStyle(e, "opacity", String(l(t.state)));
21
+ const { x: y, y: f } = t.state.smooth;
22
+ r.setTransform(e, y, f);
23
+ }
24
+ }, o);
25
+ };
26
+ export {
27
+ x as Ring
28
+ };
@@ -0,0 +1 @@
1
+ (function(r,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("@supermousejs/utils")):typeof define=="function"&&define.amd?define(["exports","@supermousejs/utils"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r.SupermouseRing={},r.SupermouseUtils))})(this,(function(r,e){"use strict";const c=(n={})=>{const d=e.normalize(n.size,20),a=e.normalize(n.color,"#ffffff"),m=e.normalize(n.borderWidth,2),f=e.normalize(n.opacity,1);return e.definePlugin({name:n.name||"ring",selector:"[data-supermouse-color]",create:o=>{const t=e.dom.createCircle(d(o.state),"transparent");return e.dom.applyStyles(t,{zIndex:e.Layers.FOLLOWER,mixBlendMode:n.mixBlendMode||"difference",borderStyle:"solid",transition:"opacity 0.2s ease",boxSizing:"border-box"}),t},update:(o,t)=>{const s=d(o.state);let i=a(o.state);o.state.interaction.color&&(i=o.state.interaction.color),e.dom.setStyle(t,"width",`${s}px`),e.dom.setStyle(t,"height",`${s}px`),e.dom.setStyle(t,"borderRadius","50%"),e.dom.setStyle(t,"borderColor",i),e.dom.setStyle(t,"borderWidth",`${m(o.state)}px`),e.dom.setStyle(t,"opacity",String(f(o.state)));const{x:y,y:S}=o.state.smooth;e.dom.setTransform(t,y,S)}},n)};r.Ring=c,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
package/meta.json ADDED
@@ -0,0 +1,17 @@
1
+
2
+ {
3
+ "id": "ring",
4
+ "name": "Ring",
5
+ "package": "@supermousejs/ring",
6
+ "description": "Adds a lagging outer ring. Simple and performant.",
7
+ "code": "app.use(Ring({ size: 32, color: '#000' }));",
8
+ "recipeId": "magnetic-button",
9
+ "icon": "ring",
10
+ "options": [
11
+ { "name": "size", "type": "number", "default": "20", "description": "Diameter of the ring in pixels.", "reactive": true },
12
+ { "name": "color", "type": "string", "default": "'#ffffff'", "description": "Border color.", "reactive": true },
13
+ { "name": "borderWidth", "type": "number", "default": "2", "description": "Stroke width in pixels.", "reactive": true },
14
+ { "name": "opacity", "type": "number", "default": "1", "description": "Opacity level (0-1).", "reactive": true },
15
+ { "name": "mixBlendMode", "type": "string", "default": "'difference'", "description": "CSS blend mode.", "reactive": false }
16
+ ]
17
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@supermousejs/ring",
3
+ "version": "2.0.0",
4
+ "main": "dist/index.umd.js",
5
+ "module": "dist/index.mjs",
6
+ "types": "dist/index.d.ts",
7
+ "dependencies": {
8
+ "@supermousejs/core": "2.0.0",
9
+ "@supermousejs/utils": "2.0.0"
10
+ },
11
+ "devDependencies": {},
12
+ "peerDependencies": {},
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.mjs",
17
+ "require": "./dist/index.umd.js"
18
+ }
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "scripts": {
24
+ "build": "vite build"
25
+ }
26
+ }
package/src/index.ts ADDED
@@ -0,0 +1,56 @@
1
+ import type { ValueOrGetter } from '@supermousejs/core';
2
+ import { definePlugin, normalize, dom, Layers } from '@supermousejs/utils';
3
+
4
+ export interface RingOptions {
5
+ name?: string;
6
+ isEnabled?: boolean;
7
+ size?: ValueOrGetter<number>;
8
+ color?: ValueOrGetter<string>;
9
+ borderWidth?: ValueOrGetter<number>;
10
+ opacity?: ValueOrGetter<number>;
11
+ mixBlendMode?: string;
12
+ }
13
+
14
+ export const Ring = (options: RingOptions = {}) => {
15
+ const getSize = normalize(options.size, 20);
16
+ const getColor = normalize(options.color, '#ffffff');
17
+ const getBorder = normalize(options.borderWidth, 2);
18
+ const getOpacity = normalize(options.opacity, 1);
19
+
20
+ return definePlugin<HTMLDivElement, RingOptions>({
21
+ name: options.name || 'ring',
22
+ selector: '[data-supermouse-color]',
23
+
24
+ create: (app) => {
25
+ const el = dom.createCircle(getSize(app.state), 'transparent');
26
+ dom.applyStyles(el, {
27
+ zIndex: Layers.FOLLOWER,
28
+ mixBlendMode: options.mixBlendMode || 'difference',
29
+ borderStyle: 'solid',
30
+ transition: 'opacity 0.2s ease',
31
+ boxSizing: 'border-box'
32
+ });
33
+ return el;
34
+ },
35
+
36
+ update: (app, el) => {
37
+ const size = getSize(app.state);
38
+ let color = getColor(app.state);
39
+
40
+ // Basic interaction override for color only
41
+ if (app.state.interaction.color) {
42
+ color = app.state.interaction.color;
43
+ }
44
+
45
+ dom.setStyle(el, 'width', `${size}px`);
46
+ dom.setStyle(el, 'height', `${size}px`);
47
+ dom.setStyle(el, 'borderRadius', '50%');
48
+ dom.setStyle(el, 'borderColor', color);
49
+ dom.setStyle(el, 'borderWidth', `${getBorder(app.state)}px`);
50
+ dom.setStyle(el, 'opacity', String(getOpacity(app.state)));
51
+
52
+ const { x, y } = app.state.smooth;
53
+ dom.setTransform(el, x, y);
54
+ }
55
+ }, options);
56
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": [
4
+ "src"
5
+ ],
6
+ "compilerOptions": {
7
+ "outDir": "dist",
8
+ "baseUrl": ".",
9
+ "paths": {
10
+ "@supermousejs/core": [
11
+ "../core/src/index.ts"
12
+ ],
13
+ "@supermousejs/utils": [
14
+ "../utils/src/index.ts"
15
+ ]
16
+ }
17
+ }
18
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,22 @@
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: 'SupermouseRing',
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
+ plugins: [dts({ rollupTypes: true })]
22
+ });