@skbkontur/colors 1.1.2-34230.0 → 1.1.2-73aed.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/dist/cjs/get-base-tokens.d.ts +7 -5
  2. package/dist/cjs/get-base-tokens.js +35 -63
  3. package/dist/cjs/get-default-tokens.d.ts +8 -0
  4. package/dist/cjs/get-default-tokens.js +19 -11
  5. package/dist/cjs/helpers/get-palette.js +58 -64
  6. package/dist/cjs/helpers/get-promo.js +21 -27
  7. package/dist/cjs/types/base-tokens.d.ts +5 -6
  8. package/dist/cjs/utils/format-variable.d.ts +2 -0
  9. package/dist/cjs/utils/format-variable.js +11 -0
  10. package/dist/esm/get-base-tokens.d.ts +7 -5
  11. package/dist/esm/get-base-tokens.js +33 -58
  12. package/dist/esm/get-default-tokens.d.ts +8 -0
  13. package/dist/esm/get-default-tokens.js +19 -11
  14. package/dist/esm/helpers/get-palette.js +58 -64
  15. package/dist/esm/helpers/get-promo.js +21 -27
  16. package/dist/esm/types/base-tokens.d.ts +5 -6
  17. package/dist/esm/utils/format-variable.d.ts +2 -0
  18. package/dist/esm/utils/format-variable.js +6 -0
  19. package/dist/tokens/base/css/brand-blue-deep_accent-gray.css +1 -1
  20. package/dist/tokens/base/css/brand-blue_accent-gray.css +1 -1
  21. package/dist/tokens/base/css/brand-green_accent-gray.css +1 -1
  22. package/dist/tokens/base/css/brand-mint_accent-gray.css +1 -1
  23. package/dist/tokens/base/css/brand-orange_accent-gray.css +1 -1
  24. package/dist/tokens/base/css/brand-purple_accent-gray.css +1 -1
  25. package/dist/tokens/base/css/brand-red_accent-gray.css +1 -1
  26. package/dist/tokens/base/css/brand-violet_accent-gray.css +1 -1
  27. package/dist/tokens/base/js/brand-blue-deep_accent-gray.js +1 -0
  28. package/dist/tokens/base/js/brand-blue_accent-gray.js +1 -0
  29. package/dist/tokens/base/js/brand-green_accent-gray.js +1 -0
  30. package/dist/tokens/base/js/brand-mint_accent-gray.js +1 -0
  31. package/dist/tokens/base/js/brand-orange_accent-gray.js +1 -0
  32. package/dist/tokens/base/js/brand-purple_accent-gray.js +1 -0
  33. package/dist/tokens/base/js/brand-red_accent-gray.js +1 -0
  34. package/dist/tokens/base/js/brand-violet_accent-gray.js +1 -0
  35. package/dist/tokens/base/js-tree/brand-blue-deep_accent-gray.tree.js +1 -0
  36. package/dist/tokens/base/js-tree/brand-blue_accent-gray.tree.js +1 -0
  37. package/dist/tokens/base/js-tree/brand-green_accent-gray.tree.js +1 -0
  38. package/dist/tokens/base/js-tree/brand-mint_accent-gray.tree.js +1 -0
  39. package/dist/tokens/base/js-tree/brand-orange_accent-gray.tree.js +1 -0
  40. package/dist/tokens/base/js-tree/brand-purple_accent-gray.tree.js +1 -0
  41. package/dist/tokens/base/js-tree/brand-red_accent-gray.tree.js +1 -0
  42. package/dist/tokens/base/js-tree/brand-violet_accent-gray.tree.js +1 -0
  43. package/dist/tokens/base/json/brand-blue-deep_accent-gray.json +1 -0
  44. package/dist/tokens/base/json/brand-blue_accent-gray.json +1 -0
  45. package/dist/tokens/base/json/brand-green_accent-gray.json +1 -0
  46. package/dist/tokens/base/json/brand-mint_accent-gray.json +1 -0
  47. package/dist/tokens/base/json/brand-orange_accent-gray.json +1 -0
  48. package/dist/tokens/base/json/brand-purple_accent-gray.json +1 -0
  49. package/dist/tokens/base/json/brand-red_accent-gray.json +1 -0
  50. package/dist/tokens/base/json/brand-violet_accent-gray.json +1 -0
  51. package/dist/tokens/base/json-tree/brand-blue-deep_accent-gray.tree.json +1 -0
  52. package/dist/tokens/base/json-tree/brand-blue_accent-gray.tree.json +1 -0
  53. package/dist/tokens/base/json-tree/brand-green_accent-gray.tree.json +1 -0
  54. package/dist/tokens/base/json-tree/brand-mint_accent-gray.tree.json +1 -0
  55. package/dist/tokens/base/json-tree/brand-orange_accent-gray.tree.json +1 -0
  56. package/dist/tokens/base/json-tree/brand-purple_accent-gray.tree.json +1 -0
  57. package/dist/tokens/base/json-tree/brand-red_accent-gray.tree.json +1 -0
  58. package/dist/tokens/base/json-tree/brand-violet_accent-gray.tree.json +1 -0
  59. package/dist/tokens/base/less/brand-blue-deep_accent-gray.less +1 -1
  60. package/dist/tokens/base/less/brand-blue_accent-gray.less +1 -1
  61. package/dist/tokens/base/less/brand-green_accent-gray.less +1 -1
  62. package/dist/tokens/base/less/brand-mint_accent-gray.less +1 -1
  63. package/dist/tokens/base/less/brand-orange_accent-gray.less +1 -1
  64. package/dist/tokens/base/less/brand-purple_accent-gray.less +1 -1
  65. package/dist/tokens/base/less/brand-red_accent-gray.less +1 -1
  66. package/dist/tokens/base/less/brand-violet_accent-gray.less +1 -1
  67. package/dist/tokens/base/scss/brand-blue-deep_accent-gray.scss +1 -1
  68. package/dist/tokens/base/scss/brand-blue_accent-gray.scss +1 -1
  69. package/dist/tokens/base/scss/brand-green_accent-gray.scss +1 -1
  70. package/dist/tokens/base/scss/brand-mint_accent-gray.scss +1 -1
  71. package/dist/tokens/base/scss/brand-orange_accent-gray.scss +1 -1
  72. package/dist/tokens/base/scss/brand-purple_accent-gray.scss +1 -1
  73. package/dist/tokens/base/scss/brand-red_accent-gray.scss +1 -1
  74. package/dist/tokens/base/scss/brand-violet_accent-gray.scss +1 -1
  75. package/dist/tokens/semantic/css/brand-blue-deep_accent-brand.css +19 -11
  76. package/dist/tokens/semantic/css/brand-blue-deep_accent-gray.css +19 -11
  77. package/dist/tokens/semantic/css/brand-blue_accent-brand.css +19 -11
  78. package/dist/tokens/semantic/css/brand-blue_accent-gray.css +19 -11
  79. package/dist/tokens/semantic/css/brand-green_accent-brand.css +19 -11
  80. package/dist/tokens/semantic/css/brand-green_accent-gray.css +19 -11
  81. package/dist/tokens/semantic/css/brand-mint_accent-brand.css +19 -11
  82. package/dist/tokens/semantic/css/brand-mint_accent-gray.css +19 -11
  83. package/dist/tokens/semantic/css/brand-orange_accent-brand.css +19 -11
  84. package/dist/tokens/semantic/css/brand-orange_accent-gray.css +19 -11
  85. package/dist/tokens/semantic/css/brand-purple_accent-brand.css +19 -11
  86. package/dist/tokens/semantic/css/brand-purple_accent-gray.css +19 -11
  87. package/dist/tokens/semantic/css/brand-red_accent-brand.css +19 -11
  88. package/dist/tokens/semantic/css/brand-red_accent-gray.css +19 -11
  89. package/dist/tokens/semantic/css/brand-violet_accent-brand.css +19 -11
  90. package/dist/tokens/semantic/css/brand-violet_accent-gray.css +19 -11
  91. package/dist/tokens/semantic/js/brand-blue-deep_accent-brand.js +19 -11
  92. package/dist/tokens/semantic/js/brand-blue-deep_accent-gray.js +19 -11
  93. package/dist/tokens/semantic/js/brand-blue_accent-brand.js +19 -11
  94. package/dist/tokens/semantic/js/brand-blue_accent-gray.js +19 -11
  95. package/dist/tokens/semantic/js/brand-green_accent-brand.js +19 -11
  96. package/dist/tokens/semantic/js/brand-green_accent-gray.js +19 -11
  97. package/dist/tokens/semantic/js/brand-mint_accent-brand.js +19 -11
  98. package/dist/tokens/semantic/js/brand-mint_accent-gray.js +19 -11
  99. package/dist/tokens/semantic/js/brand-orange_accent-brand.js +19 -11
  100. package/dist/tokens/semantic/js/brand-orange_accent-gray.js +19 -11
  101. package/dist/tokens/semantic/js/brand-purple_accent-brand.js +19 -11
  102. package/dist/tokens/semantic/js/brand-purple_accent-gray.js +19 -11
  103. package/dist/tokens/semantic/js/brand-red_accent-brand.js +19 -11
  104. package/dist/tokens/semantic/js/brand-red_accent-gray.js +19 -11
  105. package/dist/tokens/semantic/js/brand-violet_accent-brand.js +19 -11
  106. package/dist/tokens/semantic/js/brand-violet_accent-gray.js +19 -11
  107. package/dist/tokens/semantic/json/brand-blue-deep_accent-brand.json +9 -1
  108. package/dist/tokens/semantic/json/brand-blue-deep_accent-gray.json +9 -1
  109. package/dist/tokens/semantic/json/brand-blue_accent-brand.json +9 -1
  110. package/dist/tokens/semantic/json/brand-blue_accent-gray.json +9 -1
  111. package/dist/tokens/semantic/json/brand-green_accent-brand.json +9 -1
  112. package/dist/tokens/semantic/json/brand-green_accent-gray.json +9 -1
  113. package/dist/tokens/semantic/json/brand-mint_accent-brand.json +9 -1
  114. package/dist/tokens/semantic/json/brand-mint_accent-gray.json +9 -1
  115. package/dist/tokens/semantic/json/brand-orange_accent-brand.json +9 -1
  116. package/dist/tokens/semantic/json/brand-orange_accent-gray.json +9 -1
  117. package/dist/tokens/semantic/json/brand-purple_accent-brand.json +9 -1
  118. package/dist/tokens/semantic/json/brand-purple_accent-gray.json +9 -1
  119. package/dist/tokens/semantic/json/brand-red_accent-brand.json +9 -1
  120. package/dist/tokens/semantic/json/brand-red_accent-gray.json +9 -1
  121. package/dist/tokens/semantic/json/brand-violet_accent-brand.json +9 -1
  122. package/dist/tokens/semantic/json/brand-violet_accent-gray.json +9 -1
  123. package/dist/tokens/semantic/less/semantic.less +4 -0
  124. package/dist/tokens/semantic/scss/semantic.scss +4 -0
  125. package/package.json +1 -1
@@ -1,6 +1,11 @@
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 interface ColorObject {
5
+ [key: string]: ColorValue;
6
+ }
7
+ export type ColorValue = string | ColorObject | ColorValue[];
8
+ type ColorStructure = ColorObject | ColorValue[];
4
9
  export interface ConfigOptions {
5
10
  brand: PresetOrCustom<keyof typeof DEFAULT_SWATCH.brand>;
6
11
  accent: PresetOrCustom<'brand' | 'gray'>;
@@ -8,10 +13,7 @@ export interface ConfigOptions {
8
13
  }
9
14
  export declare function getBaseTokens({ brand, accent, system }: ConfigOptions): BaseTokens;
10
15
  export declare const colorToHex: (color: string) => string;
11
- export declare const camelCaseToKebabCase: (str: string) => string;
12
- export declare const kebabCaseToCamelCase: (str: string) => string;
13
- export declare function convertOklchToHex(obj: any): any;
16
+ export declare function convertOklchToHex(obj: ColorStructure): ColorStructure;
14
17
  export declare const convertOklchToRgba: (oklchString: string) => string;
15
- export declare function convertAlphaOklchToRgba(obj: any): any;
16
- export declare function flattenObject(obj: any, prefix?: string): any;
18
+ export declare function convertAlphaOklchToRgba(obj: ColorStructure): ColorStructure;
17
19
  export {};
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -34,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
34
23
  return result;
35
24
  };
36
25
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.flattenObject = exports.convertAlphaOklchToRgba = exports.convertOklchToRgba = exports.convertOklchToHex = exports.kebabCaseToCamelCase = exports.camelCaseToKebabCase = exports.colorToHex = exports.getBaseTokens = void 0;
26
+ exports.convertAlphaOklchToRgba = exports.convertOklchToRgba = exports.convertOklchToHex = exports.colorToHex = exports.getBaseTokens = void 0;
38
27
  var culori_1 = require("culori");
39
28
  var get_palette_1 = require("./helpers/get-palette");
40
29
  var get_promo_1 = require("./helpers/get-promo");
@@ -63,10 +52,9 @@ function getBaseTokens(_a) {
63
52
  });
64
53
  var customizable = {};
65
54
  for (var colorKey in DEFAULT_SWATCH.customizable) {
66
- // @ts-expect-error
67
- customizable[colorKey] = (0, get_palette_1.getPalette)({
68
- // @ts-expect-error
69
- color: DEFAULT_SWATCH.customizable[colorKey],
55
+ var key = colorKey;
56
+ customizable[key] = (0, get_palette_1.getPalette)({
57
+ color: DEFAULT_SWATCH.customizable[key],
70
58
  });
71
59
  }
72
60
  return {
@@ -90,7 +78,7 @@ function getBaseTokens(_a) {
90
78
  hover: (0, get_interactions_1.getHover)(accent === 'brand' ? brandColor : DEFAULT_SWATCH.gray[36]),
91
79
  pressed: (0, get_interactions_1.getPressed)(accent === 'brand' ? brandColor : DEFAULT_SWATCH.gray[36]),
92
80
  },
93
- palette: accentPalette || undefined,
81
+ palette: accentPalette,
94
82
  },
95
83
  warning: warningPalette,
96
84
  error: errorPalette,
@@ -100,7 +88,7 @@ function getBaseTokens(_a) {
100
88
  blackAlpha: DEFAULT_SWATCH.blackAlpha,
101
89
  onBrand: (0, get_palette_1.calcOnBrand)(brandColor),
102
90
  // TODO: настроить для gray
103
- onAccent: (accent === 'brand' && (0, get_palette_1.calcOnBrand)(brandColor)) || undefined,
91
+ onAccent: (accent === 'brand' && (0, get_palette_1.calcOnBrand)(brandColor)),
104
92
  customizable: customizable,
105
93
  };
106
94
  }
@@ -112,50 +100,46 @@ var colorToHex = function (color) {
112
100
  return color;
113
101
  };
114
102
  exports.colorToHex = colorToHex;
115
- var camelCaseToKebabCase = function (str) {
116
- return str.replace(/[A-Z]/g, function (match) { return "-".concat(match.toLowerCase()); });
117
- };
118
- exports.camelCaseToKebabCase = camelCaseToKebabCase;
119
- var kebabCaseToCamelCase = function (str) {
120
- return str.replace(/-(\w)/g, function (_, c) { return c.toUpperCase(); });
121
- };
122
- exports.kebabCaseToCamelCase = kebabCaseToCamelCase;
123
103
  function convertOklchToHex(obj) {
124
104
  if (typeof obj !== 'object' || obj === null) {
125
105
  return obj;
126
106
  }
127
107
  if (Array.isArray(obj)) {
128
- return obj.map(function (item) { return convertOklchToHex(item); });
108
+ return obj.map(function (item) {
109
+ if (typeof item === 'object' && item !== null) {
110
+ return convertOklchToHex(item);
111
+ }
112
+ return item;
113
+ });
129
114
  }
130
115
  var newObj = {};
131
116
  for (var key in obj) {
132
117
  if (Object.prototype.hasOwnProperty.call(obj, key)) {
133
118
  var value = obj[key];
134
119
  if (typeof value === 'string' && value.startsWith('oklch(') && !value.includes('/')) {
135
- try {
136
- var toHex = (0, culori_1.converter)('oklch');
137
- value = (0, culori_1.formatHex)(toHex(value));
138
- }
139
- catch (e) {
140
- console.error("Failed to convert OKLCH to hex: ".concat(value), e);
141
- }
120
+ var oklchColor = (0, culori_1.converter)('oklch')(value);
121
+ var rgbColor = (0, culori_1.converter)('rgb')(oklchColor);
122
+ value = (0, culori_1.formatHex)(rgbColor);
123
+ }
124
+ if (typeof value === 'object' && value !== null) {
125
+ newObj[key] = convertOklchToHex(value);
126
+ }
127
+ else {
128
+ newObj[key] = value;
142
129
  }
143
- newObj[key] = convertOklchToHex(value);
144
130
  }
145
131
  }
146
132
  return newObj;
147
133
  }
148
134
  exports.convertOklchToHex = convertOklchToHex;
149
135
  var convertOklchToRgba = function (oklchString) {
136
+ var _a;
150
137
  var oklch = (0, culori_1.converter)('oklch')(oklchString);
151
138
  var rgb = (0, culori_1.converter)('rgb')(oklch);
152
- if (!rgb) {
153
- throw new Error("Invalid color format: ".concat(oklchString));
154
- }
155
139
  var r = Math.round(rgb.r * 255);
156
140
  var g = Math.round(rgb.g * 255);
157
141
  var b = Math.round(rgb.b * 255);
158
- var alpha = oklch.alpha;
142
+ var alpha = (_a = oklch.alpha) !== null && _a !== void 0 ? _a : 1;
159
143
  return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(alpha, ")");
160
144
  };
161
145
  exports.convertOklchToRgba = convertOklchToRgba;
@@ -164,40 +148,28 @@ function convertAlphaOklchToRgba(obj) {
164
148
  return obj;
165
149
  }
166
150
  if (Array.isArray(obj)) {
167
- return obj.map(function (item) { return convertAlphaOklchToRgba(item); });
151
+ return obj.map(function (item) {
152
+ if (typeof item === 'object' && item !== null) {
153
+ return convertAlphaOklchToRgba(item);
154
+ }
155
+ return item;
156
+ });
168
157
  }
169
158
  var newObj = {};
170
159
  for (var key in obj) {
171
160
  if (Object.prototype.hasOwnProperty.call(obj, key)) {
172
161
  var value = obj[key];
173
162
  if (typeof value === 'string' && value.includes('oklch(')) {
174
- try {
175
- value = (0, exports.convertOklchToRgba)(value);
176
- }
177
- catch (e) {
178
- console.error("Failed to convert OKLCH with alpha to rgba: ".concat(value), e);
179
- }
163
+ value = (0, exports.convertOklchToRgba)(value);
180
164
  }
181
- newObj[key] = convertAlphaOklchToRgba(value);
182
- }
183
- }
184
- return newObj;
185
- }
186
- exports.convertAlphaOklchToRgba = convertAlphaOklchToRgba;
187
- function flattenObject(obj, prefix) {
188
- if (prefix === void 0) { prefix = ''; }
189
- var result = {};
190
- for (var key in obj) {
191
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
192
- var newKey = prefix ? "".concat(prefix, "-").concat((0, exports.camelCaseToKebabCase)(key)) : key;
193
- if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
194
- result = __assign(__assign({}, result), flattenObject(obj[key], newKey));
165
+ if (typeof value === 'object' && value !== null) {
166
+ newObj[key] = convertAlphaOklchToRgba(value);
195
167
  }
196
168
  else {
197
- result[newKey] = obj[key];
169
+ newObj[key] = value;
198
170
  }
199
171
  }
200
172
  }
201
- return result;
173
+ return newObj;
202
174
  }
203
- exports.flattenObject = flattenObject;
175
+ exports.convertAlphaOklchToRgba = convertAlphaOklchToRgba;
@@ -92,6 +92,8 @@ export declare const getDefaultTokens: (base: BaseTokens) => {
92
92
  shapeOtherBasePressed: string;
93
93
  shapeOtherDisabled: string;
94
94
  shapeOtherField: string;
95
+ shapeOtherFieldHover: string;
96
+ shapeOtherFieldPressed: string;
95
97
  shapeOtherLow: string;
96
98
  shapeOtherLowHover: string;
97
99
  shapeOtherLowPressed: string;
@@ -250,6 +252,8 @@ export declare const getDefaultTokens: (base: BaseTokens) => {
250
252
  illustrationBlack: string;
251
253
  illustrationBrand: string;
252
254
  illustrationComplement: string;
255
+ illustrationInvertedNeutral: string;
256
+ illustrationNeutral: string;
253
257
  illustrationOnBrand: string;
254
258
  illustrationOnComplement: string;
255
259
  illustrationPromo: string;
@@ -403,6 +407,8 @@ export declare const getDefaultTokens: (base: BaseTokens) => {
403
407
  shapeOtherBasePressed: string;
404
408
  shapeOtherDisabled: string;
405
409
  shapeOtherField: string;
410
+ shapeOtherFieldHover: string;
411
+ shapeOtherFieldPressed: string;
406
412
  shapeOtherLow: string;
407
413
  shapeOtherLowHover: string;
408
414
  shapeOtherLowPressed: string;
@@ -561,6 +567,8 @@ export declare const getDefaultTokens: (base: BaseTokens) => {
561
567
  illustrationBlack: string;
562
568
  illustrationBrand: string;
563
569
  illustrationComplement: string;
570
+ illustrationInvertedNeutral: string;
571
+ illustrationNeutral: string;
564
572
  illustrationOnBrand: string;
565
573
  illustrationOnComplement: string;
566
574
  illustrationPromo: string;
@@ -89,13 +89,15 @@ var getDefaultTokens = function (base) {
89
89
  shapeHeavySuccess: base.customizable.green.normal[36],
90
90
  shapeHeavyWarning: base.warning.vivid[36],
91
91
  shapeOtherAccentBoldDisabled: base.blackAlpha[32],
92
- shapeOtherBacklessHover: base.blackAlpha[8],
93
- shapeOtherBacklessPressed: base.blackAlpha[12],
92
+ shapeOtherBacklessHover: base.blackAlpha[6],
93
+ shapeOtherBacklessPressed: base.blackAlpha[8],
94
94
  shapeOtherBase: base.gray[100],
95
- shapeOtherBaseHover: base.whiteAlpha[64],
96
- shapeOtherBasePressed: base.whiteAlpha[32],
95
+ shapeOtherBaseHover: base.gray[96],
96
+ shapeOtherBasePressed: base.gray[92],
97
97
  shapeOtherDisabled: base.blackAlpha[6],
98
98
  shapeOtherField: base.gray[100],
99
+ shapeOtherFieldHover: base.gray[96],
100
+ shapeOtherFieldPressed: base.gray[92],
99
101
  shapeOtherLow: base.blackAlpha[6],
100
102
  shapeOtherLowHover: base.blackAlpha[8],
101
103
  shapeOtherLowPressed: base.blackAlpha[12],
@@ -144,7 +146,7 @@ var getDefaultTokens = function (base) {
144
146
  shapeSoftWarning: base.warning.vivid[88],
145
147
  shapeSoftWarningHover: base.warning.normal[84],
146
148
  shapeSoftWarningPressed: base.warning.dim[80],
147
- shapeInvertedBacklessHover: base.whiteAlpha[8],
149
+ shapeInvertedBacklessHover: base.whiteAlpha[6],
148
150
  shapeInvertedBacklessPressed: base.whiteAlpha[4],
149
151
  shapeInvertedDisabled: base.whiteAlpha[6],
150
152
  shapeInvertedNeutralFaintAlpha: base.whiteAlpha[6],
@@ -254,6 +256,8 @@ var getDefaultTokens = function (base) {
254
256
  illustrationBlack: base.gray[16],
255
257
  illustrationBrand: base.brand.original,
256
258
  illustrationComplement: base.brand.promo,
259
+ illustrationInvertedNeutral: base.gray[100],
260
+ illustrationNeutral: base.gray[0],
257
261
  illustrationOnBrand: base.onBrand[100],
258
262
  illustrationOnComplement: base.gray[100],
259
263
  illustrationPromo: base.brand.promo,
@@ -400,13 +404,15 @@ var getDefaultTokens = function (base) {
400
404
  shapeHeavySuccess: base.customizable.green.normal[92],
401
405
  shapeHeavyWarning: base.warning.vivid[92],
402
406
  shapeOtherAccentBoldDisabled: base.whiteAlpha[32],
403
- shapeOtherBacklessHover: base.whiteAlpha[8],
407
+ shapeOtherBacklessHover: base.whiteAlpha[6],
404
408
  shapeOtherBacklessPressed: base.whiteAlpha[4],
405
- shapeOtherBase: base.whiteAlpha[6],
406
- shapeOtherBaseHover: base.whiteAlpha[12],
407
- shapeOtherBasePressed: base.whiteAlpha[4],
409
+ shapeOtherBase: base.gray[32],
410
+ shapeOtherBaseHover: base.gray[36],
411
+ shapeOtherBasePressed: base.gray[28],
408
412
  shapeOtherDisabled: base.whiteAlpha[6],
409
413
  shapeOtherField: base.blackAlpha[12],
414
+ shapeOtherFieldHover: base.whiteAlpha[4],
415
+ shapeOtherFieldPressed: base.blackAlpha[24],
410
416
  shapeOtherLow: base.blackAlpha[24],
411
417
  shapeOtherLowHover: base.blackAlpha[16],
412
418
  shapeOtherLowPressed: base.blackAlpha[32],
@@ -455,8 +461,8 @@ var getDefaultTokens = function (base) {
455
461
  shapeSoftWarning: base.warning.dim[52],
456
462
  shapeSoftWarningHover: base.warning.dim[56],
457
463
  shapeSoftWarningPressed: base.warning.dim[48],
458
- shapeInvertedBacklessHover: base.blackAlpha[8],
459
- shapeInvertedBacklessPressed: base.blackAlpha[12],
464
+ shapeInvertedBacklessHover: base.blackAlpha[6],
465
+ shapeInvertedBacklessPressed: base.blackAlpha[8],
460
466
  shapeInvertedDisabled: base.blackAlpha[6],
461
467
  shapeInvertedNeutralFaintAlpha: base.blackAlpha[6],
462
468
  shapeInvertedNeutralFaintAlphaHover: base.blackAlpha[8],
@@ -565,6 +571,8 @@ var getDefaultTokens = function (base) {
565
571
  illustrationBlack: base.gray[16],
566
572
  illustrationBrand: base.brand.original,
567
573
  illustrationComplement: base.gray[100],
574
+ illustrationInvertedNeutral: base.gray[0],
575
+ illustrationNeutral: base.gray[100],
568
576
  illustrationOnBrand: base.onBrand[100],
569
577
  illustrationOnComplement: base.brand.promo,
570
578
  illustrationPromo: base.brand.promo,
@@ -160,75 +160,69 @@ function findClosestLightnessStep(targetL, availableLightnessSteps) {
160
160
  return closestStep;
161
161
  }
162
162
  function calculateBaseHueAndCorrectionRange(inputColorString, abneyData) {
163
- try {
164
- var toOklch = (0, culori_1.converter)('oklch');
165
- var oklch = toOklch(inputColorString);
166
- if (!oklch) {
167
- console.warn("Could not parse color string: ".concat(inputColorString));
168
- return null;
169
- }
170
- var targetLightness = Math.round(oklch.l * 100);
171
- var targetHue_1 = oklch.h;
172
- if (isNaN(targetHue_1)) {
173
- console.warn("Achromatic color detected (".concat(inputColorString, "). Defaulting hue to 0."));
174
- targetHue_1 = 0;
175
- }
176
- var availableLightnessSteps = Object.keys(abneyData).map(Number);
177
- if (availableLightnessSteps.length === 0) {
178
- console.warn('Abney correction data is empty, cannot calculate base hue.');
179
- return null;
180
- }
181
- var closestLightness = findClosestLightnessStep(targetLightness, availableLightnessSteps);
182
- var lightnessCorrectionData = abneyData[closestLightness];
183
- if (!lightnessCorrectionData) {
184
- console.warn("No Abney correction data for lightness ".concat(closestLightness, "."));
185
- return null;
186
- }
187
- var correctedHueMap_1 = Object.entries(lightnessCorrectionData).map(function (_a) {
188
- var rawHueStr = _a[0], shift = _a[1];
189
- var rawHue = Number(rawHueStr);
190
- return {
191
- rawHue: rawHue,
192
- shift: shift,
193
- correctedHue: (rawHue + shift + 360) % 360,
194
- };
195
- });
196
- correctedHueMap_1.sort(function (a, b) {
197
- if (a.correctedHue !== b.correctedHue) {
198
- return a.correctedHue - b.correctedHue;
199
- }
200
- return a.rawHue - b.rawHue;
201
- });
202
- if (correctedHueMap_1.length === 0) {
203
- console.warn("No hue ranges defined for lightness ".concat(closestLightness, "."));
204
- return null;
205
- }
206
- var findCorrectRange = function () {
207
- var nextRangeIndex = correctedHueMap_1.findIndex(function (range) { return range.correctedHue > targetHue_1; });
208
- if (nextRangeIndex === 0) {
209
- return correctedHueMap_1[correctedHueMap_1.length - 1];
210
- }
211
- if (nextRangeIndex > 0) {
212
- return correctedHueMap_1[nextRangeIndex - 1];
213
- }
214
- return correctedHueMap_1[correctedHueMap_1.length - 1];
215
- };
216
- var selectedRange = findCorrectRange();
217
- if (!selectedRange) {
218
- console.error('Could not determine the correct hue range.');
219
- return null;
220
- }
221
- var baseHue = (targetHue_1 - selectedRange.shift + 360) % 360;
163
+ var toOklch = (0, culori_1.converter)('oklch');
164
+ var oklch = toOklch(inputColorString);
165
+ if (!oklch) {
166
+ console.warn("Could not parse color string: ".concat(inputColorString));
167
+ return null;
168
+ }
169
+ var targetLightness = Math.round(oklch.l * 100);
170
+ var targetHue = oklch.h;
171
+ if (isNaN(targetHue)) {
172
+ console.warn("Achromatic color detected (".concat(inputColorString, "). Defaulting hue to 0."));
173
+ targetHue = 0;
174
+ }
175
+ var availableLightnessSteps = Object.keys(abneyData).map(Number);
176
+ if (availableLightnessSteps.length === 0) {
177
+ console.warn('Abney correction data is empty, cannot calculate base hue.');
178
+ return null;
179
+ }
180
+ var closestLightness = findClosestLightnessStep(targetLightness, availableLightnessSteps);
181
+ var lightnessCorrectionData = abneyData[closestLightness];
182
+ if (!lightnessCorrectionData) {
183
+ console.warn("No Abney correction data for lightness ".concat(closestLightness, "."));
184
+ return null;
185
+ }
186
+ var correctedHueMap = Object.entries(lightnessCorrectionData).map(function (_a) {
187
+ var rawHueStr = _a[0], shift = _a[1];
188
+ var rawHue = Number(rawHueStr);
222
189
  return {
223
- baseHue: baseHue,
224
- correctionLightness: closestLightness,
225
- correctionHueRange: selectedRange.rawHue,
190
+ rawHue: rawHue,
191
+ shift: shift,
192
+ correctedHue: (rawHue + shift + 360) % 360,
226
193
  };
194
+ });
195
+ correctedHueMap.sort(function (a, b) {
196
+ if (a.correctedHue !== b.correctedHue) {
197
+ return a.correctedHue - b.correctedHue;
198
+ }
199
+ return a.rawHue - b.rawHue;
200
+ });
201
+ if (correctedHueMap.length === 0) {
202
+ console.warn("No hue ranges defined for lightness ".concat(closestLightness, "."));
203
+ return null;
227
204
  }
228
- catch (error) {
229
- console.error('Error calculating base hue:', error);
205
+ var findCorrectRange = function () {
206
+ var nextRangeIndex = correctedHueMap.findIndex(function (range) { return range.correctedHue > targetHue; });
207
+ if (nextRangeIndex === 0) {
208
+ return correctedHueMap[correctedHueMap.length - 1];
209
+ }
210
+ if (nextRangeIndex > 0) {
211
+ return correctedHueMap[nextRangeIndex - 1];
212
+ }
213
+ return correctedHueMap[correctedHueMap.length - 1];
214
+ };
215
+ var selectedRange = findCorrectRange();
216
+ if (!selectedRange) {
217
+ console.error('Could not determine the correct hue range.');
230
218
  return null;
231
219
  }
220
+ var baseHue = (targetHue - selectedRange.shift + 360) % 360;
221
+ return {
222
+ baseHue: baseHue,
223
+ correctionLightness: closestLightness,
224
+ correctionHueRange: selectedRange.rawHue,
225
+ };
232
226
  }
233
227
  exports.calculateBaseHueAndCorrectionRange = calculateBaseHueAndCorrectionRange;
234
228
  function calcOnBrand(hex) {
@@ -5,35 +5,29 @@ var culori_1 = require("culori");
5
5
  var promo_hue_shift_1 = require("../constants/promo-hue-shift");
6
6
  function getPromo(color, hueShifts) {
7
7
  if (hueShifts === void 0) { hueShifts = promo_hue_shift_1.PROMO_HUE_SHIFTS; }
8
- try {
9
- var toOklch = (0, culori_1.converter)('oklch');
10
- var oklchColor = toOklch(color);
11
- if (!oklchColor) {
12
- throw new Error("Invalid color string: ".concat(color));
13
- }
14
- var currentHue = oklchColor.h;
15
- var promoHueShift = getPromoHueShift(currentHue, hueShifts);
16
- var correctedHue = (currentHue + promoHueShift + 360) % 360;
17
- var promoLightness = oklchColor.l * 100;
18
- if (promoLightness >= 50) {
19
- promoLightness = promoLightness - 32;
20
- }
21
- promoLightness = Math.min(Math.max(promoLightness, 30), 34);
22
- var promoChroma = 0.1;
23
- var finalLightness = Math.round(promoLightness) / 100;
24
- var finalChroma = Math.round(promoChroma * 100) / 100;
25
- var promoOklch = {
26
- mode: 'oklch',
27
- l: finalLightness,
28
- c: finalChroma,
29
- h: correctedHue,
30
- };
31
- return (0, culori_1.formatHex)((0, culori_1.clampChroma)(promoOklch, 'oklch'));
8
+ var toOklch = (0, culori_1.converter)('oklch');
9
+ var oklchColor = toOklch(color);
10
+ if (!oklchColor) {
11
+ throw new Error("Invalid color string: ".concat(color));
32
12
  }
33
- catch (error) {
34
- console.error('Error generating promo palette:', error);
35
- return '';
13
+ var currentHue = oklchColor.h;
14
+ var promoHueShift = getPromoHueShift(currentHue, hueShifts);
15
+ var correctedHue = (currentHue + promoHueShift + 360) % 360;
16
+ var promoLightness = oklchColor.l * 100;
17
+ if (promoLightness >= 50) {
18
+ promoLightness = promoLightness - 32;
36
19
  }
20
+ promoLightness = Math.min(Math.max(promoLightness, 30), 34);
21
+ var promoChroma = 0.1;
22
+ var finalLightness = Math.round(promoLightness) / 100;
23
+ var finalChroma = Math.round(promoChroma * 100) / 100;
24
+ var promoOklch = {
25
+ mode: 'oklch',
26
+ l: finalLightness,
27
+ c: finalChroma,
28
+ h: correctedHue,
29
+ };
30
+ return (0, culori_1.formatHex)((0, culori_1.clampChroma)(promoOklch, 'oklch'));
37
31
  }
38
32
  exports.getPromo = getPromo;
39
33
  function getPromoHueShift(currentHue, promoHueShifts) {
@@ -42,14 +42,13 @@ export interface ColorPalette {
42
42
  normal: ColorWithScale<ChromaScale>;
43
43
  dim: ColorWithScale<ChromaScale>;
44
44
  }
45
- type ChromaScale = 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96;
46
- type AlphaScale = 4 | 6 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96 | 100;
47
- type GrayScale = 0 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96 | 98 | 100;
48
- type ColorWithScale<T extends string | number> = {
45
+ export type ChromaScale = 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96;
46
+ export type AlphaScale = 4 | 6 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96 | 100;
47
+ export type GrayScale = 0 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96 | 98 | 100;
48
+ export type ColorWithScale<T extends string | number> = {
49
49
  [K in T]: string;
50
50
  };
51
- interface ThemedValue {
51
+ export interface ThemedValue {
52
52
  light: string;
53
53
  dark: string;
54
54
  }
55
- export {};
@@ -0,0 +1,2 @@
1
+ export declare const camelCaseToKebabCase: (str: string) => string;
2
+ export declare const kebabCaseToCamelCase: (str: string) => string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kebabCaseToCamelCase = exports.camelCaseToKebabCase = void 0;
4
+ var camelCaseToKebabCase = function (str) {
5
+ return str.replace(/[A-Z]/g, function (match) { return "-".concat(match.toLowerCase()); });
6
+ };
7
+ exports.camelCaseToKebabCase = camelCaseToKebabCase;
8
+ var kebabCaseToCamelCase = function (str) {
9
+ return str.replace(/-(\w)/g, function (_, c) { return c.toUpperCase(); });
10
+ };
11
+ exports.kebabCaseToCamelCase = kebabCaseToCamelCase;
@@ -1,6 +1,11 @@
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 interface ColorObject {
5
+ [key: string]: ColorValue;
6
+ }
7
+ export type ColorValue = string | ColorObject | ColorValue[];
8
+ type ColorStructure = ColorObject | ColorValue[];
4
9
  export interface ConfigOptions {
5
10
  brand: PresetOrCustom<keyof typeof DEFAULT_SWATCH.brand>;
6
11
  accent: PresetOrCustom<'brand' | 'gray'>;
@@ -8,10 +13,7 @@ export interface ConfigOptions {
8
13
  }
9
14
  export declare function getBaseTokens({ brand, accent, system }: ConfigOptions): BaseTokens;
10
15
  export declare const colorToHex: (color: string) => string;
11
- export declare const camelCaseToKebabCase: (str: string) => string;
12
- export declare const kebabCaseToCamelCase: (str: string) => string;
13
- export declare function convertOklchToHex(obj: any): any;
16
+ export declare function convertOklchToHex(obj: ColorStructure): ColorStructure;
14
17
  export declare const convertOklchToRgba: (oklchString: string) => string;
15
- export declare function convertAlphaOklchToRgba(obj: any): any;
16
- export declare function flattenObject(obj: any, prefix?: string): any;
18
+ export declare function convertAlphaOklchToRgba(obj: ColorStructure): ColorStructure;
17
19
  export {};