@skbkontur/colors 1.1.2-d1791.0 → 2.0.0-alpha.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.
- package/dist/cjs/constants/abney-correction.js +1102 -1102
- package/dist/cjs/constants/chroma-settings.js +102 -102
- package/dist/cjs/constants/default-swatch.d.ts +97 -95
- package/dist/cjs/constants/default-swatch.js +99 -97
- package/dist/cjs/constants/interaction-settings.d.ts +8 -0
- package/dist/cjs/constants/interaction-settings.js +19 -0
- package/dist/cjs/constants/logo-lightness.js +2 -2
- package/dist/cjs/constants/promo-hue-shift.d.ts +1 -1
- package/dist/cjs/constants/promo-hue-shift.js +11 -11
- package/dist/cjs/constants/warning-hue-patch.d.ts +1 -1
- package/dist/cjs/constants/warning-hue-patch.js +22 -22
- package/dist/cjs/get-base-tokens.d.ts +11 -9
- package/dist/cjs/get-base-tokens.js +178 -202
- package/dist/cjs/get-colors.d.ts +19 -0
- package/dist/cjs/get-colors.js +16 -0
- package/dist/cjs/get-default-tokens.d.ts +642 -1275
- package/dist/cjs/get-default-tokens.js +993 -1280
- package/dist/cjs/helpers/get-interactions.d.ts +7 -0
- package/dist/cjs/helpers/get-interactions.js +61 -0
- package/dist/cjs/helpers/get-logo.d.ts +2 -2
- package/dist/cjs/helpers/get-logo.js +28 -25
- package/dist/cjs/helpers/get-palette.d.ts +69 -42
- package/dist/cjs/helpers/get-palette.js +249 -204
- package/dist/cjs/helpers/get-promo.d.ts +10 -4
- package/dist/cjs/helpers/get-promo.js +48 -50
- package/dist/cjs/types/base-tokens.d.ts +115 -43
- package/dist/cjs/types/base-tokens.js +2 -2
- package/dist/cjs/types/generator-tokens.d.ts +30 -30
- package/dist/cjs/types/generator-tokens.js +2 -2
- package/dist/cjs/utils/format-variable.d.ts +2 -0
- package/dist/cjs/utils/format-variable.js +15 -0
- package/dist/colors.default-dark.js +325 -0
- package/dist/colors.default-light.js +326 -0
- package/dist/colors.js +319 -0
- package/dist/colors.less +319 -0
- package/dist/colors.scss +319 -0
- package/dist/esm/constants/abney-correction.js +1100 -1100
- package/dist/esm/constants/chroma-settings.js +100 -100
- package/dist/esm/constants/default-swatch.d.ts +97 -95
- package/dist/esm/constants/default-swatch.js +97 -95
- package/dist/esm/constants/interaction-settings.d.ts +8 -0
- package/dist/esm/constants/interaction-settings.js +8 -0
- package/dist/esm/constants/promo-hue-shift.d.ts +1 -1
- package/dist/esm/constants/promo-hue-shift.js +9 -9
- package/dist/esm/constants/warning-hue-patch.d.ts +1 -1
- package/dist/esm/constants/warning-hue-patch.js +20 -20
- package/dist/esm/get-base-tokens.d.ts +11 -9
- package/dist/esm/get-base-tokens.js +130 -172
- package/dist/esm/get-colors.d.ts +19 -0
- package/dist/esm/get-colors.js +12 -0
- package/dist/esm/get-default-tokens.d.ts +642 -1275
- package/dist/esm/get-default-tokens.js +991 -1278
- package/dist/esm/helpers/get-interactions.d.ts +7 -0
- package/dist/esm/helpers/get-interactions.js +49 -0
- package/dist/esm/helpers/get-logo.d.ts +2 -2
- package/dist/esm/helpers/get-logo.js +24 -21
- package/dist/esm/helpers/get-palette.d.ts +69 -42
- package/dist/esm/helpers/get-palette.js +197 -175
- package/dist/esm/helpers/get-promo.d.ts +10 -4
- package/dist/esm/helpers/get-promo.js +44 -46
- package/dist/esm/types/base-tokens.d.ts +115 -43
- package/dist/esm/types/generator-tokens.d.ts +30 -30
- package/dist/esm/utils/format-variable.d.ts +2 -0
- package/dist/esm/utils/format-variable.js +10 -0
- package/dist/tokens/brand-blue-deep_accent-brand.css +643 -0
- package/dist/tokens/brand-blue-deep_accent-gray.css +643 -0
- package/dist/tokens/brand-blue_accent-brand.css +643 -0
- package/dist/tokens/brand-blue_accent-gray.css +643 -0
- package/dist/tokens/brand-green_accent-brand.css +643 -0
- package/dist/tokens/brand-green_accent-gray.css +643 -0
- package/dist/tokens/brand-mint_accent-brand.css +643 -0
- package/dist/tokens/brand-mint_accent-gray.css +643 -0
- package/dist/tokens/brand-orange_accent-gray.css +643 -0
- package/dist/tokens/brand-purple_accent-brand.css +643 -0
- package/dist/tokens/brand-purple_accent-gray.css +643 -0
- package/dist/tokens/brand-red_accent-gray.css +643 -0
- package/dist/tokens/brand-violet_accent-brand.css +643 -0
- package/dist/tokens/brand-violet_accent-gray.css +643 -0
- package/dist/tokens-js/brand-blue-deep_accent-brand.js +644 -0
- package/dist/tokens-js/brand-blue-deep_accent-gray.js +644 -0
- package/dist/tokens-js/brand-blue_accent-brand.js +644 -0
- package/dist/tokens-js/brand-blue_accent-gray.js +644 -0
- package/dist/tokens-js/brand-green_accent-brand.js +644 -0
- package/dist/tokens-js/brand-green_accent-gray.js +644 -0
- package/dist/tokens-js/brand-mint_accent-brand.js +644 -0
- package/dist/tokens-js/brand-mint_accent-gray.js +644 -0
- package/dist/tokens-js/brand-orange_accent-gray.js +644 -0
- package/dist/tokens-js/brand-purple_accent-brand.js +644 -0
- package/dist/tokens-js/brand-purple_accent-gray.js +644 -0
- package/dist/tokens-js/brand-red_accent-gray.js +644 -0
- package/dist/tokens-js/brand-violet_accent-brand.js +644 -0
- package/dist/tokens-js/brand-violet_accent-gray.js +644 -0
- package/dist/tokens-mobile/brand-blue-deep_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-blue-deep_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-blue_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-blue_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-green_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-green_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-mint_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-mint_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-orange_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-purple_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-purple_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-red_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-violet_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-violet_accent-gray.json +718 -0
- package/package.json +7 -6
- package/dist/cjs/get-tokens.d.ts +0 -15
- package/dist/cjs/get-tokens.js +0 -13
- package/dist/esm/get-tokens.d.ts +0 -15
- package/dist/esm/get-tokens.js +0 -9
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.PROMO_HUE_SHIFTS = void 0;
|
|
4
4
|
exports.PROMO_HUE_SHIFTS = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
0: -24,
|
|
6
|
+
25: -32,
|
|
7
|
+
44: -35,
|
|
8
|
+
148: 40,
|
|
9
|
+
177: 51,
|
|
10
|
+
253: 11,
|
|
11
|
+
264: 14,
|
|
12
|
+
294: 0,
|
|
13
|
+
319: -24,
|
|
14
14
|
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.WARNING_HUE_PATCH = void 0;
|
|
4
4
|
exports.WARNING_HUE_PATCH = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
96: 0,
|
|
6
|
+
92: 0,
|
|
7
|
+
88: 0,
|
|
8
|
+
84: 0,
|
|
9
|
+
80: 0,
|
|
10
|
+
76: 0,
|
|
11
|
+
72: -4,
|
|
12
|
+
68: -8,
|
|
13
|
+
64: -12,
|
|
14
|
+
60: -8,
|
|
15
|
+
56: -4,
|
|
16
|
+
52: -2,
|
|
17
|
+
48: 0,
|
|
18
|
+
44: 0,
|
|
19
|
+
40: 0,
|
|
20
|
+
36: 0,
|
|
21
|
+
32: 0,
|
|
22
|
+
28: 0,
|
|
23
|
+
24: 0,
|
|
24
|
+
20: 0,
|
|
25
25
|
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import * as DEFAULT_SWATCH from './constants/default-swatch';
|
|
2
2
|
import type { BaseTokens } from './types/base-tokens';
|
|
3
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[];
|
|
4
10
|
export interface ConfigOptions {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
brand: PresetOrCustom<keyof typeof DEFAULT_SWATCH.brand>;
|
|
12
|
+
accent: PresetOrCustom<(typeof ACCENT_PARAMS)[number]>;
|
|
13
|
+
system?: typeof DEFAULT_SWATCH.system;
|
|
8
14
|
}
|
|
9
15
|
export declare function getBaseTokens({ brand, accent, system }: ConfigOptions): BaseTokens;
|
|
10
|
-
export declare
|
|
11
|
-
export declare const camelCaseToKebabCase: (str: string) => string;
|
|
12
|
-
export declare const kebabCaseToCamelCase: (str: string) => string;
|
|
13
|
-
export declare function convertOklchToHex(obj: any): any;
|
|
16
|
+
export declare function convertOklchToHex(obj: ColorStructure): ColorStructure;
|
|
14
17
|
export declare const convertOklchToRgba: (oklchString: string) => string;
|
|
15
|
-
export declare function convertAlphaOklchToRgba(obj:
|
|
16
|
-
export declare function flattenObject(obj: any, prefix?: string): any;
|
|
18
|
+
export declare function convertAlphaOklchToRgba(obj: ColorStructure): ColorStructure;
|
|
17
19
|
export {};
|
|
@@ -1,223 +1,199 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
};
|
|
8
15
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
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) {
|
|
30
34
|
if (mod && mod.__esModule) return mod;
|
|
31
35
|
var result = {};
|
|
32
|
-
if (mod != null)
|
|
36
|
+
if (mod != null)
|
|
37
|
+
for (var k in mod)
|
|
38
|
+
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
39
|
__setModuleDefault(result, mod);
|
|
34
40
|
return result;
|
|
35
|
-
};
|
|
36
|
-
Object.defineProperty(exports,
|
|
37
|
-
exports.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
43
|
+
exports.convertAlphaOklchToRgba =
|
|
44
|
+
exports.convertOklchToRgba =
|
|
45
|
+
exports.convertOklchToHex =
|
|
46
|
+
exports.getBaseTokens =
|
|
47
|
+
exports.ACCENT_PARAMS =
|
|
48
|
+
void 0;
|
|
49
|
+
var culori_1 = require('culori');
|
|
50
|
+
var get_palette_1 = require('./helpers/get-palette');
|
|
51
|
+
var get_promo_1 = require('./helpers/get-promo');
|
|
52
|
+
var DEFAULT_SWATCH = __importStar(require('./constants/default-swatch'));
|
|
53
|
+
var get_logo_1 = require('./helpers/get-logo');
|
|
54
|
+
var get_interactions_1 = require('./helpers/get-interactions');
|
|
55
|
+
exports.ACCENT_PARAMS = ['brand', 'gray'];
|
|
43
56
|
function getBaseTokens(_a) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
var brand = _a.brand,
|
|
58
|
+
_b = _a.accent,
|
|
59
|
+
accent = _b === void 0 ? 'gray' : _b,
|
|
60
|
+
_c = _a.system,
|
|
61
|
+
system = _c === void 0 ? DEFAULT_SWATCH.system : _c;
|
|
62
|
+
var isPresetColor = brand in DEFAULT_SWATCH.brand;
|
|
63
|
+
var brandColor;
|
|
64
|
+
if (isPresetColor) {
|
|
65
|
+
brandColor = DEFAULT_SWATCH.brand[brand];
|
|
66
|
+
} else {
|
|
67
|
+
brandColor = brand;
|
|
68
|
+
}
|
|
69
|
+
var accentColor;
|
|
70
|
+
if (accent === 'brand') {
|
|
71
|
+
accentColor = brandColor;
|
|
72
|
+
} else if (accent !== 'gray') {
|
|
73
|
+
accentColor = accent;
|
|
74
|
+
}
|
|
75
|
+
var brandPalette = (0, get_palette_1.getPalette)({ color: brandColor });
|
|
76
|
+
var accentPalette;
|
|
77
|
+
if (accent === 'brand') {
|
|
78
|
+
accentPalette = brandPalette;
|
|
79
|
+
} else if (accent !== 'gray' && accentColor) {
|
|
80
|
+
accentPalette = (0, get_palette_1.getPalette)({ color: accentColor });
|
|
81
|
+
}
|
|
82
|
+
var customizablePalettes = {};
|
|
83
|
+
for (var colorKey in DEFAULT_SWATCH.customizable) {
|
|
84
|
+
var key = colorKey;
|
|
85
|
+
if (key === brand && isPresetColor) {
|
|
86
|
+
customizablePalettes[key] = brandPalette;
|
|
87
|
+
continue;
|
|
57
88
|
}
|
|
58
|
-
|
|
59
|
-
|
|
89
|
+
customizablePalettes[key] = (0, get_palette_1.getPalette)({
|
|
90
|
+
color: DEFAULT_SWATCH.customizable[key],
|
|
60
91
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
light:
|
|
77
|
-
dark:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
palette: brandPalette,
|
|
97
|
-
},
|
|
98
|
-
accent: {
|
|
99
|
-
original: {
|
|
100
|
-
// todo Fix gray
|
|
101
|
-
light: accent === 'gray' ? accent : '#3d3d3d',
|
|
102
|
-
dark: accent === 'gray' ? accent : '#3d3d3d',
|
|
103
|
-
},
|
|
104
|
-
// todo interactions
|
|
105
|
-
interactions: {
|
|
106
|
-
hover: {
|
|
107
|
-
light: '',
|
|
108
|
-
dark: '',
|
|
109
|
-
},
|
|
110
|
-
pressed: {
|
|
111
|
-
light: '',
|
|
112
|
-
dark: '',
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
palette: accentPalette || undefined,
|
|
116
|
-
},
|
|
117
|
-
warning: warningPalette,
|
|
118
|
-
error: errorPalette,
|
|
119
|
-
success: successPalette,
|
|
120
|
-
gray: DEFAULT_SWATCH.gray,
|
|
121
|
-
whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
|
|
122
|
-
blackAlpha: DEFAULT_SWATCH.blackAlpha,
|
|
123
|
-
onBrand: (0, get_palette_1.calcOnBrand)(brandColor),
|
|
124
|
-
customizable: customizable,
|
|
125
|
-
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
brand: {
|
|
95
|
+
logo: (0, get_logo_1.getLogo)(brandColor),
|
|
96
|
+
promo: (0, get_promo_1.getPromo)(brandColor),
|
|
97
|
+
original: brandColor,
|
|
98
|
+
interactions: {
|
|
99
|
+
hover: (0, get_interactions_1.getHover)(brandColor),
|
|
100
|
+
pressed: (0, get_interactions_1.getPressed)(brandColor),
|
|
101
|
+
},
|
|
102
|
+
palette: brandPalette,
|
|
103
|
+
},
|
|
104
|
+
accent: accentColor
|
|
105
|
+
? {
|
|
106
|
+
original: {
|
|
107
|
+
light: accentColor,
|
|
108
|
+
dark: accentColor,
|
|
109
|
+
},
|
|
110
|
+
interactions: {
|
|
111
|
+
hover: (0, get_interactions_1.getHover)(accentColor),
|
|
112
|
+
pressed: (0, get_interactions_1.getPressed)(accentColor),
|
|
113
|
+
},
|
|
114
|
+
palette: accentPalette,
|
|
115
|
+
}
|
|
116
|
+
: undefined,
|
|
117
|
+
warning: (0, get_palette_1.getPalette)({ color: system.warning }),
|
|
118
|
+
error: (0, get_palette_1.getPalette)({ color: system.error }),
|
|
119
|
+
success: (0, get_palette_1.getPalette)({ color: system.success }),
|
|
120
|
+
gray: DEFAULT_SWATCH.gray,
|
|
121
|
+
whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
|
|
122
|
+
blackAlpha: DEFAULT_SWATCH.blackAlpha,
|
|
123
|
+
onBrand: (0, get_palette_1.calcOnBrand)(brandColor),
|
|
124
|
+
onAccent: accentColor ? (0, get_palette_1.calcOnBrand)(accentColor) : undefined,
|
|
125
|
+
customizable: customizablePalettes,
|
|
126
|
+
};
|
|
126
127
|
}
|
|
127
128
|
exports.getBaseTokens = getBaseTokens;
|
|
128
|
-
var colorToHex = function (color) {
|
|
129
|
-
if (DEFAULT_SWATCH.brand[color]) {
|
|
130
|
-
return DEFAULT_SWATCH.brand[color];
|
|
131
|
-
}
|
|
132
|
-
return color;
|
|
133
|
-
};
|
|
134
|
-
exports.colorToHex = colorToHex;
|
|
135
|
-
var camelCaseToKebabCase = function (str) {
|
|
136
|
-
return str.replace(/[A-Z]/g, function (match) { return "-".concat(match.toLowerCase()); });
|
|
137
|
-
};
|
|
138
|
-
exports.camelCaseToKebabCase = camelCaseToKebabCase;
|
|
139
|
-
var kebabCaseToCamelCase = function (str) {
|
|
140
|
-
return str.replace(/-(\w)/g, function (_, c) { return c.toUpperCase(); });
|
|
141
|
-
};
|
|
142
|
-
exports.kebabCaseToCamelCase = kebabCaseToCamelCase;
|
|
143
129
|
function convertOklchToHex(obj) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
130
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
131
|
+
return obj;
|
|
132
|
+
}
|
|
133
|
+
if (Array.isArray(obj)) {
|
|
134
|
+
return obj.map(function (item) {
|
|
135
|
+
if (typeof item === 'object' && item !== null) {
|
|
136
|
+
return convertOklchToHex(item);
|
|
137
|
+
}
|
|
138
|
+
return item;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
var newObj = {};
|
|
142
|
+
for (var key in obj) {
|
|
143
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
144
|
+
var value = obj[key];
|
|
145
|
+
if (typeof value === 'string' && value.startsWith('oklch(') && !value.includes('/')) {
|
|
146
|
+
var oklchColor = (0, culori_1.converter)('oklch')(value);
|
|
147
|
+
var rgbColor = (0, culori_1.converter)('rgb')(oklchColor);
|
|
148
|
+
value = (0, culori_1.formatHex)(rgbColor);
|
|
149
|
+
}
|
|
150
|
+
if (typeof value === 'object' && value !== null) {
|
|
151
|
+
newObj[key] = convertOklchToHex(value);
|
|
152
|
+
} else {
|
|
153
|
+
newObj[key] = value;
|
|
154
|
+
}
|
|
165
155
|
}
|
|
166
|
-
|
|
156
|
+
}
|
|
157
|
+
return newObj;
|
|
167
158
|
}
|
|
168
159
|
exports.convertOklchToHex = convertOklchToHex;
|
|
169
160
|
var convertOklchToRgba = function (oklchString) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
var alpha = oklch.alpha;
|
|
179
|
-
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(alpha, ")");
|
|
161
|
+
var _a;
|
|
162
|
+
var oklch = (0, culori_1.converter)('oklch')(oklchString);
|
|
163
|
+
var rgb = (0, culori_1.converter)('rgb')(oklch);
|
|
164
|
+
var r = Math.round(rgb.r * 255);
|
|
165
|
+
var g = Math.round(rgb.g * 255);
|
|
166
|
+
var b = Math.round(rgb.b * 255);
|
|
167
|
+
var alpha = (_a = oklch.alpha) !== null && _a !== void 0 ? _a : 1;
|
|
168
|
+
return 'rgba('.concat(r, ', ').concat(g, ', ').concat(b, ', ').concat(alpha, ')');
|
|
180
169
|
};
|
|
181
170
|
exports.convertOklchToRgba = convertOklchToRgba;
|
|
182
171
|
function convertAlphaOklchToRgba(obj) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
172
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
173
|
+
return obj;
|
|
174
|
+
}
|
|
175
|
+
if (Array.isArray(obj)) {
|
|
176
|
+
return obj.map(function (item) {
|
|
177
|
+
if (typeof item === 'object' && item !== null) {
|
|
178
|
+
return convertAlphaOklchToRgba(item);
|
|
179
|
+
}
|
|
180
|
+
return item;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
var newObj = {};
|
|
184
|
+
for (var key in obj) {
|
|
185
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
186
|
+
var value = obj[key];
|
|
187
|
+
if (typeof value === 'string' && value.includes('oklch(')) {
|
|
188
|
+
value = (0, exports.convertOklchToRgba)(value);
|
|
189
|
+
}
|
|
190
|
+
if (typeof value === 'object' && value !== null) {
|
|
191
|
+
newObj[key] = convertAlphaOklchToRgba(value);
|
|
192
|
+
} else {
|
|
193
|
+
newObj[key] = value;
|
|
194
|
+
}
|
|
203
195
|
}
|
|
204
|
-
|
|
196
|
+
}
|
|
197
|
+
return newObj;
|
|
205
198
|
}
|
|
206
199
|
exports.convertAlphaOklchToRgba = convertAlphaOklchToRgba;
|
|
207
|
-
function flattenObject(obj, prefix) {
|
|
208
|
-
if (prefix === void 0) { prefix = ''; }
|
|
209
|
-
var result = {};
|
|
210
|
-
for (var key in obj) {
|
|
211
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
212
|
-
var newKey = prefix ? "".concat(prefix, "-").concat((0, exports.camelCaseToKebabCase)(key)) : key;
|
|
213
|
-
if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
|
|
214
|
-
result = __assign(__assign({}, result), flattenObject(obj[key], newKey));
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
result[newKey] = obj[key];
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return result;
|
|
222
|
-
}
|
|
223
|
-
exports.flattenObject = flattenObject;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ConfigOptions } 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
|
+
}
|
|
14
|
+
export declare function getColors(params: SemanticConfigOptions<DefaultTokens>): DefaultTokens;
|
|
15
|
+
export declare function getColors<T>(
|
|
16
|
+
params: SemanticConfigOptions<T> & {
|
|
17
|
+
overrides: (base: BaseTokens) => Themed<T>;
|
|
18
|
+
}
|
|
19
|
+
): Themed<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
if (params.overrides) {
|
|
12
|
+
return params.overrides(base, defaults, params)[theme];
|
|
13
|
+
}
|
|
14
|
+
return defaults[theme];
|
|
15
|
+
}
|
|
16
|
+
exports.getColors = getColors;
|