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
package/dist/index.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");
|
|
@@ -33,6 +34,7 @@ const require_Popover = require("./components/Popover.cjs");
|
|
|
33
34
|
const require_ColorInput = require("./components/ColorInput.cjs");
|
|
34
35
|
const require_ColorArea = require("./primitives/ColorArea.cjs");
|
|
35
36
|
const require_Swatch = require("./primitives/Swatch.cjs");
|
|
37
|
+
const require_value = require("./color/value.cjs");
|
|
36
38
|
const require_contrast = require("./a11y/contrast.cjs");
|
|
37
39
|
//#region src/index.ts
|
|
38
40
|
require_registry.registerMode(require_index.wheelMode);
|
|
@@ -64,14 +66,19 @@ exports.WheelPanel = require_index.WheelPanel;
|
|
|
64
66
|
exports.apcaContrast = require_contrast.apcaContrast;
|
|
65
67
|
exports.clamp = require_convert.clamp;
|
|
66
68
|
exports.clearNamedColors = require_parse.clearNamedColors;
|
|
69
|
+
exports.colorValueToHsva = require_css4.colorValueToHsva;
|
|
70
|
+
exports.compositeColor = require_contrast.compositeColor;
|
|
67
71
|
exports.contrastRatio = require_contrast.contrastRatio;
|
|
72
|
+
exports.contrastRatioWithAlpha = require_contrast.contrastRatioWithAlpha;
|
|
68
73
|
exports.contrastReport = require_contrast.contrastReport;
|
|
74
|
+
exports.convertColor = require_css4.convertColor;
|
|
69
75
|
exports.createColorStore = require_store.createColorStore;
|
|
70
76
|
exports.defaultPalettes = require_defaults.defaultPalettes;
|
|
71
77
|
exports.defaultPencils = require_defaults.defaultPencils;
|
|
72
78
|
exports.extractPalette = require_extract.extractPalette;
|
|
73
79
|
exports.getMode = require_registry.getMode;
|
|
74
80
|
exports.hslaToHsva = require_convert.hslaToHsva;
|
|
81
|
+
exports.hsvaToColorValue = require_css4.hsvaToColorValue;
|
|
75
82
|
exports.hsvaToHsl = require_convert.hsvaToHsl;
|
|
76
83
|
exports.hsvaToHsla = require_convert.hsvaToHsla;
|
|
77
84
|
exports.hsvaToHwba = require_convert.hsvaToHwba;
|
|
@@ -81,12 +88,16 @@ exports.hwbaToHsva = require_convert.hwbaToHsva;
|
|
|
81
88
|
exports.imageMode = require_index$3.imageMode;
|
|
82
89
|
exports.ingest = require_sticky.ingest;
|
|
83
90
|
exports.injectStyles = require_styleInjector.injectStyles;
|
|
91
|
+
exports.isInGamut = require_css4.isInGamut;
|
|
84
92
|
exports.isValidColor = require_parse.isValidColor;
|
|
93
|
+
exports.mapToGamut = require_css4.mapToGamut;
|
|
85
94
|
exports.meetsContrast = require_contrast.meetsContrast;
|
|
86
95
|
exports.meetsNonTextContrast = require_contrast.meetsNonTextContrast;
|
|
87
96
|
exports.normalizeHue = require_convert.normalizeHue;
|
|
88
97
|
exports.palettesMode = require_index$2.palettesMode;
|
|
89
98
|
exports.parse = require_parse.parse;
|
|
99
|
+
exports.parseColor = require_value.parseColor;
|
|
100
|
+
exports.parseCss4Color = require_css4.parseCss4Color;
|
|
90
101
|
exports.pencilsMode = require_index$4.pencilsMode;
|
|
91
102
|
exports.pushRecent = require_PanelFooter.pushRecent;
|
|
92
103
|
exports.quantize = require_mmcq.quantize;
|
|
@@ -99,8 +110,10 @@ exports.rgbaToHsva = require_convert.rgbaToHsva;
|
|
|
99
110
|
exports.roundRgba = require_convert.roundRgba;
|
|
100
111
|
exports.sameHsva = require_sticky.sameHsva;
|
|
101
112
|
exports.sameRendered = require_sticky.sameRendered;
|
|
113
|
+
exports.serializeColor = require_css4.serializeColor;
|
|
102
114
|
exports.setStyleNonce = require_styleInjector.setStyleNonce;
|
|
103
115
|
exports.slidersMode = require_index$1.slidersMode;
|
|
116
|
+
exports.suggestAccessibleColor = require_contrast.suggestAccessibleColor;
|
|
104
117
|
exports.toFormat = require_serialize.toFormat;
|
|
105
118
|
exports.toHex = require_serialize.toHex;
|
|
106
119
|
exports.toHexa = require_serialize.toHexa;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ColorChangeResult, ColorFormat, Hsl, Hsla, Hsva, Hwb, Hwba, Rgb, Rgba } from "./color/types.cjs";
|
|
2
|
-
import { ContrastOptions, ContrastReport, TextSize, WcagLevel, apcaContrast, contrastRatio, contrastReport, meetsContrast, meetsNonTextContrast, readableTextColor, relativeLuminance, wcagLevel } from "./a11y/contrast.cjs";
|
|
1
|
+
import { ColorChangeMeta, ColorChangeResult, ColorChangeSource, ColorFormat, ColorValue, Hsl, Hsla, Hsva, Hwb, Hwba, ModernColorSpace, Rgb, Rgba, SerializeColorOptions } from "./color/types.cjs";
|
|
3
2
|
import { clamp, hslaToHsva, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, normalizeHue, rgbaToHsva, roundRgba } from "./color/convert.cjs";
|
|
4
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";
|
|
5
6
|
import { toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString } from "./color/serialize.cjs";
|
|
6
7
|
import { ingest, sameHsva, sameRendered } from "./color/sticky.cjs";
|
|
7
8
|
import { ColorListener, ColorStore, Unsubscribe, createColorStore } from "./core/store.cjs";
|
|
9
|
+
import { AccessibleColorSuggestion, ContrastOptions, ContrastReport, TextSize, WcagLevel, apcaContrast, compositeColor, contrastRatio, contrastRatioWithAlpha, contrastReport, meetsContrast, meetsNonTextContrast, readableTextColor, relativeLuminance, suggestAccessibleColor, wcagLevel } from "./a11y/contrast.cjs";
|
|
8
10
|
import { QuantizedSwatch, quantize } from "./image/mmcq.cjs";
|
|
9
11
|
import { ExtractOptions, ExtractResult, extractPalette } from "./image/extract.cjs";
|
|
10
12
|
import { ModeId, PickerMode, getMode, registerMode, resolveModes } from "./modes/registry.cjs";
|
|
@@ -33,4 +35,4 @@ import { PENCIL_COLUMNS, defaultPalettes, defaultPencils } from "./data/defaults
|
|
|
33
35
|
import { useColorValue, useTransientColor } from "./core/useColorStore.cjs";
|
|
34
36
|
import { useAxisKeyboard, usePointerDrag } from "./core/usePointerDrag.cjs";
|
|
35
37
|
import { injectStyles, setStyleNonce } from "./core/styleInjector.cjs";
|
|
36
|
-
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 ContrastOptions, type ContrastReport, type ExtractOptions, type ExtractResult, type Eyedropper, Hsl, Hsla, Hsva, Hwb, Hwba, Icon, type IconName, type IconProps, ImagePanel, type ModeId, ModeToolbar, type ModeToolbarProps, NumberField, type NumberFieldProps, PENCIL_COLUMNS, PalettesPanel, PanelFooter, type PanelOptions, PencilsPanel, type PickerMode, Popover, type PopoverProps, type QuantizedSwatch, Rgb, Rgba, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SlidersPanel, Swatch, type SwatchEntry, SwatchGrid, type SwatchGridProps, type SwatchProps, type SwatchVariant, type TextSize, type Unsubscribe, type WcagLevel, WheelPanel, apcaContrast, clamp, clearNamedColors, contrastRatio, contrastReport, createColorStore, defaultPalettes, defaultPencils, extractPalette, getMode, hslaToHsva, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, imageMode, ingest, injectStyles, isValidColor, meetsContrast, meetsNonTextContrast, normalizeHue, palettesMode, parse, pencilsMode, pushRecent, quantize, readableTextColor, registerMode, registerNamedColors, relativeLuminance, resolveModes, rgbaToHsva, roundRgba, sameHsva, sameRendered, setStyleNonce, slidersMode, toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString, useAxisKeyboard, useColorValue, useEyedropper, usePanel, usePointerDrag, useTransientColor, wcagLevel, wheelMode };
|
|
38
|
+
export { type AccessibleColorSuggestion, 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 ContrastOptions, type ContrastReport, type ExtractOptions, type ExtractResult, type Eyedropper, Hsl, Hsla, Hsva, Hwb, Hwba, Icon, type IconName, type IconProps, ImagePanel, type ModeId, ModeToolbar, type ModeToolbarProps, ModernColorSpace, NumberField, type NumberFieldProps, PENCIL_COLUMNS, PalettesPanel, PanelFooter, type PanelOptions, PencilsPanel, type PickerMode, Popover, type PopoverProps, type QuantizedSwatch, Rgb, Rgba, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SerializeColorOptions, SlidersPanel, Swatch, type SwatchEntry, SwatchGrid, type SwatchGridProps, type SwatchProps, type SwatchVariant, type TextSize, type Unsubscribe, type WcagLevel, WheelPanel, apcaContrast, clamp, clearNamedColors, colorValueToHsva, compositeColor, contrastRatio, contrastRatioWithAlpha, contrastReport, convertColor, createColorStore, defaultPalettes, defaultPencils, extractPalette, getMode, hslaToHsva, hsvaToColorValue, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, imageMode, ingest, injectStyles, isInGamut, isValidColor, mapToGamut, meetsContrast, meetsNonTextContrast, normalizeHue, palettesMode, parse, parseColor, parseCss4Color, pencilsMode, pushRecent, quantize, readableTextColor, registerMode, registerNamedColors, relativeLuminance, resolveModes, rgbaToHsva, roundRgba, sameHsva, sameRendered, serializeColor, setStyleNonce, slidersMode, suggestAccessibleColor, toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString, useAxisKeyboard, useColorValue, useEyedropper, usePanel, usePointerDrag, useTransientColor, wcagLevel, wheelMode };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ColorChangeResult, ColorFormat, Hsl, Hsla, Hsva, Hwb, Hwba, Rgb, Rgba } from "./color/types.js";
|
|
2
|
-
import { ContrastOptions, ContrastReport, TextSize, WcagLevel, apcaContrast, contrastRatio, contrastReport, meetsContrast, meetsNonTextContrast, readableTextColor, relativeLuminance, wcagLevel } from "./a11y/contrast.js";
|
|
1
|
+
import { ColorChangeMeta, ColorChangeResult, ColorChangeSource, ColorFormat, ColorValue, Hsl, Hsla, Hsva, Hwb, Hwba, ModernColorSpace, Rgb, Rgba, SerializeColorOptions } from "./color/types.js";
|
|
3
2
|
import { clamp, hslaToHsva, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, normalizeHue, rgbaToHsva, roundRgba } from "./color/convert.js";
|
|
4
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";
|
|
5
6
|
import { toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString } from "./color/serialize.js";
|
|
6
7
|
import { ingest, sameHsva, sameRendered } from "./color/sticky.js";
|
|
7
8
|
import { ColorListener, ColorStore, Unsubscribe, createColorStore } from "./core/store.js";
|
|
9
|
+
import { AccessibleColorSuggestion, ContrastOptions, ContrastReport, TextSize, WcagLevel, apcaContrast, compositeColor, contrastRatio, contrastRatioWithAlpha, contrastReport, meetsContrast, meetsNonTextContrast, readableTextColor, relativeLuminance, suggestAccessibleColor, wcagLevel } from "./a11y/contrast.js";
|
|
8
10
|
import { QuantizedSwatch, quantize } from "./image/mmcq.js";
|
|
9
11
|
import { ExtractOptions, ExtractResult, extractPalette } from "./image/extract.js";
|
|
10
12
|
import { ModeId, PickerMode, getMode, registerMode, resolveModes } from "./modes/registry.js";
|
|
@@ -33,4 +35,4 @@ import { PENCIL_COLUMNS, defaultPalettes, defaultPencils } from "./data/defaults
|
|
|
33
35
|
import { useColorValue, useTransientColor } from "./core/useColorStore.js";
|
|
34
36
|
import { useAxisKeyboard, usePointerDrag } from "./core/usePointerDrag.js";
|
|
35
37
|
import { injectStyles, setStyleNonce } from "./core/styleInjector.js";
|
|
36
|
-
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 ContrastOptions, type ContrastReport, type ExtractOptions, type ExtractResult, type Eyedropper, Hsl, Hsla, Hsva, Hwb, Hwba, Icon, type IconName, type IconProps, ImagePanel, type ModeId, ModeToolbar, type ModeToolbarProps, NumberField, type NumberFieldProps, PENCIL_COLUMNS, PalettesPanel, PanelFooter, type PanelOptions, PencilsPanel, type PickerMode, Popover, type PopoverProps, type QuantizedSwatch, Rgb, Rgba, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SlidersPanel, Swatch, type SwatchEntry, SwatchGrid, type SwatchGridProps, type SwatchProps, type SwatchVariant, type TextSize, type Unsubscribe, type WcagLevel, WheelPanel, apcaContrast, clamp, clearNamedColors, contrastRatio, contrastReport, createColorStore, defaultPalettes, defaultPencils, extractPalette, getMode, hslaToHsva, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, imageMode, ingest, injectStyles, isValidColor, meetsContrast, meetsNonTextContrast, normalizeHue, palettesMode, parse, pencilsMode, pushRecent, quantize, readableTextColor, registerMode, registerNamedColors, relativeLuminance, resolveModes, rgbaToHsva, roundRgba, sameHsva, sameRendered, setStyleNonce, slidersMode, toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString, useAxisKeyboard, useColorValue, useEyedropper, usePanel, usePointerDrag, useTransientColor, wcagLevel, wheelMode };
|
|
38
|
+
export { type AccessibleColorSuggestion, 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 ContrastOptions, type ContrastReport, type ExtractOptions, type ExtractResult, type Eyedropper, Hsl, Hsla, Hsva, Hwb, Hwba, Icon, type IconName, type IconProps, ImagePanel, type ModeId, ModeToolbar, type ModeToolbarProps, ModernColorSpace, NumberField, type NumberFieldProps, PENCIL_COLUMNS, PalettesPanel, PanelFooter, type PanelOptions, PencilsPanel, type PickerMode, Popover, type PopoverProps, type QuantizedSwatch, Rgb, Rgba, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SerializeColorOptions, SlidersPanel, Swatch, type SwatchEntry, SwatchGrid, type SwatchGridProps, type SwatchProps, type SwatchVariant, type TextSize, type Unsubscribe, type WcagLevel, WheelPanel, apcaContrast, clamp, clearNamedColors, colorValueToHsva, compositeColor, contrastRatio, contrastRatioWithAlpha, contrastReport, convertColor, createColorStore, defaultPalettes, defaultPencils, extractPalette, getMode, hslaToHsva, hsvaToColorValue, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, imageMode, ingest, injectStyles, isInGamut, isValidColor, mapToGamut, meetsContrast, meetsNonTextContrast, normalizeHue, palettesMode, parse, parseColor, parseCss4Color, pencilsMode, pushRecent, quantize, readableTextColor, registerMode, registerNamedColors, relativeLuminance, resolveModes, rgbaToHsva, roundRgba, sameHsva, sameRendered, serializeColor, setStyleNonce, slidersMode, suggestAccessibleColor, toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString, useAxisKeyboard, useColorValue, useEyedropper, usePanel, usePointerDrag, useTransientColor, wcagLevel, wheelMode };
|
package/dist/index.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";
|
|
@@ -32,7 +33,8 @@ import { Popover } from "./components/Popover.js";
|
|
|
32
33
|
import { ColorInput } from "./components/ColorInput.js";
|
|
33
34
|
import { ColorArea } from "./primitives/ColorArea.js";
|
|
34
35
|
import { Swatch } from "./primitives/Swatch.js";
|
|
35
|
-
import {
|
|
36
|
+
import { parseColor } from "./color/value.js";
|
|
37
|
+
import { apcaContrast, compositeColor, contrastRatio, contrastRatioWithAlpha, contrastReport, meetsContrast, meetsNonTextContrast, readableTextColor, relativeLuminance, suggestAccessibleColor, wcagLevel } from "./a11y/contrast.js";
|
|
36
38
|
//#region src/index.ts
|
|
37
39
|
registerMode(wheelMode);
|
|
38
40
|
registerMode(slidersMode);
|
|
@@ -40,5 +42,5 @@ registerMode(palettesMode);
|
|
|
40
42
|
registerMode(imageMode);
|
|
41
43
|
registerMode(pencilsMode);
|
|
42
44
|
//#endregion
|
|
43
|
-
export { ChannelSlider, ChromaPanel, ColorArea, ColorDisc, ColorField, ColorInput, Icon, ImagePanel, ModeToolbar, NumberField, PENCIL_COLUMNS, PalettesPanel, PanelFooter, PencilsPanel, Popover, SegmentedControl, SlidersPanel, Swatch, SwatchGrid, WheelPanel, apcaContrast, clamp, clearNamedColors, contrastRatio, contrastReport, createColorStore, defaultPalettes, defaultPencils, extractPalette, getMode, hslaToHsva, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, imageMode, ingest, injectStyles, isValidColor, meetsContrast, meetsNonTextContrast, normalizeHue, palettesMode, parse, pencilsMode, pushRecent, quantize, readableTextColor, registerMode, registerNamedColors, relativeLuminance, resolveModes, rgbaToHsva, roundRgba, sameHsva, sameRendered, setStyleNonce, slidersMode, toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString, useAxisKeyboard, useColorValue, useEyedropper, usePanel, usePointerDrag, useTransientColor, wcagLevel, wheelMode };
|
|
45
|
+
export { ChannelSlider, ChromaPanel, ColorArea, ColorDisc, ColorField, ColorInput, Icon, ImagePanel, ModeToolbar, NumberField, PENCIL_COLUMNS, PalettesPanel, PanelFooter, PencilsPanel, Popover, SegmentedControl, SlidersPanel, Swatch, SwatchGrid, WheelPanel, apcaContrast, clamp, clearNamedColors, colorValueToHsva, compositeColor, contrastRatio, contrastRatioWithAlpha, contrastReport, convertColor, createColorStore, defaultPalettes, defaultPencils, extractPalette, getMode, hslaToHsva, hsvaToColorValue, hsvaToHsl, hsvaToHsla, hsvaToHwba, hsvaToRgb, hsvaToRgba, hwbaToHsva, imageMode, ingest, injectStyles, isInGamut, isValidColor, mapToGamut, meetsContrast, meetsNonTextContrast, normalizeHue, palettesMode, parse, parseColor, parseCss4Color, pencilsMode, pushRecent, quantize, readableTextColor, registerMode, registerNamedColors, relativeLuminance, resolveModes, rgbaToHsva, roundRgba, sameHsva, sameRendered, serializeColor, setStyleNonce, slidersMode, suggestAccessibleColor, toFormat, toHex, toHexa, toHslString, toHslaString, toResult, toRgbString, toRgbaString, useAxisKeyboard, useColorValue, useEyedropper, usePanel, usePointerDrag, useTransientColor, wcagLevel, wheelMode };
|
|
44
46
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_context = require("../../core/context.cjs");
|
|
4
|
+
const require_convert = require("../../color/convert.cjs");
|
|
4
5
|
const require_parse = require("../../color/parse.cjs");
|
|
5
6
|
const require_icons = require("../../primitives/icons.cjs");
|
|
6
7
|
const require_SwatchGrid = require("../../primitives/SwatchGrid.cjs");
|
|
@@ -17,7 +18,7 @@ const EMPTY = {
|
|
|
17
18
|
preview: null
|
|
18
19
|
};
|
|
19
20
|
function ImagePanel(props) {
|
|
20
|
-
const { extractOptions } = props;
|
|
21
|
+
const { extractOptions, sortBy = "population" } = props;
|
|
21
22
|
const { idPrefix, disabled } = require_context.usePanel();
|
|
22
23
|
const inputId = `${idPrefix}-image-file`;
|
|
23
24
|
const { store } = require_context.usePanel();
|
|
@@ -29,6 +30,10 @@ function ImagePanel(props) {
|
|
|
29
30
|
const [point, setPoint] = react.useState(null);
|
|
30
31
|
const inputRef = react.useRef(null);
|
|
31
32
|
const imageRef = react.useRef(null);
|
|
33
|
+
const [clipboardRead, setClipboardRead] = react.useState(false);
|
|
34
|
+
react.useEffect(() => {
|
|
35
|
+
setClipboardRead(typeof navigator.clipboard?.read === "function");
|
|
36
|
+
}, []);
|
|
32
37
|
react.useEffect(() => {
|
|
33
38
|
if (preview === null && status === "idle") kept.delete(store);
|
|
34
39
|
else kept.set(store, {
|
|
@@ -87,6 +92,50 @@ function ImagePanel(props) {
|
|
|
87
92
|
const file = files?.[0];
|
|
88
93
|
if (file !== void 0) run(file);
|
|
89
94
|
};
|
|
95
|
+
const pasteFile = (items) => {
|
|
96
|
+
for (const item of Array.from(items)) {
|
|
97
|
+
if (item.kind !== "file" || !item.type.startsWith("image/")) continue;
|
|
98
|
+
const file = item.getAsFile();
|
|
99
|
+
if (file !== null) run(file);
|
|
100
|
+
return file !== null;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
};
|
|
104
|
+
const readClipboard = async () => {
|
|
105
|
+
try {
|
|
106
|
+
const items = await navigator.clipboard.read();
|
|
107
|
+
for (const item of items) {
|
|
108
|
+
const type = item.types.find((candidate) => candidate.startsWith("image/"));
|
|
109
|
+
if (type === void 0) continue;
|
|
110
|
+
const blob = await item.getType(type);
|
|
111
|
+
await run(new File([blob], "clipboard-image", { type }));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
setStatus("error");
|
|
115
|
+
setMessage("The clipboard does not contain an image.");
|
|
116
|
+
} catch {
|
|
117
|
+
setStatus("error");
|
|
118
|
+
setMessage("Clipboard access was not allowed. Use paste or choose a file instead.");
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const sortedSwatches = react.useMemo(() => [...swatches].sort((a, b) => {
|
|
122
|
+
if (sortBy === "population") return b.population - a.population;
|
|
123
|
+
if (sortBy === "luminance") {
|
|
124
|
+
const luminance = (rgb) => .2126 * rgb[0] + .7152 * rgb[1] + .0722 * rgb[2];
|
|
125
|
+
return luminance(b.rgb) - luminance(a.rgb);
|
|
126
|
+
}
|
|
127
|
+
return require_convert.rgbaToHsva({
|
|
128
|
+
r: a.rgb[0],
|
|
129
|
+
g: a.rgb[1],
|
|
130
|
+
b: a.rgb[2],
|
|
131
|
+
a: 1
|
|
132
|
+
}).h - require_convert.rgbaToHsva({
|
|
133
|
+
r: b.rgb[0],
|
|
134
|
+
g: b.rgb[1],
|
|
135
|
+
b: b.rgb[2],
|
|
136
|
+
a: 1
|
|
137
|
+
}).h;
|
|
138
|
+
}), [swatches, sortBy]);
|
|
90
139
|
const clear = () => {
|
|
91
140
|
controller.current?.abort();
|
|
92
141
|
releasePreview();
|
|
@@ -131,8 +180,8 @@ function ImagePanel(props) {
|
|
|
131
180
|
}
|
|
132
181
|
const parsed = require_parse.parse(`rgba(${r}, ${g}, ${b}, ${Math.round(a / 255 * 1e3) / 1e3})`);
|
|
133
182
|
if (parsed === null) return;
|
|
134
|
-
store.ingest(parsed);
|
|
135
|
-
store.commit();
|
|
183
|
+
store.ingest(parsed, "image");
|
|
184
|
+
store.commit("image");
|
|
136
185
|
setMessage("Color selected from image.");
|
|
137
186
|
};
|
|
138
187
|
const dragDepth = react.useRef(0);
|
|
@@ -143,6 +192,9 @@ function ImagePanel(props) {
|
|
|
143
192
|
};
|
|
144
193
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
145
194
|
className: "cp-panel",
|
|
195
|
+
onPaste: (event) => {
|
|
196
|
+
if (!disabled && pasteFile(event.clipboardData.items)) event.preventDefault();
|
|
197
|
+
},
|
|
146
198
|
onDragEnter: (e) => {
|
|
147
199
|
e.preventDefault();
|
|
148
200
|
if (disabled) return;
|
|
@@ -245,6 +297,15 @@ function ImagePanel(props) {
|
|
|
245
297
|
tabIndex: preview === null ? void 0 : -1,
|
|
246
298
|
onChange: (e) => onFiles(e.currentTarget.files)
|
|
247
299
|
}),
|
|
300
|
+
preview === null && clipboardRead && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
301
|
+
type: "button",
|
|
302
|
+
className: "cp-button",
|
|
303
|
+
disabled,
|
|
304
|
+
onClick: () => {
|
|
305
|
+
readClipboard();
|
|
306
|
+
},
|
|
307
|
+
children: "Paste image"
|
|
308
|
+
}),
|
|
248
309
|
preview !== null && status === "error" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
249
310
|
className: "cp-empty",
|
|
250
311
|
children: message
|
|
@@ -254,7 +315,7 @@ function ImagePanel(props) {
|
|
|
254
315
|
children: "Click the image to pick an exact color."
|
|
255
316
|
}),
|
|
256
317
|
status === "ready" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SwatchGrid.SwatchGrid, {
|
|
257
|
-
swatches:
|
|
318
|
+
swatches: sortedSwatches.map((s) => ({
|
|
258
319
|
color: s.hex,
|
|
259
320
|
name: s.hex
|
|
260
321
|
})),
|
|
@@ -4,6 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
//#region src/modes/image/index.d.ts
|
|
5
5
|
export interface ImagePanelProps {
|
|
6
6
|
extractOptions?: ExtractOptions;
|
|
7
|
+
sortBy?: "population" | "luminance" | "hue";
|
|
7
8
|
}
|
|
8
9
|
export declare function ImagePanel(props: ImagePanelProps): React.ReactElement;
|
|
9
10
|
export declare const imageMode: PickerMode;
|
|
@@ -4,6 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
//#region src/modes/image/index.d.ts
|
|
5
5
|
export interface ImagePanelProps {
|
|
6
6
|
extractOptions?: ExtractOptions;
|
|
7
|
+
sortBy?: "population" | "luminance" | "hue";
|
|
7
8
|
}
|
|
8
9
|
export declare function ImagePanel(props: ImagePanelProps): React.ReactElement;
|
|
9
10
|
export declare const imageMode: PickerMode;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { usePanel } from "../../core/context.js";
|
|
3
|
+
import { rgbaToHsva } from "../../color/convert.js";
|
|
3
4
|
import { parse } from "../../color/parse.js";
|
|
4
5
|
import { Icon, ImageIcon } from "../../primitives/icons.js";
|
|
5
6
|
import { SwatchGrid } from "../../primitives/SwatchGrid.js";
|
|
@@ -15,7 +16,7 @@ const EMPTY = {
|
|
|
15
16
|
preview: null
|
|
16
17
|
};
|
|
17
18
|
function ImagePanel(props) {
|
|
18
|
-
const { extractOptions } = props;
|
|
19
|
+
const { extractOptions, sortBy = "population" } = props;
|
|
19
20
|
const { idPrefix, disabled } = usePanel();
|
|
20
21
|
const inputId = `${idPrefix}-image-file`;
|
|
21
22
|
const { store } = usePanel();
|
|
@@ -27,6 +28,10 @@ function ImagePanel(props) {
|
|
|
27
28
|
const [point, setPoint] = React.useState(null);
|
|
28
29
|
const inputRef = React.useRef(null);
|
|
29
30
|
const imageRef = React.useRef(null);
|
|
31
|
+
const [clipboardRead, setClipboardRead] = React.useState(false);
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
setClipboardRead(typeof navigator.clipboard?.read === "function");
|
|
34
|
+
}, []);
|
|
30
35
|
React.useEffect(() => {
|
|
31
36
|
if (preview === null && status === "idle") kept.delete(store);
|
|
32
37
|
else kept.set(store, {
|
|
@@ -85,6 +90,50 @@ function ImagePanel(props) {
|
|
|
85
90
|
const file = files?.[0];
|
|
86
91
|
if (file !== void 0) run(file);
|
|
87
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]);
|
|
88
137
|
const clear = () => {
|
|
89
138
|
controller.current?.abort();
|
|
90
139
|
releasePreview();
|
|
@@ -129,8 +178,8 @@ function ImagePanel(props) {
|
|
|
129
178
|
}
|
|
130
179
|
const parsed = parse(`rgba(${r}, ${g}, ${b}, ${Math.round(a / 255 * 1e3) / 1e3})`);
|
|
131
180
|
if (parsed === null) return;
|
|
132
|
-
store.ingest(parsed);
|
|
133
|
-
store.commit();
|
|
181
|
+
store.ingest(parsed, "image");
|
|
182
|
+
store.commit("image");
|
|
134
183
|
setMessage("Color selected from image.");
|
|
135
184
|
};
|
|
136
185
|
const dragDepth = React.useRef(0);
|
|
@@ -141,6 +190,9 @@ function ImagePanel(props) {
|
|
|
141
190
|
};
|
|
142
191
|
return /* @__PURE__ */ jsxs("div", {
|
|
143
192
|
className: "cp-panel",
|
|
193
|
+
onPaste: (event) => {
|
|
194
|
+
if (!disabled && pasteFile(event.clipboardData.items)) event.preventDefault();
|
|
195
|
+
},
|
|
144
196
|
onDragEnter: (e) => {
|
|
145
197
|
e.preventDefault();
|
|
146
198
|
if (disabled) return;
|
|
@@ -243,6 +295,15 @@ function ImagePanel(props) {
|
|
|
243
295
|
tabIndex: preview === null ? void 0 : -1,
|
|
244
296
|
onChange: (e) => onFiles(e.currentTarget.files)
|
|
245
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
|
+
}),
|
|
246
307
|
preview !== null && status === "error" && /* @__PURE__ */ jsx("p", {
|
|
247
308
|
className: "cp-empty",
|
|
248
309
|
children: message
|
|
@@ -252,7 +313,7 @@ function ImagePanel(props) {
|
|
|
252
313
|
children: "Click the image to pick an exact color."
|
|
253
314
|
}),
|
|
254
315
|
status === "ready" && /* @__PURE__ */ jsx(SwatchGrid, {
|
|
255
|
-
swatches:
|
|
316
|
+
swatches: sortedSwatches.map((s) => ({
|
|
256
317
|
color: s.hex,
|
|
257
318
|
name: s.hex
|
|
258
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),
|