@zag-js/color-picker 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +42 -41
- package/dist/index.d.ts +42 -41
- package/dist/index.js +0 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- package/src/color-picker.connect.ts +9 -26
- package/src/color-picker.dom.ts +1 -1
- package/src/color-picker.machine.ts +2 -2
- package/src/color-picker.types.ts +45 -3
- package/src/index.ts +4 -0
- package/src/utils/get-channel-details.ts +1 -1
- package/src/utils/get-channel-display-color.ts +1 -1
- package/src/utils/get-channel-input-value.ts +2 -2
- package/src/utils/get-color-area-gradient.ts +3 -3
- package/src/utils/get-slider-background.ts +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { Orientation, PropTypes, RequiredBy, CommonProperties, Context, NormalizeProps } from '@zag-js/types';
|
|
3
|
+
import { ColorChannel, Color, ColorFormat, ColorAxes } from '@zag-js/color-utils';
|
|
4
|
+
export { Color, ColorAxes, ColorChannel, ColorFormat, ColorType } from '@zag-js/color-utils';
|
|
5
5
|
import * as _zag_js_core from '@zag-js/core';
|
|
6
6
|
import { StateMachine } from '@zag-js/core';
|
|
7
7
|
|
|
@@ -67,43 +67,7 @@ type PublicContext = CommonProperties & {
|
|
|
67
67
|
*/
|
|
68
68
|
onChangeEnd?: (details: ChangeDetails) => void;
|
|
69
69
|
};
|
|
70
|
-
type
|
|
71
|
-
/**
|
|
72
|
-
* The id of the thumb that is currently being dragged
|
|
73
|
-
*/
|
|
74
|
-
activeId: string | null;
|
|
75
|
-
/**
|
|
76
|
-
* The color value as a Color object
|
|
77
|
-
*/
|
|
78
|
-
valueAsColor: Color;
|
|
79
|
-
/**
|
|
80
|
-
* The channel that is currently being interacted with
|
|
81
|
-
*/
|
|
82
|
-
activeChannel: Partial<ColorAxes> | null;
|
|
83
|
-
/**
|
|
84
|
-
* The orientation of the channel that is currently being interacted with
|
|
85
|
-
*/
|
|
86
|
-
activeOrientation: Orientation | null;
|
|
87
|
-
}>;
|
|
88
|
-
type ComputedContext = Readonly<{
|
|
89
|
-
/**
|
|
90
|
-
* Whether the color picker is in RTL mode
|
|
91
|
-
*/
|
|
92
|
-
isRtl: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Whether the color picker is interactive
|
|
95
|
-
*/
|
|
96
|
-
isInteractive: boolean;
|
|
97
|
-
}>;
|
|
98
|
-
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
99
|
-
type MachineContext = PublicContext & PrivateContext & ComputedContext;
|
|
100
|
-
type MachineState = {
|
|
101
|
-
value: "idle" | "focused" | "dragging";
|
|
102
|
-
};
|
|
103
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
104
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
105
|
-
|
|
106
|
-
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
70
|
+
type PublicApi<T extends PropTypes = PropTypes> = {
|
|
107
71
|
/**
|
|
108
72
|
* Whether the color picker is being dragged
|
|
109
73
|
*/
|
|
@@ -144,7 +108,44 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
|
|
|
144
108
|
getSwatchBackgroundProps(props: ColorSwatchProps): T["element"];
|
|
145
109
|
getSwatchProps(props: ColorSwatchProps): T["element"];
|
|
146
110
|
};
|
|
111
|
+
type PrivateContext = Context<{
|
|
112
|
+
/**
|
|
113
|
+
* The id of the thumb that is currently being dragged
|
|
114
|
+
*/
|
|
115
|
+
activeId: string | null;
|
|
116
|
+
/**
|
|
117
|
+
* The color value as a Color object
|
|
118
|
+
*/
|
|
119
|
+
valueAsColor: Color;
|
|
120
|
+
/**
|
|
121
|
+
* The channel that is currently being interacted with
|
|
122
|
+
*/
|
|
123
|
+
activeChannel: Partial<ColorAxes> | null;
|
|
124
|
+
/**
|
|
125
|
+
* The orientation of the channel that is currently being interacted with
|
|
126
|
+
*/
|
|
127
|
+
activeOrientation: Orientation | null;
|
|
128
|
+
}>;
|
|
129
|
+
type ComputedContext = Readonly<{
|
|
130
|
+
/**
|
|
131
|
+
* Whether the color picker is in RTL mode
|
|
132
|
+
*/
|
|
133
|
+
isRtl: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Whether the color picker is interactive
|
|
136
|
+
*/
|
|
137
|
+
isInteractive: boolean;
|
|
138
|
+
}>;
|
|
139
|
+
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
140
|
+
type MachineContext = PublicContext & PrivateContext & ComputedContext;
|
|
141
|
+
type MachineState = {
|
|
142
|
+
value: "idle" | "focused" | "dragging";
|
|
143
|
+
};
|
|
144
|
+
type State = StateMachine.State<MachineContext, MachineState>;
|
|
145
|
+
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
146
|
+
|
|
147
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): PublicApi<T>;
|
|
147
148
|
|
|
148
149
|
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
149
150
|
|
|
150
|
-
export { ColorAreaProps, ColorChannelInputProps, ColorChannelProps, ColorSwatchProps, UserDefinedContext as Context, anatomy, connect, machine };
|
|
151
|
+
export { ColorAreaProps, ColorChannelInputProps, ColorChannelProps, ColorSwatchProps, UserDefinedContext as Context, PublicApi, anatomy, connect, machine };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { Orientation, PropTypes, RequiredBy, CommonProperties, Context, NormalizeProps } from '@zag-js/types';
|
|
3
|
+
import { ColorChannel, Color, ColorFormat, ColorAxes } from '@zag-js/color-utils';
|
|
4
|
+
export { Color, ColorAxes, ColorChannel, ColorFormat, ColorType } from '@zag-js/color-utils';
|
|
5
5
|
import * as _zag_js_core from '@zag-js/core';
|
|
6
6
|
import { StateMachine } from '@zag-js/core';
|
|
7
7
|
|
|
@@ -67,43 +67,7 @@ type PublicContext = CommonProperties & {
|
|
|
67
67
|
*/
|
|
68
68
|
onChangeEnd?: (details: ChangeDetails) => void;
|
|
69
69
|
};
|
|
70
|
-
type
|
|
71
|
-
/**
|
|
72
|
-
* The id of the thumb that is currently being dragged
|
|
73
|
-
*/
|
|
74
|
-
activeId: string | null;
|
|
75
|
-
/**
|
|
76
|
-
* The color value as a Color object
|
|
77
|
-
*/
|
|
78
|
-
valueAsColor: Color;
|
|
79
|
-
/**
|
|
80
|
-
* The channel that is currently being interacted with
|
|
81
|
-
*/
|
|
82
|
-
activeChannel: Partial<ColorAxes> | null;
|
|
83
|
-
/**
|
|
84
|
-
* The orientation of the channel that is currently being interacted with
|
|
85
|
-
*/
|
|
86
|
-
activeOrientation: Orientation | null;
|
|
87
|
-
}>;
|
|
88
|
-
type ComputedContext = Readonly<{
|
|
89
|
-
/**
|
|
90
|
-
* Whether the color picker is in RTL mode
|
|
91
|
-
*/
|
|
92
|
-
isRtl: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Whether the color picker is interactive
|
|
95
|
-
*/
|
|
96
|
-
isInteractive: boolean;
|
|
97
|
-
}>;
|
|
98
|
-
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
99
|
-
type MachineContext = PublicContext & PrivateContext & ComputedContext;
|
|
100
|
-
type MachineState = {
|
|
101
|
-
value: "idle" | "focused" | "dragging";
|
|
102
|
-
};
|
|
103
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
104
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
105
|
-
|
|
106
|
-
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
70
|
+
type PublicApi<T extends PropTypes = PropTypes> = {
|
|
107
71
|
/**
|
|
108
72
|
* Whether the color picker is being dragged
|
|
109
73
|
*/
|
|
@@ -144,7 +108,44 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
|
|
|
144
108
|
getSwatchBackgroundProps(props: ColorSwatchProps): T["element"];
|
|
145
109
|
getSwatchProps(props: ColorSwatchProps): T["element"];
|
|
146
110
|
};
|
|
111
|
+
type PrivateContext = Context<{
|
|
112
|
+
/**
|
|
113
|
+
* The id of the thumb that is currently being dragged
|
|
114
|
+
*/
|
|
115
|
+
activeId: string | null;
|
|
116
|
+
/**
|
|
117
|
+
* The color value as a Color object
|
|
118
|
+
*/
|
|
119
|
+
valueAsColor: Color;
|
|
120
|
+
/**
|
|
121
|
+
* The channel that is currently being interacted with
|
|
122
|
+
*/
|
|
123
|
+
activeChannel: Partial<ColorAxes> | null;
|
|
124
|
+
/**
|
|
125
|
+
* The orientation of the channel that is currently being interacted with
|
|
126
|
+
*/
|
|
127
|
+
activeOrientation: Orientation | null;
|
|
128
|
+
}>;
|
|
129
|
+
type ComputedContext = Readonly<{
|
|
130
|
+
/**
|
|
131
|
+
* Whether the color picker is in RTL mode
|
|
132
|
+
*/
|
|
133
|
+
isRtl: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Whether the color picker is interactive
|
|
136
|
+
*/
|
|
137
|
+
isInteractive: boolean;
|
|
138
|
+
}>;
|
|
139
|
+
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
140
|
+
type MachineContext = PublicContext & PrivateContext & ComputedContext;
|
|
141
|
+
type MachineState = {
|
|
142
|
+
value: "idle" | "focused" | "dragging";
|
|
143
|
+
};
|
|
144
|
+
type State = StateMachine.State<MachineContext, MachineState>;
|
|
145
|
+
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
146
|
+
|
|
147
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): PublicApi<T>;
|
|
147
148
|
|
|
148
149
|
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
149
150
|
|
|
150
|
-
export { ColorAreaProps, ColorChannelInputProps, ColorChannelProps, ColorSwatchProps, UserDefinedContext as Context, anatomy, connect, machine };
|
|
151
|
+
export { ColorAreaProps, ColorChannelInputProps, ColorChannelProps, ColorSwatchProps, UserDefinedContext as Context, PublicApi, anatomy, connect, machine };
|
package/dist/index.js
CHANGED
|
@@ -402,38 +402,17 @@ function connect(state, send, normalize) {
|
|
|
402
402
|
const isDragging = state.matches("dragging");
|
|
403
403
|
const channels = valueAsColor.getColorChannels();
|
|
404
404
|
return {
|
|
405
|
-
/**
|
|
406
|
-
* Whether the color picker is being dragged
|
|
407
|
-
*/
|
|
408
405
|
isDragging,
|
|
409
|
-
/**
|
|
410
|
-
* The current color value (as a string)
|
|
411
|
-
*/
|
|
412
406
|
value: state.context.value,
|
|
413
|
-
/**
|
|
414
|
-
* The current color value (as a Color object)
|
|
415
|
-
*/
|
|
416
407
|
valueAsColor,
|
|
417
|
-
/**
|
|
418
|
-
* The current color channels of the color
|
|
419
|
-
*/
|
|
420
408
|
channels,
|
|
421
|
-
/**
|
|
422
|
-
* Function to set the color value
|
|
423
|
-
*/
|
|
424
409
|
setColor(value) {
|
|
425
410
|
send({ type: "VALUE.SET", value: (0, import_color_utils2.normalizeColor)(value), src: "set-color" });
|
|
426
411
|
},
|
|
427
|
-
/**
|
|
428
|
-
* Function to set the color value of a specific channel
|
|
429
|
-
*/
|
|
430
412
|
setChannelValue(channel, value) {
|
|
431
413
|
const color = valueAsColor.withChannelValue(channel, value);
|
|
432
414
|
send({ type: "VALUE.SET", value: color, src: "set-channel" });
|
|
433
415
|
},
|
|
434
|
-
/**
|
|
435
|
-
* Function to set the color format
|
|
436
|
-
*/
|
|
437
416
|
setFormat(format) {
|
|
438
417
|
const value = valueAsColor.toFormat(format);
|
|
439
418
|
send({ type: "VALUE.SET", value, src: "set-format" });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/color-picker.anatomy.ts","../src/color-picker.connect.ts","../src/color-picker.dom.ts","../src/utils/get-channel-details.ts","../src/utils/get-channel-display-color.ts","../src/utils/get-channel-input-value.ts","../src/utils/generate-format-background.ts","../src/utils/get-color-area-gradient.ts","../src/utils/get-slider-background.ts","../src/color-picker.machine.ts"],"sourcesContent":["export { anatomy } from \"./color-picker.anatomy\"\nexport { connect } from \"./color-picker.connect\"\nexport { machine } from \"./color-picker.machine\"\nexport type {\n Color,\n ColorAreaProps,\n ColorChannel,\n ColorChannelProps,\n ColorChannelInputProps,\n ColorSwatchProps,\n UserDefinedContext as Context,\n} from \"./color-picker.types\"\n","import { createAnatomy } from \"@zag-js/anatomy\"\n\nexport const anatomy = createAnatomy(\"color-picker\", [\n \"area\",\n \"areaThumb\",\n \"areaGradient\",\n \"channelSliderTrack\",\n \"channelSliderTrackBg\",\n \"channelSliderThumb\",\n \"channelInput\",\n \"swatch\",\n \"swatchBg\",\n \"content\",\n \"label\",\n \"eyeDropTrigger\",\n])\n\nexport const parts = anatomy.build()\n","import { Color, normalizeColor, type ColorChannel, type ColorFormat } from \"@zag-js/color-utils\"\nimport {\n EventKeyMap,\n getEventKey,\n getEventPoint,\n getEventStep,\n getNativeEvent,\n isLeftClick,\n isModifiedEvent,\n} from \"@zag-js/dom-event\"\nimport { dataAttr } from \"@zag-js/dom-query\"\nimport { NormalizeProps, type PropTypes } from \"@zag-js/types\"\nimport { parts } from \"./color-picker.anatomy\"\nimport { dom } from \"./color-picker.dom\"\nimport {\n ColorAreaProps,\n ColorChannelInputProps,\n ColorChannelProps,\n ColorSwatchProps,\n Send,\n State,\n} from \"./color-picker.types\"\nimport { getChannelDetails } from \"./utils/get-channel-details\"\nimport { getChannelDisplayColor } from \"./utils/get-channel-display-color\"\nimport { getChannelInputRange, getChannelInputValue } from \"./utils/get-channel-input-value\"\nimport { getColorAreaGradient } from \"./utils/get-color-area-gradient\"\nimport { getSliderBgImage } from \"./utils/get-slider-background\"\n\nexport function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>) {\n const valueAsColor = state.context.valueAsColor\n const isDisabled = state.context.disabled\n const isInteractive = state.context.isInteractive\n const isDragging = state.matches(\"dragging\")\n\n const channels = valueAsColor.getColorChannels()\n\n return {\n /**\n * Whether the color picker is being dragged\n */\n isDragging,\n /**\n * The current color value (as a string)\n */\n value: state.context.value,\n /**\n * The current color value (as a Color object)\n */\n valueAsColor,\n /**\n * The current color channels of the color\n */\n channels,\n /**\n * Function to set the color value\n */\n setColor(value: string | Color) {\n send({ type: \"VALUE.SET\", value: normalizeColor(value), src: \"set-color\" })\n },\n /**\n * Function to set the color value of a specific channel\n */\n setChannelValue(channel: ColorChannel, value: number) {\n const color = valueAsColor.withChannelValue(channel, value)\n send({ type: \"VALUE.SET\", value: color, src: \"set-channel\" })\n },\n /**\n * Function to set the color format\n */\n setFormat(format: ColorFormat) {\n const value = valueAsColor.toFormat(format)\n send({ type: \"VALUE.SET\", value, src: \"set-format\" })\n },\n\n contentProps: normalize.element({\n ...parts.content.attrs,\n id: dom.getContentId(state.context),\n }),\n\n getAreaProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { areaStyles } = getColorAreaGradient(state.context, xChannel, yChannel)\n\n return normalize.element({\n ...parts.area.attrs,\n id: dom.getAreaId(state.context),\n role: \"group\",\n onPointerDown(event) {\n if (!isInteractive) return\n\n const evt = getNativeEvent(event)\n if (!isLeftClick(evt) || isModifiedEvent(evt)) return\n\n const point = getEventPoint(evt)\n const channel = { xChannel, yChannel }\n\n send({ type: \"AREA.POINTER_DOWN\", point, channel, id: \"area\" })\n },\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n ...areaStyles,\n },\n })\n },\n\n getAreaGradientProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { areaGradientStyles } = getColorAreaGradient(state.context, xChannel, yChannel)\n\n return normalize.element({\n ...parts.areaGradient.attrs,\n id: dom.getAreaGradientId(state.context),\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n ...areaGradientStyles,\n },\n })\n },\n\n getAreaThumbProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { getThumbPosition } = getChannelDetails(valueAsColor, xChannel, yChannel)\n const { x, y } = getThumbPosition()\n\n const channel = { xChannel, yChannel }\n\n return normalize.element({\n ...parts.areaThumb.attrs,\n id: dom.getAreaThumbId(state.context),\n tabIndex: isDisabled ? undefined : 0,\n \"data-disabled\": dataAttr(isDisabled),\n role: \"presentation\",\n style: {\n position: \"absolute\",\n left: `${x * 100}%`,\n top: `${y * 100}%`,\n transform: \"translate(-50%, -50%)\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n background: valueAsColor.withChannelValue(\"alpha\", 1).toString(\"css\"),\n },\n onBlur() {\n send(\"AREA.BLUR\")\n },\n onKeyDown(event) {\n if (!isInteractive) return\n\n const step = getEventStep(event)\n\n const keyMap: EventKeyMap = {\n ArrowUp() {\n send({ type: \"AREA.ARROW_UP\", channel, step })\n },\n ArrowDown() {\n send({ type: \"AREA.ARROW_DOWN\", channel, step })\n },\n ArrowLeft() {\n send({ type: \"AREA.ARROW_LEFT\", channel, step })\n },\n ArrowRight() {\n send({ type: \"AREA.ARROW_RIGHT\", channel, step })\n },\n PageUp() {\n send({ type: \"AREA.PAGE_UP\", channel, step })\n },\n PageDown() {\n send({ type: \"AREA.PAGE_DOWN\", channel, step })\n },\n }\n\n const exec = keyMap[getEventKey(event, state.context)]\n\n if (exec) {\n exec(event)\n event.preventDefault()\n }\n },\n })\n },\n\n getChannelSliderTrackProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n\n return normalize.element({\n ...parts.channelSliderTrack.attrs,\n id: dom.getChannelSliderTrackId(state.context, channel),\n role: \"group\",\n \"data-channel\": channel,\n \"data-orientation\": orientation,\n onPointerDown(event) {\n if (!isInteractive) return\n\n const evt = getNativeEvent(event)\n if (!isLeftClick(evt) || isModifiedEvent(evt)) return\n\n const point = getEventPoint(evt)\n send({ type: \"CHANNEL_SLIDER.POINTER_DOWN\", channel, point, id: channel, orientation })\n },\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n backgroundImage: getSliderBgImage(state.context, { orientation, channel }),\n },\n })\n },\n\n getChannelSliderBackgroundProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n return normalize.element({\n ...parts.channelSliderTrackBg.attrs,\n \"data-orientation\": orientation,\n \"data-channel\": channel,\n style: {\n position: \"absolute\",\n backgroundColor: \"#fff\",\n backgroundImage: [\n \"linear-gradient(-45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(-45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n \"linear-gradient(45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n ].join(\",\"),\n backgroundSize: \"16px 16px\",\n backgroundPosition: \"-2px -2px,-2px 6px,6px -10px,-10px -2px\",\n inset: 0,\n zIndex: -1,\n },\n })\n },\n\n getChannelSliderThumbProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n const { minValue, maxValue, step: stepValue } = valueAsColor.getChannelRange(channel)\n const channelValue = valueAsColor.getChannelValue(channel)\n\n const offset = (channelValue - minValue) / (maxValue - minValue)\n\n const placementStyles =\n orientation === \"horizontal\"\n ? { left: `${offset * 100}%`, top: \"50%\" }\n : { top: `${offset * 100}%`, left: \"50%\" }\n\n return normalize.element({\n ...parts.channelSliderThumb.attrs,\n id: dom.getChannelSliderThumbId(state.context, channel),\n role: \"slider\",\n \"aria-label\": channel,\n tabIndex: isDisabled ? undefined : 0,\n \"data-channel\": channel,\n \"data-disabled\": dataAttr(isDisabled),\n \"data-orientation\": orientation,\n \"aria-disabled\": dataAttr(isDisabled),\n \"aria-orientation\": orientation,\n \"aria-valuemax\": maxValue,\n \"aria-valuemin\": minValue,\n \"aria-valuenow\": channelValue,\n style: {\n forcedColorAdjust: \"none\",\n position: \"absolute\",\n background: getChannelDisplayColor(valueAsColor, channel).toString(\"css\"),\n ...placementStyles,\n },\n onFocus() {\n if (!isInteractive) return\n send({ type: \"CHANNEL_SLIDER.FOCUS\", channel })\n },\n onBlur() {\n if (!isInteractive) return\n send({ type: \"CHANNEL_SLIDER.BLUR\", channel })\n },\n onKeyDown(event) {\n if (!isInteractive) return\n const step = getEventStep(event) * stepValue\n\n const keyMap: EventKeyMap = {\n ArrowUp() {\n send({ type: \"CHANNEL_SLIDER.ARROW_UP\", channel, step })\n },\n ArrowDown() {\n send({ type: \"CHANNEL_SLIDER.ARROW_DOWN\", channel, step })\n },\n ArrowLeft() {\n send({ type: \"CHANNEL_SLIDER.ARROW_LEFT\", channel, step })\n },\n ArrowRight() {\n send({ type: \"CHANNEL_SLIDER.ARROW_RIGHT\", channel, step })\n },\n PageUp() {\n send({ type: \"CHANNEL_SLIDER.PAGE_UP\", channel })\n },\n PageDown() {\n send({ type: \"CHANNEL_SLIDER.PAGE_DOWN\", channel })\n },\n Home() {\n send({ type: \"CHANNEL_SLIDER.HOME\", channel })\n },\n End() {\n send({ type: \"CHANNEL_SLIDER.END\", channel })\n },\n }\n\n const exec = keyMap[getEventKey(event, state.context)]\n\n if (exec) {\n exec(event)\n event.preventDefault()\n }\n },\n })\n },\n\n getChannelInputProps(props: ColorChannelInputProps) {\n const { channel } = props\n const isTextField = channel === \"hex\" || channel === \"css\"\n const range = getChannelInputRange(valueAsColor, channel)\n\n return normalize.input({\n ...parts.channelInput.attrs,\n type: isTextField ? \"text\" : \"number\",\n \"data-channel\": channel,\n \"aria-label\": channel,\n disabled: isDisabled,\n \"data-disabled\": dataAttr(isDisabled),\n readOnly: state.context.readOnly,\n id: dom.getChannelInputId(state.context, channel),\n defaultValue: getChannelInputValue(valueAsColor, channel),\n min: range?.minValue,\n max: range?.maxValue,\n step: range?.step,\n onFocus() {\n send({ type: \"CHANNEL_INPUT.FOCUS\", channel })\n },\n onChange(event) {\n if (isTextField) return\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.CHANGE\", channel, value, isTextField })\n },\n onBlur(event) {\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.BLUR\", channel, value, isTextField })\n },\n onKeyDown(event) {\n if (!isTextField) return\n if (event.key === \"Enter\") {\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.CHANGE\", channel, value, isTextField })\n }\n },\n style: {\n appearance: \"none\",\n WebkitAppearance: \"none\",\n MozAppearance: \"textfield\",\n },\n })\n },\n\n eyeDropperTriggerProps: normalize.button({\n ...parts.eyeDropTrigger.attrs,\n onClick() {\n send(\"EYEDROPPER.CLICK\")\n },\n }),\n\n getSwatchBackgroundProps(props: ColorSwatchProps) {\n const { value } = props\n const alpha = normalizeColor(value).getChannelValue(\"alpha\")\n return normalize.element({\n ...parts.swatchBg.attrs,\n \"data-alpha\": alpha,\n style: {\n width: \"100%\",\n height: \"100%\",\n background: \"#fff\",\n backgroundImage: [\n \"linear-gradient(-45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(-45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n \"linear-gradient(45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n ].join(\",\"),\n backgroundPosition: \"-2px -2px,-2px 6px,6px -10px,-10px -2px\",\n backgroundSize: \"16px 16px\",\n position: \"absolute\",\n inset: \"0px\",\n zIndex: -1,\n },\n })\n },\n\n getSwatchProps(props: ColorSwatchProps) {\n const { value, readOnly } = props\n const color = normalizeColor(value).toFormat(valueAsColor.getColorSpace())\n return normalize.element({\n ...parts.swatch.attrs,\n onClick() {\n if (readOnly) return\n send({ type: \"VALUE.SET\", value: color })\n },\n style: {\n position: \"relative\",\n background: color.toString(\"css\"),\n },\n })\n },\n }\n}\n","import { type ColorChannel } from \"@zag-js/color-utils\"\nimport { getRelativePoint, type Point } from \"@zag-js/dom-event\"\nimport { createScope, queryAll } from \"@zag-js/dom-query\"\nimport type { MachineContext as Ctx } from \"./color-picker.types\"\n\nexport const dom = createScope({\n getContentId: (ctx: Ctx) => ctx.ids?.content ?? `color-picker:${ctx.id}:content`,\n getAreaId: (ctx: Ctx) => ctx.ids?.area ?? `color-picker:${ctx.id}:area`,\n getAreaGradientId: (ctx: Ctx) => ctx.ids?.areaGradient ?? `color-picker:${ctx.id}:area-gradient`,\n getAreaThumbId: (ctx: Ctx) => ctx.ids?.areaThumb ?? `color-picker:${ctx.id}:area-thumb`,\n getChannelSliderTrackId: (ctx: Ctx, channel: ColorChannel) =>\n ctx.ids?.channelSliderTrack?.(channel) ?? `color-picker:${ctx.id}:slider-track:${channel}`,\n getChannelInputId: (ctx: Ctx, channel: string) =>\n ctx.ids?.channelInput?.(channel) ?? `color-picker:${ctx.id}:input:${channel}`,\n getChannelSliderThumbId: (ctx: Ctx, channel: ColorChannel) =>\n ctx.ids?.channelSliderThumb?.(channel) ?? `color-picker:${ctx.id}:slider-thumb:${channel}`,\n\n getContentEl: (ctx: Ctx) => dom.queryById(ctx, dom.getContentId(ctx)),\n getAreaThumbEl: (ctx: Ctx) => dom.queryById(ctx, dom.getAreaThumbId(ctx)),\n getChannelSliderThumbEl: (ctx: Ctx, channel: ColorChannel) =>\n dom.queryById(ctx, dom.getChannelSliderThumbId(ctx, channel)),\n getChannelInputEl: (ctx: Ctx, channel: string) =>\n dom.queryById<HTMLInputElement>(ctx, dom.getChannelInputId(ctx, channel)),\n\n getAreaEl: (ctx: Ctx) => dom.queryById(ctx, dom.getAreaId(ctx)),\n getAreaValueFromPoint(ctx: Ctx, point: Point) {\n const { percent } = getRelativePoint(point, dom.getAreaEl(ctx))\n return percent\n },\n\n getChannelSliderTrackEl: (ctx: Ctx, channel: ColorChannel) => {\n return dom.queryById(ctx, dom.getChannelSliderTrackId(ctx, channel))\n },\n getChannelSliderValueFromPoint(ctx: Ctx, point: Point, channel: ColorChannel) {\n const { percent } = getRelativePoint(point, dom.getChannelSliderTrackEl(ctx, channel))\n return percent\n },\n getChannelInputEls: (ctx: Ctx) => {\n return queryAll<HTMLInputElement>(dom.getContentEl(ctx), \"input[data-channel]\")\n },\n})\n","import { Color, type ColorChannel } from \"@zag-js/color-utils\"\nimport { getPercentValue, snapValueToStep } from \"@zag-js/numeric-range\"\n\nexport function getChannelDetails(color: Color, xChannel: ColorChannel, yChannel: ColorChannel) {\n const channels = color.getColorSpaceAxes({ xChannel, yChannel })\n\n const xChannelRange = color.getChannelRange(channels.xChannel)\n const yChannelRange = color.getChannelRange(channels.yChannel)\n\n const { minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX } = xChannelRange\n const { minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY } = yChannelRange\n\n const xValue = color.getChannelValue(channels.xChannel)\n const yValue = color.getChannelValue(channels.yChannel)\n\n return {\n channels,\n xChannelStep: stepX,\n yChannelStep: stepY,\n xChannelPageStep: pageSizeX,\n yChannelPageStep: pageSizeY,\n xValue,\n yValue,\n getThumbPosition() {\n let x = (xValue - minValueX) / (maxValueX - minValueX)\n let y = 1 - (yValue - minValueY) / (maxValueY - minValueY)\n return { x, y }\n },\n incrementX(stepSize: number) {\n return xValue + stepSize > maxValueX ? maxValueX : snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX)\n },\n incrementY(stepSize: number) {\n return yValue + stepSize > maxValueY ? maxValueY : snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY)\n },\n decrementX(stepSize: number) {\n return snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX)\n },\n decrementY(stepSize: number) {\n return snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY)\n },\n getColorFromPoint(x: number, y: number) {\n let newXValue = getPercentValue(x, minValueX, maxValueX, stepX)\n let newYValue = getPercentValue(1 - y, minValueY, maxValueY, stepY)\n\n let newColor: Color | undefined\n\n if (newXValue !== xValue) {\n newXValue = snapValueToStep(newXValue, minValueX, maxValueX, stepX)\n newColor = color.withChannelValue(channels.xChannel, newXValue)\n }\n\n if (newYValue !== yValue) {\n newYValue = snapValueToStep(newYValue, minValueY, maxValueY, stepY)\n newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue)\n }\n\n return newColor\n },\n }\n}\n","import { Color, parseColor, type ColorChannel } from \"@zag-js/color-utils\"\n\nexport function getChannelDisplayColor(color: Color, channel: ColorChannel) {\n switch (channel) {\n case \"hue\":\n return parseColor(`hsl(${color.getChannelValue(\"hue\")}, 100%, 50%)`)\n case \"lightness\":\n case \"brightness\":\n case \"saturation\":\n case \"red\":\n case \"green\":\n case \"blue\":\n return color.withChannelValue(\"alpha\", 1)\n case \"alpha\": {\n return color\n }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n}\n","import { Color } from \"@zag-js/color-utils\"\nimport { ExtendedColorChannel } from \"../color-picker.types\"\n\nexport function getChannelInputValue(color: Color, channel: ExtendedColorChannel) {\n switch (channel) {\n case \"hex\":\n return color.toString(\"hex\")\n case \"css\":\n return color.toString(\"css\")\n default:\n return color.getChannelValue(channel).toString()\n }\n}\n\nexport function getChannelInputRange(color: Color, channel: ExtendedColorChannel) {\n switch (channel) {\n case \"hex\":\n case \"css\":\n return undefined\n default:\n return color.getChannelRange(channel)\n }\n}\n","export const generateRGB_R = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_G = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_B = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateHSL_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(dir)]\n }, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(!dir)]\n }, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n \"hsl(0, 0%, 50%)\",\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_L = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n backgroundImage: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_B = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n \"#000\",\n ].join(\",\"),\n },\n }\n return result\n}\n","import { type ColorChannel } from \"@zag-js/color-utils\"\nimport { Style } from \"@zag-js/types\"\nimport { MachineContext } from \"../color-picker.types\"\nimport {\n generateHSB_B,\n generateHSB_H,\n generateHSB_S,\n generateHSL_H,\n generateHSL_L,\n generateHSL_S,\n generateRGB_B,\n generateRGB_G,\n generateRGB_R,\n} from \"./generate-format-background\"\n\nexport function getColorAreaGradient(ctx: MachineContext, xChannel: ColorChannel, yChannel: ColorChannel) {\n const value = ctx.valueAsColor\n\n const { zChannel } = value.getColorSpaceAxes({ xChannel, yChannel })\n const zValue = value.getChannelValue(zChannel)\n\n const { minValue: zMin, maxValue: zMax } = value.getChannelRange(zChannel)\n const orientation: [string, string] = [\"top\", ctx.dir === \"rtl\" ? \"left\" : \"right\"]\n\n let dir = false\n let background = { areaStyles: {} as Style, areaGradientStyles: {} as Style }\n\n let alphaValue = (zValue - zMin) / (zMax - zMin)\n let isHSL = value.getColorSpace() === \"hsl\"\n\n switch (zChannel) {\n case \"red\": {\n dir = xChannel === \"green\"\n background = generateRGB_R(orientation, dir, zValue)\n break\n }\n\n case \"green\": {\n dir = xChannel === \"red\"\n background = generateRGB_G(orientation, dir, zValue)\n break\n }\n\n case \"blue\": {\n dir = xChannel === \"red\"\n background = generateRGB_B(orientation, dir, zValue)\n break\n }\n\n case \"hue\": {\n dir = xChannel !== \"saturation\"\n if (isHSL) {\n background = generateHSL_H(orientation, dir, zValue)\n } else {\n background = generateHSB_H(orientation, dir, zValue)\n }\n break\n }\n\n case \"saturation\": {\n dir = xChannel === \"hue\"\n if (isHSL) {\n background = generateHSL_S(orientation, dir, alphaValue)\n } else {\n background = generateHSB_S(orientation, dir, alphaValue)\n }\n break\n }\n\n case \"brightness\": {\n dir = xChannel === \"hue\"\n background = generateHSB_B(orientation, dir, alphaValue)\n break\n }\n\n case \"lightness\": {\n dir = xChannel === \"hue\"\n background = generateHSL_L(orientation, dir, zValue)\n break\n }\n }\n\n return background\n}\n","import { ColorChannelProps, MachineContext } from \"../color-picker.types\"\n\nfunction getSliderBgDirection(orientation: \"vertical\" | \"horizontal\", dir: \"ltr\" | \"rtl\") {\n if (orientation === \"vertical\") {\n return \"top\"\n } else if (dir === \"ltr\") {\n return \"right\"\n } else {\n return \"left\"\n }\n}\n\nexport const getSliderBgImage = (ctx: MachineContext, props: Required<ColorChannelProps>) => {\n const { channel } = props\n\n const dir = getSliderBgDirection(props.orientation, ctx.dir!)\n const value = ctx.valueAsColor\n\n const { minValue, maxValue } = ctx.valueAsColor.getChannelRange(channel)\n\n switch (channel) {\n case \"hue\":\n return `linear-gradient(to ${dir}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`\n case \"lightness\": {\n let start = ctx.valueAsColor.withChannelValue(channel, minValue).toString(\"css\")\n let middle = value.withChannelValue(channel, (maxValue - minValue) / 2).toString(\"css\")\n let end = value.withChannelValue(channel, maxValue).toString(\"css\")\n return `linear-gradient(to ${dir}, ${start}, ${middle}, ${end})`\n }\n case \"saturation\":\n case \"brightness\":\n case \"red\":\n case \"green\":\n case \"blue\":\n case \"alpha\": {\n let start = value.withChannelValue(channel, minValue).toString(\"css\")\n let end = value.withChannelValue(channel, maxValue).toString(\"css\")\n return `linear-gradient(to ${dir}, ${start}, ${end})`\n }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n}\n","import { Color, parseColor } from \"@zag-js/color-utils\"\nimport { createMachine } from \"@zag-js/core\"\nimport { trackPointerMove } from \"@zag-js/dom-event\"\nimport { raf } from \"@zag-js/dom-query\"\nimport { clampValue, getPercentValue, snapValueToStep } from \"@zag-js/numeric-range\"\nimport { disableTextSelection } from \"@zag-js/text-selection\"\nimport { compact } from \"@zag-js/utils\"\nimport { dom } from \"./color-picker.dom\"\nimport { ExtendedColorChannel, MachineContext, MachineState, UserDefinedContext } from \"./color-picker.types\"\nimport { getChannelDetails } from \"./utils/get-channel-details\"\nimport { getChannelInputValue } from \"./utils/get-channel-input-value\"\n\nexport function machine(userContext: UserDefinedContext) {\n const ctx = compact(userContext)\n\n return createMachine<MachineContext, MachineState>(\n {\n id: \"color-picker\",\n initial: \"idle\",\n context: {\n dir: \"ltr\",\n activeId: null,\n activeChannel: null,\n activeOrientation: null,\n value: \"#D9D9D9\",\n ...ctx,\n valueAsColor: parseColor(ctx.value || \"#D9D9D9\"),\n },\n\n computed: {\n isRtl: (ctx) => ctx.dir === \"rtl\",\n isInteractive: (ctx) => !(ctx.disabled || ctx.readOnly),\n },\n\n on: {\n \"VALUE.SET\": {\n actions: [\"setValue\"],\n },\n },\n\n created: [\"setValueAsColor\"],\n\n watch: {\n value: [\"setValueAsColor\", \"syncChannelInputs\", \"invokeOnChange\"],\n },\n\n states: {\n idle: {\n on: {\n \"EYEDROPPER.CLICK\": {\n actions: [\"openEyeDropper\"],\n },\n \"AREA.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setAreaColorFromPoint\", \"focusAreaThumb\"],\n },\n \"CHANNEL_SLIDER.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setChannelColorFromPoint\", \"focusChannelThumb\"],\n },\n \"CHANNEL_INPUT.FOCUS\": {\n target: \"focused\",\n actions: [\"setActiveChannel\"],\n },\n \"CHANNEL_INPUT.CHANGE\": {\n actions: [\"setChannelColorFromInput\"],\n },\n },\n },\n\n focused: {\n on: {\n \"AREA.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setAreaColorFromPoint\", \"focusAreaThumb\"],\n },\n \"CHANNEL_SLIDER.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setChannelColorFromPoint\", \"focusChannelThumb\"],\n },\n \"AREA.ARROW_LEFT\": {\n actions: [\"decrementXChannel\"],\n },\n \"AREA.ARROW_RIGHT\": {\n actions: [\"incrementXChannel\"],\n },\n \"AREA.ARROW_UP\": {\n actions: [\"incrementYChannel\"],\n },\n \"AREA.ARROW_DOWN\": {\n actions: [\"decrementYChannel\"],\n },\n \"AREA.PAGE_UP\": {\n actions: [\"incrementXChannel\"],\n },\n \"AREA.PAGE_DOWN\": {\n actions: [\"decrementXChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_LEFT\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_RIGHT\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_UP\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_DOWN\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.PAGE_UP\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.PAGE_DOWN\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.HOME\": {\n actions: [\"setChannelToMin\"],\n },\n \"CHANNEL_SLIDER.END\": {\n actions: [\"setChannelToMax\"],\n },\n \"CHANNEL_INPUT.FOCUS\": {\n actions: [\"setActiveChannel\"],\n },\n \"CHANNEL_INPUT.CHANGE\": {\n actions: [\"setChannelColorFromInput\"],\n },\n \"CHANNEL_INPUT.BLUR\": [\n {\n guard: \"isTextField\",\n target: \"idle\",\n actions: [\"setChannelColorFromInput\"],\n },\n { target: \"idle\" },\n ],\n \"CHANNEL_SLIDER.BLUR\": {\n target: \"idle\",\n },\n \"AREA.BLUR\": {\n target: \"idle\",\n },\n },\n },\n\n dragging: {\n exit: [\"clearActiveChannel\"],\n activities: [\"trackPointerMove\", \"disableTextSelection\"],\n on: {\n \"AREA.POINTER_MOVE\": {\n actions: [\"setAreaColorFromPoint\"],\n },\n \"AREA.POINTER_UP\": {\n target: \"focused\",\n actions: [\"invokeOnChangeEnd\"],\n },\n \"CHANNEL_SLIDER.POINTER_MOVE\": {\n actions: [\"setChannelColorFromPoint\"],\n },\n \"CHANNEL_SLIDER.POINTER_UP\": {\n target: \"focused\",\n actions: [\"invokeOnChangeEnd\"],\n },\n },\n },\n },\n },\n {\n guards: {\n isTextField: (_ctx, evt) => !!evt.isTextField,\n },\n activities: {\n trackPointerMove(ctx, _evt, { send }) {\n return trackPointerMove(dom.getDoc(ctx), {\n onPointerMove({ point }) {\n const type = ctx.activeId === \"area\" ? \"AREA.POINTER_MOVE\" : \"CHANNEL_SLIDER.POINTER_MOVE\"\n send({ type, point })\n },\n onPointerUp() {\n const type = ctx.activeId === \"area\" ? \"AREA.POINTER_UP\" : \"CHANNEL_SLIDER.POINTER_UP\"\n send({ type })\n },\n })\n },\n disableTextSelection(ctx) {\n return disableTextSelection({ doc: dom.getDoc(ctx), target: dom.getContentEl(ctx) })\n },\n },\n actions: {\n openEyeDropper(ctx) {\n const isSupported = \"EyeDropper\" in dom.getWin(ctx)\n if (!isSupported) return\n const win = dom.getWin(ctx) as any\n const picker = new win.EyeDropper()\n picker\n .open()\n .then(({ sRGBHex }: { sRGBHex: string }) => {\n const format = ctx.valueAsColor.getColorSpace()\n const color = parseColor(sRGBHex).toFormat(format)\n setColor(ctx, color)\n ctx.onChangeEnd?.({ value: ctx.value, valueAsColor: color })\n })\n .catch(() => void 0)\n },\n setActiveChannel(ctx, evt) {\n ctx.activeId = evt.id\n if (evt.channel) {\n ctx.activeChannel = evt.channel\n }\n if (evt.orientation) {\n ctx.activeOrientation = evt.orientation\n }\n },\n clearActiveChannel(ctx) {\n ctx.activeChannel = null\n ctx.activeId = null\n ctx.activeOrientation = null\n },\n setAreaColorFromPoint(ctx, evt) {\n const { xChannel, yChannel } = evt.channel || ctx.activeChannel\n\n const percent = dom.getAreaValueFromPoint(ctx, evt.point)\n const { getColorFromPoint } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const color = getColorFromPoint(percent.x, percent.y)\n\n if (!color) return\n setColor(ctx, color)\n },\n setChannelColorFromPoint(ctx, evt) {\n const channel = evt.channel || ctx.activeId\n const percent = dom.getChannelSliderValueFromPoint(ctx, evt.point, channel)\n\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(channel)\n const orientation = ctx.activeOrientation || \"horizontal\"\n\n const point = orientation === \"horizontal\" ? percent.x : percent.y\n const channelValue = getPercentValue(point, minValue, maxValue, step)\n\n const value = snapValueToStep(channelValue - step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(channel, value)\n\n setColor(ctx, newColor)\n },\n setValue(ctx, evt) {\n setColor(ctx, evt.value)\n },\n setValueAsColor(ctx) {\n try {\n const color = parseColor(ctx.value)\n if (color.isEqual(ctx.valueAsColor)) return\n ctx.valueAsColor = color\n } catch {}\n },\n syncChannelInputs(ctx) {\n const inputs = dom.getChannelInputEls(ctx)\n inputs.forEach((input) => {\n const channel = input.getAttribute(\"data-channel\") as ExtendedColorChannel | null\n if (!channel) return\n const value = getChannelInputValue(ctx.valueAsColor, channel)\n input.value = value.toString()\n })\n },\n setChannelColorFromInput(ctx, evt) {\n const { channel, isTextField, value } = evt\n try {\n const format = ctx.valueAsColor.getColorSpace()\n\n const newColor = isTextField\n ? parseColor(value).toFormat(format)\n : ctx.valueAsColor.withChannelValue(channel, value)\n\n setColor(ctx, newColor)\n //\n } catch {\n // reset input value\n const input = dom.getChannelInputEl(ctx, channel)\n if (!input) return\n input.value = getChannelInputValue(ctx.valueAsColor, channel)\n }\n },\n\n incrementChannel(ctx, evt) {\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(evt.channel)\n const channelValue = ctx.valueAsColor.getChannelValue(evt.channel)\n const value = snapValueToStep(channelValue + evt.step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, clampValue(value, minValue, maxValue))\n setColor(ctx, newColor)\n },\n decrementChannel(ctx, evt) {\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(evt.channel)\n const channelValue = ctx.valueAsColor.getChannelValue(evt.channel)\n const value = snapValueToStep(channelValue - evt.step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, clampValue(value, minValue, maxValue))\n setColor(ctx, newColor)\n },\n\n incrementXChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { incrementX } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(xChannel, incrementX(evt.step))\n setColor(ctx, newColor)\n },\n decrementXChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { decrementX } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(xChannel, decrementX(evt.step))\n setColor(ctx, newColor)\n },\n\n incrementYChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { incrementY } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(yChannel, incrementY(evt.step))\n setColor(ctx, newColor)\n },\n decrementYChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { decrementY } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(yChannel, decrementY(evt.step))\n setColor(ctx, newColor)\n },\n\n setChannelToMax(ctx, evt) {\n const { maxValue } = ctx.valueAsColor.getChannelRange(evt.channel)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, maxValue)\n setColor(ctx, newColor)\n },\n setChannelToMin(ctx, evt) {\n const { minValue } = ctx.valueAsColor.getChannelRange(evt.channel)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, minValue)\n setColor(ctx, newColor)\n },\n\n invokeOnChangeEnd(ctx) {\n ctx.onChangeEnd?.({ value: ctx.value, valueAsColor: ctx.valueAsColor })\n },\n invokeOnChange(ctx) {\n ctx.onChange?.({ value: ctx.value, valueAsColor: ctx.valueAsColor })\n },\n focusAreaThumb(ctx) {\n raf(() => {\n dom.getAreaThumbEl(ctx)?.focus({ preventScroll: true })\n })\n },\n focusChannelThumb(ctx, evt) {\n raf(() => {\n dom.getChannelSliderThumbEl(ctx, evt.channel)?.focus({ preventScroll: true })\n })\n },\n },\n },\n )\n}\n\nconst setColor = (ctx: MachineContext, color: Color) => {\n ctx.value = color.toString(\"css\")\n ctx.valueAsColor = color\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAA8B;AAEvB,IAAM,cAAU,8BAAc,gBAAgB;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,QAAQ,QAAQ,MAAM;;;ACjBnC,IAAAA,sBAA2E;AAC3E,IAAAC,oBAQO;AACP,IAAAC,oBAAyB;;;ACTzB,uBAA6C;AAC7C,uBAAsC;AAG/B,IAAM,UAAM,8BAAY;AAAA,EAC7B,cAAc,CAAC,QAAa,IAAI,KAAK,WAAW,gBAAgB,IAAI;AAAA,EACpE,WAAW,CAAC,QA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M,SAAS,KAAK;AAChC,MAAI,eAAe;AACrB;","names":["import_color_utils","import_dom_event","import_dom_query","import_color_utils","import_dom_event","import_dom_query","import_numeric_range","ctx"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/color-picker.anatomy.ts","../src/color-picker.connect.ts","../src/color-picker.dom.ts","../src/utils/get-channel-details.ts","../src/utils/get-channel-display-color.ts","../src/utils/get-channel-input-value.ts","../src/utils/generate-format-background.ts","../src/utils/get-color-area-gradient.ts","../src/utils/get-slider-background.ts","../src/color-picker.machine.ts"],"sourcesContent":["export { anatomy } from \"./color-picker.anatomy\"\nexport { connect } from \"./color-picker.connect\"\nexport { machine } from \"./color-picker.machine\"\nexport type {\n Color,\n ColorAxes,\n ColorFormat,\n ColorAreaProps,\n ColorChannel,\n ColorChannelProps,\n ColorChannelInputProps,\n ColorSwatchProps,\n ColorType,\n UserDefinedContext as Context,\n PublicApi,\n} from \"./color-picker.types\"\n","import { createAnatomy } from \"@zag-js/anatomy\"\n\nexport const anatomy = createAnatomy(\"color-picker\", [\n \"area\",\n \"areaThumb\",\n \"areaGradient\",\n \"channelSliderTrack\",\n \"channelSliderTrackBg\",\n \"channelSliderThumb\",\n \"channelInput\",\n \"swatch\",\n \"swatchBg\",\n \"content\",\n \"label\",\n \"eyeDropTrigger\",\n])\n\nexport const parts = anatomy.build()\n","import { normalizeColor, type Color, type ColorChannel, type ColorFormat } from \"@zag-js/color-utils\"\nimport {\n getEventKey,\n getEventPoint,\n getEventStep,\n getNativeEvent,\n isLeftClick,\n isModifiedEvent,\n type EventKeyMap,\n} from \"@zag-js/dom-event\"\nimport { dataAttr } from \"@zag-js/dom-query\"\nimport type { NormalizeProps, PropTypes } from \"@zag-js/types\"\nimport { parts } from \"./color-picker.anatomy\"\nimport { dom } from \"./color-picker.dom\"\nimport type {\n ColorAreaProps,\n ColorChannelInputProps,\n ColorChannelProps,\n ColorSwatchProps,\n PublicApi,\n Send,\n State,\n} from \"./color-picker.types\"\nimport { getChannelDetails } from \"./utils/get-channel-details\"\nimport { getChannelDisplayColor } from \"./utils/get-channel-display-color\"\nimport { getChannelInputRange, getChannelInputValue } from \"./utils/get-channel-input-value\"\nimport { getColorAreaGradient } from \"./utils/get-color-area-gradient\"\nimport { getSliderBgImage } from \"./utils/get-slider-background\"\n\nexport function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): PublicApi<T> {\n const valueAsColor = state.context.valueAsColor\n const isDisabled = state.context.disabled\n const isInteractive = state.context.isInteractive\n const isDragging = state.matches(\"dragging\")\n\n const channels = valueAsColor.getColorChannels()\n\n return {\n isDragging,\n value: state.context.value,\n valueAsColor,\n channels,\n\n setColor(value: string | Color) {\n send({ type: \"VALUE.SET\", value: normalizeColor(value), src: \"set-color\" })\n },\n\n setChannelValue(channel: ColorChannel, value: number) {\n const color = valueAsColor.withChannelValue(channel, value)\n send({ type: \"VALUE.SET\", value: color, src: \"set-channel\" })\n },\n\n setFormat(format: ColorFormat) {\n const value = valueAsColor.toFormat(format)\n send({ type: \"VALUE.SET\", value, src: \"set-format\" })\n },\n\n contentProps: normalize.element({\n ...parts.content.attrs,\n id: dom.getContentId(state.context),\n }),\n\n getAreaProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { areaStyles } = getColorAreaGradient(state.context, xChannel, yChannel)\n\n return normalize.element({\n ...parts.area.attrs,\n id: dom.getAreaId(state.context),\n role: \"group\",\n onPointerDown(event) {\n if (!isInteractive) return\n\n const evt = getNativeEvent(event)\n if (!isLeftClick(evt) || isModifiedEvent(evt)) return\n\n const point = getEventPoint(evt)\n const channel = { xChannel, yChannel }\n\n send({ type: \"AREA.POINTER_DOWN\", point, channel, id: \"area\" })\n },\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n ...areaStyles,\n },\n })\n },\n\n getAreaGradientProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { areaGradientStyles } = getColorAreaGradient(state.context, xChannel, yChannel)\n\n return normalize.element({\n ...parts.areaGradient.attrs,\n id: dom.getAreaGradientId(state.context),\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n ...areaGradientStyles,\n },\n })\n },\n\n getAreaThumbProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { getThumbPosition } = getChannelDetails(valueAsColor, xChannel, yChannel)\n const { x, y } = getThumbPosition()\n\n const channel = { xChannel, yChannel }\n\n return normalize.element({\n ...parts.areaThumb.attrs,\n id: dom.getAreaThumbId(state.context),\n tabIndex: isDisabled ? undefined : 0,\n \"data-disabled\": dataAttr(isDisabled),\n role: \"presentation\",\n style: {\n position: \"absolute\",\n left: `${x * 100}%`,\n top: `${y * 100}%`,\n transform: \"translate(-50%, -50%)\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n background: valueAsColor.withChannelValue(\"alpha\", 1).toString(\"css\"),\n },\n onBlur() {\n send(\"AREA.BLUR\")\n },\n onKeyDown(event) {\n if (!isInteractive) return\n\n const step = getEventStep(event)\n\n const keyMap: EventKeyMap = {\n ArrowUp() {\n send({ type: \"AREA.ARROW_UP\", channel, step })\n },\n ArrowDown() {\n send({ type: \"AREA.ARROW_DOWN\", channel, step })\n },\n ArrowLeft() {\n send({ type: \"AREA.ARROW_LEFT\", channel, step })\n },\n ArrowRight() {\n send({ type: \"AREA.ARROW_RIGHT\", channel, step })\n },\n PageUp() {\n send({ type: \"AREA.PAGE_UP\", channel, step })\n },\n PageDown() {\n send({ type: \"AREA.PAGE_DOWN\", channel, step })\n },\n }\n\n const exec = keyMap[getEventKey(event, state.context)]\n\n if (exec) {\n exec(event)\n event.preventDefault()\n }\n },\n })\n },\n\n getChannelSliderTrackProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n\n return normalize.element({\n ...parts.channelSliderTrack.attrs,\n id: dom.getChannelSliderTrackId(state.context, channel),\n role: \"group\",\n \"data-channel\": channel,\n \"data-orientation\": orientation,\n onPointerDown(event) {\n if (!isInteractive) return\n\n const evt = getNativeEvent(event)\n if (!isLeftClick(evt) || isModifiedEvent(evt)) return\n\n const point = getEventPoint(evt)\n send({ type: \"CHANNEL_SLIDER.POINTER_DOWN\", channel, point, id: channel, orientation })\n },\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n backgroundImage: getSliderBgImage(state.context, { orientation, channel }),\n },\n })\n },\n\n getChannelSliderBackgroundProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n return normalize.element({\n ...parts.channelSliderTrackBg.attrs,\n \"data-orientation\": orientation,\n \"data-channel\": channel,\n style: {\n position: \"absolute\",\n backgroundColor: \"#fff\",\n backgroundImage: [\n \"linear-gradient(-45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(-45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n \"linear-gradient(45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n ].join(\",\"),\n backgroundSize: \"16px 16px\",\n backgroundPosition: \"-2px -2px,-2px 6px,6px -10px,-10px -2px\",\n inset: 0,\n zIndex: -1,\n },\n })\n },\n\n getChannelSliderThumbProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n const { minValue, maxValue, step: stepValue } = valueAsColor.getChannelRange(channel)\n const channelValue = valueAsColor.getChannelValue(channel)\n\n const offset = (channelValue - minValue) / (maxValue - minValue)\n\n const placementStyles =\n orientation === \"horizontal\"\n ? { left: `${offset * 100}%`, top: \"50%\" }\n : { top: `${offset * 100}%`, left: \"50%\" }\n\n return normalize.element({\n ...parts.channelSliderThumb.attrs,\n id: dom.getChannelSliderThumbId(state.context, channel),\n role: \"slider\",\n \"aria-label\": channel,\n tabIndex: isDisabled ? undefined : 0,\n \"data-channel\": channel,\n \"data-disabled\": dataAttr(isDisabled),\n \"data-orientation\": orientation,\n \"aria-disabled\": dataAttr(isDisabled),\n \"aria-orientation\": orientation,\n \"aria-valuemax\": maxValue,\n \"aria-valuemin\": minValue,\n \"aria-valuenow\": channelValue,\n style: {\n forcedColorAdjust: \"none\",\n position: \"absolute\",\n background: getChannelDisplayColor(valueAsColor, channel).toString(\"css\"),\n ...placementStyles,\n },\n onFocus() {\n if (!isInteractive) return\n send({ type: \"CHANNEL_SLIDER.FOCUS\", channel })\n },\n onBlur() {\n if (!isInteractive) return\n send({ type: \"CHANNEL_SLIDER.BLUR\", channel })\n },\n onKeyDown(event) {\n if (!isInteractive) return\n const step = getEventStep(event) * stepValue\n\n const keyMap: EventKeyMap = {\n ArrowUp() {\n send({ type: \"CHANNEL_SLIDER.ARROW_UP\", channel, step })\n },\n ArrowDown() {\n send({ type: \"CHANNEL_SLIDER.ARROW_DOWN\", channel, step })\n },\n ArrowLeft() {\n send({ type: \"CHANNEL_SLIDER.ARROW_LEFT\", channel, step })\n },\n ArrowRight() {\n send({ type: \"CHANNEL_SLIDER.ARROW_RIGHT\", channel, step })\n },\n PageUp() {\n send({ type: \"CHANNEL_SLIDER.PAGE_UP\", channel })\n },\n PageDown() {\n send({ type: \"CHANNEL_SLIDER.PAGE_DOWN\", channel })\n },\n Home() {\n send({ type: \"CHANNEL_SLIDER.HOME\", channel })\n },\n End() {\n send({ type: \"CHANNEL_SLIDER.END\", channel })\n },\n }\n\n const exec = keyMap[getEventKey(event, state.context)]\n\n if (exec) {\n exec(event)\n event.preventDefault()\n }\n },\n })\n },\n\n getChannelInputProps(props: ColorChannelInputProps) {\n const { channel } = props\n const isTextField = channel === \"hex\" || channel === \"css\"\n const range = getChannelInputRange(valueAsColor, channel)\n\n return normalize.input({\n ...parts.channelInput.attrs,\n type: isTextField ? \"text\" : \"number\",\n \"data-channel\": channel,\n \"aria-label\": channel,\n disabled: isDisabled,\n \"data-disabled\": dataAttr(isDisabled),\n readOnly: state.context.readOnly,\n id: dom.getChannelInputId(state.context, channel),\n defaultValue: getChannelInputValue(valueAsColor, channel),\n min: range?.minValue,\n max: range?.maxValue,\n step: range?.step,\n onFocus() {\n send({ type: \"CHANNEL_INPUT.FOCUS\", channel })\n },\n onChange(event) {\n if (isTextField) return\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.CHANGE\", channel, value, isTextField })\n },\n onBlur(event) {\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.BLUR\", channel, value, isTextField })\n },\n onKeyDown(event) {\n if (!isTextField) return\n if (event.key === \"Enter\") {\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.CHANGE\", channel, value, isTextField })\n }\n },\n style: {\n appearance: \"none\",\n WebkitAppearance: \"none\",\n MozAppearance: \"textfield\",\n },\n })\n },\n\n eyeDropperTriggerProps: normalize.button({\n ...parts.eyeDropTrigger.attrs,\n onClick() {\n send(\"EYEDROPPER.CLICK\")\n },\n }),\n\n getSwatchBackgroundProps(props: ColorSwatchProps) {\n const { value } = props\n const alpha = normalizeColor(value).getChannelValue(\"alpha\")\n return normalize.element({\n ...parts.swatchBg.attrs,\n \"data-alpha\": alpha,\n style: {\n width: \"100%\",\n height: \"100%\",\n background: \"#fff\",\n backgroundImage: [\n \"linear-gradient(-45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(-45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n \"linear-gradient(45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n ].join(\",\"),\n backgroundPosition: \"-2px -2px,-2px 6px,6px -10px,-10px -2px\",\n backgroundSize: \"16px 16px\",\n position: \"absolute\",\n inset: \"0px\",\n zIndex: -1,\n },\n })\n },\n\n getSwatchProps(props: ColorSwatchProps) {\n const { value, readOnly } = props\n const color = normalizeColor(value).toFormat(valueAsColor.getColorSpace())\n return normalize.element({\n ...parts.swatch.attrs,\n onClick() {\n if (readOnly) return\n send({ type: \"VALUE.SET\", value: color })\n },\n style: {\n position: \"relative\",\n background: color.toString(\"css\"),\n },\n })\n },\n }\n}\n","import type { ColorChannel } from \"@zag-js/color-utils\"\nimport { getRelativePoint, type Point } from \"@zag-js/dom-event\"\nimport { createScope, queryAll } from \"@zag-js/dom-query\"\nimport type { MachineContext as Ctx } from \"./color-picker.types\"\n\nexport const dom = createScope({\n getContentId: (ctx: Ctx) => ctx.ids?.content ?? `color-picker:${ctx.id}:content`,\n getAreaId: (ctx: Ctx) => ctx.ids?.area ?? `color-picker:${ctx.id}:area`,\n getAreaGradientId: (ctx: Ctx) => ctx.ids?.areaGradient ?? `color-picker:${ctx.id}:area-gradient`,\n getAreaThumbId: (ctx: Ctx) => ctx.ids?.areaThumb ?? `color-picker:${ctx.id}:area-thumb`,\n getChannelSliderTrackId: (ctx: Ctx, channel: ColorChannel) =>\n ctx.ids?.channelSliderTrack?.(channel) ?? `color-picker:${ctx.id}:slider-track:${channel}`,\n getChannelInputId: (ctx: Ctx, channel: string) =>\n ctx.ids?.channelInput?.(channel) ?? `color-picker:${ctx.id}:input:${channel}`,\n getChannelSliderThumbId: (ctx: Ctx, channel: ColorChannel) =>\n ctx.ids?.channelSliderThumb?.(channel) ?? `color-picker:${ctx.id}:slider-thumb:${channel}`,\n\n getContentEl: (ctx: Ctx) => dom.queryById(ctx, dom.getContentId(ctx)),\n getAreaThumbEl: (ctx: Ctx) => dom.queryById(ctx, dom.getAreaThumbId(ctx)),\n getChannelSliderThumbEl: (ctx: Ctx, channel: ColorChannel) =>\n dom.queryById(ctx, dom.getChannelSliderThumbId(ctx, channel)),\n getChannelInputEl: (ctx: Ctx, channel: string) =>\n dom.queryById<HTMLInputElement>(ctx, dom.getChannelInputId(ctx, channel)),\n\n getAreaEl: (ctx: Ctx) => dom.queryById(ctx, dom.getAreaId(ctx)),\n getAreaValueFromPoint(ctx: Ctx, point: Point) {\n const { percent } = getRelativePoint(point, dom.getAreaEl(ctx))\n return percent\n },\n\n getChannelSliderTrackEl: (ctx: Ctx, channel: ColorChannel) => {\n return dom.queryById(ctx, dom.getChannelSliderTrackId(ctx, channel))\n },\n getChannelSliderValueFromPoint(ctx: Ctx, point: Point, channel: ColorChannel) {\n const { percent } = getRelativePoint(point, dom.getChannelSliderTrackEl(ctx, channel))\n return percent\n },\n getChannelInputEls: (ctx: Ctx) => {\n return queryAll<HTMLInputElement>(dom.getContentEl(ctx), \"input[data-channel]\")\n },\n})\n","import type { Color, ColorChannel } from \"@zag-js/color-utils\"\nimport { getPercentValue, snapValueToStep } from \"@zag-js/numeric-range\"\n\nexport function getChannelDetails(color: Color, xChannel: ColorChannel, yChannel: ColorChannel) {\n const channels = color.getColorSpaceAxes({ xChannel, yChannel })\n\n const xChannelRange = color.getChannelRange(channels.xChannel)\n const yChannelRange = color.getChannelRange(channels.yChannel)\n\n const { minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX } = xChannelRange\n const { minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY } = yChannelRange\n\n const xValue = color.getChannelValue(channels.xChannel)\n const yValue = color.getChannelValue(channels.yChannel)\n\n return {\n channels,\n xChannelStep: stepX,\n yChannelStep: stepY,\n xChannelPageStep: pageSizeX,\n yChannelPageStep: pageSizeY,\n xValue,\n yValue,\n getThumbPosition() {\n let x = (xValue - minValueX) / (maxValueX - minValueX)\n let y = 1 - (yValue - minValueY) / (maxValueY - minValueY)\n return { x, y }\n },\n incrementX(stepSize: number) {\n return xValue + stepSize > maxValueX ? maxValueX : snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX)\n },\n incrementY(stepSize: number) {\n return yValue + stepSize > maxValueY ? maxValueY : snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY)\n },\n decrementX(stepSize: number) {\n return snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX)\n },\n decrementY(stepSize: number) {\n return snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY)\n },\n getColorFromPoint(x: number, y: number) {\n let newXValue = getPercentValue(x, minValueX, maxValueX, stepX)\n let newYValue = getPercentValue(1 - y, minValueY, maxValueY, stepY)\n\n let newColor: Color | undefined\n\n if (newXValue !== xValue) {\n newXValue = snapValueToStep(newXValue, minValueX, maxValueX, stepX)\n newColor = color.withChannelValue(channels.xChannel, newXValue)\n }\n\n if (newYValue !== yValue) {\n newYValue = snapValueToStep(newYValue, minValueY, maxValueY, stepY)\n newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue)\n }\n\n return newColor\n },\n }\n}\n","import { parseColor, type Color, type ColorChannel } from \"@zag-js/color-utils\"\n\nexport function getChannelDisplayColor(color: Color, channel: ColorChannel) {\n switch (channel) {\n case \"hue\":\n return parseColor(`hsl(${color.getChannelValue(\"hue\")}, 100%, 50%)`)\n case \"lightness\":\n case \"brightness\":\n case \"saturation\":\n case \"red\":\n case \"green\":\n case \"blue\":\n return color.withChannelValue(\"alpha\", 1)\n case \"alpha\": {\n return color\n }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n}\n","import type { Color } from \"@zag-js/color-utils\"\nimport type { ExtendedColorChannel } from \"../color-picker.types\"\n\nexport function getChannelInputValue(color: Color, channel: ExtendedColorChannel) {\n switch (channel) {\n case \"hex\":\n return color.toString(\"hex\")\n case \"css\":\n return color.toString(\"css\")\n default:\n return color.getChannelValue(channel).toString()\n }\n}\n\nexport function getChannelInputRange(color: Color, channel: ExtendedColorChannel) {\n switch (channel) {\n case \"hex\":\n case \"css\":\n return undefined\n default:\n return color.getChannelRange(channel)\n }\n}\n","export const generateRGB_R = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_G = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_B = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateHSL_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(dir)]\n }, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(!dir)]\n }, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n \"hsl(0, 0%, 50%)\",\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_L = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n backgroundImage: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_B = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n \"#000\",\n ].join(\",\"),\n },\n }\n return result\n}\n","import type { ColorChannel } from \"@zag-js/color-utils\"\nimport type { Style } from \"@zag-js/types\"\nimport type { MachineContext } from \"../color-picker.types\"\nimport {\n generateHSB_B,\n generateHSB_H,\n generateHSB_S,\n generateHSL_H,\n generateHSL_L,\n generateHSL_S,\n generateRGB_B,\n generateRGB_G,\n generateRGB_R,\n} from \"./generate-format-background\"\n\nexport function getColorAreaGradient(ctx: MachineContext, xChannel: ColorChannel, yChannel: ColorChannel) {\n const value = ctx.valueAsColor\n\n const { zChannel } = value.getColorSpaceAxes({ xChannel, yChannel })\n const zValue = value.getChannelValue(zChannel)\n\n const { minValue: zMin, maxValue: zMax } = value.getChannelRange(zChannel)\n const orientation: [string, string] = [\"top\", ctx.dir === \"rtl\" ? \"left\" : \"right\"]\n\n let dir = false\n let background = { areaStyles: {} as Style, areaGradientStyles: {} as Style }\n\n let alphaValue = (zValue - zMin) / (zMax - zMin)\n let isHSL = value.getColorSpace() === \"hsl\"\n\n switch (zChannel) {\n case \"red\": {\n dir = xChannel === \"green\"\n background = generateRGB_R(orientation, dir, zValue)\n break\n }\n\n case \"green\": {\n dir = xChannel === \"red\"\n background = generateRGB_G(orientation, dir, zValue)\n break\n }\n\n case \"blue\": {\n dir = xChannel === \"red\"\n background = generateRGB_B(orientation, dir, zValue)\n break\n }\n\n case \"hue\": {\n dir = xChannel !== \"saturation\"\n if (isHSL) {\n background = generateHSL_H(orientation, dir, zValue)\n } else {\n background = generateHSB_H(orientation, dir, zValue)\n }\n break\n }\n\n case \"saturation\": {\n dir = xChannel === \"hue\"\n if (isHSL) {\n background = generateHSL_S(orientation, dir, alphaValue)\n } else {\n background = generateHSB_S(orientation, dir, alphaValue)\n }\n break\n }\n\n case \"brightness\": {\n dir = xChannel === \"hue\"\n background = generateHSB_B(orientation, dir, alphaValue)\n break\n }\n\n case \"lightness\": {\n dir = xChannel === \"hue\"\n background = generateHSL_L(orientation, dir, zValue)\n break\n }\n }\n\n return background\n}\n","import type { ColorChannelProps, MachineContext } from \"../color-picker.types\"\n\nfunction getSliderBgDirection(orientation: \"vertical\" | \"horizontal\", dir: \"ltr\" | \"rtl\") {\n if (orientation === \"vertical\") {\n return \"top\"\n } else if (dir === \"ltr\") {\n return \"right\"\n } else {\n return \"left\"\n }\n}\n\nexport const getSliderBgImage = (ctx: MachineContext, props: Required<ColorChannelProps>) => {\n const { channel } = props\n\n const dir = getSliderBgDirection(props.orientation, ctx.dir!)\n const value = ctx.valueAsColor\n\n const { minValue, maxValue } = ctx.valueAsColor.getChannelRange(channel)\n\n switch (channel) {\n case \"hue\":\n return `linear-gradient(to ${dir}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`\n case \"lightness\": {\n let start = ctx.valueAsColor.withChannelValue(channel, minValue).toString(\"css\")\n let middle = value.withChannelValue(channel, (maxValue - minValue) / 2).toString(\"css\")\n let end = value.withChannelValue(channel, maxValue).toString(\"css\")\n return `linear-gradient(to ${dir}, ${start}, ${middle}, ${end})`\n }\n case \"saturation\":\n case \"brightness\":\n case \"red\":\n case \"green\":\n case \"blue\":\n case \"alpha\": {\n let start = value.withChannelValue(channel, minValue).toString(\"css\")\n let end = value.withChannelValue(channel, maxValue).toString(\"css\")\n return `linear-gradient(to ${dir}, ${start}, ${end})`\n }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n}\n","import { type Color, parseColor } from \"@zag-js/color-utils\"\nimport { createMachine } from \"@zag-js/core\"\nimport { trackPointerMove } from \"@zag-js/dom-event\"\nimport { raf } from \"@zag-js/dom-query\"\nimport { clampValue, getPercentValue, snapValueToStep } from \"@zag-js/numeric-range\"\nimport { disableTextSelection } from \"@zag-js/text-selection\"\nimport { compact } from \"@zag-js/utils\"\nimport { dom } from \"./color-picker.dom\"\nimport type { ExtendedColorChannel, MachineContext, MachineState, UserDefinedContext } from \"./color-picker.types\"\nimport { getChannelDetails } from \"./utils/get-channel-details\"\nimport { getChannelInputValue } from \"./utils/get-channel-input-value\"\n\nexport function machine(userContext: UserDefinedContext) {\n const ctx = compact(userContext)\n\n return createMachine<MachineContext, MachineState>(\n {\n id: \"color-picker\",\n initial: \"idle\",\n context: {\n dir: \"ltr\",\n activeId: null,\n activeChannel: null,\n activeOrientation: null,\n value: \"#D9D9D9\",\n ...ctx,\n valueAsColor: parseColor(ctx.value || \"#D9D9D9\"),\n },\n\n computed: {\n isRtl: (ctx) => ctx.dir === \"rtl\",\n isInteractive: (ctx) => !(ctx.disabled || ctx.readOnly),\n },\n\n on: {\n \"VALUE.SET\": {\n actions: [\"setValue\"],\n },\n },\n\n created: [\"setValueAsColor\"],\n\n watch: {\n value: [\"setValueAsColor\", \"syncChannelInputs\", \"invokeOnChange\"],\n },\n\n states: {\n idle: {\n on: {\n \"EYEDROPPER.CLICK\": {\n actions: [\"openEyeDropper\"],\n },\n \"AREA.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setAreaColorFromPoint\", \"focusAreaThumb\"],\n },\n \"CHANNEL_SLIDER.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setChannelColorFromPoint\", \"focusChannelThumb\"],\n },\n \"CHANNEL_INPUT.FOCUS\": {\n target: \"focused\",\n actions: [\"setActiveChannel\"],\n },\n \"CHANNEL_INPUT.CHANGE\": {\n actions: [\"setChannelColorFromInput\"],\n },\n },\n },\n\n focused: {\n on: {\n \"AREA.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setAreaColorFromPoint\", \"focusAreaThumb\"],\n },\n \"CHANNEL_SLIDER.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setChannelColorFromPoint\", \"focusChannelThumb\"],\n },\n \"AREA.ARROW_LEFT\": {\n actions: [\"decrementXChannel\"],\n },\n \"AREA.ARROW_RIGHT\": {\n actions: [\"incrementXChannel\"],\n },\n \"AREA.ARROW_UP\": {\n actions: [\"incrementYChannel\"],\n },\n \"AREA.ARROW_DOWN\": {\n actions: [\"decrementYChannel\"],\n },\n \"AREA.PAGE_UP\": {\n actions: [\"incrementXChannel\"],\n },\n \"AREA.PAGE_DOWN\": {\n actions: [\"decrementXChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_LEFT\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_RIGHT\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_UP\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_DOWN\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.PAGE_UP\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.PAGE_DOWN\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.HOME\": {\n actions: [\"setChannelToMin\"],\n },\n \"CHANNEL_SLIDER.END\": {\n actions: [\"setChannelToMax\"],\n },\n \"CHANNEL_INPUT.FOCUS\": {\n actions: [\"setActiveChannel\"],\n },\n \"CHANNEL_INPUT.CHANGE\": {\n actions: [\"setChannelColorFromInput\"],\n },\n \"CHANNEL_INPUT.BLUR\": [\n {\n guard: \"isTextField\",\n target: \"idle\",\n actions: [\"setChannelColorFromInput\"],\n },\n { target: \"idle\" },\n ],\n \"CHANNEL_SLIDER.BLUR\": {\n target: \"idle\",\n },\n \"AREA.BLUR\": {\n target: \"idle\",\n },\n },\n },\n\n dragging: {\n exit: [\"clearActiveChannel\"],\n activities: [\"trackPointerMove\", \"disableTextSelection\"],\n on: {\n \"AREA.POINTER_MOVE\": {\n actions: [\"setAreaColorFromPoint\"],\n },\n \"AREA.POINTER_UP\": {\n target: \"focused\",\n actions: [\"invokeOnChangeEnd\"],\n },\n \"CHANNEL_SLIDER.POINTER_MOVE\": {\n actions: [\"setChannelColorFromPoint\"],\n },\n \"CHANNEL_SLIDER.POINTER_UP\": {\n target: \"focused\",\n actions: [\"invokeOnChangeEnd\"],\n },\n },\n },\n },\n },\n {\n guards: {\n isTextField: (_ctx, evt) => !!evt.isTextField,\n },\n activities: {\n trackPointerMove(ctx, _evt, { send }) {\n return trackPointerMove(dom.getDoc(ctx), {\n onPointerMove({ point }) {\n const type = ctx.activeId === \"area\" ? \"AREA.POINTER_MOVE\" : \"CHANNEL_SLIDER.POINTER_MOVE\"\n send({ type, point })\n },\n onPointerUp() {\n const type = ctx.activeId === \"area\" ? \"AREA.POINTER_UP\" : \"CHANNEL_SLIDER.POINTER_UP\"\n send({ type })\n },\n })\n },\n disableTextSelection(ctx) {\n return disableTextSelection({ doc: dom.getDoc(ctx), target: dom.getContentEl(ctx) })\n },\n },\n actions: {\n openEyeDropper(ctx) {\n const isSupported = \"EyeDropper\" in dom.getWin(ctx)\n if (!isSupported) return\n const win = dom.getWin(ctx) as any\n const picker = new win.EyeDropper()\n picker\n .open()\n .then(({ sRGBHex }: { sRGBHex: string }) => {\n const format = ctx.valueAsColor.getColorSpace()\n const color = parseColor(sRGBHex).toFormat(format)\n setColor(ctx, color)\n ctx.onChangeEnd?.({ value: ctx.value, valueAsColor: color })\n })\n .catch(() => void 0)\n },\n setActiveChannel(ctx, evt) {\n ctx.activeId = evt.id\n if (evt.channel) {\n ctx.activeChannel = evt.channel\n }\n if (evt.orientation) {\n ctx.activeOrientation = evt.orientation\n }\n },\n clearActiveChannel(ctx) {\n ctx.activeChannel = null\n ctx.activeId = null\n ctx.activeOrientation = null\n },\n setAreaColorFromPoint(ctx, evt) {\n const { xChannel, yChannel } = evt.channel || ctx.activeChannel\n\n const percent = dom.getAreaValueFromPoint(ctx, evt.point)\n const { getColorFromPoint } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const color = getColorFromPoint(percent.x, percent.y)\n\n if (!color) return\n setColor(ctx, color)\n },\n setChannelColorFromPoint(ctx, evt) {\n const channel = evt.channel || ctx.activeId\n const percent = dom.getChannelSliderValueFromPoint(ctx, evt.point, channel)\n\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(channel)\n const orientation = ctx.activeOrientation || \"horizontal\"\n\n const point = orientation === \"horizontal\" ? percent.x : percent.y\n const channelValue = getPercentValue(point, minValue, maxValue, step)\n\n const value = snapValueToStep(channelValue - step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(channel, value)\n\n setColor(ctx, newColor)\n },\n setValue(ctx, evt) {\n setColor(ctx, evt.value)\n },\n setValueAsColor(ctx) {\n try {\n const color = parseColor(ctx.value)\n if (color.isEqual(ctx.valueAsColor)) return\n ctx.valueAsColor = color\n } catch {}\n },\n syncChannelInputs(ctx) {\n const inputs = dom.getChannelInputEls(ctx)\n inputs.forEach((input) => {\n const channel = input.getAttribute(\"data-channel\") as ExtendedColorChannel | null\n if (!channel) return\n const value = getChannelInputValue(ctx.valueAsColor, channel)\n input.value = value.toString()\n })\n },\n setChannelColorFromInput(ctx, evt) {\n const { channel, isTextField, value } = evt\n try {\n const format = ctx.valueAsColor.getColorSpace()\n\n const newColor = isTextField\n ? parseColor(value).toFormat(format)\n : ctx.valueAsColor.withChannelValue(channel, value)\n\n setColor(ctx, newColor)\n //\n } catch {\n // reset input value\n const input = dom.getChannelInputEl(ctx, channel)\n if (!input) return\n input.value = getChannelInputValue(ctx.valueAsColor, channel)\n }\n },\n\n incrementChannel(ctx, evt) {\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(evt.channel)\n const channelValue = ctx.valueAsColor.getChannelValue(evt.channel)\n const value = snapValueToStep(channelValue + evt.step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, clampValue(value, minValue, maxValue))\n setColor(ctx, newColor)\n },\n decrementChannel(ctx, evt) {\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(evt.channel)\n const channelValue = ctx.valueAsColor.getChannelValue(evt.channel)\n const value = snapValueToStep(channelValue - evt.step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, clampValue(value, minValue, maxValue))\n setColor(ctx, newColor)\n },\n\n incrementXChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { incrementX } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(xChannel, incrementX(evt.step))\n setColor(ctx, newColor)\n },\n decrementXChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { decrementX } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(xChannel, decrementX(evt.step))\n setColor(ctx, newColor)\n },\n\n incrementYChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { incrementY } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(yChannel, incrementY(evt.step))\n setColor(ctx, newColor)\n },\n decrementYChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { decrementY } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(yChannel, decrementY(evt.step))\n setColor(ctx, newColor)\n },\n\n setChannelToMax(ctx, evt) {\n const { maxValue } = ctx.valueAsColor.getChannelRange(evt.channel)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, maxValue)\n setColor(ctx, newColor)\n },\n setChannelToMin(ctx, evt) {\n const { minValue } = ctx.valueAsColor.getChannelRange(evt.channel)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, minValue)\n setColor(ctx, newColor)\n },\n\n invokeOnChangeEnd(ctx) {\n ctx.onChangeEnd?.({ value: ctx.value, valueAsColor: ctx.valueAsColor })\n },\n invokeOnChange(ctx) {\n ctx.onChange?.({ value: ctx.value, valueAsColor: ctx.valueAsColor })\n },\n focusAreaThumb(ctx) {\n raf(() => {\n dom.getAreaThumbEl(ctx)?.focus({ preventScroll: true })\n })\n },\n focusChannelThumb(ctx, evt) {\n raf(() => {\n dom.getChannelSliderThumbEl(ctx, evt.channel)?.focus({ preventScroll: true })\n })\n },\n },\n },\n )\n}\n\nconst setColor = (ctx: MachineContext, color: Color) => {\n ctx.value = color.toString(\"css\")\n ctx.valueAsColor = color\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAA8B;AAEvB,IAAM,cAAU,8BAAc,gBAAgB;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,QAAQ,QAAQ,MAAM;;;ACjBnC,IAAAA,sBAAgF;AAChF,IAAAC,oBAQO;AACP,IAAAC,oBAAyB;;;ACTzB,uBAA6C;AAC7C,uBAAsC;AAG/B,IAAM,UAAM,8BAAY;AAAA,EAC7B,cAAc,CAAC,QAAa,IAAI,KAAK,WAAW,gBAAgB,IAAI;AAAA,EACpE,WAAW,CAAC,QAAa,IAAI,KAAK,QAAQ,gBAAgB,IAAI;AAAA,EAC9D,mBAAmB,CAAC,QAAa,IAAI,KAAK,gBA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B;AAAA,QAEA,gBAAgBA,MAAK,KAAK;AACxB,gBAAM,EAAE,SAAS,IAAIA,KAAI,aAAa,gBAAgB,IAAI,OAAO;AACjE,gBAAM,WAAWA,KAAI,aAAa,iBAAiB,IAAI,SAAS,QAAQ;AACxE,mBAASA,MAAK,QAAQ;AAAA,QACxB;AAAA,QACA,gBAAgBA,MAAK,KAAK;AACxB,gBAAM,EAAE,SAAS,IAAIA,KAAI,aAAa,gBAAgB,IAAI,OAAO;AACjE,gBAAM,WAAWA,KAAI,aAAa,iBAAiB,IAAI,SAAS,QAAQ;AACxE,mBAASA,MAAK,QAAQ;AAAA,QACxB;AAAA,QAEA,kBAAkBA,MAAK;AACrB,UAAAA,KAAI,cAAc,EAAE,OAAOA,KAAI,OAAO,cAAcA,KAAI,aAAa,CAAC;AAAA,QACxE;AAAA,QACA,eAAeA,MAAK;AAClB,UAAAA,KAAI,WAAW,EAAE,OAAOA,KAAI,OAAO,cAAcA,KAAI,aAAa,CAAC;AAAA,QACrE;AAAA,QACA,eAAeA,MAAK;AAClB,qCAAI,MAAM;AACR,gBAAI,eAAeA,IAAG,GAAG,MAAM,EAAE,eAAe,KAAK,CAAC;AAAA,UACxD,CAAC;AAAA,QACH;AAAA,QACA,kBAAkBA,MAAK,KAAK;AAC1B,qCAAI,MAAM;AACR,gBAAI,wBAAwBA,MAAK,IAAI,OAAO,GAAG,MAAM,EAAE,eAAe,KAAK,CAAC;AAAA,UAC9E,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAM,WAAW,CAAC,KAAqB,UAAiB;AACtD,MAAI,QAAQ,MAAM,SAAS,KAAK;AAChC,MAAI,eAAe;AACrB;","names":["import_color_utils","import_dom_event","import_dom_query","import_color_utils","import_dom_event","import_dom_query","import_numeric_range","ctx"]}
|
package/dist/index.mjs
CHANGED
|
@@ -381,38 +381,17 @@ function connect(state, send, normalize) {
|
|
|
381
381
|
const isDragging = state.matches("dragging");
|
|
382
382
|
const channels = valueAsColor.getColorChannels();
|
|
383
383
|
return {
|
|
384
|
-
/**
|
|
385
|
-
* Whether the color picker is being dragged
|
|
386
|
-
*/
|
|
387
384
|
isDragging,
|
|
388
|
-
/**
|
|
389
|
-
* The current color value (as a string)
|
|
390
|
-
*/
|
|
391
385
|
value: state.context.value,
|
|
392
|
-
/**
|
|
393
|
-
* The current color value (as a Color object)
|
|
394
|
-
*/
|
|
395
386
|
valueAsColor,
|
|
396
|
-
/**
|
|
397
|
-
* The current color channels of the color
|
|
398
|
-
*/
|
|
399
387
|
channels,
|
|
400
|
-
/**
|
|
401
|
-
* Function to set the color value
|
|
402
|
-
*/
|
|
403
388
|
setColor(value) {
|
|
404
389
|
send({ type: "VALUE.SET", value: normalizeColor(value), src: "set-color" });
|
|
405
390
|
},
|
|
406
|
-
/**
|
|
407
|
-
* Function to set the color value of a specific channel
|
|
408
|
-
*/
|
|
409
391
|
setChannelValue(channel, value) {
|
|
410
392
|
const color = valueAsColor.withChannelValue(channel, value);
|
|
411
393
|
send({ type: "VALUE.SET", value: color, src: "set-channel" });
|
|
412
394
|
},
|
|
413
|
-
/**
|
|
414
|
-
* Function to set the color format
|
|
415
|
-
*/
|
|
416
395
|
setFormat(format) {
|
|
417
396
|
const value = valueAsColor.toFormat(format);
|
|
418
397
|
send({ type: "VALUE.SET", value, src: "set-format" });
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/color-picker.anatomy.ts","../src/color-picker.connect.ts","../src/color-picker.dom.ts","../src/utils/get-channel-details.ts","../src/utils/get-channel-display-color.ts","../src/utils/get-channel-input-value.ts","../src/utils/generate-format-background.ts","../src/utils/get-color-area-gradient.ts","../src/utils/get-slider-background.ts","../src/color-picker.machine.ts"],"sourcesContent":["import { createAnatomy } from \"@zag-js/anatomy\"\n\nexport const anatomy = createAnatomy(\"color-picker\", [\n \"area\",\n \"areaThumb\",\n \"areaGradient\",\n \"channelSliderTrack\",\n \"channelSliderTrackBg\",\n \"channelSliderThumb\",\n \"channelInput\",\n \"swatch\",\n \"swatchBg\",\n \"content\",\n \"label\",\n \"eyeDropTrigger\",\n])\n\nexport const parts = anatomy.build()\n","import { Color, normalizeColor, type ColorChannel, type ColorFormat } from \"@zag-js/color-utils\"\nimport {\n EventKeyMap,\n getEventKey,\n getEventPoint,\n getEventStep,\n getNativeEvent,\n isLeftClick,\n isModifiedEvent,\n} from \"@zag-js/dom-event\"\nimport { dataAttr } from \"@zag-js/dom-query\"\nimport { NormalizeProps, type PropTypes } from \"@zag-js/types\"\nimport { parts } from \"./color-picker.anatomy\"\nimport { dom } from \"./color-picker.dom\"\nimport {\n ColorAreaProps,\n ColorChannelInputProps,\n ColorChannelProps,\n ColorSwatchProps,\n Send,\n State,\n} from \"./color-picker.types\"\nimport { getChannelDetails } from \"./utils/get-channel-details\"\nimport { getChannelDisplayColor } from \"./utils/get-channel-display-color\"\nimport { getChannelInputRange, getChannelInputValue } from \"./utils/get-channel-input-value\"\nimport { getColorAreaGradient } from \"./utils/get-color-area-gradient\"\nimport { getSliderBgImage } from \"./utils/get-slider-background\"\n\nexport function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>) {\n const valueAsColor = state.context.valueAsColor\n const isDisabled = state.context.disabled\n const isInteractive = state.context.isInteractive\n const isDragging = state.matches(\"dragging\")\n\n const channels = valueAsColor.getColorChannels()\n\n return {\n /**\n * Whether the color picker is being dragged\n */\n isDragging,\n /**\n * The current color value (as a string)\n */\n value: state.context.value,\n /**\n * The current color value (as a Color object)\n */\n valueAsColor,\n /**\n * The current color channels of the color\n */\n channels,\n /**\n * Function to set the color value\n */\n setColor(value: string | Color) {\n send({ type: \"VALUE.SET\", value: normalizeColor(value), src: \"set-color\" })\n },\n /**\n * Function to set the color value of a specific channel\n */\n setChannelValue(channel: ColorChannel, value: number) {\n const color = valueAsColor.withChannelValue(channel, value)\n send({ type: \"VALUE.SET\", value: color, src: \"set-channel\" })\n },\n /**\n * Function to set the color format\n */\n setFormat(format: ColorFormat) {\n const value = valueAsColor.toFormat(format)\n send({ type: \"VALUE.SET\", value, src: \"set-format\" })\n },\n\n contentProps: normalize.element({\n ...parts.content.attrs,\n id: dom.getContentId(state.context),\n }),\n\n getAreaProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { areaStyles } = getColorAreaGradient(state.context, xChannel, yChannel)\n\n return normalize.element({\n ...parts.area.attrs,\n id: dom.getAreaId(state.context),\n role: \"group\",\n onPointerDown(event) {\n if (!isInteractive) return\n\n const evt = getNativeEvent(event)\n if (!isLeftClick(evt) || isModifiedEvent(evt)) return\n\n const point = getEventPoint(evt)\n const channel = { xChannel, yChannel }\n\n send({ type: \"AREA.POINTER_DOWN\", point, channel, id: \"area\" })\n },\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n ...areaStyles,\n },\n })\n },\n\n getAreaGradientProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { areaGradientStyles } = getColorAreaGradient(state.context, xChannel, yChannel)\n\n return normalize.element({\n ...parts.areaGradient.attrs,\n id: dom.getAreaGradientId(state.context),\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n ...areaGradientStyles,\n },\n })\n },\n\n getAreaThumbProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { getThumbPosition } = getChannelDetails(valueAsColor, xChannel, yChannel)\n const { x, y } = getThumbPosition()\n\n const channel = { xChannel, yChannel }\n\n return normalize.element({\n ...parts.areaThumb.attrs,\n id: dom.getAreaThumbId(state.context),\n tabIndex: isDisabled ? undefined : 0,\n \"data-disabled\": dataAttr(isDisabled),\n role: \"presentation\",\n style: {\n position: \"absolute\",\n left: `${x * 100}%`,\n top: `${y * 100}%`,\n transform: \"translate(-50%, -50%)\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n background: valueAsColor.withChannelValue(\"alpha\", 1).toString(\"css\"),\n },\n onBlur() {\n send(\"AREA.BLUR\")\n },\n onKeyDown(event) {\n if (!isInteractive) return\n\n const step = getEventStep(event)\n\n const keyMap: EventKeyMap = {\n ArrowUp() {\n send({ type: \"AREA.ARROW_UP\", channel, step })\n },\n ArrowDown() {\n send({ type: \"AREA.ARROW_DOWN\", channel, step })\n },\n ArrowLeft() {\n send({ type: \"AREA.ARROW_LEFT\", channel, step })\n },\n ArrowRight() {\n send({ type: \"AREA.ARROW_RIGHT\", channel, step })\n },\n PageUp() {\n send({ type: \"AREA.PAGE_UP\", channel, step })\n },\n PageDown() {\n send({ type: \"AREA.PAGE_DOWN\", channel, step })\n },\n }\n\n const exec = keyMap[getEventKey(event, state.context)]\n\n if (exec) {\n exec(event)\n event.preventDefault()\n }\n },\n })\n },\n\n getChannelSliderTrackProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n\n return normalize.element({\n ...parts.channelSliderTrack.attrs,\n id: dom.getChannelSliderTrackId(state.context, channel),\n role: \"group\",\n \"data-channel\": channel,\n \"data-orientation\": orientation,\n onPointerDown(event) {\n if (!isInteractive) return\n\n const evt = getNativeEvent(event)\n if (!isLeftClick(evt) || isModifiedEvent(evt)) return\n\n const point = getEventPoint(evt)\n send({ type: \"CHANNEL_SLIDER.POINTER_DOWN\", channel, point, id: channel, orientation })\n },\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n backgroundImage: getSliderBgImage(state.context, { orientation, channel }),\n },\n })\n },\n\n getChannelSliderBackgroundProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n return normalize.element({\n ...parts.channelSliderTrackBg.attrs,\n \"data-orientation\": orientation,\n \"data-channel\": channel,\n style: {\n position: \"absolute\",\n backgroundColor: \"#fff\",\n backgroundImage: [\n \"linear-gradient(-45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(-45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n \"linear-gradient(45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n ].join(\",\"),\n backgroundSize: \"16px 16px\",\n backgroundPosition: \"-2px -2px,-2px 6px,6px -10px,-10px -2px\",\n inset: 0,\n zIndex: -1,\n },\n })\n },\n\n getChannelSliderThumbProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n const { minValue, maxValue, step: stepValue } = valueAsColor.getChannelRange(channel)\n const channelValue = valueAsColor.getChannelValue(channel)\n\n const offset = (channelValue - minValue) / (maxValue - minValue)\n\n const placementStyles =\n orientation === \"horizontal\"\n ? { left: `${offset * 100}%`, top: \"50%\" }\n : { top: `${offset * 100}%`, left: \"50%\" }\n\n return normalize.element({\n ...parts.channelSliderThumb.attrs,\n id: dom.getChannelSliderThumbId(state.context, channel),\n role: \"slider\",\n \"aria-label\": channel,\n tabIndex: isDisabled ? undefined : 0,\n \"data-channel\": channel,\n \"data-disabled\": dataAttr(isDisabled),\n \"data-orientation\": orientation,\n \"aria-disabled\": dataAttr(isDisabled),\n \"aria-orientation\": orientation,\n \"aria-valuemax\": maxValue,\n \"aria-valuemin\": minValue,\n \"aria-valuenow\": channelValue,\n style: {\n forcedColorAdjust: \"none\",\n position: \"absolute\",\n background: getChannelDisplayColor(valueAsColor, channel).toString(\"css\"),\n ...placementStyles,\n },\n onFocus() {\n if (!isInteractive) return\n send({ type: \"CHANNEL_SLIDER.FOCUS\", channel })\n },\n onBlur() {\n if (!isInteractive) return\n send({ type: \"CHANNEL_SLIDER.BLUR\", channel })\n },\n onKeyDown(event) {\n if (!isInteractive) return\n const step = getEventStep(event) * stepValue\n\n const keyMap: EventKeyMap = {\n ArrowUp() {\n send({ type: \"CHANNEL_SLIDER.ARROW_UP\", channel, step })\n },\n ArrowDown() {\n send({ type: \"CHANNEL_SLIDER.ARROW_DOWN\", channel, step })\n },\n ArrowLeft() {\n send({ type: \"CHANNEL_SLIDER.ARROW_LEFT\", channel, step })\n },\n ArrowRight() {\n send({ type: \"CHANNEL_SLIDER.ARROW_RIGHT\", channel, step })\n },\n PageUp() {\n send({ type: \"CHANNEL_SLIDER.PAGE_UP\", channel })\n },\n PageDown() {\n send({ type: \"CHANNEL_SLIDER.PAGE_DOWN\", channel })\n },\n Home() {\n send({ type: \"CHANNEL_SLIDER.HOME\", channel })\n },\n End() {\n send({ type: \"CHANNEL_SLIDER.END\", channel })\n },\n }\n\n const exec = keyMap[getEventKey(event, state.context)]\n\n if (exec) {\n exec(event)\n event.preventDefault()\n }\n },\n })\n },\n\n getChannelInputProps(props: ColorChannelInputProps) {\n const { channel } = props\n const isTextField = channel === \"hex\" || channel === \"css\"\n const range = getChannelInputRange(valueAsColor, channel)\n\n return normalize.input({\n ...parts.channelInput.attrs,\n type: isTextField ? \"text\" : \"number\",\n \"data-channel\": channel,\n \"aria-label\": channel,\n disabled: isDisabled,\n \"data-disabled\": dataAttr(isDisabled),\n readOnly: state.context.readOnly,\n id: dom.getChannelInputId(state.context, channel),\n defaultValue: getChannelInputValue(valueAsColor, channel),\n min: range?.minValue,\n max: range?.maxValue,\n step: range?.step,\n onFocus() {\n send({ type: \"CHANNEL_INPUT.FOCUS\", channel })\n },\n onChange(event) {\n if (isTextField) return\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.CHANGE\", channel, value, isTextField })\n },\n onBlur(event) {\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.BLUR\", channel, value, isTextField })\n },\n onKeyDown(event) {\n if (!isTextField) return\n if (event.key === \"Enter\") {\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.CHANGE\", channel, value, isTextField })\n }\n },\n style: {\n appearance: \"none\",\n WebkitAppearance: \"none\",\n MozAppearance: \"textfield\",\n },\n })\n },\n\n eyeDropperTriggerProps: normalize.button({\n ...parts.eyeDropTrigger.attrs,\n onClick() {\n send(\"EYEDROPPER.CLICK\")\n },\n }),\n\n getSwatchBackgroundProps(props: ColorSwatchProps) {\n const { value } = props\n const alpha = normalizeColor(value).getChannelValue(\"alpha\")\n return normalize.element({\n ...parts.swatchBg.attrs,\n \"data-alpha\": alpha,\n style: {\n width: \"100%\",\n height: \"100%\",\n background: \"#fff\",\n backgroundImage: [\n \"linear-gradient(-45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(-45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n \"linear-gradient(45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n ].join(\",\"),\n backgroundPosition: \"-2px -2px,-2px 6px,6px -10px,-10px -2px\",\n backgroundSize: \"16px 16px\",\n position: \"absolute\",\n inset: \"0px\",\n zIndex: -1,\n },\n })\n },\n\n getSwatchProps(props: ColorSwatchProps) {\n const { value, readOnly } = props\n const color = normalizeColor(value).toFormat(valueAsColor.getColorSpace())\n return normalize.element({\n ...parts.swatch.attrs,\n onClick() {\n if (readOnly) return\n send({ type: \"VALUE.SET\", value: color })\n },\n style: {\n position: \"relative\",\n background: color.toString(\"css\"),\n },\n })\n },\n }\n}\n","import { type ColorChannel } from \"@zag-js/color-utils\"\nimport { getRelativePoint, type Point } from \"@zag-js/dom-event\"\nimport { createScope, queryAll } from \"@zag-js/dom-query\"\nimport type { MachineContext as Ctx } from \"./color-picker.types\"\n\nexport const dom = createScope({\n getContentId: (ctx: Ctx) => ctx.ids?.content ?? `color-picker:${ctx.id}:content`,\n getAreaId: (ctx: Ctx) => ctx.ids?.area ?? `color-picker:${ctx.id}:area`,\n getAreaGradientId: (ctx: Ctx) => ctx.ids?.areaGradient ?? `color-picker:${ctx.id}:area-gradient`,\n getAreaThumbId: (ctx: Ctx) => ctx.ids?.areaThumb ?? `color-picker:${ctx.id}:area-thumb`,\n getChannelSliderTrackId: (ctx: Ctx, channel: ColorChannel) =>\n ctx.ids?.channelSliderTrack?.(channel) ?? `color-picker:${ctx.id}:slider-track:${channel}`,\n getChannelInputId: (ctx: Ctx, channel: string) =>\n ctx.ids?.channelInput?.(channel) ?? `color-picker:${ctx.id}:input:${channel}`,\n getChannelSliderThumbId: (ctx: Ctx, channel: ColorChannel) =>\n ctx.ids?.channelSliderThumb?.(channel) ?? `color-picker:${ctx.id}:slider-thumb:${channel}`,\n\n getContentEl: (ctx: Ctx) => dom.queryById(ctx, dom.getContentId(ctx)),\n getAreaThumbEl: (ctx: Ctx) => dom.queryById(ctx, dom.getAreaThumbId(ctx)),\n getChannelSliderThumbEl: (ctx: Ctx, channel: ColorChannel) =>\n dom.queryById(ctx, dom.getChannelSliderThumbId(ctx, channel)),\n getChannelInputEl: (ctx: Ctx, channel: string) =>\n dom.queryById<HTMLInputElement>(ctx, dom.getChannelInputId(ctx, channel)),\n\n getAreaEl: (ctx: Ctx) => dom.queryById(ctx, dom.getAreaId(ctx)),\n getAreaValueFromPoint(ctx: Ctx, point: Point) {\n const { percent } = getRelativePoint(point, dom.getAreaEl(ctx))\n return percent\n },\n\n getChannelSliderTrackEl: (ctx: Ctx, channel: ColorChannel) => {\n return dom.queryById(ctx, dom.getChannelSliderTrackId(ctx, channel))\n },\n getChannelSliderValueFromPoint(ctx: Ctx, point: Point, channel: ColorChannel) {\n const { percent } = getRelativePoint(point, dom.getChannelSliderTrackEl(ctx, channel))\n return percent\n },\n getChannelInputEls: (ctx: Ctx) => {\n return queryAll<HTMLInputElement>(dom.getContentEl(ctx), \"input[data-channel]\")\n },\n})\n","import { Color, type ColorChannel } from \"@zag-js/color-utils\"\nimport { getPercentValue, snapValueToStep } from \"@zag-js/numeric-range\"\n\nexport function getChannelDetails(color: Color, xChannel: ColorChannel, yChannel: ColorChannel) {\n const channels = color.getColorSpaceAxes({ xChannel, yChannel })\n\n const xChannelRange = color.getChannelRange(channels.xChannel)\n const yChannelRange = color.getChannelRange(channels.yChannel)\n\n const { minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX } = xChannelRange\n const { minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY } = yChannelRange\n\n const xValue = color.getChannelValue(channels.xChannel)\n const yValue = color.getChannelValue(channels.yChannel)\n\n return {\n channels,\n xChannelStep: stepX,\n yChannelStep: stepY,\n xChannelPageStep: pageSizeX,\n yChannelPageStep: pageSizeY,\n xValue,\n yValue,\n getThumbPosition() {\n let x = (xValue - minValueX) / (maxValueX - minValueX)\n let y = 1 - (yValue - minValueY) / (maxValueY - minValueY)\n return { x, y }\n },\n incrementX(stepSize: number) {\n return xValue + stepSize > maxValueX ? maxValueX : snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX)\n },\n incrementY(stepSize: number) {\n return yValue + stepSize > maxValueY ? maxValueY : snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY)\n },\n decrementX(stepSize: number) {\n return snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX)\n },\n decrementY(stepSize: number) {\n return snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY)\n },\n getColorFromPoint(x: number, y: number) {\n let newXValue = getPercentValue(x, minValueX, maxValueX, stepX)\n let newYValue = getPercentValue(1 - y, minValueY, maxValueY, stepY)\n\n let newColor: Color | undefined\n\n if (newXValue !== xValue) {\n newXValue = snapValueToStep(newXValue, minValueX, maxValueX, stepX)\n newColor = color.withChannelValue(channels.xChannel, newXValue)\n }\n\n if (newYValue !== yValue) {\n newYValue = snapValueToStep(newYValue, minValueY, maxValueY, stepY)\n newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue)\n }\n\n return newColor\n },\n }\n}\n","import { Color, parseColor, type ColorChannel } from \"@zag-js/color-utils\"\n\nexport function getChannelDisplayColor(color: Color, channel: ColorChannel) {\n switch (channel) {\n case \"hue\":\n return parseColor(`hsl(${color.getChannelValue(\"hue\")}, 100%, 50%)`)\n case \"lightness\":\n case \"brightness\":\n case \"saturation\":\n case \"red\":\n case \"green\":\n case \"blue\":\n return color.withChannelValue(\"alpha\", 1)\n case \"alpha\": {\n return color\n }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n}\n","import { Color } from \"@zag-js/color-utils\"\nimport { ExtendedColorChannel } from \"../color-picker.types\"\n\nexport function getChannelInputValue(color: Color, channel: ExtendedColorChannel) {\n switch (channel) {\n case \"hex\":\n return color.toString(\"hex\")\n case \"css\":\n return color.toString(\"css\")\n default:\n return color.getChannelValue(channel).toString()\n }\n}\n\nexport function getChannelInputRange(color: Color, channel: ExtendedColorChannel) {\n switch (channel) {\n case \"hex\":\n case \"css\":\n return undefined\n default:\n return color.getChannelRange(channel)\n }\n}\n","export const generateRGB_R = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_G = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_B = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateHSL_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(dir)]\n }, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(!dir)]\n }, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n \"hsl(0, 0%, 50%)\",\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_L = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n backgroundImage: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_B = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n \"#000\",\n ].join(\",\"),\n },\n }\n return result\n}\n","import { type ColorChannel } from \"@zag-js/color-utils\"\nimport { Style } from \"@zag-js/types\"\nimport { MachineContext } from \"../color-picker.types\"\nimport {\n generateHSB_B,\n generateHSB_H,\n generateHSB_S,\n generateHSL_H,\n generateHSL_L,\n generateHSL_S,\n generateRGB_B,\n generateRGB_G,\n generateRGB_R,\n} from \"./generate-format-background\"\n\nexport function getColorAreaGradient(ctx: MachineContext, xChannel: ColorChannel, yChannel: ColorChannel) {\n const value = ctx.valueAsColor\n\n const { zChannel } = value.getColorSpaceAxes({ xChannel, yChannel })\n const zValue = value.getChannelValue(zChannel)\n\n const { minValue: zMin, maxValue: zMax } = value.getChannelRange(zChannel)\n const orientation: [string, string] = [\"top\", ctx.dir === \"rtl\" ? \"left\" : \"right\"]\n\n let dir = false\n let background = { areaStyles: {} as Style, areaGradientStyles: {} as Style }\n\n let alphaValue = (zValue - zMin) / (zMax - zMin)\n let isHSL = value.getColorSpace() === \"hsl\"\n\n switch (zChannel) {\n case \"red\": {\n dir = xChannel === \"green\"\n background = generateRGB_R(orientation, dir, zValue)\n break\n }\n\n case \"green\": {\n dir = xChannel === \"red\"\n background = generateRGB_G(orientation, dir, zValue)\n break\n }\n\n case \"blue\": {\n dir = xChannel === \"red\"\n background = generateRGB_B(orientation, dir, zValue)\n break\n }\n\n case \"hue\": {\n dir = xChannel !== \"saturation\"\n if (isHSL) {\n background = generateHSL_H(orientation, dir, zValue)\n } else {\n background = generateHSB_H(orientation, dir, zValue)\n }\n break\n }\n\n case \"saturation\": {\n dir = xChannel === \"hue\"\n if (isHSL) {\n background = generateHSL_S(orientation, dir, alphaValue)\n } else {\n background = generateHSB_S(orientation, dir, alphaValue)\n }\n break\n }\n\n case \"brightness\": {\n dir = xChannel === \"hue\"\n background = generateHSB_B(orientation, dir, alphaValue)\n break\n }\n\n case \"lightness\": {\n dir = xChannel === \"hue\"\n background = generateHSL_L(orientation, dir, zValue)\n break\n }\n }\n\n return background\n}\n","import { ColorChannelProps, MachineContext } from \"../color-picker.types\"\n\nfunction getSliderBgDirection(orientation: \"vertical\" | \"horizontal\", dir: \"ltr\" | \"rtl\") {\n if (orientation === \"vertical\") {\n return \"top\"\n } else if (dir === \"ltr\") {\n return \"right\"\n } else {\n return \"left\"\n }\n}\n\nexport const getSliderBgImage = (ctx: MachineContext, props: Required<ColorChannelProps>) => {\n const { channel } = props\n\n const dir = getSliderBgDirection(props.orientation, ctx.dir!)\n const value = ctx.valueAsColor\n\n const { minValue, maxValue } = ctx.valueAsColor.getChannelRange(channel)\n\n switch (channel) {\n case \"hue\":\n return `linear-gradient(to ${dir}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`\n case \"lightness\": {\n let start = ctx.valueAsColor.withChannelValue(channel, minValue).toString(\"css\")\n let middle = value.withChannelValue(channel, (maxValue - minValue) / 2).toString(\"css\")\n let end = value.withChannelValue(channel, maxValue).toString(\"css\")\n return `linear-gradient(to ${dir}, ${start}, ${middle}, ${end})`\n }\n case \"saturation\":\n case \"brightness\":\n case \"red\":\n case \"green\":\n case \"blue\":\n case \"alpha\": {\n let start = value.withChannelValue(channel, minValue).toString(\"css\")\n let end = value.withChannelValue(channel, maxValue).toString(\"css\")\n return `linear-gradient(to ${dir}, ${start}, ${end})`\n }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n}\n","import { Color, parseColor } from \"@zag-js/color-utils\"\nimport { createMachine } from \"@zag-js/core\"\nimport { trackPointerMove } from \"@zag-js/dom-event\"\nimport { raf } from \"@zag-js/dom-query\"\nimport { clampValue, getPercentValue, snapValueToStep } from \"@zag-js/numeric-range\"\nimport { disableTextSelection } from \"@zag-js/text-selection\"\nimport { compact } from \"@zag-js/utils\"\nimport { dom } from \"./color-picker.dom\"\nimport { ExtendedColorChannel, MachineContext, MachineState, UserDefinedContext } from \"./color-picker.types\"\nimport { getChannelDetails } from \"./utils/get-channel-details\"\nimport { getChannelInputValue } from \"./utils/get-channel-input-value\"\n\nexport function machine(userContext: UserDefinedContext) {\n const ctx = compact(userContext)\n\n return createMachine<MachineContext, MachineState>(\n {\n id: \"color-picker\",\n initial: \"idle\",\n context: {\n dir: \"ltr\",\n activeId: null,\n activeChannel: null,\n activeOrientation: null,\n value: \"#D9D9D9\",\n ...ctx,\n valueAsColor: parseColor(ctx.value || \"#D9D9D9\"),\n },\n\n computed: {\n isRtl: (ctx) => ctx.dir === \"rtl\",\n isInteractive: (ctx) => !(ctx.disabled || ctx.readOnly),\n },\n\n on: {\n \"VALUE.SET\": {\n actions: [\"setValue\"],\n },\n },\n\n created: [\"setValueAsColor\"],\n\n watch: {\n value: [\"setValueAsColor\", \"syncChannelInputs\", \"invokeOnChange\"],\n },\n\n states: {\n idle: {\n on: {\n \"EYEDROPPER.CLICK\": {\n actions: [\"openEyeDropper\"],\n },\n \"AREA.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setAreaColorFromPoint\", \"focusAreaThumb\"],\n },\n \"CHANNEL_SLIDER.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setChannelColorFromPoint\", \"focusChannelThumb\"],\n },\n \"CHANNEL_INPUT.FOCUS\": {\n target: \"focused\",\n actions: [\"setActiveChannel\"],\n },\n \"CHANNEL_INPUT.CHANGE\": {\n actions: [\"setChannelColorFromInput\"],\n },\n },\n },\n\n focused: {\n on: {\n \"AREA.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setAreaColorFromPoint\", \"focusAreaThumb\"],\n },\n \"CHANNEL_SLIDER.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setChannelColorFromPoint\", \"focusChannelThumb\"],\n },\n \"AREA.ARROW_LEFT\": {\n actions: [\"decrementXChannel\"],\n },\n \"AREA.ARROW_RIGHT\": {\n actions: [\"incrementXChannel\"],\n },\n \"AREA.ARROW_UP\": {\n actions: [\"incrementYChannel\"],\n },\n \"AREA.ARROW_DOWN\": {\n actions: [\"decrementYChannel\"],\n },\n \"AREA.PAGE_UP\": {\n actions: [\"incrementXChannel\"],\n },\n \"AREA.PAGE_DOWN\": {\n actions: [\"decrementXChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_LEFT\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_RIGHT\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_UP\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_DOWN\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.PAGE_UP\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.PAGE_DOWN\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.HOME\": {\n actions: [\"setChannelToMin\"],\n },\n \"CHANNEL_SLIDER.END\": {\n actions: [\"setChannelToMax\"],\n },\n \"CHANNEL_INPUT.FOCUS\": {\n actions: [\"setActiveChannel\"],\n },\n \"CHANNEL_INPUT.CHANGE\": {\n actions: [\"setChannelColorFromInput\"],\n },\n \"CHANNEL_INPUT.BLUR\": [\n {\n guard: \"isTextField\",\n target: \"idle\",\n actions: [\"setChannelColorFromInput\"],\n },\n { target: \"idle\" },\n ],\n \"CHANNEL_SLIDER.BLUR\": {\n target: \"idle\",\n },\n \"AREA.BLUR\": {\n target: \"idle\",\n },\n },\n },\n\n dragging: {\n exit: [\"clearActiveChannel\"],\n activities: [\"trackPointerMove\", \"disableTextSelection\"],\n on: {\n \"AREA.POINTER_MOVE\": {\n actions: [\"setAreaColorFromPoint\"],\n },\n \"AREA.POINTER_UP\": {\n target: \"focused\",\n actions: [\"invokeOnChangeEnd\"],\n },\n \"CHANNEL_SLIDER.POINTER_MOVE\": {\n actions: [\"setChannelColorFromPoint\"],\n },\n \"CHANNEL_SLIDER.POINTER_UP\": {\n target: \"focused\",\n actions: [\"invokeOnChangeEnd\"],\n },\n },\n },\n },\n },\n {\n guards: {\n isTextField: (_ctx, evt) => !!evt.isTextField,\n },\n activities: {\n trackPointerMove(ctx, _evt, { send }) {\n return trackPointerMove(dom.getDoc(ctx), {\n onPointerMove({ point }) {\n const type = ctx.activeId === \"area\" ? \"AREA.POINTER_MOVE\" : \"CHANNEL_SLIDER.POINTER_MOVE\"\n send({ type, point })\n },\n onPointerUp() {\n const type = ctx.activeId === \"area\" ? \"AREA.POINTER_UP\" : \"CHANNEL_SLIDER.POINTER_UP\"\n send({ type })\n },\n })\n },\n disableTextSelection(ctx) {\n return disableTextSelection({ doc: dom.getDoc(ctx), target: dom.getContentEl(ctx) })\n },\n },\n actions: {\n openEyeDropper(ctx) {\n const isSupported = \"EyeDropper\" in dom.getWin(ctx)\n if (!isSupported) return\n const win = dom.getWin(ctx) as any\n const picker = new win.EyeDropper()\n picker\n .open()\n .then(({ sRGBHex }: { sRGBHex: string }) => {\n const format = ctx.valueAsColor.getColorSpace()\n const color = parseColor(sRGBHex).toFormat(format)\n setColor(ctx, color)\n ctx.onChangeEnd?.({ value: ctx.value, valueAsColor: color })\n })\n .catch(() => void 0)\n },\n setActiveChannel(ctx, evt) {\n ctx.activeId = evt.id\n if (evt.channel) {\n ctx.activeChannel = evt.channel\n }\n if (evt.orientation) {\n ctx.activeOrientation = evt.orientation\n }\n },\n clearActiveChannel(ctx) {\n ctx.activeChannel = null\n ctx.activeId = null\n ctx.activeOrientation = null\n },\n setAreaColorFromPoint(ctx, evt) {\n const { xChannel, yChannel } = evt.channel || ctx.activeChannel\n\n const percent = dom.getAreaValueFromPoint(ctx, evt.point)\n const { getColorFromPoint } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const color = getColorFromPoint(percent.x, percent.y)\n\n if (!color) return\n setColor(ctx, color)\n },\n setChannelColorFromPoint(ctx, evt) {\n const channel = evt.channel || ctx.activeId\n const percent = dom.getChannelSliderValueFromPoint(ctx, evt.point, channel)\n\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(channel)\n const orientation = ctx.activeOrientation || \"horizontal\"\n\n const point = orientation === \"horizontal\" ? percent.x : percent.y\n const channelValue = getPercentValue(point, minValue, maxValue, step)\n\n const value = snapValueToStep(channelValue - step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(channel, value)\n\n setColor(ctx, newColor)\n },\n setValue(ctx, evt) {\n setColor(ctx, evt.value)\n },\n setValueAsColor(ctx) {\n try {\n const color = parseColor(ctx.value)\n if (color.isEqual(ctx.valueAsColor)) return\n ctx.valueAsColor = color\n } catch {}\n },\n syncChannelInputs(ctx) {\n const inputs = dom.getChannelInputEls(ctx)\n inputs.forEach((input) => {\n const channel = input.getAttribute(\"data-channel\") as ExtendedColorChannel | null\n if (!channel) return\n const value = getChannelInputValue(ctx.valueAsColor, channel)\n input.value = value.toString()\n })\n },\n setChannelColorFromInput(ctx, evt) {\n const { channel, isTextField, value } = evt\n try {\n const format = ctx.valueAsColor.getColorSpace()\n\n const newColor = isTextField\n ? parseColor(value).toFormat(format)\n : ctx.valueAsColor.withChannelValue(channel, value)\n\n setColor(ctx, newColor)\n //\n } catch {\n // reset input value\n const input = dom.getChannelInputEl(ctx, channel)\n if (!input) return\n input.value = getChannelInputValue(ctx.valueAsColor, channel)\n }\n },\n\n incrementChannel(ctx, evt) {\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(evt.channel)\n const channelValue = ctx.valueAsColor.getChannelValue(evt.channel)\n const value = snapValueToStep(channelValue + evt.step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, clampValue(value, minValue, maxValue))\n setColor(ctx, newColor)\n },\n decrementChannel(ctx, evt) {\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(evt.channel)\n const channelValue = ctx.valueAsColor.getChannelValue(evt.channel)\n const value = snapValueToStep(channelValue - evt.step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, clampValue(value, minValue, maxValue))\n setColor(ctx, newColor)\n },\n\n incrementXChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { incrementX } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(xChannel, incrementX(evt.step))\n setColor(ctx, newColor)\n },\n decrementXChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { decrementX } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(xChannel, decrementX(evt.step))\n setColor(ctx, newColor)\n },\n\n incrementYChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { incrementY } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(yChannel, incrementY(evt.step))\n setColor(ctx, newColor)\n },\n decrementYChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { decrementY } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(yChannel, decrementY(evt.step))\n setColor(ctx, newColor)\n },\n\n setChannelToMax(ctx, evt) {\n const { maxValue } = ctx.valueAsColor.getChannelRange(evt.channel)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, maxValue)\n setColor(ctx, newColor)\n },\n setChannelToMin(ctx, evt) {\n const { minValue } = ctx.valueAsColor.getChannelRange(evt.channel)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, minValue)\n setColor(ctx, newColor)\n },\n\n invokeOnChangeEnd(ctx) {\n ctx.onChangeEnd?.({ value: ctx.value, valueAsColor: ctx.valueAsColor })\n },\n invokeOnChange(ctx) {\n ctx.onChange?.({ value: ctx.value, valueAsColor: ctx.valueAsColor })\n },\n focusAreaThumb(ctx) {\n raf(() => {\n dom.getAreaThumbEl(ctx)?.focus({ preventScroll: true })\n })\n },\n focusChannelThumb(ctx, evt) {\n raf(() => {\n dom.getChannelSliderThumbEl(ctx, evt.channel)?.focus({ preventScroll: true })\n })\n },\n },\n },\n )\n}\n\nconst setColor = (ctx: MachineContext, color: Color) => {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EA,kBAAkBA,MAAK;AACrB,UAAAA,KAAI,cAAc,EAAE,OAAOA,KAAI,OAAO,cAAcA,KAAI,aAAa,CAAC;AAAA,QACxE;AAAA,QACA,eAAeA,MAAK;AAClB,UAAAA,KAAI,WAAW,EAAE,OAAOA,KAAI,OAAO,cAAcA,KAAI,aAAa,CAAC;AAAA,QACrE;AAAA,QACA,eAAeA,MAAK;AAClB,cAAI,MAAM;AACR,gBAAI,eAAeA,IAAG,GAAG,MAAM,EAAE,eAAe,KAAK,CAAC;AAAA,UACxD,CAAC;AAAA,QACH;AAAA,QACA,kBAAkBA,MAAK,KAAK;AAC1B,cAAI,MAAM;AACR,gBAAI,wBAAwBA,MAAK,IAAI,OAAO,GAAG,MAAM,EAAE,eAAe,KAAK,CAAC;AAAA,UAC9E,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAM,WAAW,CAAC,KAAqB,UAAiB;AACtD,MAAI,QAAQ,MAAM,SAAS,KAAK;AAChC,MAAI,eAAe;AACrB;","names":["parseColor","getPercentValue","snapValueToStep","parseColor","ctx","getPercentValue","snapValueToStep"]}
|
|
1
|
+
{"version":3,"sources":["../src/color-picker.anatomy.ts","../src/color-picker.connect.ts","../src/color-picker.dom.ts","../src/utils/get-channel-details.ts","../src/utils/get-channel-display-color.ts","../src/utils/get-channel-input-value.ts","../src/utils/generate-format-background.ts","../src/utils/get-color-area-gradient.ts","../src/utils/get-slider-background.ts","../src/color-picker.machine.ts"],"sourcesContent":["import { createAnatomy } from \"@zag-js/anatomy\"\n\nexport const anatomy = createAnatomy(\"color-picker\", [\n \"area\",\n \"areaThumb\",\n \"areaGradient\",\n \"channelSliderTrack\",\n \"channelSliderTrackBg\",\n \"channelSliderThumb\",\n \"channelInput\",\n \"swatch\",\n \"swatchBg\",\n \"content\",\n \"label\",\n \"eyeDropTrigger\",\n])\n\nexport const parts = anatomy.build()\n","import { normalizeColor, type Color, type ColorChannel, type ColorFormat } from \"@zag-js/color-utils\"\nimport {\n getEventKey,\n getEventPoint,\n getEventStep,\n getNativeEvent,\n isLeftClick,\n isModifiedEvent,\n type EventKeyMap,\n} from \"@zag-js/dom-event\"\nimport { dataAttr } from \"@zag-js/dom-query\"\nimport type { NormalizeProps, PropTypes } from \"@zag-js/types\"\nimport { parts } from \"./color-picker.anatomy\"\nimport { dom } from \"./color-picker.dom\"\nimport type {\n ColorAreaProps,\n ColorChannelInputProps,\n ColorChannelProps,\n ColorSwatchProps,\n PublicApi,\n Send,\n State,\n} from \"./color-picker.types\"\nimport { getChannelDetails } from \"./utils/get-channel-details\"\nimport { getChannelDisplayColor } from \"./utils/get-channel-display-color\"\nimport { getChannelInputRange, getChannelInputValue } from \"./utils/get-channel-input-value\"\nimport { getColorAreaGradient } from \"./utils/get-color-area-gradient\"\nimport { getSliderBgImage } from \"./utils/get-slider-background\"\n\nexport function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): PublicApi<T> {\n const valueAsColor = state.context.valueAsColor\n const isDisabled = state.context.disabled\n const isInteractive = state.context.isInteractive\n const isDragging = state.matches(\"dragging\")\n\n const channels = valueAsColor.getColorChannels()\n\n return {\n isDragging,\n value: state.context.value,\n valueAsColor,\n channels,\n\n setColor(value: string | Color) {\n send({ type: \"VALUE.SET\", value: normalizeColor(value), src: \"set-color\" })\n },\n\n setChannelValue(channel: ColorChannel, value: number) {\n const color = valueAsColor.withChannelValue(channel, value)\n send({ type: \"VALUE.SET\", value: color, src: \"set-channel\" })\n },\n\n setFormat(format: ColorFormat) {\n const value = valueAsColor.toFormat(format)\n send({ type: \"VALUE.SET\", value, src: \"set-format\" })\n },\n\n contentProps: normalize.element({\n ...parts.content.attrs,\n id: dom.getContentId(state.context),\n }),\n\n getAreaProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { areaStyles } = getColorAreaGradient(state.context, xChannel, yChannel)\n\n return normalize.element({\n ...parts.area.attrs,\n id: dom.getAreaId(state.context),\n role: \"group\",\n onPointerDown(event) {\n if (!isInteractive) return\n\n const evt = getNativeEvent(event)\n if (!isLeftClick(evt) || isModifiedEvent(evt)) return\n\n const point = getEventPoint(evt)\n const channel = { xChannel, yChannel }\n\n send({ type: \"AREA.POINTER_DOWN\", point, channel, id: \"area\" })\n },\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n ...areaStyles,\n },\n })\n },\n\n getAreaGradientProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { areaGradientStyles } = getColorAreaGradient(state.context, xChannel, yChannel)\n\n return normalize.element({\n ...parts.areaGradient.attrs,\n id: dom.getAreaGradientId(state.context),\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n ...areaGradientStyles,\n },\n })\n },\n\n getAreaThumbProps(props: ColorAreaProps) {\n const { xChannel, yChannel } = props\n const { getThumbPosition } = getChannelDetails(valueAsColor, xChannel, yChannel)\n const { x, y } = getThumbPosition()\n\n const channel = { xChannel, yChannel }\n\n return normalize.element({\n ...parts.areaThumb.attrs,\n id: dom.getAreaThumbId(state.context),\n tabIndex: isDisabled ? undefined : 0,\n \"data-disabled\": dataAttr(isDisabled),\n role: \"presentation\",\n style: {\n position: \"absolute\",\n left: `${x * 100}%`,\n top: `${y * 100}%`,\n transform: \"translate(-50%, -50%)\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n background: valueAsColor.withChannelValue(\"alpha\", 1).toString(\"css\"),\n },\n onBlur() {\n send(\"AREA.BLUR\")\n },\n onKeyDown(event) {\n if (!isInteractive) return\n\n const step = getEventStep(event)\n\n const keyMap: EventKeyMap = {\n ArrowUp() {\n send({ type: \"AREA.ARROW_UP\", channel, step })\n },\n ArrowDown() {\n send({ type: \"AREA.ARROW_DOWN\", channel, step })\n },\n ArrowLeft() {\n send({ type: \"AREA.ARROW_LEFT\", channel, step })\n },\n ArrowRight() {\n send({ type: \"AREA.ARROW_RIGHT\", channel, step })\n },\n PageUp() {\n send({ type: \"AREA.PAGE_UP\", channel, step })\n },\n PageDown() {\n send({ type: \"AREA.PAGE_DOWN\", channel, step })\n },\n }\n\n const exec = keyMap[getEventKey(event, state.context)]\n\n if (exec) {\n exec(event)\n event.preventDefault()\n }\n },\n })\n },\n\n getChannelSliderTrackProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n\n return normalize.element({\n ...parts.channelSliderTrack.attrs,\n id: dom.getChannelSliderTrackId(state.context, channel),\n role: \"group\",\n \"data-channel\": channel,\n \"data-orientation\": orientation,\n onPointerDown(event) {\n if (!isInteractive) return\n\n const evt = getNativeEvent(event)\n if (!isLeftClick(evt) || isModifiedEvent(evt)) return\n\n const point = getEventPoint(evt)\n send({ type: \"CHANNEL_SLIDER.POINTER_DOWN\", channel, point, id: channel, orientation })\n },\n style: {\n position: \"relative\",\n touchAction: \"none\",\n forcedColorAdjust: \"none\",\n backgroundImage: getSliderBgImage(state.context, { orientation, channel }),\n },\n })\n },\n\n getChannelSliderBackgroundProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n return normalize.element({\n ...parts.channelSliderTrackBg.attrs,\n \"data-orientation\": orientation,\n \"data-channel\": channel,\n style: {\n position: \"absolute\",\n backgroundColor: \"#fff\",\n backgroundImage: [\n \"linear-gradient(-45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(-45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n \"linear-gradient(45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n ].join(\",\"),\n backgroundSize: \"16px 16px\",\n backgroundPosition: \"-2px -2px,-2px 6px,6px -10px,-10px -2px\",\n inset: 0,\n zIndex: -1,\n },\n })\n },\n\n getChannelSliderThumbProps(props: ColorChannelProps) {\n const { orientation = \"horizontal\", channel } = props\n const { minValue, maxValue, step: stepValue } = valueAsColor.getChannelRange(channel)\n const channelValue = valueAsColor.getChannelValue(channel)\n\n const offset = (channelValue - minValue) / (maxValue - minValue)\n\n const placementStyles =\n orientation === \"horizontal\"\n ? { left: `${offset * 100}%`, top: \"50%\" }\n : { top: `${offset * 100}%`, left: \"50%\" }\n\n return normalize.element({\n ...parts.channelSliderThumb.attrs,\n id: dom.getChannelSliderThumbId(state.context, channel),\n role: \"slider\",\n \"aria-label\": channel,\n tabIndex: isDisabled ? undefined : 0,\n \"data-channel\": channel,\n \"data-disabled\": dataAttr(isDisabled),\n \"data-orientation\": orientation,\n \"aria-disabled\": dataAttr(isDisabled),\n \"aria-orientation\": orientation,\n \"aria-valuemax\": maxValue,\n \"aria-valuemin\": minValue,\n \"aria-valuenow\": channelValue,\n style: {\n forcedColorAdjust: \"none\",\n position: \"absolute\",\n background: getChannelDisplayColor(valueAsColor, channel).toString(\"css\"),\n ...placementStyles,\n },\n onFocus() {\n if (!isInteractive) return\n send({ type: \"CHANNEL_SLIDER.FOCUS\", channel })\n },\n onBlur() {\n if (!isInteractive) return\n send({ type: \"CHANNEL_SLIDER.BLUR\", channel })\n },\n onKeyDown(event) {\n if (!isInteractive) return\n const step = getEventStep(event) * stepValue\n\n const keyMap: EventKeyMap = {\n ArrowUp() {\n send({ type: \"CHANNEL_SLIDER.ARROW_UP\", channel, step })\n },\n ArrowDown() {\n send({ type: \"CHANNEL_SLIDER.ARROW_DOWN\", channel, step })\n },\n ArrowLeft() {\n send({ type: \"CHANNEL_SLIDER.ARROW_LEFT\", channel, step })\n },\n ArrowRight() {\n send({ type: \"CHANNEL_SLIDER.ARROW_RIGHT\", channel, step })\n },\n PageUp() {\n send({ type: \"CHANNEL_SLIDER.PAGE_UP\", channel })\n },\n PageDown() {\n send({ type: \"CHANNEL_SLIDER.PAGE_DOWN\", channel })\n },\n Home() {\n send({ type: \"CHANNEL_SLIDER.HOME\", channel })\n },\n End() {\n send({ type: \"CHANNEL_SLIDER.END\", channel })\n },\n }\n\n const exec = keyMap[getEventKey(event, state.context)]\n\n if (exec) {\n exec(event)\n event.preventDefault()\n }\n },\n })\n },\n\n getChannelInputProps(props: ColorChannelInputProps) {\n const { channel } = props\n const isTextField = channel === \"hex\" || channel === \"css\"\n const range = getChannelInputRange(valueAsColor, channel)\n\n return normalize.input({\n ...parts.channelInput.attrs,\n type: isTextField ? \"text\" : \"number\",\n \"data-channel\": channel,\n \"aria-label\": channel,\n disabled: isDisabled,\n \"data-disabled\": dataAttr(isDisabled),\n readOnly: state.context.readOnly,\n id: dom.getChannelInputId(state.context, channel),\n defaultValue: getChannelInputValue(valueAsColor, channel),\n min: range?.minValue,\n max: range?.maxValue,\n step: range?.step,\n onFocus() {\n send({ type: \"CHANNEL_INPUT.FOCUS\", channel })\n },\n onChange(event) {\n if (isTextField) return\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.CHANGE\", channel, value, isTextField })\n },\n onBlur(event) {\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.BLUR\", channel, value, isTextField })\n },\n onKeyDown(event) {\n if (!isTextField) return\n if (event.key === \"Enter\") {\n const value = event.currentTarget.value\n send({ type: \"CHANNEL_INPUT.CHANGE\", channel, value, isTextField })\n }\n },\n style: {\n appearance: \"none\",\n WebkitAppearance: \"none\",\n MozAppearance: \"textfield\",\n },\n })\n },\n\n eyeDropperTriggerProps: normalize.button({\n ...parts.eyeDropTrigger.attrs,\n onClick() {\n send(\"EYEDROPPER.CLICK\")\n },\n }),\n\n getSwatchBackgroundProps(props: ColorSwatchProps) {\n const { value } = props\n const alpha = normalizeColor(value).getChannelValue(\"alpha\")\n return normalize.element({\n ...parts.swatchBg.attrs,\n \"data-alpha\": alpha,\n style: {\n width: \"100%\",\n height: \"100%\",\n background: \"#fff\",\n backgroundImage: [\n \"linear-gradient(-45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(45deg,#0000 75.5%,#bcbcbc 75.5%)\",\n \"linear-gradient(-45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n \"linear-gradient(45deg,#bcbcbc 25.5%,#0000 25.5%)\",\n ].join(\",\"),\n backgroundPosition: \"-2px -2px,-2px 6px,6px -10px,-10px -2px\",\n backgroundSize: \"16px 16px\",\n position: \"absolute\",\n inset: \"0px\",\n zIndex: -1,\n },\n })\n },\n\n getSwatchProps(props: ColorSwatchProps) {\n const { value, readOnly } = props\n const color = normalizeColor(value).toFormat(valueAsColor.getColorSpace())\n return normalize.element({\n ...parts.swatch.attrs,\n onClick() {\n if (readOnly) return\n send({ type: \"VALUE.SET\", value: color })\n },\n style: {\n position: \"relative\",\n background: color.toString(\"css\"),\n },\n })\n },\n }\n}\n","import type { ColorChannel } from \"@zag-js/color-utils\"\nimport { getRelativePoint, type Point } from \"@zag-js/dom-event\"\nimport { createScope, queryAll } from \"@zag-js/dom-query\"\nimport type { MachineContext as Ctx } from \"./color-picker.types\"\n\nexport const dom = createScope({\n getContentId: (ctx: Ctx) => ctx.ids?.content ?? `color-picker:${ctx.id}:content`,\n getAreaId: (ctx: Ctx) => ctx.ids?.area ?? `color-picker:${ctx.id}:area`,\n getAreaGradientId: (ctx: Ctx) => ctx.ids?.areaGradient ?? `color-picker:${ctx.id}:area-gradient`,\n getAreaThumbId: (ctx: Ctx) => ctx.ids?.areaThumb ?? `color-picker:${ctx.id}:area-thumb`,\n getChannelSliderTrackId: (ctx: Ctx, channel: ColorChannel) =>\n ctx.ids?.channelSliderTrack?.(channel) ?? `color-picker:${ctx.id}:slider-track:${channel}`,\n getChannelInputId: (ctx: Ctx, channel: string) =>\n ctx.ids?.channelInput?.(channel) ?? `color-picker:${ctx.id}:input:${channel}`,\n getChannelSliderThumbId: (ctx: Ctx, channel: ColorChannel) =>\n ctx.ids?.channelSliderThumb?.(channel) ?? `color-picker:${ctx.id}:slider-thumb:${channel}`,\n\n getContentEl: (ctx: Ctx) => dom.queryById(ctx, dom.getContentId(ctx)),\n getAreaThumbEl: (ctx: Ctx) => dom.queryById(ctx, dom.getAreaThumbId(ctx)),\n getChannelSliderThumbEl: (ctx: Ctx, channel: ColorChannel) =>\n dom.queryById(ctx, dom.getChannelSliderThumbId(ctx, channel)),\n getChannelInputEl: (ctx: Ctx, channel: string) =>\n dom.queryById<HTMLInputElement>(ctx, dom.getChannelInputId(ctx, channel)),\n\n getAreaEl: (ctx: Ctx) => dom.queryById(ctx, dom.getAreaId(ctx)),\n getAreaValueFromPoint(ctx: Ctx, point: Point) {\n const { percent } = getRelativePoint(point, dom.getAreaEl(ctx))\n return percent\n },\n\n getChannelSliderTrackEl: (ctx: Ctx, channel: ColorChannel) => {\n return dom.queryById(ctx, dom.getChannelSliderTrackId(ctx, channel))\n },\n getChannelSliderValueFromPoint(ctx: Ctx, point: Point, channel: ColorChannel) {\n const { percent } = getRelativePoint(point, dom.getChannelSliderTrackEl(ctx, channel))\n return percent\n },\n getChannelInputEls: (ctx: Ctx) => {\n return queryAll<HTMLInputElement>(dom.getContentEl(ctx), \"input[data-channel]\")\n },\n})\n","import type { Color, ColorChannel } from \"@zag-js/color-utils\"\nimport { getPercentValue, snapValueToStep } from \"@zag-js/numeric-range\"\n\nexport function getChannelDetails(color: Color, xChannel: ColorChannel, yChannel: ColorChannel) {\n const channels = color.getColorSpaceAxes({ xChannel, yChannel })\n\n const xChannelRange = color.getChannelRange(channels.xChannel)\n const yChannelRange = color.getChannelRange(channels.yChannel)\n\n const { minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX } = xChannelRange\n const { minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY } = yChannelRange\n\n const xValue = color.getChannelValue(channels.xChannel)\n const yValue = color.getChannelValue(channels.yChannel)\n\n return {\n channels,\n xChannelStep: stepX,\n yChannelStep: stepY,\n xChannelPageStep: pageSizeX,\n yChannelPageStep: pageSizeY,\n xValue,\n yValue,\n getThumbPosition() {\n let x = (xValue - minValueX) / (maxValueX - minValueX)\n let y = 1 - (yValue - minValueY) / (maxValueY - minValueY)\n return { x, y }\n },\n incrementX(stepSize: number) {\n return xValue + stepSize > maxValueX ? maxValueX : snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX)\n },\n incrementY(stepSize: number) {\n return yValue + stepSize > maxValueY ? maxValueY : snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY)\n },\n decrementX(stepSize: number) {\n return snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX)\n },\n decrementY(stepSize: number) {\n return snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY)\n },\n getColorFromPoint(x: number, y: number) {\n let newXValue = getPercentValue(x, minValueX, maxValueX, stepX)\n let newYValue = getPercentValue(1 - y, minValueY, maxValueY, stepY)\n\n let newColor: Color | undefined\n\n if (newXValue !== xValue) {\n newXValue = snapValueToStep(newXValue, minValueX, maxValueX, stepX)\n newColor = color.withChannelValue(channels.xChannel, newXValue)\n }\n\n if (newYValue !== yValue) {\n newYValue = snapValueToStep(newYValue, minValueY, maxValueY, stepY)\n newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue)\n }\n\n return newColor\n },\n }\n}\n","import { parseColor, type Color, type ColorChannel } from \"@zag-js/color-utils\"\n\nexport function getChannelDisplayColor(color: Color, channel: ColorChannel) {\n switch (channel) {\n case \"hue\":\n return parseColor(`hsl(${color.getChannelValue(\"hue\")}, 100%, 50%)`)\n case \"lightness\":\n case \"brightness\":\n case \"saturation\":\n case \"red\":\n case \"green\":\n case \"blue\":\n return color.withChannelValue(\"alpha\", 1)\n case \"alpha\": {\n return color\n }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n}\n","import type { Color } from \"@zag-js/color-utils\"\nimport type { ExtendedColorChannel } from \"../color-picker.types\"\n\nexport function getChannelInputValue(color: Color, channel: ExtendedColorChannel) {\n switch (channel) {\n case \"hex\":\n return color.toString(\"hex\")\n case \"css\":\n return color.toString(\"css\")\n default:\n return color.getChannelValue(channel).toString()\n }\n}\n\nexport function getChannelInputRange(color: Color, channel: ExtendedColorChannel) {\n switch (channel) {\n case \"hex\":\n case \"css\":\n return undefined\n default:\n return color.getChannelRange(channel)\n }\n}\n","export const generateRGB_R = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_G = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateRGB_B = (orientation: [string, string], dir: boolean, zValue: number) => {\n const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`\n const result = {\n areaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`,\n },\n areaGradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,\n WebkitMaskImage: maskImage,\n maskImage,\n },\n }\n return result\n}\n\nexport const generateHSL_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(dir)]\n }, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${\n orientation[Number(!dir)]\n }, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n \"hsl(0, 0%, 50%)\",\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSL_L = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n backgroundImage: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_H = (orientation: [string, string], dir: boolean, zValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,\n `hsl(${zValue}, 100%, 50%)`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_S = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`,\n ].join(\",\"),\n },\n }\n return result\n}\n\nexport const generateHSB_B = (orientation: [string, string], dir: boolean, alphaValue: number) => {\n const result = {\n areaStyles: {},\n areaGradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,\n `linear-gradient(to ${\n orientation[Number(dir)]\n },hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n \"#000\",\n ].join(\",\"),\n },\n }\n return result\n}\n","import type { ColorChannel } from \"@zag-js/color-utils\"\nimport type { Style } from \"@zag-js/types\"\nimport type { MachineContext } from \"../color-picker.types\"\nimport {\n generateHSB_B,\n generateHSB_H,\n generateHSB_S,\n generateHSL_H,\n generateHSL_L,\n generateHSL_S,\n generateRGB_B,\n generateRGB_G,\n generateRGB_R,\n} from \"./generate-format-background\"\n\nexport function getColorAreaGradient(ctx: MachineContext, xChannel: ColorChannel, yChannel: ColorChannel) {\n const value = ctx.valueAsColor\n\n const { zChannel } = value.getColorSpaceAxes({ xChannel, yChannel })\n const zValue = value.getChannelValue(zChannel)\n\n const { minValue: zMin, maxValue: zMax } = value.getChannelRange(zChannel)\n const orientation: [string, string] = [\"top\", ctx.dir === \"rtl\" ? \"left\" : \"right\"]\n\n let dir = false\n let background = { areaStyles: {} as Style, areaGradientStyles: {} as Style }\n\n let alphaValue = (zValue - zMin) / (zMax - zMin)\n let isHSL = value.getColorSpace() === \"hsl\"\n\n switch (zChannel) {\n case \"red\": {\n dir = xChannel === \"green\"\n background = generateRGB_R(orientation, dir, zValue)\n break\n }\n\n case \"green\": {\n dir = xChannel === \"red\"\n background = generateRGB_G(orientation, dir, zValue)\n break\n }\n\n case \"blue\": {\n dir = xChannel === \"red\"\n background = generateRGB_B(orientation, dir, zValue)\n break\n }\n\n case \"hue\": {\n dir = xChannel !== \"saturation\"\n if (isHSL) {\n background = generateHSL_H(orientation, dir, zValue)\n } else {\n background = generateHSB_H(orientation, dir, zValue)\n }\n break\n }\n\n case \"saturation\": {\n dir = xChannel === \"hue\"\n if (isHSL) {\n background = generateHSL_S(orientation, dir, alphaValue)\n } else {\n background = generateHSB_S(orientation, dir, alphaValue)\n }\n break\n }\n\n case \"brightness\": {\n dir = xChannel === \"hue\"\n background = generateHSB_B(orientation, dir, alphaValue)\n break\n }\n\n case \"lightness\": {\n dir = xChannel === \"hue\"\n background = generateHSL_L(orientation, dir, zValue)\n break\n }\n }\n\n return background\n}\n","import type { ColorChannelProps, MachineContext } from \"../color-picker.types\"\n\nfunction getSliderBgDirection(orientation: \"vertical\" | \"horizontal\", dir: \"ltr\" | \"rtl\") {\n if (orientation === \"vertical\") {\n return \"top\"\n } else if (dir === \"ltr\") {\n return \"right\"\n } else {\n return \"left\"\n }\n}\n\nexport const getSliderBgImage = (ctx: MachineContext, props: Required<ColorChannelProps>) => {\n const { channel } = props\n\n const dir = getSliderBgDirection(props.orientation, ctx.dir!)\n const value = ctx.valueAsColor\n\n const { minValue, maxValue } = ctx.valueAsColor.getChannelRange(channel)\n\n switch (channel) {\n case \"hue\":\n return `linear-gradient(to ${dir}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`\n case \"lightness\": {\n let start = ctx.valueAsColor.withChannelValue(channel, minValue).toString(\"css\")\n let middle = value.withChannelValue(channel, (maxValue - minValue) / 2).toString(\"css\")\n let end = value.withChannelValue(channel, maxValue).toString(\"css\")\n return `linear-gradient(to ${dir}, ${start}, ${middle}, ${end})`\n }\n case \"saturation\":\n case \"brightness\":\n case \"red\":\n case \"green\":\n case \"blue\":\n case \"alpha\": {\n let start = value.withChannelValue(channel, minValue).toString(\"css\")\n let end = value.withChannelValue(channel, maxValue).toString(\"css\")\n return `linear-gradient(to ${dir}, ${start}, ${end})`\n }\n default:\n throw new Error(\"Unknown color channel: \" + channel)\n }\n}\n","import { type Color, parseColor } from \"@zag-js/color-utils\"\nimport { createMachine } from \"@zag-js/core\"\nimport { trackPointerMove } from \"@zag-js/dom-event\"\nimport { raf } from \"@zag-js/dom-query\"\nimport { clampValue, getPercentValue, snapValueToStep } from \"@zag-js/numeric-range\"\nimport { disableTextSelection } from \"@zag-js/text-selection\"\nimport { compact } from \"@zag-js/utils\"\nimport { dom } from \"./color-picker.dom\"\nimport type { ExtendedColorChannel, MachineContext, MachineState, UserDefinedContext } from \"./color-picker.types\"\nimport { getChannelDetails } from \"./utils/get-channel-details\"\nimport { getChannelInputValue } from \"./utils/get-channel-input-value\"\n\nexport function machine(userContext: UserDefinedContext) {\n const ctx = compact(userContext)\n\n return createMachine<MachineContext, MachineState>(\n {\n id: \"color-picker\",\n initial: \"idle\",\n context: {\n dir: \"ltr\",\n activeId: null,\n activeChannel: null,\n activeOrientation: null,\n value: \"#D9D9D9\",\n ...ctx,\n valueAsColor: parseColor(ctx.value || \"#D9D9D9\"),\n },\n\n computed: {\n isRtl: (ctx) => ctx.dir === \"rtl\",\n isInteractive: (ctx) => !(ctx.disabled || ctx.readOnly),\n },\n\n on: {\n \"VALUE.SET\": {\n actions: [\"setValue\"],\n },\n },\n\n created: [\"setValueAsColor\"],\n\n watch: {\n value: [\"setValueAsColor\", \"syncChannelInputs\", \"invokeOnChange\"],\n },\n\n states: {\n idle: {\n on: {\n \"EYEDROPPER.CLICK\": {\n actions: [\"openEyeDropper\"],\n },\n \"AREA.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setAreaColorFromPoint\", \"focusAreaThumb\"],\n },\n \"CHANNEL_SLIDER.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setChannelColorFromPoint\", \"focusChannelThumb\"],\n },\n \"CHANNEL_INPUT.FOCUS\": {\n target: \"focused\",\n actions: [\"setActiveChannel\"],\n },\n \"CHANNEL_INPUT.CHANGE\": {\n actions: [\"setChannelColorFromInput\"],\n },\n },\n },\n\n focused: {\n on: {\n \"AREA.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setAreaColorFromPoint\", \"focusAreaThumb\"],\n },\n \"CHANNEL_SLIDER.POINTER_DOWN\": {\n target: \"dragging\",\n actions: [\"setActiveChannel\", \"setChannelColorFromPoint\", \"focusChannelThumb\"],\n },\n \"AREA.ARROW_LEFT\": {\n actions: [\"decrementXChannel\"],\n },\n \"AREA.ARROW_RIGHT\": {\n actions: [\"incrementXChannel\"],\n },\n \"AREA.ARROW_UP\": {\n actions: [\"incrementYChannel\"],\n },\n \"AREA.ARROW_DOWN\": {\n actions: [\"decrementYChannel\"],\n },\n \"AREA.PAGE_UP\": {\n actions: [\"incrementXChannel\"],\n },\n \"AREA.PAGE_DOWN\": {\n actions: [\"decrementXChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_LEFT\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_RIGHT\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_UP\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.ARROW_DOWN\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.PAGE_UP\": {\n actions: [\"incrementChannel\"],\n },\n \"CHANNEL_SLIDER.PAGE_DOWN\": {\n actions: [\"decrementChannel\"],\n },\n \"CHANNEL_SLIDER.HOME\": {\n actions: [\"setChannelToMin\"],\n },\n \"CHANNEL_SLIDER.END\": {\n actions: [\"setChannelToMax\"],\n },\n \"CHANNEL_INPUT.FOCUS\": {\n actions: [\"setActiveChannel\"],\n },\n \"CHANNEL_INPUT.CHANGE\": {\n actions: [\"setChannelColorFromInput\"],\n },\n \"CHANNEL_INPUT.BLUR\": [\n {\n guard: \"isTextField\",\n target: \"idle\",\n actions: [\"setChannelColorFromInput\"],\n },\n { target: \"idle\" },\n ],\n \"CHANNEL_SLIDER.BLUR\": {\n target: \"idle\",\n },\n \"AREA.BLUR\": {\n target: \"idle\",\n },\n },\n },\n\n dragging: {\n exit: [\"clearActiveChannel\"],\n activities: [\"trackPointerMove\", \"disableTextSelection\"],\n on: {\n \"AREA.POINTER_MOVE\": {\n actions: [\"setAreaColorFromPoint\"],\n },\n \"AREA.POINTER_UP\": {\n target: \"focused\",\n actions: [\"invokeOnChangeEnd\"],\n },\n \"CHANNEL_SLIDER.POINTER_MOVE\": {\n actions: [\"setChannelColorFromPoint\"],\n },\n \"CHANNEL_SLIDER.POINTER_UP\": {\n target: \"focused\",\n actions: [\"invokeOnChangeEnd\"],\n },\n },\n },\n },\n },\n {\n guards: {\n isTextField: (_ctx, evt) => !!evt.isTextField,\n },\n activities: {\n trackPointerMove(ctx, _evt, { send }) {\n return trackPointerMove(dom.getDoc(ctx), {\n onPointerMove({ point }) {\n const type = ctx.activeId === \"area\" ? \"AREA.POINTER_MOVE\" : \"CHANNEL_SLIDER.POINTER_MOVE\"\n send({ type, point })\n },\n onPointerUp() {\n const type = ctx.activeId === \"area\" ? \"AREA.POINTER_UP\" : \"CHANNEL_SLIDER.POINTER_UP\"\n send({ type })\n },\n })\n },\n disableTextSelection(ctx) {\n return disableTextSelection({ doc: dom.getDoc(ctx), target: dom.getContentEl(ctx) })\n },\n },\n actions: {\n openEyeDropper(ctx) {\n const isSupported = \"EyeDropper\" in dom.getWin(ctx)\n if (!isSupported) return\n const win = dom.getWin(ctx) as any\n const picker = new win.EyeDropper()\n picker\n .open()\n .then(({ sRGBHex }: { sRGBHex: string }) => {\n const format = ctx.valueAsColor.getColorSpace()\n const color = parseColor(sRGBHex).toFormat(format)\n setColor(ctx, color)\n ctx.onChangeEnd?.({ value: ctx.value, valueAsColor: color })\n })\n .catch(() => void 0)\n },\n setActiveChannel(ctx, evt) {\n ctx.activeId = evt.id\n if (evt.channel) {\n ctx.activeChannel = evt.channel\n }\n if (evt.orientation) {\n ctx.activeOrientation = evt.orientation\n }\n },\n clearActiveChannel(ctx) {\n ctx.activeChannel = null\n ctx.activeId = null\n ctx.activeOrientation = null\n },\n setAreaColorFromPoint(ctx, evt) {\n const { xChannel, yChannel } = evt.channel || ctx.activeChannel\n\n const percent = dom.getAreaValueFromPoint(ctx, evt.point)\n const { getColorFromPoint } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const color = getColorFromPoint(percent.x, percent.y)\n\n if (!color) return\n setColor(ctx, color)\n },\n setChannelColorFromPoint(ctx, evt) {\n const channel = evt.channel || ctx.activeId\n const percent = dom.getChannelSliderValueFromPoint(ctx, evt.point, channel)\n\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(channel)\n const orientation = ctx.activeOrientation || \"horizontal\"\n\n const point = orientation === \"horizontal\" ? percent.x : percent.y\n const channelValue = getPercentValue(point, minValue, maxValue, step)\n\n const value = snapValueToStep(channelValue - step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(channel, value)\n\n setColor(ctx, newColor)\n },\n setValue(ctx, evt) {\n setColor(ctx, evt.value)\n },\n setValueAsColor(ctx) {\n try {\n const color = parseColor(ctx.value)\n if (color.isEqual(ctx.valueAsColor)) return\n ctx.valueAsColor = color\n } catch {}\n },\n syncChannelInputs(ctx) {\n const inputs = dom.getChannelInputEls(ctx)\n inputs.forEach((input) => {\n const channel = input.getAttribute(\"data-channel\") as ExtendedColorChannel | null\n if (!channel) return\n const value = getChannelInputValue(ctx.valueAsColor, channel)\n input.value = value.toString()\n })\n },\n setChannelColorFromInput(ctx, evt) {\n const { channel, isTextField, value } = evt\n try {\n const format = ctx.valueAsColor.getColorSpace()\n\n const newColor = isTextField\n ? parseColor(value).toFormat(format)\n : ctx.valueAsColor.withChannelValue(channel, value)\n\n setColor(ctx, newColor)\n //\n } catch {\n // reset input value\n const input = dom.getChannelInputEl(ctx, channel)\n if (!input) return\n input.value = getChannelInputValue(ctx.valueAsColor, channel)\n }\n },\n\n incrementChannel(ctx, evt) {\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(evt.channel)\n const channelValue = ctx.valueAsColor.getChannelValue(evt.channel)\n const value = snapValueToStep(channelValue + evt.step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, clampValue(value, minValue, maxValue))\n setColor(ctx, newColor)\n },\n decrementChannel(ctx, evt) {\n const { minValue, maxValue, step } = ctx.valueAsColor.getChannelRange(evt.channel)\n const channelValue = ctx.valueAsColor.getChannelValue(evt.channel)\n const value = snapValueToStep(channelValue - evt.step, minValue, maxValue, step)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, clampValue(value, minValue, maxValue))\n setColor(ctx, newColor)\n },\n\n incrementXChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { incrementX } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(xChannel, incrementX(evt.step))\n setColor(ctx, newColor)\n },\n decrementXChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { decrementX } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(xChannel, decrementX(evt.step))\n setColor(ctx, newColor)\n },\n\n incrementYChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { incrementY } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(yChannel, incrementY(evt.step))\n setColor(ctx, newColor)\n },\n decrementYChannel(ctx, evt) {\n const { xChannel, yChannel } = evt.channel\n const { decrementY } = getChannelDetails(ctx.valueAsColor, xChannel, yChannel)\n const newColor = ctx.valueAsColor.withChannelValue(yChannel, decrementY(evt.step))\n setColor(ctx, newColor)\n },\n\n setChannelToMax(ctx, evt) {\n const { maxValue } = ctx.valueAsColor.getChannelRange(evt.channel)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, maxValue)\n setColor(ctx, newColor)\n },\n setChannelToMin(ctx, evt) {\n const { minValue } = ctx.valueAsColor.getChannelRange(evt.channel)\n const newColor = ctx.valueAsColor.withChannelValue(evt.channel, minValue)\n setColor(ctx, newColor)\n },\n\n invokeOnChangeEnd(ctx) {\n ctx.onChangeEnd?.({ value: ctx.value, valueAsColor: ctx.valueAsColor })\n },\n invokeOnChange(ctx) {\n ctx.onChange?.({ value: ctx.value, valueAsColor: ctx.valueAsColor })\n },\n focusAreaThumb(ctx) {\n raf(() => {\n dom.getAreaThumbEl(ctx)?.focus({ preventScroll: true })\n })\n },\n focusChannelThumb(ctx, evt) {\n raf(() => {\n dom.getChannelSliderThumbEl(ctx, evt.channel)?.focus({ preventScroll: true })\n })\n },\n },\n },\n )\n}\n\nconst setColor = (ctx: MachineContext, color: Color) => {\n ctx.value = color.toString(\"css\")\n ctx.valueAsColor = color\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;AAEvB,IAAM,UAAU,cAAc,gBAAgB;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,QAAQ,QAAQ,MAAM;;;ACjBnC,SAAS,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I,OAAO,GAAG,MAAM,EAAE,eAAe,KAAK,CAAC;AAAA,UAC9E,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAM,WAAW,CAAC,KAAqB,UAAiB;AACtD,MAAI,QAAQ,MAAM,SAAS,KAAK;AAChC,MAAI,eAAe;AACrB;","names":["parseColor","getPercentValue","snapValueToStep","parseColor","ctx","getPercentValue","snapValueToStep"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/color-picker",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "Core logic for the color-picker widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@zag-js/core": "0.11.
|
|
32
|
-
"@zag-js/anatomy": "0.11.
|
|
33
|
-
"@zag-js/dom-query": "0.11.
|
|
34
|
-
"@zag-js/dom-event": "0.11.
|
|
35
|
-
"@zag-js/utils": "0.11.
|
|
36
|
-
"@zag-js/color-utils": "0.11.
|
|
37
|
-
"@zag-js/numeric-range": "0.11.
|
|
38
|
-
"@zag-js/text-selection": "0.11.
|
|
39
|
-
"@zag-js/types": "0.11.
|
|
31
|
+
"@zag-js/core": "0.11.2",
|
|
32
|
+
"@zag-js/anatomy": "0.11.2",
|
|
33
|
+
"@zag-js/dom-query": "0.11.2",
|
|
34
|
+
"@zag-js/dom-event": "0.11.2",
|
|
35
|
+
"@zag-js/utils": "0.11.2",
|
|
36
|
+
"@zag-js/color-utils": "0.11.2",
|
|
37
|
+
"@zag-js/numeric-range": "0.11.2",
|
|
38
|
+
"@zag-js/text-selection": "0.11.2",
|
|
39
|
+
"@zag-js/types": "0.11.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"clean-package": "2.2.0"
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeColor, type Color, type ColorChannel, type ColorFormat } from "@zag-js/color-utils"
|
|
2
2
|
import {
|
|
3
|
-
EventKeyMap,
|
|
4
3
|
getEventKey,
|
|
5
4
|
getEventPoint,
|
|
6
5
|
getEventStep,
|
|
7
6
|
getNativeEvent,
|
|
8
7
|
isLeftClick,
|
|
9
8
|
isModifiedEvent,
|
|
9
|
+
type EventKeyMap,
|
|
10
10
|
} from "@zag-js/dom-event"
|
|
11
11
|
import { dataAttr } from "@zag-js/dom-query"
|
|
12
|
-
import { NormalizeProps,
|
|
12
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types"
|
|
13
13
|
import { parts } from "./color-picker.anatomy"
|
|
14
14
|
import { dom } from "./color-picker.dom"
|
|
15
|
-
import {
|
|
15
|
+
import type {
|
|
16
16
|
ColorAreaProps,
|
|
17
17
|
ColorChannelInputProps,
|
|
18
18
|
ColorChannelProps,
|
|
19
19
|
ColorSwatchProps,
|
|
20
|
+
PublicApi,
|
|
20
21
|
Send,
|
|
21
22
|
State,
|
|
22
23
|
} from "./color-picker.types"
|
|
@@ -26,7 +27,7 @@ import { getChannelInputRange, getChannelInputValue } from "./utils/get-channel-
|
|
|
26
27
|
import { getColorAreaGradient } from "./utils/get-color-area-gradient"
|
|
27
28
|
import { getSliderBgImage } from "./utils/get-slider-background"
|
|
28
29
|
|
|
29
|
-
export function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>) {
|
|
30
|
+
export function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): PublicApi<T> {
|
|
30
31
|
const valueAsColor = state.context.valueAsColor
|
|
31
32
|
const isDisabled = state.context.disabled
|
|
32
33
|
const isInteractive = state.context.isInteractive
|
|
@@ -35,38 +36,20 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
|
|
|
35
36
|
const channels = valueAsColor.getColorChannels()
|
|
36
37
|
|
|
37
38
|
return {
|
|
38
|
-
/**
|
|
39
|
-
* Whether the color picker is being dragged
|
|
40
|
-
*/
|
|
41
39
|
isDragging,
|
|
42
|
-
/**
|
|
43
|
-
* The current color value (as a string)
|
|
44
|
-
*/
|
|
45
40
|
value: state.context.value,
|
|
46
|
-
/**
|
|
47
|
-
* The current color value (as a Color object)
|
|
48
|
-
*/
|
|
49
41
|
valueAsColor,
|
|
50
|
-
/**
|
|
51
|
-
* The current color channels of the color
|
|
52
|
-
*/
|
|
53
42
|
channels,
|
|
54
|
-
|
|
55
|
-
* Function to set the color value
|
|
56
|
-
*/
|
|
43
|
+
|
|
57
44
|
setColor(value: string | Color) {
|
|
58
45
|
send({ type: "VALUE.SET", value: normalizeColor(value), src: "set-color" })
|
|
59
46
|
},
|
|
60
|
-
|
|
61
|
-
* Function to set the color value of a specific channel
|
|
62
|
-
*/
|
|
47
|
+
|
|
63
48
|
setChannelValue(channel: ColorChannel, value: number) {
|
|
64
49
|
const color = valueAsColor.withChannelValue(channel, value)
|
|
65
50
|
send({ type: "VALUE.SET", value: color, src: "set-channel" })
|
|
66
51
|
},
|
|
67
|
-
|
|
68
|
-
* Function to set the color format
|
|
69
|
-
*/
|
|
52
|
+
|
|
70
53
|
setFormat(format: ColorFormat) {
|
|
71
54
|
const value = valueAsColor.toFormat(format)
|
|
72
55
|
send({ type: "VALUE.SET", value, src: "set-format" })
|
package/src/color-picker.dom.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ColorChannel } from "@zag-js/color-utils"
|
|
2
2
|
import { getRelativePoint, type Point } from "@zag-js/dom-event"
|
|
3
3
|
import { createScope, queryAll } from "@zag-js/dom-query"
|
|
4
4
|
import type { MachineContext as Ctx } from "./color-picker.types"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color, parseColor } from "@zag-js/color-utils"
|
|
1
|
+
import { type Color, parseColor } from "@zag-js/color-utils"
|
|
2
2
|
import { createMachine } from "@zag-js/core"
|
|
3
3
|
import { trackPointerMove } from "@zag-js/dom-event"
|
|
4
4
|
import { raf } from "@zag-js/dom-query"
|
|
@@ -6,7 +6,7 @@ import { clampValue, getPercentValue, snapValueToStep } from "@zag-js/numeric-ra
|
|
|
6
6
|
import { disableTextSelection } from "@zag-js/text-selection"
|
|
7
7
|
import { compact } from "@zag-js/utils"
|
|
8
8
|
import { dom } from "./color-picker.dom"
|
|
9
|
-
import { ExtendedColorChannel, MachineContext, MachineState, UserDefinedContext } from "./color-picker.types"
|
|
9
|
+
import type { ExtendedColorChannel, MachineContext, MachineState, UserDefinedContext } from "./color-picker.types"
|
|
10
10
|
import { getChannelDetails } from "./utils/get-channel-details"
|
|
11
11
|
import { getChannelInputValue } from "./utils/get-channel-input-value"
|
|
12
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Color,
|
|
1
|
+
import type { Color, ColorAxes, ColorChannel, ColorFormat, ColorType } from "@zag-js/color-utils"
|
|
2
2
|
import type { StateMachine as S } from "@zag-js/core"
|
|
3
|
-
import type { CommonProperties, Context, Orientation, RequiredBy } from "@zag-js/types"
|
|
3
|
+
import type { CommonProperties, Context, Orientation, PropTypes, RequiredBy } from "@zag-js/types"
|
|
4
4
|
|
|
5
5
|
export type ColorChannelProps = {
|
|
6
6
|
channel: ColorChannel
|
|
@@ -70,6 +70,48 @@ type PublicContext = CommonProperties & {
|
|
|
70
70
|
onChangeEnd?: (details: ChangeDetails) => void
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
export type PublicApi<T extends PropTypes = PropTypes> = {
|
|
74
|
+
/**
|
|
75
|
+
* Whether the color picker is being dragged
|
|
76
|
+
*/
|
|
77
|
+
isDragging: boolean
|
|
78
|
+
/**
|
|
79
|
+
* The current color value (as a string)
|
|
80
|
+
*/
|
|
81
|
+
value: string
|
|
82
|
+
/**
|
|
83
|
+
* The current color value (as a Color object)
|
|
84
|
+
*/
|
|
85
|
+
valueAsColor: Color
|
|
86
|
+
/**
|
|
87
|
+
* The current color channels of the color
|
|
88
|
+
*/
|
|
89
|
+
channels: [ColorChannel, ColorChannel, ColorChannel]
|
|
90
|
+
/**
|
|
91
|
+
* Function to set the color value
|
|
92
|
+
*/
|
|
93
|
+
setColor(value: string | Color): void
|
|
94
|
+
/**
|
|
95
|
+
* Function to set the color value of a specific channel
|
|
96
|
+
*/
|
|
97
|
+
setChannelValue(channel: ColorChannel, value: number): void
|
|
98
|
+
/**
|
|
99
|
+
* Function to set the color format
|
|
100
|
+
*/
|
|
101
|
+
setFormat(format: ColorFormat): void
|
|
102
|
+
contentProps: T["element"]
|
|
103
|
+
getAreaProps(props: ColorAreaProps): T["element"]
|
|
104
|
+
getAreaGradientProps(props: ColorAreaProps): T["element"]
|
|
105
|
+
getAreaThumbProps(props: ColorAreaProps): T["element"]
|
|
106
|
+
getChannelSliderTrackProps(props: ColorChannelProps): T["element"]
|
|
107
|
+
getChannelSliderBackgroundProps(props: ColorChannelProps): T["element"]
|
|
108
|
+
getChannelSliderThumbProps(props: ColorChannelProps): T["element"]
|
|
109
|
+
getChannelInputProps(props: ColorChannelInputProps): T["input"]
|
|
110
|
+
eyeDropperTriggerProps: T["button"]
|
|
111
|
+
getSwatchBackgroundProps(props: ColorSwatchProps): T["element"]
|
|
112
|
+
getSwatchProps(props: ColorSwatchProps): T["element"]
|
|
113
|
+
}
|
|
114
|
+
|
|
73
115
|
type PrivateContext = Context<{
|
|
74
116
|
/**
|
|
75
117
|
* The id of the thumb that is currently being dragged
|
|
@@ -112,4 +154,4 @@ export type State = S.State<MachineContext, MachineState>
|
|
|
112
154
|
|
|
113
155
|
export type Send = S.Send<S.AnyEventObject>
|
|
114
156
|
|
|
115
|
-
export type { Color, ColorChannel, ColorFormat }
|
|
157
|
+
export type { Color, ColorAxes, ColorChannel, ColorFormat, ColorType }
|
package/src/index.ts
CHANGED
|
@@ -3,10 +3,14 @@ export { connect } from "./color-picker.connect"
|
|
|
3
3
|
export { machine } from "./color-picker.machine"
|
|
4
4
|
export type {
|
|
5
5
|
Color,
|
|
6
|
+
ColorAxes,
|
|
7
|
+
ColorFormat,
|
|
6
8
|
ColorAreaProps,
|
|
7
9
|
ColorChannel,
|
|
8
10
|
ColorChannelProps,
|
|
9
11
|
ColorChannelInputProps,
|
|
10
12
|
ColorSwatchProps,
|
|
13
|
+
ColorType,
|
|
11
14
|
UserDefinedContext as Context,
|
|
15
|
+
PublicApi,
|
|
12
16
|
} from "./color-picker.types"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color,
|
|
1
|
+
import type { Color, ColorChannel } from "@zag-js/color-utils"
|
|
2
2
|
import { getPercentValue, snapValueToStep } from "@zag-js/numeric-range"
|
|
3
3
|
|
|
4
4
|
export function getChannelDetails(color: Color, xChannel: ColorChannel, yChannel: ColorChannel) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Color } from "@zag-js/color-utils"
|
|
2
|
-
import { ExtendedColorChannel } from "../color-picker.types"
|
|
1
|
+
import type { Color } from "@zag-js/color-utils"
|
|
2
|
+
import type { ExtendedColorChannel } from "../color-picker.types"
|
|
3
3
|
|
|
4
4
|
export function getChannelInputValue(color: Color, channel: ExtendedColorChannel) {
|
|
5
5
|
switch (channel) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Style } from "@zag-js/types"
|
|
3
|
-
import { MachineContext } from "../color-picker.types"
|
|
1
|
+
import type { ColorChannel } from "@zag-js/color-utils"
|
|
2
|
+
import type { Style } from "@zag-js/types"
|
|
3
|
+
import type { MachineContext } from "../color-picker.types"
|
|
4
4
|
import {
|
|
5
5
|
generateHSB_B,
|
|
6
6
|
generateHSB_H,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorChannelProps, MachineContext } from "../color-picker.types"
|
|
1
|
+
import type { ColorChannelProps, MachineContext } from "../color-picker.types"
|
|
2
2
|
|
|
3
3
|
function getSliderBgDirection(orientation: "vertical" | "horizontal", dir: "ltr" | "rtl") {
|
|
4
4
|
if (orientation === "vertical") {
|