@skbkontur/colors 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (174) hide show
  1. package/README.md +104 -171
  2. package/colors.less +319 -0
  3. package/colors.scss +319 -0
  4. package/lib/consts/default-swatch.d.ts +108 -0
  5. package/lib/consts/default-swatch.js +108 -0
  6. package/{dist/esm/constants/default-swatch.js → lib/consts/default-swatch.ts} +11 -7
  7. package/lib/consts/params/abney-correction.d.ts +2 -0
  8. package/lib/consts/params/abney-correction.js +1102 -0
  9. package/{dist/cjs/constants/abney-correction.js → lib/consts/params/abney-correction.ts} +3 -4
  10. package/lib/consts/params/chroma-params.d.ts +2 -0
  11. package/lib/consts/params/chroma-params.js +102 -0
  12. package/{dist/esm/constants/chroma-settings.js → lib/consts/params/chroma-params.ts} +3 -1
  13. package/lib/consts/params/interactions.ts +9 -0
  14. package/lib/consts/params/logo-lightness.d.ts +1 -0
  15. package/lib/consts/params/logo-lightness.js +1 -0
  16. package/lib/consts/params/logo-lightness.ts +1 -0
  17. package/{dist/cjs/constants → lib/consts/params}/promo-hue-shift.d.ts +1 -1
  18. package/lib/consts/params/promo-hue-shift.js +11 -0
  19. package/{dist/esm/constants/promo-hue-shift.js → lib/consts/params/promo-hue-shift.ts} +1 -1
  20. package/{dist/cjs/constants → lib/consts/params}/warning-hue-patch.d.ts +1 -1
  21. package/lib/consts/params/warning-hue-patch.js +22 -0
  22. package/{dist/esm/constants/warning-hue-patch.js → lib/consts/params/warning-hue-patch.ts} +1 -1
  23. package/lib/get-colors-base.d.ts +11 -0
  24. package/lib/get-colors-base.js +78 -0
  25. package/lib/get-colors-base.ts +99 -0
  26. package/lib/get-colors-default-tokens.d.ts +645 -0
  27. package/lib/get-colors-default-tokens.js +647 -0
  28. package/lib/get-colors-default-tokens.ts +646 -0
  29. package/lib/get-colors.d.ts +40 -0
  30. package/lib/get-colors.js +28 -0
  31. package/lib/get-colors.ts +65 -0
  32. package/{dist/cjs → lib}/helpers/get-interactions.d.ts +2 -2
  33. package/lib/helpers/get-interactions.js +35 -0
  34. package/lib/helpers/get-interactions.ts +64 -0
  35. package/{dist/cjs → lib}/helpers/get-logo.d.ts +2 -2
  36. package/lib/helpers/get-logo.js +25 -0
  37. package/lib/helpers/get-logo.ts +40 -0
  38. package/lib/helpers/get-palette.d.ts +51 -0
  39. package/lib/helpers/get-palette.js +204 -0
  40. package/lib/helpers/get-palette.ts +261 -0
  41. package/lib/helpers/get-promo.d.ts +6 -0
  42. package/lib/helpers/get-promo.js +47 -0
  43. package/lib/helpers/get-promo.ts +55 -0
  44. package/lib/types/tokens-base-generator.d.ts +43 -0
  45. package/{dist/cjs/types/generator-tokens.d.ts → lib/types/tokens-base-generator.ts} +12 -17
  46. package/lib/types/tokens-base.d.ts +55 -0
  47. package/{dist/esm/types/base-tokens.d.ts → lib/types/tokens-base.ts} +7 -2
  48. package/lib/types/tokens.d.ts +12 -0
  49. package/lib/types/tokens.js +1 -0
  50. package/lib/types/tokens.ts +18 -0
  51. package/lib/utils/convert-color.d.ts +3 -0
  52. package/lib/utils/convert-color.js +144 -0
  53. package/lib/utils/convert-color.ts +163 -0
  54. package/lib/utils/format-variable.js +6 -0
  55. package/lib/utils/format-variable.ts +7 -0
  56. package/package.json +44 -19
  57. package/{dist/tokens → tokens}/brand-blue-deep_accent-brand.css +33 -33
  58. package/{dist/tokens → tokens}/brand-blue-deep_accent-gray.css +33 -33
  59. package/{dist/tokens → tokens}/brand-blue_accent-brand.css +33 -33
  60. package/{dist/tokens → tokens}/brand-blue_accent-gray.css +33 -33
  61. package/{dist/tokens → tokens}/brand-green_accent-brand.css +33 -33
  62. package/{dist/tokens → tokens}/brand-green_accent-gray.css +33 -33
  63. package/{dist/tokens → tokens}/brand-mint_accent-brand.css +33 -33
  64. package/{dist/tokens → tokens}/brand-mint_accent-gray.css +33 -33
  65. package/{dist/tokens → tokens}/brand-orange_accent-gray.css +33 -33
  66. package/{dist/tokens → tokens}/brand-purple_accent-brand.css +33 -33
  67. package/{dist/tokens → tokens}/brand-purple_accent-gray.css +33 -33
  68. package/{dist/tokens → tokens}/brand-red_accent-gray.css +33 -33
  69. package/{dist/tokens → tokens}/brand-violet_accent-brand.css +33 -33
  70. package/{dist/tokens → tokens}/brand-violet_accent-gray.css +33 -33
  71. package/tokens-mobile/brand-blue-deep_accent-brand.json +718 -0
  72. package/tokens-mobile/brand-blue-deep_accent-gray.json +718 -0
  73. package/tokens-mobile/brand-blue_accent-brand.json +718 -0
  74. package/tokens-mobile/brand-blue_accent-gray.json +718 -0
  75. package/tokens-mobile/brand-green_accent-brand.json +718 -0
  76. package/tokens-mobile/brand-green_accent-gray.json +718 -0
  77. package/tokens-mobile/brand-mint_accent-brand.json +718 -0
  78. package/tokens-mobile/brand-mint_accent-gray.json +718 -0
  79. package/tokens-mobile/brand-orange_accent-gray.json +718 -0
  80. package/tokens-mobile/brand-purple_accent-brand.json +718 -0
  81. package/tokens-mobile/brand-purple_accent-gray.json +718 -0
  82. package/tokens-mobile/brand-red_accent-gray.json +718 -0
  83. package/tokens-mobile/brand-violet_accent-brand.json +718 -0
  84. package/tokens-mobile/brand-violet_accent-gray.json +718 -0
  85. package/dist/cjs/constants/abney-correction.d.ts +0 -2
  86. package/dist/cjs/constants/chroma-settings.d.ts +0 -2
  87. package/dist/cjs/constants/chroma-settings.js +0 -105
  88. package/dist/cjs/constants/default-swatch.d.ts +0 -109
  89. package/dist/cjs/constants/default-swatch.js +0 -112
  90. package/dist/cjs/constants/interaction-settings.js +0 -19
  91. package/dist/cjs/constants/logo-lightness.d.ts +0 -1
  92. package/dist/cjs/constants/logo-lightness.js +0 -4
  93. package/dist/cjs/constants/promo-hue-shift.js +0 -14
  94. package/dist/cjs/constants/warning-hue-patch.js +0 -25
  95. package/dist/cjs/get-base-tokens.d.ts +0 -26
  96. package/dist/cjs/get-base-tokens.js +0 -319
  97. package/dist/cjs/get-colors.d.ts +0 -20
  98. package/dist/cjs/get-colors.js +0 -20
  99. package/dist/cjs/get-default-tokens.d.ts +0 -645
  100. package/dist/cjs/get-default-tokens.js +0 -996
  101. package/dist/cjs/helpers/get-interactions.js +0 -61
  102. package/dist/cjs/helpers/get-logo.js +0 -32
  103. package/dist/cjs/helpers/get-palette.d.ts +0 -76
  104. package/dist/cjs/helpers/get-palette.js +0 -287
  105. package/dist/cjs/helpers/get-promo.d.ts +0 -12
  106. package/dist/cjs/helpers/get-promo.js +0 -56
  107. package/dist/cjs/types/base-tokens.d.ts +0 -125
  108. package/dist/cjs/types/base-tokens.js +0 -2
  109. package/dist/cjs/types/generator-tokens.js +0 -2
  110. package/dist/cjs/utils/format-variable.js +0 -15
  111. package/dist/colors.default-dark.js +0 -332
  112. package/dist/colors.default-light.js +0 -336
  113. package/dist/colors.less +0 -319
  114. package/dist/colors.scss +0 -319
  115. package/dist/esm/constants/abney-correction.d.ts +0 -2
  116. package/dist/esm/constants/abney-correction.js +0 -1102
  117. package/dist/esm/constants/chroma-settings.d.ts +0 -2
  118. package/dist/esm/constants/default-swatch.d.ts +0 -109
  119. package/dist/esm/constants/interaction-settings.d.ts +0 -8
  120. package/dist/esm/constants/logo-lightness.d.ts +0 -1
  121. package/dist/esm/constants/logo-lightness.js +0 -1
  122. package/dist/esm/constants/promo-hue-shift.d.ts +0 -3
  123. package/dist/esm/constants/warning-hue-patch.d.ts +0 -3
  124. package/dist/esm/get-base-tokens.d.ts +0 -26
  125. package/dist/esm/get-base-tokens.js +0 -257
  126. package/dist/esm/get-colors.d.ts +0 -20
  127. package/dist/esm/get-colors.js +0 -16
  128. package/dist/esm/get-default-tokens.d.ts +0 -645
  129. package/dist/esm/get-default-tokens.js +0 -992
  130. package/dist/esm/helpers/get-interactions.d.ts +0 -7
  131. package/dist/esm/helpers/get-interactions.js +0 -49
  132. package/dist/esm/helpers/get-logo.d.ts +0 -6
  133. package/dist/esm/helpers/get-logo.js +0 -28
  134. package/dist/esm/helpers/get-palette.d.ts +0 -76
  135. package/dist/esm/helpers/get-palette.js +0 -232
  136. package/dist/esm/helpers/get-promo.d.ts +0 -12
  137. package/dist/esm/helpers/get-promo.js +0 -51
  138. package/dist/esm/types/generator-tokens.d.ts +0 -43
  139. package/dist/esm/utils/format-variable.d.ts +0 -2
  140. package/dist/esm/utils/format-variable.js +0 -10
  141. package/dist/tokens-js/brand-blue-deep_accent-brand.js +0 -644
  142. package/dist/tokens-js/brand-blue-deep_accent-gray.js +0 -644
  143. package/dist/tokens-js/brand-blue_accent-brand.js +0 -644
  144. package/dist/tokens-js/brand-blue_accent-gray.js +0 -644
  145. package/dist/tokens-js/brand-green_accent-brand.js +0 -644
  146. package/dist/tokens-js/brand-green_accent-gray.js +0 -644
  147. package/dist/tokens-js/brand-mint_accent-brand.js +0 -644
  148. package/dist/tokens-js/brand-mint_accent-gray.js +0 -644
  149. package/dist/tokens-js/brand-orange_accent-gray.js +0 -644
  150. package/dist/tokens-js/brand-purple_accent-brand.js +0 -644
  151. package/dist/tokens-js/brand-purple_accent-gray.js +0 -644
  152. package/dist/tokens-js/brand-red_accent-gray.js +0 -644
  153. package/dist/tokens-js/brand-violet_accent-brand.js +0 -644
  154. package/dist/tokens-js/brand-violet_accent-gray.js +0 -644
  155. package/dist/tokens-mobile/brand-blue-deep_accent-brand.json +0 -718
  156. package/dist/tokens-mobile/brand-blue-deep_accent-gray.json +0 -718
  157. package/dist/tokens-mobile/brand-blue_accent-brand.json +0 -718
  158. package/dist/tokens-mobile/brand-blue_accent-gray.json +0 -718
  159. package/dist/tokens-mobile/brand-green_accent-brand.json +0 -718
  160. package/dist/tokens-mobile/brand-green_accent-gray.json +0 -718
  161. package/dist/tokens-mobile/brand-mint_accent-brand.json +0 -718
  162. package/dist/tokens-mobile/brand-mint_accent-gray.json +0 -718
  163. package/dist/tokens-mobile/brand-orange_accent-gray.json +0 -718
  164. package/dist/tokens-mobile/brand-purple_accent-brand.json +0 -718
  165. package/dist/tokens-mobile/brand-purple_accent-gray.json +0 -718
  166. package/dist/tokens-mobile/brand-red_accent-gray.json +0 -718
  167. package/dist/tokens-mobile/brand-violet_accent-brand.json +0 -718
  168. package/dist/tokens-mobile/brand-violet_accent-gray.json +0 -718
  169. /package/{dist/colors.js → colors.js} +0 -0
  170. /package/{dist/cjs/constants/interaction-settings.d.ts → lib/consts/params/interactions.d.ts} +0 -0
  171. /package/{dist/esm/constants/interaction-settings.js → lib/consts/params/interactions.js} +0 -0
  172. /package/{dist/esm/types/base-tokens.js → lib/types/tokens-base-generator.js} +0 -0
  173. /package/{dist/esm/types/generator-tokens.js → lib/types/tokens-base.js} +0 -0
  174. /package/{dist/cjs → lib}/utils/format-variable.d.ts +0 -0
@@ -1,2 +0,0 @@
1
- import type { GeneratorColorChromaSettingsGroup } from '../types/generator-tokens';
2
- export declare const CHROMA_SETTINGS: GeneratorColorChromaSettingsGroup;
@@ -1,109 +0,0 @@
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
- yellow: string;
27
- };
28
- export declare const gray: {
29
- 0: string;
30
- 16: string;
31
- 20: string;
32
- 24: string;
33
- 28: string;
34
- 32: string;
35
- 36: string;
36
- 40: string;
37
- 44: string;
38
- 48: string;
39
- 52: string;
40
- 56: string;
41
- 60: string;
42
- 64: string;
43
- 68: string;
44
- 72: string;
45
- 76: string;
46
- 80: string;
47
- 84: string;
48
- 88: string;
49
- 92: string;
50
- 96: string;
51
- 98: string;
52
- 100: string;
53
- };
54
- export declare const whiteAlpha: {
55
- 4: string;
56
- 6: string;
57
- 8: string;
58
- 12: string;
59
- 16: string;
60
- 20: string;
61
- 24: string;
62
- 28: string;
63
- 32: string;
64
- 36: string;
65
- 40: string;
66
- 44: string;
67
- 48: string;
68
- 52: string;
69
- 56: string;
70
- 60: string;
71
- 64: string;
72
- 68: string;
73
- 72: string;
74
- 76: string;
75
- 80: string;
76
- 84: string;
77
- 88: string;
78
- 92: string;
79
- 96: string;
80
- 100: string;
81
- };
82
- export declare const blackAlpha: {
83
- 4: string;
84
- 6: string;
85
- 8: string;
86
- 12: string;
87
- 16: string;
88
- 20: string;
89
- 24: string;
90
- 28: string;
91
- 32: string;
92
- 36: string;
93
- 40: string;
94
- 44: string;
95
- 48: string;
96
- 52: string;
97
- 56: string;
98
- 60: string;
99
- 64: string;
100
- 68: string;
101
- 72: string;
102
- 76: string;
103
- 80: string;
104
- 84: string;
105
- 88: string;
106
- 92: string;
107
- 96: string;
108
- 100: string;
109
- };
@@ -1,8 +0,0 @@
1
- export declare const HOVER_LIGHT_L = -4;
2
- export declare const HOVER_LIGHT_C = 0;
3
- export declare const HOVER_DARK_L = 4;
4
- export declare const HOVER_DARK_C = 0;
5
- export declare const PRESSED_LIGHT_L = -8;
6
- export declare const PRESSED_LIGHT_C = -0.03;
7
- export declare const PRESSED_DARK_L = -4;
8
- export declare const PRESSED_DARK_C = -0.03;
@@ -1 +0,0 @@
1
- export declare const MIN_LOGO_LIGHTNESS = 64;
@@ -1 +0,0 @@
1
- export var MIN_LOGO_LIGHTNESS = 64;
@@ -1,3 +0,0 @@
1
- export declare const PROMO_HUE_SHIFTS: {
2
- [hueRange: number]: number;
3
- };
@@ -1,3 +0,0 @@
1
- export declare const WARNING_HUE_PATCH: {
2
- [lightness: number]: number;
3
- };
@@ -1,26 +0,0 @@
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 declare const ACCENT_PARAMS: string[];
5
- export interface ColorObject {
6
- [key: string]: ColorValue;
7
- }
8
- export type ColorValue = string | ColorObject | ColorValue[];
9
- type ColorStructure = ColorObject | ColorValue[];
10
- export type ColorFormat = 'hex/rgba' | 'rgb/rgba' | 'oklch' | 'hex-aarrggbb';
11
- export interface ConfigOptions {
12
- brand: PresetOrCustom<keyof typeof DEFAULT_SWATCH.brand>;
13
- accent: PresetOrCustom<(typeof ACCENT_PARAMS)[number]>;
14
- system?: typeof DEFAULT_SWATCH.system;
15
- format?: ColorFormat;
16
- }
17
- export declare function getBaseTokens({ brand, accent, system }: ConfigOptions): BaseTokens;
18
- export declare function convertOklchToHex(obj: ColorStructure): ColorStructure;
19
- export declare const convertOklchToRgba: (oklchString: string) => string;
20
- export declare function convertAlphaOklchToRgba(obj: ColorStructure): ColorStructure;
21
- export declare const convertHexToRgbString: (hexString: string) => string;
22
- export declare function convertHexValuesToRgb(obj: ColorStructure): ColorStructure;
23
- export declare const convertToAarrggbb: (colorString: string) => string;
24
- export declare function convertToAarrggbbRecursive(obj: ColorStructure): ColorStructure;
25
- export declare function convertColorFormat(obj: ColorStructure, format?: ColorFormat): ColorStructure;
26
- export {};
@@ -1,257 +0,0 @@
1
- import { converter, formatHex } from 'culori';
2
- import { calcOnBrand, getPalette } from './helpers/get-palette';
3
- import { getPromo } from './helpers/get-promo';
4
- import * as DEFAULT_SWATCH from './constants/default-swatch';
5
- import { getLogo } from './helpers/get-logo';
6
- import { getHover, getPressed } from './helpers/get-interactions';
7
- export var ACCENT_PARAMS = ['brand', 'gray'];
8
- export function getBaseTokens(_a) {
9
- var brand = _a.brand,
10
- _b = _a.accent,
11
- accent = _b === void 0 ? 'gray' : _b,
12
- _c = _a.system,
13
- system = _c === void 0 ? DEFAULT_SWATCH.system : _c;
14
- var isPresetColor = brand in DEFAULT_SWATCH.brand;
15
- var brandColor;
16
- if (isPresetColor) {
17
- brandColor = DEFAULT_SWATCH.brand[brand];
18
- } else {
19
- brandColor = brand;
20
- }
21
- var accentColor;
22
- if (accent === 'brand') {
23
- accentColor = brandColor;
24
- } else if (accent !== 'gray') {
25
- accentColor = accent;
26
- }
27
- var brandPalette = getPalette({ color: brandColor });
28
- var accentPalette;
29
- if (accent === 'brand') {
30
- accentPalette = brandPalette;
31
- } else if (accent !== 'gray' && accentColor) {
32
- accentPalette = getPalette({ color: accentColor });
33
- }
34
- var customizablePalettes = {};
35
- for (var colorKey in DEFAULT_SWATCH.customizable) {
36
- var key = colorKey;
37
- if (key === brand && isPresetColor) {
38
- customizablePalettes[key] = brandPalette;
39
- continue;
40
- }
41
- customizablePalettes[key] = getPalette({
42
- color: DEFAULT_SWATCH.customizable[key],
43
- });
44
- }
45
- return {
46
- brand: {
47
- logo: getLogo(brandColor),
48
- promo: getPromo(brandColor),
49
- original: brandColor,
50
- interactions: {
51
- hover: getHover(brandColor),
52
- pressed: getPressed(brandColor),
53
- },
54
- palette: brandPalette,
55
- },
56
- accent: accentColor
57
- ? {
58
- original: {
59
- light: accentColor,
60
- dark: accentColor,
61
- },
62
- interactions: {
63
- hover: getHover(accentColor),
64
- pressed: getPressed(accentColor),
65
- },
66
- palette: accentPalette,
67
- }
68
- : undefined,
69
- warning: getPalette({ color: system.warning }),
70
- error: getPalette({ color: system.error }),
71
- success: getPalette({ color: system.success }),
72
- gray: DEFAULT_SWATCH.gray,
73
- whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
74
- blackAlpha: DEFAULT_SWATCH.blackAlpha,
75
- onBrand: calcOnBrand(brandColor),
76
- onAccent: accentColor ? calcOnBrand(accentColor) : undefined,
77
- customizable: customizablePalettes,
78
- };
79
- }
80
- export function convertOklchToHex(obj) {
81
- if (typeof obj !== 'object' || obj === null) {
82
- return obj;
83
- }
84
- if (Array.isArray(obj)) {
85
- return obj.map(function (item) {
86
- if (typeof item === 'object' && item !== null) {
87
- return convertOklchToHex(item);
88
- }
89
- return item;
90
- });
91
- }
92
- var newObj = {};
93
- for (var key in obj) {
94
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
95
- var value = obj[key];
96
- if (typeof value === 'string' && value.startsWith('oklch(') && !value.includes('/')) {
97
- var oklchColor = converter('oklch')(value);
98
- var rgbColor = converter('rgb')(oklchColor);
99
- value = formatHex(rgbColor);
100
- }
101
- if (typeof value === 'object' && value !== null) {
102
- newObj[key] = convertOklchToHex(value);
103
- } else {
104
- newObj[key] = value;
105
- }
106
- }
107
- }
108
- return newObj;
109
- }
110
- export var convertOklchToRgba = function (oklchString) {
111
- var _a;
112
- var oklch = converter('oklch')(oklchString);
113
- var rgb = converter('rgb')(oklch);
114
- var r = Math.round(rgb.r * 255);
115
- var g = Math.round(rgb.g * 255);
116
- var b = Math.round(rgb.b * 255);
117
- var alpha = (_a = oklch.alpha) !== null && _a !== void 0 ? _a : 1;
118
- return 'rgba('.concat(r, ', ').concat(g, ', ').concat(b, ', ').concat(alpha, ')');
119
- };
120
- export function convertAlphaOklchToRgba(obj) {
121
- if (typeof obj !== 'object' || obj === null) {
122
- return obj;
123
- }
124
- if (Array.isArray(obj)) {
125
- return obj.map(function (item) {
126
- if (typeof item === 'object' && item !== null) {
127
- return convertAlphaOklchToRgba(item);
128
- }
129
- return item;
130
- });
131
- }
132
- var newObj = {};
133
- for (var key in obj) {
134
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
135
- var value = obj[key];
136
- // Конвертируем OKLCH с альфа-каналом (содержит '/') в RGBA
137
- if (typeof value === 'string' && value.includes('oklch(')) {
138
- value = convertOklchToRgba(value);
139
- }
140
- if (typeof value === 'object' && value !== null) {
141
- newObj[key] = convertAlphaOklchToRgba(value);
142
- } else {
143
- newObj[key] = value;
144
- }
145
- }
146
- }
147
- return newObj;
148
- }
149
- export var convertHexToRgbString = function (hexString) {
150
- var _a;
151
- var color = converter('rgb')(hexString);
152
- if (!color) {
153
- return hexString;
154
- }
155
- var r = Math.round(color.r * 255);
156
- var g = Math.round(color.g * 255);
157
- var b = Math.round(color.b * 255);
158
- var alpha = (_a = color.alpha) !== null && _a !== void 0 ? _a : 1;
159
- return alpha === 1
160
- ? 'rgb('.concat(r, ', ').concat(g, ', ').concat(b, ')')
161
- : 'rgba('.concat(r, ', ').concat(g, ', ').concat(b, ', ').concat(alpha, ')');
162
- };
163
- export function convertHexValuesToRgb(obj) {
164
- if (typeof obj !== 'object' || obj === null) {
165
- return obj;
166
- }
167
- if (Array.isArray(obj)) {
168
- return obj.map(function (item) {
169
- if (typeof item === 'object' && item !== null) {
170
- return convertHexValuesToRgb(item);
171
- }
172
- return item;
173
- });
174
- }
175
- var newObj = {};
176
- for (var key in obj) {
177
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
178
- var value = obj[key];
179
- // Конвертируем HEX-строки в RGB(A)-строки
180
- if (typeof value === 'string' && value.startsWith('#')) {
181
- newObj[key] = convertHexToRgbString(value);
182
- } else if (typeof value === 'object' && value !== null) {
183
- newObj[key] = convertHexValuesToRgb(value);
184
- } else {
185
- newObj[key] = value;
186
- }
187
- }
188
- }
189
- return newObj;
190
- }
191
- export var convertToAarrggbb = function (colorString) {
192
- var _a;
193
- var color = converter('rgb')(colorString);
194
- if (!color) {
195
- return colorString;
196
- }
197
- var r = Math.round(color.r * 255);
198
- var g = Math.round(color.g * 255);
199
- var b = Math.round(color.b * 255);
200
- var alpha = Math.round(((_a = color.alpha) !== null && _a !== void 0 ? _a : 1) * 255);
201
- var toHex = function (c) {
202
- return c.toString(16).padStart(2, '0');
203
- };
204
- var rgbHex = ''.concat(toHex(r)).concat(toHex(g)).concat(toHex(b)).toUpperCase();
205
- if (alpha === 255) {
206
- return '#'.concat(rgbHex);
207
- }
208
- return '#'.concat(toHex(alpha)).concat(rgbHex).toUpperCase();
209
- };
210
- export function convertToAarrggbbRecursive(obj) {
211
- if (typeof obj !== 'object' || obj === null) {
212
- return obj;
213
- }
214
- if (Array.isArray(obj)) {
215
- return obj.map(function (item) {
216
- if (typeof item === 'object' && item !== null) {
217
- return convertToAarrggbbRecursive(item);
218
- }
219
- return item;
220
- });
221
- }
222
- var newObj = {};
223
- for (var key in obj) {
224
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
225
- var value = obj[key];
226
- // Конвертируем строки цветов (HEX, RGBA) в AARRGGBB
227
- if (typeof value === 'string') {
228
- newObj[key] = convertToAarrggbb(value); // Измененная логика в этой функции
229
- } else if (typeof value === 'object' && value !== null) {
230
- newObj[key] = convertToAarrggbbRecursive(value);
231
- } else {
232
- newObj[key] = value;
233
- }
234
- }
235
- }
236
- return newObj;
237
- }
238
- export function convertColorFormat(obj, format) {
239
- if (format === void 0) {
240
- format = 'hex/rgba';
241
- }
242
- var result = obj;
243
- result = convertOklchToHex(obj);
244
- result = convertAlphaOklchToRgba(result);
245
- switch (format) {
246
- case 'oklch':
247
- return obj;
248
- case 'hex/rgba':
249
- return result;
250
- case 'rgb/rgba':
251
- return convertHexValuesToRgb(result);
252
- case 'hex-aarrggbb':
253
- return convertToAarrggbbRecursive(result);
254
- default:
255
- return result;
256
- }
257
- }
@@ -1,20 +0,0 @@
1
- import { type ConfigOptions, type ColorFormat } from './get-base-tokens';
2
- import { getDefaultTokens } from './get-default-tokens';
3
- import type { BaseTokens } from './types/base-tokens';
4
- export interface Themed<T> {
5
- light: T;
6
- dark: T;
7
- }
8
- export type DefaultTokensFull = ReturnType<typeof getDefaultTokens>;
9
- export type DefaultTokens = DefaultTokensFull['light' | 'dark'];
10
- export interface SemanticConfigOptions<T> extends ConfigOptions {
11
- theme?: 'light' | 'dark';
12
- overrides?: (base: BaseTokens, defaults?: DefaultTokensFull, params?: SemanticConfigOptions<T>) => Themed<T>;
13
- format?: ColorFormat;
14
- }
15
- export declare function getColors(params: SemanticConfigOptions<DefaultTokens>): DefaultTokens;
16
- export declare function getColors<T>(
17
- params: SemanticConfigOptions<T> & {
18
- overrides: (base: BaseTokens) => Themed<T>;
19
- }
20
- ): Themed<T>;
@@ -1,16 +0,0 @@
1
- import { getBaseTokens, convertColorFormat } from './get-base-tokens';
2
- import { getDefaultTokens } from './get-default-tokens';
3
- var DEFAULT_THEME = 'light';
4
- export function getColors(params) {
5
- var theme = params.theme || DEFAULT_THEME;
6
- var base = getBaseTokens(params);
7
- var defaults = getDefaultTokens(base);
8
- var result;
9
- if (params.overrides) {
10
- result = params.overrides(base, defaults, params)[theme];
11
- } else {
12
- result = defaults[theme];
13
- }
14
- var finalResult = convertColorFormat(result, params.format);
15
- return finalResult;
16
- }