@trackunit/ui-design-tokens 1.0.0 → 1.0.3

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/index.cjs.js CHANGED
@@ -103,16 +103,15 @@ function rgbToHex(r, g, b) {
103
103
  * @returns {string} HEX color
104
104
  */
105
105
  const getHEX = (variable) => {
106
- var _a, _b, _c, _d, _e;
107
106
  const regex = /rgb\(var\((.*?)\) \/ var\(--tw-bg-opacity\)\)/g;
108
107
  const root = document.documentElement;
109
108
  const match = regex.exec(variable);
110
- const colorValue = getComputedStyle(root).getPropertyValue((_b = (_a = match === null || match === void 0 ? void 0 : match[1]) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : variable);
109
+ const colorValue = getComputedStyle(root).getPropertyValue(match?.[1]?.trim() ?? variable);
111
110
  const RGB = colorValue
112
111
  .trim()
113
112
  .split(" ")
114
113
  .map(channel => Number(channel));
115
- return rgbToHex((_c = RGB[0]) !== null && _c !== void 0 ? _c : NaN, (_d = RGB[1]) !== null && _d !== void 0 ? _d : NaN, (_e = RGB[2]) !== null && _e !== void 0 ? _e : NaN);
114
+ return rgbToHex(RGB[0] ?? NaN, RGB[1] ?? NaN, RGB[2] ?? NaN);
116
115
  };
117
116
 
118
117
  /**
@@ -594,13 +593,13 @@ Returns the color value in CSS or HEX format for a given theme color and variant
594
593
  @returns {string} - Returns a string containing the color value in CSS or HEX format for the provided arguments.
595
594
  */
596
595
  function color(ColorKey, arg2, arg3) {
597
- var _a, _b;
598
596
  const colorName = themeColors[ColorKey].name;
599
597
  const colorVariants = themeColors[ColorKey].variants;
600
598
  // defaultVariant or 600 or the "middel" value available.
601
- const defaultVariant = (_b = (_a = themeColors[ColorKey].defaultVariant) !== null && _a !== void 0 ? _a :
602
- // @ts-ignore - suppressImplicitAnyIndexErrors
603
- (colorVariants[600] && 600)) !== null && _b !== void 0 ? _b : Object.keys(colorVariants)[Math.floor(Object.keys(colorVariants).length / 2)];
599
+ const defaultVariant = themeColors[ColorKey].defaultVariant ??
600
+ // @ts-ignore - suppressImplicitAnyIndexErrors
601
+ (colorVariants[600] && 600) ??
602
+ Object.keys(colorVariants)[Math.floor(Object.keys(colorVariants).length / 2)];
604
603
  let variant = defaultVariant;
605
604
  let output = "CSS";
606
605
  if (isOutputOption(arg2)) {
package/index.esm.js CHANGED
@@ -101,16 +101,15 @@ function rgbToHex(r, g, b) {
101
101
  * @returns {string} HEX color
102
102
  */
103
103
  const getHEX = (variable) => {
104
- var _a, _b, _c, _d, _e;
105
104
  const regex = /rgb\(var\((.*?)\) \/ var\(--tw-bg-opacity\)\)/g;
106
105
  const root = document.documentElement;
107
106
  const match = regex.exec(variable);
108
- const colorValue = getComputedStyle(root).getPropertyValue((_b = (_a = match === null || match === void 0 ? void 0 : match[1]) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : variable);
107
+ const colorValue = getComputedStyle(root).getPropertyValue(match?.[1]?.trim() ?? variable);
109
108
  const RGB = colorValue
110
109
  .trim()
111
110
  .split(" ")
112
111
  .map(channel => Number(channel));
113
- return rgbToHex((_c = RGB[0]) !== null && _c !== void 0 ? _c : NaN, (_d = RGB[1]) !== null && _d !== void 0 ? _d : NaN, (_e = RGB[2]) !== null && _e !== void 0 ? _e : NaN);
112
+ return rgbToHex(RGB[0] ?? NaN, RGB[1] ?? NaN, RGB[2] ?? NaN);
114
113
  };
115
114
 
116
115
  /**
@@ -592,13 +591,13 @@ Returns the color value in CSS or HEX format for a given theme color and variant
592
591
  @returns {string} - Returns a string containing the color value in CSS or HEX format for the provided arguments.
593
592
  */
594
593
  function color(ColorKey, arg2, arg3) {
595
- var _a, _b;
596
594
  const colorName = themeColors[ColorKey].name;
597
595
  const colorVariants = themeColors[ColorKey].variants;
598
596
  // defaultVariant or 600 or the "middel" value available.
599
- const defaultVariant = (_b = (_a = themeColors[ColorKey].defaultVariant) !== null && _a !== void 0 ? _a :
600
- // @ts-ignore - suppressImplicitAnyIndexErrors
601
- (colorVariants[600] && 600)) !== null && _b !== void 0 ? _b : Object.keys(colorVariants)[Math.floor(Object.keys(colorVariants).length / 2)];
597
+ const defaultVariant = themeColors[ColorKey].defaultVariant ??
598
+ // @ts-ignore - suppressImplicitAnyIndexErrors
599
+ (colorVariants[600] && 600) ??
600
+ Object.keys(colorVariants)[Math.floor(Object.keys(colorVariants).length / 2)];
602
601
  let variant = defaultVariant;
603
602
  let output = "CSS";
604
603
  if (isOutputOption(arg2)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/ui-design-tokens",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {