react-circular-range 1.0.94 → 1.0.97
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/CircularRange.d.ts +13 -0
- package/dist/index.d.ts +1 -15
- package/dist/index.js +2 -2
- package/dist/index.js.LICENSE.txt +9 -0
- package/dist/styles.css +103 -0
- package/package.json +16 -7
- package/dist/index.d.mts +0 -15
- package/dist/index.mjs +0 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type StyleSlots = 'knob' | 'knobRing' | 'knobBackground' | 'knobBackgroundPath' | 'knobIndicator' | 'knobCenter' | 'active';
|
|
3
|
+
export type CircularRangeThemeProps = Partial<Record<StyleSlots, string>>;
|
|
4
|
+
export interface CircularRangeProps {
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
value?: number;
|
|
8
|
+
step?: number;
|
|
9
|
+
onChange?: (value: number) => void;
|
|
10
|
+
theme?: CircularRangeThemeProps;
|
|
11
|
+
}
|
|
12
|
+
export declare const CircularRange: React.FC<CircularRangeProps>;
|
|
13
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type StyleSlots = 'knob' | 'knobRing' | 'knobBackground' | 'knobBackgroundPath' | 'knobIndicator' | 'knobCenter' | 'active';
|
|
4
|
-
type CircularRangeThemeProps = Partial<Record<StyleSlots, string>>;
|
|
5
|
-
interface CircularRangeProps {
|
|
6
|
-
min?: number;
|
|
7
|
-
max?: number;
|
|
8
|
-
value?: number;
|
|
9
|
-
step?: number;
|
|
10
|
-
onChange?: (value: number) => void;
|
|
11
|
-
theme?: CircularRangeThemeProps;
|
|
12
|
-
}
|
|
13
|
-
declare const CircularRange: React.FC<CircularRangeProps>;
|
|
14
|
-
|
|
15
|
-
export { CircularRange, type CircularRangeProps, type CircularRangeThemeProps, type StyleSlots };
|
|
1
|
+
export * from './CircularRange';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
+
import{useCallback as e,useEffect as t,useRef as n,useState as r}from"react";var o={698(e,t){var n=Symbol.for("react.transitional.element");function r(e,t,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==t.key&&(o=""+t.key),"key"in t)for(var a in r={},t)"key"!==a&&(r[a]=t[a]);else r=t;return t=r.ref,{$$typeof:n,type:e,key:o,ref:void 0!==t?t:null,props:r}}Symbol.for("react.fragment"),t.jsx=r,t.jsxs=r},848(e,t,n){e.exports=n(698)}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return o[e](n,n.exports,s),n.exports}s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};s.r(c),s.d(c,{active:()=>i,knob:()=>d,knobBackground:()=>l,knobBackgroundPath:()=>m,knobCenter:()=>v,knobIndicator:()=>k,knobRing:()=>b});var u=s(848),i="CircularRange-module__active--BqXnY",d="CircularRange-module__knob--BAUKG",l="CircularRange-module__knobBackground--qxu1s",m="CircularRange-module__knobBackgroundPath--rxKDz",v="CircularRange-module__knobCenter--UIeoG",k="CircularRange-module__knobIndicator--lJKRO",b="CircularRange-module__knobRing--F6qGP";const f=113.1,g=({min:o=0,max:a=100,value:s=0,step:i=.01,onChange:d,theme:l=c})=>{const m=n(null),[v,k]=r(s),[b,g]=r(!1),h=n(0),p=n(0);t(()=>{k(s)},[s]);const y=e(e=>(e-o)/(a-o),[o,a]),x=e(e=>{let t=(e=>Math.min(a,Math.max(o,e)))(e);i>0&&(t=Math.round(t/i)*i),k(t),d?.(t)},[o,a,i,d]),_=e=>{e.preventDefault(),g(!0);const t="touches"in e?e.touches[0].clientY:e.clientY;h.current=t,p.current=v},E=e=>{if(!b)return;e.preventDefault();const t="touches"in e?e.touches[0].clientY:e.clientY,n=.01*(h.current-t)*(a-o);x(p.current+n)},L=()=>{g(!1)},j=()=>{x((o+a)/2)};t(()=>{const e=m.current;if(e)return e.addEventListener("mousedown",_),e.addEventListener("touchstart",_),document.addEventListener("mousemove",E),document.addEventListener("touchmove",E),document.addEventListener("mouseup",L),document.addEventListener("touchend",L),e.addEventListener("dblclick",j),()=>{e.removeEventListener("mousedown",_),e.removeEventListener("touchstart",_),document.removeEventListener("mousemove",E),document.removeEventListener("touchmove",E),document.removeEventListener("mouseup",L),document.removeEventListener("touchend",L),e.removeEventListener("dblclick",j)}},[E,b]);const C=y(v),R=270*C-135,$=f-C*f;return(0,u.jsx)("div",{ref:m,className:`${l.knob} ${b?l.active:""}`,children:(0,u.jsxs)("div",{className:`${l.knobRing}`,children:[(0,u.jsx)("svg",{className:`${l.knobBackground}`,viewBox:"0 0 60 60",children:(0,u.jsx)("path",{className:`${l.knobBackgroundPath}`,d:"M 30 6 A 24 24 0 1 1 6 30",strokeDasharray:f,strokeDashoffset:$})}),(0,u.jsx)("div",{className:`${l.knobIndicator}`,style:{transform:`translateX(-50%) rotate(${R}deg)`}}),(0,u.jsx)("div",{className:`${l.knobCenter}`})]})})};export{g as CircularRange};
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
.CircularRange-module__knob--BAUKG {
|
|
2
|
+
width: 65px;
|
|
3
|
+
height: 65px;
|
|
4
|
+
position: relative;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
user-select: none;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.CircularRange-module__knobRing--F6qGP {
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
border: 3px solid #333;
|
|
13
|
+
border-radius: 50%;
|
|
14
|
+
background: linear-gradient(145deg, #1a1a1a, #252525);
|
|
15
|
+
box-shadow:
|
|
16
|
+
inset 2px 2px 5px rgba(0, 0, 0, 0.5),
|
|
17
|
+
inset -2px -2px 5px rgba(60, 60, 60, 0.1),
|
|
18
|
+
0 4px 8px rgba(0, 0, 0, 0.3);
|
|
19
|
+
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.CircularRange-module__knobBackground--qxu1s {
|
|
23
|
+
position: absolute;
|
|
24
|
+
top: 0;
|
|
25
|
+
left: 0;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
transform: rotate(-135deg);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.CircularRange-module__knobBackgroundPath--rxKDz {
|
|
33
|
+
fill: none;
|
|
34
|
+
stroke: #8b5cf6;
|
|
35
|
+
stroke-width: 3.5;
|
|
36
|
+
stroke-linecap: round;
|
|
37
|
+
stroke-dasharray: 113.1;
|
|
38
|
+
stroke-dashoffset: 113.1;
|
|
39
|
+
transition: stroke-dashoffset 0.1s ease-out;
|
|
40
|
+
filter: drop-shadow(0 0 3px rgba(139, 92, 246, 0.7));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.CircularRange-module__knobIndicator--lJKRO {
|
|
44
|
+
position: absolute;
|
|
45
|
+
width: 4px;
|
|
46
|
+
height: 20px;
|
|
47
|
+
background: linear-gradient(to bottom, #8b5cf6, #c084fc);
|
|
48
|
+
top: 5px;
|
|
49
|
+
left: 50%;
|
|
50
|
+
transform-origin: center 27.5px;
|
|
51
|
+
transform: translateX(-50%) rotate(-135deg);
|
|
52
|
+
border-radius: 2px;
|
|
53
|
+
z-index: 2;
|
|
54
|
+
/*transition: transform 0.05s ease-out;*/
|
|
55
|
+
box-shadow: 0 0 6px rgba(139, 92, 246, 0.8);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.CircularRange-module__knobCenter--UIeoG {
|
|
59
|
+
position: absolute;
|
|
60
|
+
width: 18px;
|
|
61
|
+
height: 18px;
|
|
62
|
+
background: radial-gradient(circle, #0a0a0a, #1a1a1a);
|
|
63
|
+
border-radius: 50%;
|
|
64
|
+
top: 50%;
|
|
65
|
+
left: 50%;
|
|
66
|
+
transform: translate(-50%, -50%);
|
|
67
|
+
box-shadow:
|
|
68
|
+
inset 1px 1px 3px rgba(0, 0, 0, 0.7),
|
|
69
|
+
0 1px 2px rgba(139, 92, 246, 0.3);
|
|
70
|
+
z-index: 3;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Hover states */
|
|
74
|
+
.CircularRange-module__knob--BAUKG:hover .CircularRange-module__knobRing--F6qGP {
|
|
75
|
+
border-color: #8b5cf6;
|
|
76
|
+
box-shadow:
|
|
77
|
+
inset 2px 2px 5px rgba(0, 0, 0, 0.5),
|
|
78
|
+
inset -2px -2px 5px rgba(60, 60, 60, 0.1),
|
|
79
|
+
0 4px 12px rgba(139, 92, 246, 0.4);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.CircularRange-module__knob--BAUKG:hover .CircularRange-module__knobIndicator--lJKRO {
|
|
83
|
+
background: linear-gradient(to bottom, #a78bfa, #c084fc);
|
|
84
|
+
box-shadow: 0 0 8px rgba(167, 139, 250, 0.9);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.CircularRange-module__knob--BAUKG.CircularRange-module__active--BqXnY .CircularRange-module__knobRing--F6qGP {
|
|
88
|
+
border-color: #a78bfa;
|
|
89
|
+
box-shadow:
|
|
90
|
+
inset 2px 2px 5px rgba(0, 0, 0, 0.6),
|
|
91
|
+
inset -2px -2px 5px rgba(60, 60, 60, 0.15),
|
|
92
|
+
0 4px 16px rgba(167, 139, 250, 0.5);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.CircularRange-module__knob--BAUKG.CircularRange-module__active--BqXnY .CircularRange-module__knobIndicator--lJKRO {
|
|
96
|
+
background: linear-gradient(to bottom, #a78bfa, #c084fc);
|
|
97
|
+
box-shadow: 0 0 10px rgba(167, 139, 250, 1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.CircularRange-module__knob--BAUKG.CircularRange-module__active--BqXnY .CircularRange-module__knobBackgroundPath--rxKDz {
|
|
101
|
+
stroke: #a78bfa;
|
|
102
|
+
filter: drop-shadow(0 0 4px rgba(167, 139, 250, 0.9));
|
|
103
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-circular-range",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.97",
|
|
4
4
|
"description": "Simple VST-like circular slider/range.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"sideEffects": [
|
|
9
|
+
"*.css",
|
|
10
|
+
"*.module.css"
|
|
11
|
+
],
|
|
8
12
|
"files": [
|
|
9
13
|
"dist"
|
|
10
14
|
],
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
13
17
|
"types": "./dist/index.d.ts",
|
|
14
|
-
"import": "./dist/index.
|
|
18
|
+
"import": "./dist/index.js",
|
|
15
19
|
"require": "./dist/index.js"
|
|
16
20
|
}
|
|
17
21
|
},
|
|
18
22
|
"scripts": {
|
|
19
|
-
"build": "
|
|
23
|
+
"build": "webpack"
|
|
20
24
|
},
|
|
21
25
|
"repository": {
|
|
22
26
|
"type": "git",
|
|
@@ -44,7 +48,12 @@
|
|
|
44
48
|
"devDependencies": {
|
|
45
49
|
"@types/react": "^19.2.7",
|
|
46
50
|
"@types/react-dom": "^19.2.3",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
51
|
+
"css-loader": "^7.1.2",
|
|
52
|
+
"mini-css-extract-plugin": "^2.9.4",
|
|
53
|
+
"style-loader": "^4.0.0",
|
|
54
|
+
"ts-loader": "^9.5.4",
|
|
55
|
+
"typescript": "^5.9.3",
|
|
56
|
+
"webpack": "^5.104.1",
|
|
57
|
+
"webpack-cli": "^6.0.1"
|
|
49
58
|
}
|
|
50
|
-
}
|
|
59
|
+
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
type StyleSlots = 'knob' | 'knobRing' | 'knobBackground' | 'knobBackgroundPath' | 'knobIndicator' | 'knobCenter' | 'active';
|
|
4
|
-
type CircularRangeThemeProps = Partial<Record<StyleSlots, string>>;
|
|
5
|
-
interface CircularRangeProps {
|
|
6
|
-
min?: number;
|
|
7
|
-
max?: number;
|
|
8
|
-
value?: number;
|
|
9
|
-
step?: number;
|
|
10
|
-
onChange?: (value: number) => void;
|
|
11
|
-
theme?: CircularRangeThemeProps;
|
|
12
|
-
}
|
|
13
|
-
declare const CircularRange: React.FC<CircularRangeProps>;
|
|
14
|
-
|
|
15
|
-
export { CircularRange, type CircularRangeProps, type CircularRangeThemeProps, type StyleSlots };
|
package/dist/index.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{useCallback as R,useEffect as B,useRef as b,useState as N}from"react";var L={};function p(o,{insertAt:r}={}){if(!o||typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",r==="top"&&n.firstChild?n.insertBefore(t,n.firstChild):n.appendChild(t),t.styleSheet?t.styleSheet.cssText=o:t.appendChild(document.createTextNode(o))}p(`.knob{width:65px;height:65px;position:relative;cursor:pointer;user-select:none}.knobRing{width:100%;height:100%;border:3px solid #333;border-radius:50%;background:linear-gradient(145deg,#1a1a1a,#252525);box-shadow:inset 2px 2px 5px #00000080,inset -2px -2px 5px #3c3c3c1a,0 4px 8px #0000004d;transition:border-color .2s ease,box-shadow .2s ease}.knobBackground{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;transform:rotate(-135deg)}.knobBackgroundPath{fill:none;stroke:#8b5cf6;stroke-width:3.5;stroke-linecap:round;stroke-dasharray:113.1;stroke-dashoffset:113.1;transition:stroke-dashoffset .1s ease-out;filter:drop-shadow(0 0 3px rgba(139,92,246,.7))}.knobIndicator{position:absolute;width:4px;height:20px;background:linear-gradient(to bottom,#8b5cf6,#c084fc);top:5px;left:50%;transform-origin:center 27.5px;transform:translate(-50%) rotate(-135deg);border-radius:2px;z-index:2;box-shadow:0 0 6px #8b5cf6cc}.knobCenter{position:absolute;width:18px;height:18px;background:radial-gradient(circle,#0a0a0a,#1a1a1a);border-radius:50%;top:50%;left:50%;transform:translate(-50%,-50%);box-shadow:inset 1px 1px 3px #000000b3,0 1px 2px #8b5cf64d;z-index:3}.knob:hover .knobRing{border-color:#8b5cf6;box-shadow:inset 2px 2px 5px #00000080,inset -2px -2px 5px #3c3c3c1a,0 4px 12px #8b5cf666}.knob:hover .knobIndicator{background:linear-gradient(to bottom,#a78bfa,#c084fc);box-shadow:0 0 8px #a78bfae6}.knob.active .knobRing{border-color:#a78bfa;box-shadow:inset 2px 2px 5px #0009,inset -2px -2px 5px #3c3c3c26,0 4px 16px #a78bfa80}.knob.active .knobIndicator{background:linear-gradient(to bottom,#a78bfa,#c084fc);box-shadow:0 0 10px #a78bfa}.knob.active .knobBackgroundPath{stroke:#a78bfa;filter:drop-shadow(0 0 4px rgba(167,139,250,.9))}
|
|
2
|
-
`);import{jsx as i,jsxs as $}from"react/jsx-runtime";var h=113.1,j=({min:o=0,max:r=100,value:n=0,step:t=.01,onChange:f,theme:s=L})=>{let x=b(null),[m,v]=N(n),[u,k]=N(!1),g=b(0),E=b(0),I=.01;B(()=>{v(n)},[n]);let P=e=>Math.min(r,Math.max(o,e)),T=R(e=>(e-o)/(r-o),[o,r]),w=R(e=>{let a=P(e);t>0&&(a=Math.round(a/t)*t),v(a),f?.(a)},[o,r,t,f]),d=e=>{e.preventDefault(),k(!0);let a="touches"in e?e.touches[0].clientY:e.clientY;g.current=a,E.current=m},c=e=>{if(!u)return;e.preventDefault();let a="touches"in e?e.touches[0].clientY:e.clientY,S=(g.current-a)*I*(r-o);w(E.current+S)},l=()=>{k(!1)},y=()=>{w((o+r)/2)};B(()=>{let e=x.current;if(e)return e.addEventListener("mousedown",d),e.addEventListener("touchstart",d),document.addEventListener("mousemove",c),document.addEventListener("touchmove",c),document.addEventListener("mouseup",l),document.addEventListener("touchend",l),e.addEventListener("dblclick",y),()=>{e.removeEventListener("mousedown",d),e.removeEventListener("touchstart",d),document.removeEventListener("mousemove",c),document.removeEventListener("touchmove",c),document.removeEventListener("mouseup",l),document.removeEventListener("touchend",l),e.removeEventListener("dblclick",y)}},[c,u]);let C=T(m),Y=C*270-135,M=h-C*h;return i("div",{ref:x,className:`${s.knob} ${u?s.active:""}`,children:$("div",{className:`${s.knobRing}`,children:[i("svg",{className:`${s.knobBackground}`,viewBox:"0 0 60 60",children:i("path",{className:`${s.knobBackgroundPath}`,d:"M 30 6 A 24 24 0 1 1 6 30",strokeDasharray:h,strokeDashoffset:M})}),i("div",{className:`${s.knobIndicator}`,style:{transform:`translateX(-50%) rotate(${Y}deg)`}}),i("div",{className:`${s.knobCenter}`})]})})};export{j as CircularRange};
|