@zag-js/color-picker 0.0.0-dev-20230414151834

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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/dist/chunk-2ERX54SV.mjs +25 -0
  4. package/dist/chunk-3XH465XT.mjs +42 -0
  5. package/dist/chunk-75JXJMB5.mjs +22 -0
  6. package/dist/chunk-ACSV4TXB.mjs +35 -0
  7. package/dist/chunk-J3XCPS5T.mjs +365 -0
  8. package/dist/chunk-JNBNPPMF.mjs +24 -0
  9. package/dist/chunk-KLLIOTK6.mjs +55 -0
  10. package/dist/chunk-KO4TBUXB.mjs +74 -0
  11. package/dist/chunk-OY3B7NXA.mjs +132 -0
  12. package/dist/chunk-ZBNUATFY.mjs +344 -0
  13. package/dist/color-picker.anatomy.d.ts +6 -0
  14. package/dist/color-picker.anatomy.js +47 -0
  15. package/dist/color-picker.anatomy.mjs +8 -0
  16. package/dist/color-picker.connect.d.ts +27 -0
  17. package/dist/color-picker.connect.js +731 -0
  18. package/dist/color-picker.connect.mjs +14 -0
  19. package/dist/color-picker.dom.d.ts +62 -0
  20. package/dist/color-picker.dom.js +59 -0
  21. package/dist/color-picker.dom.mjs +6 -0
  22. package/dist/color-picker.machine.d.ts +8 -0
  23. package/dist/color-picker.machine.js +456 -0
  24. package/dist/color-picker.machine.mjs +9 -0
  25. package/dist/color-picker.types.d.ts +88 -0
  26. package/dist/color-picker.types.js +18 -0
  27. package/dist/color-picker.types.mjs +0 -0
  28. package/dist/index.d.ts +6 -0
  29. package/dist/index.js +1066 -0
  30. package/dist/index.mjs +18 -0
  31. package/dist/utils/generate-format-background.d.ts +68 -0
  32. package/dist/utils/generate-format-background.js +164 -0
  33. package/dist/utils/generate-format-background.mjs +22 -0
  34. package/dist/utils/get-channel-details.d.ts +23 -0
  35. package/dist/utils/get-channel-details.js +79 -0
  36. package/dist/utils/get-channel-details.mjs +6 -0
  37. package/dist/utils/get-channel-display-color.d.ts +5 -0
  38. package/dist/utils/get-channel-display-color.js +48 -0
  39. package/dist/utils/get-channel-display-color.mjs +6 -0
  40. package/dist/utils/get-channel-input-value.d.ts +10 -0
  41. package/dist/utils/get-channel-input-value.js +50 -0
  42. package/dist/utils/get-channel-input-value.mjs +8 -0
  43. package/dist/utils/get-color-area-gradient.d.ts +11 -0
  44. package/dist/utils/get-color-area-gradient.js +209 -0
  45. package/dist/utils/get-color-area-gradient.mjs +7 -0
  46. package/dist/utils/get-slider-background.d.ts +8 -0
  47. package/dist/utils/get-slider-background.js +66 -0
  48. package/dist/utils/get-slider-background.mjs +6 -0
  49. package/package.json +65 -0
@@ -0,0 +1,88 @@
1
+ import { ColorChannel, Color, ColorAxes } from '@zag-js/color-utils';
2
+ import { StateMachine } from '@zag-js/core';
3
+ import { Orientation, RequiredBy, CommonProperties, Context } from '@zag-js/types';
4
+
5
+ type ChannelProps = {
6
+ channel: ColorChannel;
7
+ orientation?: Orientation;
8
+ };
9
+ type ExtendedColorChannel = ColorChannel | "hex" | "css";
10
+ type ChannelInputProps = {
11
+ channel: ExtendedColorChannel;
12
+ orientation?: Orientation;
13
+ };
14
+ type AreaProps = {
15
+ xChannel: ColorChannel;
16
+ yChannel: ColorChannel;
17
+ };
18
+ type SwatchProps = {
19
+ readOnly?: boolean;
20
+ value: string | Color;
21
+ };
22
+ type ChangeDetails = {
23
+ value: string;
24
+ valueAsColor: Color;
25
+ };
26
+ type PublicContext = CommonProperties & {
27
+ /**
28
+ * The direction of the color picker
29
+ */
30
+ dir: "ltr" | "rtl";
31
+ /**
32
+ * The current color value
33
+ */
34
+ value: string;
35
+ /**
36
+ * Whether the color picker is disabled
37
+ */
38
+ disabled?: boolean;
39
+ /**
40
+ * Whether the color picker is read-only
41
+ */
42
+ readOnly?: boolean;
43
+ /**
44
+ * Handler that is called when the value changes, as the user drags.
45
+ */
46
+ onChange?: (details: ChangeDetails) => void;
47
+ /**
48
+ * Handler that is called when the user stops dragging.
49
+ */
50
+ onChangeEnd?: (details: ChangeDetails) => void;
51
+ };
52
+ type PrivateContext = Context<{
53
+ /**
54
+ * The id of the thumb that is currently being dragged
55
+ */
56
+ activeId: string | null;
57
+ /**
58
+ * The color value as a Color object
59
+ */
60
+ valueAsColor: Color;
61
+ /**
62
+ * The channel that is currently being interacted with
63
+ */
64
+ activeChannel: Partial<ColorAxes> | null;
65
+ /**
66
+ * The orientation of the channel that is currently being interacted with
67
+ */
68
+ activeOrientation: Orientation | null;
69
+ }>;
70
+ type ComputedContext = Readonly<{
71
+ /**
72
+ * Whether the color picker is in RTL mode
73
+ */
74
+ isRtl: boolean;
75
+ /**
76
+ * Whether the color picker is interactive
77
+ */
78
+ isInteractive: boolean;
79
+ }>;
80
+ type UserDefinedContext = RequiredBy<PublicContext, "id">;
81
+ type MachineContext = PublicContext & PrivateContext & ComputedContext;
82
+ type MachineState = {
83
+ value: "idle" | "focused" | "dragging";
84
+ };
85
+ type State = StateMachine.State<MachineContext, MachineState>;
86
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
87
+
88
+ export { AreaProps, ChannelInputProps, ChannelProps, ExtendedColorChannel, MachineContext, MachineState, Send, State, SwatchProps, UserDefinedContext };
@@ -0,0 +1,18 @@
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
@@ -0,0 +1,6 @@
1
+ export { connect } from './color-picker.connect.js';
2
+ export { machine } from './color-picker.machine.js';
3
+ export { UserDefinedContext as Context } from './color-picker.types.js';
4
+ import '@zag-js/color-utils';
5
+ import '@zag-js/types';
6
+ import '@zag-js/core';