@zag-js/color-picker 0.10.2 → 0.10.4

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.
Files changed (54) hide show
  1. package/dist/color-picker.anatomy.d.ts +3 -6
  2. package/dist/color-picker.anatomy.js +10 -33
  3. package/dist/color-picker.anatomy.mjs +19 -8
  4. package/dist/color-picker.connect.d.ts +4 -8
  5. package/dist/color-picker.connect.js +56 -436
  6. package/dist/color-picker.connect.mjs +368 -14
  7. package/dist/color-picker.dom.d.ts +27 -32
  8. package/dist/color-picker.dom.js +12 -34
  9. package/dist/color-picker.dom.mjs +33 -6
  10. package/dist/color-picker.machine.d.ts +3 -8
  11. package/dist/color-picker.machine.js +46 -163
  12. package/dist/color-picker.machine.mjs +335 -8
  13. package/dist/color-picker.types.d.ts +14 -16
  14. package/dist/index.d.ts +4 -8
  15. package/dist/index.js +8 -1085
  16. package/dist/index.mjs +3 -21
  17. package/dist/utils/generate-format-background.d.ts +9 -11
  18. package/dist/utils/generate-format-background.js +22 -53
  19. package/dist/utils/generate-format-background.mjs +120 -21
  20. package/dist/utils/get-channel-details.d.ts +3 -7
  21. package/dist/utils/get-channel-details.js +15 -37
  22. package/dist/utils/get-channel-details.mjs +53 -6
  23. package/dist/utils/get-channel-display-color.d.ts +3 -5
  24. package/dist/utils/get-channel-display-color.js +8 -30
  25. package/dist/utils/get-channel-display-color.mjs +22 -6
  26. package/dist/utils/get-channel-input-value.d.ts +5 -10
  27. package/dist/utils/get-channel-input-value.js +6 -30
  28. package/dist/utils/get-channel-input-value.mjs +21 -8
  29. package/dist/utils/get-color-area-gradient.d.ts +6 -10
  30. package/dist/utils/get-color-area-gradient.js +14 -158
  31. package/dist/utils/get-color-area-gradient.mjs +61 -7
  32. package/dist/utils/get-slider-background.d.ts +2 -8
  33. package/dist/utils/get-slider-background.js +6 -29
  34. package/dist/utils/get-slider-background.mjs +38 -5
  35. package/package.json +11 -16
  36. package/src/color-picker.connect.ts +1 -1
  37. package/src/color-picker.dom.ts +1 -1
  38. package/src/color-picker.types.ts +3 -1
  39. package/src/index.ts +2 -0
  40. package/src/utils/get-channel-details.ts +2 -2
  41. package/src/utils/get-channel-display-color.ts +1 -1
  42. package/src/utils/get-color-area-gradient.ts +1 -1
  43. package/dist/chunk-2ERX54SV.mjs +0 -25
  44. package/dist/chunk-3XH465XT.mjs +0 -42
  45. package/dist/chunk-5QSFKCT5.mjs +0 -393
  46. package/dist/chunk-75JXJMB5.mjs +0 -22
  47. package/dist/chunk-JNBNPPMF.mjs +0 -24
  48. package/dist/chunk-KLLIOTK6.mjs +0 -55
  49. package/dist/chunk-KO4TBUXB.mjs +0 -74
  50. package/dist/chunk-ML3WX6YS.mjs +0 -345
  51. package/dist/chunk-OY3B7NXA.mjs +0 -132
  52. package/dist/chunk-SPSDVZCT.mjs +0 -35
  53. package/dist/color-picker.types.js +0 -18
  54. package/dist/color-picker.types.mjs +0 -0
@@ -1,345 +0,0 @@
1
- import {
2
- getChannelInputValue
3
- } from "./chunk-2ERX54SV.mjs";
4
- import {
5
- dom
6
- } from "./chunk-SPSDVZCT.mjs";
7
- import {
8
- getChannelDetails
9
- } from "./chunk-KLLIOTK6.mjs";
10
-
11
- // src/color-picker.machine.ts
12
- import { parseColor } from "@zag-js/color-utils";
13
- import { createMachine } from "@zag-js/core";
14
- import { trackPointerMove } from "@zag-js/dom-event";
15
- import { raf } from "@zag-js/dom-query";
16
- import { clampValue, getPercentValue, snapValueToStep } from "@zag-js/numeric-range";
17
- import { disableTextSelection } from "@zag-js/text-selection";
18
- import { compact } from "@zag-js/utils";
19
- function machine(userContext) {
20
- const ctx = compact(userContext);
21
- return createMachine(
22
- {
23
- id: "color-picker",
24
- initial: "idle",
25
- context: {
26
- dir: "ltr",
27
- activeId: null,
28
- activeChannel: null,
29
- activeOrientation: null,
30
- value: "#D9D9D9",
31
- ...ctx,
32
- valueAsColor: parseColor(ctx.value || "#D9D9D9")
33
- },
34
- computed: {
35
- isRtl: (ctx2) => ctx2.dir === "rtl",
36
- isInteractive: (ctx2) => !(ctx2.disabled || ctx2.readOnly)
37
- },
38
- on: {
39
- "VALUE.SET": {
40
- actions: ["setValue"]
41
- }
42
- },
43
- created: ["setValueAsColor"],
44
- watch: {
45
- value: ["setValueAsColor", "syncChannelInputs", "invokeOnChange"]
46
- },
47
- states: {
48
- idle: {
49
- on: {
50
- "EYEDROPPER.CLICK": {
51
- actions: ["openEyeDropper"]
52
- },
53
- "AREA.POINTER_DOWN": {
54
- target: "dragging",
55
- actions: ["setActiveChannel", "setAreaColorFromPoint", "focusAreaThumb"]
56
- },
57
- "CHANNEL_SLIDER.POINTER_DOWN": {
58
- target: "dragging",
59
- actions: ["setActiveChannel", "setChannelColorFromPoint", "focusChannelThumb"]
60
- },
61
- "CHANNEL_INPUT.FOCUS": {
62
- target: "focused",
63
- actions: ["setActiveChannel"]
64
- },
65
- "CHANNEL_INPUT.CHANGE": {
66
- actions: ["setChannelColorFromInput"]
67
- }
68
- }
69
- },
70
- focused: {
71
- on: {
72
- "AREA.POINTER_DOWN": {
73
- target: "dragging",
74
- actions: ["setActiveChannel", "setAreaColorFromPoint", "focusAreaThumb"]
75
- },
76
- "CHANNEL_SLIDER.POINTER_DOWN": {
77
- target: "dragging",
78
- actions: ["setActiveChannel", "setChannelColorFromPoint", "focusChannelThumb"]
79
- },
80
- "AREA.ARROW_LEFT": {
81
- actions: ["decrementXChannel"]
82
- },
83
- "AREA.ARROW_RIGHT": {
84
- actions: ["incrementXChannel"]
85
- },
86
- "AREA.ARROW_UP": {
87
- actions: ["incrementYChannel"]
88
- },
89
- "AREA.ARROW_DOWN": {
90
- actions: ["decrementYChannel"]
91
- },
92
- "AREA.PAGE_UP": {
93
- actions: ["incrementXChannel"]
94
- },
95
- "AREA.PAGE_DOWN": {
96
- actions: ["decrementXChannel"]
97
- },
98
- "CHANNEL_SLIDER.ARROW_LEFT": {
99
- actions: ["decrementChannel"]
100
- },
101
- "CHANNEL_SLIDER.ARROW_RIGHT": {
102
- actions: ["incrementChannel"]
103
- },
104
- "CHANNEL_SLIDER.ARROW_UP": {
105
- actions: ["incrementChannel"]
106
- },
107
- "CHANNEL_SLIDER.ARROW_DOWN": {
108
- actions: ["decrementChannel"]
109
- },
110
- "CHANNEL_SLIDER.PAGE_UP": {
111
- actions: ["incrementChannel"]
112
- },
113
- "CHANNEL_SLIDER.PAGE_DOWN": {
114
- actions: ["decrementChannel"]
115
- },
116
- "CHANNEL_SLIDER.HOME": {
117
- actions: ["setChannelToMin"]
118
- },
119
- "CHANNEL_SLIDER.END": {
120
- actions: ["setChannelToMax"]
121
- },
122
- "CHANNEL_INPUT.FOCUS": {
123
- actions: ["setActiveChannel"]
124
- },
125
- "CHANNEL_INPUT.CHANGE": {
126
- actions: ["setChannelColorFromInput"]
127
- },
128
- "CHANNEL_INPUT.BLUR": [
129
- {
130
- guard: "isTextField",
131
- target: "idle",
132
- actions: ["setChannelColorFromInput"]
133
- },
134
- { target: "idle" }
135
- ],
136
- "CHANNEL_SLIDER.BLUR": {
137
- target: "idle"
138
- },
139
- "AREA.BLUR": {
140
- target: "idle"
141
- }
142
- }
143
- },
144
- dragging: {
145
- exit: ["clearActiveChannel"],
146
- activities: ["trackPointerMove", "disableTextSelection"],
147
- on: {
148
- "AREA.POINTER_MOVE": {
149
- actions: ["setAreaColorFromPoint"]
150
- },
151
- "AREA.POINTER_UP": {
152
- target: "focused",
153
- actions: ["invokeOnChangeEnd"]
154
- },
155
- "CHANNEL_SLIDER.POINTER_MOVE": {
156
- actions: ["setChannelColorFromPoint"]
157
- },
158
- "CHANNEL_SLIDER.POINTER_UP": {
159
- target: "focused",
160
- actions: ["invokeOnChangeEnd"]
161
- }
162
- }
163
- }
164
- }
165
- },
166
- {
167
- guards: {
168
- isTextField: (_ctx, evt) => !!evt.isTextField
169
- },
170
- activities: {
171
- trackPointerMove(ctx2, _evt, { send }) {
172
- return trackPointerMove(dom.getDoc(ctx2), {
173
- onPointerMove({ point }) {
174
- const type = ctx2.activeId === "area" ? "AREA.POINTER_MOVE" : "CHANNEL_SLIDER.POINTER_MOVE";
175
- send({ type, point });
176
- },
177
- onPointerUp() {
178
- const type = ctx2.activeId === "area" ? "AREA.POINTER_UP" : "CHANNEL_SLIDER.POINTER_UP";
179
- send({ type });
180
- }
181
- });
182
- },
183
- disableTextSelection(ctx2) {
184
- return disableTextSelection({ doc: dom.getDoc(ctx2), target: dom.getContentEl(ctx2) });
185
- }
186
- },
187
- actions: {
188
- openEyeDropper(ctx2) {
189
- const isSupported = "EyeDropper" in dom.getWin(ctx2);
190
- if (!isSupported)
191
- return;
192
- const win = dom.getWin(ctx2);
193
- const picker = new win.EyeDropper();
194
- picker.open().then(({ sRGBHex }) => {
195
- const format = ctx2.valueAsColor.getColorSpace();
196
- const color = parseColor(sRGBHex).toFormat(format);
197
- setColor(ctx2, color);
198
- ctx2.onChangeEnd?.({ value: ctx2.value, valueAsColor: color });
199
- }).catch(() => void 0);
200
- },
201
- setActiveChannel(ctx2, evt) {
202
- ctx2.activeId = evt.id;
203
- if (evt.channel) {
204
- ctx2.activeChannel = evt.channel;
205
- }
206
- if (evt.orientation) {
207
- ctx2.activeOrientation = evt.orientation;
208
- }
209
- },
210
- clearActiveChannel(ctx2) {
211
- ctx2.activeChannel = null;
212
- ctx2.activeId = null;
213
- ctx2.activeOrientation = null;
214
- },
215
- setAreaColorFromPoint(ctx2, evt) {
216
- const { xChannel, yChannel } = evt.channel || ctx2.activeChannel;
217
- const percent = dom.getAreaValueFromPoint(ctx2, evt.point);
218
- const { getColorFromPoint } = getChannelDetails(ctx2.valueAsColor, xChannel, yChannel);
219
- const color = getColorFromPoint(percent.x, percent.y);
220
- if (!color)
221
- return;
222
- setColor(ctx2, color);
223
- },
224
- setChannelColorFromPoint(ctx2, evt) {
225
- const channel = evt.channel || ctx2.activeId;
226
- const percent = dom.getChannelSliderValueFromPoint(ctx2, evt.point, channel);
227
- const { minValue, maxValue, step } = ctx2.valueAsColor.getChannelRange(channel);
228
- const orientation = ctx2.activeOrientation || "horizontal";
229
- const point = orientation === "horizontal" ? percent.x : percent.y;
230
- const channelValue = getPercentValue(point, minValue, maxValue, step);
231
- const value = snapValueToStep(channelValue - step, minValue, maxValue, step);
232
- const newColor = ctx2.valueAsColor.withChannelValue(channel, value);
233
- setColor(ctx2, newColor);
234
- },
235
- setValue(ctx2, evt) {
236
- setColor(ctx2, evt.value);
237
- },
238
- setValueAsColor(ctx2) {
239
- try {
240
- const color = parseColor(ctx2.value);
241
- if (color.isEqual(ctx2.valueAsColor))
242
- return;
243
- ctx2.valueAsColor = color;
244
- } catch {
245
- }
246
- },
247
- syncChannelInputs(ctx2) {
248
- const inputs = dom.getChannelInputEls(ctx2);
249
- inputs.forEach((input) => {
250
- const channel = input.getAttribute("data-channel");
251
- if (!channel)
252
- return;
253
- const value = getChannelInputValue(ctx2.valueAsColor, channel);
254
- input.value = value.toString();
255
- });
256
- },
257
- setChannelColorFromInput(ctx2, evt) {
258
- const { channel, isTextField, value } = evt;
259
- try {
260
- const format = ctx2.valueAsColor.getColorSpace();
261
- const newColor = isTextField ? parseColor(value).toFormat(format) : ctx2.valueAsColor.withChannelValue(channel, value);
262
- setColor(ctx2, newColor);
263
- } catch {
264
- const input = dom.getChannelInputEl(ctx2, channel);
265
- if (!input)
266
- return;
267
- input.value = getChannelInputValue(ctx2.valueAsColor, channel);
268
- }
269
- },
270
- incrementChannel(ctx2, evt) {
271
- const { minValue, maxValue, step } = ctx2.valueAsColor.getChannelRange(evt.channel);
272
- const channelValue = ctx2.valueAsColor.getChannelValue(evt.channel);
273
- const value = snapValueToStep(channelValue + evt.step, minValue, maxValue, step);
274
- const newColor = ctx2.valueAsColor.withChannelValue(evt.channel, clampValue(value, minValue, maxValue));
275
- setColor(ctx2, newColor);
276
- },
277
- decrementChannel(ctx2, evt) {
278
- const { minValue, maxValue, step } = ctx2.valueAsColor.getChannelRange(evt.channel);
279
- const channelValue = ctx2.valueAsColor.getChannelValue(evt.channel);
280
- const value = snapValueToStep(channelValue - evt.step, minValue, maxValue, step);
281
- const newColor = ctx2.valueAsColor.withChannelValue(evt.channel, clampValue(value, minValue, maxValue));
282
- setColor(ctx2, newColor);
283
- },
284
- incrementXChannel(ctx2, evt) {
285
- const { xChannel, yChannel } = evt.channel;
286
- const { incrementX } = getChannelDetails(ctx2.valueAsColor, xChannel, yChannel);
287
- const newColor = ctx2.valueAsColor.withChannelValue(xChannel, incrementX(evt.step));
288
- setColor(ctx2, newColor);
289
- },
290
- decrementXChannel(ctx2, evt) {
291
- const { xChannel, yChannel } = evt.channel;
292
- const { decrementX } = getChannelDetails(ctx2.valueAsColor, xChannel, yChannel);
293
- const newColor = ctx2.valueAsColor.withChannelValue(xChannel, decrementX(evt.step));
294
- setColor(ctx2, newColor);
295
- },
296
- incrementYChannel(ctx2, evt) {
297
- const { xChannel, yChannel } = evt.channel;
298
- const { incrementY } = getChannelDetails(ctx2.valueAsColor, xChannel, yChannel);
299
- const newColor = ctx2.valueAsColor.withChannelValue(yChannel, incrementY(evt.step));
300
- setColor(ctx2, newColor);
301
- },
302
- decrementYChannel(ctx2, evt) {
303
- const { xChannel, yChannel } = evt.channel;
304
- const { decrementY } = getChannelDetails(ctx2.valueAsColor, xChannel, yChannel);
305
- const newColor = ctx2.valueAsColor.withChannelValue(yChannel, decrementY(evt.step));
306
- setColor(ctx2, newColor);
307
- },
308
- setChannelToMax(ctx2, evt) {
309
- const { maxValue } = ctx2.valueAsColor.getChannelRange(evt.channel);
310
- const newColor = ctx2.valueAsColor.withChannelValue(evt.channel, maxValue);
311
- setColor(ctx2, newColor);
312
- },
313
- setChannelToMin(ctx2, evt) {
314
- const { minValue } = ctx2.valueAsColor.getChannelRange(evt.channel);
315
- const newColor = ctx2.valueAsColor.withChannelValue(evt.channel, minValue);
316
- setColor(ctx2, newColor);
317
- },
318
- invokeOnChangeEnd(ctx2) {
319
- ctx2.onChangeEnd?.({ value: ctx2.value, valueAsColor: ctx2.valueAsColor });
320
- },
321
- invokeOnChange(ctx2) {
322
- ctx2.onChange?.({ value: ctx2.value, valueAsColor: ctx2.valueAsColor });
323
- },
324
- focusAreaThumb(ctx2) {
325
- raf(() => {
326
- dom.getAreaThumbEl(ctx2)?.focus({ preventScroll: true });
327
- });
328
- },
329
- focusChannelThumb(ctx2, evt) {
330
- raf(() => {
331
- dom.getChannelSliderThumbEl(ctx2, evt.channel)?.focus({ preventScroll: true });
332
- });
333
- }
334
- }
335
- }
336
- );
337
- }
338
- var setColor = (ctx, color) => {
339
- ctx.value = color.toString("css");
340
- ctx.valueAsColor = color;
341
- };
342
-
343
- export {
344
- machine
345
- };
@@ -1,132 +0,0 @@
1
- // src/utils/generate-format-background.ts
2
- var generateRGB_R = (orientation, dir, zValue) => {
3
- const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
4
- const result = {
5
- areaStyles: {
6
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
7
- },
8
- areaGradientStyles: {
9
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
10
- WebkitMaskImage: maskImage,
11
- maskImage
12
- }
13
- };
14
- return result;
15
- };
16
- var generateRGB_G = (orientation, dir, zValue) => {
17
- const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
18
- const result = {
19
- areaStyles: {
20
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
21
- },
22
- areaGradientStyles: {
23
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
24
- WebkitMaskImage: maskImage,
25
- maskImage
26
- }
27
- };
28
- return result;
29
- };
30
- var generateRGB_B = (orientation, dir, zValue) => {
31
- const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
32
- const result = {
33
- areaStyles: {
34
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
35
- },
36
- areaGradientStyles: {
37
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
38
- WebkitMaskImage: maskImage,
39
- maskImage
40
- }
41
- };
42
- return result;
43
- };
44
- var generateHSL_H = (orientation, dir, zValue) => {
45
- const result = {
46
- areaStyles: {},
47
- areaGradientStyles: {
48
- background: [
49
- `linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,
50
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
51
- `hsl(${zValue}, 100%, 50%)`
52
- ].join(",")
53
- }
54
- };
55
- return result;
56
- };
57
- var generateHSL_S = (orientation, dir, alphaValue) => {
58
- const result = {
59
- areaStyles: {},
60
- areaGradientStyles: {
61
- background: [
62
- `linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,
63
- `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
64
- "hsl(0, 0%, 50%)"
65
- ].join(",")
66
- }
67
- };
68
- return result;
69
- };
70
- var generateHSL_L = (orientation, dir, zValue) => {
71
- const result = {
72
- areaStyles: {},
73
- areaGradientStyles: {
74
- backgroundImage: [
75
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
76
- `linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`
77
- ].join(",")
78
- }
79
- };
80
- return result;
81
- };
82
- var generateHSB_H = (orientation, dir, zValue) => {
83
- const result = {
84
- areaStyles: {},
85
- areaGradientStyles: {
86
- background: [
87
- `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
88
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
89
- `hsl(${zValue}, 100%, 50%)`
90
- ].join(",")
91
- }
92
- };
93
- return result;
94
- };
95
- var generateHSB_S = (orientation, dir, alphaValue) => {
96
- const result = {
97
- areaStyles: {},
98
- areaGradientStyles: {
99
- background: [
100
- `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
101
- `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
102
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
103
- ].join(",")
104
- }
105
- };
106
- return result;
107
- };
108
- var generateHSB_B = (orientation, dir, alphaValue) => {
109
- const result = {
110
- areaStyles: {},
111
- areaGradientStyles: {
112
- background: [
113
- `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
114
- `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
115
- "#000"
116
- ].join(",")
117
- }
118
- };
119
- return result;
120
- };
121
-
122
- export {
123
- generateRGB_R,
124
- generateRGB_G,
125
- generateRGB_B,
126
- generateHSL_H,
127
- generateHSL_S,
128
- generateHSL_L,
129
- generateHSB_H,
130
- generateHSB_S,
131
- generateHSB_B
132
- };
@@ -1,35 +0,0 @@
1
- // src/color-picker.dom.ts
2
- import { getRelativePoint } from "@zag-js/dom-event";
3
- import { createScope, queryAll } from "@zag-js/dom-query";
4
- var dom = createScope({
5
- getContentId: (ctx) => ctx.ids?.content ?? `color-picker:${ctx.id}:content`,
6
- getAreaId: (ctx) => ctx.ids?.area ?? `color-picker:${ctx.id}:area`,
7
- getAreaGradientId: (ctx) => ctx.ids?.areaGradient ?? `color-picker:${ctx.id}:area-gradient`,
8
- getAreaThumbId: (ctx) => ctx.ids?.areaThumb ?? `color-picker:${ctx.id}:area-thumb`,
9
- getChannelSliderTrackId: (ctx, channel) => ctx.ids?.channelSliderTrack?.(channel) ?? `color-picker:${ctx.id}:slider-track:${channel}`,
10
- getChannelInputId: (ctx, channel) => ctx.ids?.channelInput?.(channel) ?? `color-picker:${ctx.id}:input:${channel}`,
11
- getChannelSliderThumbId: (ctx, channel) => ctx.ids?.channelSliderThumb?.(channel) ?? `color-picker:${ctx.id}:slider-thumb:${channel}`,
12
- getContentEl: (ctx) => dom.queryById(ctx, dom.getContentId(ctx)),
13
- getAreaThumbEl: (ctx) => dom.queryById(ctx, dom.getAreaThumbId(ctx)),
14
- getChannelSliderThumbEl: (ctx, channel) => dom.queryById(ctx, dom.getChannelSliderThumbId(ctx, channel)),
15
- getChannelInputEl: (ctx, channel) => dom.queryById(ctx, dom.getChannelInputId(ctx, channel)),
16
- getAreaEl: (ctx) => dom.queryById(ctx, dom.getAreaId(ctx)),
17
- getAreaValueFromPoint(ctx, point) {
18
- const { percent } = getRelativePoint(point, dom.getAreaEl(ctx));
19
- return percent;
20
- },
21
- getChannelSliderTrackEl: (ctx, channel) => {
22
- return dom.queryById(ctx, dom.getChannelSliderTrackId(ctx, channel));
23
- },
24
- getChannelSliderValueFromPoint(ctx, point, channel) {
25
- const { percent } = getRelativePoint(point, dom.getChannelSliderTrackEl(ctx, channel));
26
- return percent;
27
- },
28
- getChannelInputEls: (ctx) => {
29
- return queryAll(dom.getContentEl(ctx), "input[data-channel]");
30
- }
31
- });
32
-
33
- export {
34
- dom
35
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/color-picker.types.ts
17
- var color_picker_types_exports = {};
18
- module.exports = __toCommonJS(color_picker_types_exports);
File without changes