@uni-design-system/uni-core 0.0.28 → 0.0.29

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.
@@ -1,3 +1,4 @@
1
- import { HSLA, UniColor } from './color.model';
2
- export declare function hslaToString({ hue, saturation, lightness, alpha }: HSLA): string;
1
+ import { HSL, HSLA, RGB, UniColor } from './color.model';
2
+ export declare function HSLAToString({ hue, saturation, lightness, alpha }: HSLA): string;
3
3
  export declare function uniColor({ role, category, alpha }: UniColor): string;
4
+ export declare const RGBToHSL: ({ red, green, blue }: RGB) => HSL;
@@ -1,17 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uniColor = exports.hslaToString = void 0;
3
+ exports.RGBToHSL = exports.uniColor = exports.HSLAToString = void 0;
4
4
  const color_records_1 = require("./color.records");
5
5
  const color_utils_1 = require("./color.utils");
6
- function hslaToString({ hue, saturation, lightness, alpha = 1 }) {
6
+ function HSLAToString({ hue, saturation, lightness, alpha = 1 }) {
7
7
  return `hsla(${hue}, ${saturation}%, ${lightness}%, ${alpha})`;
8
8
  }
9
- exports.hslaToString = hslaToString;
9
+ exports.HSLAToString = HSLAToString;
10
10
  function uniColor({ role, category, alpha = 1 }) {
11
11
  const hue = (0, color_utils_1.randomRangeValue)(color_records_1.RoleHues[role]);
12
12
  const saturation = (0, color_utils_1.randomRangeValue)(color_records_1.CategorySaturation[category]);
13
13
  const lightness = (0, color_utils_1.randomRangeValue)(color_records_1.CategoryLightness[category]);
14
- return hslaToString({ hue, saturation, lightness, alpha });
14
+ return HSLAToString({ hue, saturation, lightness, alpha });
15
15
  }
16
16
  exports.uniColor = uniColor;
17
+ const RGBToHSL = ({ red, green, blue }) => {
18
+ red /= 255;
19
+ green /= 255;
20
+ blue /= 255;
21
+ const l = Math.max(red, green, blue);
22
+ const s = l - Math.min(red, green, blue);
23
+ const h = s ? (l === red ? (green - blue) / s : l === green ? 2 + (blue - red) / s : 4 + (red - green) / s) : 0;
24
+ return {
25
+ hue: 60 * h < 0 ? 60 * h + 360 : 60 * h,
26
+ saturation: 100 * (s ? (l <= 0.5 ? s / (2 * l - s) : s / (2 - (2 * l - s))) : 0),
27
+ lightness: (100 * (2 * l - s)) / 2,
28
+ };
29
+ };
30
+ exports.RGBToHSL = RGBToHSL;
17
31
  //# sourceMappingURL=color.helper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"color.helper.js","sourceRoot":"","sources":["../../../../src/core/color/color.helper.ts"],"names":[],"mappings":";;;AACA,mDAAkF;AAClF,+CAAiD;AAEjD,SAAgB,YAAY,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,GAAG,CAAC,EAAQ;IAC1E,OAAO,QAAQ,GAAG,KAAK,UAAU,MAAM,SAAS,MAAM,KAAK,GAAG,CAAC;AACjE,CAAC;AAFD,oCAEC;AAED,SAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC,EAAY;IAC9D,MAAM,GAAG,GAAG,IAAA,8BAAgB,EAAC,wBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,MAAM,UAAU,GAAG,IAAA,8BAAgB,EAAC,kCAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClE,MAAM,SAAS,GAAG,IAAA,8BAAgB,EAAC,iCAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEhE,OAAO,YAAY,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7D,CAAC;AAND,4BAMC"}
1
+ {"version":3,"file":"color.helper.js","sourceRoot":"","sources":["../../../../src/core/color/color.helper.ts"],"names":[],"mappings":";;;AACA,mDAAkF;AAClF,+CAAiD;AAEjD,SAAgB,YAAY,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,GAAG,CAAC,EAAQ;IAC1E,OAAO,QAA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AAC,CAAC,CAAC;IAChH,OAAO;QACL,GAAG,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QACvC,UAAU,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChF,SAAS,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;KACnC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,QAAQ,YAYnB"}
@@ -1,4 +1,4 @@
1
- import { ColorCategory, ColorRole, ColorScheme, colorStyles } from './color.types';
1
+ import { ColorCategory, ColorRole, ColorScheme, ColorStyles } from './color.types';
2
2
  export interface UniColor {
3
3
  scheme: ColorScheme;
4
4
  role: ColorRole;
@@ -9,7 +9,7 @@ export interface Color {
9
9
  scheme?: ColorScheme;
10
10
  role?: ColorRole;
11
11
  category?: ColorCategory;
12
- style?: colorStyles;
12
+ style?: ColorStyles;
13
13
  GradientPosition?: GradientPosition;
14
14
  saturationRange?: Range;
15
15
  brightnessRangeMap?: Range;
@@ -26,9 +26,20 @@ export interface Range {
26
26
  high: number;
27
27
  default?: number;
28
28
  }
29
- export interface HSLA {
29
+ export interface HSL {
30
30
  hue?: number;
31
31
  saturation?: number;
32
32
  lightness?: number;
33
33
  alpha?: number;
34
34
  }
35
+ export interface HSLA extends HSL {
36
+ alpha?: number;
37
+ }
38
+ export interface RGB {
39
+ red: number;
40
+ green: number;
41
+ blue: number;
42
+ }
43
+ export interface RGBA extends RGB {
44
+ alpha: number;
45
+ }
@@ -1,6 +1,6 @@
1
1
  export declare type ColorScheme = 'monochromatic' | 'analogous' | 'complimentary' | 'splitComplimentary' | 'triadic';
2
2
  export declare type ColorCategory = 'jewel' | 'pastel' | 'earth' | 'neutral' | 'florescent' | 'shades';
3
- export declare type colorStyles = 'solid' | 'transparent' | 'gradient';
3
+ export declare type ColorStyles = 'solid' | 'transparent' | 'gradient';
4
4
  export declare type ColorOutput = 'HEX' | 'RGB' | 'RGBA' | 'HSL' | 'HSLA';
5
5
  export declare type ColorModes = 'base' | 'hover' | 'active' | 'disabled';
6
6
  export declare type ColorRole = 'primary' | 'secondary' | 'tertiary' | 'inverse' | 'ghost';
@@ -2,3 +2,4 @@ export * from './color.helper';
2
2
  export * from './color.model';
3
3
  export * from './color.types';
4
4
  export * from './color.records';
5
+ export * from './color.utils';
@@ -18,4 +18,5 @@ __exportStar(require("./color.helper"), exports);
18
18
  __exportStar(require("./color.model"), exports);
19
19
  __exportStar(require("./color.types"), exports);
20
20
  __exportStar(require("./color.records"), exports);
21
+ __exportStar(require("./color.utils"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/color/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,gDAA8B;AAC9B,gDAA8B;AAC9B,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/color/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,gDAA8B;AAC9B,gDAA8B;AAC9B,kDAAgC;AAChC,gDAA8B"}
@@ -1,3 +1,4 @@
1
- import { HSLA, UniColor } from './color.model';
2
- export declare function hslaToString({ hue, saturation, lightness, alpha }: HSLA): string;
1
+ import { HSL, HSLA, RGB, UniColor } from './color.model';
2
+ export declare function HSLAToString({ hue, saturation, lightness, alpha }: HSLA): string;
3
3
  export declare function uniColor({ role, category, alpha }: UniColor): string;
4
+ export declare const RGBToHSL: ({ red, green, blue }: RGB) => HSL;
@@ -1,12 +1,25 @@
1
1
  import { CategoryLightness, CategorySaturation, RoleHues } from './color.records';
2
2
  import { randomRangeValue } from './color.utils';
3
- export function hslaToString({ hue, saturation, lightness, alpha = 1 }) {
3
+ export function HSLAToString({ hue, saturation, lightness, alpha = 1 }) {
4
4
  return `hsla(${hue}, ${saturation}%, ${lightness}%, ${alpha})`;
5
5
  }
6
6
  export function uniColor({ role, category, alpha = 1 }) {
7
7
  const hue = randomRangeValue(RoleHues[role]);
8
8
  const saturation = randomRangeValue(CategorySaturation[category]);
9
9
  const lightness = randomRangeValue(CategoryLightness[category]);
10
- return hslaToString({ hue, saturation, lightness, alpha });
10
+ return HSLAToString({ hue, saturation, lightness, alpha });
11
11
  }
12
+ export const RGBToHSL = ({ red, green, blue }) => {
13
+ red /= 255;
14
+ green /= 255;
15
+ blue /= 255;
16
+ const l = Math.max(red, green, blue);
17
+ const s = l - Math.min(red, green, blue);
18
+ const h = s ? (l === red ? (green - blue) / s : l === green ? 2 + (blue - red) / s : 4 + (red - green) / s) : 0;
19
+ return {
20
+ hue: 60 * h < 0 ? 60 * h + 360 : 60 * h,
21
+ saturation: 100 * (s ? (l <= 0.5 ? s / (2 * l - s) : s / (2 - (2 * l - s))) : 0),
22
+ lightness: (100 * (2 * l - s)) / 2,
23
+ };
24
+ };
12
25
  //# sourceMappingURL=color.helper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"color.helper.js","sourceRoot":"","sources":["../../../../src/core/color/color.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,UAAU,YAAY,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,GAAG,CAAC,EAAQ;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CAAC,CAAC,CAAC,CAAC;QAChF,SAAS,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;KACnC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ColorCategory, ColorRole, ColorScheme, colorStyles } from './color.types';
1
+ import { ColorCategory, ColorRole, ColorScheme, ColorStyles } from './color.types';
2
2
  export interface UniColor {
3
3
  scheme: ColorScheme;
4
4
  role: ColorRole;
@@ -9,7 +9,7 @@ export interface Color {
9
9
  scheme?: ColorScheme;
10
10
  role?: ColorRole;
11
11
  category?: ColorCategory;
12
- style?: colorStyles;
12
+ style?: ColorStyles;
13
13
  GradientPosition?: GradientPosition;
14
14
  saturationRange?: Range;
15
15
  brightnessRangeMap?: Range;
@@ -26,9 +26,20 @@ export interface Range {
26
26
  high: number;
27
27
  default?: number;
28
28
  }
29
- export interface HSLA {
29
+ export interface HSL {
30
30
  hue?: number;
31
31
  saturation?: number;
32
32
  lightness?: number;
33
33
  alpha?: number;
34
34
  }
35
+ export interface HSLA extends HSL {
36
+ alpha?: number;
37
+ }
38
+ export interface RGB {
39
+ red: number;
40
+ green: number;
41
+ blue: number;
42
+ }
43
+ export interface RGBA extends RGB {
44
+ alpha: number;
45
+ }
@@ -1,6 +1,6 @@
1
1
  export declare type ColorScheme = 'monochromatic' | 'analogous' | 'complimentary' | 'splitComplimentary' | 'triadic';
2
2
  export declare type ColorCategory = 'jewel' | 'pastel' | 'earth' | 'neutral' | 'florescent' | 'shades';
3
- export declare type colorStyles = 'solid' | 'transparent' | 'gradient';
3
+ export declare type ColorStyles = 'solid' | 'transparent' | 'gradient';
4
4
  export declare type ColorOutput = 'HEX' | 'RGB' | 'RGBA' | 'HSL' | 'HSLA';
5
5
  export declare type ColorModes = 'base' | 'hover' | 'active' | 'disabled';
6
6
  export declare type ColorRole = 'primary' | 'secondary' | 'tertiary' | 'inverse' | 'ghost';
@@ -2,3 +2,4 @@ export * from './color.helper';
2
2
  export * from './color.model';
3
3
  export * from './color.types';
4
4
  export * from './color.records';
5
+ export * from './color.utils';
@@ -2,4 +2,5 @@ export * from './color.helper';
2
2
  export * from './color.model';
3
3
  export * from './color.types';
4
4
  export * from './color.records';
5
+ export * from './color.utils';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/color/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/color/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uni-design-system/uni-core",
3
3
  "description": "UNI Design System core dependencies.",
4
- "version": "0.0.28",
4
+ "version": "0.0.29",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/uni-design-system/uni-core.git"