@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,319 +0,0 @@
1
- 'use strict';
2
- var __createBinding =
3
- (this && this.__createBinding) ||
4
- (Object.create
5
- ? function (o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = {
10
- enumerable: true,
11
- get: function () {
12
- return m[k];
13
- },
14
- };
15
- }
16
- Object.defineProperty(o, k2, desc);
17
- }
18
- : function (o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- });
22
- var __setModuleDefault =
23
- (this && this.__setModuleDefault) ||
24
- (Object.create
25
- ? function (o, v) {
26
- Object.defineProperty(o, 'default', { enumerable: true, value: v });
27
- }
28
- : function (o, v) {
29
- o['default'] = v;
30
- });
31
- var __importStar =
32
- (this && this.__importStar) ||
33
- function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null)
37
- for (var k in mod)
38
- if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
39
- __setModuleDefault(result, mod);
40
- return result;
41
- };
42
- Object.defineProperty(exports, '__esModule', { value: true });
43
- exports.convertColorFormat =
44
- exports.convertToAarrggbbRecursive =
45
- exports.convertToAarrggbb =
46
- exports.convertHexValuesToRgb =
47
- exports.convertHexToRgbString =
48
- exports.convertAlphaOklchToRgba =
49
- exports.convertOklchToRgba =
50
- exports.convertOklchToHex =
51
- exports.getBaseTokens =
52
- exports.ACCENT_PARAMS =
53
- void 0;
54
- var culori_1 = require('culori');
55
- var get_palette_1 = require('./helpers/get-palette');
56
- var get_promo_1 = require('./helpers/get-promo');
57
- var DEFAULT_SWATCH = __importStar(require('./constants/default-swatch'));
58
- var get_logo_1 = require('./helpers/get-logo');
59
- var get_interactions_1 = require('./helpers/get-interactions');
60
- exports.ACCENT_PARAMS = ['brand', 'gray'];
61
- function getBaseTokens(_a) {
62
- var brand = _a.brand,
63
- _b = _a.accent,
64
- accent = _b === void 0 ? 'gray' : _b,
65
- _c = _a.system,
66
- system = _c === void 0 ? DEFAULT_SWATCH.system : _c;
67
- var isPresetColor = brand in DEFAULT_SWATCH.brand;
68
- var brandColor;
69
- if (isPresetColor) {
70
- brandColor = DEFAULT_SWATCH.brand[brand];
71
- } else {
72
- brandColor = brand;
73
- }
74
- var accentColor;
75
- if (accent === 'brand') {
76
- accentColor = brandColor;
77
- } else if (accent !== 'gray') {
78
- accentColor = accent;
79
- }
80
- var brandPalette = (0, get_palette_1.getPalette)({ color: brandColor });
81
- var accentPalette;
82
- if (accent === 'brand') {
83
- accentPalette = brandPalette;
84
- } else if (accent !== 'gray' && accentColor) {
85
- accentPalette = (0, get_palette_1.getPalette)({ color: accentColor });
86
- }
87
- var customizablePalettes = {};
88
- for (var colorKey in DEFAULT_SWATCH.customizable) {
89
- var key = colorKey;
90
- if (key === brand && isPresetColor) {
91
- customizablePalettes[key] = brandPalette;
92
- continue;
93
- }
94
- customizablePalettes[key] = (0, get_palette_1.getPalette)({
95
- color: DEFAULT_SWATCH.customizable[key],
96
- });
97
- }
98
- return {
99
- brand: {
100
- logo: (0, get_logo_1.getLogo)(brandColor),
101
- promo: (0, get_promo_1.getPromo)(brandColor),
102
- original: brandColor,
103
- interactions: {
104
- hover: (0, get_interactions_1.getHover)(brandColor),
105
- pressed: (0, get_interactions_1.getPressed)(brandColor),
106
- },
107
- palette: brandPalette,
108
- },
109
- accent: accentColor
110
- ? {
111
- original: {
112
- light: accentColor,
113
- dark: accentColor,
114
- },
115
- interactions: {
116
- hover: (0, get_interactions_1.getHover)(accentColor),
117
- pressed: (0, get_interactions_1.getPressed)(accentColor),
118
- },
119
- palette: accentPalette,
120
- }
121
- : undefined,
122
- warning: (0, get_palette_1.getPalette)({ color: system.warning }),
123
- error: (0, get_palette_1.getPalette)({ color: system.error }),
124
- success: (0, get_palette_1.getPalette)({ color: system.success }),
125
- gray: DEFAULT_SWATCH.gray,
126
- whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
127
- blackAlpha: DEFAULT_SWATCH.blackAlpha,
128
- onBrand: (0, get_palette_1.calcOnBrand)(brandColor),
129
- onAccent: accentColor ? (0, get_palette_1.calcOnBrand)(accentColor) : undefined,
130
- customizable: customizablePalettes,
131
- };
132
- }
133
- exports.getBaseTokens = getBaseTokens;
134
- function convertOklchToHex(obj) {
135
- if (typeof obj !== 'object' || obj === null) {
136
- return obj;
137
- }
138
- if (Array.isArray(obj)) {
139
- return obj.map(function (item) {
140
- if (typeof item === 'object' && item !== null) {
141
- return convertOklchToHex(item);
142
- }
143
- return item;
144
- });
145
- }
146
- var newObj = {};
147
- for (var key in obj) {
148
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
149
- var value = obj[key];
150
- if (typeof value === 'string' && value.startsWith('oklch(') && !value.includes('/')) {
151
- var oklchColor = (0, culori_1.converter)('oklch')(value);
152
- var rgbColor = (0, culori_1.converter)('rgb')(oklchColor);
153
- value = (0, culori_1.formatHex)(rgbColor);
154
- }
155
- if (typeof value === 'object' && value !== null) {
156
- newObj[key] = convertOklchToHex(value);
157
- } else {
158
- newObj[key] = value;
159
- }
160
- }
161
- }
162
- return newObj;
163
- }
164
- exports.convertOklchToHex = convertOklchToHex;
165
- var convertOklchToRgba = function (oklchString) {
166
- var _a;
167
- var oklch = (0, culori_1.converter)('oklch')(oklchString);
168
- var rgb = (0, culori_1.converter)('rgb')(oklch);
169
- var r = Math.round(rgb.r * 255);
170
- var g = Math.round(rgb.g * 255);
171
- var b = Math.round(rgb.b * 255);
172
- var alpha = (_a = oklch.alpha) !== null && _a !== void 0 ? _a : 1;
173
- return 'rgba('.concat(r, ', ').concat(g, ', ').concat(b, ', ').concat(alpha, ')');
174
- };
175
- exports.convertOklchToRgba = convertOklchToRgba;
176
- function convertAlphaOklchToRgba(obj) {
177
- if (typeof obj !== 'object' || obj === null) {
178
- return obj;
179
- }
180
- if (Array.isArray(obj)) {
181
- return obj.map(function (item) {
182
- if (typeof item === 'object' && item !== null) {
183
- return convertAlphaOklchToRgba(item);
184
- }
185
- return item;
186
- });
187
- }
188
- var newObj = {};
189
- for (var key in obj) {
190
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
191
- var value = obj[key];
192
- // Конвертируем OKLCH с альфа-каналом (содержит '/') в RGBA
193
- if (typeof value === 'string' && value.includes('oklch(')) {
194
- value = (0, exports.convertOklchToRgba)(value);
195
- }
196
- if (typeof value === 'object' && value !== null) {
197
- newObj[key] = convertAlphaOklchToRgba(value);
198
- } else {
199
- newObj[key] = value;
200
- }
201
- }
202
- }
203
- return newObj;
204
- }
205
- exports.convertAlphaOklchToRgba = convertAlphaOklchToRgba;
206
- var convertHexToRgbString = function (hexString) {
207
- var _a;
208
- var color = (0, culori_1.converter)('rgb')(hexString);
209
- if (!color) {
210
- return hexString;
211
- }
212
- var r = Math.round(color.r * 255);
213
- var g = Math.round(color.g * 255);
214
- var b = Math.round(color.b * 255);
215
- var alpha = (_a = color.alpha) !== null && _a !== void 0 ? _a : 1;
216
- return alpha === 1
217
- ? 'rgb('.concat(r, ', ').concat(g, ', ').concat(b, ')')
218
- : 'rgba('.concat(r, ', ').concat(g, ', ').concat(b, ', ').concat(alpha, ')');
219
- };
220
- exports.convertHexToRgbString = convertHexToRgbString;
221
- function convertHexValuesToRgb(obj) {
222
- if (typeof obj !== 'object' || obj === null) {
223
- return obj;
224
- }
225
- if (Array.isArray(obj)) {
226
- return obj.map(function (item) {
227
- if (typeof item === 'object' && item !== null) {
228
- return convertHexValuesToRgb(item);
229
- }
230
- return item;
231
- });
232
- }
233
- var newObj = {};
234
- for (var key in obj) {
235
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
236
- var value = obj[key];
237
- // Конвертируем HEX-строки в RGB(A)-строки
238
- if (typeof value === 'string' && value.startsWith('#')) {
239
- newObj[key] = (0, exports.convertHexToRgbString)(value);
240
- } else if (typeof value === 'object' && value !== null) {
241
- newObj[key] = convertHexValuesToRgb(value);
242
- } else {
243
- newObj[key] = value;
244
- }
245
- }
246
- }
247
- return newObj;
248
- }
249
- exports.convertHexValuesToRgb = convertHexValuesToRgb;
250
- var convertToAarrggbb = function (colorString) {
251
- var _a;
252
- var color = (0, culori_1.converter)('rgb')(colorString);
253
- if (!color) {
254
- return colorString;
255
- }
256
- var r = Math.round(color.r * 255);
257
- var g = Math.round(color.g * 255);
258
- var b = Math.round(color.b * 255);
259
- var alpha = Math.round(((_a = color.alpha) !== null && _a !== void 0 ? _a : 1) * 255);
260
- var toHex = function (c) {
261
- return c.toString(16).padStart(2, '0');
262
- };
263
- var rgbHex = ''.concat(toHex(r)).concat(toHex(g)).concat(toHex(b)).toUpperCase();
264
- if (alpha === 255) {
265
- return '#'.concat(rgbHex);
266
- }
267
- return '#'.concat(toHex(alpha)).concat(rgbHex).toUpperCase();
268
- };
269
- exports.convertToAarrggbb = convertToAarrggbb;
270
- function convertToAarrggbbRecursive(obj) {
271
- if (typeof obj !== 'object' || obj === null) {
272
- return obj;
273
- }
274
- if (Array.isArray(obj)) {
275
- return obj.map(function (item) {
276
- if (typeof item === 'object' && item !== null) {
277
- return convertToAarrggbbRecursive(item);
278
- }
279
- return item;
280
- });
281
- }
282
- var newObj = {};
283
- for (var key in obj) {
284
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
285
- var value = obj[key];
286
- // Конвертируем строки цветов (HEX, RGBA) в AARRGGBB
287
- if (typeof value === 'string') {
288
- newObj[key] = (0, exports.convertToAarrggbb)(value); // Измененная логика в этой функции
289
- } else if (typeof value === 'object' && value !== null) {
290
- newObj[key] = convertToAarrggbbRecursive(value);
291
- } else {
292
- newObj[key] = value;
293
- }
294
- }
295
- }
296
- return newObj;
297
- }
298
- exports.convertToAarrggbbRecursive = convertToAarrggbbRecursive;
299
- function convertColorFormat(obj, format) {
300
- if (format === void 0) {
301
- format = 'hex/rgba';
302
- }
303
- var result = obj;
304
- result = convertOklchToHex(obj);
305
- result = convertAlphaOklchToRgba(result);
306
- switch (format) {
307
- case 'oklch':
308
- return obj;
309
- case 'hex/rgba':
310
- return result;
311
- case 'rgb/rgba':
312
- return convertHexValuesToRgb(result);
313
- case 'hex-aarrggbb':
314
- return convertToAarrggbbRecursive(result);
315
- default:
316
- return result;
317
- }
318
- }
319
- exports.convertColorFormat = convertColorFormat;
@@ -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,20 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.getColors = void 0;
4
- var get_base_tokens_1 = require('./get-base-tokens');
5
- var get_default_tokens_1 = require('./get-default-tokens');
6
- var DEFAULT_THEME = 'light';
7
- function getColors(params) {
8
- var theme = params.theme || DEFAULT_THEME;
9
- var base = (0, get_base_tokens_1.getBaseTokens)(params);
10
- var defaults = (0, get_default_tokens_1.getDefaultTokens)(base);
11
- var result;
12
- if (params.overrides) {
13
- result = params.overrides(base, defaults, params)[theme];
14
- } else {
15
- result = defaults[theme];
16
- }
17
- var finalResult = (0, get_base_tokens_1.convertColorFormat)(result, params.format);
18
- return finalResult;
19
- }
20
- exports.getColors = getColors;