@zag-js/color-picker 0.10.4 → 0.11.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 +150 -0
- package/dist/index.d.ts +150 -4
- package/dist/index.js +1086 -8
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1069 -3
- package/dist/index.mjs.map +1 -0
- package/package.json +11 -11
- package/dist/color-picker.anatomy.d.ts +0 -3
- package/dist/color-picker.anatomy.js +0 -24
- package/dist/color-picker.anatomy.mjs +0 -19
- package/dist/color-picker.connect.d.ts +0 -44
- package/dist/color-picker.connect.js +0 -372
- package/dist/color-picker.connect.mjs +0 -368
- package/dist/color-picker.dom.d.ts +0 -46
- package/dist/color-picker.dom.js +0 -37
- package/dist/color-picker.dom.mjs +0 -33
- package/dist/color-picker.machine.d.ts +0 -3
- package/dist/color-picker.machine.js +0 -340
- package/dist/color-picker.machine.mjs +0 -336
- package/dist/color-picker.types.d.ts +0 -99
- package/dist/utils/generate-format-background.d.ts +0 -66
- package/dist/utils/generate-format-background.js +0 -133
- package/dist/utils/generate-format-background.mjs +0 -121
- package/dist/utils/get-channel-details.d.ts +0 -19
- package/dist/utils/get-channel-details.js +0 -57
- package/dist/utils/get-channel-details.mjs +0 -53
- package/dist/utils/get-channel-display-color.d.ts +0 -3
- package/dist/utils/get-channel-display-color.js +0 -26
- package/dist/utils/get-channel-display-color.mjs +0 -22
- package/dist/utils/get-channel-input-value.d.ts +0 -5
- package/dist/utils/get-channel-input-value.js +0 -26
- package/dist/utils/get-channel-input-value.mjs +0 -21
- package/dist/utils/get-color-area-gradient.d.ts +0 -7
- package/dist/utils/get-color-area-gradient.js +0 -65
- package/dist/utils/get-color-area-gradient.mjs +0 -61
- package/dist/utils/get-slider-background.d.ts +0 -2
- package/dist/utils/get-slider-background.js +0 -43
- package/dist/utils/get-slider-background.mjs +0 -39
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
+
import { ColorChannel, Color, ColorAxes, ColorFormat } from '@zag-js/color-utils';
|
|
3
|
+
export { Color, ColorChannel } from '@zag-js/color-utils';
|
|
4
|
+
import { Orientation, RequiredBy, CommonProperties, Context, PropTypes, NormalizeProps } from '@zag-js/types';
|
|
5
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
6
|
+
import { StateMachine } from '@zag-js/core';
|
|
7
|
+
|
|
8
|
+
declare const anatomy: _zag_js_anatomy.Anatomy<"area" | "areaThumb" | "areaGradient" | "channelSliderTrack" | "channelSliderTrackBg" | "channelSliderThumb" | "channelInput" | "swatch" | "swatchBg" | "content" | "label" | "eyeDropTrigger">;
|
|
9
|
+
|
|
10
|
+
type ColorChannelProps = {
|
|
11
|
+
channel: ColorChannel;
|
|
12
|
+
orientation?: Orientation;
|
|
13
|
+
};
|
|
14
|
+
type ExtendedColorChannel = ColorChannel | "hex" | "css";
|
|
15
|
+
type ColorChannelInputProps = {
|
|
16
|
+
channel: ExtendedColorChannel;
|
|
17
|
+
orientation?: Orientation;
|
|
18
|
+
};
|
|
19
|
+
type ColorAreaProps = {
|
|
20
|
+
xChannel: ColorChannel;
|
|
21
|
+
yChannel: ColorChannel;
|
|
22
|
+
};
|
|
23
|
+
type ColorSwatchProps = {
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
value: string | Color;
|
|
26
|
+
};
|
|
27
|
+
type ChangeDetails = {
|
|
28
|
+
value: string;
|
|
29
|
+
valueAsColor: Color;
|
|
30
|
+
};
|
|
31
|
+
type ElementIds = Partial<{
|
|
32
|
+
content: string;
|
|
33
|
+
area: string;
|
|
34
|
+
areaGradient: string;
|
|
35
|
+
areaThumb: string;
|
|
36
|
+
channelInput(id: string): string;
|
|
37
|
+
channelSliderTrack(id: ColorChannel): string;
|
|
38
|
+
channelSliderThumb(id: ColorChannel): string;
|
|
39
|
+
}>;
|
|
40
|
+
type PublicContext = CommonProperties & {
|
|
41
|
+
/**
|
|
42
|
+
* The ids of the elements in the color picker. Useful for composition.
|
|
43
|
+
*/
|
|
44
|
+
ids?: ElementIds;
|
|
45
|
+
/**
|
|
46
|
+
* The direction of the color picker
|
|
47
|
+
*/
|
|
48
|
+
dir: "ltr" | "rtl";
|
|
49
|
+
/**
|
|
50
|
+
* The current color value
|
|
51
|
+
*/
|
|
52
|
+
value: string;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the color picker is disabled
|
|
55
|
+
*/
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the color picker is read-only
|
|
59
|
+
*/
|
|
60
|
+
readOnly?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Handler that is called when the value changes, as the user drags.
|
|
63
|
+
*/
|
|
64
|
+
onChange?: (details: ChangeDetails) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Handler that is called when the user stops dragging.
|
|
67
|
+
*/
|
|
68
|
+
onChangeEnd?: (details: ChangeDetails) => void;
|
|
69
|
+
};
|
|
70
|
+
type PrivateContext = Context<{
|
|
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>): {
|
|
107
|
+
/**
|
|
108
|
+
* Whether the color picker is being dragged
|
|
109
|
+
*/
|
|
110
|
+
isDragging: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* The current color value (as a string)
|
|
113
|
+
*/
|
|
114
|
+
value: string;
|
|
115
|
+
/**
|
|
116
|
+
* The current color value (as a Color object)
|
|
117
|
+
*/
|
|
118
|
+
valueAsColor: Color;
|
|
119
|
+
/**
|
|
120
|
+
* The current color channels of the color
|
|
121
|
+
*/
|
|
122
|
+
channels: [ColorChannel, ColorChannel, ColorChannel];
|
|
123
|
+
/**
|
|
124
|
+
* Function to set the color value
|
|
125
|
+
*/
|
|
126
|
+
setColor(value: string | Color): void;
|
|
127
|
+
/**
|
|
128
|
+
* Function to set the color value of a specific channel
|
|
129
|
+
*/
|
|
130
|
+
setChannelValue(channel: ColorChannel, value: number): void;
|
|
131
|
+
/**
|
|
132
|
+
* Function to set the color format
|
|
133
|
+
*/
|
|
134
|
+
setFormat(format: ColorFormat): void;
|
|
135
|
+
contentProps: T["element"];
|
|
136
|
+
getAreaProps(props: ColorAreaProps): T["element"];
|
|
137
|
+
getAreaGradientProps(props: ColorAreaProps): T["element"];
|
|
138
|
+
getAreaThumbProps(props: ColorAreaProps): T["element"];
|
|
139
|
+
getChannelSliderTrackProps(props: ColorChannelProps): T["element"];
|
|
140
|
+
getChannelSliderBackgroundProps(props: ColorChannelProps): T["element"];
|
|
141
|
+
getChannelSliderThumbProps(props: ColorChannelProps): T["element"];
|
|
142
|
+
getChannelInputProps(props: ColorChannelInputProps): T["input"];
|
|
143
|
+
eyeDropperTriggerProps: T["button"];
|
|
144
|
+
getSwatchBackgroundProps(props: ColorSwatchProps): T["element"];
|
|
145
|
+
getSwatchProps(props: ColorSwatchProps): T["element"];
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
149
|
+
|
|
150
|
+
export { ColorAreaProps, ColorChannelProps, ColorSwatchProps, UserDefinedContext as Context, anatomy, connect, machine };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,150 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
|
|
1
|
+
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
+
import { ColorChannel, Color, ColorAxes, ColorFormat } from '@zag-js/color-utils';
|
|
3
|
+
export { Color, ColorChannel } from '@zag-js/color-utils';
|
|
4
|
+
import { Orientation, RequiredBy, CommonProperties, Context, PropTypes, NormalizeProps } from '@zag-js/types';
|
|
5
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
6
|
+
import { StateMachine } from '@zag-js/core';
|
|
7
|
+
|
|
8
|
+
declare const anatomy: _zag_js_anatomy.Anatomy<"area" | "areaThumb" | "areaGradient" | "channelSliderTrack" | "channelSliderTrackBg" | "channelSliderThumb" | "channelInput" | "swatch" | "swatchBg" | "content" | "label" | "eyeDropTrigger">;
|
|
9
|
+
|
|
10
|
+
type ColorChannelProps = {
|
|
11
|
+
channel: ColorChannel;
|
|
12
|
+
orientation?: Orientation;
|
|
13
|
+
};
|
|
14
|
+
type ExtendedColorChannel = ColorChannel | "hex" | "css";
|
|
15
|
+
type ColorChannelInputProps = {
|
|
16
|
+
channel: ExtendedColorChannel;
|
|
17
|
+
orientation?: Orientation;
|
|
18
|
+
};
|
|
19
|
+
type ColorAreaProps = {
|
|
20
|
+
xChannel: ColorChannel;
|
|
21
|
+
yChannel: ColorChannel;
|
|
22
|
+
};
|
|
23
|
+
type ColorSwatchProps = {
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
value: string | Color;
|
|
26
|
+
};
|
|
27
|
+
type ChangeDetails = {
|
|
28
|
+
value: string;
|
|
29
|
+
valueAsColor: Color;
|
|
30
|
+
};
|
|
31
|
+
type ElementIds = Partial<{
|
|
32
|
+
content: string;
|
|
33
|
+
area: string;
|
|
34
|
+
areaGradient: string;
|
|
35
|
+
areaThumb: string;
|
|
36
|
+
channelInput(id: string): string;
|
|
37
|
+
channelSliderTrack(id: ColorChannel): string;
|
|
38
|
+
channelSliderThumb(id: ColorChannel): string;
|
|
39
|
+
}>;
|
|
40
|
+
type PublicContext = CommonProperties & {
|
|
41
|
+
/**
|
|
42
|
+
* The ids of the elements in the color picker. Useful for composition.
|
|
43
|
+
*/
|
|
44
|
+
ids?: ElementIds;
|
|
45
|
+
/**
|
|
46
|
+
* The direction of the color picker
|
|
47
|
+
*/
|
|
48
|
+
dir: "ltr" | "rtl";
|
|
49
|
+
/**
|
|
50
|
+
* The current color value
|
|
51
|
+
*/
|
|
52
|
+
value: string;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the color picker is disabled
|
|
55
|
+
*/
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the color picker is read-only
|
|
59
|
+
*/
|
|
60
|
+
readOnly?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Handler that is called when the value changes, as the user drags.
|
|
63
|
+
*/
|
|
64
|
+
onChange?: (details: ChangeDetails) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Handler that is called when the user stops dragging.
|
|
67
|
+
*/
|
|
68
|
+
onChangeEnd?: (details: ChangeDetails) => void;
|
|
69
|
+
};
|
|
70
|
+
type PrivateContext = Context<{
|
|
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>): {
|
|
107
|
+
/**
|
|
108
|
+
* Whether the color picker is being dragged
|
|
109
|
+
*/
|
|
110
|
+
isDragging: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* The current color value (as a string)
|
|
113
|
+
*/
|
|
114
|
+
value: string;
|
|
115
|
+
/**
|
|
116
|
+
* The current color value (as a Color object)
|
|
117
|
+
*/
|
|
118
|
+
valueAsColor: Color;
|
|
119
|
+
/**
|
|
120
|
+
* The current color channels of the color
|
|
121
|
+
*/
|
|
122
|
+
channels: [ColorChannel, ColorChannel, ColorChannel];
|
|
123
|
+
/**
|
|
124
|
+
* Function to set the color value
|
|
125
|
+
*/
|
|
126
|
+
setColor(value: string | Color): void;
|
|
127
|
+
/**
|
|
128
|
+
* Function to set the color value of a specific channel
|
|
129
|
+
*/
|
|
130
|
+
setChannelValue(channel: ColorChannel, value: number): void;
|
|
131
|
+
/**
|
|
132
|
+
* Function to set the color format
|
|
133
|
+
*/
|
|
134
|
+
setFormat(format: ColorFormat): void;
|
|
135
|
+
contentProps: T["element"];
|
|
136
|
+
getAreaProps(props: ColorAreaProps): T["element"];
|
|
137
|
+
getAreaGradientProps(props: ColorAreaProps): T["element"];
|
|
138
|
+
getAreaThumbProps(props: ColorAreaProps): T["element"];
|
|
139
|
+
getChannelSliderTrackProps(props: ColorChannelProps): T["element"];
|
|
140
|
+
getChannelSliderBackgroundProps(props: ColorChannelProps): T["element"];
|
|
141
|
+
getChannelSliderThumbProps(props: ColorChannelProps): T["element"];
|
|
142
|
+
getChannelInputProps(props: ColorChannelInputProps): T["input"];
|
|
143
|
+
eyeDropperTriggerProps: T["button"];
|
|
144
|
+
getSwatchBackgroundProps(props: ColorSwatchProps): T["element"];
|
|
145
|
+
getSwatchProps(props: ColorSwatchProps): T["element"];
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
149
|
+
|
|
150
|
+
export { ColorAreaProps, ColorChannelProps, ColorSwatchProps, UserDefinedContext as Context, anatomy, connect, machine };
|