@idealyst/theme 1.2.40 → 1.2.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idealyst/theme",
3
- "version": "1.2.40",
3
+ "version": "1.2.41",
4
4
  "description": "Theming system for Idealyst Framework",
5
5
  "readme": "README.md",
6
6
  "main": "src/index.ts",
@@ -435,6 +435,15 @@ function expandCompoundVariantsArray(t, arrayNode, themeParam, keys, verbose, ex
435
435
  } else if (iteratorInfo.type === 'sizes' && iteratorInfo.componentName) {
436
436
  keysToExpand = keys?.sizes?.[iteratorInfo.componentName] || [];
437
437
  variantKeyName = 'size';
438
+ } else if (iteratorInfo.type === 'surfaceColors') {
439
+ keysToExpand = keys?.surfaceColors || [];
440
+ variantKeyName = 'background';
441
+ } else if (iteratorInfo.type === 'textColors') {
442
+ keysToExpand = keys?.textColors || [];
443
+ variantKeyName = 'color';
444
+ } else if (iteratorInfo.type === 'borderColors') {
445
+ keysToExpand = keys?.borderColors || [];
446
+ variantKeyName = 'borderColor';
438
447
  }
439
448
 
440
449
  if (keysToExpand.length === 0) {
@@ -498,6 +507,32 @@ function findIteratorPattern(t, node, themeParam, debugLog = () => {}) {
498
507
  return;
499
508
  }
500
509
 
510
+ // Color iterators: theme.colors.$surface, theme.colors.$text, theme.colors.$border
511
+ // Pattern: theme.colors.$surface expands to screen, primary, secondary, etc.
512
+ if (i > 0 && chain[i - 1] === 'colors') {
513
+ if (iteratorName === 'surface') {
514
+ result = {
515
+ type: 'surfaceColors',
516
+ accessPath: chain.slice(i + 1),
517
+ };
518
+ return;
519
+ }
520
+ if (iteratorName === 'text') {
521
+ result = {
522
+ type: 'textColors',
523
+ accessPath: chain.slice(i + 1),
524
+ };
525
+ return;
526
+ }
527
+ if (iteratorName === 'border') {
528
+ result = {
529
+ type: 'borderColors',
530
+ accessPath: chain.slice(i + 1),
531
+ };
532
+ return;
533
+ }
534
+ }
535
+
501
536
  if (i > 0 && chain[i - 1] === 'sizes') {
502
537
  result = {
503
538
  type: 'sizes',
@@ -561,6 +596,12 @@ function expandVariantWithIterator(t, valueNode, themeParam, keys, iteratorInfo,
561
596
  keysToExpand = keys?.typography || [];
562
597
  } else if (iteratorInfo.type === 'sizes' && iteratorInfo.componentName) {
563
598
  keysToExpand = keys?.sizes?.[iteratorInfo.componentName] || [];
599
+ } else if (iteratorInfo.type === 'surfaceColors') {
600
+ keysToExpand = keys?.surfaceColors || [];
601
+ } else if (iteratorInfo.type === 'textColors') {
602
+ keysToExpand = keys?.textColors || [];
603
+ } else if (iteratorInfo.type === 'borderColors') {
604
+ keysToExpand = keys?.borderColors || [];
564
605
  }
565
606
 
566
607
  if (keysToExpand.length === 0) {
@@ -573,9 +614,14 @@ function expandVariantWithIterator(t, valueNode, themeParam, keys, iteratorInfo,
573
614
 
574
615
  for (const key of keysToExpand) {
575
616
  const expandedValue = replaceIteratorRefs(t, valueNode, themeParam, iteratorInfo, key);
617
+ // Use string literal for keys with special characters (like hyphens)
618
+ // e.g., 'inverse-secondary' cannot be a valid identifier
619
+ const keyNode = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)
620
+ ? t.identifier(key)
621
+ : t.stringLiteral(key);
576
622
  expandedProps.push(
577
623
  t.objectProperty(
578
- t.identifier(key),
624
+ keyNode,
579
625
  expandedValue
580
626
  )
581
627
  );
@@ -621,6 +667,22 @@ function replaceIteratorRefs(t, node, themeParam, iteratorInfo, key) {
621
667
  dollarIndex = i;
622
668
  break;
623
669
  }
670
+ // Color iterators: theme.colors.$surface -> theme.colors.surface.{key}
671
+ if (iteratorInfo.type === 'surfaceColors' && iterName === 'surface' && i > 0 && chain[i - 1] === 'colors') {
672
+ hasIterator = true;
673
+ dollarIndex = i;
674
+ break;
675
+ }
676
+ if (iteratorInfo.type === 'textColors' && iterName === 'text' && i > 0 && chain[i - 1] === 'colors') {
677
+ hasIterator = true;
678
+ dollarIndex = i;
679
+ break;
680
+ }
681
+ if (iteratorInfo.type === 'borderColors' && iterName === 'border' && i > 0 && chain[i - 1] === 'colors') {
682
+ hasIterator = true;
683
+ dollarIndex = i;
684
+ break;
685
+ }
624
686
  }
625
687
  }
626
688
 
@@ -664,7 +726,14 @@ function replaceIteratorRefs(t, node, themeParam, iteratorInfo, key) {
664
726
  function buildMemberExpression(t, base, chain) {
665
727
  let expr = t.identifier(base);
666
728
  for (const part of chain) {
667
- expr = t.memberExpression(expr, t.identifier(part));
729
+ // Use bracket notation for keys with special characters (like hyphens)
730
+ // e.g., theme.colors.surface['inverse-secondary'] instead of theme.colors.surface.inverse-secondary
731
+ const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(part);
732
+ if (isValidIdentifier) {
733
+ expr = t.memberExpression(expr, t.identifier(part));
734
+ } else {
735
+ expr = t.memberExpression(expr, t.stringLiteral(part), true); // computed = true
736
+ }
668
737
  }
669
738
  return expr;
670
739
  }