@zag-js/color-picker 0.56.1 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -5,11 +5,11 @@ import { RequiredBy, Orientation, PropTypes, CommonProperties, DirectionProperty
5
5
  import { Color, ColorFormat, ColorChannel } from '@zag-js/color-utils';
6
6
  export { Color, ColorAxes, ColorChannel, ColorFormat, ColorType } from '@zag-js/color-utils';
7
7
  import * as _zag_js_core from '@zag-js/core';
8
- import { StateMachine } from '@zag-js/core';
8
+ import { Machine, StateMachine } from '@zag-js/core';
9
9
  import { PositioningOptions } from '@zag-js/popper';
10
10
  export { PositioningOptions } from '@zag-js/popper';
11
11
 
12
- declare const anatomy: _zag_js_anatomy.Anatomy<"area" | "label" | "root" | "content" | "control" | "trigger" | "positioner" | "areaThumb" | "areaBackground" | "channelSlider" | "channelSliderTrack" | "channelSliderThumb" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
12
+ declare const anatomy: _zag_js_anatomy.Anatomy<"area" | "label" | "root" | "content" | "control" | "trigger" | "positioner" | "areaThumb" | "areaBackground" | "channelSlider" | "channelSliderLabel" | "channelSliderTrack" | "channelSliderThumb" | "channelSliderValueText" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
13
13
 
14
14
  type ExtendedColorChannel = ColorChannel | "hex" | "css";
15
15
  interface EyeDropper {
@@ -42,9 +42,12 @@ type ElementIds = Partial<{
42
42
  trigger: string;
43
43
  label: string;
44
44
  input: string;
45
+ hiddenInput: string;
45
46
  content: string;
46
47
  area: string;
47
48
  areaGradient: string;
49
+ positioner: string;
50
+ formatSelect: string;
48
51
  areaThumb: string;
49
52
  channelInput(id: string): string;
50
53
  channelSliderTrack(id: ColorChannel): string;
@@ -68,6 +71,10 @@ interface PublicContext extends CommonProperties, DirectionProperty, InteractOut
68
71
  * Whether the color picker is read-only
69
72
  */
70
73
  readOnly?: boolean;
74
+ /**
75
+ * Whether the color picker is required
76
+ */
77
+ required?: boolean;
71
78
  /**
72
79
  * Handler that is called when the value changes, as the user drags.
73
80
  */
@@ -153,10 +160,14 @@ interface MachineState {
153
160
  }
154
161
  type State = StateMachine.State<MachineContext, MachineState>;
155
162
  type Send = StateMachine.Send<StateMachine.AnyEventObject>;
163
+ type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
156
164
  interface ChannelProps {
157
165
  channel: ColorChannel;
158
166
  orientation?: Orientation;
159
167
  }
168
+ interface ChannelSliderProps extends ChannelProps {
169
+ format?: ColorFormat;
170
+ }
160
171
  interface ChannelInputProps {
161
172
  channel: ExtendedColorChannel;
162
173
  orientation?: Orientation;
@@ -219,6 +230,10 @@ interface MachineApi<T extends PropTypes = PropTypes> {
219
230
  * Function to set the color value
220
231
  */
221
232
  getChannelValue(channel: ColorChannel): string;
233
+ /**
234
+ * Function to get the formatted and localized value of a specific channel
235
+ */
236
+ getChannelValueText(channel: ColorChannel, locale: string): string;
222
237
  /**
223
238
  * Function to set the color value of a specific channel
224
239
  */
@@ -253,10 +268,12 @@ interface MachineApi<T extends PropTypes = PropTypes> {
253
268
  getAreaProps(props?: AreaProps): T["element"];
254
269
  getAreaBackgroundProps(props?: AreaProps): T["element"];
255
270
  getAreaThumbProps(props?: AreaProps): T["element"];
256
- getChannelSliderProps(props: ChannelProps): T["element"];
257
- getChannelSliderTrackProps(props: ChannelProps): T["element"];
258
- getChannelSliderThumbProps(props: ChannelProps): T["element"];
259
271
  getChannelInputProps(props: ChannelInputProps): T["input"];
272
+ getChannelSliderProps(props: ChannelSliderProps): T["element"];
273
+ getChannelSliderTrackProps(props: ChannelSliderProps): T["element"];
274
+ getChannelSliderThumbProps(props: ChannelSliderProps): T["element"];
275
+ getChannelSliderLabelProps(props: ChannelProps): T["element"];
276
+ getChannelSliderValueTextProps(props: ChannelProps): T["element"];
260
277
  getTransparencyGridProps(props?: TransparencyGridProps): T["element"];
261
278
  getEyeDropperTriggerProps(): T["button"];
262
279
  getSwatchGroupProps(): T["element"];
@@ -274,4 +291,4 @@ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<
274
291
 
275
292
  declare const parse: (colorString: string) => Color;
276
293
 
277
- export { type MachineApi as Api, type AreaProps, type ChannelInputProps, type ChannelProps, type UserDefinedContext as Context, type ElementIds, type FormatChangeDetails, type OpenChangeDetails, type SwatchProps, type SwatchTriggerProps, type SwatchTriggerState, type TransparencyGridProps, type ValueChangeDetails, anatomy, connect, machine, parse };
294
+ export { type MachineApi as Api, type AreaProps, type ChannelInputProps, type ChannelProps, type ChannelSliderProps, type UserDefinedContext as Context, type ElementIds, type FormatChangeDetails, type OpenChangeDetails, type Service, type SwatchProps, type SwatchTriggerProps, type SwatchTriggerState, type TransparencyGridProps, type ValueChangeDetails, anatomy, connect, machine, parse };
package/dist/index.d.ts CHANGED
@@ -5,11 +5,11 @@ import { RequiredBy, Orientation, PropTypes, CommonProperties, DirectionProperty
5
5
  import { Color, ColorFormat, ColorChannel } from '@zag-js/color-utils';
6
6
  export { Color, ColorAxes, ColorChannel, ColorFormat, ColorType } from '@zag-js/color-utils';
7
7
  import * as _zag_js_core from '@zag-js/core';
8
- import { StateMachine } from '@zag-js/core';
8
+ import { Machine, StateMachine } from '@zag-js/core';
9
9
  import { PositioningOptions } from '@zag-js/popper';
10
10
  export { PositioningOptions } from '@zag-js/popper';
11
11
 
12
- declare const anatomy: _zag_js_anatomy.Anatomy<"area" | "label" | "root" | "content" | "control" | "trigger" | "positioner" | "areaThumb" | "areaBackground" | "channelSlider" | "channelSliderTrack" | "channelSliderThumb" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
12
+ declare const anatomy: _zag_js_anatomy.Anatomy<"area" | "label" | "root" | "content" | "control" | "trigger" | "positioner" | "areaThumb" | "areaBackground" | "channelSlider" | "channelSliderLabel" | "channelSliderTrack" | "channelSliderThumb" | "channelSliderValueText" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
13
13
 
14
14
  type ExtendedColorChannel = ColorChannel | "hex" | "css";
15
15
  interface EyeDropper {
@@ -42,9 +42,12 @@ type ElementIds = Partial<{
42
42
  trigger: string;
43
43
  label: string;
44
44
  input: string;
45
+ hiddenInput: string;
45
46
  content: string;
46
47
  area: string;
47
48
  areaGradient: string;
49
+ positioner: string;
50
+ formatSelect: string;
48
51
  areaThumb: string;
49
52
  channelInput(id: string): string;
50
53
  channelSliderTrack(id: ColorChannel): string;
@@ -68,6 +71,10 @@ interface PublicContext extends CommonProperties, DirectionProperty, InteractOut
68
71
  * Whether the color picker is read-only
69
72
  */
70
73
  readOnly?: boolean;
74
+ /**
75
+ * Whether the color picker is required
76
+ */
77
+ required?: boolean;
71
78
  /**
72
79
  * Handler that is called when the value changes, as the user drags.
73
80
  */
@@ -153,10 +160,14 @@ interface MachineState {
153
160
  }
154
161
  type State = StateMachine.State<MachineContext, MachineState>;
155
162
  type Send = StateMachine.Send<StateMachine.AnyEventObject>;
163
+ type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
156
164
  interface ChannelProps {
157
165
  channel: ColorChannel;
158
166
  orientation?: Orientation;
159
167
  }
168
+ interface ChannelSliderProps extends ChannelProps {
169
+ format?: ColorFormat;
170
+ }
160
171
  interface ChannelInputProps {
161
172
  channel: ExtendedColorChannel;
162
173
  orientation?: Orientation;
@@ -219,6 +230,10 @@ interface MachineApi<T extends PropTypes = PropTypes> {
219
230
  * Function to set the color value
220
231
  */
221
232
  getChannelValue(channel: ColorChannel): string;
233
+ /**
234
+ * Function to get the formatted and localized value of a specific channel
235
+ */
236
+ getChannelValueText(channel: ColorChannel, locale: string): string;
222
237
  /**
223
238
  * Function to set the color value of a specific channel
224
239
  */
@@ -253,10 +268,12 @@ interface MachineApi<T extends PropTypes = PropTypes> {
253
268
  getAreaProps(props?: AreaProps): T["element"];
254
269
  getAreaBackgroundProps(props?: AreaProps): T["element"];
255
270
  getAreaThumbProps(props?: AreaProps): T["element"];
256
- getChannelSliderProps(props: ChannelProps): T["element"];
257
- getChannelSliderTrackProps(props: ChannelProps): T["element"];
258
- getChannelSliderThumbProps(props: ChannelProps): T["element"];
259
271
  getChannelInputProps(props: ChannelInputProps): T["input"];
272
+ getChannelSliderProps(props: ChannelSliderProps): T["element"];
273
+ getChannelSliderTrackProps(props: ChannelSliderProps): T["element"];
274
+ getChannelSliderThumbProps(props: ChannelSliderProps): T["element"];
275
+ getChannelSliderLabelProps(props: ChannelProps): T["element"];
276
+ getChannelSliderValueTextProps(props: ChannelProps): T["element"];
260
277
  getTransparencyGridProps(props?: TransparencyGridProps): T["element"];
261
278
  getEyeDropperTriggerProps(): T["button"];
262
279
  getSwatchGroupProps(): T["element"];
@@ -274,4 +291,4 @@ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<
274
291
 
275
292
  declare const parse: (colorString: string) => Color;
276
293
 
277
- export { type MachineApi as Api, type AreaProps, type ChannelInputProps, type ChannelProps, type UserDefinedContext as Context, type ElementIds, type FormatChangeDetails, type OpenChangeDetails, type SwatchProps, type SwatchTriggerProps, type SwatchTriggerState, type TransparencyGridProps, type ValueChangeDetails, anatomy, connect, machine, parse };
294
+ export { type MachineApi as Api, type AreaProps, type ChannelInputProps, type ChannelProps, type ChannelSliderProps, type UserDefinedContext as Context, type ElementIds, type FormatChangeDetails, type OpenChangeDetails, type Service, type SwatchProps, type SwatchTriggerProps, type SwatchTriggerState, type TransparencyGridProps, type ValueChangeDetails, anatomy, connect, machine, parse };
package/dist/index.js CHANGED
@@ -40,8 +40,10 @@ var anatomy = (0, import_anatomy.createAnatomy)("color-picker", [
40
40
  "areaThumb",
41
41
  "areaBackground",
42
42
  "channelSlider",
43
+ "channelSliderLabel",
43
44
  "channelSliderTrack",
44
45
  "channelSliderThumb",
46
+ "channelSliderValueText",
45
47
  "channelInput",
46
48
  "transparencyGrid",
47
49
  "swatchGroup",
@@ -66,24 +68,25 @@ var import_dom_query = require("@zag-js/dom-query");
66
68
  var dom = (0, import_dom_query.createScope)({
67
69
  getRootId: (ctx) => ctx.ids?.root ?? `color-picker:${ctx.id}`,
68
70
  getLabelId: (ctx) => ctx.ids?.label ?? `color-picker:${ctx.id}:label`,
69
- getHiddenInputId: (ctx) => `color-picker:${ctx.id}:hidden-input`,
71
+ getHiddenInputId: (ctx) => ctx.ids?.hiddenInput ?? `color-picker:${ctx.id}:hidden-input`,
70
72
  getControlId: (ctx) => ctx.ids?.control ?? `color-picker:${ctx.id}:control`,
71
73
  getTriggerId: (ctx) => ctx.ids?.trigger ?? `color-picker:${ctx.id}:trigger`,
72
74
  getContentId: (ctx) => ctx.ids?.content ?? `color-picker:${ctx.id}:content`,
73
- getPositionerId: (ctx) => `color-picker:${ctx.id}:positioner`,
74
- getFormatSelectId: (ctx) => `color-picker:${ctx.id}:format-select`,
75
+ getPositionerId: (ctx) => ctx.ids?.positioner ?? `color-picker:${ctx.id}:positioner`,
76
+ getFormatSelectId: (ctx) => ctx.ids?.formatSelect ?? `color-picker:${ctx.id}:format-select`,
75
77
  getAreaId: (ctx) => ctx.ids?.area ?? `color-picker:${ctx.id}:area`,
76
78
  getAreaGradientId: (ctx) => ctx.ids?.areaGradient ?? `color-picker:${ctx.id}:area-gradient`,
77
79
  getAreaThumbId: (ctx) => ctx.ids?.areaThumb ?? `color-picker:${ctx.id}:area-thumb`,
78
- getChannelSliderId: (ctx, channel) => ctx.ids?.channelSliderTrack?.(channel) ?? `color-picker:${ctx.id}:slider-track:${channel}`,
80
+ getChannelSliderTrackId: (ctx, channel) => ctx.ids?.channelSliderTrack?.(channel) ?? `color-picker:${ctx.id}:slider-track:${channel}`,
79
81
  getChannelSliderThumbId: (ctx, channel) => ctx.ids?.channelSliderThumb?.(channel) ?? `color-picker:${ctx.id}:slider-thumb:${channel}`,
80
82
  getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
81
83
  getAreaThumbEl: (ctx) => dom.getById(ctx, dom.getAreaThumbId(ctx)),
82
84
  getChannelSliderThumbEl: (ctx, channel) => dom.getById(ctx, dom.getChannelSliderThumbId(ctx, channel)),
83
85
  getChannelInputEl: (ctx, channel) => {
86
+ const selector = `input[data-channel="${channel}"]`;
84
87
  return [
85
- ...(0, import_dom_query.queryAll)(dom.getContentEl(ctx), `input[data-channel="${channel}"]`),
86
- ...(0, import_dom_query.queryAll)(dom.getControlEl(ctx), `input[data-channel="${channel}"]`)
88
+ ...(0, import_dom_query.queryAll)(dom.getContentEl(ctx), selector),
89
+ ...(0, import_dom_query.queryAll)(dom.getControlEl(ctx), selector)
87
90
  ];
88
91
  },
89
92
  getFormatSelectEl: (ctx) => dom.getById(ctx, dom.getFormatSelectId(ctx)),
@@ -99,7 +102,7 @@ var dom = (0, import_dom_query.createScope)({
99
102
  getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
100
103
  getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
101
104
  getChannelSliderTrackEl: (ctx, channel) => {
102
- return dom.getById(ctx, dom.getChannelSliderId(ctx, channel));
105
+ return dom.getById(ctx, dom.getChannelSliderTrackId(ctx, channel));
103
106
  },
104
107
  getChannelSliderValueFromPoint(ctx, point, channel) {
105
108
  const trackEl = dom.getChannelSliderTrackEl(ctx, channel);
@@ -279,6 +282,9 @@ function connect(state, send, normalize) {
279
282
  getChannelValue(channel) {
280
283
  return getChannelValue(value, channel);
281
284
  },
285
+ getChannelValueText(channel, locale) {
286
+ return value.formatChannelValue(channel, locale);
287
+ },
282
288
  setChannelValue(channel, channelValue) {
283
289
  const color = value.withChannelValue(channel, channelValue);
284
290
  send({ type: "VALUE.SET", value: color, src: "set-channel" });
@@ -512,7 +518,7 @@ function connect(state, send, normalize) {
512
518
  });
513
519
  },
514
520
  getChannelSliderProps(props) {
515
- const { orientation = "horizontal", channel } = props;
521
+ const { orientation = "horizontal", channel, format } = props;
516
522
  return normalize.element({
517
523
  ...parts.channelSlider.attrs,
518
524
  "data-channel": channel,
@@ -523,7 +529,7 @@ function connect(state, send, normalize) {
523
529
  if (!(0, import_dom_event2.isLeftClick)(event)) return;
524
530
  if ((0, import_dom_event2.isModifierKey)(event)) return;
525
531
  const point = (0, import_dom_event2.getEventPoint)(event);
526
- send({ type: "CHANNEL_SLIDER.POINTER_DOWN", channel, point, id: channel, orientation });
532
+ send({ type: "CHANNEL_SLIDER.POINTER_DOWN", channel, format, point, id: channel, orientation });
527
533
  event.preventDefault();
528
534
  },
529
535
  style: {
@@ -533,10 +539,11 @@ function connect(state, send, normalize) {
533
539
  });
534
540
  },
535
541
  getChannelSliderTrackProps(props) {
536
- const { orientation = "horizontal", channel } = props;
542
+ const { orientation = "horizontal", channel, format } = props;
543
+ const normalizedValue = format ? value.toFormat(format) : areaValue;
537
544
  return normalize.element({
538
545
  ...parts.channelSliderTrack.attrs,
539
- id: dom.getChannelSliderId(state.context, channel),
546
+ id: dom.getChannelSliderTrackId(state.context, channel),
540
547
  role: "group",
541
548
  "data-channel": channel,
542
549
  "data-orientation": orientation,
@@ -547,16 +554,40 @@ function connect(state, send, normalize) {
547
554
  orientation,
548
555
  channel,
549
556
  dir: state.context.dir,
550
- value: areaValue
557
+ value: normalizedValue
551
558
  })
552
559
  }
553
560
  });
554
561
  },
562
+ getChannelSliderLabelProps(props) {
563
+ const { channel } = props;
564
+ return normalize.element({
565
+ ...parts.channelSliderLabel.attrs,
566
+ "data-channel": channel,
567
+ onClick(event) {
568
+ if (!interactive) return;
569
+ event.preventDefault();
570
+ const thumbId = dom.getChannelSliderThumbId(state.context, channel);
571
+ dom.getById(state.context, thumbId)?.focus({ preventScroll: true });
572
+ },
573
+ style: {
574
+ userSelect: "none",
575
+ WebkitUserSelect: "none"
576
+ }
577
+ });
578
+ },
579
+ getChannelSliderValueTextProps(props) {
580
+ return normalize.element({
581
+ ...parts.channelSliderValueText.attrs,
582
+ "data-channel": props.channel
583
+ });
584
+ },
555
585
  getChannelSliderThumbProps(props) {
556
- const { orientation = "horizontal", channel } = props;
557
- const { minValue, maxValue, step: stepValue } = areaValue.getChannelRange(channel);
558
- const channelValue = areaValue.getChannelValue(channel);
559
- const offset = (channelValue - minValue) / (maxValue - minValue);
586
+ const { orientation = "horizontal", channel, format } = props;
587
+ const normalizedValue = format ? value.toFormat(format) : areaValue;
588
+ const channelRange = normalizedValue.getChannelRange(channel);
589
+ const channelValue = normalizedValue.getChannelValue(channel);
590
+ const offset = (channelValue - channelRange.minValue) / (channelRange.maxValue - channelRange.minValue);
560
591
  const placementStyles = orientation === "horizontal" ? { left: `${offset * 100}%`, top: "50%" } : { top: `${offset * 100}%`, left: "50%" };
561
592
  return normalize.element({
562
593
  ...parts.channelSliderThumb.attrs,
@@ -569,8 +600,8 @@ function connect(state, send, normalize) {
569
600
  "data-orientation": orientation,
570
601
  "aria-disabled": (0, import_dom_query2.dataAttr)(disabled),
571
602
  "aria-orientation": orientation,
572
- "aria-valuemax": maxValue,
573
- "aria-valuemin": minValue,
603
+ "aria-valuemax": channelRange.maxValue,
604
+ "aria-valuemin": channelRange.minValue,
574
605
  "aria-valuenow": channelValue,
575
606
  "aria-valuetext": `${channel} ${channelValue}`,
576
607
  style: {
@@ -586,7 +617,7 @@ function connect(state, send, normalize) {
586
617
  onKeyDown(event) {
587
618
  if (event.defaultPrevented) return;
588
619
  if (!interactive) return;
589
- const step = (0, import_dom_event2.getEventStep)(event) * stepValue;
620
+ const step = (0, import_dom_event2.getEventStep)(event) * channelRange.step;
590
621
  const keyMap = {
591
622
  ArrowUp() {
592
623
  send({ type: "CHANNEL_SLIDER.ARROW_UP", channel, step });
@@ -627,7 +658,7 @@ function connect(state, send, normalize) {
627
658
  getChannelInputProps(props) {
628
659
  const { channel } = props;
629
660
  const isTextField = channel === "hex" || channel === "css";
630
- const range = getChannelRange(value, channel);
661
+ const channelRange = getChannelRange(value, channel);
631
662
  return normalize.input({
632
663
  ...parts.channelInput.attrs,
633
664
  dir: state.context.dir,
@@ -640,9 +671,9 @@ function connect(state, send, normalize) {
640
671
  "data-disabled": (0, import_dom_query2.dataAttr)(disabled),
641
672
  readOnly: state.context.readOnly,
642
673
  defaultValue: getChannelValue(value, channel),
643
- min: range?.minValue,
644
- max: range?.maxValue,
645
- step: range?.step,
674
+ min: channelRange?.minValue,
675
+ max: channelRange?.maxValue,
676
+ step: channelRange?.step,
646
677
  onBeforeInput(event) {
647
678
  if (isTextField || !interactive) return;
648
679
  const value2 = event.currentTarget.value;
@@ -681,6 +712,8 @@ function connect(state, send, normalize) {
681
712
  type: "text",
682
713
  disabled,
683
714
  name: state.context.name,
715
+ readOnly: state.context.readOnly,
716
+ required: state.context.required,
684
717
  id: dom.getHiddenInputId(state.context),
685
718
  style: import_dom_query2.visuallyHiddenStyle,
686
719
  defaultValue: valueAsString
@@ -972,22 +1005,22 @@ function machine(userContext) {
972
1005
  actions: ["setActiveChannel"]
973
1006
  },
974
1007
  "AREA.ARROW_LEFT": {
975
- actions: ["decrementXChannel"]
1008
+ actions: ["decrementAreaXChannel"]
976
1009
  },
977
1010
  "AREA.ARROW_RIGHT": {
978
- actions: ["incrementXChannel"]
1011
+ actions: ["incrementAreaXChannel"]
979
1012
  },
980
1013
  "AREA.ARROW_UP": {
981
- actions: ["incrementYChannel"]
1014
+ actions: ["incrementAreaYChannel"]
982
1015
  },
983
1016
  "AREA.ARROW_DOWN": {
984
- actions: ["decrementYChannel"]
1017
+ actions: ["decrementAreaYChannel"]
985
1018
  },
986
1019
  "AREA.PAGE_UP": {
987
- actions: ["incrementXChannel"]
1020
+ actions: ["incrementAreaXChannel"]
988
1021
  },
989
1022
  "AREA.PAGE_DOWN": {
990
- actions: ["decrementXChannel"]
1023
+ actions: ["decrementAreaXChannel"]
991
1024
  },
992
1025
  "CHANNEL_SLIDER.ARROW_LEFT": {
993
1026
  actions: ["decrementChannel"]
@@ -1162,11 +1195,11 @@ function machine(userContext) {
1162
1195
  }
1163
1196
  });
1164
1197
  },
1165
- trackPointerMove(ctx2, _evt, { send }) {
1198
+ trackPointerMove(ctx2, evt, { send }) {
1166
1199
  return (0, import_dom_event3.trackPointerMove)(dom.getDoc(ctx2), {
1167
1200
  onPointerMove({ point }) {
1168
1201
  const type = ctx2.activeId === "area" ? "AREA.POINTER_MOVE" : "CHANNEL_SLIDER.POINTER_MOVE";
1169
- send({ type, point });
1202
+ send({ type, point, format: evt.format });
1170
1203
  },
1171
1204
  onPointerUp() {
1172
1205
  const type = ctx2.activeId === "area" ? "AREA.POINTER_UP" : "CHANNEL_SLIDER.POINTER_UP";
@@ -1202,22 +1235,24 @@ function machine(userContext) {
1202
1235
  ctx2.activeOrientation = null;
1203
1236
  },
1204
1237
  setAreaColorFromPoint(ctx2, evt) {
1238
+ const normalizedValue = evt.format ? ctx2.value.toFormat(evt.format) : ctx2.areaValue;
1205
1239
  const { xChannel, yChannel } = evt.channel || ctx2.activeChannel;
1206
1240
  const percent = dom.getAreaValueFromPoint(ctx2, evt.point);
1207
1241
  if (!percent) return;
1208
- const xValue = ctx2.areaValue.getChannelPercentValue(xChannel, percent.x);
1209
- const yValue = ctx2.areaValue.getChannelPercentValue(yChannel, 1 - percent.y);
1210
- const color = ctx2.areaValue.withChannelValue(xChannel, xValue).withChannelValue(yChannel, yValue);
1242
+ const xValue = normalizedValue.getChannelPercentValue(xChannel, percent.x);
1243
+ const yValue = normalizedValue.getChannelPercentValue(yChannel, 1 - percent.y);
1244
+ const color = normalizedValue.withChannelValue(xChannel, xValue).withChannelValue(yChannel, yValue);
1211
1245
  set.value(ctx2, color);
1212
1246
  },
1213
1247
  setChannelColorFromPoint(ctx2, evt) {
1214
1248
  const channel = evt.channel || ctx2.activeId;
1249
+ const normalizedValue = evt.format ? ctx2.value.toFormat(evt.format) : ctx2.areaValue;
1215
1250
  const percent = dom.getChannelSliderValueFromPoint(ctx2, evt.point, channel);
1216
1251
  if (!percent) return;
1217
1252
  const orientation = ctx2.activeOrientation || "horizontal";
1218
1253
  const channelPercent = orientation === "horizontal" ? percent.x : percent.y;
1219
- const value = ctx2.areaValue.getChannelPercentValue(channel, channelPercent);
1220
- const color = ctx2.areaValue.withChannelValue(channel, value);
1254
+ const value = normalizedValue.getChannelPercentValue(channel, channelPercent);
1255
+ const color = normalizedValue.withChannelValue(channel, value);
1221
1256
  set.value(ctx2, color);
1222
1257
  },
1223
1258
  setValue(ctx2, evt) {
@@ -1261,22 +1296,22 @@ function machine(userContext) {
1261
1296
  const color = ctx2.value.decrementChannel(evt.channel, evt.step);
1262
1297
  set.value(ctx2, color);
1263
1298
  },
1264
- incrementXChannel(ctx2, evt) {
1299
+ incrementAreaXChannel(ctx2, evt) {
1265
1300
  const { xChannel } = evt.channel;
1266
1301
  const color = ctx2.areaValue.incrementChannel(xChannel, evt.step);
1267
1302
  set.value(ctx2, color);
1268
1303
  },
1269
- decrementXChannel(ctx2, evt) {
1304
+ decrementAreaXChannel(ctx2, evt) {
1270
1305
  const { xChannel } = evt.channel;
1271
1306
  const color = ctx2.areaValue.decrementChannel(xChannel, evt.step);
1272
1307
  set.value(ctx2, color);
1273
1308
  },
1274
- incrementYChannel(ctx2, evt) {
1309
+ incrementAreaYChannel(ctx2, evt) {
1275
1310
  const { yChannel } = evt.channel;
1276
1311
  const color = ctx2.areaValue.incrementChannel(yChannel, evt.step);
1277
1312
  set.value(ctx2, color);
1278
1313
  },
1279
- decrementYChannel(ctx2, evt) {
1314
+ decrementAreaYChannel(ctx2, evt) {
1280
1315
  const { yChannel } = evt.channel;
1281
1316
  const color = ctx2.areaValue.decrementChannel(yChannel, evt.step);
1282
1317
  set.value(ctx2, color);