@zag-js/color-picker 0.82.2 → 1.0.1
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 +69 -55
- package/dist/index.d.ts +69 -55
- package/dist/index.js +761 -711
- package/dist/index.mjs +755 -717
- package/package.json +17 -12
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { InteractOutsideHandlers } from '@zag-js/dismissable';
|
|
2
2
|
export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/dismissable';
|
|
3
3
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
4
|
-
import {
|
|
5
|
-
import { Color, ColorFormat, ColorChannel } from '@zag-js/color-utils';
|
|
4
|
+
import { CommonProperties, DirectionProperty, Orientation, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
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 { Machine,
|
|
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
|
|
|
@@ -53,16 +53,21 @@ type ElementIds = Partial<{
|
|
|
53
53
|
channelSliderTrack(id: ColorChannel): string;
|
|
54
54
|
channelSliderThumb(id: ColorChannel): string;
|
|
55
55
|
}>;
|
|
56
|
-
interface
|
|
56
|
+
interface ColorPickerProps extends CommonProperties, DirectionProperty, InteractOutsideHandlers {
|
|
57
57
|
/**
|
|
58
58
|
* The ids of the elements in the color picker. Useful for composition.
|
|
59
59
|
*/
|
|
60
60
|
ids?: ElementIds | undefined;
|
|
61
61
|
/**
|
|
62
|
-
* The
|
|
62
|
+
* The controlled color value of the color picker
|
|
63
|
+
*/
|
|
64
|
+
value?: Color | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* The initial color value when rendered.
|
|
67
|
+
* Use when you don't need to control the color value of the color picker.
|
|
63
68
|
* @default #000000
|
|
64
69
|
*/
|
|
65
|
-
|
|
70
|
+
defaultValue?: Color | undefined;
|
|
66
71
|
/**
|
|
67
72
|
* Whether the color picker is disabled
|
|
68
73
|
*/
|
|
@@ -98,24 +103,30 @@ interface PublicContext extends CommonProperties, DirectionProperty, InteractOut
|
|
|
98
103
|
/**
|
|
99
104
|
* The positioning options for the color picker
|
|
100
105
|
*/
|
|
101
|
-
positioning
|
|
106
|
+
positioning?: PositioningOptions | undefined;
|
|
102
107
|
/**
|
|
103
108
|
* The initial focus element when the color picker is opened.
|
|
104
109
|
*/
|
|
105
110
|
initialFocusEl?: (() => HTMLElement | null) | undefined;
|
|
106
111
|
/**
|
|
107
|
-
*
|
|
112
|
+
* The controlled open state of the color picker
|
|
108
113
|
*/
|
|
109
114
|
open?: boolean | undefined;
|
|
110
115
|
/**
|
|
111
|
-
*
|
|
116
|
+
* The initial open state of the color picker when rendered.
|
|
117
|
+
* Use when you don't need to control the open state of the color picker.
|
|
112
118
|
*/
|
|
113
|
-
|
|
119
|
+
defaultOpen?: boolean | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* The controlled color format to use
|
|
122
|
+
*/
|
|
123
|
+
format?: ColorFormat | undefined;
|
|
114
124
|
/**
|
|
115
|
-
* The color format
|
|
125
|
+
* The initial color format when rendered.
|
|
126
|
+
* Use when you don't need to control the color format of the color picker.
|
|
116
127
|
* @default "rgba"
|
|
117
128
|
*/
|
|
118
|
-
|
|
129
|
+
defaultFormat?: ColorFormat | undefined;
|
|
119
130
|
/**
|
|
120
131
|
* Function called when the color format changes
|
|
121
132
|
*/
|
|
@@ -131,45 +142,35 @@ interface PublicContext extends CommonProperties, DirectionProperty, InteractOut
|
|
|
131
142
|
*/
|
|
132
143
|
openAutoFocus?: boolean | undefined;
|
|
133
144
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
164
|
-
interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
|
|
165
|
-
}
|
|
166
|
-
interface MachineState {
|
|
167
|
-
tags: "open" | "closed" | "dragging" | "focused";
|
|
168
|
-
value: "idle" | "focused" | "open" | "open:dragging";
|
|
169
|
-
}
|
|
170
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
171
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
172
|
-
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
145
|
+
type PropsWithDefault = "defaultFormat" | "defaultValue" | "openAutoFocus" | "dir" | "positioning";
|
|
146
|
+
type ColorPickerSchema = {
|
|
147
|
+
tag: "open" | "closed" | "dragging" | "focused";
|
|
148
|
+
state: "idle" | "focused" | "open" | "open:dragging";
|
|
149
|
+
props: RequiredBy<ColorPickerProps, PropsWithDefault>;
|
|
150
|
+
computed: {
|
|
151
|
+
disabled: boolean;
|
|
152
|
+
rtl: boolean;
|
|
153
|
+
interactive: boolean;
|
|
154
|
+
valueAsString: string;
|
|
155
|
+
areaValue: Color;
|
|
156
|
+
};
|
|
157
|
+
context: {
|
|
158
|
+
format: ColorFormat;
|
|
159
|
+
value: Color;
|
|
160
|
+
activeId: string | null;
|
|
161
|
+
activeChannel: Partial<ColorAxes> | null;
|
|
162
|
+
activeOrientation: Orientation | null;
|
|
163
|
+
fieldsetDisabled: boolean;
|
|
164
|
+
currentPlacement: PositioningOptions["placement"] | undefined;
|
|
165
|
+
restoreFocus: boolean;
|
|
166
|
+
};
|
|
167
|
+
event: EventObject;
|
|
168
|
+
action: string;
|
|
169
|
+
effect: string;
|
|
170
|
+
guard: string;
|
|
171
|
+
};
|
|
172
|
+
type ColorPickerService = Service<ColorPickerSchema>;
|
|
173
|
+
type ColorPickerMachine = Machine<ColorPickerSchema>;
|
|
173
174
|
interface ChannelProps {
|
|
174
175
|
channel: ColorChannel;
|
|
175
176
|
orientation?: Orientation | undefined;
|
|
@@ -214,7 +215,7 @@ interface SwatchProps {
|
|
|
214
215
|
interface TransparencyGridProps {
|
|
215
216
|
size?: string | undefined;
|
|
216
217
|
}
|
|
217
|
-
interface
|
|
218
|
+
interface ColorPickerApi<T extends PropTypes = PropTypes> {
|
|
218
219
|
/**
|
|
219
220
|
* Whether the color picker is being dragged
|
|
220
221
|
*/
|
|
@@ -295,10 +296,23 @@ interface MachineApi<T extends PropTypes = PropTypes> {
|
|
|
295
296
|
getFormatTriggerProps(): T["button"];
|
|
296
297
|
}
|
|
297
298
|
|
|
298
|
-
declare function connect<T extends PropTypes>(
|
|
299
|
+
declare function connect<T extends PropTypes>(service: ColorPickerService, normalize: NormalizeProps<T>): ColorPickerApi<T>;
|
|
299
300
|
|
|
300
|
-
declare
|
|
301
|
+
declare const machine: _zag_js_core.Machine<ColorPickerSchema>;
|
|
301
302
|
|
|
302
303
|
declare const parse: (colorString: string) => Color;
|
|
303
304
|
|
|
304
|
-
|
|
305
|
+
declare const props: (keyof ColorPickerProps)[];
|
|
306
|
+
declare const splitProps: <Props extends Partial<ColorPickerProps>>(props: Props) => [Partial<ColorPickerProps>, Omit<Props, keyof ColorPickerProps>];
|
|
307
|
+
declare const areaProps: (keyof AreaProps)[];
|
|
308
|
+
declare const splitAreaProps: <Props extends AreaProps>(props: Props) => [AreaProps, Omit<Props, keyof AreaProps>];
|
|
309
|
+
declare const channelProps: (keyof ChannelProps)[];
|
|
310
|
+
declare const splitChannelProps: <Props extends ChannelProps>(props: Props) => [ChannelProps, Omit<Props, keyof ChannelProps>];
|
|
311
|
+
declare const swatchTriggerProps: (keyof SwatchTriggerProps)[];
|
|
312
|
+
declare const splitSwatchTriggerProps: <Props extends SwatchTriggerProps>(props: Props) => [SwatchTriggerProps, Omit<Props, keyof SwatchTriggerProps>];
|
|
313
|
+
declare const swatchProps: (keyof SwatchProps)[];
|
|
314
|
+
declare const splitSwatchProps: <Props extends SwatchProps>(props: Props) => [SwatchProps, Omit<Props, keyof SwatchProps>];
|
|
315
|
+
declare const transparencyGridProps: "size"[];
|
|
316
|
+
declare const splitTransparencyGridProps: <Props extends TransparencyGridProps>(props: Props) => [TransparencyGridProps, Omit<Props, "size">];
|
|
317
|
+
|
|
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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { InteractOutsideHandlers } from '@zag-js/dismissable';
|
|
2
2
|
export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/dismissable';
|
|
3
3
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
4
|
-
import {
|
|
5
|
-
import { Color, ColorFormat, ColorChannel } from '@zag-js/color-utils';
|
|
4
|
+
import { CommonProperties, DirectionProperty, Orientation, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
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 { Machine,
|
|
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
|
|
|
@@ -53,16 +53,21 @@ type ElementIds = Partial<{
|
|
|
53
53
|
channelSliderTrack(id: ColorChannel): string;
|
|
54
54
|
channelSliderThumb(id: ColorChannel): string;
|
|
55
55
|
}>;
|
|
56
|
-
interface
|
|
56
|
+
interface ColorPickerProps extends CommonProperties, DirectionProperty, InteractOutsideHandlers {
|
|
57
57
|
/**
|
|
58
58
|
* The ids of the elements in the color picker. Useful for composition.
|
|
59
59
|
*/
|
|
60
60
|
ids?: ElementIds | undefined;
|
|
61
61
|
/**
|
|
62
|
-
* The
|
|
62
|
+
* The controlled color value of the color picker
|
|
63
|
+
*/
|
|
64
|
+
value?: Color | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* The initial color value when rendered.
|
|
67
|
+
* Use when you don't need to control the color value of the color picker.
|
|
63
68
|
* @default #000000
|
|
64
69
|
*/
|
|
65
|
-
|
|
70
|
+
defaultValue?: Color | undefined;
|
|
66
71
|
/**
|
|
67
72
|
* Whether the color picker is disabled
|
|
68
73
|
*/
|
|
@@ -98,24 +103,30 @@ interface PublicContext extends CommonProperties, DirectionProperty, InteractOut
|
|
|
98
103
|
/**
|
|
99
104
|
* The positioning options for the color picker
|
|
100
105
|
*/
|
|
101
|
-
positioning
|
|
106
|
+
positioning?: PositioningOptions | undefined;
|
|
102
107
|
/**
|
|
103
108
|
* The initial focus element when the color picker is opened.
|
|
104
109
|
*/
|
|
105
110
|
initialFocusEl?: (() => HTMLElement | null) | undefined;
|
|
106
111
|
/**
|
|
107
|
-
*
|
|
112
|
+
* The controlled open state of the color picker
|
|
108
113
|
*/
|
|
109
114
|
open?: boolean | undefined;
|
|
110
115
|
/**
|
|
111
|
-
*
|
|
116
|
+
* The initial open state of the color picker when rendered.
|
|
117
|
+
* Use when you don't need to control the open state of the color picker.
|
|
112
118
|
*/
|
|
113
|
-
|
|
119
|
+
defaultOpen?: boolean | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* The controlled color format to use
|
|
122
|
+
*/
|
|
123
|
+
format?: ColorFormat | undefined;
|
|
114
124
|
/**
|
|
115
|
-
* The color format
|
|
125
|
+
* The initial color format when rendered.
|
|
126
|
+
* Use when you don't need to control the color format of the color picker.
|
|
116
127
|
* @default "rgba"
|
|
117
128
|
*/
|
|
118
|
-
|
|
129
|
+
defaultFormat?: ColorFormat | undefined;
|
|
119
130
|
/**
|
|
120
131
|
* Function called when the color format changes
|
|
121
132
|
*/
|
|
@@ -131,45 +142,35 @@ interface PublicContext extends CommonProperties, DirectionProperty, InteractOut
|
|
|
131
142
|
*/
|
|
132
143
|
openAutoFocus?: boolean | undefined;
|
|
133
144
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
164
|
-
interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
|
|
165
|
-
}
|
|
166
|
-
interface MachineState {
|
|
167
|
-
tags: "open" | "closed" | "dragging" | "focused";
|
|
168
|
-
value: "idle" | "focused" | "open" | "open:dragging";
|
|
169
|
-
}
|
|
170
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
171
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
172
|
-
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
145
|
+
type PropsWithDefault = "defaultFormat" | "defaultValue" | "openAutoFocus" | "dir" | "positioning";
|
|
146
|
+
type ColorPickerSchema = {
|
|
147
|
+
tag: "open" | "closed" | "dragging" | "focused";
|
|
148
|
+
state: "idle" | "focused" | "open" | "open:dragging";
|
|
149
|
+
props: RequiredBy<ColorPickerProps, PropsWithDefault>;
|
|
150
|
+
computed: {
|
|
151
|
+
disabled: boolean;
|
|
152
|
+
rtl: boolean;
|
|
153
|
+
interactive: boolean;
|
|
154
|
+
valueAsString: string;
|
|
155
|
+
areaValue: Color;
|
|
156
|
+
};
|
|
157
|
+
context: {
|
|
158
|
+
format: ColorFormat;
|
|
159
|
+
value: Color;
|
|
160
|
+
activeId: string | null;
|
|
161
|
+
activeChannel: Partial<ColorAxes> | null;
|
|
162
|
+
activeOrientation: Orientation | null;
|
|
163
|
+
fieldsetDisabled: boolean;
|
|
164
|
+
currentPlacement: PositioningOptions["placement"] | undefined;
|
|
165
|
+
restoreFocus: boolean;
|
|
166
|
+
};
|
|
167
|
+
event: EventObject;
|
|
168
|
+
action: string;
|
|
169
|
+
effect: string;
|
|
170
|
+
guard: string;
|
|
171
|
+
};
|
|
172
|
+
type ColorPickerService = Service<ColorPickerSchema>;
|
|
173
|
+
type ColorPickerMachine = Machine<ColorPickerSchema>;
|
|
173
174
|
interface ChannelProps {
|
|
174
175
|
channel: ColorChannel;
|
|
175
176
|
orientation?: Orientation | undefined;
|
|
@@ -214,7 +215,7 @@ interface SwatchProps {
|
|
|
214
215
|
interface TransparencyGridProps {
|
|
215
216
|
size?: string | undefined;
|
|
216
217
|
}
|
|
217
|
-
interface
|
|
218
|
+
interface ColorPickerApi<T extends PropTypes = PropTypes> {
|
|
218
219
|
/**
|
|
219
220
|
* Whether the color picker is being dragged
|
|
220
221
|
*/
|
|
@@ -295,10 +296,23 @@ interface MachineApi<T extends PropTypes = PropTypes> {
|
|
|
295
296
|
getFormatTriggerProps(): T["button"];
|
|
296
297
|
}
|
|
297
298
|
|
|
298
|
-
declare function connect<T extends PropTypes>(
|
|
299
|
+
declare function connect<T extends PropTypes>(service: ColorPickerService, normalize: NormalizeProps<T>): ColorPickerApi<T>;
|
|
299
300
|
|
|
300
|
-
declare
|
|
301
|
+
declare const machine: _zag_js_core.Machine<ColorPickerSchema>;
|
|
301
302
|
|
|
302
303
|
declare const parse: (colorString: string) => Color;
|
|
303
304
|
|
|
304
|
-
|
|
305
|
+
declare const props: (keyof ColorPickerProps)[];
|
|
306
|
+
declare const splitProps: <Props extends Partial<ColorPickerProps>>(props: Props) => [Partial<ColorPickerProps>, Omit<Props, keyof ColorPickerProps>];
|
|
307
|
+
declare const areaProps: (keyof AreaProps)[];
|
|
308
|
+
declare const splitAreaProps: <Props extends AreaProps>(props: Props) => [AreaProps, Omit<Props, keyof AreaProps>];
|
|
309
|
+
declare const channelProps: (keyof ChannelProps)[];
|
|
310
|
+
declare const splitChannelProps: <Props extends ChannelProps>(props: Props) => [ChannelProps, Omit<Props, keyof ChannelProps>];
|
|
311
|
+
declare const swatchTriggerProps: (keyof SwatchTriggerProps)[];
|
|
312
|
+
declare const splitSwatchTriggerProps: <Props extends SwatchTriggerProps>(props: Props) => [SwatchTriggerProps, Omit<Props, keyof SwatchTriggerProps>];
|
|
313
|
+
declare const swatchProps: (keyof SwatchProps)[];
|
|
314
|
+
declare const splitSwatchProps: <Props extends SwatchProps>(props: Props) => [SwatchProps, Omit<Props, keyof SwatchProps>];
|
|
315
|
+
declare const transparencyGridProps: "size"[];
|
|
316
|
+
declare const splitTransparencyGridProps: <Props extends TransparencyGridProps>(props: Props) => [TransparencyGridProps, Omit<Props, "size">];
|
|
317
|
+
|
|
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 };
|