@skbkontur/colors 1.1.2-c8467.0 → 1.1.2-d1791.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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/constants/abney-correction.d.ts +2 -0
  3. package/dist/cjs/constants/abney-correction.js +1105 -0
  4. package/dist/cjs/constants/chroma-settings.d.ts +2 -0
  5. package/dist/cjs/constants/chroma-settings.js +105 -0
  6. package/dist/cjs/constants/default-swatch.d.ts +107 -0
  7. package/dist/cjs/constants/default-swatch.js +110 -0
  8. package/dist/cjs/constants/logo-lightness.d.ts +1 -0
  9. package/dist/cjs/constants/logo-lightness.js +4 -0
  10. package/dist/cjs/constants/promo-hue-shift.d.ts +3 -0
  11. package/dist/cjs/constants/promo-hue-shift.js +14 -0
  12. package/dist/cjs/constants/warning-hue-patch.d.ts +3 -0
  13. package/dist/cjs/constants/warning-hue-patch.js +25 -0
  14. package/dist/cjs/get-base-tokens.d.ts +17 -0
  15. package/dist/cjs/get-base-tokens.js +223 -0
  16. package/dist/cjs/get-default-tokens.d.ts +1278 -0
  17. package/dist/cjs/get-default-tokens.js +1284 -0
  18. package/dist/cjs/get-tokens.d.ts +15 -0
  19. package/dist/cjs/get-tokens.js +13 -0
  20. package/dist/cjs/helpers/get-logo.d.ts +6 -0
  21. package/dist/cjs/helpers/get-logo.js +29 -0
  22. package/dist/cjs/helpers/get-palette.d.ts +49 -0
  23. package/dist/cjs/helpers/get-palette.js +242 -0
  24. package/dist/cjs/helpers/get-promo.d.ts +6 -0
  25. package/dist/cjs/helpers/get-promo.js +58 -0
  26. package/dist/cjs/types/base-tokens.d.ts +53 -0
  27. package/dist/cjs/types/base-tokens.js +2 -0
  28. package/dist/cjs/types/generator-tokens.d.ts +43 -0
  29. package/dist/cjs/types/generator-tokens.js +2 -0
  30. package/dist/esm/constants/abney-correction.d.ts +2 -0
  31. package/dist/esm/constants/abney-correction.js +1102 -0
  32. package/dist/esm/constants/chroma-settings.d.ts +2 -0
  33. package/dist/esm/constants/chroma-settings.js +102 -0
  34. package/dist/esm/constants/default-swatch.d.ts +107 -0
  35. package/dist/esm/constants/default-swatch.js +107 -0
  36. package/dist/esm/constants/logo-lightness.d.ts +1 -0
  37. package/dist/esm/constants/logo-lightness.js +1 -0
  38. package/dist/esm/constants/promo-hue-shift.d.ts +3 -0
  39. package/dist/esm/constants/promo-hue-shift.js +11 -0
  40. package/dist/esm/constants/warning-hue-patch.d.ts +3 -0
  41. package/dist/esm/constants/warning-hue-patch.js +22 -0
  42. package/dist/esm/get-base-tokens.d.ts +17 -0
  43. package/dist/esm/get-base-tokens.js +189 -0
  44. package/dist/esm/get-default-tokens.d.ts +1278 -0
  45. package/dist/esm/get-default-tokens.js +1280 -0
  46. package/dist/esm/get-tokens.d.ts +15 -0
  47. package/dist/esm/get-tokens.js +9 -0
  48. package/dist/esm/helpers/get-logo.d.ts +6 -0
  49. package/dist/esm/helpers/get-logo.js +25 -0
  50. package/dist/esm/helpers/get-palette.d.ts +49 -0
  51. package/dist/esm/helpers/get-palette.js +210 -0
  52. package/dist/esm/helpers/get-promo.d.ts +6 -0
  53. package/dist/esm/helpers/get-promo.js +53 -0
  54. package/dist/esm/types/base-tokens.d.ts +53 -0
  55. package/dist/esm/types/base-tokens.js +1 -0
  56. package/dist/esm/types/generator-tokens.d.ts +43 -0
  57. package/dist/esm/types/generator-tokens.js +1 -0
  58. package/package.json +13 -8
  59. package/colors.css +0 -160
  60. package/colors.less +0 -158
  61. package/colors.scss +0 -158
  62. package/dist/cjs/colors.d.ts +0 -161
  63. package/dist/cjs/colors.js +0 -163
  64. package/dist/esm/colors.d.ts +0 -161
  65. package/dist/esm/colors.js +0 -160
@@ -0,0 +1,2 @@
1
+ import type { GeneratorColorChromaSettingsGroup } from '../types/generator-tokens';
2
+ export declare const CHROMA_SETTINGS: GeneratorColorChromaSettingsGroup;
@@ -0,0 +1,102 @@
1
+ export var CHROMA_SETTINGS = {
2
+ 20: {
3
+ vivid: { rel: 100, max: 12 },
4
+ normal: { rel: 66, min: 4.4, max: 8 },
5
+ dim: { rel: 46, min: 2, max: 4.4 },
6
+ },
7
+ 24: {
8
+ vivid: { rel: 100, max: 14.2 },
9
+ normal: { rel: 68, min: 5.7, max: 10 },
10
+ dim: { rel: 48, min: 2.8, max: 5.7 },
11
+ },
12
+ 28: {
13
+ vivid: { rel: 100, max: 15.8 },
14
+ normal: { rel: 70, min: 7, max: 11.8 },
15
+ dim: { rel: 50, min: 3.6, max: 7 },
16
+ },
17
+ 32: {
18
+ vivid: { rel: 100, max: 17.1 },
19
+ normal: { rel: 72, min: 8.2, max: 13.2 },
20
+ dim: { rel: 52, min: 4.4, max: 8.2 },
21
+ },
22
+ 36: {
23
+ vivid: { rel: 100, max: 18 },
24
+ normal: { rel: 74, min: 9.4, max: 14.4 },
25
+ dim: { rel: 54, min: 5.2, max: 9.4 },
26
+ },
27
+ 40: {
28
+ vivid: { rel: 100, max: 18.8 },
29
+ normal: { rel: 76, min: 10.6, max: 15.6 },
30
+ dim: { rel: 56, min: 6, max: 10.6 },
31
+ },
32
+ 44: {
33
+ vivid: { rel: 100, max: 19.6 },
34
+ normal: { rel: 78, min: 11.7, max: 16.6 },
35
+ dim: { rel: 58, min: 6.8, max: 11.7 },
36
+ },
37
+ 48: {
38
+ vivid: { rel: 100, max: 20.3 },
39
+ normal: { rel: 80, min: 12.8, max: 17.5 },
40
+ dim: { rel: 60, min: 7.6, max: 12.8 },
41
+ },
42
+ 52: {
43
+ vivid: { rel: 100, max: 21 },
44
+ normal: { rel: 82, min: 13.9, max: 18.4 },
45
+ dim: { rel: 62, min: 8.4, max: 13.9 },
46
+ },
47
+ 56: {
48
+ vivid: { rel: 100, max: 21.6 },
49
+ normal: { rel: 84, min: 15, max: 19.2 },
50
+ dim: { rel: 64, min: 9.2, max: 15 },
51
+ },
52
+ 60: {
53
+ vivid: { rel: 100, max: 22 },
54
+ normal: { rel: 86, min: 15.9, max: 19.9 },
55
+ dim: { rel: 66, min: 9.9, max: 15.9 },
56
+ },
57
+ 64: {
58
+ vivid: { rel: 100, max: 22.2 },
59
+ normal: { rel: 88, min: 16.2, max: 20.2 },
60
+ dim: { rel: 68, min: 10.2, max: 16.2 },
61
+ },
62
+ 68: {
63
+ vivid: { rel: 100, max: 21.9 },
64
+ normal: { rel: 90, min: 15.8, max: 19.8 },
65
+ dim: { rel: 70, min: 9.6, max: 15.8 },
66
+ },
67
+ 72: {
68
+ vivid: { rel: 100, max: 21.2 },
69
+ normal: { rel: 92, min: 14.8, max: 18.8 },
70
+ dim: { rel: 72, min: 8.4, max: 14.8 },
71
+ },
72
+ 76: {
73
+ vivid: { rel: 100, max: 20.3 },
74
+ normal: { rel: 90, min: 13.1, max: 17.5 },
75
+ dim: { rel: 70, min: 7, max: 13.1 },
76
+ },
77
+ 80: {
78
+ vivid: { rel: 100, max: 19 },
79
+ normal: { rel: 88, min: 11.2, max: 15.6 },
80
+ dim: { rel: 68, min: 5.6, max: 11.2 },
81
+ },
82
+ 84: {
83
+ vivid: { rel: 100, max: 17.1 },
84
+ normal: { rel: 86, min: 9, max: 13.4 },
85
+ dim: { rel: 66, min: 4.4, max: 9 },
86
+ },
87
+ 88: {
88
+ vivid: { rel: 100, max: 14.2 },
89
+ normal: { rel: 84, min: 6.7, max: 10.4 },
90
+ dim: { rel: 64, min: 3.2, max: 6.7 },
91
+ },
92
+ 92: {
93
+ vivid: { rel: 100, max: 11 },
94
+ normal: { rel: 82, min: 4.4, max: 7.4 },
95
+ dim: { rel: 62, min: 2.2, max: 4.4 },
96
+ },
97
+ 96: {
98
+ vivid: { rel: 100, max: 7 },
99
+ normal: { rel: 80, min: 2.6, max: 4.4 },
100
+ dim: { rel: 60, min: 1.5, max: 2.6 },
101
+ },
102
+ };
@@ -0,0 +1,107 @@
1
+ export declare const brand: {
2
+ red: string;
3
+ orange: string;
4
+ green: string;
5
+ mint: string;
6
+ blue: string;
7
+ blueDeep: string;
8
+ violet: string;
9
+ purple: string;
10
+ };
11
+ export declare const system: {
12
+ warning: string;
13
+ error: string;
14
+ success: string;
15
+ accent: string;
16
+ };
17
+ export declare const customizable: {
18
+ red: string;
19
+ orange: string;
20
+ green: string;
21
+ mint: string;
22
+ blue: string;
23
+ blueDeep: string;
24
+ violet: string;
25
+ purple: string;
26
+ };
27
+ export declare const gray: {
28
+ 0: string;
29
+ 4: string;
30
+ 8: string;
31
+ 12: string;
32
+ 16: string;
33
+ 20: string;
34
+ 24: string;
35
+ 28: string;
36
+ 32: string;
37
+ 36: string;
38
+ 40: string;
39
+ 44: string;
40
+ 48: string;
41
+ 52: string;
42
+ 56: string;
43
+ 60: string;
44
+ 64: string;
45
+ 68: string;
46
+ 72: string;
47
+ 76: string;
48
+ 80: string;
49
+ 84: string;
50
+ 88: string;
51
+ 92: string;
52
+ 96: string;
53
+ 98: string;
54
+ 100: string;
55
+ };
56
+ export declare const whiteAlpha: {
57
+ 4: string;
58
+ 8: string;
59
+ 12: string;
60
+ 16: string;
61
+ 20: string;
62
+ 24: string;
63
+ 28: string;
64
+ 32: string;
65
+ 36: string;
66
+ 40: string;
67
+ 44: string;
68
+ 48: string;
69
+ 52: string;
70
+ 56: string;
71
+ 60: string;
72
+ 64: string;
73
+ 68: string;
74
+ 72: string;
75
+ 76: string;
76
+ 80: string;
77
+ 84: string;
78
+ 88: string;
79
+ 92: string;
80
+ 96: string;
81
+ };
82
+ export declare const blackAlpha: {
83
+ 4: string;
84
+ 8: string;
85
+ 12: string;
86
+ 16: string;
87
+ 20: string;
88
+ 24: string;
89
+ 28: string;
90
+ 32: string;
91
+ 36: string;
92
+ 40: string;
93
+ 44: string;
94
+ 48: string;
95
+ 52: string;
96
+ 56: string;
97
+ 60: string;
98
+ 64: string;
99
+ 68: string;
100
+ 72: string;
101
+ 76: string;
102
+ 80: string;
103
+ 84: string;
104
+ 88: string;
105
+ 92: string;
106
+ 96: string;
107
+ };
@@ -0,0 +1,107 @@
1
+ export var brand = {
2
+ red: '#FE4C4C',
3
+ orange: '#FC7630',
4
+ green: '#26AD50',
5
+ mint: '#00BEA2',
6
+ blue: '#2291FF',
7
+ blueDeep: '#366AF3',
8
+ violet: '#844BEC',
9
+ purple: '#B750D1',
10
+ };
11
+ export var system = {
12
+ warning: '#FDAA00',
13
+ error: '#E62B34',
14
+ success: '#009A40',
15
+ accent: '#2291FF',
16
+ };
17
+ export var customizable = {
18
+ red: '#FE4C4C',
19
+ orange: '#FC7630',
20
+ green: '#26AD50',
21
+ mint: '#00BEA2',
22
+ blue: '#2291FF',
23
+ blueDeep: '#366AF3',
24
+ violet: '#844BEC',
25
+ purple: '#B750D1',
26
+ };
27
+ export var gray = {
28
+ 0: 'oklch(0% 0 0)',
29
+ 4: 'oklch(4% 0 0)',
30
+ 8: 'oklch(8% 0 0)',
31
+ 12: 'oklch(12% 0 0)',
32
+ 16: 'oklch(16% 0 0)',
33
+ 20: 'oklch(20% 0 0)',
34
+ 24: 'oklch(24% 0 0)',
35
+ 28: 'oklch(28% 0 0)',
36
+ 32: 'oklch(32% 0 0)',
37
+ 36: 'oklch(36% 0 0)',
38
+ 40: 'oklch(40% 0 0)',
39
+ 44: 'oklch(44% 0 0)',
40
+ 48: 'oklch(48% 0 0)',
41
+ 52: 'oklch(52% 0 0)',
42
+ 56: 'oklch(56% 0 0)',
43
+ 60: 'oklch(60% 0 0)',
44
+ 64: 'oklch(64% 0 0)',
45
+ 68: 'oklch(68% 0 0)',
46
+ 72: 'oklch(72% 0 0)',
47
+ 76: 'oklch(76% 0 0)',
48
+ 80: 'oklch(80% 0 0)',
49
+ 84: 'oklch(84% 0 0)',
50
+ 88: 'oklch(88% 0 0)',
51
+ 92: 'oklch(92% 0 0)',
52
+ 96: 'oklch(96% 0 0)',
53
+ 98: 'oklch(98% 0 0)',
54
+ 100: 'oklch(100% 0 0)',
55
+ };
56
+ export var whiteAlpha = {
57
+ 4: 'oklch(100% 0 0 / 0.04)',
58
+ 8: 'oklch(100% 0 0 / 0.08)',
59
+ 12: 'oklch(100% 0 0 / 0.12)',
60
+ 16: 'oklch(100% 0 0 / 0.16)',
61
+ 20: 'oklch(100% 0 0 / 0.2)',
62
+ 24: 'oklch(100% 0 0 / 0.24)',
63
+ 28: 'oklch(100% 0 0 / 0.28)',
64
+ 32: 'oklch(100% 0 0 / 0.32)',
65
+ 36: 'oklch(100% 0 0 / 0.36)',
66
+ 40: 'oklch(100% 0 0 / 0.4)',
67
+ 44: 'oklch(100% 0 0 / 0.44)',
68
+ 48: 'oklch(100% 0 0 / 0.48)',
69
+ 52: 'oklch(100% 0 0 / 0.52)',
70
+ 56: 'oklch(100% 0 0 / 0.56)',
71
+ 60: 'oklch(100% 0 0 / 0.6)',
72
+ 64: 'oklch(100% 0 0 / 0.64)',
73
+ 68: 'oklch(100% 0 0 / 0.68)',
74
+ 72: 'oklch(100% 0 0 / 0.72)',
75
+ 76: 'oklch(100% 0 0 / 0.76)',
76
+ 80: 'oklch(100% 0 0 / 0.8)',
77
+ 84: 'oklch(100% 0 0 / 0.84)',
78
+ 88: 'oklch(100% 0 0 / 0.88)',
79
+ 92: 'oklch(100% 0 0 / 0.92)',
80
+ 96: 'oklch(100% 0 0 / 0.96)',
81
+ };
82
+ export var blackAlpha = {
83
+ 4: 'oklch(0% 0 0 / 0.04)',
84
+ 8: 'oklch(0% 0 0 / 0.08)',
85
+ 12: 'oklch(0% 0 0 / 0.12)',
86
+ 16: 'oklch(0% 0 0 / 0.16)',
87
+ 20: 'oklch(0% 0 0 / 0.2)',
88
+ 24: 'oklch(0% 0 0 / 0.24)',
89
+ 28: 'oklch(0% 0 0 / 0.28)',
90
+ 32: 'oklch(0% 0 0 / 0.32)',
91
+ 36: 'oklch(0% 0 0 / 0.36)',
92
+ 40: 'oklch(0% 0 0 / 0.4)',
93
+ 44: 'oklch(0% 0 0 / 0.44)',
94
+ 48: 'oklch(0% 0 0 / 0.48)',
95
+ 52: 'oklch(0% 0 0 / 0.52)',
96
+ 56: 'oklch(0% 0 0 / 0.56)',
97
+ 60: 'oklch(0% 0 0 / 0.6)',
98
+ 64: 'oklch(0% 0 0 / 0.64)',
99
+ 68: 'oklch(0% 0 0 / 0.68)',
100
+ 72: 'oklch(0% 0 0 / 0.72)',
101
+ 76: 'oklch(0% 0 0 / 0.76)',
102
+ 80: 'oklch(0% 0 0 / 0.8)',
103
+ 84: 'oklch(0% 0 0 / 0.84)',
104
+ 88: 'oklch(0% 0 0 / 0.88)',
105
+ 92: 'oklch(0% 0 0 / 0.92)',
106
+ 96: 'oklch(0% 0 0 / 0.96)',
107
+ };
@@ -0,0 +1 @@
1
+ export declare const MIN_LOGO_LIGHTNESS = 64;
@@ -0,0 +1 @@
1
+ export var MIN_LOGO_LIGHTNESS = 64;
@@ -0,0 +1,3 @@
1
+ export declare const PROMO_HUE_SHIFTS: {
2
+ [hueRange: number]: number;
3
+ };
@@ -0,0 +1,11 @@
1
+ export var PROMO_HUE_SHIFTS = {
2
+ 0: -24,
3
+ 25: -32,
4
+ 44: -35,
5
+ 148: 40,
6
+ 177: 51,
7
+ 253: 11,
8
+ 264: 14,
9
+ 294: 0,
10
+ 319: -24,
11
+ };
@@ -0,0 +1,3 @@
1
+ export declare const WARNING_HUE_PATCH: {
2
+ [lightness: number]: number;
3
+ };
@@ -0,0 +1,22 @@
1
+ export var WARNING_HUE_PATCH = {
2
+ 96: 0,
3
+ 92: 0,
4
+ 88: 0,
5
+ 84: 0,
6
+ 80: 0,
7
+ 76: 0,
8
+ 72: -4,
9
+ 68: -8,
10
+ 64: -12,
11
+ 60: -8,
12
+ 56: -4,
13
+ 52: -2,
14
+ 48: 0,
15
+ 44: 0,
16
+ 40: 0,
17
+ 36: 0,
18
+ 32: 0,
19
+ 28: 0,
20
+ 24: 0,
21
+ 20: 0,
22
+ };
@@ -0,0 +1,17 @@
1
+ import * as DEFAULT_SWATCH from './constants/default-swatch';
2
+ import type { BaseTokens } from './types/base-tokens';
3
+ type PresetOrCustom<T extends string> = T | (string & Record<never, never>);
4
+ export interface ConfigOptions {
5
+ brand: PresetOrCustom<keyof typeof DEFAULT_SWATCH.brand>;
6
+ accent: PresetOrCustom<'brand' | 'gray'>;
7
+ system?: typeof DEFAULT_SWATCH.system;
8
+ }
9
+ export declare function getBaseTokens({ brand, accent, system }: ConfigOptions): BaseTokens;
10
+ export declare const colorToHex: (color: string) => string;
11
+ export declare const camelCaseToKebabCase: (str: string) => string;
12
+ export declare const kebabCaseToCamelCase: (str: string) => string;
13
+ export declare function convertOklchToHex(obj: any): any;
14
+ export declare const convertOklchToRgba: (oklchString: string) => string;
15
+ export declare function convertAlphaOklchToRgba(obj: any): any;
16
+ export declare function flattenObject(obj: any, prefix?: string): any;
17
+ export {};
@@ -0,0 +1,189 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { converter, formatHex } from 'culori';
13
+ import { calcOnBrand, getPalette } from './helpers/get-palette';
14
+ import { getPromo } from './helpers/get-promo';
15
+ import * as DEFAULT_SWATCH from './constants/default-swatch';
16
+ import { getLogo } from './helpers/get-logo';
17
+ export function getBaseTokens(_a) {
18
+ var brand = _a.brand, accent = _a.accent, _b = _a.system, system = _b === void 0 ? DEFAULT_SWATCH.system : _b;
19
+ var brandColor = colorToHex(brand);
20
+ var brandPalette = getPalette({ color: brandColor });
21
+ var accentPalette;
22
+ switch (accent) {
23
+ case 'brand':
24
+ accentPalette = brandPalette;
25
+ break;
26
+ case 'gray':
27
+ accentPalette = undefined;
28
+ break;
29
+ default:
30
+ accentPalette = getPalette({ color: accent });
31
+ }
32
+ var warningPalette = getPalette({
33
+ color: system.warning,
34
+ });
35
+ var errorPalette = getPalette({ color: system.error });
36
+ var successPalette = getPalette({
37
+ color: system.success,
38
+ });
39
+ var customizable = {};
40
+ for (var colorKey in DEFAULT_SWATCH.brand) {
41
+ // @ts-expect-error
42
+ customizable[colorKey] = getPalette({
43
+ // @ts-expect-error
44
+ color: DEFAULT_SWATCH.brand[colorKey],
45
+ });
46
+ }
47
+ return {
48
+ brandLogo: getLogo(brand),
49
+ brandPromo: {
50
+ light: getPromo(brandColor),
51
+ dark: 'blue',
52
+ },
53
+ brand: {
54
+ // todo Brand
55
+ original: {
56
+ light: brand,
57
+ dark: brand,
58
+ },
59
+ // todo interactions
60
+ interactions: {
61
+ hover: {
62
+ light: '',
63
+ dark: '',
64
+ },
65
+ pressed: {
66
+ light: '',
67
+ dark: '',
68
+ },
69
+ },
70
+ palette: brandPalette,
71
+ },
72
+ accent: {
73
+ original: {
74
+ // todo Fix gray
75
+ light: accent === 'gray' ? accent : '#3d3d3d',
76
+ dark: accent === 'gray' ? accent : '#3d3d3d',
77
+ },
78
+ // todo interactions
79
+ interactions: {
80
+ hover: {
81
+ light: '',
82
+ dark: '',
83
+ },
84
+ pressed: {
85
+ light: '',
86
+ dark: '',
87
+ },
88
+ },
89
+ palette: accentPalette || undefined,
90
+ },
91
+ warning: warningPalette,
92
+ error: errorPalette,
93
+ success: successPalette,
94
+ gray: DEFAULT_SWATCH.gray,
95
+ whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
96
+ blackAlpha: DEFAULT_SWATCH.blackAlpha,
97
+ onBrand: calcOnBrand(brandColor),
98
+ customizable: customizable,
99
+ };
100
+ }
101
+ export var colorToHex = function (color) {
102
+ if (DEFAULT_SWATCH.brand[color]) {
103
+ return DEFAULT_SWATCH.brand[color];
104
+ }
105
+ return color;
106
+ };
107
+ export var camelCaseToKebabCase = function (str) {
108
+ return str.replace(/[A-Z]/g, function (match) { return "-".concat(match.toLowerCase()); });
109
+ };
110
+ export var kebabCaseToCamelCase = function (str) {
111
+ return str.replace(/-(\w)/g, function (_, c) { return c.toUpperCase(); });
112
+ };
113
+ export function convertOklchToHex(obj) {
114
+ if (typeof obj !== 'object' || obj === null) {
115
+ return obj;
116
+ }
117
+ if (Array.isArray(obj)) {
118
+ return obj.map(function (item) { return convertOklchToHex(item); });
119
+ }
120
+ var newObj = {};
121
+ for (var key in obj) {
122
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
123
+ var value = obj[key];
124
+ if (typeof value === 'string' && value.startsWith('oklch(') && !value.includes('/')) {
125
+ try {
126
+ var toHex = converter('oklch');
127
+ value = formatHex(toHex(value));
128
+ }
129
+ catch (e) {
130
+ console.error("Failed to convert OKLCH to hex: ".concat(value), e);
131
+ }
132
+ }
133
+ newObj[key] = convertOklchToHex(value);
134
+ }
135
+ }
136
+ return newObj;
137
+ }
138
+ export var convertOklchToRgba = function (oklchString) {
139
+ var oklch = converter('oklch')(oklchString);
140
+ var rgb = converter('rgb')(oklch);
141
+ if (!rgb) {
142
+ throw new Error("Invalid color format: ".concat(oklchString));
143
+ }
144
+ var r = Math.round(rgb.r * 255);
145
+ var g = Math.round(rgb.g * 255);
146
+ var b = Math.round(rgb.b * 255);
147
+ var alpha = oklch.alpha;
148
+ return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(alpha, ")");
149
+ };
150
+ export function convertAlphaOklchToRgba(obj) {
151
+ if (typeof obj !== 'object' || obj === null) {
152
+ return obj;
153
+ }
154
+ if (Array.isArray(obj)) {
155
+ return obj.map(function (item) { return convertAlphaOklchToRgba(item); });
156
+ }
157
+ var newObj = {};
158
+ for (var key in obj) {
159
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
160
+ var value = obj[key];
161
+ if (typeof value === 'string' && value.includes('oklch(')) {
162
+ try {
163
+ value = convertOklchToRgba(value);
164
+ }
165
+ catch (e) {
166
+ console.error("Failed to convert OKLCH with alpha to rgba: ".concat(value), e);
167
+ }
168
+ }
169
+ newObj[key] = convertAlphaOklchToRgba(value);
170
+ }
171
+ }
172
+ return newObj;
173
+ }
174
+ export function flattenObject(obj, prefix) {
175
+ if (prefix === void 0) { prefix = ''; }
176
+ var result = {};
177
+ for (var key in obj) {
178
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
179
+ var newKey = prefix ? "".concat(prefix, "-").concat(camelCaseToKebabCase(key)) : key;
180
+ if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
181
+ result = __assign(__assign({}, result), flattenObject(obj[key], newKey));
182
+ }
183
+ else {
184
+ result[newKey] = obj[key];
185
+ }
186
+ }
187
+ }
188
+ return result;
189
+ }