@zag-js/color-utils 1.32.0 → 1.33.0

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 CHANGED
@@ -24,8 +24,8 @@ interface ColorType {
24
24
  toFormat(format: ColorFormat): ColorType;
25
25
  /** Converts the color to a JSON object. */
26
26
  toJSON(): Record<string, number>;
27
- /** Converts the color to a string in the given format. */
28
- toString(format: ColorStringFormat): string;
27
+ /** Converts the color to a string in the given format. Defaults to CSS format. */
28
+ toString(format?: ColorStringFormat): string;
29
29
  /** Converts the color to hex, and returns an integer representation. */
30
30
  toHexInt(): number;
31
31
  /**
@@ -87,7 +87,7 @@ interface ColorType {
87
87
  declare abstract class Color implements ColorType {
88
88
  abstract toFormat(format: ColorFormat): ColorType;
89
89
  abstract toJSON(): Record<string, number>;
90
- abstract toString(format: ColorStringFormat): string;
90
+ abstract toString(format?: ColorStringFormat): string;
91
91
  abstract clone(): ColorType;
92
92
  abstract getChannelRange(channel: ColorChannel): ColorChannelRange;
93
93
  abstract getFormat(): ColorFormat;
package/dist/index.d.ts CHANGED
@@ -24,8 +24,8 @@ interface ColorType {
24
24
  toFormat(format: ColorFormat): ColorType;
25
25
  /** Converts the color to a JSON object. */
26
26
  toJSON(): Record<string, number>;
27
- /** Converts the color to a string in the given format. */
28
- toString(format: ColorStringFormat): string;
27
+ /** Converts the color to a string in the given format. Defaults to CSS format. */
28
+ toString(format?: ColorStringFormat): string;
29
29
  /** Converts the color to hex, and returns an integer representation. */
30
30
  toHexInt(): number;
31
31
  /**
@@ -87,7 +87,7 @@ interface ColorType {
87
87
  declare abstract class Color implements ColorType {
88
88
  abstract toFormat(format: ColorFormat): ColorType;
89
89
  abstract toJSON(): Record<string, number>;
90
- abstract toString(format: ColorStringFormat): string;
90
+ abstract toString(format?: ColorStringFormat): string;
91
91
  abstract clone(): ColorType;
92
92
  abstract getChannelRange(channel: ColorChannel): ColorChannelRange;
93
93
  abstract getFormat(): ColorFormat;
package/dist/index.js CHANGED
@@ -268,7 +268,7 @@ var _RGBColor = class _RGBColor extends Color {
268
268
  }
269
269
  return colors.length < 3 ? void 0 : new _RGBColor(colors[0], colors[1], colors[2], colors[3] ?? 1);
270
270
  }
271
- toString(format) {
271
+ toString(format = "css") {
272
272
  switch (format) {
273
273
  case "hex":
274
274
  return "#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0")).toUpperCase();
@@ -438,7 +438,7 @@ var _HSLColor = class _HSLColor extends Color {
438
438
  return new _HSLColor(utils.mod(h, 360), utils.clampValue(s, 0, 100), utils.clampValue(l, 0, 100), utils.clampValue(a ?? 1, 0, 1));
439
439
  }
440
440
  }
441
- toString(format) {
441
+ toString(format = "css") {
442
442
  switch (format) {
443
443
  case "hex":
444
444
  return this.toRGB().toString("hex");
@@ -570,7 +570,7 @@ var _HSBColor = class _HSBColor extends Color {
570
570
  return new _HSBColor(utils.mod(h, 360), utils.clampValue(s, 0, 100), utils.clampValue(b, 0, 100), utils.clampValue(a ?? 1, 0, 1));
571
571
  }
572
572
  }
573
- toString(format) {
573
+ toString(format = "css") {
574
574
  switch (format) {
575
575
  case "css":
576
576
  return this.toHSL().toString("css");
package/dist/index.mjs CHANGED
@@ -266,7 +266,7 @@ var _RGBColor = class _RGBColor extends Color {
266
266
  }
267
267
  return colors.length < 3 ? void 0 : new _RGBColor(colors[0], colors[1], colors[2], colors[3] ?? 1);
268
268
  }
269
- toString(format) {
269
+ toString(format = "css") {
270
270
  switch (format) {
271
271
  case "hex":
272
272
  return "#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0")).toUpperCase();
@@ -436,7 +436,7 @@ var _HSLColor = class _HSLColor extends Color {
436
436
  return new _HSLColor(mod(h, 360), clampValue(s, 0, 100), clampValue(l, 0, 100), clampValue(a ?? 1, 0, 1));
437
437
  }
438
438
  }
439
- toString(format) {
439
+ toString(format = "css") {
440
440
  switch (format) {
441
441
  case "hex":
442
442
  return this.toRGB().toString("hex");
@@ -568,7 +568,7 @@ var _HSBColor = class _HSBColor extends Color {
568
568
  return new _HSBColor(mod(h, 360), clampValue(s, 0, 100), clampValue(b, 0, 100), clampValue(a ?? 1, 0, 1));
569
569
  }
570
570
  }
571
- toString(format) {
571
+ toString(format = "css") {
572
572
  switch (format) {
573
573
  case "css":
574
574
  return this.toHSL().toString("css");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/color-utils",
3
- "version": "1.32.0",
3
+ "version": "1.33.0",
4
4
  "description": "Color utilities for zag.js",
5
5
  "keywords": [
6
6
  "js",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "clean-package": "../../../clean-package.config.json",
26
26
  "dependencies": {
27
- "@zag-js/utils": "1.32.0"
27
+ "@zag-js/utils": "1.33.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "clean-package": "2.2.0"