anubis-ui 1.3.0 → 1.4.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 (60) hide show
  1. package/README.md +206 -74
  2. package/dist/interfaces/color.interface.d.ts +8 -0
  3. package/dist/interfaces/color.interface.js +2 -0
  4. package/{src/interfaces/config.interface.ts → dist/interfaces/config.interface.d.ts} +0 -3
  5. package/dist/interfaces/config.interface.js +2 -0
  6. package/dist/interfaces/files.interface.d.ts +4 -0
  7. package/dist/interfaces/files.interface.js +2 -0
  8. package/{src/interfaces/preset.interface.ts → dist/interfaces/preset.interface.d.ts} +3 -7
  9. package/dist/interfaces/preset.interface.js +2 -0
  10. package/dist/tools/config.tool.d.ts +4 -0
  11. package/dist/tools/config.tool.js +64 -0
  12. package/dist/tools/extraction/extractClasses.d.ts +5 -0
  13. package/dist/tools/extraction/extractClasses.js +134 -0
  14. package/dist/tools/fileStuff/config.file.d.ts +5 -0
  15. package/dist/tools/fileStuff/config.file.js +41 -0
  16. package/dist/tools/fileStuff/file.tools.d.ts +19 -0
  17. package/dist/tools/fileStuff/file.tools.js +88 -0
  18. package/dist/tools/fileStuff/quasar-variables.file.d.ts +1 -0
  19. package/dist/tools/fileStuff/quasar-variables.file.js +12 -0
  20. package/dist/tools/logger.d.ts +5 -0
  21. package/dist/tools/logger.js +27 -0
  22. package/dist/tools/main.d.ts +1 -0
  23. package/dist/tools/main.js +54 -0
  24. package/dist/tools/mapping/mapClassIntoRule.d.ts +5 -0
  25. package/dist/tools/mapping/mapClassIntoRule.js +256 -0
  26. package/dist/tools/mapping/mapColors.d.ts +3 -0
  27. package/dist/tools/mapping/mapColors.js +18 -0
  28. package/dist/tools/mapping/mapUtilities.d.ts +1 -0
  29. package/dist/tools/mapping/mapUtilities.js +17 -0
  30. package/dist/tools/output/css.output.d.ts +11 -0
  31. package/dist/tools/output/css.output.js +118 -0
  32. package/dist/tools/validation/color.validation.d.ts +12 -0
  33. package/{src/tools/validation/color.validation.ts → dist/tools/validation/color.validation.js} +14 -31
  34. package/dist/version.d.ts +5 -0
  35. package/dist/version.js +7 -0
  36. package/index.js +5 -18
  37. package/package.json +10 -3
  38. package/index.html +0 -20
  39. package/scripts/generate-version.js +0 -15
  40. package/src/config/colors.config.json +0 -242
  41. package/src/config/files.config.json +0 -5
  42. package/src/config/force.config.json +0 -1
  43. package/src/config/states.config.json +0 -4
  44. package/src/config/utilities.config.json +0 -152
  45. package/src/interfaces/color.interface.ts +0 -9
  46. package/src/interfaces/files.interface.ts +0 -4
  47. package/src/manual/build.js +0 -4
  48. package/src/tools/config.tool.ts +0 -70
  49. package/src/tools/extraction/extractClasses.ts +0 -215
  50. package/src/tools/fileStuff/config.file.ts +0 -44
  51. package/src/tools/fileStuff/css.file.ts +0 -47
  52. package/src/tools/fileStuff/file.tools.ts +0 -12
  53. package/src/tools/logger.ts +0 -23
  54. package/src/tools/mapping/mapClassIntoRule.ts +0 -335
  55. package/src/tools/mapping/mapColorIntoDeclaration.ts +0 -14
  56. package/src/tools/output/css.output.ts +0 -104
  57. package/tests/README.md +0 -54
  58. package/tests/validation/color.validation.test.ts +0 -182
  59. package/tsconfig.json +0 -22
  60. package/vitest.config.ts +0 -19
@@ -1,335 +0,0 @@
1
- import { IRuleInfo } from '@/interfaces/preset.interface';
2
- import { config } from '@tools/config.tool';
3
- import { log } from '@tools/logger';
4
-
5
- const mapClassesIntoRules = (classes: string[]) => {
6
- const usedVariations = new Map<string, string>();
7
- const ruleInfos = classes
8
- .map(cssClass => mapClassIntoRule(cssClass))
9
- .filter(ruleInfo => ruleInfo !== null);
10
-
11
- // Collecter les variations utilisés dans les règles générées
12
- ruleInfos.forEach(ruleInfo => {
13
- if (ruleInfo.variant && ruleInfo.variant.shouldExport) {
14
- const variableName = `${ruleInfo.variant.prefix}-${ruleInfo.variant.variantName}`;
15
- usedVariations.set(variableName, ruleInfo.variant.variantValue);
16
- }
17
- });
18
-
19
- // Générer les règles CSS
20
- const rules = generateCssRules(ruleInfos);
21
-
22
- log(`${ruleInfos.length} rules generated`);
23
-
24
- return {
25
- rules,
26
- variationsFromRules: Object.fromEntries(usedVariations),
27
- };
28
- };
29
-
30
- const generateCssRules = (ruleInfos: IRuleInfo[]): string => {
31
- return ruleInfos
32
- .map(ruleInfo => `.${ruleInfo.selector} { ${ruleInfo.declaration} }`)
33
- .join('\n');
34
- };
35
-
36
- const mapClassIntoRule = (stringClass: string): IRuleInfo | null => {
37
- const params = getClassInfos(stringClass);
38
- if (!params.utility) { return null }
39
-
40
- const needsColor = params.utility?.declaration?.includes('${color}')
41
- const usesVariation = params.variationName
42
- const hasDefaultVariation = !params.utility?.variations || Object.keys(params.utility?.variations || []).includes('default')
43
-
44
- /**
45
- * If need color but doesn't have one or if need a variation but doesn't have one either
46
- * this is a no go
47
- */
48
- if ((needsColor && !params.color) || (!hasDefaultVariation && !usesVariation)) {
49
- return null
50
- }
51
-
52
- const ruleInfo = buildRuleInfo(params);
53
- return ruleInfo;
54
- };
55
-
56
- const getClassInfos = (stringClass: string) => {
57
- const { cleanedClass, state } = getStateInfos(stringClass);
58
- const { cleanedColor, prefix } = getPrefixInfos(cleanedClass);
59
- const { color, baseColor, utility, variation, variationName } = getUtilityInfos({
60
- cleanedColor,
61
- prefix,
62
- });
63
-
64
- return {
65
- state,
66
-
67
- color,
68
- baseColor,
69
- prefix,
70
-
71
- utility,
72
- variation,
73
- variationName,
74
- };
75
- };
76
-
77
- const getStateInfos = (stringClass: string) => {
78
- const state = config.states.find(configState =>
79
- stringClass.startsWith(configState)
80
- );
81
-
82
- const cleanedClass = state
83
- ? stringClass.slice(state.length + 1)
84
- : stringClass;
85
-
86
- return {
87
- cleanedClass,
88
- state,
89
- };
90
- };
91
-
92
- const getPrefixInfos = (
93
- stringClass: string
94
- ): { cleanedColor: string; prefix: string } => {
95
- const prefixes = [
96
- ...config.utilities.map(u => u.prefix)
97
- ];
98
-
99
- for (const prefix of prefixes) {
100
- if (!stringClass.startsWith(prefix)) {
101
- continue;
102
- }
103
-
104
- return {
105
- cleanedColor: stringClass.slice(prefix.length + 1),
106
- prefix,
107
- };
108
- }
109
-
110
- log(`No matching prefix found for class: ${stringClass}`);
111
- return { cleanedColor: stringClass, prefix: null };
112
- };
113
-
114
- const getUtilityInfos = ({
115
- cleanedColor,
116
- prefix,
117
- }: {
118
- cleanedColor: string;
119
- prefix?: string;
120
- }) => {
121
- /**
122
- * Find utility variations matching the prefix from the config
123
- * Since a prefix can be in multiple utilities, filter every matching prefixes
124
- */
125
- const possibleUtility = [...config.utilities].filter(
126
- p => p.prefix === prefix
127
- );
128
-
129
- if (!possibleUtility.length) {
130
- return { matchingUtility: null, variation: null };
131
- }
132
-
133
- const { colorExists } = getColorInfos(cleanedColor);
134
- const possibleUtilityVariations = possibleUtility.filter(({ variations }) => Object.keys(variations || {})?.length)
135
-
136
- /**
137
- * Find the utility where the variations exist
138
- * Logic:
139
- * 1. If
140
- * OR we have a valid color
141
- * OR no color specified
142
- * OR no possible utilities have variation
143
- * Then use the first utility
144
- * 2. Otherwise, find a utility with a matching variation
145
- */
146
- let matchingUtility;
147
-
148
- if (colorExists || !cleanedColor || possibleUtilityVariations?.length <= 0) {
149
- matchingUtility = possibleUtility[0];
150
- } else {
151
- // Find utility with matching variation
152
- matchingUtility = possibleUtilityVariations.find(({ variations }) => {
153
- if (!variations) return true;
154
-
155
- const mappedVariations = Array.isArray(variations) ? variations : Object.keys(variations)
156
-
157
- return mappedVariations.some(
158
- v => cleanedColor === v || cleanedColor.endsWith(v)
159
- );
160
- });
161
- }
162
-
163
- if (!matchingUtility) {
164
- // log(`No utility found for ${cleanedColor || prefix}`);
165
-
166
- return {
167
- matchingUtility,
168
- variation: null,
169
- };
170
- }
171
-
172
- if (!colorExists && !matchingUtility.variations) {
173
- // log(`Unknow stuff -> ${[prefix, cleanedColor].join('-')}`);
174
-
175
- return {
176
- matchingUtility,
177
- variation: null,
178
- };
179
- }
180
-
181
- const possibleVariations = matchingUtility.variations || { default: '' };
182
-
183
- const defaultVariation = 'default';
184
- /**
185
- * Variation matching logic:
186
- * 1. Check for exact match first (prevents "xl" matching when looking for "2xl")
187
- * 2. Fall back to endsWith for edge cases where variation is a suffix
188
- */
189
- const exactVariation = Object.keys(possibleVariations).find(
190
- v => cleanedColor === v
191
- );
192
- const closestVariation = Object.keys(possibleVariations).find(v =>
193
- cleanedColor.endsWith(v)
194
- );
195
-
196
- const matchingVariation = exactVariation || closestVariation;
197
-
198
- const variation = possibleVariations[matchingVariation || defaultVariation];
199
- const color = matchingVariation
200
- ? cleanedColor.slice(0, -matchingVariation.length - 1)
201
- : cleanedColor;
202
-
203
- const { baseColor } = getColorInfos(color)
204
-
205
- return {
206
- color,
207
- baseColor,
208
- utility: matchingUtility,
209
- variationName: matchingVariation,
210
- variation,
211
- };
212
- };
213
-
214
- // Map state names to CSS pseudo-selectors
215
- const stateSelectors: Record<string, string> = {
216
- hover: ':hover',
217
- 'not-hover': ':not(:hover)',
218
- };
219
-
220
- const buildRuleInfo = ({
221
- state,
222
- prefix,
223
- color,
224
- baseColor,
225
- utility,
226
- variation,
227
- variationName,
228
- }): IRuleInfo | null => {
229
- // Get state selector from mapping
230
- const stateSelector = state ? stateSelectors[state] || '' : '';
231
-
232
- let selector = `${prefix}${color ? `-${color}` : ''}${
233
- variationName ? `-${variationName}` : ''
234
- }`;
235
-
236
- if (state) {
237
- selector = `${state}\\:${selector}${stateSelector}`;
238
- }
239
-
240
- // Vérifier que la couleur existe dans la config
241
- if (baseColor && !config.colors[baseColor]) {
242
- log(
243
- `Color '${baseColor}' not found in colors config - skipping rule generation`
244
- );
245
- return null;
246
- }
247
-
248
- // Gérer les variations avec variables CSS ou valeurs directes
249
- let variableToUse = variation;
250
- let variantInfo = undefined;
251
-
252
- // Vérifier si on doit exporter les variations en tant que variables CSS
253
- const exportVariations = utility['export'];
254
- const useVariables = exportVariations === 'variations' || exportVariations === 'all';
255
-
256
- if (variationName && variationName !== 'default') {
257
- const variablePrefix = prefix;
258
- const variableName = `${variablePrefix}-${variationName}`;
259
-
260
- // Si export-variations: true, utiliser une variable CSS, sinon la valeur directe
261
- if (useVariables) {
262
- variableToUse = `var(--${variableName})`;
263
- variantInfo = {
264
- prefix,
265
- variantName: variationName,
266
- variantValue: variation,
267
- shouldExport: true,
268
- };
269
- } else {
270
- // Utiliser la valeur directe, pas de variable CSS
271
- variableToUse = variation;
272
- }
273
- } else if (variation && variationName === 'default') {
274
- // Pour les variations par défaut
275
- const variableName = `${prefix}-default`;
276
-
277
- if (useVariables) {
278
- variableToUse = `var(--${variableName})`;
279
- variantInfo = {
280
- prefix,
281
- variantName: 'default',
282
- variantValue: variation,
283
- shouldExport: true,
284
- };
285
- } else {
286
- variableToUse = variation;
287
- }
288
- }
289
-
290
- let declaration = utility.declaration
291
- .replace('${value}', variableToUse)
292
- .replace('${color}', color ? `var(--${color})` : '');
293
-
294
- if (!declaration.endsWith(';')) {
295
- declaration += ';';
296
- }
297
-
298
- if (!declaration.includes('!important')) {
299
- declaration = declaration.replace(';', ' !important;');
300
- }
301
-
302
- return {
303
- selector,
304
- declaration,
305
- color: color || undefined,
306
- variant: variantInfo,
307
- };
308
- };
309
-
310
- /**
311
- * _ Check if a color includes opacity (ends with 2 digits)
312
- * * Opacity is included in the color name during mixin declaration
313
- * */
314
- // Cache regex outside function to avoid recompilation on every call
315
- const OPACITY_DETECTION_REGEX = /(?:(\w-?)+)-\d{2}$/; // Strings that end with two digits (e.g., primary-50)
316
- const OPACITY_SUFFIX_LENGTH = 3; // Length of "-NN" format
317
-
318
- const getColorInfos = (color: string) => {
319
- const isOpacity = OPACITY_DETECTION_REGEX.test(color);
320
-
321
- const baseColor = isOpacity
322
- ? color.slice(0, -OPACITY_SUFFIX_LENGTH)
323
- : color;
324
- const colorExists = Object.keys(config.colors).some(
325
- configColor => configColor === baseColor
326
- );
327
-
328
- return {
329
- colorExists,
330
- isOpacity,
331
- baseColor,
332
- };
333
- };
334
-
335
- export { mapClassesIntoRules };
@@ -1,14 +0,0 @@
1
- import { IColor } from '@interfaces/color.interface';
2
- import { defineColor } from '@tools/output/css.output';
3
-
4
- const mapColorsIntoMixinDeclaration = (colors: IColor) => {
5
- const mappedColors = Object.entries(colors)
6
- ?.map(([colorName, { light, dark }]) =>
7
- defineColor(colorName, light, dark)
8
- )
9
- ?.join('\n');
10
-
11
- return mappedColors;
12
- };
13
-
14
- export { mapColorsIntoMixinDeclaration };
@@ -1,104 +0,0 @@
1
- import { version } from '../../version';
2
-
3
- const header = `/**
4
- * Anubis v.${version}
5
- * Improba
6
- * Released under the MIT License.
7
- */`;
8
-
9
- const mixin = `
10
- $background-opacity: (
11
- 10: 0.1,
12
- 20: 0.2,
13
- 30: 0.3,
14
- 40: 0.4,
15
- 50: 0.5,
16
- 60: 0.6,
17
- 70: 0.7,
18
- 80: 0.8,
19
- 90: 0.9
20
- );
21
-
22
- // Mixin that will automatically generate colors for light and/or dark themes (with opacity variations)
23
- @mixin setRootColors ($name, $lightColor: null, $darkColor: null) {
24
- :root {
25
- @if $lightColor != null {
26
- body.body--light {
27
- #{"--"+$name}: $lightColor;
28
-
29
- // Only generate opacity variations for non transparent colors
30
- @if $lightColor != transparent {
31
- @each $opacity, $multiplier in $background-opacity {
32
- #{"--"+$name+"-"+$opacity}: #{rgba(red($lightColor), green($lightColor), blue($lightColor), $multiplier)};
33
- }
34
- }
35
- }
36
- }
37
-
38
- @if $darkColor != null {
39
- body.body--dark {
40
- #{"--"+$name}: $darkColor;
41
-
42
- // Only generate opacity variations for non transparent colors
43
- @if $darkColor != transparent {
44
- @each $opacity, $multiplier in $background-opacity {
45
- #{"--"+$name+"-"+$opacity}: #{rgba(red($darkColor), green($darkColor), blue($darkColor), $multiplier)};
46
- }
47
- }
48
- }
49
- }
50
- }
51
- }
52
- `;
53
-
54
- const COLOR_COMMENT = `/**
55
- * These colours will be mapped to css variables in
56
- * the :root element on the html page.
57
- *
58
- * It allows you to write custom css/scss classes in your web
59
- * components.
60
- */`;
61
-
62
- const VARIANT_COMMENT = `/**
63
- * These css variables are generated automatically when Anubis
64
- * detects that they are used in utilities in your config.
65
- *
66
- * It allows you to write custom css/scss classes in your web
67
- * components like:
68
- *
69
- * .paragraph-small {
70
- * font-size: var(--size-xs);
71
- * font-weight: var(--weight-light);
72
- * }
73
- *
74
- * (You can also force the generation of all variants from a
75
- * utility by setting the 'export' to 'variations')
76
- */`;
77
-
78
- const CLASS_COMMENT = `/**
79
- * These are the css classes generated by Anubis based on your config
80
- * and what was detected in your source files.
81
- */`;
82
-
83
- const defineColor = (colorName: string, light?: string, dark?: string) => {
84
- // Handle cases where only dark is provided
85
- if (!light && dark) {
86
- return `@include setRootColors('${colorName}', null, ${dark});`;
87
- }
88
- // Handle cases where only light is provided or both are provided
89
- return `@include setRootColors('${colorName}', ${light}${
90
- dark ? ', ' + dark : ''
91
- });`;
92
- };
93
-
94
- const getHeader = () => {
95
- return `${header}${mixin}`;
96
- };
97
-
98
- export {
99
- getHeader,
100
- defineColor,
101
- COLOR_COMMENT,
102
- VARIANT_COMMENT,
103
- CLASS_COMMENT,
104
- };
package/tests/README.md DELETED
@@ -1,54 +0,0 @@
1
- # AnubisUI Tests
2
-
3
- This directory contains all tests for the AnubisUI project.
4
-
5
- ## Running Tests
6
-
7
- ```bash
8
- # Run tests in watch mode (development)
9
- npm test
10
-
11
- # Run tests once (CI/production)
12
- npm run test:run
13
-
14
- # Run tests with UI
15
- npm run test:ui
16
- ```
17
-
18
- ## Test Structure
19
-
20
- ```
21
- tests/
22
- └── validation/
23
- └── color.validation.test.ts # Color configuration validation tests
24
- ```
25
-
26
- ## Test Coverage
27
-
28
- ### Color Validation (`color.validation.test.ts`)
29
-
30
- Tests the color configuration validation logic to ensure:
31
- - Valid colors pass validation
32
- - Invalid colors are properly rejected
33
- - Edge cases are handled correctly
34
-
35
- **Test groups:**
36
- 1. **Valid configurations** - Tests all supported color formats
37
- 2. **Invalid configurations** - Ensures improper configs are rejected
38
- 3. **Helper functions** - Tests individual validation utilities
39
-
40
- ## Adding New Tests
41
-
42
- 1. Create a new test file in the appropriate subdirectory
43
- 2. Use the `.test.ts` extension
44
- 3. Import test utilities from Vitest:
45
- ```typescript
46
- import { describe, it, expect } from 'vitest';
47
- ```
48
-
49
- ## Test Framework
50
-
51
- We use [Vitest](https://vitest.dev/) for testing:
52
- - **Fast** - Native ESM and TypeScript support
53
- - **Compatible** - Jest-like API
54
- - **Modern** - Built for Vite projects
@@ -1,182 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import {
3
- validateColors,
4
- isValidColorValue,
5
- } from '@validation/color.validation';
6
- import { IColor } from '@interfaces/color.interface';
7
-
8
- describe('isValidColorValue', () => {
9
- it('should accept valid hex colors (#RRGGBB)', () => {
10
- expect(isValidColorValue('#ff00ff')).toBe(true);
11
- expect(isValidColorValue('#0f84cb')).toBe(true);
12
- expect(isValidColorValue('#000000')).toBe(true);
13
- expect(isValidColorValue('#ffffff')).toBe(true);
14
- });
15
-
16
- it('should accept valid short hex colors (#RGB)', () => {
17
- expect(isValidColorValue('#f0f')).toBe(true);
18
- expect(isValidColorValue('#0ff')).toBe(true);
19
- expect(isValidColorValue('#000')).toBe(true);
20
- expect(isValidColorValue('#fff')).toBe(true);
21
- });
22
-
23
- it('should accept transparent keyword', () => {
24
- expect(isValidColorValue('transparent')).toBe(true);
25
- });
26
-
27
- it('should accept mixed case hex values', () => {
28
- expect(isValidColorValue('#FF00FF')).toBe(true);
29
- expect(isValidColorValue('#Ff00fF')).toBe(true);
30
- });
31
-
32
- it('should reject invalid hex colors', () => {
33
- expect(isValidColorValue('not-a-color')).toBe(false);
34
- expect(isValidColorValue('#ff')).toBe(false);
35
- expect(isValidColorValue('#fffffff')).toBe(false);
36
- expect(isValidColorValue('ff00ff')).toBe(false);
37
- expect(isValidColorValue('#gggggg')).toBe(false);
38
- expect(isValidColorValue('#xyz')).toBe(false);
39
- });
40
- });
41
-
42
- describe('validateColors', () => {
43
- describe('Valid configurations', () => {
44
- it('should accept color with both light and dark themes', () => {
45
- const colors: IColor = {
46
- primary: { light: '#0f84cb', dark: '#1a94db' },
47
- };
48
- expect(() => validateColors(colors)).not.toThrow();
49
- });
50
-
51
- it('should accept color with only light theme', () => {
52
- const colors: IColor = {
53
- 'custom-light': { light: '#ff00ff' },
54
- };
55
- expect(() => validateColors(colors)).not.toThrow();
56
- });
57
-
58
- it('should accept color with only dark theme', () => {
59
- const colors: IColor = {
60
- 'custom-dark': { dark: '#00ffff' },
61
- };
62
- expect(() => validateColors(colors)).not.toThrow();
63
- });
64
-
65
- it('should accept transparent colors', () => {
66
- const colors: IColor = {
67
- none: { light: 'transparent', dark: 'transparent' },
68
- };
69
- expect(() => validateColors(colors)).not.toThrow();
70
- });
71
-
72
- it('should accept short hex format (#RGB)', () => {
73
- const colors: IColor = {
74
- 'short-hex': { light: '#f0f', dark: '#0ff' },
75
- };
76
- expect(() => validateColors(colors)).not.toThrow();
77
- });
78
-
79
- it('should accept multiple valid colors', () => {
80
- const colors: IColor = {
81
- primary: { light: '#0f84cb', dark: '#1a94db' },
82
- secondary: { light: '#3b5161', dark: '#4a5f6f' },
83
- accent: { light: '#0f84cb' },
84
- };
85
- expect(() => validateColors(colors)).not.toThrow();
86
- });
87
-
88
- it('should accept empty colors object', () => {
89
- const colors: IColor = {};
90
- expect(() => validateColors(colors)).not.toThrow();
91
- });
92
-
93
- it('should accept uppercase hex values', () => {
94
- const colors: IColor = {
95
- uppercase: { light: '#FF00FF', dark: '#00FFFF' },
96
- };
97
- expect(() => validateColors(colors)).not.toThrow();
98
- });
99
-
100
- it('should accept mixed case hex values', () => {
101
- const colors: IColor = {
102
- mixed: { light: '#Ff00fF', dark: '#00FfFf' },
103
- };
104
- expect(() => validateColors(colors)).not.toThrow();
105
- });
106
- });
107
-
108
- describe('Invalid configurations', () => {
109
- it('should reject empty color object (no light or dark)', () => {
110
- const colors: IColor = {
111
- 'test-empty': {},
112
- };
113
- expect(() => validateColors(colors)).toThrow(
114
- 'Invalid color configuration'
115
- );
116
- });
117
-
118
- it('should reject invalid hex color format', () => {
119
- const colors: IColor = {
120
- 'test-invalid': { light: 'not-a-color' },
121
- };
122
- expect(() => validateColors(colors)).toThrow(
123
- 'Invalid color configuration'
124
- );
125
- });
126
-
127
- it('should reject invalid short hex (#XX)', () => {
128
- const colors: IColor = {
129
- 'test-short': { light: '#ff' },
130
- };
131
- expect(() => validateColors(colors)).toThrow(
132
- 'Invalid color configuration'
133
- );
134
- });
135
-
136
- it('should reject hex color without #', () => {
137
- const colors: IColor = {
138
- 'test-no-hash': { light: 'ff00ff' },
139
- };
140
- expect(() => validateColors(colors)).toThrow(
141
- 'Invalid color configuration'
142
- );
143
- });
144
-
145
- it('should reject invalid characters in hex', () => {
146
- const colors: IColor = {
147
- 'test-invalid-chars': { light: '#gggggg' },
148
- };
149
- expect(() => validateColors(colors)).toThrow(
150
- 'Invalid color configuration'
151
- );
152
- });
153
-
154
- it('should reject when both light and dark are invalid', () => {
155
- const colors: IColor = {
156
- 'test-both-invalid': { light: 'invalid', dark: 'also-invalid' },
157
- };
158
- expect(() => validateColors(colors)).toThrow(
159
- 'Invalid color configuration'
160
- );
161
- });
162
-
163
- it('should reject when mixing valid and invalid colors', () => {
164
- const colors: IColor = {
165
- valid: { light: '#ff00ff' },
166
- invalid: { light: 'not-valid' },
167
- };
168
- expect(() => validateColors(colors)).toThrow(
169
- 'Invalid color configuration'
170
- );
171
- });
172
-
173
- it('should reject when only dark color is invalid', () => {
174
- const colors: IColor = {
175
- 'test-dark-invalid': { light: '#ff00ff', dark: 'not-valid' },
176
- };
177
- expect(() => validateColors(colors)).toThrow(
178
- 'Invalid color configuration'
179
- );
180
- });
181
- });
182
- });
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "outDir": "./dist",
4
- "rootDir": "./src",
5
- "declaration": true,
6
- "module": "commonjs",
7
- "target": "es2019",
8
- "skipLibCheck": true, // Ignore la vérification des fichiers .d.ts dans node_modules
9
- "esModuleInterop": true,
10
- "resolveJsonModule": true,
11
- "baseUrl": "./src",
12
- "paths": {
13
- "@/*": ["./*"],
14
- "@config/*": ["./config/*"],
15
- "@interfaces/*": ["./interfaces/*"],
16
- "@tools/*": ["./tools/*"],
17
- "@validation/*": ["./tools/validation/*"]
18
- }
19
- },
20
- "include": ["src/**/*"],
21
- "exclude": ["node_modules", "dist"]
22
- }