chroma-panel 0.1.4 → 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 +47 -9
- 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 +21 -7
- package/dist/components/ChromaPanel.d.cts +5 -2
- package/dist/components/ChromaPanel.d.ts +5 -2
- package/dist/components/ChromaPanel.js +21 -7
- package/dist/components/ColorInput.cjs +1 -1
- package/dist/components/ColorInput.js +1 -1
- package/dist/components/PanelFooter.cjs +37 -4
- package/dist/components/PanelFooter.js +39 -6
- 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/context.d.cts +3 -0
- package/dist/core/context.d.ts +3 -0
- 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/image/extract.cjs +23 -6
- package/dist/image/extract.d.cts +2 -0
- package/dist/image/extract.d.ts +2 -0
- package/dist/image/extract.js +23 -6
- 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 +155 -14
- package/dist/modes/image/index.d.cts +1 -0
- package/dist/modes/image/index.d.ts +1 -0
- package/dist/modes/image/index.js +155 -14
- 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/dist/primitives/icons.cjs +8 -0
- package/dist/primitives/icons.d.cts +1 -1
- package/dist/primitives/icons.d.ts +1 -1
- package/dist/primitives/icons.js +8 -0
- package/dist/style.css +1 -1
- package/dist/styles/css.cjs +1 -1
- package/dist/styles/css.js +1 -1
- package/package.json +46 -2
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { usePanel } from "../../core/context.js";
|
|
3
|
+
import { rgbaToHsva } from "../../color/convert.js";
|
|
4
|
+
import { parse } from "../../color/parse.js";
|
|
3
5
|
import { Icon, ImageIcon } from "../../primitives/icons.js";
|
|
4
6
|
import { SwatchGrid } from "../../primitives/SwatchGrid.js";
|
|
5
7
|
import { extractPalette } from "../../image/extract.js";
|
|
@@ -14,7 +16,7 @@ const EMPTY = {
|
|
|
14
16
|
preview: null
|
|
15
17
|
};
|
|
16
18
|
function ImagePanel(props) {
|
|
17
|
-
const { extractOptions } = props;
|
|
19
|
+
const { extractOptions, sortBy = "population" } = props;
|
|
18
20
|
const { idPrefix, disabled } = usePanel();
|
|
19
21
|
const inputId = `${idPrefix}-image-file`;
|
|
20
22
|
const { store } = usePanel();
|
|
@@ -23,7 +25,13 @@ function ImagePanel(props) {
|
|
|
23
25
|
const [message, setMessage] = React.useState(restored.message);
|
|
24
26
|
const [swatches, setSwatches] = React.useState(restored.swatches);
|
|
25
27
|
const [preview, setPreview] = React.useState(restored.preview);
|
|
28
|
+
const [point, setPoint] = React.useState(null);
|
|
26
29
|
const inputRef = React.useRef(null);
|
|
30
|
+
const imageRef = React.useRef(null);
|
|
31
|
+
const [clipboardRead, setClipboardRead] = React.useState(false);
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
setClipboardRead(typeof navigator.clipboard?.read === "function");
|
|
34
|
+
}, []);
|
|
27
35
|
React.useEffect(() => {
|
|
28
36
|
if (preview === null && status === "idle") kept.delete(store);
|
|
29
37
|
else kept.set(store, {
|
|
@@ -82,6 +90,50 @@ function ImagePanel(props) {
|
|
|
82
90
|
const file = files?.[0];
|
|
83
91
|
if (file !== void 0) run(file);
|
|
84
92
|
};
|
|
93
|
+
const pasteFile = (items) => {
|
|
94
|
+
for (const item of Array.from(items)) {
|
|
95
|
+
if (item.kind !== "file" || !item.type.startsWith("image/")) continue;
|
|
96
|
+
const file = item.getAsFile();
|
|
97
|
+
if (file !== null) run(file);
|
|
98
|
+
return file !== null;
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
};
|
|
102
|
+
const readClipboard = async () => {
|
|
103
|
+
try {
|
|
104
|
+
const items = await navigator.clipboard.read();
|
|
105
|
+
for (const item of items) {
|
|
106
|
+
const type = item.types.find((candidate) => candidate.startsWith("image/"));
|
|
107
|
+
if (type === void 0) continue;
|
|
108
|
+
const blob = await item.getType(type);
|
|
109
|
+
await run(new File([blob], "clipboard-image", { type }));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
setStatus("error");
|
|
113
|
+
setMessage("The clipboard does not contain an image.");
|
|
114
|
+
} catch {
|
|
115
|
+
setStatus("error");
|
|
116
|
+
setMessage("Clipboard access was not allowed. Use paste or choose a file instead.");
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const sortedSwatches = React.useMemo(() => [...swatches].sort((a, b) => {
|
|
120
|
+
if (sortBy === "population") return b.population - a.population;
|
|
121
|
+
if (sortBy === "luminance") {
|
|
122
|
+
const luminance = (rgb) => .2126 * rgb[0] + .7152 * rgb[1] + .0722 * rgb[2];
|
|
123
|
+
return luminance(b.rgb) - luminance(a.rgb);
|
|
124
|
+
}
|
|
125
|
+
return rgbaToHsva({
|
|
126
|
+
r: a.rgb[0],
|
|
127
|
+
g: a.rgb[1],
|
|
128
|
+
b: a.rgb[2],
|
|
129
|
+
a: 1
|
|
130
|
+
}).h - rgbaToHsva({
|
|
131
|
+
r: b.rgb[0],
|
|
132
|
+
g: b.rgb[1],
|
|
133
|
+
b: b.rgb[2],
|
|
134
|
+
a: 1
|
|
135
|
+
}).h;
|
|
136
|
+
}), [swatches, sortBy]);
|
|
85
137
|
const clear = () => {
|
|
86
138
|
controller.current?.abort();
|
|
87
139
|
releasePreview();
|
|
@@ -89,8 +141,47 @@ function ImagePanel(props) {
|
|
|
89
141
|
setSwatches([]);
|
|
90
142
|
setMessage("");
|
|
91
143
|
setStatus("idle");
|
|
144
|
+
setPoint(null);
|
|
92
145
|
if (inputRef.current !== null) inputRef.current.value = "";
|
|
93
146
|
};
|
|
147
|
+
const locate = (image, clientX, clientY) => {
|
|
148
|
+
const rect = image.getBoundingClientRect();
|
|
149
|
+
if (rect.width <= 0 || rect.height <= 0 || image.naturalWidth <= 0 || image.naturalHeight <= 0) return null;
|
|
150
|
+
const scale = Math.min(rect.width / image.naturalWidth, rect.height / image.naturalHeight);
|
|
151
|
+
const width = image.naturalWidth * scale;
|
|
152
|
+
const height = image.naturalHeight * scale;
|
|
153
|
+
const left = rect.left + (rect.width - width) / 2;
|
|
154
|
+
const top = rect.top + (rect.height - height) / 2;
|
|
155
|
+
if (clientX < left || clientX > left + width || clientY < top || clientY > top + height) return null;
|
|
156
|
+
return {
|
|
157
|
+
x: Math.min(1, Math.max(0, (clientX - left) / width)),
|
|
158
|
+
y: Math.min(1, Math.max(0, (clientY - top) / height)),
|
|
159
|
+
left: Math.min(1, Math.max(0, (clientX - rect.left) / rect.width)),
|
|
160
|
+
top: Math.min(1, Math.max(0, (clientY - rect.top) / rect.height))
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
const selectPixel = (next) => {
|
|
164
|
+
const image = imageRef.current;
|
|
165
|
+
if (image === null || image.naturalWidth <= 0 || image.naturalHeight <= 0) return;
|
|
166
|
+
const canvas = document.createElement("canvas");
|
|
167
|
+
canvas.width = 1;
|
|
168
|
+
canvas.height = 1;
|
|
169
|
+
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
170
|
+
if (context === null) return;
|
|
171
|
+
const sx = Math.min(image.naturalWidth - 1, Math.floor(next.x * image.naturalWidth));
|
|
172
|
+
const sy = Math.min(image.naturalHeight - 1, Math.floor(next.y * image.naturalHeight));
|
|
173
|
+
context.drawImage(image, sx, sy, 1, 1, 0, 0, 1, 1);
|
|
174
|
+
const [r = 0, g = 0, b = 0, a = 0] = context.getImageData(0, 0, 1, 1).data;
|
|
175
|
+
if (a === 0) {
|
|
176
|
+
setMessage("That pixel is transparent. Choose another point.");
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const parsed = parse(`rgba(${r}, ${g}, ${b}, ${Math.round(a / 255 * 1e3) / 1e3})`);
|
|
180
|
+
if (parsed === null) return;
|
|
181
|
+
store.ingest(parsed, "image");
|
|
182
|
+
store.commit("image");
|
|
183
|
+
setMessage("Color selected from image.");
|
|
184
|
+
};
|
|
94
185
|
const dragDepth = React.useRef(0);
|
|
95
186
|
const [dragging, setDragging] = React.useState(false);
|
|
96
187
|
const endDrag = () => {
|
|
@@ -99,6 +190,9 @@ function ImagePanel(props) {
|
|
|
99
190
|
};
|
|
100
191
|
return /* @__PURE__ */ jsxs("div", {
|
|
101
192
|
className: "cp-panel",
|
|
193
|
+
onPaste: (event) => {
|
|
194
|
+
if (!disabled && pasteFile(event.clipboardData.items)) event.preventDefault();
|
|
195
|
+
},
|
|
102
196
|
onDragEnter: (e) => {
|
|
103
197
|
e.preventDefault();
|
|
104
198
|
if (disabled) return;
|
|
@@ -143,18 +237,52 @@ function ImagePanel(props) {
|
|
|
143
237
|
]
|
|
144
238
|
}) : /* @__PURE__ */ jsxs("div", {
|
|
145
239
|
className: "cp-image-preview",
|
|
146
|
-
children: [
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ jsx("img", {
|
|
242
|
+
ref: imageRef,
|
|
243
|
+
src: preview,
|
|
244
|
+
alt: "Uploaded image. Move over it and click to select a color.",
|
|
245
|
+
role: "button",
|
|
246
|
+
tabIndex: disabled ? -1 : 0,
|
|
247
|
+
"aria-label": "Pick a color from the uploaded image",
|
|
248
|
+
onPointerMove: (event) => setPoint(locate(event.currentTarget, event.clientX, event.clientY)),
|
|
249
|
+
onPointerLeave: () => setPoint(null),
|
|
250
|
+
onClick: (event) => {
|
|
251
|
+
if (disabled) return;
|
|
252
|
+
const next = locate(event.currentTarget, event.clientX, event.clientY);
|
|
253
|
+
if (next !== null) selectPixel(next);
|
|
254
|
+
},
|
|
255
|
+
onKeyDown: (event) => {
|
|
256
|
+
if (disabled || event.key !== "Enter" && event.key !== " ") return;
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
selectPixel(point ?? {
|
|
259
|
+
x: .5,
|
|
260
|
+
y: .5,
|
|
261
|
+
left: .5,
|
|
262
|
+
top: .5
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}),
|
|
266
|
+
point !== null && /* @__PURE__ */ jsx("span", {
|
|
267
|
+
className: "cp-image-loupe",
|
|
268
|
+
"aria-hidden": "true",
|
|
269
|
+
style: {
|
|
270
|
+
left: `${point.left * 100}%`,
|
|
271
|
+
top: `${point.top * 100}%`,
|
|
272
|
+
backgroundImage: `url("${preview}")`,
|
|
273
|
+
backgroundPosition: `${point.x * 100}% ${point.y * 100}%`
|
|
274
|
+
}
|
|
275
|
+
}),
|
|
276
|
+
/* @__PURE__ */ jsx("button", {
|
|
277
|
+
type: "button",
|
|
278
|
+
className: "cp-image-remove",
|
|
279
|
+
"aria-label": "Remove image",
|
|
280
|
+
title: "Remove image",
|
|
281
|
+
disabled,
|
|
282
|
+
onClick: clear,
|
|
283
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "x" })
|
|
284
|
+
})
|
|
285
|
+
]
|
|
158
286
|
}),
|
|
159
287
|
/* @__PURE__ */ jsx("input", {
|
|
160
288
|
ref: inputRef,
|
|
@@ -167,12 +295,25 @@ function ImagePanel(props) {
|
|
|
167
295
|
tabIndex: preview === null ? void 0 : -1,
|
|
168
296
|
onChange: (e) => onFiles(e.currentTarget.files)
|
|
169
297
|
}),
|
|
298
|
+
preview === null && clipboardRead && /* @__PURE__ */ jsx("button", {
|
|
299
|
+
type: "button",
|
|
300
|
+
className: "cp-button",
|
|
301
|
+
disabled,
|
|
302
|
+
onClick: () => {
|
|
303
|
+
readClipboard();
|
|
304
|
+
},
|
|
305
|
+
children: "Paste image"
|
|
306
|
+
}),
|
|
170
307
|
preview !== null && status === "error" && /* @__PURE__ */ jsx("p", {
|
|
171
308
|
className: "cp-empty",
|
|
172
309
|
children: message
|
|
173
310
|
}),
|
|
311
|
+
preview !== null && status !== "error" && /* @__PURE__ */ jsx("p", {
|
|
312
|
+
className: "cp-image-hint",
|
|
313
|
+
children: "Click the image to pick an exact color."
|
|
314
|
+
}),
|
|
174
315
|
status === "ready" && /* @__PURE__ */ jsx(SwatchGrid, {
|
|
175
|
-
swatches:
|
|
316
|
+
swatches: sortedSwatches.map((s) => ({
|
|
176
317
|
color: s.hex,
|
|
177
318
|
name: s.hex
|
|
178
319
|
})),
|
|
@@ -9,5 +9,5 @@ export interface PickerMode {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function registerMode(mode: PickerMode): void;
|
|
11
11
|
export declare function getMode(id: string): PickerMode | undefined;
|
|
12
|
-
export declare function resolveModes(requested: (string | PickerMode)[]): PickerMode[];
|
|
12
|
+
export declare function resolveModes(requested: readonly (string | PickerMode)[]): PickerMode[];
|
|
13
13
|
//#endregion
|
package/dist/modes/registry.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export interface PickerMode {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function registerMode(mode: PickerMode): void;
|
|
11
11
|
export declare function getMode(id: string): PickerMode | undefined;
|
|
12
|
-
export declare function resolveModes(requested: (string | PickerMode)[]): PickerMode[];
|
|
12
|
+
export declare function resolveModes(requested: readonly (string | PickerMode)[]): PickerMode[];
|
|
13
13
|
//#endregion
|
package/dist/modes.cjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_registry = require("./modes/registry.cjs");
|
|
3
|
+
const require_index = require("./modes/wheel/index.cjs");
|
|
4
|
+
const require_index$1 = require("./modes/sliders/index.cjs");
|
|
5
|
+
const require_index$2 = require("./modes/palettes/index.cjs");
|
|
6
|
+
const require_index$3 = require("./modes/image/index.cjs");
|
|
7
|
+
const require_index$4 = require("./modes/pencils/index.cjs");
|
|
8
|
+
//#region src/modes.ts
|
|
9
|
+
const builtInModes = Object.freeze([
|
|
10
|
+
require_index.wheelMode,
|
|
11
|
+
require_index$1.slidersMode,
|
|
12
|
+
require_index$2.palettesMode,
|
|
13
|
+
require_index$3.imageMode,
|
|
14
|
+
require_index$4.pencilsMode
|
|
15
|
+
]);
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.ImagePanel = require_index$3.ImagePanel;
|
|
18
|
+
exports.PalettesPanel = require_index$2.PalettesPanel;
|
|
19
|
+
exports.PencilsPanel = require_index$4.PencilsPanel;
|
|
20
|
+
exports.SlidersPanel = require_index$1.SlidersPanel;
|
|
21
|
+
exports.WheelPanel = require_index.WheelPanel;
|
|
22
|
+
exports.builtInModes = builtInModes;
|
|
23
|
+
exports.getMode = require_registry.getMode;
|
|
24
|
+
exports.imageMode = require_index$3.imageMode;
|
|
25
|
+
exports.palettesMode = require_index$2.palettesMode;
|
|
26
|
+
exports.pencilsMode = require_index$4.pencilsMode;
|
|
27
|
+
exports.registerMode = require_registry.registerMode;
|
|
28
|
+
exports.resolveModes = require_registry.resolveModes;
|
|
29
|
+
exports.slidersMode = require_index$1.slidersMode;
|
|
30
|
+
exports.wheelMode = require_index.wheelMode;
|
package/dist/modes.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModeId, PickerMode, getMode, registerMode, resolveModes } from "./modes/registry.cjs";
|
|
2
|
+
import { ImagePanel, ImagePanelProps, imageMode } from "./modes/image/index.cjs";
|
|
3
|
+
import { WheelPanel, wheelMode } from "./modes/wheel/index.cjs";
|
|
4
|
+
import { SlidersPanel, slidersMode } from "./modes/sliders/index.cjs";
|
|
5
|
+
import { PalettesPanel, palettesMode } from "./modes/palettes/index.cjs";
|
|
6
|
+
import { PencilsPanel, pencilsMode } from "./modes/pencils/index.cjs";
|
|
7
|
+
//#region src/modes.d.ts
|
|
8
|
+
export declare const builtInModes: readonly PickerMode[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ImagePanel, type ImagePanelProps, type ModeId, PalettesPanel, PencilsPanel, type PickerMode, SlidersPanel, WheelPanel, getMode, imageMode, palettesMode, pencilsMode, registerMode, resolveModes, slidersMode, wheelMode };
|
package/dist/modes.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModeId, PickerMode, getMode, registerMode, resolveModes } from "./modes/registry.js";
|
|
2
|
+
import { ImagePanel, ImagePanelProps, imageMode } from "./modes/image/index.js";
|
|
3
|
+
import { WheelPanel, wheelMode } from "./modes/wheel/index.js";
|
|
4
|
+
import { SlidersPanel, slidersMode } from "./modes/sliders/index.js";
|
|
5
|
+
import { PalettesPanel, palettesMode } from "./modes/palettes/index.js";
|
|
6
|
+
import { PencilsPanel, pencilsMode } from "./modes/pencils/index.js";
|
|
7
|
+
//#region src/modes.d.ts
|
|
8
|
+
export declare const builtInModes: readonly PickerMode[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ImagePanel, type ImagePanelProps, type ModeId, PalettesPanel, PencilsPanel, type PickerMode, SlidersPanel, WheelPanel, getMode, imageMode, palettesMode, pencilsMode, registerMode, resolveModes, slidersMode, wheelMode };
|
package/dist/modes.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getMode, registerMode, resolveModes } from "./modes/registry.js";
|
|
2
|
+
import { WheelPanel, wheelMode } from "./modes/wheel/index.js";
|
|
3
|
+
import { SlidersPanel, slidersMode } from "./modes/sliders/index.js";
|
|
4
|
+
import { PalettesPanel, palettesMode } from "./modes/palettes/index.js";
|
|
5
|
+
import { ImagePanel, imageMode } from "./modes/image/index.js";
|
|
6
|
+
import { PencilsPanel, pencilsMode } from "./modes/pencils/index.js";
|
|
7
|
+
//#region src/modes.ts
|
|
8
|
+
const builtInModes = Object.freeze([
|
|
9
|
+
wheelMode,
|
|
10
|
+
slidersMode,
|
|
11
|
+
palettesMode,
|
|
12
|
+
imageMode,
|
|
13
|
+
pencilsMode
|
|
14
|
+
]);
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ImagePanel, PalettesPanel, PencilsPanel, SlidersPanel, WheelPanel, builtInModes, getMode, imageMode, palettesMode, pencilsMode, registerMode, resolveModes, slidersMode, wheelMode };
|
|
17
|
+
|
package/dist/panel.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const require_useColorStore = require("./core/useColorStore.cjs");
|
|
|
7
7
|
const require_usePointerDrag = require("./core/usePointerDrag.cjs");
|
|
8
8
|
const require_ChannelSlider = require("./primitives/ChannelSlider.cjs");
|
|
9
9
|
const require_ColorDisc = require("./primitives/ColorDisc.cjs");
|
|
10
|
+
const require_css4 = require("./color/css4.cjs");
|
|
10
11
|
const require_parse = require("./color/parse.cjs");
|
|
11
12
|
const require_serialize = require("./color/serialize.cjs");
|
|
12
13
|
const require_ColorField = require("./primitives/ColorField.cjs");
|
|
@@ -25,6 +26,7 @@ const require_Popover = require("./components/Popover.cjs");
|
|
|
25
26
|
const require_ColorInput = require("./components/ColorInput.cjs");
|
|
26
27
|
const require_ColorArea = require("./primitives/ColorArea.cjs");
|
|
27
28
|
const require_Swatch = require("./primitives/Swatch.cjs");
|
|
29
|
+
const require_value = require("./color/value.cjs");
|
|
28
30
|
exports.ChannelSlider = require_ChannelSlider.ChannelSlider;
|
|
29
31
|
exports.ChromaPanel = require_ChromaPanel.ChromaPanel;
|
|
30
32
|
exports.ColorArea = require_ColorArea.ColorArea;
|
|
@@ -41,9 +43,12 @@ exports.Swatch = require_Swatch.Swatch;
|
|
|
41
43
|
exports.SwatchGrid = require_SwatchGrid.SwatchGrid;
|
|
42
44
|
exports.clamp = require_convert.clamp;
|
|
43
45
|
exports.clearNamedColors = require_parse.clearNamedColors;
|
|
46
|
+
exports.colorValueToHsva = require_css4.colorValueToHsva;
|
|
47
|
+
exports.convertColor = require_css4.convertColor;
|
|
44
48
|
exports.createColorStore = require_store.createColorStore;
|
|
45
49
|
exports.getMode = require_registry.getMode;
|
|
46
50
|
exports.hslaToHsva = require_convert.hslaToHsva;
|
|
51
|
+
exports.hsvaToColorValue = require_css4.hsvaToColorValue;
|
|
47
52
|
exports.hsvaToHsl = require_convert.hsvaToHsl;
|
|
48
53
|
exports.hsvaToHsla = require_convert.hsvaToHsla;
|
|
49
54
|
exports.hsvaToHwba = require_convert.hsvaToHwba;
|
|
@@ -52,9 +57,13 @@ exports.hsvaToRgba = require_convert.hsvaToRgba;
|
|
|
52
57
|
exports.hwbaToHsva = require_convert.hwbaToHsva;
|
|
53
58
|
exports.ingest = require_sticky.ingest;
|
|
54
59
|
exports.injectStyles = require_styleInjector.injectStyles;
|
|
60
|
+
exports.isInGamut = require_css4.isInGamut;
|
|
55
61
|
exports.isValidColor = require_parse.isValidColor;
|
|
62
|
+
exports.mapToGamut = require_css4.mapToGamut;
|
|
56
63
|
exports.normalizeHue = require_convert.normalizeHue;
|
|
57
64
|
exports.parse = require_parse.parse;
|
|
65
|
+
exports.parseColor = require_value.parseColor;
|
|
66
|
+
exports.parseCss4Color = require_css4.parseCss4Color;
|
|
58
67
|
exports.pushRecent = require_PanelFooter.pushRecent;
|
|
59
68
|
exports.registerMode = require_registry.registerMode;
|
|
60
69
|
exports.registerNamedColors = require_parse.registerNamedColors;
|
|
@@ -63,6 +72,7 @@ exports.rgbaToHsva = require_convert.rgbaToHsva;
|
|
|
63
72
|
exports.roundRgba = require_convert.roundRgba;
|
|
64
73
|
exports.sameHsva = require_sticky.sameHsva;
|
|
65
74
|
exports.sameRendered = require_sticky.sameRendered;
|
|
75
|
+
exports.serializeColor = require_css4.serializeColor;
|
|
66
76
|
exports.setStyleNonce = require_styleInjector.setStyleNonce;
|
|
67
77
|
exports.toFormat = require_serialize.toFormat;
|
|
68
78
|
exports.toHex = require_serialize.toHex;
|
package/dist/panel.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ColorChangeResult, ColorFormat, Hsl, Hsla, Hsva, Hwb, Hwba, Rgb, Rgba } from "./color/types.cjs";
|
|
1
|
+
import { ColorChangeMeta, ColorChangeResult, ColorChangeSource, ColorFormat, ColorValue, Hsl, Hsla, Hsva, Hwb, Hwba, ModernColorSpace, Rgb, Rgba, SerializeColorOptions } from "./color/types.cjs";
|
|
2
2
|
import { clamp, hslaToHsva, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, normalizeHue, rgbaToHsva, roundRgba } from "./color/convert.cjs";
|
|
3
3
|
import { clearNamedColors, isValidColor, parse, registerNamedColors } from "./color/parse.cjs";
|
|
4
|
+
import { parseColor } from "./color/value.cjs";
|
|
5
|
+
import { colorValueToHsva, convertColor, hsvaToColorValue, isInGamut, mapToGamut, parseCss4Color, serializeColor } from "./color/css4.cjs";
|
|
4
6
|
import { toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString } from "./color/serialize.cjs";
|
|
5
7
|
import { ingest, sameHsva, sameRendered } from "./color/sticky.cjs";
|
|
6
8
|
import { ColorListener, ColorStore, Unsubscribe, createColorStore } from "./core/store.cjs";
|
|
@@ -24,4 +26,4 @@ import { Eyedropper, useEyedropper } from "./primitives/useEyedropper.cjs";
|
|
|
24
26
|
import { useColorValue, useTransientColor } from "./core/useColorStore.cjs";
|
|
25
27
|
import { useAxisKeyboard, usePointerDrag } from "./core/usePointerDrag.cjs";
|
|
26
28
|
import { injectStyles, setStyleNonce } from "./core/styleInjector.cjs";
|
|
27
|
-
export { ChannelSlider, type ChannelSliderProps, type ChromaClassNames, ChromaPanel, type ChromaPanelProps, ColorArea, type ColorAreaProps, ColorChangeResult, ColorDisc, type ColorDiscProps, ColorField, type ColorFieldProps, ColorFormat, ColorInput, type ColorInputProps, type ColorListener, type ColorPalette, type ColorStore, type Eyedropper, Hsl, Hsla, Hsva, Hwb, Hwba, Icon, type IconName, type IconProps, type ModeId, ModeToolbar, type ModeToolbarProps, NumberField, type NumberFieldProps, PanelFooter, type PanelOptions, type PickerMode, Popover, type PopoverProps, Rgb, Rgba, SegmentedControl, type SegmentedControlProps, type SegmentedItem, Swatch, type SwatchEntry, SwatchGrid, type SwatchGridProps, type SwatchProps, type SwatchVariant, type Unsubscribe, clamp, clearNamedColors, createColorStore, getMode, hslaToHsva, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, ingest, injectStyles, isValidColor, normalizeHue, parse, pushRecent, registerMode, registerNamedColors, resolveModes, rgbaToHsva, roundRgba, sameHsva, sameRendered, setStyleNonce, toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString, useAxisKeyboard, useColorValue, useEyedropper, usePanel, usePointerDrag, useTransientColor };
|
|
29
|
+
export { ChannelSlider, type ChannelSliderProps, type ChromaClassNames, ChromaPanel, type ChromaPanelProps, ColorArea, type ColorAreaProps, ColorChangeMeta, ColorChangeResult, ColorChangeSource, ColorDisc, type ColorDiscProps, ColorField, type ColorFieldProps, ColorFormat, ColorInput, type ColorInputProps, type ColorListener, type ColorPalette, type ColorStore, ColorValue, type Eyedropper, Hsl, Hsla, Hsva, Hwb, Hwba, Icon, type IconName, type IconProps, type ModeId, ModeToolbar, type ModeToolbarProps, ModernColorSpace, NumberField, type NumberFieldProps, PanelFooter, type PanelOptions, type PickerMode, Popover, type PopoverProps, Rgb, Rgba, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SerializeColorOptions, Swatch, type SwatchEntry, SwatchGrid, type SwatchGridProps, type SwatchProps, type SwatchVariant, type Unsubscribe, clamp, clearNamedColors, colorValueToHsva, convertColor, createColorStore, getMode, hslaToHsva, hsvaToColorValue, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, ingest, injectStyles, isInGamut, isValidColor, mapToGamut, normalizeHue, parse, parseColor, parseCss4Color, pushRecent, registerMode, registerNamedColors, resolveModes, rgbaToHsva, roundRgba, sameHsva, sameRendered, serializeColor, setStyleNonce, toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString, useAxisKeyboard, useColorValue, useEyedropper, usePanel, usePointerDrag, useTransientColor };
|
package/dist/panel.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ColorChangeResult, ColorFormat, Hsl, Hsla, Hsva, Hwb, Hwba, Rgb, Rgba } from "./color/types.js";
|
|
1
|
+
import { ColorChangeMeta, ColorChangeResult, ColorChangeSource, ColorFormat, ColorValue, Hsl, Hsla, Hsva, Hwb, Hwba, ModernColorSpace, Rgb, Rgba, SerializeColorOptions } from "./color/types.js";
|
|
2
2
|
import { clamp, hslaToHsva, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, normalizeHue, rgbaToHsva, roundRgba } from "./color/convert.js";
|
|
3
3
|
import { clearNamedColors, isValidColor, parse, registerNamedColors } from "./color/parse.js";
|
|
4
|
+
import { parseColor } from "./color/value.js";
|
|
5
|
+
import { colorValueToHsva, convertColor, hsvaToColorValue, isInGamut, mapToGamut, parseCss4Color, serializeColor } from "./color/css4.js";
|
|
4
6
|
import { toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString } from "./color/serialize.js";
|
|
5
7
|
import { ingest, sameHsva, sameRendered } from "./color/sticky.js";
|
|
6
8
|
import { ColorListener, ColorStore, Unsubscribe, createColorStore } from "./core/store.js";
|
|
@@ -24,4 +26,4 @@ import { Eyedropper, useEyedropper } from "./primitives/useEyedropper.js";
|
|
|
24
26
|
import { useColorValue, useTransientColor } from "./core/useColorStore.js";
|
|
25
27
|
import { useAxisKeyboard, usePointerDrag } from "./core/usePointerDrag.js";
|
|
26
28
|
import { injectStyles, setStyleNonce } from "./core/styleInjector.js";
|
|
27
|
-
export { ChannelSlider, type ChannelSliderProps, type ChromaClassNames, ChromaPanel, type ChromaPanelProps, ColorArea, type ColorAreaProps, ColorChangeResult, ColorDisc, type ColorDiscProps, ColorField, type ColorFieldProps, ColorFormat, ColorInput, type ColorInputProps, type ColorListener, type ColorPalette, type ColorStore, type Eyedropper, Hsl, Hsla, Hsva, Hwb, Hwba, Icon, type IconName, type IconProps, type ModeId, ModeToolbar, type ModeToolbarProps, NumberField, type NumberFieldProps, PanelFooter, type PanelOptions, type PickerMode, Popover, type PopoverProps, Rgb, Rgba, SegmentedControl, type SegmentedControlProps, type SegmentedItem, Swatch, type SwatchEntry, SwatchGrid, type SwatchGridProps, type SwatchProps, type SwatchVariant, type Unsubscribe, clamp, clearNamedColors, createColorStore, getMode, hslaToHsva, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, ingest, injectStyles, isValidColor, normalizeHue, parse, pushRecent, registerMode, registerNamedColors, resolveModes, rgbaToHsva, roundRgba, sameHsva, sameRendered, setStyleNonce, toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString, useAxisKeyboard, useColorValue, useEyedropper, usePanel, usePointerDrag, useTransientColor };
|
|
29
|
+
export { ChannelSlider, type ChannelSliderProps, type ChromaClassNames, ChromaPanel, type ChromaPanelProps, ColorArea, type ColorAreaProps, ColorChangeMeta, ColorChangeResult, ColorChangeSource, ColorDisc, type ColorDiscProps, ColorField, type ColorFieldProps, ColorFormat, ColorInput, type ColorInputProps, type ColorListener, type ColorPalette, type ColorStore, ColorValue, type Eyedropper, Hsl, Hsla, Hsva, Hwb, Hwba, Icon, type IconName, type IconProps, type ModeId, ModeToolbar, type ModeToolbarProps, ModernColorSpace, NumberField, type NumberFieldProps, PanelFooter, type PanelOptions, type PickerMode, Popover, type PopoverProps, Rgb, Rgba, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SerializeColorOptions, Swatch, type SwatchEntry, SwatchGrid, type SwatchGridProps, type SwatchProps, type SwatchVariant, type Unsubscribe, clamp, clearNamedColors, colorValueToHsva, convertColor, createColorStore, getMode, hslaToHsva, hsvaToColorValue, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, ingest, injectStyles, isInGamut, isValidColor, mapToGamut, normalizeHue, parse, parseColor, parseCss4Color, pushRecent, registerMode, registerNamedColors, resolveModes, rgbaToHsva, roundRgba, sameHsva, sameRendered, serializeColor, setStyleNonce, toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString, useAxisKeyboard, useColorValue, useEyedropper, usePanel, usePointerDrag, useTransientColor };
|
package/dist/panel.js
CHANGED
|
@@ -6,6 +6,7 @@ import { useColorValue, useTransientColor } from "./core/useColorStore.js";
|
|
|
6
6
|
import { useAxisKeyboard, usePointerDrag } from "./core/usePointerDrag.js";
|
|
7
7
|
import { ChannelSlider } from "./primitives/ChannelSlider.js";
|
|
8
8
|
import { ColorDisc } from "./primitives/ColorDisc.js";
|
|
9
|
+
import { colorValueToHsva, convertColor, hsvaToColorValue, isInGamut, mapToGamut, parseCss4Color, serializeColor } from "./color/css4.js";
|
|
9
10
|
import { clearNamedColors, isValidColor, parse, registerNamedColors } from "./color/parse.js";
|
|
10
11
|
import { toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString } from "./color/serialize.js";
|
|
11
12
|
import { ColorField } from "./primitives/ColorField.js";
|
|
@@ -24,4 +25,5 @@ import { Popover } from "./components/Popover.js";
|
|
|
24
25
|
import { ColorInput } from "./components/ColorInput.js";
|
|
25
26
|
import { ColorArea } from "./primitives/ColorArea.js";
|
|
26
27
|
import { Swatch } from "./primitives/Swatch.js";
|
|
27
|
-
|
|
28
|
+
import { parseColor } from "./color/value.js";
|
|
29
|
+
export { ChannelSlider, ChromaPanel, ColorArea, ColorDisc, ColorField, ColorInput, Icon, ModeToolbar, NumberField, PanelFooter, Popover, SegmentedControl, Swatch, SwatchGrid, clamp, clearNamedColors, colorValueToHsva, convertColor, createColorStore, getMode, hslaToHsva, hsvaToColorValue, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, ingest, injectStyles, isInGamut, isValidColor, mapToGamut, normalizeHue, parse, parseColor, parseCss4Color, pushRecent, registerMode, registerNamedColors, resolveModes, rgbaToHsva, roundRgba, sameHsva, sameRendered, serializeColor, setStyleNonce, toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString, useAxisKeyboard, useColorValue, useEyedropper, usePanel, usePointerDrag, useTransientColor };
|
|
@@ -44,8 +44,8 @@ function ChannelSlider(props) {
|
|
|
44
44
|
});
|
|
45
45
|
const drag = require_usePointerDrag.usePointerDrag({
|
|
46
46
|
disabled,
|
|
47
|
-
onMove: ({ x }) => store.set(write(min + x * (max - min), store.get())),
|
|
48
|
-
onEnd: () => store.commit()
|
|
47
|
+
onMove: ({ x }) => store.set(write(min + x * (max - min), store.get()), "pointer"),
|
|
48
|
+
onEnd: () => store.commit("pointer")
|
|
49
49
|
});
|
|
50
50
|
const initial = read(store.get());
|
|
51
51
|
const track = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -71,8 +71,8 @@ function ChannelSlider(props) {
|
|
|
71
71
|
step: step ?? 1,
|
|
72
72
|
defaultValue: initial,
|
|
73
73
|
disabled,
|
|
74
|
-
onInput: (v) => store.set(write(v, store.get())),
|
|
75
|
-
onCommit: () => store.commit()
|
|
74
|
+
onInput: (v) => store.set(write(v, store.get()), "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),
|
|
@@ -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();
|