app-studio 0.5.85 → 0.5.89

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.
@@ -1339,83 +1339,208 @@ class LRUCache {
1339
1339
  return this.cache.has(key);
1340
1340
  }
1341
1341
  }
1342
+ // Store raw CSS classes
1343
+ const rawCssCache = /*#__PURE__*/new Map();
1344
+ /**
1345
+ * Maps a React event to a CSS pseudo-class.
1346
+ */
1347
+ const EVENT_TO_PSEUDO = {
1348
+ // Basic interaction states
1349
+ hover: 'hover',
1350
+ active: 'active',
1351
+ focus: 'focus',
1352
+ visited: 'visited',
1353
+ // Form states
1354
+ disabled: 'disabled',
1355
+ enabled: 'enabled',
1356
+ checked: 'checked',
1357
+ unchecked: 'not(:checked)',
1358
+ invalid: 'invalid',
1359
+ valid: 'valid',
1360
+ required: 'required',
1361
+ optional: 'optional',
1362
+ // Selection states
1363
+ selected: 'selected',
1364
+ // Target states
1365
+ target: 'target',
1366
+ // Child states
1367
+ firstChild: 'first-child',
1368
+ lastChild: 'last-child',
1369
+ onlyChild: 'only-child',
1370
+ firstOfType: 'first-of-type',
1371
+ lastOfType: 'last-of-type',
1372
+ // Other states
1373
+ empty: 'empty',
1374
+ // Focus states
1375
+ focusVisible: 'focus-visible',
1376
+ focusWithin: 'focus-within',
1377
+ // Placeholder
1378
+ placeholder: 'placeholder-shown'
1379
+ };
1380
+ /**
1381
+ * Utility functions for animation handling
1382
+ */
1383
+ const AnimationUtils = {
1384
+ parseDuration(duration) {
1385
+ const match = duration.match(/^([\d.]+)(ms|s)$/);
1386
+ if (!match) return 0;
1387
+ const value = parseFloat(match[1]);
1388
+ const unit = match[2];
1389
+ return unit === 's' ? value * 1000 : value;
1390
+ },
1391
+ formatDuration(ms) {
1392
+ if (ms >= 1000 && ms % 1000 === 0) {
1393
+ return `${ms / 1000}s`;
1394
+ }
1395
+ return `${ms}ms`;
1396
+ },
1397
+ processAnimations(animations) {
1398
+ const result = {
1399
+ names: [],
1400
+ durations: [],
1401
+ timingFunctions: [],
1402
+ delays: [],
1403
+ iterationCounts: [],
1404
+ directions: [],
1405
+ fillModes: [],
1406
+ playStates: [],
1407
+ timelines: [],
1408
+ ranges: []
1409
+ };
1410
+ let cumulativeTime = 0;
1411
+ animations.forEach(animation => {
1412
+ const {
1413
+ keyframesName,
1414
+ keyframes
1415
+ } = generateKeyframes(animation);
1416
+ if (keyframes && typeof document !== 'undefined') {
1417
+ utilityClassManager.injectRule(keyframes);
1418
+ }
1419
+ result.names.push(keyframesName);
1420
+ const durationMs = this.parseDuration(animation.duration || '0s');
1421
+ const delayMs = this.parseDuration(animation.delay || '0s');
1422
+ const totalDelayMs = cumulativeTime + delayMs;
1423
+ cumulativeTime = totalDelayMs + durationMs;
1424
+ result.durations.push(this.formatDuration(durationMs));
1425
+ result.timingFunctions.push(animation.timingFunction || 'ease');
1426
+ result.delays.push(this.formatDuration(totalDelayMs));
1427
+ result.iterationCounts.push(animation.iterationCount !== undefined ? `${animation.iterationCount}` : '1');
1428
+ result.directions.push(animation.direction || 'normal');
1429
+ result.fillModes.push(animation.fillMode || 'none');
1430
+ result.playStates.push(animation.playState || 'running');
1431
+ result.timelines.push(animation.timeline || '');
1432
+ result.ranges.push(animation.range || '');
1433
+ });
1434
+ return {
1435
+ animationName: result.names.join(', '),
1436
+ animationDuration: result.durations.join(', '),
1437
+ animationTimingFunction: result.timingFunctions.join(', '),
1438
+ animationDelay: result.delays.join(', '),
1439
+ animationIterationCount: result.iterationCounts.join(', '),
1440
+ animationDirection: result.directions.join(', '),
1441
+ animationFillMode: result.fillModes.join(', '),
1442
+ animationPlayState: result.playStates.join(', '),
1443
+ ...(result.timelines.some(t => t) && {
1444
+ animationTimeline: result.timelines.join(', ')
1445
+ }),
1446
+ ...(result.ranges.some(r => r) && {
1447
+ animationRange: result.ranges.join(', ')
1448
+ })
1449
+ };
1450
+ }
1451
+ };
1452
+ /**
1453
+ * Utility functions for value processing
1454
+ */
1455
+ const ValueUtils = {
1456
+ formatValue(value, property, getColor) {
1457
+ let processedValue = value;
1458
+ // If the property is a color, convert it
1459
+ if (property.toLowerCase().includes('color')) {
1460
+ processedValue = getColor(value);
1461
+ }
1462
+ // Handle border properties that might contain color values
1463
+ if (typeof value === 'string' && value.length > 7 && (value.indexOf('color.') >= 0 || value.indexOf('theme.') >= 0)) {
1464
+ // Parse border property to extract color
1465
+ const parts = value.split(' ');
1466
+ if (parts.length >= 3) {
1467
+ // The color is typically the last part
1468
+ const colorIndex = parts.length - 1;
1469
+ const colorValue = parts[colorIndex];
1470
+ // Process the color part through getColor
1471
+ const processedColor = getColor(colorValue);
1472
+ // Replace the color part and reconstruct the border value
1473
+ parts[colorIndex] = processedColor;
1474
+ processedValue = parts.join(' ');
1475
+ }
1476
+ }
1477
+ // Handle numeric values
1478
+ if (typeof processedValue === 'number') {
1479
+ if (numericCssProperties.has(property)) {
1480
+ processedValue = `${processedValue}px`;
1481
+ }
1482
+ }
1483
+ return processedValue;
1484
+ },
1485
+ normalizeCssValue(value) {
1486
+ return value.toString().replace(/\./g, 'p').replace(/\s+/g, '-').replace(/[^a-zA-Z0-9\-]/g, '').replace(/%/g, 'pct').replace(/vw/g, 'vw').replace(/vh/g, 'vh').replace(/em/g, 'em').replace(/rem/g, 'rem');
1487
+ },
1488
+ generateUniqueClassName(css) {
1489
+ if (rawCssCache.has(css)) {
1490
+ return rawCssCache.get(css);
1491
+ }
1492
+ const shortName = Math.random().toString(36).substring(7);
1493
+ const newClassName = `raw-css-${shortName}`;
1494
+ rawCssCache.set(css, newClassName);
1495
+ return newClassName;
1496
+ }
1497
+ };
1342
1498
  class UtilityClassManager {
1343
1499
  constructor(propertyShorthand, maxCacheSize) {
1344
1500
  if (maxCacheSize === void 0) {
1345
1501
  maxCacheSize = 10000;
1346
1502
  }
1347
- this.baseStyleSheet = new Map();
1348
- this.mediaStyleSheet = new Map();
1349
- this.modifierStyleSheet = new Map();
1503
+ this.styleSheets = new Map();
1350
1504
  this.mainDocument = null;
1351
1505
  this.propertyShorthand = propertyShorthand;
1352
- this.maxCacheSize = maxCacheSize;
1353
- // Initialize LRUCache with maxSize
1354
- this.classCache = new LRUCache(this.maxCacheSize);
1506
+ this.classCache = new LRUCache(maxCacheSize);
1355
1507
  if (typeof document !== 'undefined') {
1356
1508
  this.mainDocument = document;
1357
1509
  this.initStyleSheets(document);
1358
1510
  }
1359
1511
  }
1360
1512
  initStyleSheets(targetDocument) {
1361
- if (!this.baseStyleSheet.has(targetDocument)) {
1362
- let baseStyleTag = targetDocument.getElementById('utility-classes-base');
1363
- if (!baseStyleTag) {
1364
- baseStyleTag = targetDocument.createElement('style');
1365
- baseStyleTag.id = 'utility-classes-base';
1366
- targetDocument.head.appendChild(baseStyleTag);
1367
- }
1368
- this.baseStyleSheet.set(targetDocument, baseStyleTag.sheet);
1369
- }
1370
- if (!this.mediaStyleSheet.has(targetDocument)) {
1371
- let mediaStyleTag = targetDocument.getElementById('utility-classes-media');
1372
- if (!mediaStyleTag) {
1373
- mediaStyleTag = targetDocument.createElement('style');
1374
- mediaStyleTag.id = 'utility-classes-media';
1375
- targetDocument.head.appendChild(mediaStyleTag);
1376
- }
1377
- this.mediaStyleSheet.set(targetDocument, mediaStyleTag.sheet);
1378
- }
1379
- if (!this.modifierStyleSheet.has(targetDocument)) {
1380
- let modifierStyleTag = targetDocument.getElementById('utility-classes-modifier');
1381
- if (!modifierStyleTag) {
1382
- modifierStyleTag = targetDocument.createElement('style');
1383
- modifierStyleTag.id = 'utility-classes-modifier';
1384
- targetDocument.head.appendChild(modifierStyleTag);
1513
+ if (!this.styleSheets.has(targetDocument)) {
1514
+ const sheetMap = {};
1515
+ // Initialize all style sheets at once
1516
+ const contextIds = {
1517
+ base: 'utility-classes-base',
1518
+ pseudo: 'utility-classes-pseudo',
1519
+ media: 'utility-classes-media',
1520
+ modifier: 'utility-classes-modifier'
1521
+ };
1522
+ for (const [context, id] of Object.entries(contextIds)) {
1523
+ let styleTag = targetDocument.getElementById(id);
1524
+ if (!styleTag) {
1525
+ styleTag = targetDocument.createElement('style');
1526
+ styleTag.id = id;
1527
+ targetDocument.head.appendChild(styleTag);
1528
+ }
1529
+ sheetMap[context] = styleTag.sheet;
1385
1530
  }
1386
- this.modifierStyleSheet.set(targetDocument, modifierStyleTag.sheet);
1531
+ this.styleSheets.set(targetDocument, sheetMap);
1387
1532
  }
1388
1533
  }
1389
- getMainDocumentRules() {
1390
- if (!this.mainDocument) return [];
1534
+ getDocumentRules(targetDocument) {
1391
1535
  const rules = [];
1392
- // Get base rules
1393
- const baseSheet = this.baseStyleSheet.get(this.mainDocument);
1394
- if (baseSheet) {
1395
- Array.from(baseSheet.cssRules).forEach(rule => {
1536
+ const styleSheetsMap = this.styleSheets.get(targetDocument);
1537
+ if (!styleSheetsMap) return rules;
1538
+ // Get rules from all contexts
1539
+ for (const [context, sheet] of Object.entries(styleSheetsMap)) {
1540
+ Array.from(sheet.cssRules).forEach(rule => {
1396
1541
  rules.push({
1397
1542
  cssText: rule.cssText,
1398
- context: 'base'
1399
- });
1400
- });
1401
- }
1402
- // Get media rules
1403
- const mediaSheet = this.mediaStyleSheet.get(this.mainDocument);
1404
- if (mediaSheet) {
1405
- Array.from(mediaSheet.cssRules).forEach(rule => {
1406
- rules.push({
1407
- cssText: rule.cssText,
1408
- context: 'media'
1409
- });
1410
- });
1411
- }
1412
- // Get modifier rules
1413
- const modifierSheet = this.modifierStyleSheet.get(this.mainDocument);
1414
- if (modifierSheet) {
1415
- Array.from(modifierSheet.cssRules).forEach(rule => {
1416
- rules.push({
1417
- cssText: rule.cssText,
1418
- context: 'modifier'
1543
+ context: context
1419
1544
  });
1420
1545
  });
1421
1546
  }
@@ -1425,23 +1550,24 @@ class UtilityClassManager {
1425
1550
  if (targetDocument === this.mainDocument) return;
1426
1551
  this.initStyleSheets(targetDocument);
1427
1552
  this.clearStylesFromDocument(targetDocument);
1428
- // Reinject all cached rules into the new document
1429
- const mainRules = this.getMainDocumentRules();
1430
- mainRules.forEach(_ref => {
1431
- let {
1432
- cssText,
1433
- context
1434
- } = _ref;
1435
- this.injectRuleToDocument(cssText, context, targetDocument);
1436
- });
1553
+ // Copy rules from main document
1554
+ if (this.mainDocument) {
1555
+ const mainRules = this.getDocumentRules(this.mainDocument);
1556
+ mainRules.forEach(_ref => {
1557
+ let {
1558
+ cssText,
1559
+ context
1560
+ } = _ref;
1561
+ this.injectRuleToDocument(cssText, context, targetDocument);
1562
+ });
1563
+ }
1437
1564
  }
1438
1565
  clearStylesFromDocument(targetDocument) {
1439
- const baseSheet = this.baseStyleSheet.get(targetDocument);
1440
- const mediaSheet = this.mediaStyleSheet.get(targetDocument);
1441
- const modifierSheet = this.modifierStyleSheet.get(targetDocument);
1442
- if (baseSheet) this.clearStyleSheet(baseSheet);
1443
- if (mediaSheet) this.clearStyleSheet(mediaSheet);
1444
- if (modifierSheet) this.clearStyleSheet(modifierSheet);
1566
+ const styleSheetsMap = this.styleSheets.get(targetDocument);
1567
+ if (!styleSheetsMap) return;
1568
+ for (const sheet of Object.values(styleSheetsMap)) {
1569
+ this.clearStyleSheet(sheet);
1570
+ }
1445
1571
  }
1446
1572
  escapeClassName(className) {
1447
1573
  return className.replace(/:/g, '\\:');
@@ -1450,11 +1576,11 @@ class UtilityClassManager {
1450
1576
  if (context === void 0) {
1451
1577
  context = 'base';
1452
1578
  }
1453
- // First inject to main document
1579
+ // Inject to main document
1454
1580
  if (this.mainDocument) {
1455
1581
  this.injectRuleToDocument(cssRule, context, this.mainDocument);
1456
1582
  }
1457
- // Then inject to all iframe documents
1583
+ // Inject to all other documents
1458
1584
  for (const document of this.getAllRegisteredDocuments()) {
1459
1585
  if (document !== this.mainDocument) {
1460
1586
  this.injectRuleToDocument(cssRule, context, document);
@@ -1462,10 +1588,9 @@ class UtilityClassManager {
1462
1588
  }
1463
1589
  }
1464
1590
  getAllRegisteredDocuments() {
1465
- return Array.from(this.baseStyleSheet.keys());
1591
+ return Array.from(this.styleSheets.keys());
1466
1592
  }
1467
1593
  addToCache(key, className, rules) {
1468
- // LRUCache handles size limit internally
1469
1594
  this.classCache.set(key, {
1470
1595
  className,
1471
1596
  rules
@@ -1481,90 +1606,58 @@ class UtilityClassManager {
1481
1606
  if (mediaQueries === void 0) {
1482
1607
  mediaQueries = [];
1483
1608
  }
1484
- let processedValue = value;
1485
- // If the property is a color, convert it
1486
- if (property.toLowerCase().includes('color')) {
1487
- processedValue = getColor(value);
1488
- }
1489
- // Handle border properties that might contain color values
1490
- if (typeof value === 'string' && value.length > 7 && (value.indexOf('color.') >= 0 || value.indexOf('theme.') >= 0)) {
1491
- // Parse border property to extract color
1492
- // Format could be like: "1px solid red" or "1px solid color.red.500"
1493
- const parts = value.split(' ');
1494
- if (parts.length >= 3) {
1495
- // The color is typically the last part
1496
- const colorIndex = parts.length - 1;
1497
- const colorValue = parts[colorIndex];
1498
- // Process the color part through getColor
1499
- const processedColor = getColor(colorValue);
1500
- // Replace the color part and reconstruct the border value
1501
- parts[colorIndex] = processedColor;
1502
- processedValue = parts.join(' ');
1503
- }
1504
- }
1505
- // Handle numeric values
1506
- if (typeof processedValue === 'number') {
1507
- if (numericCssProperties.has(property)) {
1508
- processedValue = `${processedValue}px`;
1509
- }
1510
- }
1609
+ // Format value
1610
+ let processedValue = ValueUtils.formatValue(value, property, getColor);
1511
1611
  let formattedValue = processedValue.toString().split(' ').join('-');
1512
1612
  let key = `${property}:${formattedValue}`;
1513
1613
  if (modifier && context !== 'base') {
1514
1614
  key = `${property}:${formattedValue}|${context}:${modifier}`;
1515
1615
  }
1616
+ // Check cache
1516
1617
  const cached = this.classCache.get(key);
1517
1618
  if (cached) {
1518
1619
  return [cached.className];
1519
1620
  }
1520
- let shorthand = this.propertyShorthand[property];
1521
- if (!shorthand) {
1522
- shorthand = property.replace(/([A-Z])/g, '-$1').toLowerCase();
1523
- }
1524
- let normalizedValue = formattedValue.toString().replace(/\./g, 'p').replace(/\s+/g, '-').replace(/[^a-zA-Z0-9\-]/g, '').replace(/%/g, 'pct').replace(/vw/g, 'vw').replace(/vh/g, 'vh').replace(/em/g, 'em').replace(/rem/g, 'rem');
1621
+ // Get property shorthand
1622
+ let shorthand = this.propertyShorthand[property] || property.replace(/([A-Z])/g, '-$1').toLowerCase();
1623
+ // Normalize the value for class name generation
1624
+ let normalizedValue = ValueUtils.normalizeCssValue(formattedValue);
1625
+ // Generate class name
1525
1626
  let baseClassName = `${shorthand}-${normalizedValue}`;
1526
1627
  let classNames = [baseClassName];
1527
1628
  let rules = [];
1629
+ // Format CSS property name
1528
1630
  const cssProperty = property.replace(/([A-Z])/g, '-$1').toLowerCase();
1529
1631
  let valueForCss = processedValue;
1632
+ // Handle numeric values for CSS
1530
1633
  if (typeof valueForCss === 'number' && numericCssProperties.has(cssProperty)) {
1531
1634
  valueForCss = `${valueForCss}px`;
1532
1635
  }
1533
- const generateRules = className => {
1534
- const escapedClassName = this.escapeClassName(className);
1535
- switch (context) {
1536
- case 'base':
1537
- rules.push({
1538
- rule: `.${escapedClassName} { ${cssProperty}: ${valueForCss}; }`,
1539
- context: 'base'
1540
- });
1541
- break;
1542
- case 'pseudo':
1543
- rules.push({
1544
- rule: `.${escapedClassName}:${modifier} { ${cssProperty}: ${valueForCss}; }`,
1545
- context: 'pseudo'
1546
- });
1547
- break;
1548
- case 'media':
1549
- mediaQueries.forEach(mq => {
1550
- rules.push({
1551
- rule: `@media ${mq} { .${escapedClassName} { ${cssProperty}: ${valueForCss}; } }`,
1552
- context: 'media'
1553
- });
1554
- });
1555
- break;
1556
- }
1557
- };
1636
+ // Generate CSS rules based on context
1558
1637
  if (context === 'pseudo' && modifier) {
1559
1638
  const pseudoClassName = `${baseClassName}--${modifier}`;
1560
1639
  classNames = [pseudoClassName];
1561
- generateRules(pseudoClassName);
1640
+ const escapedClassName = this.escapeClassName(pseudoClassName);
1641
+ rules.push({
1642
+ rule: `.${escapedClassName}:${modifier} { ${cssProperty}: ${valueForCss}; }`,
1643
+ context: 'pseudo'
1644
+ });
1562
1645
  } else if (context === 'media' && modifier) {
1563
1646
  const mediaClassName = `${modifier}--${baseClassName}`;
1564
1647
  classNames = [mediaClassName];
1565
- generateRules(mediaClassName);
1648
+ const escapedClassName = this.escapeClassName(mediaClassName);
1649
+ mediaQueries.forEach(mq => {
1650
+ rules.push({
1651
+ rule: `@media ${mq} { .${escapedClassName} { ${cssProperty}: ${valueForCss}; } }`,
1652
+ context: 'media'
1653
+ });
1654
+ });
1566
1655
  } else {
1567
- generateRules(baseClassName);
1656
+ const escapedClassName = this.escapeClassName(baseClassName);
1657
+ rules.push({
1658
+ rule: `.${escapedClassName} { ${cssProperty}: ${valueForCss}; }`,
1659
+ context: 'base'
1660
+ });
1568
1661
  }
1569
1662
  // Inject all rules
1570
1663
  rules.forEach(_ref2 => {
@@ -1580,9 +1673,7 @@ class UtilityClassManager {
1580
1673
  }
1581
1674
  removeDocument(targetDocument) {
1582
1675
  if (targetDocument === this.mainDocument) return;
1583
- this.baseStyleSheet.delete(targetDocument);
1584
- this.mediaStyleSheet.delete(targetDocument);
1585
- this.modifierStyleSheet.delete(targetDocument);
1676
+ this.styleSheets.delete(targetDocument);
1586
1677
  }
1587
1678
  clearCache() {
1588
1679
  this.classCache.clear();
@@ -1609,30 +1700,19 @@ class UtilityClassManager {
1609
1700
  });
1610
1701
  }
1611
1702
  } else {
1612
- // For iframes, copy from main document
1703
+ // For other documents, copy from main document
1613
1704
  this.addDocument(targetDocument);
1614
1705
  }
1615
1706
  }
1616
1707
  regenerateAllStyles() {
1617
- // Regenerate styles for all registered documents
1618
1708
  for (const document of this.getAllRegisteredDocuments()) {
1619
1709
  this.regenerateStyles(document);
1620
1710
  }
1621
1711
  }
1622
1712
  injectRuleToDocument(cssRule, context, targetDocument) {
1623
- let styleSheet = null;
1624
- switch (context) {
1625
- case 'base':
1626
- case 'pseudo':
1627
- styleSheet = this.baseStyleSheet.get(targetDocument) || null;
1628
- break;
1629
- case 'media':
1630
- styleSheet = this.mediaStyleSheet.get(targetDocument) || null;
1631
- break;
1632
- case 'modifier':
1633
- styleSheet = this.modifierStyleSheet.get(targetDocument) || null;
1634
- break;
1635
- }
1713
+ const styleSheetsMap = this.styleSheets.get(targetDocument);
1714
+ if (!styleSheetsMap) return;
1715
+ const styleSheet = styleSheetsMap[context];
1636
1716
  if (styleSheet) {
1637
1717
  try {
1638
1718
  styleSheet.insertRule(cssRule, styleSheet.cssRules.length);
@@ -1641,75 +1721,25 @@ class UtilityClassManager {
1641
1721
  }
1642
1722
  }
1643
1723
  }
1644
- // Optional: Add helpers for debugging
1724
+ // Debug helper
1645
1725
  printStyles(targetDocument) {
1646
1726
  console.group('Current styles for document:');
1647
- console.group('Base styles:');
1648
- const baseSheet = this.baseStyleSheet.get(targetDocument);
1649
- if (baseSheet) {
1650
- Array.from(baseSheet.cssRules).forEach((rule, i) => {
1651
- console.log(`${i}: ${rule.cssText}`);
1652
- });
1653
- }
1654
- console.groupEnd();
1655
- console.group('Media styles:');
1656
- const mediaSheet = this.mediaStyleSheet.get(targetDocument);
1657
- if (mediaSheet) {
1658
- Array.from(mediaSheet.cssRules).forEach((rule, i) => {
1659
- console.log(`${i}: ${rule.cssText}`);
1660
- });
1727
+ const styleSheetsMap = this.styleSheets.get(targetDocument);
1728
+ if (!styleSheetsMap) {
1729
+ console.log('No styles found for this document');
1730
+ console.groupEnd();
1731
+ return;
1661
1732
  }
1662
- console.groupEnd();
1663
- console.group('Modifier styles:');
1664
- const modifierSheet = this.modifierStyleSheet.get(targetDocument);
1665
- if (modifierSheet) {
1666
- Array.from(modifierSheet.cssRules).forEach((rule, i) => {
1733
+ for (const [context, sheet] of Object.entries(styleSheetsMap)) {
1734
+ console.group(`${context} styles:`);
1735
+ Array.from(sheet.cssRules).forEach((rule, i) => {
1667
1736
  console.log(`${i}: ${rule.cssText}`);
1668
1737
  });
1738
+ console.groupEnd();
1669
1739
  }
1670
1740
  console.groupEnd();
1671
- console.groupEnd();
1672
1741
  }
1673
1742
  }
1674
- /**
1675
- * Maps a React event to a CSS pseudo-class.
1676
- */
1677
- const mapEventToPseudo = event => {
1678
- const eventWeakMap = {
1679
- // Basic interaction states
1680
- hover: 'hover',
1681
- active: 'active',
1682
- focus: 'focus',
1683
- visited: 'visited',
1684
- // Form states
1685
- disabled: 'disabled',
1686
- enabled: 'enabled',
1687
- checked: 'checked',
1688
- unchecked: 'not(:checked)',
1689
- invalid: 'invalid',
1690
- valid: 'valid',
1691
- required: 'required',
1692
- optional: 'optional',
1693
- // Selection states
1694
- selected: 'selected',
1695
- // Target states
1696
- target: 'target',
1697
- // Child states
1698
- firstChild: 'first-child',
1699
- lastChild: 'last-child',
1700
- onlyChild: 'only-child',
1701
- firstOfType: 'first-of-type',
1702
- lastOfType: 'last-of-type',
1703
- // Other states
1704
- empty: 'empty',
1705
- // Focus states
1706
- focusVisible: 'focus-visible',
1707
- focusWithin: 'focus-within',
1708
- // Placeholder
1709
- placeholder: 'placeholder-shown'
1710
- };
1711
- return eventWeakMap[event] || null;
1712
- };
1713
1743
  /**
1714
1744
  * Generates shorthand abbreviations for CSS properties.
1715
1745
  */
@@ -1738,68 +1768,96 @@ function generatePropertyShorthand(styledProps) {
1738
1768
  }
1739
1769
  return propertyShorthand;
1740
1770
  }
1741
- const rawCssCache = /*#__PURE__*/new Map();
1742
- function generateUniqueClassName(css) {
1743
- // If we already have a class name for this exact CSS, return it
1744
- // Otherwise, create a new encoded and truncated class name
1745
- if (rawCssCache.has(css)) {
1746
- return rawCssCache.get(css);
1747
- }
1748
- const shortName = Math.random().toString(36).substring(7);
1749
- // Optionally include a counter to reduce collisions on identical slice
1750
- const newClassName = `raw-css-${shortName}`;
1751
- // Store it in the cache
1752
- rawCssCache.set(css, newClassName);
1753
- return newClassName;
1754
- }
1755
1771
  const propertyShorthand = /*#__PURE__*/generatePropertyShorthand(StyleProps);
1756
- const utilityClassManager = /*#__PURE__*/new UtilityClassManager(propertyShorthand, 10000); // You can adjust maxSize here
1757
- function parseDuration(duration) {
1758
- const match = duration.match(/^([\d.]+)(ms|s)$/);
1759
- if (!match) return 0;
1760
- const value = parseFloat(match[1]);
1761
- const unit = match[2];
1762
- return unit === 's' ? value * 1000 : value;
1772
+ const utilityClassManager = /*#__PURE__*/new UtilityClassManager(propertyShorthand, 10000);
1773
+ /**
1774
+ * Process styles for various contexts (base, pseudo, media)
1775
+ */
1776
+ function processStyles(styles, context, modifier, getColor, mediaQueries, devices) {
1777
+ if (context === void 0) {
1778
+ context = 'base';
1779
+ }
1780
+ if (modifier === void 0) {
1781
+ modifier = '';
1782
+ }
1783
+ if (mediaQueries === void 0) {
1784
+ mediaQueries = {};
1785
+ }
1786
+ if (devices === void 0) {
1787
+ devices = {};
1788
+ }
1789
+ const classes = [];
1790
+ Object.keys(styles).forEach(property => {
1791
+ const value = styles[property];
1792
+ let mediaQueriesForClass = [];
1793
+ if (context === 'media') {
1794
+ if (mediaQueries[modifier]) {
1795
+ mediaQueriesForClass = [mediaQueries[modifier]];
1796
+ } else if (devices[modifier]) {
1797
+ mediaQueriesForClass = devices[modifier].map(mq => mediaQueries[mq]).filter(mq => mq);
1798
+ }
1799
+ }
1800
+ if (value !== undefined && value !== '') {
1801
+ const classNames = utilityClassManager.getClassNames(property, value, context, modifier, getColor, mediaQueriesForClass);
1802
+ classes.push(...classNames);
1803
+ }
1804
+ });
1805
+ return classes;
1763
1806
  }
1764
- function formatDuration(ms) {
1765
- if (ms >= 1000 && ms % 1000 === 0) {
1766
- return `${ms / 1000}s`;
1807
+ /**
1808
+ * Process event-based styles (hover, focus, etc.)
1809
+ */
1810
+ function processEventStyles(eventName, eventStyles, getColor) {
1811
+ const classes = [];
1812
+ const {
1813
+ animate = undefined,
1814
+ ...otherEventStyles
1815
+ } = typeof eventStyles === 'object' && eventStyles !== null ? eventStyles : {
1816
+ color: eventStyles
1817
+ };
1818
+ // Process animations if present
1819
+ if (animate) {
1820
+ const animations = Array.isArray(animate) ? animate : [animate];
1821
+ const animationStyles = AnimationUtils.processAnimations(animations);
1822
+ Object.assign(otherEventStyles, animationStyles);
1823
+ }
1824
+ // Apply styles if we have a valid pseudo-class
1825
+ if (Object.keys(otherEventStyles).length > 0) {
1826
+ const pseudo = EVENT_TO_PSEUDO[eventName];
1827
+ if (pseudo) {
1828
+ classes.push(...processStyles(otherEventStyles, 'pseudo', pseudo, getColor));
1829
+ }
1767
1830
  }
1768
- return `${ms}ms`;
1831
+ return classes;
1769
1832
  }
1770
1833
  const extractUtilityClasses = (props, getColor, mediaQueries, devices) => {
1771
1834
  const classes = [];
1772
1835
  const computedStyles = {};
1773
- // Handle widthHeight
1774
- const widthHeight = props.height !== undefined && props.width !== undefined && props.height === props.width ? props.height : props.widthHeight || null;
1775
- if (widthHeight) {
1776
- const widthHeightValue = typeof widthHeight === 'number' ? `${widthHeight}px` : widthHeight;
1777
- computedStyles.width = widthHeightValue;
1778
- computedStyles.height = widthHeightValue;
1779
- }
1780
- // Handle padding and margin
1781
- if (props.paddingHorizontal) {
1782
- const paddingH = typeof props.paddingHorizontal === 'number' ? `${props.paddingHorizontal}px` : props.paddingHorizontal;
1783
- computedStyles.paddingLeft = paddingH;
1784
- computedStyles.paddingRight = paddingH;
1785
- }
1786
- if (props.marginHorizontal) {
1787
- const marginH = typeof props.marginHorizontal === 'number' ? `${props.marginHorizontal}px` : props.marginHorizontal;
1788
- computedStyles.marginLeft = marginH;
1789
- computedStyles.marginRight = marginH;
1790
- }
1791
- if (props.paddingVertical) {
1792
- const paddingV = typeof props.paddingVertical === 'number' ? `${props.paddingVertical}px` : props.paddingVertical;
1793
- computedStyles.paddingTop = paddingV;
1794
- computedStyles.paddingBottom = paddingV;
1795
- }
1796
- if (props.marginVertical) {
1797
- const marginV = typeof props.marginVertical === 'number' ? `${props.marginVertical}px` : props.marginVertical;
1798
- computedStyles.marginTop = marginV;
1799
- computedStyles.marginBottom = marginV;
1836
+ // Handle widthHeight (shorthand for both width and height)
1837
+ if (props.widthHeight || props.height !== undefined && props.width !== undefined && props.height === props.width) {
1838
+ const widthHeightValue = props.widthHeight || props.width;
1839
+ const formattedValue = typeof widthHeightValue === 'number' ? `${widthHeightValue}px` : widthHeightValue;
1840
+ computedStyles.width = formattedValue;
1841
+ computedStyles.height = formattedValue;
1842
+ }
1843
+ // Handle padding and margin shorthands
1844
+ const shorthandProps = {
1845
+ paddingHorizontal: ['paddingLeft', 'paddingRight'],
1846
+ paddingVertical: ['paddingTop', 'paddingBottom'],
1847
+ marginHorizontal: ['marginLeft', 'marginRight'],
1848
+ marginVertical: ['marginTop', 'marginBottom']
1849
+ };
1850
+ for (const [shorthand, properties] of Object.entries(shorthandProps)) {
1851
+ const value = props[shorthand];
1852
+ if (value !== undefined) {
1853
+ const formattedValue = typeof value === 'number' ? `${value}px` : value;
1854
+ properties.forEach(prop => {
1855
+ computedStyles[prop] = formattedValue;
1856
+ });
1857
+ }
1800
1858
  }
1801
1859
  // Handle shadows
1802
- if (props.shadow) {
1860
+ if (props.shadow !== undefined) {
1803
1861
  let shadowValue;
1804
1862
  if (typeof props.shadow === 'number' && Shadows[props.shadow] !== undefined) {
1805
1863
  shadowValue = props.shadow;
@@ -1823,241 +1881,57 @@ const extractUtilityClasses = (props, getColor, mediaQueries, devices) => {
1823
1881
  // Handle animations
1824
1882
  if (props.animate) {
1825
1883
  const animations = Array.isArray(props.animate) ? props.animate : [props.animate];
1826
- const animationNames = [];
1827
- const animationDurations = [];
1828
- const animationTimingFunctions = [];
1829
- const animationDelays = [];
1830
- const animationIterationCounts = [];
1831
- const animationDirections = [];
1832
- const animationFillModes = [];
1833
- const animationPlayStates = [];
1834
- const animationTimelines = [];
1835
- const animationRanges = [];
1836
- let cumulativeTime = 0;
1837
- animations.forEach(animation => {
1838
- const {
1839
- keyframesName,
1840
- keyframes
1841
- } = generateKeyframes(animation);
1842
- if (keyframes && typeof document !== 'undefined') {
1843
- utilityClassManager.injectRule(keyframes);
1844
- }
1845
- animationNames.push(keyframesName);
1846
- const durationMs = parseDuration(animation.duration || '0s');
1847
- const delayMs = parseDuration(animation.delay || '0s');
1848
- const totalDelayMs = cumulativeTime + delayMs;
1849
- cumulativeTime = totalDelayMs + durationMs;
1850
- animationDurations.push(formatDuration(durationMs));
1851
- animationTimingFunctions.push(animation.timingFunction || 'ease');
1852
- animationDelays.push(formatDuration(totalDelayMs));
1853
- animationIterationCounts.push(animation.iterationCount !== undefined ? `${animation.iterationCount}` : '1');
1854
- animationDirections.push(animation.direction || 'normal');
1855
- animationFillModes.push(animation.fillMode || 'none');
1856
- animationPlayStates.push(animation.playState || 'running');
1857
- animationTimelines.push(animation.timeline || '');
1858
- animationRanges.push(animation.range || '');
1859
- });
1860
- computedStyles.animationName = animationNames.join(', ');
1861
- computedStyles.animationDuration = animationDurations.join(', ');
1862
- computedStyles.animationTimingFunction = animationTimingFunctions.join(', ');
1863
- computedStyles.animationDelay = animationDelays.join(', ');
1864
- computedStyles.animationIterationCount = animationIterationCounts.join(', ');
1865
- computedStyles.animationDirection = animationDirections.join(', ');
1866
- computedStyles.animationFillMode = animationFillModes.join(', ');
1867
- computedStyles.animationPlayState = animationPlayStates.join(', ');
1868
- if (animationTimelines.some(t => t)) {
1869
- computedStyles.animationTimeline = animationTimelines.join(', ');
1870
- }
1871
- if (animationRanges.some(r => r)) {
1872
- computedStyles.animationRange = animationRanges.join(', ');
1873
- }
1884
+ Object.assign(computedStyles, AnimationUtils.processAnimations(animations));
1874
1885
  }
1875
- // Generate utility classes for computed styles
1876
- const generateUtilityClasses = function (styles, context, modifier) {
1877
- if (context === void 0) {
1878
- context = 'base';
1879
- }
1880
- if (modifier === void 0) {
1881
- modifier = '';
1882
- }
1883
- Object.keys(styles).forEach(property => {
1884
- const value = styles[property];
1885
- let mediaQueriesForClass = [];
1886
- if (context === 'media') {
1887
- if (mediaQueries[modifier]) {
1888
- mediaQueriesForClass = [mediaQueries[modifier]];
1889
- } else if (devices[modifier]) {
1890
- mediaQueriesForClass = devices[modifier].map(mq => mediaQueries[mq]).filter(mq => mq);
1891
- }
1892
- }
1893
- if (value !== undefined && value !== '') {
1894
- const classNames = utilityClassManager.getClassNames(property, value, context, modifier, getColor, mediaQueriesForClass);
1895
- classes.push(...classNames);
1896
- }
1897
- });
1898
- };
1899
- generateUtilityClasses(computedStyles, 'base');
1900
- // Process underscore-prefixed properties (e.g., _hover, _active)
1901
- // and collect them into a pseudo-'on' object
1886
+ // Process base styles
1887
+ classes.push(...processStyles(computedStyles, 'base', '', getColor));
1888
+ // Collect underscore-prefixed properties (_hover, _focus, etc.)
1902
1889
  const underscoreProps = {};
1903
1890
  Object.keys(props).forEach(property => {
1904
1891
  if (property.startsWith('_') && property.length > 1) {
1905
- const eventName = property.substring(1); // Remove the underscore
1892
+ const eventName = property.substring(1);
1906
1893
  underscoreProps[eventName] = props[property];
1907
1894
  }
1908
1895
  });
1909
- // Iterate over remaining style props
1896
+ // Process standard style props
1910
1897
  Object.keys(props).forEach(property => {
1911
- if (property !== 'style' && property !== 'css' && !property.startsWith('_') && (
1912
- // Skip underscore props as we handle them separately
1913
- isStyleProp(property) || ['on', 'media'].includes(property))) {
1898
+ if (property !== 'style' && property !== 'css' && !property.startsWith('_') && (isStyleProp(property) || ['on', 'media'].includes(property))) {
1914
1899
  const value = props[property];
1915
1900
  if (typeof value === 'object' && value !== null) {
1916
1901
  if (property === 'on') {
1902
+ // Process event-based styles
1917
1903
  Object.keys(value).forEach(event => {
1918
- const eventStyles = value[event];
1919
- const {
1920
- animate,
1921
- ...otherEventStyles
1922
- } = eventStyles;
1923
- if (animate) {
1924
- const animations = Array.isArray(animate) ? animate : [animate];
1925
- const animationNames = [];
1926
- const animationDurations = [];
1927
- const animationTimingFunctions = [];
1928
- const animationDelays = [];
1929
- const animationIterationCounts = [];
1930
- const animationDirections = [];
1931
- const animationFillModes = [];
1932
- const animationPlayStates = [];
1933
- animations.forEach(animation => {
1934
- const {
1935
- keyframesName,
1936
- keyframes
1937
- } = generateKeyframes(animation);
1938
- if (keyframes && typeof document !== 'undefined') {
1939
- utilityClassManager.injectRule(keyframes);
1940
- }
1941
- animationNames.push(keyframesName);
1942
- animationDurations.push(animation.duration || '0s');
1943
- animationTimingFunctions.push(animation.timingFunction || 'ease');
1944
- animationDelays.push(animation.delay || '0s');
1945
- animationIterationCounts.push(animation.iterationCount !== undefined ? `${animation.iterationCount}` : '1');
1946
- animationDirections.push(animation.direction || 'normal');
1947
- animationFillModes.push(animation.fillMode || 'none');
1948
- animationPlayStates.push(animation.playState || 'running');
1949
- });
1950
- const animationStyles = {
1951
- animationName: animationNames.join(', '),
1952
- animationDuration: animationDurations.join(', '),
1953
- animationTimingFunction: animationTimingFunctions.join(', '),
1954
- animationDelay: animationDelays.join(', '),
1955
- animationIterationCount: animationIterationCounts.join(', '),
1956
- animationDirection: animationDirections.join(', '),
1957
- animationFillMode: animationFillModes.join(', '),
1958
- animationPlayState: animationPlayStates.join(', ')
1959
- };
1960
- Object.assign(otherEventStyles, animationStyles);
1961
- }
1962
- if (Object.keys(otherEventStyles).length > 0) {
1963
- const pseudo = mapEventToPseudo(event);
1964
- if (pseudo) {
1965
- generateUtilityClasses(otherEventStyles, 'pseudo', pseudo);
1966
- }
1967
- }
1904
+ classes.push(...processEventStyles(event, value[event], getColor));
1968
1905
  });
1969
1906
  } else if (property === 'media') {
1907
+ // Process media query styles
1970
1908
  Object.keys(value).forEach(screenOrDevice => {
1971
- const mediaStyles = value[screenOrDevice];
1972
- generateUtilityClasses(mediaStyles, 'media', screenOrDevice);
1909
+ classes.push(...processStyles(value[screenOrDevice], 'media', screenOrDevice, getColor, mediaQueries, devices));
1973
1910
  });
1974
1911
  }
1975
- } else {
1976
- if (value !== undefined && value !== '') {
1977
- const classNames = utilityClassManager.getClassNames(property, value, 'base', '', getColor, []);
1978
- classes.push(...classNames);
1979
- }
1912
+ } else if (value !== undefined && value !== '') {
1913
+ // Direct style property
1914
+ classes.push(...utilityClassManager.getClassNames(property, value, 'base', '', getColor, []));
1980
1915
  }
1981
1916
  }
1982
1917
  });
1918
+ // Handle raw CSS
1983
1919
  if (props.css) {
1984
1920
  if (typeof props.css === 'object') {
1921
+ // Object-style CSS gets processed as regular styles
1985
1922
  Object.assign(computedStyles, props.css);
1923
+ classes.push(...processStyles(props.css, 'base', '', getColor));
1986
1924
  } else if (typeof props.css === 'string') {
1987
- // Generate or reuse a class for the raw CSS
1988
- const uniqueClassName = generateUniqueClassName(props.css);
1989
- console.log('uniqueClassName', uniqueClassName, props.css);
1925
+ // String-style CSS gets its own class
1926
+ const uniqueClassName = ValueUtils.generateUniqueClassName(props.css);
1990
1927
  utilityClassManager.injectRule(`.${uniqueClassName} { ${props.css} }`);
1991
1928
  classes.push(uniqueClassName);
1992
1929
  }
1993
1930
  }
1994
- // Process the underscore-prefixed properties we collected earlier
1931
+ // Process underscore-prefixed event properties
1995
1932
  if (Object.keys(underscoreProps).length > 0) {
1996
1933
  Object.keys(underscoreProps).forEach(event => {
1997
- const eventStyles = underscoreProps[event];
1998
- // Handle both object and non-object values
1999
- if (typeof eventStyles === 'object' && eventStyles !== null) {
2000
- const {
2001
- animate,
2002
- ...otherEventStyles
2003
- } = eventStyles;
2004
- if (animate) {
2005
- const animations = Array.isArray(animate) ? animate : [animate];
2006
- const animationNames = [];
2007
- const animationDurations = [];
2008
- const animationTimingFunctions = [];
2009
- const animationDelays = [];
2010
- const animationIterationCounts = [];
2011
- const animationDirections = [];
2012
- const animationFillModes = [];
2013
- const animationPlayStates = [];
2014
- animations.forEach(animation => {
2015
- const {
2016
- keyframesName,
2017
- keyframes
2018
- } = generateKeyframes(animation);
2019
- if (keyframes && typeof document !== 'undefined') {
2020
- utilityClassManager.injectRule(keyframes);
2021
- }
2022
- animationNames.push(keyframesName);
2023
- animationDurations.push(animation.duration || '0s');
2024
- animationTimingFunctions.push(animation.timingFunction || 'ease');
2025
- animationDelays.push(animation.delay || '0s');
2026
- animationIterationCounts.push(animation.iterationCount !== undefined ? `${animation.iterationCount}` : '1');
2027
- animationDirections.push(animation.direction || 'normal');
2028
- animationFillModes.push(animation.fillMode || 'none');
2029
- animationPlayStates.push(animation.playState || 'running');
2030
- });
2031
- const animationStyles = {
2032
- animationName: animationNames.join(', '),
2033
- animationDuration: animationDurations.join(', '),
2034
- animationTimingFunction: animationTimingFunctions.join(', '),
2035
- animationDelay: animationDelays.join(', '),
2036
- animationIterationCount: animationIterationCounts.join(', '),
2037
- animationDirection: animationDirections.join(', '),
2038
- animationFillMode: animationFillModes.join(', '),
2039
- animationPlayState: animationPlayStates.join(', ')
2040
- };
2041
- Object.assign(otherEventStyles, animationStyles);
2042
- }
2043
- if (Object.keys(otherEventStyles).length > 0) {
2044
- const pseudo = mapEventToPseudo(event);
2045
- if (pseudo) {
2046
- generateUtilityClasses(otherEventStyles, 'pseudo', pseudo);
2047
- }
2048
- }
2049
- } else {
2050
- // For non-object values, create a simple style object with a default property
2051
- // This allows syntax like _hover="color.blue" to work
2052
- const defaultProperty = 'color'; // You can change this or make it configurable
2053
- const styleObj = {
2054
- [defaultProperty]: eventStyles
2055
- };
2056
- const pseudo = mapEventToPseudo(event);
2057
- if (pseudo) {
2058
- generateUtilityClasses(styleObj, 'pseudo', pseudo);
2059
- }
2060
- }
1934
+ classes.push(...processEventStyles(event, underscoreProps[event], getColor));
2061
1935
  });
2062
1936
  }
2063
1937
  return classes;
@@ -2166,6 +2040,13 @@ const Horizontal = /*#__PURE__*/React__default.forwardRef((props, ref) => (/*#__
2166
2040
  }, props, {
2167
2041
  ref: ref
2168
2042
  }))));
2043
+ const Center = /*#__PURE__*/React__default.forwardRef((props, ref) => (/*#__PURE__*/React__default.createElement(Element, Object.assign({
2044
+ display: "flex",
2045
+ justifyContent: "center",
2046
+ alignItems: "center"
2047
+ }, props, {
2048
+ ref: ref
2049
+ }))));
2169
2050
  const Vertical = /*#__PURE__*/React__default.forwardRef((props, ref) => (/*#__PURE__*/React__default.createElement(Element, Object.assign({
2170
2051
  display: "flex",
2171
2052
  flexDirection: "column"
@@ -4121,6 +4002,7 @@ exports.AnalyticsContext = AnalyticsContext;
4121
4002
  exports.AnalyticsProvider = AnalyticsProvider;
4122
4003
  exports.Animation = Animation;
4123
4004
  exports.Button = Button;
4005
+ exports.Center = Center;
4124
4006
  exports.Div = Div;
4125
4007
  exports.Element = Element;
4126
4008
  exports.Form = Form;