@zag-js/color-picker 1.0.0 → 1.0.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 +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +8 -6
- package/dist/index.mjs +9 -7
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { CommonProperties, DirectionProperty, Orientation, PropTypes, RequiredBy
|
|
|
5
5
|
import { Color, ColorFormat, ColorChannel, ColorAxes } 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 { Service, EventObject } from '@zag-js/core';
|
|
8
|
+
import { Service, Machine, EventObject } from '@zag-js/core';
|
|
9
9
|
import { PositioningOptions } from '@zag-js/popper';
|
|
10
10
|
export { PositioningOptions } from '@zag-js/popper';
|
|
11
11
|
|
|
@@ -170,6 +170,7 @@ type ColorPickerSchema = {
|
|
|
170
170
|
guard: string;
|
|
171
171
|
};
|
|
172
172
|
type ColorPickerService = Service<ColorPickerSchema>;
|
|
173
|
+
type ColorPickerMachine = Machine<ColorPickerSchema>;
|
|
173
174
|
interface ChannelProps {
|
|
174
175
|
channel: ColorChannel;
|
|
175
176
|
orientation?: Orientation | undefined;
|
|
@@ -297,7 +298,7 @@ interface ColorPickerApi<T extends PropTypes = PropTypes> {
|
|
|
297
298
|
|
|
298
299
|
declare function connect<T extends PropTypes>(service: ColorPickerService, normalize: NormalizeProps<T>): ColorPickerApi<T>;
|
|
299
300
|
|
|
300
|
-
declare const machine: _zag_js_core.
|
|
301
|
+
declare const machine: _zag_js_core.Machine<ColorPickerSchema>;
|
|
301
302
|
|
|
302
303
|
declare const parse: (colorString: string) => Color;
|
|
303
304
|
|
|
@@ -314,4 +315,4 @@ declare const splitSwatchProps: <Props extends SwatchProps>(props: Props) => [Sw
|
|
|
314
315
|
declare const transparencyGridProps: "size"[];
|
|
315
316
|
declare const splitTransparencyGridProps: <Props extends TransparencyGridProps>(props: Props) => [TransparencyGridProps, Omit<Props, "size">];
|
|
316
317
|
|
|
317
|
-
export { type ColorPickerApi as Api, type AreaProps, type ChannelInputProps, type ChannelProps, type ChannelSliderProps, type ElementIds, type FormatChangeDetails, type OpenChangeDetails, type ColorPickerProps as Props, type ColorPickerService as Service, type SwatchProps, type SwatchTriggerProps, type SwatchTriggerState, type TransparencyGridProps, type ValueChangeDetails, anatomy, areaProps, channelProps, connect, machine, parse, props, splitAreaProps, splitChannelProps, splitProps, splitSwatchProps, splitSwatchTriggerProps, splitTransparencyGridProps, swatchProps, swatchTriggerProps, transparencyGridProps };
|
|
318
|
+
export { type ColorPickerApi as Api, type AreaProps, type ChannelInputProps, type ChannelProps, type ChannelSliderProps, type ElementIds, type FormatChangeDetails, type ColorPickerMachine as Machine, type OpenChangeDetails, type ColorPickerProps as Props, type ColorPickerService as Service, type SwatchProps, type SwatchTriggerProps, type SwatchTriggerState, type TransparencyGridProps, type ValueChangeDetails, anatomy, areaProps, channelProps, connect, machine, parse, props, splitAreaProps, splitChannelProps, splitProps, splitSwatchProps, splitSwatchTriggerProps, splitTransparencyGridProps, swatchProps, swatchTriggerProps, transparencyGridProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { CommonProperties, DirectionProperty, Orientation, PropTypes, RequiredBy
|
|
|
5
5
|
import { Color, ColorFormat, ColorChannel, ColorAxes } 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 { Service, EventObject } from '@zag-js/core';
|
|
8
|
+
import { Service, Machine, EventObject } from '@zag-js/core';
|
|
9
9
|
import { PositioningOptions } from '@zag-js/popper';
|
|
10
10
|
export { PositioningOptions } from '@zag-js/popper';
|
|
11
11
|
|
|
@@ -170,6 +170,7 @@ type ColorPickerSchema = {
|
|
|
170
170
|
guard: string;
|
|
171
171
|
};
|
|
172
172
|
type ColorPickerService = Service<ColorPickerSchema>;
|
|
173
|
+
type ColorPickerMachine = Machine<ColorPickerSchema>;
|
|
173
174
|
interface ChannelProps {
|
|
174
175
|
channel: ColorChannel;
|
|
175
176
|
orientation?: Orientation | undefined;
|
|
@@ -297,7 +298,7 @@ interface ColorPickerApi<T extends PropTypes = PropTypes> {
|
|
|
297
298
|
|
|
298
299
|
declare function connect<T extends PropTypes>(service: ColorPickerService, normalize: NormalizeProps<T>): ColorPickerApi<T>;
|
|
299
300
|
|
|
300
|
-
declare const machine: _zag_js_core.
|
|
301
|
+
declare const machine: _zag_js_core.Machine<ColorPickerSchema>;
|
|
301
302
|
|
|
302
303
|
declare const parse: (colorString: string) => Color;
|
|
303
304
|
|
|
@@ -314,4 +315,4 @@ declare const splitSwatchProps: <Props extends SwatchProps>(props: Props) => [Sw
|
|
|
314
315
|
declare const transparencyGridProps: "size"[];
|
|
315
316
|
declare const splitTransparencyGridProps: <Props extends TransparencyGridProps>(props: Props) => [TransparencyGridProps, Omit<Props, "size">];
|
|
316
317
|
|
|
317
|
-
export { type ColorPickerApi as Api, type AreaProps, type ChannelInputProps, type ChannelProps, type ChannelSliderProps, type ElementIds, type FormatChangeDetails, type OpenChangeDetails, type ColorPickerProps as Props, type ColorPickerService as Service, type SwatchProps, type SwatchTriggerProps, type SwatchTriggerState, type TransparencyGridProps, type ValueChangeDetails, anatomy, areaProps, channelProps, connect, machine, parse, props, splitAreaProps, splitChannelProps, splitProps, splitSwatchProps, splitSwatchTriggerProps, splitTransparencyGridProps, swatchProps, swatchTriggerProps, transparencyGridProps };
|
|
318
|
+
export { type ColorPickerApi as Api, type AreaProps, type ChannelInputProps, type ChannelProps, type ChannelSliderProps, type ElementIds, type FormatChangeDetails, type ColorPickerMachine as Machine, type OpenChangeDetails, type ColorPickerProps as Props, type ColorPickerService as Service, type SwatchProps, type SwatchTriggerProps, type SwatchTriggerState, type TransparencyGridProps, type ValueChangeDetails, anatomy, areaProps, channelProps, connect, machine, parse, props, splitAreaProps, splitChannelProps, splitProps, splitSwatchProps, splitSwatchTriggerProps, splitTransparencyGridProps, swatchProps, swatchTriggerProps, transparencyGridProps };
|
package/dist/index.js
CHANGED
|
@@ -835,7 +835,7 @@ var machine = core.createMachine({
|
|
|
835
835
|
const open = prop("open") || prop("defaultOpen");
|
|
836
836
|
return open ? "open" : "idle";
|
|
837
837
|
},
|
|
838
|
-
context({ prop, bindable, getContext
|
|
838
|
+
context({ prop, bindable, getContext }) {
|
|
839
839
|
return {
|
|
840
840
|
value: bindable(() => ({
|
|
841
841
|
defaultValue: prop("defaultValue"),
|
|
@@ -850,7 +850,6 @@ var machine = core.createMachine({
|
|
|
850
850
|
const ctx = getContext();
|
|
851
851
|
const valueAsString = value.toString(ctx.get("format"));
|
|
852
852
|
prop("onValueChange")?.({ value, valueAsString });
|
|
853
|
-
domQuery.dispatchInputValueEvent(getHiddenInputEl(scope), { value: valueAsString });
|
|
854
853
|
}
|
|
855
854
|
})),
|
|
856
855
|
format: bindable(() => ({
|
|
@@ -883,7 +882,7 @@ var machine = core.createMachine({
|
|
|
883
882
|
effects: ["trackFormControl"],
|
|
884
883
|
watch({ prop, context, action, track }) {
|
|
885
884
|
track([() => context.hash("value")], () => {
|
|
886
|
-
action(["syncInputElements"]);
|
|
885
|
+
action(["syncInputElements", "dispatchChangeEvent"]);
|
|
887
886
|
});
|
|
888
887
|
track([() => context.get("format")], () => {
|
|
889
888
|
action(["syncFormatSelectElement"]);
|
|
@@ -1280,8 +1279,11 @@ var machine = core.createMachine({
|
|
|
1280
1279
|
setFormat({ context, event }) {
|
|
1281
1280
|
context.set("format", event.format);
|
|
1282
1281
|
},
|
|
1282
|
+
dispatchChangeEvent({ scope, computed }) {
|
|
1283
|
+
domQuery.dispatchInputValueEvent(getHiddenInputEl(scope), { value: computed("valueAsString") });
|
|
1284
|
+
},
|
|
1283
1285
|
syncInputElements({ context, scope }) {
|
|
1284
|
-
|
|
1286
|
+
syncChannelInputs(scope, context.get("value"));
|
|
1285
1287
|
},
|
|
1286
1288
|
invokeOnChangeEnd({ context, prop, computed }) {
|
|
1287
1289
|
prop("onValueChangeEnd")?.({
|
|
@@ -1307,7 +1309,7 @@ var machine = core.createMachine({
|
|
|
1307
1309
|
const valueAsNumber = Number.isNaN(value) ? current.getChannelValue(channel) : value;
|
|
1308
1310
|
color = current.withChannelValue(channel, valueAsNumber);
|
|
1309
1311
|
}
|
|
1310
|
-
|
|
1312
|
+
syncChannelInputs(scope, context.get("value"), color);
|
|
1311
1313
|
context.set("value", color);
|
|
1312
1314
|
},
|
|
1313
1315
|
incrementChannel({ context, event }) {
|
|
@@ -1390,7 +1392,7 @@ var machine = core.createMachine({
|
|
|
1390
1392
|
}
|
|
1391
1393
|
}
|
|
1392
1394
|
});
|
|
1393
|
-
function
|
|
1395
|
+
function syncChannelInputs(scope, currentValue, nextValue) {
|
|
1394
1396
|
const channelInputEls = getChannelInputEls(scope);
|
|
1395
1397
|
domQuery.raf(() => {
|
|
1396
1398
|
channelInputEls.forEach((inputEl) => {
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createAnatomy } from '@zag-js/anatomy';
|
|
2
2
|
import { parseColor, normalizeColor, getColorAreaGradient } from '@zag-js/color-utils';
|
|
3
|
-
import {
|
|
3
|
+
import { trackFormControl, trackPointerMove, disableTextSelection, dispatchInputValueEvent, raf, getInitialFocus, setElementValue, getRelativePoint, queryAll, dataAttr, query, isLeftClick, isModifierKey, getEventPoint, getEventStep, getEventKey, visuallyHiddenStyle } from '@zag-js/dom-query';
|
|
4
4
|
import { getPlacement, getPlacementStyles } from '@zag-js/popper';
|
|
5
5
|
import { createGuards, createMachine } from '@zag-js/core';
|
|
6
6
|
import { trackDismissableElement } from '@zag-js/dismissable';
|
|
@@ -833,7 +833,7 @@ var machine = createMachine({
|
|
|
833
833
|
const open = prop("open") || prop("defaultOpen");
|
|
834
834
|
return open ? "open" : "idle";
|
|
835
835
|
},
|
|
836
|
-
context({ prop, bindable, getContext
|
|
836
|
+
context({ prop, bindable, getContext }) {
|
|
837
837
|
return {
|
|
838
838
|
value: bindable(() => ({
|
|
839
839
|
defaultValue: prop("defaultValue"),
|
|
@@ -848,7 +848,6 @@ var machine = createMachine({
|
|
|
848
848
|
const ctx = getContext();
|
|
849
849
|
const valueAsString = value.toString(ctx.get("format"));
|
|
850
850
|
prop("onValueChange")?.({ value, valueAsString });
|
|
851
|
-
dispatchInputValueEvent(getHiddenInputEl(scope), { value: valueAsString });
|
|
852
851
|
}
|
|
853
852
|
})),
|
|
854
853
|
format: bindable(() => ({
|
|
@@ -881,7 +880,7 @@ var machine = createMachine({
|
|
|
881
880
|
effects: ["trackFormControl"],
|
|
882
881
|
watch({ prop, context, action, track }) {
|
|
883
882
|
track([() => context.hash("value")], () => {
|
|
884
|
-
action(["syncInputElements"]);
|
|
883
|
+
action(["syncInputElements", "dispatchChangeEvent"]);
|
|
885
884
|
});
|
|
886
885
|
track([() => context.get("format")], () => {
|
|
887
886
|
action(["syncFormatSelectElement"]);
|
|
@@ -1278,8 +1277,11 @@ var machine = createMachine({
|
|
|
1278
1277
|
setFormat({ context, event }) {
|
|
1279
1278
|
context.set("format", event.format);
|
|
1280
1279
|
},
|
|
1280
|
+
dispatchChangeEvent({ scope, computed }) {
|
|
1281
|
+
dispatchInputValueEvent(getHiddenInputEl(scope), { value: computed("valueAsString") });
|
|
1282
|
+
},
|
|
1281
1283
|
syncInputElements({ context, scope }) {
|
|
1282
|
-
|
|
1284
|
+
syncChannelInputs(scope, context.get("value"));
|
|
1283
1285
|
},
|
|
1284
1286
|
invokeOnChangeEnd({ context, prop, computed }) {
|
|
1285
1287
|
prop("onValueChangeEnd")?.({
|
|
@@ -1305,7 +1307,7 @@ var machine = createMachine({
|
|
|
1305
1307
|
const valueAsNumber = Number.isNaN(value) ? current.getChannelValue(channel) : value;
|
|
1306
1308
|
color = current.withChannelValue(channel, valueAsNumber);
|
|
1307
1309
|
}
|
|
1308
|
-
|
|
1310
|
+
syncChannelInputs(scope, context.get("value"), color);
|
|
1309
1311
|
context.set("value", color);
|
|
1310
1312
|
},
|
|
1311
1313
|
incrementChannel({ context, event }) {
|
|
@@ -1388,7 +1390,7 @@ var machine = createMachine({
|
|
|
1388
1390
|
}
|
|
1389
1391
|
}
|
|
1390
1392
|
});
|
|
1391
|
-
function
|
|
1393
|
+
function syncChannelInputs(scope, currentValue, nextValue) {
|
|
1392
1394
|
const channelInputEls = getChannelInputEls(scope);
|
|
1393
1395
|
raf(() => {
|
|
1394
1396
|
channelInputEls.forEach((inputEl) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/color-picker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Core logic for the color-picker widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@zag-js/core": "1.0.
|
|
31
|
-
"@zag-js/anatomy": "1.0.
|
|
32
|
-
"@zag-js/dom-query": "1.0.
|
|
33
|
-
"@zag-js/dismissable": "1.0.
|
|
34
|
-
"@zag-js/utils": "1.0.
|
|
35
|
-
"@zag-js/color-utils": "1.0.
|
|
36
|
-
"@zag-js/popper": "1.0.
|
|
37
|
-
"@zag-js/types": "1.0.
|
|
30
|
+
"@zag-js/core": "1.0.2",
|
|
31
|
+
"@zag-js/anatomy": "1.0.2",
|
|
32
|
+
"@zag-js/dom-query": "1.0.2",
|
|
33
|
+
"@zag-js/dismissable": "1.0.2",
|
|
34
|
+
"@zag-js/utils": "1.0.2",
|
|
35
|
+
"@zag-js/color-utils": "1.0.2",
|
|
36
|
+
"@zag-js/popper": "1.0.2",
|
|
37
|
+
"@zag-js/types": "1.0.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"clean-package": "2.2.0"
|