react-color-palette-wheel 0.0.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/README.md +73 -0
- package/dist/components/ColorWheel.d.ts +3 -0
- package/dist/components/ColorWheelCursor.d.ts +13 -0
- package/dist/hooks/usePointerHandlers.d.ts +15 -0
- package/dist/index.d.ts +3 -0
- package/dist/react-color-palette-wheel.es.js +652 -0
- package/dist/react-color-palette-wheel.umd.js +6 -0
- package/dist/types/colorWheel.d.ts +53 -0
- package/dist/utils/calculateCursorPosition.d.ts +4 -0
- package/dist/utils/calculateHarmonyPositions.d.ts +5 -0
- package/dist/utils/calculateXy.d.ts +4 -0
- package/dist/utils/constrainToRadius.d.ts +4 -0
- package/dist/utils/drawColorWheel.d.ts +1 -0
- package/dist/utils/findClosestCursor.d.ts +2 -0
- package/dist/utils/handleCursorMove.d.ts +15 -0
- package/dist/vite.svg +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
13
|
+
|
|
14
|
+
## Expanding the ESLint configuration
|
|
15
|
+
|
|
16
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default defineConfig([
|
|
20
|
+
globalIgnores(['dist']),
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.{ts,tsx}'],
|
|
23
|
+
extends: [
|
|
24
|
+
// Other configs...
|
|
25
|
+
|
|
26
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
27
|
+
tseslint.configs.recommendedTypeChecked,
|
|
28
|
+
// Alternatively, use this for stricter rules
|
|
29
|
+
tseslint.configs.strictTypeChecked,
|
|
30
|
+
// Optionally, add this for stylistic rules
|
|
31
|
+
tseslint.configs.stylisticTypeChecked,
|
|
32
|
+
|
|
33
|
+
// Other configs...
|
|
34
|
+
],
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parserOptions: {
|
|
37
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
38
|
+
tsconfigRootDir: import.meta.dirname,
|
|
39
|
+
},
|
|
40
|
+
// other options...
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// eslint.config.js
|
|
50
|
+
import reactX from 'eslint-plugin-react-x'
|
|
51
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
52
|
+
|
|
53
|
+
export default defineConfig([
|
|
54
|
+
globalIgnores(['dist']),
|
|
55
|
+
{
|
|
56
|
+
files: ['**/*.{ts,tsx}'],
|
|
57
|
+
extends: [
|
|
58
|
+
// Other configs...
|
|
59
|
+
// Enable lint rules for React
|
|
60
|
+
reactX.configs['recommended-typescript'],
|
|
61
|
+
// Enable lint rules for React DOM
|
|
62
|
+
reactDom.configs.recommended,
|
|
63
|
+
],
|
|
64
|
+
languageOptions: {
|
|
65
|
+
parserOptions: {
|
|
66
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
67
|
+
tsconfigRootDir: import.meta.dirname,
|
|
68
|
+
},
|
|
69
|
+
// other options...
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
])
|
|
73
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface ColorWheelCursorProps {
|
|
3
|
+
hexColor: string;
|
|
4
|
+
cursorPos: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
onPointerDown: (e: React.PointerEvent) => void;
|
|
9
|
+
onPointerMove: (e: React.PointerEvent) => void;
|
|
10
|
+
onPointerUp: (e: React.PointerEvent) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const ColorWheelCursor: React.FC<ColorWheelCursorProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { CursorData } from '../types/colorWheel';
|
|
3
|
+
interface UsePointerHandlersParams {
|
|
4
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
5
|
+
cursorProps: CursorData[];
|
|
6
|
+
radius: number;
|
|
7
|
+
handleDirectCursorMove: (clientX: number, clientY: number, indexToUpdate: number) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const usePointerHandlers: ({ containerRef, cursorProps, radius, handleDirectCursorMove, }: UsePointerHandlersParams) => {
|
|
10
|
+
activeCursorIndex: number | null;
|
|
11
|
+
onPointerDown: (e: React.PointerEvent) => void;
|
|
12
|
+
onPointerMove: (e: React.PointerEvent) => void;
|
|
13
|
+
onPointerUp: (e: React.PointerEvent) => void;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
import Se, { useState as Re, useRef as Q, useCallback as K, useEffect as le } from "react";
|
|
2
|
+
var X = { exports: {} }, $ = {};
|
|
3
|
+
var ue;
|
|
4
|
+
function Ce() {
|
|
5
|
+
if (ue) return $;
|
|
6
|
+
ue = 1;
|
|
7
|
+
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
+
function r(o, a, s) {
|
|
9
|
+
var i = null;
|
|
10
|
+
if (s !== void 0 && (i = "" + s), a.key !== void 0 && (i = "" + a.key), "key" in a) {
|
|
11
|
+
s = {};
|
|
12
|
+
for (var d in a)
|
|
13
|
+
d !== "key" && (s[d] = a[d]);
|
|
14
|
+
} else s = a;
|
|
15
|
+
return a = s.ref, {
|
|
16
|
+
$$typeof: e,
|
|
17
|
+
type: o,
|
|
18
|
+
key: i,
|
|
19
|
+
ref: a !== void 0 ? a : null,
|
|
20
|
+
props: s
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return $.Fragment = t, $.jsx = r, $.jsxs = r, $;
|
|
24
|
+
}
|
|
25
|
+
var Y = {};
|
|
26
|
+
var ce;
|
|
27
|
+
function ke() {
|
|
28
|
+
return ce || (ce = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
|
+
function e(n) {
|
|
30
|
+
if (n == null) return null;
|
|
31
|
+
if (typeof n == "function")
|
|
32
|
+
return n.$$typeof === G ? null : n.displayName || n.name || null;
|
|
33
|
+
if (typeof n == "string") return n;
|
|
34
|
+
switch (n) {
|
|
35
|
+
case y:
|
|
36
|
+
return "Fragment";
|
|
37
|
+
case P:
|
|
38
|
+
return "Profiler";
|
|
39
|
+
case x:
|
|
40
|
+
return "StrictMode";
|
|
41
|
+
case V:
|
|
42
|
+
return "Suspense";
|
|
43
|
+
case q:
|
|
44
|
+
return "SuspenseList";
|
|
45
|
+
case H:
|
|
46
|
+
return "Activity";
|
|
47
|
+
}
|
|
48
|
+
if (typeof n == "object")
|
|
49
|
+
switch (typeof n.tag == "number" && console.error(
|
|
50
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
|
+
), n.$$typeof) {
|
|
52
|
+
case p:
|
|
53
|
+
return "Portal";
|
|
54
|
+
case k:
|
|
55
|
+
return n.displayName || "Context";
|
|
56
|
+
case j:
|
|
57
|
+
return (n._context.displayName || "Context") + ".Consumer";
|
|
58
|
+
case R:
|
|
59
|
+
var u = n.render;
|
|
60
|
+
return n = n.displayName, n || (n = u.displayName || u.name || "", n = n !== "" ? "ForwardRef(" + n + ")" : "ForwardRef"), n;
|
|
61
|
+
case A:
|
|
62
|
+
return u = n.displayName || null, u !== null ? u : e(n.type) || "Memo";
|
|
63
|
+
case O:
|
|
64
|
+
u = n._payload, n = n._init;
|
|
65
|
+
try {
|
|
66
|
+
return e(n(u));
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function t(n) {
|
|
73
|
+
return "" + n;
|
|
74
|
+
}
|
|
75
|
+
function r(n) {
|
|
76
|
+
try {
|
|
77
|
+
t(n);
|
|
78
|
+
var u = !1;
|
|
79
|
+
} catch {
|
|
80
|
+
u = !0;
|
|
81
|
+
}
|
|
82
|
+
if (u) {
|
|
83
|
+
u = console;
|
|
84
|
+
var b = u.error, g = typeof Symbol == "function" && Symbol.toStringTag && n[Symbol.toStringTag] || n.constructor.name || "Object";
|
|
85
|
+
return b.call(
|
|
86
|
+
u,
|
|
87
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
|
+
g
|
|
89
|
+
), t(n);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function o(n) {
|
|
93
|
+
if (n === y) return "<>";
|
|
94
|
+
if (typeof n == "object" && n !== null && n.$$typeof === O)
|
|
95
|
+
return "<...>";
|
|
96
|
+
try {
|
|
97
|
+
var u = e(n);
|
|
98
|
+
return u ? "<" + u + ">" : "<...>";
|
|
99
|
+
} catch {
|
|
100
|
+
return "<...>";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function a() {
|
|
104
|
+
var n = F.A;
|
|
105
|
+
return n === null ? null : n.getOwner();
|
|
106
|
+
}
|
|
107
|
+
function s() {
|
|
108
|
+
return Error("react-stack-top-frame");
|
|
109
|
+
}
|
|
110
|
+
function i(n) {
|
|
111
|
+
if (D.call(n, "key")) {
|
|
112
|
+
var u = Object.getOwnPropertyDescriptor(n, "key").get;
|
|
113
|
+
if (u && u.isReactWarning) return !1;
|
|
114
|
+
}
|
|
115
|
+
return n.key !== void 0;
|
|
116
|
+
}
|
|
117
|
+
function d(n, u) {
|
|
118
|
+
function b() {
|
|
119
|
+
ne || (ne = !0, console.error(
|
|
120
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
121
|
+
u
|
|
122
|
+
));
|
|
123
|
+
}
|
|
124
|
+
b.isReactWarning = !0, Object.defineProperty(n, "key", {
|
|
125
|
+
get: b,
|
|
126
|
+
configurable: !0
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function _() {
|
|
130
|
+
var n = e(this.type);
|
|
131
|
+
return oe[n] || (oe[n] = !0, console.error(
|
|
132
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
133
|
+
)), n = this.props.ref, n !== void 0 ? n : null;
|
|
134
|
+
}
|
|
135
|
+
function m(n, u, b, g, z, B) {
|
|
136
|
+
var v = b.ref;
|
|
137
|
+
return n = {
|
|
138
|
+
$$typeof: f,
|
|
139
|
+
type: n,
|
|
140
|
+
key: u,
|
|
141
|
+
props: b,
|
|
142
|
+
_owner: g
|
|
143
|
+
}, (v !== void 0 ? v : null) !== null ? Object.defineProperty(n, "ref", {
|
|
144
|
+
enumerable: !1,
|
|
145
|
+
get: _
|
|
146
|
+
}) : Object.defineProperty(n, "ref", { enumerable: !1, value: null }), n._store = {}, Object.defineProperty(n._store, "validated", {
|
|
147
|
+
configurable: !1,
|
|
148
|
+
enumerable: !1,
|
|
149
|
+
writable: !0,
|
|
150
|
+
value: 0
|
|
151
|
+
}), Object.defineProperty(n, "_debugInfo", {
|
|
152
|
+
configurable: !1,
|
|
153
|
+
enumerable: !1,
|
|
154
|
+
writable: !0,
|
|
155
|
+
value: null
|
|
156
|
+
}), Object.defineProperty(n, "_debugStack", {
|
|
157
|
+
configurable: !1,
|
|
158
|
+
enumerable: !1,
|
|
159
|
+
writable: !0,
|
|
160
|
+
value: z
|
|
161
|
+
}), Object.defineProperty(n, "_debugTask", {
|
|
162
|
+
configurable: !1,
|
|
163
|
+
enumerable: !1,
|
|
164
|
+
writable: !0,
|
|
165
|
+
value: B
|
|
166
|
+
}), Object.freeze && (Object.freeze(n.props), Object.freeze(n)), n;
|
|
167
|
+
}
|
|
168
|
+
function h(n, u, b, g, z, B) {
|
|
169
|
+
var v = u.children;
|
|
170
|
+
if (v !== void 0)
|
|
171
|
+
if (g)
|
|
172
|
+
if (L(v)) {
|
|
173
|
+
for (g = 0; g < v.length; g++)
|
|
174
|
+
N(v[g]);
|
|
175
|
+
Object.freeze && Object.freeze(v);
|
|
176
|
+
} else
|
|
177
|
+
console.error(
|
|
178
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
|
+
);
|
|
180
|
+
else N(v);
|
|
181
|
+
if (D.call(u, "key")) {
|
|
182
|
+
v = e(n);
|
|
183
|
+
var I = Object.keys(u).filter(function(we) {
|
|
184
|
+
return we !== "key";
|
|
185
|
+
});
|
|
186
|
+
g = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", ie[v + g] || (I = 0 < I.length ? "{" + I.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
188
|
+
let props = %s;
|
|
189
|
+
<%s {...props} />
|
|
190
|
+
React keys must be passed directly to JSX without using spread:
|
|
191
|
+
let props = %s;
|
|
192
|
+
<%s key={someKey} {...props} />`,
|
|
193
|
+
g,
|
|
194
|
+
v,
|
|
195
|
+
I,
|
|
196
|
+
v
|
|
197
|
+
), ie[v + g] = !0);
|
|
198
|
+
}
|
|
199
|
+
if (v = null, b !== void 0 && (r(b), v = "" + b), i(u) && (r(u.key), v = "" + u.key), "key" in u) {
|
|
200
|
+
b = {};
|
|
201
|
+
for (var Z in u)
|
|
202
|
+
Z !== "key" && (b[Z] = u[Z]);
|
|
203
|
+
} else b = u;
|
|
204
|
+
return v && d(
|
|
205
|
+
b,
|
|
206
|
+
typeof n == "function" ? n.displayName || n.name || "Unknown" : n
|
|
207
|
+
), m(
|
|
208
|
+
n,
|
|
209
|
+
v,
|
|
210
|
+
b,
|
|
211
|
+
a(),
|
|
212
|
+
z,
|
|
213
|
+
B
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
function N(n) {
|
|
217
|
+
c(n) ? n._store && (n._store.validated = 1) : typeof n == "object" && n !== null && n.$$typeof === O && (n._payload.status === "fulfilled" ? c(n._payload.value) && n._payload.value._store && (n._payload.value._store.validated = 1) : n._store && (n._store.validated = 1));
|
|
218
|
+
}
|
|
219
|
+
function c(n) {
|
|
220
|
+
return typeof n == "object" && n !== null && n.$$typeof === f;
|
|
221
|
+
}
|
|
222
|
+
var l = Se, f = /* @__PURE__ */ Symbol.for("react.transitional.element"), p = /* @__PURE__ */ Symbol.for("react.portal"), y = /* @__PURE__ */ Symbol.for("react.fragment"), x = /* @__PURE__ */ Symbol.for("react.strict_mode"), P = /* @__PURE__ */ Symbol.for("react.profiler"), j = /* @__PURE__ */ Symbol.for("react.consumer"), k = /* @__PURE__ */ Symbol.for("react.context"), R = /* @__PURE__ */ Symbol.for("react.forward_ref"), V = /* @__PURE__ */ Symbol.for("react.suspense"), q = /* @__PURE__ */ Symbol.for("react.suspense_list"), A = /* @__PURE__ */ Symbol.for("react.memo"), O = /* @__PURE__ */ Symbol.for("react.lazy"), H = /* @__PURE__ */ Symbol.for("react.activity"), G = /* @__PURE__ */ Symbol.for("react.client.reference"), F = l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, D = Object.prototype.hasOwnProperty, L = Array.isArray, J = console.createTask ? console.createTask : function() {
|
|
223
|
+
return null;
|
|
224
|
+
};
|
|
225
|
+
l = {
|
|
226
|
+
react_stack_bottom_frame: function(n) {
|
|
227
|
+
return n();
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
var ne, oe = {}, ae = l.react_stack_bottom_frame.bind(
|
|
231
|
+
l,
|
|
232
|
+
s
|
|
233
|
+
)(), se = J(o(s)), ie = {};
|
|
234
|
+
Y.Fragment = y, Y.jsx = function(n, u, b) {
|
|
235
|
+
var g = 1e4 > F.recentlyCreatedOwnerStacks++;
|
|
236
|
+
return h(
|
|
237
|
+
n,
|
|
238
|
+
u,
|
|
239
|
+
b,
|
|
240
|
+
!1,
|
|
241
|
+
g ? Error("react-stack-top-frame") : ae,
|
|
242
|
+
g ? J(o(n)) : se
|
|
243
|
+
);
|
|
244
|
+
}, Y.jsxs = function(n, u, b) {
|
|
245
|
+
var g = 1e4 > F.recentlyCreatedOwnerStacks++;
|
|
246
|
+
return h(
|
|
247
|
+
n,
|
|
248
|
+
u,
|
|
249
|
+
b,
|
|
250
|
+
!0,
|
|
251
|
+
g ? Error("react-stack-top-frame") : ae,
|
|
252
|
+
g ? J(o(n)) : se
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
})()), Y;
|
|
256
|
+
}
|
|
257
|
+
var fe;
|
|
258
|
+
function Te() {
|
|
259
|
+
return fe || (fe = 1, process.env.NODE_ENV === "production" ? X.exports = Ce() : X.exports = ke()), X.exports;
|
|
260
|
+
}
|
|
261
|
+
var M = Te(), Ae = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, T = function(e) {
|
|
262
|
+
return typeof e == "string" ? e.length > 0 : typeof e == "number";
|
|
263
|
+
}, E = function(e, t, r) {
|
|
264
|
+
return t === void 0 && (t = 0), r === void 0 && (r = Math.pow(10, t)), Math.round(r * e) / r + 0;
|
|
265
|
+
}, S = function(e, t, r) {
|
|
266
|
+
return t === void 0 && (t = 0), r === void 0 && (r = 1), e > r ? r : e > t ? e : t;
|
|
267
|
+
}, Ee = function(e) {
|
|
268
|
+
return (e = isFinite(e) ? e % 360 : 0) > 0 ? e : e + 360;
|
|
269
|
+
}, de = function(e) {
|
|
270
|
+
return { r: S(e.r, 0, 255), g: S(e.g, 0, 255), b: S(e.b, 0, 255), a: S(e.a) };
|
|
271
|
+
}, ee = function(e) {
|
|
272
|
+
return { r: E(e.r), g: E(e.g), b: E(e.b), a: E(e.a, 3) };
|
|
273
|
+
}, Me = /^#([0-9a-f]{3,8})$/i, U = function(e) {
|
|
274
|
+
var t = e.toString(16);
|
|
275
|
+
return t.length < 2 ? "0" + t : t;
|
|
276
|
+
}, _e = function(e) {
|
|
277
|
+
var t = e.r, r = e.g, o = e.b, a = e.a, s = Math.max(t, r, o), i = s - Math.min(t, r, o), d = i ? s === t ? (r - o) / i : s === r ? 2 + (o - t) / i : 4 + (t - r) / i : 0;
|
|
278
|
+
return { h: 60 * (d < 0 ? d + 6 : d), s: s ? i / s * 100 : 0, v: s / 255 * 100, a };
|
|
279
|
+
}, Pe = function(e) {
|
|
280
|
+
var t = e.h, r = e.s, o = e.v, a = e.a;
|
|
281
|
+
t = t / 360 * 6, r /= 100, o /= 100;
|
|
282
|
+
var s = Math.floor(t), i = o * (1 - r), d = o * (1 - (t - s) * r), _ = o * (1 - (1 - t + s) * r), m = s % 6;
|
|
283
|
+
return { r: 255 * [o, d, i, i, _, o][m], g: 255 * [_, o, o, d, i, i][m], b: 255 * [i, i, _, o, o, d][m], a };
|
|
284
|
+
}, pe = function(e) {
|
|
285
|
+
return { h: Ee(e.h), s: S(e.s, 0, 100), l: S(e.l, 0, 100), a: S(e.a) };
|
|
286
|
+
}, he = function(e) {
|
|
287
|
+
return { h: E(e.h), s: E(e.s), l: E(e.l), a: E(e.a, 3) };
|
|
288
|
+
}, be = function(e) {
|
|
289
|
+
return Pe((r = (t = e).s, { h: t.h, s: (r *= ((o = t.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * r / (o + r) * 100 : 0, v: o + r, a: t.a }));
|
|
290
|
+
var t, r, o;
|
|
291
|
+
}, W = function(e) {
|
|
292
|
+
return { h: (t = _e(e)).h, s: (a = (200 - (r = t.s)) * (o = t.v) / 100) > 0 && a < 200 ? r * o / 100 / (a <= 100 ? a : 200 - a) * 100 : 0, l: a / 2, a: t.a };
|
|
293
|
+
var t, r, o, a;
|
|
294
|
+
}, Ne = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, je = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Oe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Fe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ge = { string: [[function(e) {
|
|
295
|
+
var t = Me.exec(e);
|
|
296
|
+
return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ? E(parseInt(e[3] + e[3], 16) / 255, 2) : 1 } : e.length === 6 || e.length === 8 ? { r: parseInt(e.substr(0, 2), 16), g: parseInt(e.substr(2, 2), 16), b: parseInt(e.substr(4, 2), 16), a: e.length === 8 ? E(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
297
|
+
}, "hex"], [function(e) {
|
|
298
|
+
var t = Oe.exec(e) || Fe.exec(e);
|
|
299
|
+
return t ? t[2] !== t[4] || t[4] !== t[6] ? null : de({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: t[7] === void 0 ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
|
|
300
|
+
}, "rgb"], [function(e) {
|
|
301
|
+
var t = Ne.exec(e) || je.exec(e);
|
|
302
|
+
if (!t) return null;
|
|
303
|
+
var r, o, a = pe({ h: (r = t[1], o = t[2], o === void 0 && (o = "deg"), Number(r) * (Ae[o] || 1)), s: Number(t[3]), l: Number(t[4]), a: t[5] === void 0 ? 1 : Number(t[5]) / (t[6] ? 100 : 1) });
|
|
304
|
+
return be(a);
|
|
305
|
+
}, "hsl"]], object: [[function(e) {
|
|
306
|
+
var t = e.r, r = e.g, o = e.b, a = e.a, s = a === void 0 ? 1 : a;
|
|
307
|
+
return T(t) && T(r) && T(o) ? de({ r: Number(t), g: Number(r), b: Number(o), a: Number(s) }) : null;
|
|
308
|
+
}, "rgb"], [function(e) {
|
|
309
|
+
var t = e.h, r = e.s, o = e.l, a = e.a, s = a === void 0 ? 1 : a;
|
|
310
|
+
if (!T(t) || !T(r) || !T(o)) return null;
|
|
311
|
+
var i = pe({ h: Number(t), s: Number(r), l: Number(o), a: Number(s) });
|
|
312
|
+
return be(i);
|
|
313
|
+
}, "hsl"], [function(e) {
|
|
314
|
+
var t = e.h, r = e.s, o = e.v, a = e.a, s = a === void 0 ? 1 : a;
|
|
315
|
+
if (!T(t) || !T(r) || !T(o)) return null;
|
|
316
|
+
var i = (function(d) {
|
|
317
|
+
return { h: Ee(d.h), s: S(d.s, 0, 100), v: S(d.v, 0, 100), a: S(d.a) };
|
|
318
|
+
})({ h: Number(t), s: Number(r), v: Number(o), a: Number(s) });
|
|
319
|
+
return Pe(i);
|
|
320
|
+
}, "hsv"]] }, ve = function(e, t) {
|
|
321
|
+
for (var r = 0; r < t.length; r++) {
|
|
322
|
+
var o = t[r][0](e);
|
|
323
|
+
if (o) return [o, t[r][1]];
|
|
324
|
+
}
|
|
325
|
+
return [null, void 0];
|
|
326
|
+
}, Ie = function(e) {
|
|
327
|
+
return typeof e == "string" ? ve(e.trim(), ge.string) : typeof e == "object" && e !== null ? ve(e, ge.object) : [null, void 0];
|
|
328
|
+
}, te = function(e, t) {
|
|
329
|
+
var r = W(e);
|
|
330
|
+
return { h: r.h, s: S(r.s + 100 * t, 0, 100), l: r.l, a: r.a };
|
|
331
|
+
}, re = function(e) {
|
|
332
|
+
return (299 * e.r + 587 * e.g + 114 * e.b) / 1e3 / 255;
|
|
333
|
+
}, me = function(e, t) {
|
|
334
|
+
var r = W(e);
|
|
335
|
+
return { h: r.h, s: r.s, l: S(r.l + 100 * t, 0, 100), a: r.a };
|
|
336
|
+
}, ye = (function() {
|
|
337
|
+
function e(t) {
|
|
338
|
+
this.parsed = Ie(t)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
339
|
+
}
|
|
340
|
+
return e.prototype.isValid = function() {
|
|
341
|
+
return this.parsed !== null;
|
|
342
|
+
}, e.prototype.brightness = function() {
|
|
343
|
+
return E(re(this.rgba), 2);
|
|
344
|
+
}, e.prototype.isDark = function() {
|
|
345
|
+
return re(this.rgba) < 0.5;
|
|
346
|
+
}, e.prototype.isLight = function() {
|
|
347
|
+
return re(this.rgba) >= 0.5;
|
|
348
|
+
}, e.prototype.toHex = function() {
|
|
349
|
+
return t = ee(this.rgba), r = t.r, o = t.g, a = t.b, i = (s = t.a) < 1 ? U(E(255 * s)) : "", "#" + U(r) + U(o) + U(a) + i;
|
|
350
|
+
var t, r, o, a, s, i;
|
|
351
|
+
}, e.prototype.toRgb = function() {
|
|
352
|
+
return ee(this.rgba);
|
|
353
|
+
}, e.prototype.toRgbString = function() {
|
|
354
|
+
return t = ee(this.rgba), r = t.r, o = t.g, a = t.b, (s = t.a) < 1 ? "rgba(" + r + ", " + o + ", " + a + ", " + s + ")" : "rgb(" + r + ", " + o + ", " + a + ")";
|
|
355
|
+
var t, r, o, a, s;
|
|
356
|
+
}, e.prototype.toHsl = function() {
|
|
357
|
+
return he(W(this.rgba));
|
|
358
|
+
}, e.prototype.toHslString = function() {
|
|
359
|
+
return t = he(W(this.rgba)), r = t.h, o = t.s, a = t.l, (s = t.a) < 1 ? "hsla(" + r + ", " + o + "%, " + a + "%, " + s + ")" : "hsl(" + r + ", " + o + "%, " + a + "%)";
|
|
360
|
+
var t, r, o, a, s;
|
|
361
|
+
}, e.prototype.toHsv = function() {
|
|
362
|
+
return t = _e(this.rgba), { h: E(t.h), s: E(t.s), v: E(t.v), a: E(t.a, 3) };
|
|
363
|
+
var t;
|
|
364
|
+
}, e.prototype.invert = function() {
|
|
365
|
+
return C({ r: 255 - (t = this.rgba).r, g: 255 - t.g, b: 255 - t.b, a: t.a });
|
|
366
|
+
var t;
|
|
367
|
+
}, e.prototype.saturate = function(t) {
|
|
368
|
+
return t === void 0 && (t = 0.1), C(te(this.rgba, t));
|
|
369
|
+
}, e.prototype.desaturate = function(t) {
|
|
370
|
+
return t === void 0 && (t = 0.1), C(te(this.rgba, -t));
|
|
371
|
+
}, e.prototype.grayscale = function() {
|
|
372
|
+
return C(te(this.rgba, -1));
|
|
373
|
+
}, e.prototype.lighten = function(t) {
|
|
374
|
+
return t === void 0 && (t = 0.1), C(me(this.rgba, t));
|
|
375
|
+
}, e.prototype.darken = function(t) {
|
|
376
|
+
return t === void 0 && (t = 0.1), C(me(this.rgba, -t));
|
|
377
|
+
}, e.prototype.rotate = function(t) {
|
|
378
|
+
return t === void 0 && (t = 15), this.hue(this.hue() + t);
|
|
379
|
+
}, e.prototype.alpha = function(t) {
|
|
380
|
+
return typeof t == "number" ? C({ r: (r = this.rgba).r, g: r.g, b: r.b, a: t }) : E(this.rgba.a, 3);
|
|
381
|
+
var r;
|
|
382
|
+
}, e.prototype.hue = function(t) {
|
|
383
|
+
var r = W(this.rgba);
|
|
384
|
+
return typeof t == "number" ? C({ h: t, s: r.s, l: r.l, a: r.a }) : E(r.h);
|
|
385
|
+
}, e.prototype.isEqual = function(t) {
|
|
386
|
+
return this.toHex() === C(t).toHex();
|
|
387
|
+
}, e;
|
|
388
|
+
})(), C = function(e) {
|
|
389
|
+
return e instanceof ye ? e : new ye(e);
|
|
390
|
+
};
|
|
391
|
+
const De = ({
|
|
392
|
+
hexColor: e,
|
|
393
|
+
cursorPos: t,
|
|
394
|
+
onPointerDown: r,
|
|
395
|
+
onPointerMove: o,
|
|
396
|
+
onPointerUp: a
|
|
397
|
+
}) => {
|
|
398
|
+
const [s, i] = Re(!1), d = (h) => {
|
|
399
|
+
i(!0), r(h), h.currentTarget.setPointerCapture(h.pointerId);
|
|
400
|
+
}, _ = (h) => {
|
|
401
|
+
s && o(h);
|
|
402
|
+
}, m = (h) => {
|
|
403
|
+
i(!1), a(h), h.currentTarget.releasePointerCapture(h.pointerId);
|
|
404
|
+
};
|
|
405
|
+
return /* @__PURE__ */ M.jsx(
|
|
406
|
+
"div",
|
|
407
|
+
{
|
|
408
|
+
style: {
|
|
409
|
+
position: "absolute",
|
|
410
|
+
width: 24,
|
|
411
|
+
height: 24,
|
|
412
|
+
borderRadius: "50%",
|
|
413
|
+
border: "2px solid white",
|
|
414
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.3)",
|
|
415
|
+
backgroundColor: e,
|
|
416
|
+
left: "50%",
|
|
417
|
+
top: "50%",
|
|
418
|
+
transform: `translate(calc(-50% + ${t.x}px), calc(-50% + ${t.y}px))`,
|
|
419
|
+
pointerEvents: "auto",
|
|
420
|
+
cursor: s ? "grabbing" : "grab",
|
|
421
|
+
willChange: "transform",
|
|
422
|
+
zIndex: 10
|
|
423
|
+
},
|
|
424
|
+
onPointerDown: d,
|
|
425
|
+
onPointerMove: _,
|
|
426
|
+
onPointerUp: m
|
|
427
|
+
}
|
|
428
|
+
);
|
|
429
|
+
}, w = {
|
|
430
|
+
/** Custom color selection without predefined harmony */
|
|
431
|
+
Custom: "Custom",
|
|
432
|
+
/** Colors adjacent to each other on the color wheel */
|
|
433
|
+
Analogous: "Analogous",
|
|
434
|
+
/** Colors of the same hue with varying saturation and lightness */
|
|
435
|
+
Monochromatic: "Monochromatic",
|
|
436
|
+
/** Three colors evenly spaced around the color wheel */
|
|
437
|
+
Triad: "Triad",
|
|
438
|
+
/** Two colors opposite each other on the color wheel */
|
|
439
|
+
Complementary: "Complementary",
|
|
440
|
+
/** A base color and two colors adjacent to its complement */
|
|
441
|
+
SplitComplementary: "SplitComplementary",
|
|
442
|
+
/** Four colors evenly spaced around the color wheel */
|
|
443
|
+
Square: "Square",
|
|
444
|
+
/** A combination of complementary and analogous colors */
|
|
445
|
+
Compound: "Compound"
|
|
446
|
+
}, xe = (e, t, r, o) => {
|
|
447
|
+
const a = Math.atan2(t, e), s = Math.sqrt(e * e + t * t);
|
|
448
|
+
let i = [];
|
|
449
|
+
switch (r) {
|
|
450
|
+
case w.Analogous:
|
|
451
|
+
i = [0, -30, 30, -60, 60];
|
|
452
|
+
break;
|
|
453
|
+
case w.Monochromatic:
|
|
454
|
+
i = [0];
|
|
455
|
+
break;
|
|
456
|
+
case w.Triad:
|
|
457
|
+
i = [0, 120, 240];
|
|
458
|
+
break;
|
|
459
|
+
case w.Complementary:
|
|
460
|
+
i = [0, 180];
|
|
461
|
+
break;
|
|
462
|
+
case w.SplitComplementary:
|
|
463
|
+
i = [0, 150, 210];
|
|
464
|
+
break;
|
|
465
|
+
case w.Square:
|
|
466
|
+
i = [0, 90, 180, 270];
|
|
467
|
+
break;
|
|
468
|
+
case w.Compound:
|
|
469
|
+
i = [0, 180, 30, 210, 60];
|
|
470
|
+
break;
|
|
471
|
+
case w.Custom:
|
|
472
|
+
default:
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
const d = i.length, _ = 0.25, m = [];
|
|
476
|
+
for (let h = 0; h < o; h++) {
|
|
477
|
+
const N = Math.floor(h / d), c = h % d, l = i[c], f = a + l * Math.PI / 180;
|
|
478
|
+
let p = s;
|
|
479
|
+
r === w.Monochromatic ? (p = s * (1 - h * 0.15), p < 0 && (p = 0)) : (p = s * (1 - N * _), p < 0 && (p = 0)), m.push({
|
|
480
|
+
x: Math.cos(f) * p,
|
|
481
|
+
y: Math.sin(f) * p
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
return m;
|
|
485
|
+
}, $e = (e, t) => {
|
|
486
|
+
const r = t, o = t, a = e.createConicGradient(Math.PI * 1.5, r, o);
|
|
487
|
+
a.addColorStop(0, "#FFFF00"), a.addColorStop(0.19, "#FF0000"), a.addColorStop(0.36, "#FF00FF"), a.addColorStop(0.5, "#0000FF"), a.addColorStop(0.64, "#00FFFF"), a.addColorStop(0.78, "#00FF00"), a.addColorStop(1, "#FFFF00"), e.fillStyle = a, e.beginPath(), e.arc(r, o, t, 0, Math.PI * 2), e.fill();
|
|
488
|
+
const s = e.createRadialGradient(r, o, 0, r, o, t);
|
|
489
|
+
s.addColorStop(0, "#ffffff"), s.addColorStop(0.2, "rgba(255, 255, 255, 0.8)"), s.addColorStop(0.6, "rgba(255, 255, 255, 0.2)"), s.addColorStop(1, "rgba(255, 255, 255, 0)"), e.fillStyle = s, e.beginPath(), e.arc(r, o, t, 0, Math.PI * 2), e.fill();
|
|
490
|
+
}, Ye = (e, t, r) => {
|
|
491
|
+
const o = Math.sqrt(e * e + t * t), a = r - 1;
|
|
492
|
+
if (o > a) {
|
|
493
|
+
const s = a / o;
|
|
494
|
+
return { x: e * s, y: t * s };
|
|
495
|
+
}
|
|
496
|
+
return { x: e, y: t };
|
|
497
|
+
}, qe = ({
|
|
498
|
+
radius: e = 150,
|
|
499
|
+
onChange: t,
|
|
500
|
+
quantityOfColors: r = 5,
|
|
501
|
+
harmony: o = w.Monochromatic
|
|
502
|
+
}) => {
|
|
503
|
+
const a = Q(null), s = Q(null), [i, d] = Re([]), _ = Q([]), m = K((c, l) => {
|
|
504
|
+
const f = a.current;
|
|
505
|
+
if (!f) return "#ffffff";
|
|
506
|
+
const p = f.getContext("2d");
|
|
507
|
+
if (!p) return "#ffffff";
|
|
508
|
+
const y = window.devicePixelRatio || 1, x = c + e, P = l + e, j = Math.floor(x * y), k = Math.floor(P * y), R = p.getImageData(j, k, 1, 1).data;
|
|
509
|
+
return C({ r: R[0], g: R[1], b: R[2], a: R[3] / 255 }).toHex();
|
|
510
|
+
}, [e]);
|
|
511
|
+
le(() => {
|
|
512
|
+
const c = a.current;
|
|
513
|
+
if (!c) return;
|
|
514
|
+
const l = c.getContext("2d", { willReadFrequently: !0 });
|
|
515
|
+
if (!l) return;
|
|
516
|
+
const f = window.devicePixelRatio || 1, p = e * 2;
|
|
517
|
+
c.width = p * f, c.height = p * f, c.style.width = `${p}px`, c.style.height = `${p}px`, l.scale(f, f), $e(l, e);
|
|
518
|
+
}, [e]), le(() => {
|
|
519
|
+
let c;
|
|
520
|
+
if (i.length > 0) {
|
|
521
|
+
const l = i[0];
|
|
522
|
+
c = xe(l.x, l.y, o, r);
|
|
523
|
+
}
|
|
524
|
+
if (!c) {
|
|
525
|
+
const l = e * 0.5;
|
|
526
|
+
o !== w.Custom ? c = xe(l, 0, o, r) : c = Array.from({ length: r }).map((p, y) => {
|
|
527
|
+
const x = y / r * 2 * Math.PI;
|
|
528
|
+
return { x: Math.cos(x) * e * 0.6, y: Math.sin(x) * e * 0.6 };
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
if (c) {
|
|
532
|
+
const l = c.map((f, p) => ({
|
|
533
|
+
id: p,
|
|
534
|
+
x: f.x,
|
|
535
|
+
y: f.y,
|
|
536
|
+
color: m(f.x, f.y)
|
|
537
|
+
}));
|
|
538
|
+
if (l.length > 0 && o !== w.Custom) {
|
|
539
|
+
const f = Math.atan2(l[0].y, l[0].x), p = Math.sqrt(l[0].x * l[0].x + l[0].y * l[0].y);
|
|
540
|
+
_.current = l.map((y) => {
|
|
541
|
+
const x = Math.atan2(y.y, y.x), P = Math.sqrt(y.x * y.x + y.y * y.y);
|
|
542
|
+
return {
|
|
543
|
+
angleOffset: x - f,
|
|
544
|
+
distanceRatio: p > 0 ? P / p : 1
|
|
545
|
+
};
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
d(l), t && t(l);
|
|
549
|
+
}
|
|
550
|
+
}, [o, r, m]);
|
|
551
|
+
const h = K(
|
|
552
|
+
(c, l, f) => {
|
|
553
|
+
const p = s.current;
|
|
554
|
+
if (!p) return;
|
|
555
|
+
const y = p.getBoundingClientRect();
|
|
556
|
+
let x = c - y.left - e, P = l - y.top - e;
|
|
557
|
+
const j = Ye(x, P, e);
|
|
558
|
+
if (x = j.x, P = j.y, o === w.Custom) {
|
|
559
|
+
const k = m(x, P), R = [...i];
|
|
560
|
+
R[f] = { ...R[f], x, y: P, color: k }, d(R), t && t(R);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (_.current.length > 0 && _.current[f]) {
|
|
564
|
+
const k = Math.atan2(P, x), R = _.current[f], V = k - R.angleOffset, q = i.map((A, O) => {
|
|
565
|
+
if (O === f)
|
|
566
|
+
return { ...A, x, y: P, color: m(x, P) };
|
|
567
|
+
const H = Math.sqrt(A.x * A.x + A.y * A.y), G = _.current[O], F = V + G.angleOffset, D = Math.cos(F) * H, L = Math.sin(F) * H;
|
|
568
|
+
return {
|
|
569
|
+
...A,
|
|
570
|
+
x: D,
|
|
571
|
+
y: L,
|
|
572
|
+
color: m(D, L)
|
|
573
|
+
};
|
|
574
|
+
});
|
|
575
|
+
d(q), t && t(q);
|
|
576
|
+
} else {
|
|
577
|
+
const k = m(x, P), R = [...i];
|
|
578
|
+
R[f] = { ...R[f], x, y: P, color: k }, d(R), t && t(R);
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
[e, m, t, i, o]
|
|
582
|
+
), N = K((c) => ({
|
|
583
|
+
onPointerDown: (l) => {
|
|
584
|
+
h(l.clientX, l.clientY, c);
|
|
585
|
+
},
|
|
586
|
+
onPointerMove: (l) => {
|
|
587
|
+
h(l.clientX, l.clientY, c);
|
|
588
|
+
},
|
|
589
|
+
onPointerUp: () => {
|
|
590
|
+
}
|
|
591
|
+
}), [h]);
|
|
592
|
+
return /* @__PURE__ */ M.jsx("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 20 }, children: /* @__PURE__ */ M.jsxs(
|
|
593
|
+
"div",
|
|
594
|
+
{
|
|
595
|
+
ref: s,
|
|
596
|
+
style: {
|
|
597
|
+
width: e * 2,
|
|
598
|
+
height: e * 2,
|
|
599
|
+
position: "relative",
|
|
600
|
+
touchAction: "none"
|
|
601
|
+
},
|
|
602
|
+
children: [
|
|
603
|
+
/* @__PURE__ */ M.jsx("canvas", { ref: a, style: { borderRadius: "50%", display: "block" } }),
|
|
604
|
+
/* @__PURE__ */ M.jsx(
|
|
605
|
+
"svg",
|
|
606
|
+
{
|
|
607
|
+
style: {
|
|
608
|
+
position: "absolute",
|
|
609
|
+
top: 0,
|
|
610
|
+
left: 0,
|
|
611
|
+
width: "100%",
|
|
612
|
+
height: "100%",
|
|
613
|
+
pointerEvents: "none",
|
|
614
|
+
zIndex: 1
|
|
615
|
+
},
|
|
616
|
+
children: i.map((c) => /* @__PURE__ */ M.jsx(
|
|
617
|
+
"line",
|
|
618
|
+
{
|
|
619
|
+
x1: e,
|
|
620
|
+
y1: e,
|
|
621
|
+
x2: e + c.x,
|
|
622
|
+
y2: e + c.y,
|
|
623
|
+
stroke: "white",
|
|
624
|
+
strokeWidth: "2",
|
|
625
|
+
style: { filter: "drop-shadow(0px 1px 1px rgba(0,0,0,0.3))" }
|
|
626
|
+
},
|
|
627
|
+
c.id
|
|
628
|
+
))
|
|
629
|
+
}
|
|
630
|
+
),
|
|
631
|
+
i.map((c, l) => {
|
|
632
|
+
const f = N(l);
|
|
633
|
+
return /* @__PURE__ */ M.jsx(
|
|
634
|
+
De,
|
|
635
|
+
{
|
|
636
|
+
cursorPos: { x: c.x, y: c.y },
|
|
637
|
+
hexColor: c.color,
|
|
638
|
+
onPointerDown: f.onPointerDown,
|
|
639
|
+
onPointerMove: f.onPointerMove,
|
|
640
|
+
onPointerUp: f.onPointerUp
|
|
641
|
+
},
|
|
642
|
+
c.id
|
|
643
|
+
);
|
|
644
|
+
})
|
|
645
|
+
]
|
|
646
|
+
}
|
|
647
|
+
) });
|
|
648
|
+
};
|
|
649
|
+
export {
|
|
650
|
+
qe as ColorWheel,
|
|
651
|
+
w as HarmonyType
|
|
652
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(A,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],_):(A=typeof globalThis<"u"?globalThis:A||self,_(A.ReactColorPaletteWheel={},A.React))})(this,(function(A,_){"use strict";var X={exports:{}},W={};var ne;function _e(){if(ne)return W;ne=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(o,a,s){var i=null;if(s!==void 0&&(i=""+s),a.key!==void 0&&(i=""+a.key),"key"in a){s={};for(var d in a)d!=="key"&&(s[d]=a[d])}else s=a;return a=s.ref,{$$typeof:e,type:o,key:i,ref:a!==void 0?a:null,props:s}}return W.Fragment=t,W.jsx=r,W.jsxs=r,W}var H={};var oe;function Pe(){return oe||(oe=1,process.env.NODE_ENV!=="production"&&(function(){function e(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===K?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case R:return"Fragment";case w:return"Profiler";case x:return"StrictMode";case Q:return"Suspense";case V:return"SuspenseList";case G:return"Activity"}if(typeof n=="object")switch(typeof n.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),n.$$typeof){case p:return"Portal";case M:return n.displayName||"Context";case F:return(n._context.displayName||"Context")+".Consumer";case E:var u=n.render;return n=n.displayName,n||(n=u.displayName||u.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case N:return u=n.displayName||null,u!==null?u:e(n.type)||"Memo";case I:u=n._payload,n=n._init;try{return e(n(u))}catch{}}return null}function t(n){return""+n}function r(n){try{t(n);var u=!1}catch{u=!0}if(u){u=console;var b=u.error,g=typeof Symbol=="function"&&Symbol.toStringTag&&n[Symbol.toStringTag]||n.constructor.name||"Object";return b.call(u,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",g),t(n)}}function o(n){if(n===R)return"<>";if(typeof n=="object"&&n!==null&&n.$$typeof===I)return"<...>";try{var u=e(n);return u?"<"+u+">":"<...>"}catch{return"<...>"}}function a(){var n=D.A;return n===null?null:n.getOwner()}function s(){return Error("react-stack-top-frame")}function i(n){if(z.call(n,"key")){var u=Object.getOwnPropertyDescriptor(n,"key").get;if(u&&u.isReactWarning)return!1}return n.key!==void 0}function d(n,u){function b(){me||(me=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",u))}b.isReactWarning=!0,Object.defineProperty(n,"key",{get:b,configurable:!0})}function P(){var n=e(this.type);return ye[n]||(ye[n]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),n=this.props.ref,n!==void 0?n:null}function y(n,u,b,g,$,te){var v=b.ref;return n={$$typeof:f,type:n,key:u,props:b,_owner:g},(v!==void 0?v:null)!==null?Object.defineProperty(n,"ref",{enumerable:!1,get:P}):Object.defineProperty(n,"ref",{enumerable:!1,value:null}),n._store={},Object.defineProperty(n._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(n,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(n,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:$}),Object.defineProperty(n,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.freeze&&(Object.freeze(n.props),Object.freeze(n)),n}function h(n,u,b,g,$,te){var v=u.children;if(v!==void 0)if(g)if(J(v)){for(g=0;g<v.length;g++)O(v[g]);Object.freeze&&Object.freeze(v)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else O(v);if(z.call(u,"key")){v=e(n);var Y=Object.keys(u).filter(function(De){return De!=="key"});g=0<Y.length?"{key: someKey, "+Y.join(": ..., ")+": ...}":"{key: someKey}",Ee[v+g]||(Y=0<Y.length?"{"+Y.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
5
|
+
let props = %s;
|
|
6
|
+
<%s key={someKey} {...props} />`,g,v,Y,v),Ee[v+g]=!0)}if(v=null,b!==void 0&&(r(b),v=""+b),i(u)&&(r(u.key),v=""+u.key),"key"in u){b={};for(var re in u)re!=="key"&&(b[re]=u[re])}else b=u;return v&&d(b,typeof n=="function"?n.displayName||n.name||"Unknown":n),y(n,v,b,a(),$,te)}function O(n){c(n)?n._store&&(n._store.validated=1):typeof n=="object"&&n!==null&&n.$$typeof===I&&(n._payload.status==="fulfilled"?c(n._payload.value)&&n._payload.value._store&&(n._payload.value._store.validated=1):n._store&&(n._store.validated=1))}function c(n){return typeof n=="object"&&n!==null&&n.$$typeof===f}var l=_,f=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),F=Symbol.for("react.consumer"),M=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),Q=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),G=Symbol.for("react.activity"),K=Symbol.for("react.client.reference"),D=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,J=Array.isArray,ee=console.createTask?console.createTask:function(){return null};l={react_stack_bottom_frame:function(n){return n()}};var me,ye={},Re=l.react_stack_bottom_frame.bind(l,s)(),xe=ee(o(s)),Ee={};H.Fragment=R,H.jsx=function(n,u,b){var g=1e4>D.recentlyCreatedOwnerStacks++;return h(n,u,b,!1,g?Error("react-stack-top-frame"):Re,g?ee(o(n)):xe)},H.jsxs=function(n,u,b){var g=1e4>D.recentlyCreatedOwnerStacks++;return h(n,u,b,!0,g?Error("react-stack-top-frame"):Re,g?ee(o(n)):xe)}})()),H}var ae;function we(){return ae||(ae=1,process.env.NODE_ENV==="production"?X.exports=_e():X.exports=Pe()),X.exports}var j=we(),Se={grad:.9,turn:360,rad:360/(2*Math.PI)},k=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},m=function(e,t,r){return t===void 0&&(t=0),r===void 0&&(r=Math.pow(10,t)),Math.round(r*e)/r+0},C=function(e,t,r){return t===void 0&&(t=0),r===void 0&&(r=1),e>r?r:e>t?e:t},se=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},ie=function(e){return{r:C(e.r,0,255),g:C(e.g,0,255),b:C(e.b,0,255),a:C(e.a)}},q=function(e){return{r:m(e.r),g:m(e.g),b:m(e.b),a:m(e.a,3)}},Ce=/^#([0-9a-f]{3,8})$/i,U=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},le=function(e){var t=e.r,r=e.g,o=e.b,a=e.a,s=Math.max(t,r,o),i=s-Math.min(t,r,o),d=i?s===t?(r-o)/i:s===r?2+(o-t)/i:4+(t-r)/i:0;return{h:60*(d<0?d+6:d),s:s?i/s*100:0,v:s/255*100,a}},ue=function(e){var t=e.h,r=e.s,o=e.v,a=e.a;t=t/360*6,r/=100,o/=100;var s=Math.floor(t),i=o*(1-r),d=o*(1-(t-s)*r),P=o*(1-(1-t+s)*r),y=s%6;return{r:255*[o,d,i,i,P,o][y],g:255*[P,o,o,d,i,i][y],b:255*[i,i,P,o,o,d][y],a}},ce=function(e){return{h:se(e.h),s:C(e.s,0,100),l:C(e.l,0,100),a:C(e.a)}},fe=function(e){return{h:m(e.h),s:m(e.s),l:m(e.l),a:m(e.a,3)}},de=function(e){return ue((r=(t=e).s,{h:t.h,s:(r*=((o=t.l)<50?o:100-o)/100)>0?2*r/(o+r)*100:0,v:o+r,a:t.a}));var t,r,o},L=function(e){return{h:(t=le(e)).h,s:(a=(200-(r=t.s))*(o=t.v)/100)>0&&a<200?r*o/100/(a<=100?a:200-a)*100:0,l:a/2,a:t.a};var t,r,o,a},Te=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ke=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Me=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ae=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,pe={string:[[function(e){var t=Ce.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?m(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?m(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=Me.exec(e)||Ae.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:ie({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=Te.exec(e)||ke.exec(e);if(!t)return null;var r,o,a=ce({h:(r=t[1],o=t[2],o===void 0&&(o="deg"),Number(r)*(Se[o]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return de(a)},"hsl"]],object:[[function(e){var t=e.r,r=e.g,o=e.b,a=e.a,s=a===void 0?1:a;return k(t)&&k(r)&&k(o)?ie({r:Number(t),g:Number(r),b:Number(o),a:Number(s)}):null},"rgb"],[function(e){var t=e.h,r=e.s,o=e.l,a=e.a,s=a===void 0?1:a;if(!k(t)||!k(r)||!k(o))return null;var i=ce({h:Number(t),s:Number(r),l:Number(o),a:Number(s)});return de(i)},"hsl"],[function(e){var t=e.h,r=e.s,o=e.v,a=e.a,s=a===void 0?1:a;if(!k(t)||!k(r)||!k(o))return null;var i=(function(d){return{h:se(d.h),s:C(d.s,0,100),v:C(d.v,0,100),a:C(d.a)}})({h:Number(t),s:Number(r),v:Number(o),a:Number(s)});return ue(i)},"hsv"]]},he=function(e,t){for(var r=0;r<t.length;r++){var o=t[r][0](e);if(o)return[o,t[r][1]]}return[null,void 0]},Ne=function(e){return typeof e=="string"?he(e.trim(),pe.string):typeof e=="object"&&e!==null?he(e,pe.object):[null,void 0]},B=function(e,t){var r=L(e);return{h:r.h,s:C(r.s+100*t,0,100),l:r.l,a:r.a}},Z=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},be=function(e,t){var r=L(e);return{h:r.h,s:r.s,l:C(r.l+100*t,0,100),a:r.a}},ge=(function(){function e(t){this.parsed=Ne(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return m(Z(this.rgba),2)},e.prototype.isDark=function(){return Z(this.rgba)<.5},e.prototype.isLight=function(){return Z(this.rgba)>=.5},e.prototype.toHex=function(){return t=q(this.rgba),r=t.r,o=t.g,a=t.b,i=(s=t.a)<1?U(m(255*s)):"","#"+U(r)+U(o)+U(a)+i;var t,r,o,a,s,i},e.prototype.toRgb=function(){return q(this.rgba)},e.prototype.toRgbString=function(){return t=q(this.rgba),r=t.r,o=t.g,a=t.b,(s=t.a)<1?"rgba("+r+", "+o+", "+a+", "+s+")":"rgb("+r+", "+o+", "+a+")";var t,r,o,a,s},e.prototype.toHsl=function(){return fe(L(this.rgba))},e.prototype.toHslString=function(){return t=fe(L(this.rgba)),r=t.h,o=t.s,a=t.l,(s=t.a)<1?"hsla("+r+", "+o+"%, "+a+"%, "+s+")":"hsl("+r+", "+o+"%, "+a+"%)";var t,r,o,a,s},e.prototype.toHsv=function(){return t=le(this.rgba),{h:m(t.h),s:m(t.s),v:m(t.v),a:m(t.a,3)};var t},e.prototype.invert=function(){return T({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=.1),T(B(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),T(B(this.rgba,-t))},e.prototype.grayscale=function(){return T(B(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),T(be(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),T(be(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?T({r:(r=this.rgba).r,g:r.g,b:r.b,a:t}):m(this.rgba.a,3);var r},e.prototype.hue=function(t){var r=L(this.rgba);return typeof t=="number"?T({h:t,s:r.s,l:r.l,a:r.a}):m(r.h)},e.prototype.isEqual=function(t){return this.toHex()===T(t).toHex()},e})(),T=function(e){return e instanceof ge?e:new ge(e)};const je=({hexColor:e,cursorPos:t,onPointerDown:r,onPointerMove:o,onPointerUp:a})=>{const[s,i]=_.useState(!1),d=h=>{i(!0),r(h),h.currentTarget.setPointerCapture(h.pointerId)},P=h=>{s&&o(h)},y=h=>{i(!1),a(h),h.currentTarget.releasePointerCapture(h.pointerId)};return j.jsx("div",{style:{position:"absolute",width:24,height:24,borderRadius:"50%",border:"2px solid white",boxShadow:"0 2px 4px rgba(0,0,0,0.3)",backgroundColor:e,left:"50%",top:"50%",transform:`translate(calc(-50% + ${t.x}px), calc(-50% + ${t.y}px))`,pointerEvents:"auto",cursor:s?"grabbing":"grab",willChange:"transform",zIndex:10},onPointerDown:d,onPointerMove:P,onPointerUp:y})},S={Custom:"Custom",Analogous:"Analogous",Monochromatic:"Monochromatic",Triad:"Triad",Complementary:"Complementary",SplitComplementary:"SplitComplementary",Square:"Square",Compound:"Compound"},ve=(e,t,r,o)=>{const a=Math.atan2(t,e),s=Math.sqrt(e*e+t*t);let i=[];switch(r){case S.Analogous:i=[0,-30,30,-60,60];break;case S.Monochromatic:i=[0];break;case S.Triad:i=[0,120,240];break;case S.Complementary:i=[0,180];break;case S.SplitComplementary:i=[0,150,210];break;case S.Square:i=[0,90,180,270];break;case S.Compound:i=[0,180,30,210,60];break;case S.Custom:default:return null}const d=i.length,P=.25,y=[];for(let h=0;h<o;h++){const O=Math.floor(h/d),c=h%d,l=i[c],f=a+l*Math.PI/180;let p=s;r===S.Monochromatic?(p=s*(1-h*.15),p<0&&(p=0)):(p=s*(1-O*P),p<0&&(p=0)),y.push({x:Math.cos(f)*p,y:Math.sin(f)*p})}return y},Oe=(e,t)=>{const r=t,o=t,a=e.createConicGradient(Math.PI*1.5,r,o);a.addColorStop(0,"#FFFF00"),a.addColorStop(.19,"#FF0000"),a.addColorStop(.36,"#FF00FF"),a.addColorStop(.5,"#0000FF"),a.addColorStop(.64,"#00FFFF"),a.addColorStop(.78,"#00FF00"),a.addColorStop(1,"#FFFF00"),e.fillStyle=a,e.beginPath(),e.arc(r,o,t,0,Math.PI*2),e.fill();const s=e.createRadialGradient(r,o,0,r,o,t);s.addColorStop(0,"#ffffff"),s.addColorStop(.2,"rgba(255, 255, 255, 0.8)"),s.addColorStop(.6,"rgba(255, 255, 255, 0.2)"),s.addColorStop(1,"rgba(255, 255, 255, 0)"),e.fillStyle=s,e.beginPath(),e.arc(r,o,t,0,Math.PI*2),e.fill()},Fe=(e,t,r)=>{const o=Math.sqrt(e*e+t*t),a=r-1;if(o>a){const s=a/o;return{x:e*s,y:t*s}}return{x:e,y:t}},Ie=({radius:e=150,onChange:t,quantityOfColors:r=5,harmony:o=S.Monochromatic})=>{const a=_.useRef(null),s=_.useRef(null),[i,d]=_.useState([]),P=_.useRef([]),y=_.useCallback((c,l)=>{const f=a.current;if(!f)return"#ffffff";const p=f.getContext("2d");if(!p)return"#ffffff";const R=window.devicePixelRatio||1,x=c+e,w=l+e,F=Math.floor(x*R),M=Math.floor(w*R),E=p.getImageData(F,M,1,1).data;return T({r:E[0],g:E[1],b:E[2],a:E[3]/255}).toHex()},[e]);_.useEffect(()=>{const c=a.current;if(!c)return;const l=c.getContext("2d",{willReadFrequently:!0});if(!l)return;const f=window.devicePixelRatio||1,p=e*2;c.width=p*f,c.height=p*f,c.style.width=`${p}px`,c.style.height=`${p}px`,l.scale(f,f),Oe(l,e)},[e]),_.useEffect(()=>{let c;if(i.length>0){const l=i[0];c=ve(l.x,l.y,o,r)}if(!c){const l=e*.5;o!==S.Custom?c=ve(l,0,o,r):c=Array.from({length:r}).map((p,R)=>{const x=R/r*2*Math.PI;return{x:Math.cos(x)*e*.6,y:Math.sin(x)*e*.6}})}if(c){const l=c.map((f,p)=>({id:p,x:f.x,y:f.y,color:y(f.x,f.y)}));if(l.length>0&&o!==S.Custom){const f=Math.atan2(l[0].y,l[0].x),p=Math.sqrt(l[0].x*l[0].x+l[0].y*l[0].y);P.current=l.map(R=>{const x=Math.atan2(R.y,R.x),w=Math.sqrt(R.x*R.x+R.y*R.y);return{angleOffset:x-f,distanceRatio:p>0?w/p:1}})}d(l),t&&t(l)}},[o,r,y]);const h=_.useCallback((c,l,f)=>{const p=s.current;if(!p)return;const R=p.getBoundingClientRect();let x=c-R.left-e,w=l-R.top-e;const F=Fe(x,w,e);if(x=F.x,w=F.y,o===S.Custom){const M=y(x,w),E=[...i];E[f]={...E[f],x,y:w,color:M},d(E),t&&t(E);return}if(P.current.length>0&&P.current[f]){const M=Math.atan2(w,x),E=P.current[f],Q=M-E.angleOffset,V=i.map((N,I)=>{if(I===f)return{...N,x,y:w,color:y(x,w)};const G=Math.sqrt(N.x*N.x+N.y*N.y),K=P.current[I],D=Q+K.angleOffset,z=Math.cos(D)*G,J=Math.sin(D)*G;return{...N,x:z,y:J,color:y(z,J)}});d(V),t&&t(V)}else{const M=y(x,w),E=[...i];E[f]={...E[f],x,y:w,color:M},d(E),t&&t(E)}},[e,y,t,i,o]),O=_.useCallback(c=>({onPointerDown:l=>{h(l.clientX,l.clientY,c)},onPointerMove:l=>{h(l.clientX,l.clientY,c)},onPointerUp:()=>{}}),[h]);return j.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:20},children:j.jsxs("div",{ref:s,style:{width:e*2,height:e*2,position:"relative",touchAction:"none"},children:[j.jsx("canvas",{ref:a,style:{borderRadius:"50%",display:"block"}}),j.jsx("svg",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:1},children:i.map(c=>j.jsx("line",{x1:e,y1:e,x2:e+c.x,y2:e+c.y,stroke:"white",strokeWidth:"2",style:{filter:"drop-shadow(0px 1px 1px rgba(0,0,0,0.3))"}},c.id))}),i.map((c,l)=>{const f=O(l);return j.jsx(je,{cursorPos:{x:c.x,y:c.y},hexColor:c.color,onPointerDown:f.onPointerDown,onPointerMove:f.onPointerMove,onPointerUp:f.onPointerUp},c.id)})]})})};A.ColorWheel=Ie,A.HarmonyType=S,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Available color harmony types for the color wheel.
|
|
3
|
+
* Each type represents a different color relationship scheme.
|
|
4
|
+
*/
|
|
5
|
+
export declare const HarmonyType: {
|
|
6
|
+
/** Custom color selection without predefined harmony */
|
|
7
|
+
readonly Custom: "Custom";
|
|
8
|
+
/** Colors adjacent to each other on the color wheel */
|
|
9
|
+
readonly Analogous: "Analogous";
|
|
10
|
+
/** Colors of the same hue with varying saturation and lightness */
|
|
11
|
+
readonly Monochromatic: "Monochromatic";
|
|
12
|
+
/** Three colors evenly spaced around the color wheel */
|
|
13
|
+
readonly Triad: "Triad";
|
|
14
|
+
/** Two colors opposite each other on the color wheel */
|
|
15
|
+
readonly Complementary: "Complementary";
|
|
16
|
+
/** A base color and two colors adjacent to its complement */
|
|
17
|
+
readonly SplitComplementary: "SplitComplementary";
|
|
18
|
+
/** Four colors evenly spaced around the color wheel */
|
|
19
|
+
readonly Square: "Square";
|
|
20
|
+
/** A combination of complementary and analogous colors */
|
|
21
|
+
readonly Compound: "Compound";
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Type representing a color harmony type.
|
|
25
|
+
* Derived from the HarmonyType constant object.
|
|
26
|
+
*/
|
|
27
|
+
export type HarmonyType = typeof HarmonyType[keyof typeof HarmonyType];
|
|
28
|
+
/**
|
|
29
|
+
* Represents a cursor position and color data on the color wheel.
|
|
30
|
+
*/
|
|
31
|
+
export interface CursorData {
|
|
32
|
+
/** Unique identifier for the cursor */
|
|
33
|
+
id: number;
|
|
34
|
+
/** X coordinate position on the color wheel canvas */
|
|
35
|
+
x: number;
|
|
36
|
+
/** Y coordinate position on the color wheel canvas */
|
|
37
|
+
y: number;
|
|
38
|
+
/** Hex color value associated with this cursor position */
|
|
39
|
+
color: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Props for the ColorWheel component.
|
|
43
|
+
*/
|
|
44
|
+
export interface ColorWheelProps {
|
|
45
|
+
/** Radius of the color wheel in pixels. Defaults to a standard size if not provided. */
|
|
46
|
+
radius?: number;
|
|
47
|
+
/** Callback function invoked when colors change. Receives an array of cursor data. */
|
|
48
|
+
onChange?: (colors: CursorData[]) => void;
|
|
49
|
+
/** Number of color cursors to display on the wheel */
|
|
50
|
+
quantityOfColors?: number;
|
|
51
|
+
/** Type of color harmony to apply to the color selection */
|
|
52
|
+
harmony?: HarmonyType;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const drawColorWheel: (ctx: CanvasRenderingContext2D, radius: number) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CursorData, HarmonyType } from '../types/colorWheel';
|
|
2
|
+
interface HandleCursorMoveParams {
|
|
3
|
+
clientX: number;
|
|
4
|
+
clientY: number;
|
|
5
|
+
indexToUpdate: number;
|
|
6
|
+
containerRect: DOMRect;
|
|
7
|
+
radius: number;
|
|
8
|
+
harmony: HarmonyType;
|
|
9
|
+
quantityOfColors: number;
|
|
10
|
+
cursorProps: CursorData[];
|
|
11
|
+
getColorFromCanvas: (x: number, y: number) => string;
|
|
12
|
+
onChange?: (colors: CursorData[]) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const handleCursorMove: ({ clientX, clientY, indexToUpdate, containerRect, radius, harmony, quantityOfColors, cursorProps, getColorFromCanvas, onChange, }: HandleCursorMoveParams) => CursorData[];
|
|
15
|
+
export {};
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-color-palette-wheel",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "tsc -b && vite build",
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"prepublishOnly": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"files": ["dist"],
|
|
13
|
+
"main": "./dist/react-color-palette-wheel.umd.js",
|
|
14
|
+
"module": "./dist/react-color-palette-wheel.es.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/react-color-palette-wheel.es.js",
|
|
19
|
+
"require": "./dist/react-color-palette-wheel.umd.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"colord": "^2.9.3"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@eslint/js": "^9.39.1",
|
|
27
|
+
"@types/node": "^24.10.1",
|
|
28
|
+
"@types/react": "^19.2.5",
|
|
29
|
+
"@types/react-dom": "^19.2.3",
|
|
30
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
31
|
+
"eslint": "^9.39.1",
|
|
32
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
33
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
34
|
+
"globals": "^16.5.0",
|
|
35
|
+
"typescript": "~5.9.3",
|
|
36
|
+
"typescript-eslint": "^8.46.4",
|
|
37
|
+
"vite": "^7.2.4",
|
|
38
|
+
"vite-plugin-dts": "^4.5.4",
|
|
39
|
+
"react": "^19.2.0",
|
|
40
|
+
"react-dom": "^19.2.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": ">=19.0.0",
|
|
44
|
+
"react-dom": ">=19.0.0"
|
|
45
|
+
}
|
|
46
|
+
}
|