@ngcorex/css 0.1.7 → 0.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"scale-consistency.d.ts","sourceRoot":"","sources":["../../src/validation/scale-consistency.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAmMpB;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,GAAE,MAAM,GAAG,SAAS,GAAG,OAAmB,GACjD,gBAAgB,EAAE,CAgCpB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,CAelF"}
1
+ {"version":3,"file":"scale-consistency.d.ts","sourceRoot":"","sources":["../../src/validation/scale-consistency.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAoMpB;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,GAAE,MAAM,GAAG,SAAS,GAAG,OAAmB,GACjD,gBAAgB,EAAE,CAgCpB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,CAelF"}
@@ -152,7 +152,8 @@ function validateScale(category, tokens, severity = 'warning') {
152
152
  }
153
153
  // Check for gaps in the scale
154
154
  const { hasGaps, gapIndices } = checkForGaps(values, keys, scaleOrder.expectedOrder);
155
- if (hasGaps) {
155
+ // Skip "missing keys" info for zIndex - z-index-logic.ts provides more semantic "missing layers" message
156
+ if (hasGaps && category !== 'zIndex') {
156
157
  const missingKeys = gapIndices.map(i => scaleOrder.expectedOrder[i]);
157
158
  results.push({
158
159
  severity: 'info', // Gaps are less severe than non-monotonic values
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * Duplicate token detection
3
- * Checks for duplicate token names across different categories
3
+ * Checks for duplicate token names WITHIN the same category
4
+ * Cross-category duplicates are allowed (e.g., radius.sm, typography.fontSize.sm)
4
5
  */
5
6
  import type { ValidationResult, TokensForValidation, DuplicateToken } from './types.js';
6
7
  /**
7
- * Find all duplicate tokens across categories
8
+ * Find all duplicate tokens within each category
9
+ * Cross-category duplicates are NOT flagged (per spec X1)
8
10
  */
9
11
  export declare function findDuplicateTokens(tokens: TokensForValidation, file?: string): DuplicateToken[];
10
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"token-duplicates.d.ts","sourceRoot":"","sources":["../../src/validation/token-duplicates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EAEnB,cAAc,EACf,MAAM,YAAY,CAAC;AAOpB;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,GAAE,MAAsB,GAAG,cAAc,EAAE,CAmD/G;AAiCD;;GAEG;AACH,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,cAAc,EAAE,EAC5B,QAAQ,GAAE,MAAM,GAAG,SAAS,GAAG,OAAmB,GACjD,gBAAgB,EAAE,CAmBpB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,IAAI,GAAE,MAAsB,EAC5B,QAAQ,GAAE,MAAM,GAAG,SAAS,GAAG,OAAmB,GACjD,gBAAgB,EAAE,CAGpB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,MAAM,CAgB9E"}
1
+ {"version":3,"file":"token-duplicates.d.ts","sourceRoot":"","sources":["../../src/validation/token-duplicates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EAEnB,cAAc,EACf,MAAM,YAAY,CAAC;AAOpB;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,GAAE,MAAsB,GAAG,cAAc,EAAE,CA+B/G;AAqFD;;GAEG;AACH,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,cAAc,EAAE,EAC5B,QAAQ,GAAE,MAAM,GAAG,SAAS,GAAG,OAAmB,GACjD,gBAAgB,EAAE,CAmBpB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,IAAI,GAAE,MAAsB,EAC5B,QAAQ,GAAE,MAAM,GAAG,SAAS,GAAG,OAAmB,GACjD,gBAAgB,EAAE,CAGpB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,MAAM,CAgB9E"}
@@ -1,17 +1,19 @@
1
1
  /**
2
2
  * Duplicate token detection
3
- * Checks for duplicate token names across different categories
3
+ * Checks for duplicate token names WITHIN the same category
4
+ * Cross-category duplicates are allowed (e.g., radius.sm, typography.fontSize.sm)
4
5
  */
5
6
  /**
6
7
  * Validation code for duplicate tokens
7
8
  */
8
9
  const DUPLICATE_TOKEN_CODE = 'DUPLICATE_TOKEN';
9
10
  /**
10
- * Find all duplicate tokens across categories
11
+ * Find all duplicate tokens within each category
12
+ * Cross-category duplicates are NOT flagged (per spec X1)
11
13
  */
12
14
  export function findDuplicateTokens(tokens, file = 'tokens.json') {
13
- const tokenMap = new Map();
14
- // Collect all tokens from all categories
15
+ const duplicates = [];
16
+ // Process each category separately
15
17
  const categories = [
16
18
  { name: 'spacing' },
17
19
  { name: 'radius' },
@@ -27,30 +29,38 @@ export function findDuplicateTokens(tokens, file = 'tokens.json') {
27
29
  if (isNested) {
28
30
  // Handle nested token structures (colors, typography)
29
31
  if (typeof category === 'object' && category !== null) {
30
- collectNestedTokens(category, name, file, tokenMap);
32
+ duplicates.push(...findDuplicatesInNested(category, name, file));
31
33
  }
32
34
  }
33
35
  else {
34
36
  // Handle flat token structures (spacing, radius, zIndex, shadows)
35
37
  if (typeof category === 'object' && category !== null) {
36
- for (const [key, value] of Object.entries(category)) {
37
- const location = {
38
- file,
39
- category: name,
40
- key,
41
- path: `${name}.${key}`
42
- };
43
- if (!tokenMap.has(key)) {
44
- tokenMap.set(key, []);
45
- }
46
- tokenMap.get(key).push(location);
47
- }
38
+ duplicates.push(...findDuplicatesInFlat(category, name, file));
48
39
  }
49
40
  }
50
41
  }
51
- // Find duplicates (tokens with more than one location)
42
+ return duplicates;
43
+ }
44
+ /**
45
+ * Find duplicates in flat token structures
46
+ */
47
+ function findDuplicatesInFlat(obj, category, file) {
52
48
  const duplicates = [];
53
- for (const [name, locations] of tokenMap.entries()) {
49
+ const keyMap = new Map();
50
+ for (const [key, value] of Object.entries(obj)) {
51
+ const location = {
52
+ file,
53
+ category,
54
+ key,
55
+ path: `${category}.${key}`
56
+ };
57
+ if (!keyMap.has(key)) {
58
+ keyMap.set(key, []);
59
+ }
60
+ keyMap.get(key).push(location);
61
+ }
62
+ // Find duplicates within this category
63
+ for (const [name, locations] of keyMap.entries()) {
54
64
  if (locations.length > 1) {
55
65
  duplicates.push({ name, locations });
56
66
  }
@@ -58,27 +68,40 @@ export function findDuplicateTokens(tokens, file = 'tokens.json') {
58
68
  return duplicates;
59
69
  }
60
70
  /**
61
- * Collect tokens from nested structures
71
+ * Find duplicates in nested token structures
72
+ * Checks for duplicates at each nesting level separately
62
73
  */
63
- function collectNestedTokens(obj, category, file, tokenMap) {
74
+ function findDuplicatesInNested(obj, category, file, path = category) {
75
+ const duplicates = [];
64
76
  if (typeof obj !== 'object' || obj === null)
65
- return;
77
+ return duplicates;
78
+ const keyMap = new Map();
79
+ // Check for duplicates at current level
66
80
  for (const [key, value] of Object.entries(obj)) {
67
81
  const location = {
68
82
  file,
69
83
  category,
70
84
  key,
71
- path: `${category}.${key}`
85
+ path: `${path}.${key}`
72
86
  };
73
- if (!tokenMap.has(key)) {
74
- tokenMap.set(key, []);
87
+ if (!keyMap.has(key)) {
88
+ keyMap.set(key, []);
75
89
  }
76
- tokenMap.get(key).push(location);
77
- // Recursively collect nested tokens
90
+ keyMap.get(key).push(location);
91
+ }
92
+ // Add duplicates found at this level
93
+ for (const [name, locations] of keyMap.entries()) {
94
+ if (locations.length > 1) {
95
+ duplicates.push({ name, locations });
96
+ }
97
+ }
98
+ // Recursively check nested levels
99
+ for (const [key, value] of Object.entries(obj)) {
78
100
  if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
79
- collectNestedTokens(value, `${category}.${key}`, file, tokenMap);
101
+ duplicates.push(...findDuplicatesInNested(value, category, file, `${path}.${key}`));
80
102
  }
81
103
  }
104
+ return duplicates;
82
105
  }
83
106
  /**
84
107
  * Convert duplicate tokens to validation results
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngcorex/css",
3
- "version": "0.1.7",
3
+ "version": "0.2.0",
4
4
  "description": "Angular-native design token and utility CSS engine",
5
5
  "keywords": [
6
6
  "design-tokens",
@@ -33,10 +33,10 @@
33
33
  "build": "tsc -p tsconfig.json"
34
34
  },
35
35
  "repository": {
36
- "type": "git",
37
- "url": "https://github.com/arkdezin/ngCorex.git",
38
- "directory": "packages/css"
39
- },
36
+ "type": "git",
37
+ "url": "https://github.com/arkdezin/ngCorex.git",
38
+ "directory": "packages/css"
39
+ },
40
40
 
41
41
  "homepage": "https://github.com/arkdezin/ngCorex/blob/main/README.md"
42
42
  }