css-in-js-engine-pb 0.2.1 → 0.2.3

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 (36) hide show
  1. package/dist/index.d.ts +4 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +4 -1
  4. package/dist/mergeStyleRules.d.ts +3 -0
  5. package/dist/mergeStyleRules.d.ts.map +1 -0
  6. package/dist/mergeStyleRules.js +9 -0
  7. package/dist/resolveStyleRules.d.ts.map +1 -1
  8. package/dist/resolveStyleRules.js +26 -7
  9. package/dist/shorthands/borderColor.d.ts +2 -0
  10. package/dist/shorthands/borderColor.d.ts.map +1 -1
  11. package/dist/shorthands/borderColor.js +8 -1
  12. package/dist/shorthands/index.d.ts +1 -0
  13. package/dist/shorthands/index.d.ts.map +1 -1
  14. package/dist/shorthands/index.js +1 -1
  15. package/package.json +1 -1
  16. package/dist/shorthands/borderBottom.d.ts +0 -1
  17. package/dist/shorthands/borderBottom.d.ts.map +0 -1
  18. package/dist/shorthands/borderBottom.js +0 -1
  19. package/dist/shorthands/borderLeft.d.ts +0 -1
  20. package/dist/shorthands/borderLeft.d.ts.map +0 -1
  21. package/dist/shorthands/borderLeft.js +0 -1
  22. package/dist/shorthands/borderRadius.d.ts +0 -1
  23. package/dist/shorthands/borderRadius.d.ts.map +0 -1
  24. package/dist/shorthands/borderRadius.js +0 -1
  25. package/dist/shorthands/borderRight.d.ts +0 -1
  26. package/dist/shorthands/borderRight.d.ts.map +0 -1
  27. package/dist/shorthands/borderRight.js +0 -1
  28. package/dist/shorthands/borderStyle.d.ts +0 -1
  29. package/dist/shorthands/borderStyle.d.ts.map +0 -1
  30. package/dist/shorthands/borderStyle.js +0 -1
  31. package/dist/shorthands/borderTop.d.ts +0 -1
  32. package/dist/shorthands/borderTop.d.ts.map +0 -1
  33. package/dist/shorthands/borderTop.js +0 -1
  34. package/dist/shorthands/borderWidth.d.ts +0 -1
  35. package/dist/shorthands/borderWidth.d.ts.map +0 -1
  36. package/dist/shorthands/borderWidth.js +0 -1
package/dist/index.d.ts CHANGED
@@ -2,6 +2,9 @@ export { mergeClasses } from './mergeClasses';
2
2
  export { makeStyles } from './makeStyles';
3
3
  export { makeStaticStyles } from './makeStaticStyles';
4
4
  export { makeResetStyles } from './makeResetStyles';
5
- export declare const shorthands: {};
5
+ import { borderColor } from './shorthands';
6
+ export declare const shorthands: {
7
+ borderColor: typeof borderColor;
8
+ };
6
9
  export type { StyleRule, CSSValue, StylesBySlots, ClassNamesBySlot, } from './types';
7
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,UAAU,IAEtB,CAAC;AAEF,YAAY,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,gBAAgB,GACnB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACH,WAAW,EACd,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,UAAU;;CAEtB,CAAC;AAEF,YAAY,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,gBAAgB,GACnB,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -2,4 +2,7 @@ export { mergeClasses } from './mergeClasses';
2
2
  export { makeStyles } from './makeStyles';
3
3
  export { makeStaticStyles } from './makeStaticStyles';
4
4
  export { makeResetStyles } from './makeResetStyles';
5
- export const shorthands = {};
5
+ import { borderColor } from './shorthands';
6
+ export const shorthands = {
7
+ borderColor
8
+ };
@@ -0,0 +1,3 @@
1
+ import { StyleRule } from './types';
2
+ export declare function mergeStyleRules(rules: StyleRule[]): StyleRule;
3
+ //# sourceMappingURL=mergeStyleRules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeStyleRules.d.ts","sourceRoot":"","sources":["../src/mergeStyleRules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,CAU7D"}
@@ -0,0 +1,9 @@
1
+ export function mergeStyleRules(rules) {
2
+ const result = {};
3
+ for (const rule of rules) {
4
+ for (const key in rule) {
5
+ result[key] = rule[key];
6
+ }
7
+ }
8
+ return result;
9
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"resolveStyleRules.d.ts","sourceRoot":"","sources":["../src/resolveStyleRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAa,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAmDhD,wBAAgB,yBAAyB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACnE,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,EACnC,WAAW,CAAC,EAAE,eAAe,GAC9B,aAAa,CAAC,KAAK,CAAC,CAetB"}
1
+ {"version":3,"file":"resolveStyleRules.d.ts","sourceRoot":"","sources":["../src/resolveStyleRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAa,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAyEhD,wBAAgB,yBAAyB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACnE,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,EACnC,WAAW,CAAC,EAAE,eAAe,GAC9B,aAAa,CAAC,KAAK,CAAC,CAwBtB"}
@@ -1,32 +1,49 @@
1
1
  import { camelToKebab, resolveValue } from './utils/css';
2
2
  import { AtomicRuleCache } from './atomicCache';
3
- function buildAtomicClasses(rule, cache, cssRulesOut, atRule) {
3
+ function buildAtomicClasses(rule, cache, cssRulesOut, atRule, seenDecls = new Set()) {
4
4
  const classNames = [];
5
5
  for (const key in rule) {
6
6
  const val = rule[key];
7
7
  if (val == null)
8
8
  continue;
9
+ // --- at-rules (@media, @supports, etc.)
9
10
  if (key.startsWith('@') && typeof val === 'object') {
10
- const nested = buildAtomicClasses(val, cache, cssRulesOut, key);
11
+ const nested = buildAtomicClasses(val, cache, cssRulesOut, key, seenDecls);
11
12
  classNames.push(...nested);
12
13
  continue;
13
14
  }
15
+ // --- pseudo selectors (:hover, :active, etc.)
14
16
  if (key.startsWith(':') && typeof val === 'object') {
17
+ const selector = `&${key}`;
15
18
  for (const prop in val) {
16
19
  const v = val[prop];
17
20
  if (v == null || typeof v === 'object')
18
21
  continue;
19
- const decl = `${camelToKebab(prop)}:${resolveValue(v)}`;
20
- const res = cache.getOrCreate(`&${key}`, decl, atRule);
22
+ const cssProp = camelToKebab(prop);
23
+ const declKey = `${atRule !== null && atRule !== void 0 ? atRule : ''}|${selector}|${cssProp}`;
24
+ // 👇 LAST ONE WINS — drop earlier declarations
25
+ if (seenDecls.has(declKey))
26
+ continue;
27
+ seenDecls.add(declKey);
28
+ const decl = `${cssProp}:${resolveValue(v)}`;
29
+ const res = cache.getOrCreate(selector, decl, atRule);
21
30
  classNames.push(res.className);
22
31
  if (res.ruleText)
23
32
  cssRulesOut.push(res.ruleText);
24
33
  }
25
34
  continue;
26
35
  }
36
+ // --- normal properties
27
37
  if (typeof val !== 'object') {
28
- const decl = `${camelToKebab(key)}:${resolveValue(val)}`;
29
- const res = cache.getOrCreate('&', decl, atRule);
38
+ const cssProp = camelToKebab(key);
39
+ const selector = '&';
40
+ const declKey = `${atRule !== null && atRule !== void 0 ? atRule : ''}|${selector}|${cssProp}`;
41
+ // 👇 LAST ONE WINS — drop earlier declarations
42
+ if (seenDecls.has(declKey))
43
+ continue;
44
+ seenDecls.add(declKey);
45
+ const decl = `${cssProp}:${resolveValue(val)}`;
46
+ const res = cache.getOrCreate(selector, decl, atRule);
30
47
  classNames.push(res.className);
31
48
  if (res.ruleText)
32
49
  cssRulesOut.push(res.ruleText);
@@ -40,7 +57,9 @@ export function resolveStyleRulesForSlots(stylesBySlots, sharedCache) {
40
57
  const classNamesBySlot = {};
41
58
  for (const slot in stylesBySlots) {
42
59
  const rule = stylesBySlots[slot];
43
- const atomicClasses = buildAtomicClasses(rule !== null && rule !== void 0 ? rule : {}, cache, cssRules);
60
+ // 👇 NEW: fresh seenDecls PER SLOT
61
+ const seenDecls = new Set();
62
+ const atomicClasses = buildAtomicClasses(rule !== null && rule !== void 0 ? rule : {}, cache, cssRules, undefined, seenDecls);
44
63
  classNamesBySlot[slot] = atomicClasses.join(' ');
45
64
  }
46
65
  return { classNamesBySlot, cssRules };
@@ -1 +1,3 @@
1
+ import type { StyleRule } from '../types';
2
+ export declare function borderColor(value: string): StyleRule;
1
3
  //# sourceMappingURL=borderColor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"borderColor.d.ts","sourceRoot":"","sources":["../../src/shorthands/borderColor.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"borderColor.d.ts","sourceRoot":"","sources":["../../src/shorthands/borderColor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAOpD"}
@@ -1 +1,8 @@
1
- "use strict";
1
+ export function borderColor(value) {
2
+ return {
3
+ borderTopColor: value,
4
+ borderRightColor: value,
5
+ borderBottomColor: value,
6
+ borderLeftColor: value,
7
+ };
8
+ }
@@ -1 +1,2 @@
1
+ export { borderColor } from './borderColor';
1
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shorthands/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shorthands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -1 +1 @@
1
- "use strict";
1
+ export { borderColor } from './borderColor';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-in-js-engine-pb",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "A lightweight atomic CSS-in-JS engine built on the native CSS cascade",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- //# sourceMappingURL=borderBottom.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"borderBottom.d.ts","sourceRoot":"","sources":["../../src/shorthands/borderBottom.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- //# sourceMappingURL=borderLeft.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"borderLeft.d.ts","sourceRoot":"","sources":["../../src/shorthands/borderLeft.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- //# sourceMappingURL=borderRadius.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"borderRadius.d.ts","sourceRoot":"","sources":["../../src/shorthands/borderRadius.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- //# sourceMappingURL=borderRight.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"borderRight.d.ts","sourceRoot":"","sources":["../../src/shorthands/borderRight.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- //# sourceMappingURL=borderStyle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"borderStyle.d.ts","sourceRoot":"","sources":["../../src/shorthands/borderStyle.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- //# sourceMappingURL=borderTop.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"borderTop.d.ts","sourceRoot":"","sources":["../../src/shorthands/borderTop.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- //# sourceMappingURL=borderWidth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"borderWidth.d.ts","sourceRoot":"","sources":["../../src/shorthands/borderWidth.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";