@veracity/vui 2.8.1-rc.0 → 2.8.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.
- package/dist/cjs/utils/styles.d.ts +2 -0
- package/dist/cjs/utils/styles.d.ts.map +1 -1
- package/dist/cjs/utils/styles.js +10 -8
- package/dist/esm/utils/styles.d.ts +2 -0
- package/dist/esm/utils/styles.d.ts.map +1 -1
- package/dist/esm/utils/styles.js +7 -3
- package/package.json +1 -1
- package/src/utils/styles.ts +8 -3
|
@@ -7,6 +7,8 @@ export declare function parseHSL(color: string): {
|
|
|
7
7
|
s: number;
|
|
8
8
|
l: number;
|
|
9
9
|
};
|
|
10
|
+
/** Builds RGBA string. */
|
|
11
|
+
export declare function buildRGBA(r: number, g: number, b: number, alpha?: number): string;
|
|
10
12
|
/** Converts hex color value to rgb with optional alpha property. */
|
|
11
13
|
export declare function hexToRGBA(hex: string, alpha?: number): string;
|
|
12
14
|
export declare function vuiColorToRGBA(color: string, alpha?: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAIlC,+EAA+E;AAC/E,wBAAgB,EAAE,CAAC,GAAG,UAAU,EAAE,GAAG,EAAE,UAEtC;AAED,6BAA6B;AAC7B,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM;;;;EAIrC;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAgBpD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAS3D;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UA0CxE;AAED,8CAA8C;AAC9C,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAA"}
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAIlC,+EAA+E;AAC/E,wBAAgB,EAAE,CAAC,GAAG,UAAU,EAAE,GAAG,EAAE,UAEtC;AAED,6BAA6B;AAC7B,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM;;;;EAIrC;AAED,0BAA0B;AAC1B,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAExE;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAgBpD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAS3D;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UA0CxE;AAED,8CAA8C;AAC9C,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAA"}
|
package/dist/cjs/utils/styles.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ellipsisOverflow = exports.HSLToRGBA = exports.vuiColorToRGBA = exports.hexToRGBA = exports.parseHSL = exports.cs = void 0;
|
|
7
|
-
const
|
|
3
|
+
exports.ellipsisOverflow = exports.HSLToRGBA = exports.vuiColorToRGBA = exports.hexToRGBA = exports.buildRGBA = exports.parseHSL = exports.cs = void 0;
|
|
4
|
+
const theme_1 = require("../theme");
|
|
8
5
|
/** Concatenates individual className arguments and returns a single string. */
|
|
9
6
|
function cs(...classNames) {
|
|
10
7
|
return classNames.filter(Boolean).join(' ');
|
|
@@ -18,6 +15,11 @@ function parseHSL(color) {
|
|
|
18
15
|
return { h: Number(res === null || res === void 0 ? void 0 : res[0]) || 0, s: Number(res === null || res === void 0 ? void 0 : res[1]) || 0, l: Number(res === null || res === void 0 ? void 0 : res[2]) || 0 };
|
|
19
16
|
}
|
|
20
17
|
exports.parseHSL = parseHSL;
|
|
18
|
+
/** Builds RGBA string. */
|
|
19
|
+
function buildRGBA(r, g, b, alpha) {
|
|
20
|
+
return alpha !== undefined ? `rgba(${r}, ${g}, ${b}, ${alpha})` : `rgb(${r}, ${g}, ${b})`;
|
|
21
|
+
}
|
|
22
|
+
exports.buildRGBA = buildRGBA;
|
|
21
23
|
/** Converts hex color value to rgb with optional alpha property. */
|
|
22
24
|
function hexToRGBA(hex, alpha) {
|
|
23
25
|
let hexStr = hex;
|
|
@@ -31,7 +33,7 @@ function hexToRGBA(hex, alpha) {
|
|
|
31
33
|
const r = parseInt(hexStr.slice(0, 2), 16);
|
|
32
34
|
const g = parseInt(hexStr.slice(2, 4), 16);
|
|
33
35
|
const b = parseInt(hexStr.slice(4, 6), 16);
|
|
34
|
-
return
|
|
36
|
+
return buildRGBA(r, g, b, alpha);
|
|
35
37
|
}
|
|
36
38
|
exports.hexToRGBA = hexToRGBA;
|
|
37
39
|
function vuiColorToRGBA(color, alpha) {
|
|
@@ -40,7 +42,7 @@ function vuiColorToRGBA(color, alpha) {
|
|
|
40
42
|
const [colorName, shade] = color.split('.');
|
|
41
43
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
44
|
// @ts-ignore
|
|
43
|
-
const x = parseHSL(
|
|
45
|
+
const x = parseHSL(theme_1.colors[colorName][shade]);
|
|
44
46
|
return HSLToRGBA(x.h, x.s, x.l, alpha || shade === 'main' ? 1 : parseInt(shade));
|
|
45
47
|
}
|
|
46
48
|
exports.vuiColorToRGBA = vuiColorToRGBA;
|
|
@@ -83,7 +85,7 @@ function HSLToRGBA(h, s, l, alpha) {
|
|
|
83
85
|
r = Math.round((r + m) * 255);
|
|
84
86
|
g = Math.round((g + m) * 255);
|
|
85
87
|
b = Math.round((b + m) * 255);
|
|
86
|
-
return
|
|
88
|
+
return buildRGBA(r, g, b, alpha);
|
|
87
89
|
}
|
|
88
90
|
exports.HSLToRGBA = HSLToRGBA;
|
|
89
91
|
/** Styling to add ellipsis for long texts. */
|
|
@@ -7,6 +7,8 @@ export declare function parseHSL(color: string): {
|
|
|
7
7
|
s: number;
|
|
8
8
|
l: number;
|
|
9
9
|
};
|
|
10
|
+
/** Builds RGBA string. */
|
|
11
|
+
export declare function buildRGBA(r: number, g: number, b: number, alpha?: number): string;
|
|
10
12
|
/** Converts hex color value to rgb with optional alpha property. */
|
|
11
13
|
export declare function hexToRGBA(hex: string, alpha?: number): string;
|
|
12
14
|
export declare function vuiColorToRGBA(color: string, alpha?: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAIlC,+EAA+E;AAC/E,wBAAgB,EAAE,CAAC,GAAG,UAAU,EAAE,GAAG,EAAE,UAEtC;AAED,6BAA6B;AAC7B,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM;;;;EAIrC;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAgBpD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAS3D;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UA0CxE;AAED,8CAA8C;AAC9C,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAA"}
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAIlC,+EAA+E;AAC/E,wBAAgB,EAAE,CAAC,GAAG,UAAU,EAAE,GAAG,EAAE,UAEtC;AAED,6BAA6B;AAC7B,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM;;;;EAIrC;AAED,0BAA0B;AAC1B,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAExE;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAgBpD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAS3D;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UA0CxE;AAED,8CAA8C;AAC9C,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAA"}
|
package/dist/esm/utils/styles.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import colors from '../theme
|
|
1
|
+
import { colors } from '../theme';
|
|
2
2
|
/** Concatenates individual className arguments and returns a single string. */
|
|
3
3
|
export function cs(...classNames) {
|
|
4
4
|
return classNames.filter(Boolean).join(' ');
|
|
@@ -9,6 +9,10 @@ export function parseHSL(color) {
|
|
|
9
9
|
const res = regexp?.exec?.(color)?.slice?.(1);
|
|
10
10
|
return { h: Number(res?.[0]) || 0, s: Number(res?.[1]) || 0, l: Number(res?.[2]) || 0 };
|
|
11
11
|
}
|
|
12
|
+
/** Builds RGBA string. */
|
|
13
|
+
export function buildRGBA(r, g, b, alpha) {
|
|
14
|
+
return alpha !== undefined ? `rgba(${r}, ${g}, ${b}, ${alpha})` : `rgb(${r}, ${g}, ${b})`;
|
|
15
|
+
}
|
|
12
16
|
/** Converts hex color value to rgb with optional alpha property. */
|
|
13
17
|
export function hexToRGBA(hex, alpha) {
|
|
14
18
|
let hexStr = hex;
|
|
@@ -22,7 +26,7 @@ export function hexToRGBA(hex, alpha) {
|
|
|
22
26
|
const r = parseInt(hexStr.slice(0, 2), 16);
|
|
23
27
|
const g = parseInt(hexStr.slice(2, 4), 16);
|
|
24
28
|
const b = parseInt(hexStr.slice(4, 6), 16);
|
|
25
|
-
return
|
|
29
|
+
return buildRGBA(r, g, b, alpha);
|
|
26
30
|
}
|
|
27
31
|
export function vuiColorToRGBA(color, alpha) {
|
|
28
32
|
if (!color.includes('.'))
|
|
@@ -72,7 +76,7 @@ export function HSLToRGBA(h, s, l, alpha) {
|
|
|
72
76
|
r = Math.round((r + m) * 255);
|
|
73
77
|
g = Math.round((g + m) * 255);
|
|
74
78
|
b = Math.round((b + m) * 255);
|
|
75
|
-
return
|
|
79
|
+
return buildRGBA(r, g, b, alpha);
|
|
76
80
|
}
|
|
77
81
|
/** Styling to add ellipsis for long texts. */
|
|
78
82
|
export const ellipsisOverflow = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veracity/vui",
|
|
3
|
-
"version": "2.8.1
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
package/src/utils/styles.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Property } from 'csstype'
|
|
2
2
|
|
|
3
|
-
import colors from '../theme
|
|
3
|
+
import { colors } from '../theme'
|
|
4
4
|
|
|
5
5
|
/** Concatenates individual className arguments and returns a single string. */
|
|
6
6
|
export function cs(...classNames: any[]) {
|
|
@@ -14,6 +14,11 @@ export function parseHSL(color: string) {
|
|
|
14
14
|
return { h: Number(res?.[0]) || 0, s: Number(res?.[1]) || 0, l: Number(res?.[2]) || 0 }
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/** Builds RGBA string. */
|
|
18
|
+
export function buildRGBA(r: number, g: number, b: number, alpha?: number) {
|
|
19
|
+
return alpha !== undefined ? `rgba(${r}, ${g}, ${b}, ${alpha})` : `rgb(${r}, ${g}, ${b})`
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
/** Converts hex color value to rgb with optional alpha property. */
|
|
18
23
|
export function hexToRGBA(hex: string, alpha?: number) {
|
|
19
24
|
let hexStr = hex
|
|
@@ -30,7 +35,7 @@ export function hexToRGBA(hex: string, alpha?: number) {
|
|
|
30
35
|
const g = parseInt(hexStr.slice(2, 4), 16)
|
|
31
36
|
const b = parseInt(hexStr.slice(4, 6), 16)
|
|
32
37
|
|
|
33
|
-
return
|
|
38
|
+
return buildRGBA(r, g, b, alpha)
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
export function vuiColorToRGBA(color: string, alpha?: number) {
|
|
@@ -86,7 +91,7 @@ export function HSLToRGBA(h: number, s: number, l: number, alpha?: number) {
|
|
|
86
91
|
g = Math.round((g + m) * 255)
|
|
87
92
|
b = Math.round((b + m) * 255)
|
|
88
93
|
|
|
89
|
-
return
|
|
94
|
+
return buildRGBA(r, g, b, alpha)
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
/** Styling to add ellipsis for long texts. */
|