@zag-js/color-picker 1.43.0 → 2.0.0-next.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.
Files changed (49) hide show
  1. package/dist/color-picker.anatomy.d.mts +2 -2
  2. package/dist/color-picker.anatomy.d.ts +2 -2
  3. package/dist/color-picker.anatomy.js +1 -0
  4. package/dist/color-picker.anatomy.mjs +1 -0
  5. package/dist/color-picker.connect.d.mts +1 -0
  6. package/dist/color-picker.connect.d.ts +1 -0
  7. package/dist/color-picker.connect.js +130 -58
  8. package/dist/color-picker.connect.mjs +139 -60
  9. package/dist/color-picker.dom.js +23 -22
  10. package/dist/color-picker.dom.mjs +23 -22
  11. package/dist/color-picker.machine.d.mts +1 -0
  12. package/dist/color-picker.machine.d.ts +1 -0
  13. package/dist/color-picker.machine.js +43 -16
  14. package/dist/color-picker.machine.mjs +43 -16
  15. package/dist/color-picker.props.d.mts +1 -0
  16. package/dist/color-picker.props.d.ts +1 -0
  17. package/dist/color-picker.types.d.mts +115 -3
  18. package/dist/color-picker.types.d.ts +115 -3
  19. package/dist/index.d.mts +2 -1
  20. package/dist/index.d.ts +2 -1
  21. package/dist/utils/get-area-format.d.mts +6 -0
  22. package/dist/utils/get-area-format.d.ts +6 -0
  23. package/dist/utils/get-area-format.js +37 -0
  24. package/dist/utils/get-area-format.mjs +12 -0
  25. package/dist/utils/get-channel-display-color.d.mts +2 -1
  26. package/dist/utils/get-channel-display-color.d.ts +2 -1
  27. package/dist/utils/get-channel-display-color.js +7 -0
  28. package/dist/utils/get-channel-display-color.mjs +7 -0
  29. package/dist/utils/get-channel-input-value.d.mts +1 -0
  30. package/dist/utils/get-channel-input-value.d.ts +1 -0
  31. package/dist/utils/get-channel-input-value.js +39 -8
  32. package/dist/utils/get-channel-input-value.mjs +39 -8
  33. package/dist/utils/get-gamut-overlay-path.d.mts +33 -0
  34. package/dist/utils/get-gamut-overlay-path.d.ts +33 -0
  35. package/dist/utils/get-gamut-overlay-path.js +81 -0
  36. package/dist/utils/get-gamut-overlay-path.mjs +55 -0
  37. package/dist/utils/get-gamut-overlay-path.test.d.mts +2 -0
  38. package/dist/utils/get-gamut-overlay-path.test.d.ts +2 -0
  39. package/dist/utils/get-gamut-overlay-path.test.js +35 -0
  40. package/dist/utils/get-gamut-overlay-path.test.mjs +33 -0
  41. package/dist/utils/get-slider-background.d.mts +1 -0
  42. package/dist/utils/get-slider-background.d.ts +1 -0
  43. package/dist/utils/get-slider-background.js +16 -1
  44. package/dist/utils/get-slider-background.mjs +16 -1
  45. package/dist/utils/is-srgb-gamut.d.mts +6 -0
  46. package/dist/utils/is-srgb-gamut.d.ts +6 -0
  47. package/dist/utils/is-srgb-gamut.js +33 -0
  48. package/dist/utils/is-srgb-gamut.mjs +8 -0
  49. package/package.json +9 -9
@@ -12,8 +12,14 @@ var getSliderBackground = (props) => {
12
12
  const { channel, value, dir, orientation } = props;
13
13
  const bgDirection = getSliderBackgroundDirection(orientation, dir);
14
14
  const { minValue, maxValue } = value.getChannelRange(channel);
15
+ const fmt = value.getFormat();
15
16
  switch (channel) {
16
17
  case "hue":
18
+ if (fmt === "oklch") {
19
+ const L = value.getChannelValue("lightness");
20
+ const C = value.getChannelValue("chroma");
21
+ return `linear-gradient(to ${bgDirection} in oklch increasing hue, oklch(${L} ${C} 0), oklch(${L} ${C} 360))`;
22
+ }
17
23
  return `linear-gradient(to ${bgDirection}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;
18
24
  case "lightness": {
19
25
  let start = value.withChannelValue(channel, minValue).toString("css");
@@ -26,9 +32,18 @@ var getSliderBackground = (props) => {
26
32
  case "red":
27
33
  case "green":
28
34
  case "blue":
29
- case "alpha": {
35
+ case "alpha":
36
+ case "a":
37
+ case "b":
38
+ case "chroma": {
30
39
  let start = value.withChannelValue(channel, minValue).toString("css");
31
40
  let end = value.withChannelValue(channel, maxValue).toString("css");
41
+ if (fmt === "oklab" && (channel === "a" || channel === "b")) {
42
+ return `linear-gradient(to ${bgDirection} in oklab, ${start}, ${end})`;
43
+ }
44
+ if (fmt === "oklch" && channel === "chroma") {
45
+ return `linear-gradient(to ${bgDirection} in oklch, ${start}, ${end})`;
46
+ }
32
47
  return `linear-gradient(to ${bgDirection}, ${start}, ${end})`;
33
48
  }
34
49
  default:
@@ -0,0 +1,6 @@
1
+ import { Color } from '@zag-js/color-utils';
2
+
3
+ /** Whether the color lies inside the sRGB cube (after conversion from the working space). */
4
+ declare function isSrgbGamutColor(color: Color): boolean;
5
+
6
+ export { isSrgbGamutColor };
@@ -0,0 +1,6 @@
1
+ import { Color } from '@zag-js/color-utils';
2
+
3
+ /** Whether the color lies inside the sRGB cube (after conversion from the working space). */
4
+ declare function isSrgbGamutColor(color: Color): boolean;
5
+
6
+ export { isSrgbGamutColor };
@@ -0,0 +1,33 @@
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 __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/is-srgb-gamut.ts
21
+ var is_srgb_gamut_exports = {};
22
+ __export(is_srgb_gamut_exports, {
23
+ isSrgbGamutColor: () => isSrgbGamutColor
24
+ });
25
+ module.exports = __toCommonJS(is_srgb_gamut_exports);
26
+ var import_color_utils = require("@zag-js/color-utils");
27
+ function isSrgbGamutColor(color) {
28
+ return (0, import_color_utils.isInSrgbGamut)(color);
29
+ }
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ isSrgbGamutColor
33
+ });
@@ -0,0 +1,8 @@
1
+ // src/utils/is-srgb-gamut.ts
2
+ import { isInSrgbGamut } from "@zag-js/color-utils";
3
+ function isSrgbGamutColor(color) {
4
+ return isInSrgbGamut(color);
5
+ }
6
+ export {
7
+ isSrgbGamutColor
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/color-picker",
3
- "version": "1.43.0",
3
+ "version": "2.0.0-next.1",
4
4
  "description": "Core logic for the color-picker widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -30,14 +30,14 @@
30
30
  "url": "https://github.com/chakra-ui/zag/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@zag-js/core": "1.43.0",
34
- "@zag-js/anatomy": "1.43.0",
35
- "@zag-js/dom-query": "1.43.0",
36
- "@zag-js/dismissable": "1.43.0",
37
- "@zag-js/utils": "1.43.0",
38
- "@zag-js/color-utils": "1.43.0",
39
- "@zag-js/popper": "1.43.0",
40
- "@zag-js/types": "1.43.0"
33
+ "@zag-js/core": "2.0.0-next.1",
34
+ "@zag-js/anatomy": "2.0.0-next.1",
35
+ "@zag-js/dom-query": "2.0.0-next.1",
36
+ "@zag-js/dismissable": "2.0.0-next.1",
37
+ "@zag-js/utils": "2.0.0-next.1",
38
+ "@zag-js/color-utils": "2.0.0-next.1",
39
+ "@zag-js/popper": "2.0.0-next.1",
40
+ "@zag-js/types": "2.0.0-next.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "clean-package": "2.2.0"