@destyler/color-picker 0.0.7-beta.7 → 0.0.7-beta.9
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.ts +293 -292
- package/dist/index.js +1449 -0
- package/package.json +14 -21
- package/dist/index.cjs +0 -1453
- package/dist/index.d.cts +0 -334
- package/dist/index.d.mts +0 -334
- package/dist/index.mjs +0 -1448
package/dist/index.d.cts
DELETED
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import { CommonProperties, DirectionProperty, Orientation, PropTypes, RequiredBy, 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
|
-
import * as _zag_js_core from '@zag-js/core';
|
|
6
|
-
import { StateMachine, Machine } from '@zag-js/core';
|
|
7
|
-
import { InteractOutsideHandlers } from '@zag-js/dismissable';
|
|
8
|
-
export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/dismissable';
|
|
9
|
-
import { PositioningOptions } from '@zag-js/popper';
|
|
10
|
-
export { PositioningOptions } from '@zag-js/popper';
|
|
11
|
-
|
|
12
|
-
declare const anatomy: _zag_js_anatomy.Anatomy<"root" | "label" | "control" | "trigger" | "positioner" | "content" | "area" | "areaThumb" | "valueText" | "areaBackground" | "channelSlider" | "channelSliderLabel" | "channelSliderTrack" | "channelSliderThumb" | "channelSliderValueText" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
|
|
13
|
-
|
|
14
|
-
type ExtendedColorChannel = ColorChannel | 'hex' | 'css';
|
|
15
|
-
interface EyeDropper {
|
|
16
|
-
new (): EyeDropper;
|
|
17
|
-
open: (options?: {
|
|
18
|
-
signal?: AbortSignal;
|
|
19
|
-
}) => Promise<{
|
|
20
|
-
sRGBHex: string;
|
|
21
|
-
}>;
|
|
22
|
-
[Symbol.toStringTag]: 'EyeDropper';
|
|
23
|
-
}
|
|
24
|
-
declare global {
|
|
25
|
-
interface Window {
|
|
26
|
-
EyeDropper: EyeDropper;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
interface ValueChangeDetails {
|
|
30
|
-
value: Color;
|
|
31
|
-
valueAsString: string;
|
|
32
|
-
}
|
|
33
|
-
interface OpenChangeDetails {
|
|
34
|
-
open: boolean;
|
|
35
|
-
}
|
|
36
|
-
interface FormatChangeDetails {
|
|
37
|
-
format: ColorFormat;
|
|
38
|
-
}
|
|
39
|
-
type ElementIds = Partial<{
|
|
40
|
-
root: string;
|
|
41
|
-
control: string;
|
|
42
|
-
trigger: string;
|
|
43
|
-
label: string;
|
|
44
|
-
input: string;
|
|
45
|
-
hiddenInput: string;
|
|
46
|
-
content: string;
|
|
47
|
-
area: string;
|
|
48
|
-
areaGradient: string;
|
|
49
|
-
positioner: string;
|
|
50
|
-
formatSelect: string;
|
|
51
|
-
areaThumb: string;
|
|
52
|
-
channelInput: (id: string) => string;
|
|
53
|
-
channelSliderTrack: (id: ColorChannel) => string;
|
|
54
|
-
channelSliderThumb: (id: ColorChannel) => string;
|
|
55
|
-
}>;
|
|
56
|
-
interface PublicContext extends CommonProperties, DirectionProperty, InteractOutsideHandlers {
|
|
57
|
-
/**
|
|
58
|
-
* The ids of the elements in the color picker. Useful for composition.
|
|
59
|
-
*/
|
|
60
|
-
'ids'?: ElementIds | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* The current color value
|
|
63
|
-
* @default #000000
|
|
64
|
-
*/
|
|
65
|
-
'value': Color;
|
|
66
|
-
/**
|
|
67
|
-
* Whether the color picker is disabled
|
|
68
|
-
*/
|
|
69
|
-
'disabled'?: boolean | undefined;
|
|
70
|
-
/**
|
|
71
|
-
* Whether the color picker is read-only
|
|
72
|
-
*/
|
|
73
|
-
'readOnly'?: boolean | undefined;
|
|
74
|
-
/**
|
|
75
|
-
* Whether the color picker is required
|
|
76
|
-
*/
|
|
77
|
-
'required'?: boolean | undefined;
|
|
78
|
-
/**
|
|
79
|
-
* Whether the color picker is invalid
|
|
80
|
-
*/
|
|
81
|
-
'invalid'?: boolean | undefined;
|
|
82
|
-
/**
|
|
83
|
-
* Handler that is called when the value changes, as the user drags.
|
|
84
|
-
*/
|
|
85
|
-
'onValueChange'?: ((details: ValueChangeDetails) => void) | undefined;
|
|
86
|
-
/**
|
|
87
|
-
* Handler that is called when the user stops dragging.
|
|
88
|
-
*/
|
|
89
|
-
'onValueChangeEnd'?: ((details: ValueChangeDetails) => void) | undefined;
|
|
90
|
-
/**
|
|
91
|
-
* Handler that is called when the user opens or closes the color picker.
|
|
92
|
-
*/
|
|
93
|
-
'onOpenChange'?: ((details: OpenChangeDetails) => void) | undefined;
|
|
94
|
-
/**
|
|
95
|
-
* The name for the form input
|
|
96
|
-
*/
|
|
97
|
-
'name'?: string | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* The positioning options for the color picker
|
|
100
|
-
*/
|
|
101
|
-
'positioning': PositioningOptions;
|
|
102
|
-
/**
|
|
103
|
-
* The initial focus element when the color picker is opened.
|
|
104
|
-
*/
|
|
105
|
-
'initialFocusEl'?: (() => HTMLElement | null) | undefined;
|
|
106
|
-
/**
|
|
107
|
-
* Whether the color picker is open
|
|
108
|
-
*/
|
|
109
|
-
'open'?: boolean | undefined;
|
|
110
|
-
/**
|
|
111
|
-
* Whether the color picker open state is controlled by the user
|
|
112
|
-
*/
|
|
113
|
-
'open.controlled'?: boolean | undefined;
|
|
114
|
-
/**
|
|
115
|
-
* The color format to use
|
|
116
|
-
* @default "rgba"
|
|
117
|
-
*/
|
|
118
|
-
'format': ColorFormat;
|
|
119
|
-
/**
|
|
120
|
-
* Function called when the color format changes
|
|
121
|
-
*/
|
|
122
|
-
'onFormatChange'?: ((details: FormatChangeDetails) => void) | undefined;
|
|
123
|
-
/**
|
|
124
|
-
* Whether to close the color picker when a swatch is selected
|
|
125
|
-
* @default false
|
|
126
|
-
*/
|
|
127
|
-
'closeOnSelect'?: boolean | undefined;
|
|
128
|
-
/**
|
|
129
|
-
* Whether to auto focus the color picker when it is opened
|
|
130
|
-
* @default true
|
|
131
|
-
*/
|
|
132
|
-
'openAutoFocus'?: boolean | undefined;
|
|
133
|
-
}
|
|
134
|
-
interface PrivateContext {
|
|
135
|
-
/**
|
|
136
|
-
* @internal
|
|
137
|
-
* The id of the thumb that is currently being dragged
|
|
138
|
-
*/
|
|
139
|
-
activeId: string | null;
|
|
140
|
-
/**
|
|
141
|
-
* @internal
|
|
142
|
-
* The channel that is currently being interacted with
|
|
143
|
-
*/
|
|
144
|
-
activeChannel: Partial<ColorAxes> | null;
|
|
145
|
-
/**
|
|
146
|
-
* @internal
|
|
147
|
-
* The orientation of the channel that is currently being interacted with
|
|
148
|
-
*/
|
|
149
|
-
activeOrientation: Orientation | null;
|
|
150
|
-
/**
|
|
151
|
-
* @internal
|
|
152
|
-
* Whether the checkbox's fieldset is disabled
|
|
153
|
-
*/
|
|
154
|
-
fieldsetDisabled: boolean;
|
|
155
|
-
/**
|
|
156
|
-
* @internal
|
|
157
|
-
* The current placement of the color picker
|
|
158
|
-
*/
|
|
159
|
-
currentPlacement?: PositioningOptions['placement'] | undefined;
|
|
160
|
-
/**
|
|
161
|
-
* @internal
|
|
162
|
-
* Whether the color picker should return focus to the trigger when closed
|
|
163
|
-
*/
|
|
164
|
-
restoreFocus?: boolean | undefined;
|
|
165
|
-
}
|
|
166
|
-
type ComputedContext = Readonly<{
|
|
167
|
-
/**
|
|
168
|
-
* @computed
|
|
169
|
-
* Whether the color picker is in RTL mode
|
|
170
|
-
*/
|
|
171
|
-
isRtl: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* @computed
|
|
174
|
-
* Whether the color picker is interactive
|
|
175
|
-
*/
|
|
176
|
-
isInteractive: boolean;
|
|
177
|
-
/**
|
|
178
|
-
* @computed
|
|
179
|
-
* The color value as a Color object
|
|
180
|
-
*/
|
|
181
|
-
valueAsString: string;
|
|
182
|
-
/**
|
|
183
|
-
* @computed
|
|
184
|
-
* Whether the color picker is disabled
|
|
185
|
-
*/
|
|
186
|
-
isDisabled: boolean;
|
|
187
|
-
/**
|
|
188
|
-
* @computed
|
|
189
|
-
* The area value as a Color object
|
|
190
|
-
*/
|
|
191
|
-
areaValue: Color;
|
|
192
|
-
}>;
|
|
193
|
-
type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
|
|
194
|
-
interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
|
|
195
|
-
}
|
|
196
|
-
interface MachineState {
|
|
197
|
-
tags: 'open' | 'closed' | 'dragging' | 'focused';
|
|
198
|
-
value: 'idle' | 'focused' | 'open' | 'open:dragging';
|
|
199
|
-
}
|
|
200
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
201
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
202
|
-
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
203
|
-
interface ChannelProps {
|
|
204
|
-
channel: ColorChannel;
|
|
205
|
-
orientation?: Orientation | undefined;
|
|
206
|
-
}
|
|
207
|
-
interface ChannelSliderProps extends ChannelProps {
|
|
208
|
-
format?: ColorFormat | undefined;
|
|
209
|
-
}
|
|
210
|
-
interface ChannelInputProps {
|
|
211
|
-
channel: ExtendedColorChannel;
|
|
212
|
-
orientation?: Orientation | undefined;
|
|
213
|
-
}
|
|
214
|
-
interface AreaProps {
|
|
215
|
-
xChannel?: ColorChannel | undefined;
|
|
216
|
-
yChannel?: ColorChannel | undefined;
|
|
217
|
-
}
|
|
218
|
-
interface SwatchTriggerProps {
|
|
219
|
-
/**
|
|
220
|
-
* The color value
|
|
221
|
-
*/
|
|
222
|
-
value: string | Color;
|
|
223
|
-
/**
|
|
224
|
-
* Whether the swatch trigger is disabled
|
|
225
|
-
*/
|
|
226
|
-
disabled?: boolean | undefined;
|
|
227
|
-
}
|
|
228
|
-
interface SwatchTriggerState {
|
|
229
|
-
value: Color;
|
|
230
|
-
valueAsString: string;
|
|
231
|
-
checked: boolean;
|
|
232
|
-
disabled: boolean;
|
|
233
|
-
}
|
|
234
|
-
interface SwatchProps {
|
|
235
|
-
/**
|
|
236
|
-
* The color value
|
|
237
|
-
*/
|
|
238
|
-
value: string | Color;
|
|
239
|
-
/**
|
|
240
|
-
* Whether to include the alpha channel in the color
|
|
241
|
-
*/
|
|
242
|
-
respectAlpha?: boolean | undefined;
|
|
243
|
-
}
|
|
244
|
-
interface TransparencyGridProps {
|
|
245
|
-
size?: string | undefined;
|
|
246
|
-
}
|
|
247
|
-
interface MachineApi<T extends PropTypes = PropTypes> {
|
|
248
|
-
/**
|
|
249
|
-
* Whether the color picker is being dragged
|
|
250
|
-
*/
|
|
251
|
-
dragging: boolean;
|
|
252
|
-
/**
|
|
253
|
-
* Whether the color picker is open
|
|
254
|
-
*/
|
|
255
|
-
open: boolean;
|
|
256
|
-
/**
|
|
257
|
-
* The current color value (as a string)
|
|
258
|
-
*/
|
|
259
|
-
value: Color;
|
|
260
|
-
/**
|
|
261
|
-
* The current color value (as a Color object)
|
|
262
|
-
*/
|
|
263
|
-
valueAsString: string;
|
|
264
|
-
/**
|
|
265
|
-
* Function to set the color value
|
|
266
|
-
*/
|
|
267
|
-
setValue: (value: string | Color) => void;
|
|
268
|
-
/**
|
|
269
|
-
* Function to set the color value
|
|
270
|
-
*/
|
|
271
|
-
getChannelValue: (channel: ColorChannel) => string;
|
|
272
|
-
/**
|
|
273
|
-
* Function to get the formatted and localized value of a specific channel
|
|
274
|
-
*/
|
|
275
|
-
getChannelValueText: (channel: ColorChannel, locale: string) => string;
|
|
276
|
-
/**
|
|
277
|
-
* Function to set the color value of a specific channel
|
|
278
|
-
*/
|
|
279
|
-
setChannelValue: (channel: ColorChannel, value: number) => void;
|
|
280
|
-
/**
|
|
281
|
-
* The current color format
|
|
282
|
-
*/
|
|
283
|
-
format: ColorFormat;
|
|
284
|
-
/**
|
|
285
|
-
* Function to set the color format
|
|
286
|
-
*/
|
|
287
|
-
setFormat: (format: ColorFormat) => void;
|
|
288
|
-
/**
|
|
289
|
-
* The alpha value of the color
|
|
290
|
-
*/
|
|
291
|
-
alpha: number;
|
|
292
|
-
/**
|
|
293
|
-
* Function to set the color alpha
|
|
294
|
-
*/
|
|
295
|
-
setAlpha: (value: number) => void;
|
|
296
|
-
/**
|
|
297
|
-
* Function to open or close the color picker
|
|
298
|
-
*/
|
|
299
|
-
setOpen: (open: boolean) => void;
|
|
300
|
-
getRootProps: () => T['element'];
|
|
301
|
-
getLabelProps: () => T['element'];
|
|
302
|
-
getControlProps: () => T['element'];
|
|
303
|
-
getTriggerProps: () => T['button'];
|
|
304
|
-
getPositionerProps: () => T['element'];
|
|
305
|
-
getContentProps: () => T['element'];
|
|
306
|
-
getHiddenInputProps: () => T['input'];
|
|
307
|
-
getValueTextProps: () => T['element'];
|
|
308
|
-
getAreaProps: (props?: AreaProps) => T['element'];
|
|
309
|
-
getAreaBackgroundProps: (props?: AreaProps) => T['element'];
|
|
310
|
-
getAreaThumbProps: (props?: AreaProps) => T['element'];
|
|
311
|
-
getChannelInputProps: (props: ChannelInputProps) => T['input'];
|
|
312
|
-
getChannelSliderProps: (props: ChannelSliderProps) => T['element'];
|
|
313
|
-
getChannelSliderTrackProps: (props: ChannelSliderProps) => T['element'];
|
|
314
|
-
getChannelSliderThumbProps: (props: ChannelSliderProps) => T['element'];
|
|
315
|
-
getChannelSliderLabelProps: (props: ChannelProps) => T['element'];
|
|
316
|
-
getChannelSliderValueTextProps: (props: ChannelProps) => T['element'];
|
|
317
|
-
getTransparencyGridProps: (props?: TransparencyGridProps) => T['element'];
|
|
318
|
-
getEyeDropperTriggerProps: () => T['button'];
|
|
319
|
-
getSwatchGroupProps: () => T['element'];
|
|
320
|
-
getSwatchTriggerProps: (props: SwatchTriggerProps) => T['button'];
|
|
321
|
-
getSwatchTriggerState: (props: SwatchTriggerProps) => SwatchTriggerState;
|
|
322
|
-
getSwatchProps: (props: SwatchProps) => T['element'];
|
|
323
|
-
getSwatchIndicatorProps: (props: SwatchProps) => T['element'];
|
|
324
|
-
getFormatSelectProps: () => T['select'];
|
|
325
|
-
getFormatTriggerProps: () => T['button'];
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
329
|
-
|
|
330
|
-
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
331
|
-
|
|
332
|
-
declare function parse(colorString: string): Color;
|
|
333
|
-
|
|
334
|
-
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.mts
DELETED
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import { CommonProperties, DirectionProperty, Orientation, PropTypes, RequiredBy, 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
|
-
import * as _zag_js_core from '@zag-js/core';
|
|
6
|
-
import { StateMachine, Machine } from '@zag-js/core';
|
|
7
|
-
import { InteractOutsideHandlers } from '@zag-js/dismissable';
|
|
8
|
-
export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/dismissable';
|
|
9
|
-
import { PositioningOptions } from '@zag-js/popper';
|
|
10
|
-
export { PositioningOptions } from '@zag-js/popper';
|
|
11
|
-
|
|
12
|
-
declare const anatomy: _zag_js_anatomy.Anatomy<"root" | "label" | "control" | "trigger" | "positioner" | "content" | "area" | "areaThumb" | "valueText" | "areaBackground" | "channelSlider" | "channelSliderLabel" | "channelSliderTrack" | "channelSliderThumb" | "channelSliderValueText" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
|
|
13
|
-
|
|
14
|
-
type ExtendedColorChannel = ColorChannel | 'hex' | 'css';
|
|
15
|
-
interface EyeDropper {
|
|
16
|
-
new (): EyeDropper;
|
|
17
|
-
open: (options?: {
|
|
18
|
-
signal?: AbortSignal;
|
|
19
|
-
}) => Promise<{
|
|
20
|
-
sRGBHex: string;
|
|
21
|
-
}>;
|
|
22
|
-
[Symbol.toStringTag]: 'EyeDropper';
|
|
23
|
-
}
|
|
24
|
-
declare global {
|
|
25
|
-
interface Window {
|
|
26
|
-
EyeDropper: EyeDropper;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
interface ValueChangeDetails {
|
|
30
|
-
value: Color;
|
|
31
|
-
valueAsString: string;
|
|
32
|
-
}
|
|
33
|
-
interface OpenChangeDetails {
|
|
34
|
-
open: boolean;
|
|
35
|
-
}
|
|
36
|
-
interface FormatChangeDetails {
|
|
37
|
-
format: ColorFormat;
|
|
38
|
-
}
|
|
39
|
-
type ElementIds = Partial<{
|
|
40
|
-
root: string;
|
|
41
|
-
control: string;
|
|
42
|
-
trigger: string;
|
|
43
|
-
label: string;
|
|
44
|
-
input: string;
|
|
45
|
-
hiddenInput: string;
|
|
46
|
-
content: string;
|
|
47
|
-
area: string;
|
|
48
|
-
areaGradient: string;
|
|
49
|
-
positioner: string;
|
|
50
|
-
formatSelect: string;
|
|
51
|
-
areaThumb: string;
|
|
52
|
-
channelInput: (id: string) => string;
|
|
53
|
-
channelSliderTrack: (id: ColorChannel) => string;
|
|
54
|
-
channelSliderThumb: (id: ColorChannel) => string;
|
|
55
|
-
}>;
|
|
56
|
-
interface PublicContext extends CommonProperties, DirectionProperty, InteractOutsideHandlers {
|
|
57
|
-
/**
|
|
58
|
-
* The ids of the elements in the color picker. Useful for composition.
|
|
59
|
-
*/
|
|
60
|
-
'ids'?: ElementIds | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* The current color value
|
|
63
|
-
* @default #000000
|
|
64
|
-
*/
|
|
65
|
-
'value': Color;
|
|
66
|
-
/**
|
|
67
|
-
* Whether the color picker is disabled
|
|
68
|
-
*/
|
|
69
|
-
'disabled'?: boolean | undefined;
|
|
70
|
-
/**
|
|
71
|
-
* Whether the color picker is read-only
|
|
72
|
-
*/
|
|
73
|
-
'readOnly'?: boolean | undefined;
|
|
74
|
-
/**
|
|
75
|
-
* Whether the color picker is required
|
|
76
|
-
*/
|
|
77
|
-
'required'?: boolean | undefined;
|
|
78
|
-
/**
|
|
79
|
-
* Whether the color picker is invalid
|
|
80
|
-
*/
|
|
81
|
-
'invalid'?: boolean | undefined;
|
|
82
|
-
/**
|
|
83
|
-
* Handler that is called when the value changes, as the user drags.
|
|
84
|
-
*/
|
|
85
|
-
'onValueChange'?: ((details: ValueChangeDetails) => void) | undefined;
|
|
86
|
-
/**
|
|
87
|
-
* Handler that is called when the user stops dragging.
|
|
88
|
-
*/
|
|
89
|
-
'onValueChangeEnd'?: ((details: ValueChangeDetails) => void) | undefined;
|
|
90
|
-
/**
|
|
91
|
-
* Handler that is called when the user opens or closes the color picker.
|
|
92
|
-
*/
|
|
93
|
-
'onOpenChange'?: ((details: OpenChangeDetails) => void) | undefined;
|
|
94
|
-
/**
|
|
95
|
-
* The name for the form input
|
|
96
|
-
*/
|
|
97
|
-
'name'?: string | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* The positioning options for the color picker
|
|
100
|
-
*/
|
|
101
|
-
'positioning': PositioningOptions;
|
|
102
|
-
/**
|
|
103
|
-
* The initial focus element when the color picker is opened.
|
|
104
|
-
*/
|
|
105
|
-
'initialFocusEl'?: (() => HTMLElement | null) | undefined;
|
|
106
|
-
/**
|
|
107
|
-
* Whether the color picker is open
|
|
108
|
-
*/
|
|
109
|
-
'open'?: boolean | undefined;
|
|
110
|
-
/**
|
|
111
|
-
* Whether the color picker open state is controlled by the user
|
|
112
|
-
*/
|
|
113
|
-
'open.controlled'?: boolean | undefined;
|
|
114
|
-
/**
|
|
115
|
-
* The color format to use
|
|
116
|
-
* @default "rgba"
|
|
117
|
-
*/
|
|
118
|
-
'format': ColorFormat;
|
|
119
|
-
/**
|
|
120
|
-
* Function called when the color format changes
|
|
121
|
-
*/
|
|
122
|
-
'onFormatChange'?: ((details: FormatChangeDetails) => void) | undefined;
|
|
123
|
-
/**
|
|
124
|
-
* Whether to close the color picker when a swatch is selected
|
|
125
|
-
* @default false
|
|
126
|
-
*/
|
|
127
|
-
'closeOnSelect'?: boolean | undefined;
|
|
128
|
-
/**
|
|
129
|
-
* Whether to auto focus the color picker when it is opened
|
|
130
|
-
* @default true
|
|
131
|
-
*/
|
|
132
|
-
'openAutoFocus'?: boolean | undefined;
|
|
133
|
-
}
|
|
134
|
-
interface PrivateContext {
|
|
135
|
-
/**
|
|
136
|
-
* @internal
|
|
137
|
-
* The id of the thumb that is currently being dragged
|
|
138
|
-
*/
|
|
139
|
-
activeId: string | null;
|
|
140
|
-
/**
|
|
141
|
-
* @internal
|
|
142
|
-
* The channel that is currently being interacted with
|
|
143
|
-
*/
|
|
144
|
-
activeChannel: Partial<ColorAxes> | null;
|
|
145
|
-
/**
|
|
146
|
-
* @internal
|
|
147
|
-
* The orientation of the channel that is currently being interacted with
|
|
148
|
-
*/
|
|
149
|
-
activeOrientation: Orientation | null;
|
|
150
|
-
/**
|
|
151
|
-
* @internal
|
|
152
|
-
* Whether the checkbox's fieldset is disabled
|
|
153
|
-
*/
|
|
154
|
-
fieldsetDisabled: boolean;
|
|
155
|
-
/**
|
|
156
|
-
* @internal
|
|
157
|
-
* The current placement of the color picker
|
|
158
|
-
*/
|
|
159
|
-
currentPlacement?: PositioningOptions['placement'] | undefined;
|
|
160
|
-
/**
|
|
161
|
-
* @internal
|
|
162
|
-
* Whether the color picker should return focus to the trigger when closed
|
|
163
|
-
*/
|
|
164
|
-
restoreFocus?: boolean | undefined;
|
|
165
|
-
}
|
|
166
|
-
type ComputedContext = Readonly<{
|
|
167
|
-
/**
|
|
168
|
-
* @computed
|
|
169
|
-
* Whether the color picker is in RTL mode
|
|
170
|
-
*/
|
|
171
|
-
isRtl: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* @computed
|
|
174
|
-
* Whether the color picker is interactive
|
|
175
|
-
*/
|
|
176
|
-
isInteractive: boolean;
|
|
177
|
-
/**
|
|
178
|
-
* @computed
|
|
179
|
-
* The color value as a Color object
|
|
180
|
-
*/
|
|
181
|
-
valueAsString: string;
|
|
182
|
-
/**
|
|
183
|
-
* @computed
|
|
184
|
-
* Whether the color picker is disabled
|
|
185
|
-
*/
|
|
186
|
-
isDisabled: boolean;
|
|
187
|
-
/**
|
|
188
|
-
* @computed
|
|
189
|
-
* The area value as a Color object
|
|
190
|
-
*/
|
|
191
|
-
areaValue: Color;
|
|
192
|
-
}>;
|
|
193
|
-
type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
|
|
194
|
-
interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
|
|
195
|
-
}
|
|
196
|
-
interface MachineState {
|
|
197
|
-
tags: 'open' | 'closed' | 'dragging' | 'focused';
|
|
198
|
-
value: 'idle' | 'focused' | 'open' | 'open:dragging';
|
|
199
|
-
}
|
|
200
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
201
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
202
|
-
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
203
|
-
interface ChannelProps {
|
|
204
|
-
channel: ColorChannel;
|
|
205
|
-
orientation?: Orientation | undefined;
|
|
206
|
-
}
|
|
207
|
-
interface ChannelSliderProps extends ChannelProps {
|
|
208
|
-
format?: ColorFormat | undefined;
|
|
209
|
-
}
|
|
210
|
-
interface ChannelInputProps {
|
|
211
|
-
channel: ExtendedColorChannel;
|
|
212
|
-
orientation?: Orientation | undefined;
|
|
213
|
-
}
|
|
214
|
-
interface AreaProps {
|
|
215
|
-
xChannel?: ColorChannel | undefined;
|
|
216
|
-
yChannel?: ColorChannel | undefined;
|
|
217
|
-
}
|
|
218
|
-
interface SwatchTriggerProps {
|
|
219
|
-
/**
|
|
220
|
-
* The color value
|
|
221
|
-
*/
|
|
222
|
-
value: string | Color;
|
|
223
|
-
/**
|
|
224
|
-
* Whether the swatch trigger is disabled
|
|
225
|
-
*/
|
|
226
|
-
disabled?: boolean | undefined;
|
|
227
|
-
}
|
|
228
|
-
interface SwatchTriggerState {
|
|
229
|
-
value: Color;
|
|
230
|
-
valueAsString: string;
|
|
231
|
-
checked: boolean;
|
|
232
|
-
disabled: boolean;
|
|
233
|
-
}
|
|
234
|
-
interface SwatchProps {
|
|
235
|
-
/**
|
|
236
|
-
* The color value
|
|
237
|
-
*/
|
|
238
|
-
value: string | Color;
|
|
239
|
-
/**
|
|
240
|
-
* Whether to include the alpha channel in the color
|
|
241
|
-
*/
|
|
242
|
-
respectAlpha?: boolean | undefined;
|
|
243
|
-
}
|
|
244
|
-
interface TransparencyGridProps {
|
|
245
|
-
size?: string | undefined;
|
|
246
|
-
}
|
|
247
|
-
interface MachineApi<T extends PropTypes = PropTypes> {
|
|
248
|
-
/**
|
|
249
|
-
* Whether the color picker is being dragged
|
|
250
|
-
*/
|
|
251
|
-
dragging: boolean;
|
|
252
|
-
/**
|
|
253
|
-
* Whether the color picker is open
|
|
254
|
-
*/
|
|
255
|
-
open: boolean;
|
|
256
|
-
/**
|
|
257
|
-
* The current color value (as a string)
|
|
258
|
-
*/
|
|
259
|
-
value: Color;
|
|
260
|
-
/**
|
|
261
|
-
* The current color value (as a Color object)
|
|
262
|
-
*/
|
|
263
|
-
valueAsString: string;
|
|
264
|
-
/**
|
|
265
|
-
* Function to set the color value
|
|
266
|
-
*/
|
|
267
|
-
setValue: (value: string | Color) => void;
|
|
268
|
-
/**
|
|
269
|
-
* Function to set the color value
|
|
270
|
-
*/
|
|
271
|
-
getChannelValue: (channel: ColorChannel) => string;
|
|
272
|
-
/**
|
|
273
|
-
* Function to get the formatted and localized value of a specific channel
|
|
274
|
-
*/
|
|
275
|
-
getChannelValueText: (channel: ColorChannel, locale: string) => string;
|
|
276
|
-
/**
|
|
277
|
-
* Function to set the color value of a specific channel
|
|
278
|
-
*/
|
|
279
|
-
setChannelValue: (channel: ColorChannel, value: number) => void;
|
|
280
|
-
/**
|
|
281
|
-
* The current color format
|
|
282
|
-
*/
|
|
283
|
-
format: ColorFormat;
|
|
284
|
-
/**
|
|
285
|
-
* Function to set the color format
|
|
286
|
-
*/
|
|
287
|
-
setFormat: (format: ColorFormat) => void;
|
|
288
|
-
/**
|
|
289
|
-
* The alpha value of the color
|
|
290
|
-
*/
|
|
291
|
-
alpha: number;
|
|
292
|
-
/**
|
|
293
|
-
* Function to set the color alpha
|
|
294
|
-
*/
|
|
295
|
-
setAlpha: (value: number) => void;
|
|
296
|
-
/**
|
|
297
|
-
* Function to open or close the color picker
|
|
298
|
-
*/
|
|
299
|
-
setOpen: (open: boolean) => void;
|
|
300
|
-
getRootProps: () => T['element'];
|
|
301
|
-
getLabelProps: () => T['element'];
|
|
302
|
-
getControlProps: () => T['element'];
|
|
303
|
-
getTriggerProps: () => T['button'];
|
|
304
|
-
getPositionerProps: () => T['element'];
|
|
305
|
-
getContentProps: () => T['element'];
|
|
306
|
-
getHiddenInputProps: () => T['input'];
|
|
307
|
-
getValueTextProps: () => T['element'];
|
|
308
|
-
getAreaProps: (props?: AreaProps) => T['element'];
|
|
309
|
-
getAreaBackgroundProps: (props?: AreaProps) => T['element'];
|
|
310
|
-
getAreaThumbProps: (props?: AreaProps) => T['element'];
|
|
311
|
-
getChannelInputProps: (props: ChannelInputProps) => T['input'];
|
|
312
|
-
getChannelSliderProps: (props: ChannelSliderProps) => T['element'];
|
|
313
|
-
getChannelSliderTrackProps: (props: ChannelSliderProps) => T['element'];
|
|
314
|
-
getChannelSliderThumbProps: (props: ChannelSliderProps) => T['element'];
|
|
315
|
-
getChannelSliderLabelProps: (props: ChannelProps) => T['element'];
|
|
316
|
-
getChannelSliderValueTextProps: (props: ChannelProps) => T['element'];
|
|
317
|
-
getTransparencyGridProps: (props?: TransparencyGridProps) => T['element'];
|
|
318
|
-
getEyeDropperTriggerProps: () => T['button'];
|
|
319
|
-
getSwatchGroupProps: () => T['element'];
|
|
320
|
-
getSwatchTriggerProps: (props: SwatchTriggerProps) => T['button'];
|
|
321
|
-
getSwatchTriggerState: (props: SwatchTriggerProps) => SwatchTriggerState;
|
|
322
|
-
getSwatchProps: (props: SwatchProps) => T['element'];
|
|
323
|
-
getSwatchIndicatorProps: (props: SwatchProps) => T['element'];
|
|
324
|
-
getFormatSelectProps: () => T['select'];
|
|
325
|
-
getFormatTriggerProps: () => T['button'];
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
329
|
-
|
|
330
|
-
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
331
|
-
|
|
332
|
-
declare function parse(colorString: string): Color;
|
|
333
|
-
|
|
334
|
-
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 };
|