@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.
- package/README.md +104 -171
- package/colors.less +319 -0
- package/colors.scss +319 -0
- package/lib/consts/default-swatch.d.ts +108 -0
- package/lib/consts/default-swatch.js +108 -0
- package/{dist/esm/constants/default-swatch.js → lib/consts/default-swatch.ts} +11 -7
- package/lib/consts/params/abney-correction.d.ts +2 -0
- package/lib/consts/params/abney-correction.js +1102 -0
- package/{dist/cjs/constants/abney-correction.js → lib/consts/params/abney-correction.ts} +3 -4
- package/lib/consts/params/chroma-params.d.ts +2 -0
- package/lib/consts/params/chroma-params.js +102 -0
- package/{dist/esm/constants/chroma-settings.js → lib/consts/params/chroma-params.ts} +3 -1
- package/lib/consts/params/interactions.ts +9 -0
- package/lib/consts/params/logo-lightness.d.ts +1 -0
- package/lib/consts/params/logo-lightness.js +1 -0
- package/lib/consts/params/logo-lightness.ts +1 -0
- package/{dist/cjs/constants → lib/consts/params}/promo-hue-shift.d.ts +1 -1
- package/lib/consts/params/promo-hue-shift.js +11 -0
- package/{dist/esm/constants/promo-hue-shift.js → lib/consts/params/promo-hue-shift.ts} +1 -1
- package/{dist/cjs/constants → lib/consts/params}/warning-hue-patch.d.ts +1 -1
- package/lib/consts/params/warning-hue-patch.js +22 -0
- package/{dist/esm/constants/warning-hue-patch.js → lib/consts/params/warning-hue-patch.ts} +1 -1
- package/lib/get-colors-base.d.ts +11 -0
- package/lib/get-colors-base.js +78 -0
- package/lib/get-colors-base.ts +99 -0
- package/lib/get-colors-default-tokens.d.ts +645 -0
- package/lib/get-colors-default-tokens.js +647 -0
- package/lib/get-colors-default-tokens.ts +646 -0
- package/lib/get-colors.d.ts +40 -0
- package/lib/get-colors.js +28 -0
- package/lib/get-colors.ts +65 -0
- package/{dist/cjs → lib}/helpers/get-interactions.d.ts +2 -2
- package/lib/helpers/get-interactions.js +35 -0
- package/lib/helpers/get-interactions.ts +64 -0
- package/{dist/cjs → lib}/helpers/get-logo.d.ts +2 -2
- package/lib/helpers/get-logo.js +25 -0
- package/lib/helpers/get-logo.ts +40 -0
- package/lib/helpers/get-palette.d.ts +51 -0
- package/lib/helpers/get-palette.js +204 -0
- package/lib/helpers/get-palette.ts +261 -0
- package/lib/helpers/get-promo.d.ts +6 -0
- package/lib/helpers/get-promo.js +47 -0
- package/lib/helpers/get-promo.ts +55 -0
- package/lib/types/tokens-base-generator.d.ts +43 -0
- package/{dist/cjs/types/generator-tokens.d.ts → lib/types/tokens-base-generator.ts} +12 -17
- package/lib/types/tokens-base.d.ts +55 -0
- package/{dist/esm/types/base-tokens.d.ts → lib/types/tokens-base.ts} +7 -2
- package/lib/types/tokens.d.ts +12 -0
- package/lib/types/tokens.js +1 -0
- package/lib/types/tokens.ts +18 -0
- package/lib/utils/convert-color.d.ts +3 -0
- package/lib/utils/convert-color.js +144 -0
- package/lib/utils/convert-color.ts +163 -0
- package/lib/utils/format-variable.js +6 -0
- package/lib/utils/format-variable.ts +7 -0
- package/package.json +44 -19
- package/{dist/tokens → tokens}/brand-blue-deep_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-blue-deep_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-blue_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-blue_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-green_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-green_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-mint_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-mint_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-orange_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-purple_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-purple_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-red_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-violet_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-violet_accent-gray.css +33 -33
- package/tokens-mobile/brand-blue-deep_accent-brand.json +718 -0
- package/tokens-mobile/brand-blue-deep_accent-gray.json +718 -0
- package/tokens-mobile/brand-blue_accent-brand.json +718 -0
- package/tokens-mobile/brand-blue_accent-gray.json +718 -0
- package/tokens-mobile/brand-green_accent-brand.json +718 -0
- package/tokens-mobile/brand-green_accent-gray.json +718 -0
- package/tokens-mobile/brand-mint_accent-brand.json +718 -0
- package/tokens-mobile/brand-mint_accent-gray.json +718 -0
- package/tokens-mobile/brand-orange_accent-gray.json +718 -0
- package/tokens-mobile/brand-purple_accent-brand.json +718 -0
- package/tokens-mobile/brand-purple_accent-gray.json +718 -0
- package/tokens-mobile/brand-red_accent-gray.json +718 -0
- package/tokens-mobile/brand-violet_accent-brand.json +718 -0
- package/tokens-mobile/brand-violet_accent-gray.json +718 -0
- package/dist/cjs/constants/abney-correction.d.ts +0 -2
- package/dist/cjs/constants/chroma-settings.d.ts +0 -2
- package/dist/cjs/constants/chroma-settings.js +0 -105
- package/dist/cjs/constants/default-swatch.d.ts +0 -109
- package/dist/cjs/constants/default-swatch.js +0 -112
- package/dist/cjs/constants/interaction-settings.js +0 -19
- package/dist/cjs/constants/logo-lightness.d.ts +0 -1
- package/dist/cjs/constants/logo-lightness.js +0 -4
- package/dist/cjs/constants/promo-hue-shift.js +0 -14
- package/dist/cjs/constants/warning-hue-patch.js +0 -25
- package/dist/cjs/get-base-tokens.d.ts +0 -26
- package/dist/cjs/get-base-tokens.js +0 -319
- package/dist/cjs/get-colors.d.ts +0 -20
- package/dist/cjs/get-colors.js +0 -20
- package/dist/cjs/get-default-tokens.d.ts +0 -645
- package/dist/cjs/get-default-tokens.js +0 -996
- package/dist/cjs/helpers/get-interactions.js +0 -61
- package/dist/cjs/helpers/get-logo.js +0 -32
- package/dist/cjs/helpers/get-palette.d.ts +0 -76
- package/dist/cjs/helpers/get-palette.js +0 -287
- package/dist/cjs/helpers/get-promo.d.ts +0 -12
- package/dist/cjs/helpers/get-promo.js +0 -56
- package/dist/cjs/types/base-tokens.d.ts +0 -125
- package/dist/cjs/types/base-tokens.js +0 -2
- package/dist/cjs/types/generator-tokens.js +0 -2
- package/dist/cjs/utils/format-variable.js +0 -15
- package/dist/colors.default-dark.js +0 -332
- package/dist/colors.default-light.js +0 -336
- package/dist/colors.less +0 -319
- package/dist/colors.scss +0 -319
- package/dist/esm/constants/abney-correction.d.ts +0 -2
- package/dist/esm/constants/abney-correction.js +0 -1102
- package/dist/esm/constants/chroma-settings.d.ts +0 -2
- package/dist/esm/constants/default-swatch.d.ts +0 -109
- package/dist/esm/constants/interaction-settings.d.ts +0 -8
- package/dist/esm/constants/logo-lightness.d.ts +0 -1
- package/dist/esm/constants/logo-lightness.js +0 -1
- package/dist/esm/constants/promo-hue-shift.d.ts +0 -3
- package/dist/esm/constants/warning-hue-patch.d.ts +0 -3
- package/dist/esm/get-base-tokens.d.ts +0 -26
- package/dist/esm/get-base-tokens.js +0 -257
- package/dist/esm/get-colors.d.ts +0 -20
- package/dist/esm/get-colors.js +0 -16
- package/dist/esm/get-default-tokens.d.ts +0 -645
- package/dist/esm/get-default-tokens.js +0 -992
- package/dist/esm/helpers/get-interactions.d.ts +0 -7
- package/dist/esm/helpers/get-interactions.js +0 -49
- package/dist/esm/helpers/get-logo.d.ts +0 -6
- package/dist/esm/helpers/get-logo.js +0 -28
- package/dist/esm/helpers/get-palette.d.ts +0 -76
- package/dist/esm/helpers/get-palette.js +0 -232
- package/dist/esm/helpers/get-promo.d.ts +0 -12
- package/dist/esm/helpers/get-promo.js +0 -51
- package/dist/esm/types/generator-tokens.d.ts +0 -43
- package/dist/esm/utils/format-variable.d.ts +0 -2
- package/dist/esm/utils/format-variable.js +0 -10
- package/dist/tokens-js/brand-blue-deep_accent-brand.js +0 -644
- package/dist/tokens-js/brand-blue-deep_accent-gray.js +0 -644
- package/dist/tokens-js/brand-blue_accent-brand.js +0 -644
- package/dist/tokens-js/brand-blue_accent-gray.js +0 -644
- package/dist/tokens-js/brand-green_accent-brand.js +0 -644
- package/dist/tokens-js/brand-green_accent-gray.js +0 -644
- package/dist/tokens-js/brand-mint_accent-brand.js +0 -644
- package/dist/tokens-js/brand-mint_accent-gray.js +0 -644
- package/dist/tokens-js/brand-orange_accent-gray.js +0 -644
- package/dist/tokens-js/brand-purple_accent-brand.js +0 -644
- package/dist/tokens-js/brand-purple_accent-gray.js +0 -644
- package/dist/tokens-js/brand-red_accent-gray.js +0 -644
- package/dist/tokens-js/brand-violet_accent-brand.js +0 -644
- package/dist/tokens-js/brand-violet_accent-gray.js +0 -644
- package/dist/tokens-mobile/brand-blue-deep_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-blue-deep_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-blue_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-blue_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-green_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-green_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-mint_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-mint_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-orange_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-purple_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-purple_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-red_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-violet_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-violet_accent-gray.json +0 -718
- /package/{dist/colors.js → colors.js} +0 -0
- /package/{dist/cjs/constants/interaction-settings.d.ts → lib/consts/params/interactions.d.ts} +0 -0
- /package/{dist/esm/constants/interaction-settings.js → lib/consts/params/interactions.js} +0 -0
- /package/{dist/esm/types/base-tokens.js → lib/types/tokens-base-generator.js} +0 -0
- /package/{dist/esm/types/generator-tokens.js → lib/types/tokens-base.js} +0 -0
- /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;
|
package/dist/cjs/get-colors.d.ts
DELETED
|
@@ -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>;
|
package/dist/cjs/get-colors.js
DELETED
|
@@ -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;
|