chroma-panel 0.2.0 → 1.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/README.md +46 -8
- package/dist/a11y/contrast.cjs +94 -0
- package/dist/a11y/contrast.d.cts +8 -0
- package/dist/a11y/contrast.d.ts +8 -0
- package/dist/a11y/contrast.js +93 -2
- package/dist/color/css4.cjs +397 -0
- package/dist/color/css4.d.cts +10 -0
- package/dist/color/css4.d.ts +10 -0
- package/dist/color/css4.js +392 -0
- package/dist/color/parse.cjs +3 -1
- package/dist/color/parse.js +3 -1
- package/dist/color/types.d.cts +16 -0
- package/dist/color/types.d.ts +16 -0
- package/dist/color/value.cjs +11 -0
- package/dist/color/value.d.cts +4 -0
- package/dist/color/value.d.ts +4 -0
- package/dist/color/value.js +12 -0
- package/dist/color.cjs +43 -0
- package/dist/color.d.cts +9 -0
- package/dist/color.d.ts +9 -0
- package/dist/color.js +8 -0
- package/dist/components/ChromaPanel.cjs +16 -6
- package/dist/components/ChromaPanel.d.cts +4 -2
- package/dist/components/ChromaPanel.d.ts +4 -2
- package/dist/components/ChromaPanel.js +16 -6
- package/dist/components/ColorInput.cjs +1 -1
- package/dist/components/ColorInput.js +1 -1
- package/dist/components/PanelFooter.cjs +4 -4
- package/dist/components/PanelFooter.js +4 -4
- package/dist/contrast.cjs +3 -0
- package/dist/contrast.d.cts +2 -2
- package/dist/contrast.d.ts +2 -2
- package/dist/contrast.js +2 -2
- package/dist/core/store.cjs +17 -9
- package/dist/core/store.d.cts +6 -6
- package/dist/core/store.d.ts +6 -6
- package/dist/core/store.js +17 -9
- package/dist/core.cjs +10 -0
- package/dist/core.d.cts +4 -2
- package/dist/core.d.ts +4 -2
- package/dist/core.js +3 -1
- package/dist/export/tokens.cjs +39 -0
- package/dist/export/tokens.d.cts +16 -0
- package/dist/export/tokens.d.ts +16 -0
- package/dist/export/tokens.js +37 -0
- package/dist/export.cjs +6 -0
- package/dist/export.d.cts +2 -0
- package/dist/export.d.ts +2 -0
- package/dist/export.js +2 -0
- package/dist/gradient/GradientEditor.cjs +196 -0
- package/dist/gradient/GradientEditor.d.cts +17 -0
- package/dist/gradient/GradientEditor.d.ts +17 -0
- package/dist/gradient/GradientEditor.js +195 -0
- package/dist/gradient/model.cjs +63 -0
- package/dist/gradient/model.d.cts +23 -0
- package/dist/gradient/model.d.ts +23 -0
- package/dist/gradient/model.js +60 -0
- package/dist/gradient.cjs +9 -0
- package/dist/gradient.d.cts +3 -0
- package/dist/gradient.d.ts +3 -0
- package/dist/gradient.js +3 -0
- package/dist/index.cjs +13 -0
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/modes/image/index.cjs +65 -4
- package/dist/modes/image/index.d.cts +1 -0
- package/dist/modes/image/index.d.ts +1 -0
- package/dist/modes/image/index.js +65 -4
- package/dist/modes/registry.d.cts +1 -1
- package/dist/modes/registry.d.ts +1 -1
- package/dist/modes.cjs +30 -0
- package/dist/modes.d.cts +10 -0
- package/dist/modes.d.ts +10 -0
- package/dist/modes.js +17 -0
- package/dist/panel.cjs +10 -0
- package/dist/panel.d.cts +4 -2
- package/dist/panel.d.ts +4 -2
- package/dist/panel.js +3 -1
- package/dist/primitives/ChannelSlider.cjs +4 -4
- package/dist/primitives/ChannelSlider.js +4 -4
- package/dist/primitives/ColorArea.cjs +6 -6
- package/dist/primitives/ColorArea.js +6 -6
- package/dist/primitives/ColorDisc.cjs +6 -6
- package/dist/primitives/ColorDisc.js +6 -6
- package/dist/primitives/ColorField.cjs +2 -2
- package/dist/primitives/ColorField.js +2 -2
- package/dist/primitives/NumberField.cjs +2 -2
- package/dist/primitives/NumberField.js +2 -2
- package/dist/primitives/SwatchGrid.cjs +2 -2
- package/dist/primitives/SwatchGrid.js +2 -2
- package/package.json +46 -2
|
@@ -42,8 +42,8 @@ function ChannelSlider(props) {
|
|
|
42
42
|
});
|
|
43
43
|
const drag = usePointerDrag({
|
|
44
44
|
disabled,
|
|
45
|
-
onMove: ({ x }) => store.set(write(min + x * (max - min), store.get())),
|
|
46
|
-
onEnd: () => store.commit()
|
|
45
|
+
onMove: ({ x }) => store.set(write(min + x * (max - min), store.get()), "pointer"),
|
|
46
|
+
onEnd: () => store.commit("pointer")
|
|
47
47
|
});
|
|
48
48
|
const initial = read(store.get());
|
|
49
49
|
const track = /* @__PURE__ */ jsxs("div", {
|
|
@@ -69,8 +69,8 @@ function ChannelSlider(props) {
|
|
|
69
69
|
step: step ?? 1,
|
|
70
70
|
defaultValue: initial,
|
|
71
71
|
disabled,
|
|
72
|
-
onInput: (v) => store.set(write(v, store.get())),
|
|
73
|
-
onCommit: () => store.commit()
|
|
72
|
+
onInput: (v) => store.set(write(v, store.get()), "keyboard"),
|
|
73
|
+
onCommit: () => store.commit("keyboard")
|
|
74
74
|
}),
|
|
75
75
|
/* @__PURE__ */ jsx("div", {
|
|
76
76
|
className: cx("cp-thumb", classNames.thumb),
|
|
@@ -35,8 +35,8 @@ function ColorArea(props) {
|
|
|
35
35
|
onMove: ({ x, y }) => store.patch({
|
|
36
36
|
s: x * 100,
|
|
37
37
|
v: (1 - y) * 100
|
|
38
|
-
}),
|
|
39
|
-
onEnd: () => store.commit()
|
|
38
|
+
}, "pointer"),
|
|
39
|
+
onEnd: () => store.commit("pointer")
|
|
40
40
|
});
|
|
41
41
|
const initial = store.get();
|
|
42
42
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -61,8 +61,8 @@ function ColorArea(props) {
|
|
|
61
61
|
max: 100,
|
|
62
62
|
defaultValue: Math.round(initial.s),
|
|
63
63
|
disabled,
|
|
64
|
-
onInput: (s) => store.patch({ s }),
|
|
65
|
-
onCommit: () => store.commit()
|
|
64
|
+
onInput: (s) => store.patch({ s }, "keyboard"),
|
|
65
|
+
onCommit: () => store.commit("keyboard")
|
|
66
66
|
}),
|
|
67
67
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AxisInput.AxisInput, {
|
|
68
68
|
ref: valRef,
|
|
@@ -71,8 +71,8 @@ function ColorArea(props) {
|
|
|
71
71
|
max: 100,
|
|
72
72
|
defaultValue: Math.round(initial.v),
|
|
73
73
|
disabled,
|
|
74
|
-
onInput: (v) => store.patch({ v }),
|
|
75
|
-
onCommit: () => store.commit()
|
|
74
|
+
onInput: (v) => store.patch({ v }, "keyboard"),
|
|
75
|
+
onCommit: () => store.commit("keyboard")
|
|
76
76
|
}),
|
|
77
77
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
78
78
|
className: require_context.cx("cp-thumb", classNames.thumb),
|
|
@@ -33,8 +33,8 @@ function ColorArea(props) {
|
|
|
33
33
|
onMove: ({ x, y }) => store.patch({
|
|
34
34
|
s: x * 100,
|
|
35
35
|
v: (1 - y) * 100
|
|
36
|
-
}),
|
|
37
|
-
onEnd: () => store.commit()
|
|
36
|
+
}, "pointer"),
|
|
37
|
+
onEnd: () => store.commit("pointer")
|
|
38
38
|
});
|
|
39
39
|
const initial = store.get();
|
|
40
40
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -59,8 +59,8 @@ function ColorArea(props) {
|
|
|
59
59
|
max: 100,
|
|
60
60
|
defaultValue: Math.round(initial.s),
|
|
61
61
|
disabled,
|
|
62
|
-
onInput: (s) => store.patch({ s }),
|
|
63
|
-
onCommit: () => store.commit()
|
|
62
|
+
onInput: (s) => store.patch({ s }, "keyboard"),
|
|
63
|
+
onCommit: () => store.commit("keyboard")
|
|
64
64
|
}),
|
|
65
65
|
/* @__PURE__ */ jsx(AxisInput, {
|
|
66
66
|
ref: valRef,
|
|
@@ -69,8 +69,8 @@ function ColorArea(props) {
|
|
|
69
69
|
max: 100,
|
|
70
70
|
defaultValue: Math.round(initial.v),
|
|
71
71
|
disabled,
|
|
72
|
-
onInput: (v) => store.patch({ v }),
|
|
73
|
-
onCommit: () => store.commit()
|
|
72
|
+
onInput: (v) => store.patch({ v }, "keyboard"),
|
|
73
|
+
onCommit: () => store.commit("keyboard")
|
|
74
74
|
}),
|
|
75
75
|
/* @__PURE__ */ jsx("div", {
|
|
76
76
|
className: cx("cp-thumb", classNames.thumb),
|
|
@@ -41,9 +41,9 @@ function ColorDisc(props) {
|
|
|
41
41
|
const distance = Math.min(Math.hypot(dx, dy), .5);
|
|
42
42
|
const patch = { s: distance / .5 * 100 };
|
|
43
43
|
if (distance > 1e-6) patch.h = require_convert.normalizeHue(Math.atan2(dx, -dy) * 180 / Math.PI);
|
|
44
|
-
store.patch(patch);
|
|
44
|
+
store.patch(patch, "pointer");
|
|
45
45
|
},
|
|
46
|
-
onEnd: () => store.commit()
|
|
46
|
+
onEnd: () => store.commit("pointer")
|
|
47
47
|
});
|
|
48
48
|
const initial = store.get();
|
|
49
49
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -70,8 +70,8 @@ function ColorDisc(props) {
|
|
|
70
70
|
max: 360,
|
|
71
71
|
defaultValue: Math.round(require_convert.normalizeHue(initial.h)),
|
|
72
72
|
disabled,
|
|
73
|
-
onInput: (h) => store.patch({ h }),
|
|
74
|
-
onCommit: () => store.commit()
|
|
73
|
+
onInput: (h) => store.patch({ h }, "keyboard"),
|
|
74
|
+
onCommit: () => store.commit("keyboard")
|
|
75
75
|
}),
|
|
76
76
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AxisInput.AxisInput, {
|
|
77
77
|
ref: satRef,
|
|
@@ -80,8 +80,8 @@ function ColorDisc(props) {
|
|
|
80
80
|
max: 100,
|
|
81
81
|
defaultValue: Math.round(initial.s),
|
|
82
82
|
disabled,
|
|
83
|
-
onInput: (s) => store.patch({ s }),
|
|
84
|
-
onCommit: () => store.commit()
|
|
83
|
+
onInput: (s) => store.patch({ s }, "keyboard"),
|
|
84
|
+
onCommit: () => store.commit("keyboard")
|
|
85
85
|
}),
|
|
86
86
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
87
87
|
className: require_context.cx("cp-thumb", classNames.thumb),
|
|
@@ -39,9 +39,9 @@ function ColorDisc(props) {
|
|
|
39
39
|
const distance = Math.min(Math.hypot(dx, dy), .5);
|
|
40
40
|
const patch = { s: distance / .5 * 100 };
|
|
41
41
|
if (distance > 1e-6) patch.h = normalizeHue(Math.atan2(dx, -dy) * 180 / Math.PI);
|
|
42
|
-
store.patch(patch);
|
|
42
|
+
store.patch(patch, "pointer");
|
|
43
43
|
},
|
|
44
|
-
onEnd: () => store.commit()
|
|
44
|
+
onEnd: () => store.commit("pointer")
|
|
45
45
|
});
|
|
46
46
|
const initial = store.get();
|
|
47
47
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -68,8 +68,8 @@ function ColorDisc(props) {
|
|
|
68
68
|
max: 360,
|
|
69
69
|
defaultValue: Math.round(normalizeHue(initial.h)),
|
|
70
70
|
disabled,
|
|
71
|
-
onInput: (h) => store.patch({ h }),
|
|
72
|
-
onCommit: () => store.commit()
|
|
71
|
+
onInput: (h) => store.patch({ h }, "keyboard"),
|
|
72
|
+
onCommit: () => store.commit("keyboard")
|
|
73
73
|
}),
|
|
74
74
|
/* @__PURE__ */ jsx(AxisInput, {
|
|
75
75
|
ref: satRef,
|
|
@@ -78,8 +78,8 @@ function ColorDisc(props) {
|
|
|
78
78
|
max: 100,
|
|
79
79
|
defaultValue: Math.round(initial.s),
|
|
80
80
|
disabled,
|
|
81
|
-
onInput: (s) => store.patch({ s }),
|
|
82
|
-
onCommit: () => store.commit()
|
|
81
|
+
onInput: (s) => store.patch({ s }, "keyboard"),
|
|
82
|
+
onCommit: () => store.commit("keyboard")
|
|
83
83
|
}),
|
|
84
84
|
/* @__PURE__ */ jsx("div", {
|
|
85
85
|
className: cx("cp-thumb", classNames.thumb),
|
|
@@ -30,7 +30,7 @@ function ColorField(props) {
|
|
|
30
30
|
const handleChange = (event) => {
|
|
31
31
|
const parsed = require_parse.parse(event.currentTarget.value);
|
|
32
32
|
event.currentTarget.setAttribute("aria-invalid", parsed === null ? "true" : "false");
|
|
33
|
-
if (parsed !== null) store.ingest(parsed);
|
|
33
|
+
if (parsed !== null) store.ingest(parsed, "field");
|
|
34
34
|
};
|
|
35
35
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
36
36
|
className: require_context.cx("cp-field", classNames.field, className),
|
|
@@ -56,7 +56,7 @@ function ColorField(props) {
|
|
|
56
56
|
focused.current = false;
|
|
57
57
|
e.currentTarget.value = render(store.get());
|
|
58
58
|
e.currentTarget.setAttribute("aria-invalid", "false");
|
|
59
|
-
store.commit();
|
|
59
|
+
store.commit("field");
|
|
60
60
|
},
|
|
61
61
|
onKeyDown: (e) => {
|
|
62
62
|
if (e.key === "Enter") e.currentTarget.blur();
|
|
@@ -28,7 +28,7 @@ function ColorField(props) {
|
|
|
28
28
|
const handleChange = (event) => {
|
|
29
29
|
const parsed = parse(event.currentTarget.value);
|
|
30
30
|
event.currentTarget.setAttribute("aria-invalid", parsed === null ? "true" : "false");
|
|
31
|
-
if (parsed !== null) store.ingest(parsed);
|
|
31
|
+
if (parsed !== null) store.ingest(parsed, "field");
|
|
32
32
|
};
|
|
33
33
|
return /* @__PURE__ */ jsxs("div", {
|
|
34
34
|
className: cx("cp-field", classNames.field, className),
|
|
@@ -54,7 +54,7 @@ function ColorField(props) {
|
|
|
54
54
|
focused.current = false;
|
|
55
55
|
e.currentTarget.value = render(store.get());
|
|
56
56
|
e.currentTarget.setAttribute("aria-invalid", "false");
|
|
57
|
-
store.commit();
|
|
57
|
+
store.commit("field");
|
|
58
58
|
},
|
|
59
59
|
onKeyDown: (e) => {
|
|
60
60
|
if (e.key === "Enter") e.currentTarget.blur();
|
|
@@ -51,12 +51,12 @@ function NumberField(props) {
|
|
|
51
51
|
onChange: (e) => {
|
|
52
52
|
const raw = e.currentTarget.valueAsNumber;
|
|
53
53
|
if (Number.isNaN(raw)) return;
|
|
54
|
-
store.set(fns.current.write(require_convert.clamp(raw, min, max), store.get()));
|
|
54
|
+
store.set(fns.current.write(require_convert.clamp(raw, min, max), store.get()), "field");
|
|
55
55
|
},
|
|
56
56
|
onBlur: (e) => {
|
|
57
57
|
focused.current = false;
|
|
58
58
|
e.currentTarget.value = String(Math.round(fns.current.read(store.get())));
|
|
59
|
-
store.commit();
|
|
59
|
+
store.commit("field");
|
|
60
60
|
}
|
|
61
61
|
})]
|
|
62
62
|
});
|
|
@@ -49,12 +49,12 @@ function NumberField(props) {
|
|
|
49
49
|
onChange: (e) => {
|
|
50
50
|
const raw = e.currentTarget.valueAsNumber;
|
|
51
51
|
if (Number.isNaN(raw)) return;
|
|
52
|
-
store.set(fns.current.write(clamp(raw, min, max), store.get()));
|
|
52
|
+
store.set(fns.current.write(clamp(raw, min, max), store.get()), "field");
|
|
53
53
|
},
|
|
54
54
|
onBlur: (e) => {
|
|
55
55
|
focused.current = false;
|
|
56
56
|
e.currentTarget.value = String(Math.round(fns.current.read(store.get())));
|
|
57
|
-
store.commit();
|
|
57
|
+
store.commit("field");
|
|
58
58
|
}
|
|
59
59
|
})]
|
|
60
60
|
});
|
|
@@ -28,8 +28,8 @@ function SwatchGrid(props) {
|
|
|
28
28
|
if (target === null) return;
|
|
29
29
|
const parsed = require_parse.parse(target.getAttribute("data-cp-color") ?? "");
|
|
30
30
|
if (parsed === null) return;
|
|
31
|
-
store.ingest(parsed);
|
|
32
|
-
store.commit();
|
|
31
|
+
store.ingest(parsed, "swatch");
|
|
32
|
+
store.commit("swatch");
|
|
33
33
|
};
|
|
34
34
|
const grid = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
35
35
|
ref: gridRef,
|
|
@@ -26,8 +26,8 @@ function SwatchGrid(props) {
|
|
|
26
26
|
if (target === null) return;
|
|
27
27
|
const parsed = parse(target.getAttribute("data-cp-color") ?? "");
|
|
28
28
|
if (parsed === null) return;
|
|
29
|
-
store.ingest(parsed);
|
|
30
|
-
store.commit();
|
|
29
|
+
store.ingest(parsed, "swatch");
|
|
30
|
+
store.commit("swatch");
|
|
31
31
|
};
|
|
32
32
|
const grid = /* @__PURE__ */ jsx("ul", {
|
|
33
33
|
ref: gridRef,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chroma-panel",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Accessible React color picker
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Accessible React color picker with CSS Color 4, gradients, color wheel, sliders, palettes, image sampling and an eyedropper. Zero dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react color picker",
|
|
7
7
|
"react color picker component",
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
"color-picker",
|
|
26
26
|
"colour-picker",
|
|
27
27
|
"image-color-picker",
|
|
28
|
+
"gradient-color-picker",
|
|
29
|
+
"oklch-color-picker",
|
|
30
|
+
"display-p3",
|
|
31
|
+
"design-tokens",
|
|
28
32
|
"eyedropper",
|
|
29
33
|
"zero-dependency"
|
|
30
34
|
],
|
|
@@ -77,6 +81,16 @@
|
|
|
77
81
|
"default": "./dist/core.cjs"
|
|
78
82
|
}
|
|
79
83
|
},
|
|
84
|
+
"./color": {
|
|
85
|
+
"import": {
|
|
86
|
+
"types": "./dist/color.d.ts",
|
|
87
|
+
"default": "./dist/color.js"
|
|
88
|
+
},
|
|
89
|
+
"require": {
|
|
90
|
+
"types": "./dist/color.d.cts",
|
|
91
|
+
"default": "./dist/color.cjs"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
80
94
|
"./panel": {
|
|
81
95
|
"import": {
|
|
82
96
|
"types": "./dist/panel.d.ts",
|
|
@@ -157,6 +171,36 @@
|
|
|
157
171
|
"default": "./dist/contrast.cjs"
|
|
158
172
|
}
|
|
159
173
|
},
|
|
174
|
+
"./gradient": {
|
|
175
|
+
"import": {
|
|
176
|
+
"types": "./dist/gradient.d.ts",
|
|
177
|
+
"default": "./dist/gradient.js"
|
|
178
|
+
},
|
|
179
|
+
"require": {
|
|
180
|
+
"types": "./dist/gradient.d.cts",
|
|
181
|
+
"default": "./dist/gradient.cjs"
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"./modes": {
|
|
185
|
+
"import": {
|
|
186
|
+
"types": "./dist/modes.d.ts",
|
|
187
|
+
"default": "./dist/modes.js"
|
|
188
|
+
},
|
|
189
|
+
"require": {
|
|
190
|
+
"types": "./dist/modes.d.cts",
|
|
191
|
+
"default": "./dist/modes.cjs"
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"./export": {
|
|
195
|
+
"import": {
|
|
196
|
+
"types": "./dist/export.d.ts",
|
|
197
|
+
"default": "./dist/export.js"
|
|
198
|
+
},
|
|
199
|
+
"require": {
|
|
200
|
+
"types": "./dist/export.d.cts",
|
|
201
|
+
"default": "./dist/export.cjs"
|
|
202
|
+
}
|
|
203
|
+
},
|
|
160
204
|
"./image-worker": "./dist/image-worker.js",
|
|
161
205
|
"./styles.css": "./dist/style.css",
|
|
162
206
|
"./style.css": "./dist/style.css",
|