app-studio 0.7.10 → 0.7.12

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.
@@ -783,91 +783,44 @@ const LIGHT_PREFIX = 'light-';
783
783
  const DARK_PREFIX = 'dark-';
784
784
  const TRANSPARENT = 'transparent';
785
785
  // --- CSS Variable Injection Helper ---
786
+ // Optimized: single-pass processing, minimal string allocations, minified output
786
787
  const generateCSSVariables = (theme, lightColors, darkColors) => {
787
- const variables = [];
788
- const lightVariables = [];
789
- const darkVariables = [];
790
- const themeVariables = [];
791
- // Helper to process object and generate variables
792
- const processObject = (obj, prefix, targetArray) => {
793
- Object.keys(obj).forEach(key => {
794
- const value = obj[key];
795
- const variableName = `${prefix}-${key}`.replace(/\./g, '-');
796
- if (typeof value === 'object' && value !== null) {
797
- processObject(value, variableName, targetArray);
798
- } else if (typeof value === 'string' || typeof value === 'number') {
799
- targetArray.push(`--${variableName}: ${value};`);
788
+ const rootVars = [];
789
+ const lightMappings = [];
790
+ const darkMappings = [];
791
+ // Single-pass helper: generates base, light, dark vars and theme-switch mappings together
792
+ const processColors = (lightObj, darkObj, prefix) => {
793
+ const keys = Object.keys(lightObj);
794
+ for (let i = 0; i < keys.length; i++) {
795
+ const key = keys[i];
796
+ const lightValue = lightObj[key];
797
+ const darkValue = darkObj?.[key];
798
+ const varName = `${prefix}-${key}`;
799
+ if (typeof lightValue === 'object' && lightValue !== null) {
800
+ processColors(lightValue, darkValue, varName);
801
+ } else if (typeof lightValue === 'string' || typeof lightValue === 'number') {
802
+ // :root gets base + light/dark prefixed vars
803
+ rootVars.push(`--${varName}:${lightValue};--light-${varName}:${lightValue};--dark-${varName}:${darkValue ?? lightValue}`);
804
+ // Theme-switching selectors
805
+ lightMappings.push(`--${varName}:var(--light-${varName})`);
806
+ darkMappings.push(`--${varName}:var(--dark-${varName})`);
800
807
  }
801
- });
802
- };
803
- // 1. Generate ALL primitive variables (light and dark)
804
- // We prefix them with --light-color-... and --dark-color-...
805
- processObject(lightColors.main, 'color', variables);
806
- processObject(lightColors.palette, 'color', variables);
807
- processObject(lightColors.main, 'light-color', lightVariables);
808
- processObject(lightColors.palette, 'light-color', lightVariables);
809
- processObject(darkColors.main, 'dark-color', darkVariables);
810
- processObject(darkColors.palette, 'dark-color', darkVariables);
811
- // We collect the names that need mapping
812
- const genericColorVars = [];
813
- const collectGenericNames = (obj, prefix) => {
814
- Object.keys(obj).forEach(key => {
815
- const value = obj[key];
816
- const variableName = `${prefix}-${key}`.replace(/\./g, '-');
817
- if (typeof value === 'object' && value !== null) {
818
- collectGenericNames(value, variableName);
819
- } else {
820
- genericColorVars.push(variableName);
821
- }
822
- });
823
- };
824
- collectGenericNames(lightColors.main, 'color');
825
- collectGenericNames(lightColors.palette, 'color');
826
- // 3. Process Theme variables (references)
827
- // Theme config uses dash notation (color-blue-500, theme-primary)
828
- const processTheme = (obj, prefix) => {
829
- Object.keys(obj).forEach(key => {
830
- const value = obj[key];
831
- const variableName = `${prefix}-${key}`;
832
- if (typeof value === 'object' && value !== null) {
833
- processTheme(value, variableName);
834
- } else if (typeof value === 'string') {
835
- if (value.startsWith('color-') || value.startsWith('theme-')) {
836
- // Convert 'color-blue-500' -> 'var(--color-blue-500)'
837
- themeVariables.push(`--${variableName}: var(--${value});`);
838
- } else {
839
- themeVariables.push(`--${variableName}: ${value};`);
840
- }
841
- }
842
- });
843
- };
844
- processTheme(theme, 'theme');
845
- // 4. Construct CSS
846
- // :root has all primitives
847
- // [data-theme='light'] maps color vars to light primitives
848
- // [data-theme='dark'] maps color vars to dark primitives
849
- const lightMappings = genericColorVars.map(name => `--${name}: var(--light-${name});`).join('\n ');
850
- const darkMappings = genericColorVars.map(name => `--${name}: var(--dark-${name});`).join('\n ');
851
- const css = `
852
- :root {
853
- /* Primitives */
854
- ${variables.join('\n ')}
855
- ${lightVariables.join('\n ')}
856
- ${darkVariables.join('\n ')}
857
-
858
- /* Theme Variables (Structural) */
859
- ${themeVariables.join('\n ')}
860
- }
861
-
862
- [data-theme='light'] {
863
- ${lightMappings}
864
808
  }
865
-
866
- [data-theme='dark'] {
867
- ${darkMappings}
809
+ };
810
+ processColors(lightColors.main, darkColors.main, 'color');
811
+ processColors(lightColors.palette, darkColors.palette, 'color');
812
+ // Process theme variables
813
+ const themeVars = [];
814
+ const themeKeys = Object.keys(theme);
815
+ for (let i = 0; i < themeKeys.length; i++) {
816
+ const key = themeKeys[i];
817
+ const value = theme[key];
818
+ if (typeof value === 'string') {
819
+ themeVars.push(value.startsWith('color-') || value.startsWith('theme-') ? `--theme-${key}:var(--${value})` : `--theme-${key}:${value}`);
868
820
  }
869
- `;
870
- return css;
821
+ }
822
+ // Build minified CSS (no unnecessary whitespace)
823
+ return `:root{${rootVars.join(';')};${themeVars.join(';')}}[data-theme='light']{${lightMappings.join(';')}}[data-theme='dark']{${darkMappings.join(';')}}`;
871
824
  };
872
825
  // --- Default Configuration ---
873
826
  // Theme values use dash notation (color-X or color-X-shade)
@@ -1774,9 +1727,10 @@ function propertyToKebabCase(property) {
1774
1727
  return vendorPrefixToKebabCase(property);
1775
1728
  }
1776
1729
  // Comprehensive list of CSS properties that should be converted to classes
1730
+ // NOTE: Uses a static set instead of document.createElement('div').style
1731
+ // to avoid DOM access at module load time (breaks SSR, adds startup overhead).
1732
+ // The manual list below is comprehensive and covers all commonly used CSS properties.
1777
1733
  const cssProperties = /*#__PURE__*/new Set([
1778
- // Standard CSS properties
1779
- ... /*#__PURE__*/Object.keys(/*#__PURE__*/document.createElement('div').style),
1780
1734
  // Box model
1781
1735
  'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginHorizontal', 'marginVertical', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingHorizontal', 'paddingVertical', 'width', 'height', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight',
1782
1736
  // Positioning
@@ -1805,6 +1759,8 @@ const cssProperties = /*#__PURE__*/new Set([
1805
1759
  'textJustify', 'lineClamp', 'textIndent', 'perspective']);
1806
1760
  // Common React event handlers that should not be treated as style props
1807
1761
  const commonEventHandlers = /*#__PURE__*/new Set(['onClick', 'onChange', 'onSubmit', 'onFocus', 'onBlur', 'onKeyDown', 'onKeyUp', 'onKeyPress', 'onMouseDown', 'onMouseUp', 'onMouseMove', 'onMouseEnter', 'onMouseLeave', 'onTouchStart', 'onTouchEnd', 'onTouchMove', 'onScroll', 'onWheel', 'onDrag', 'onDragStart', 'onDragEnd', 'onDrop']);
1762
+ // Cache for CSS.supports results to avoid repeated DOM queries
1763
+ const cssSupportCache = /*#__PURE__*/new Map();
1808
1764
  // Non-hyphenated HTML/SVG attributes that must never be treated as style props.
1809
1765
  // Hyphenated attributes (aria-*, data-*, etc.) are caught by a prefix/hyphen check below.
1810
1766
  const htmlOnlyAttributes = /*#__PURE__*/new Set([
@@ -1857,11 +1813,17 @@ const isStyleProp = prop => {
1857
1813
  return true;
1858
1814
  }
1859
1815
  // Check if it's a valid CSS property using CSS.supports (browser environment)
1816
+ // Results are cached to avoid repeated CSS.supports calls
1860
1817
  if (typeof CSS !== 'undefined' && CSS.supports) {
1818
+ const cached = cssSupportCache.get(prop);
1819
+ if (cached !== undefined) return cached;
1861
1820
  try {
1862
1821
  const kebabProp = vendorPrefixToKebabCase(prop);
1863
- return CSS.supports(kebabProp, 'inherit');
1822
+ const result = CSS.supports(kebabProp, 'inherit');
1823
+ cssSupportCache.set(prop, result);
1824
+ return result;
1864
1825
  } catch {
1826
+ cssSupportCache.set(prop, false);
1865
1827
  return false;
1866
1828
  }
1867
1829
  }
@@ -1904,6 +1866,10 @@ const processStyleProperty = (property, value, getColor) => {
1904
1866
  const kebabProperty = toKebabCase(property);
1905
1867
  // Convert numbers to pixels for appropriate properties
1906
1868
  if (typeof value === 'number') {
1869
+ // lineHeight only accepts integers: 1-3 are unitless multipliers, 4+ are pixel sizes
1870
+ if (property === 'lineHeight' && Number.isInteger(value) && value <= 3) {
1871
+ return value;
1872
+ }
1907
1873
  // Check if this is a property that should have px units
1908
1874
  // First check the property as is, then check with vendor prefixes removed
1909
1875
  const shouldAddPx = !NumberProps.has(property) && (numericCssProperties.has(kebabProperty) ||
@@ -1995,67 +1961,25 @@ const generateKeyframes = animation => {
1995
1961
 
1996
1962
  /**
1997
1963
  * Mapping of standard CSS properties to their vendor-prefixed equivalents.
1998
- * This helps ensure cross-browser compatibility by automatically applying
1999
- * the appropriate vendor prefixes when needed.
1964
+ *
1965
+ * Optimized for modern browsers (Chrome 100+, Safari 15+, Firefox 91+).
1966
+ * Most properties no longer need vendor prefixes in these browsers.
1967
+ * Only -webkit- prefixes are kept where still needed by Safari/WebKit.
1968
+ *
1969
+ * Removed prefixes:
1970
+ * - -moz- (Firefox 91+ supports all standard properties unprefixed)
1971
+ * - -ms- (IE/Edge Legacy no longer supported)
1972
+ * - -o- (Opera uses Blink engine, same as Chrome)
1973
+ * - -webkit- for animation, transform, transition, flexbox, boxShadow,
1974
+ * boxSizing, columns, borderImage, backgroundSize, backgroundOrigin,
1975
+ * perspective, hyphens (all unprefixed in Safari 15+)
2000
1976
  */
2001
- // Properties that commonly need vendor prefixes across browsers
1977
+ // Properties that still need vendor prefixes in modern browsers
2002
1978
  const vendorPrefixedProperties = {
2003
- // Animation properties
2004
- animation: ['-webkit-animation', '-moz-animation', '-o-animation'],
2005
- animationDelay: ['-webkit-animation-delay', '-moz-animation-delay', '-o-animation-delay'],
2006
- animationDirection: ['-webkit-animation-direction', '-moz-animation-direction', '-o-animation-direction'],
2007
- animationDuration: ['-webkit-animation-duration', '-moz-animation-duration', '-o-animation-duration'],
2008
- animationFillMode: ['-webkit-animation-fill-mode', '-moz-animation-fill-mode', '-o-animation-fill-mode'],
2009
- animationIterationCount: ['-webkit-animation-iteration-count', '-moz-animation-iteration-count', '-o-animation-iteration-count'],
2010
- animationName: ['-webkit-animation-name', '-moz-animation-name', '-o-animation-name'],
2011
- animationPlayState: ['-webkit-animation-play-state', '-moz-animation-play-state', '-o-animation-play-state'],
2012
- animationTimingFunction: ['-webkit-animation-timing-function', '-moz-animation-timing-function', '-o-animation-timing-function'],
2013
- // Transform properties
2014
- transform: ['-webkit-transform', '-moz-transform', '-ms-transform', '-o-transform'],
2015
- transformOrigin: ['-webkit-transform-origin', '-moz-transform-origin', '-ms-transform-origin', '-o-transform-origin'],
2016
- transformStyle: ['-webkit-transform-style', '-moz-transform-style', '-ms-transform-style'],
2017
- // Transition properties
2018
- transition: ['-webkit-transition', '-moz-transition', '-ms-transition', '-o-transition'],
2019
- transitionDelay: ['-webkit-transition-delay', '-moz-transition-delay', '-ms-transition-delay', '-o-transition-delay'],
2020
- transitionDuration: ['-webkit-transition-duration', '-moz-transition-duration', '-ms-transition-duration', '-o-transition-duration'],
2021
- transitionProperty: ['-webkit-transition-property', '-moz-transition-property', '-ms-transition-property', '-o-transition-property'],
2022
- transitionTimingFunction: ['-webkit-transition-timing-function', '-moz-transition-timing-function', '-ms-transition-timing-function', '-o-transition-timing-function'],
2023
- // Flexbox properties
2024
- flex: ['-webkit-flex', '-ms-flex'],
2025
- flexBasis: ['-webkit-flex-basis', '-ms-flex-basis'],
2026
- flexDirection: ['-webkit-flex-direction', '-ms-flex-direction'],
2027
- flexFlow: ['-webkit-flex-flow', '-ms-flex-flow'],
2028
- flexGrow: ['-webkit-flex-grow', '-ms-flex-positive'],
2029
- flexShrink: ['-webkit-flex-shrink', '-ms-flex-negative'],
2030
- flexWrap: ['-webkit-flex-wrap', '-ms-flex-wrap'],
2031
- justifyContent: ['-webkit-justify-content', '-ms-flex-pack'],
2032
- alignItems: ['-webkit-align-items', '-ms-flex-align'],
2033
- alignContent: ['-webkit-align-content', '-ms-flex-line-pack'],
2034
- alignSelf: ['-webkit-align-self', '-ms-flex-item-align'],
2035
- order: ['-webkit-order', '-ms-flex-order'],
2036
- // Other commonly prefixed properties
2037
- appearance: ['-webkit-appearance', '-moz-appearance', '-ms-appearance'],
2038
- backfaceVisibility: ['-webkit-backface-visibility', '-moz-backface-visibility'],
2039
- backgroundClip: ['-webkit-background-clip', '-moz-background-clip'],
2040
- backgroundOrigin: ['-webkit-background-origin', '-moz-background-origin'],
2041
- backgroundSize: ['-webkit-background-size', '-moz-background-size', '-o-background-size'],
2042
- borderImage: ['-webkit-border-image', '-moz-border-image', '-o-border-image'],
2043
- boxShadow: ['-webkit-box-shadow', '-moz-box-shadow'],
2044
- boxSizing: ['-webkit-box-sizing', '-moz-box-sizing'],
2045
- columns: ['-webkit-columns', '-moz-columns'],
2046
- columnCount: ['-webkit-column-count', '-moz-column-count'],
2047
- columnGap: ['-webkit-column-gap', '-moz-column-gap'],
2048
- columnRule: ['-webkit-column-rule', '-moz-column-rule'],
2049
- columnWidth: ['-webkit-column-width', '-moz-column-width'],
2050
- filter: ['-webkit-filter'],
2051
- fontSmoothing: ['-webkit-font-smoothing', '-moz-osx-font-smoothing'],
2052
- hyphens: ['-webkit-hyphens', '-moz-hyphens', '-ms-hyphens'],
1979
+ // Properties that still need -webkit- in Safari
1980
+ backgroundClip: ['-webkit-background-clip'],
2053
1981
  maskImage: ['-webkit-mask-image'],
2054
- perspective: ['-webkit-perspective', '-moz-perspective'],
2055
- perspectiveOrigin: ['-webkit-perspective-origin', '-moz-perspective-origin'],
2056
- textSizeAdjust: ['-webkit-text-size-adjust', '-moz-text-size-adjust', '-ms-text-size-adjust'],
2057
- userSelect: ['-webkit-user-select', '-moz-user-select', '-ms-user-select'],
2058
- // Special webkit-only properties
1982
+ // Webkit-only properties (no unprefixed equivalent)
2059
1983
  textFillColor: ['-webkit-text-fill-color'],
2060
1984
  textStroke: ['-webkit-text-stroke'],
2061
1985
  textStrokeColor: ['-webkit-text-stroke-color'],
@@ -2295,20 +2219,18 @@ const ValueUtils = {
2295
2219
  return processStyleProperty(property, value, getColor);
2296
2220
  },
2297
2221
  normalizeCssValue(value) {
2222
+ const str = typeof value === 'string' ? value : String(value);
2298
2223
  // Handle CSS variables in values
2299
- if (typeof value === 'string' && value.startsWith('--')) {
2300
- // For CSS variable values, use a special prefix to avoid conflicts
2301
- return `var-${value.substring(2)}`;
2224
+ if (str.charCodeAt(0) === 45 && str.charCodeAt(1) === 45) {
2225
+ // starts with '--'
2226
+ return `var-${str.substring(2)}`;
2302
2227
  }
2303
2228
  // Handle vendor-prefixed values
2304
- if (typeof value === 'string' && value.startsWith('-webkit-')) {
2305
- // For webkit values, preserve the prefix but normalize the rest
2306
- const prefix = '-webkit-';
2307
- const rest = value.substring(prefix.length);
2308
- const normalizedRest = rest.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');
2309
- return `webkit-${normalizedRest}`;
2229
+ if (str.startsWith('-webkit-')) {
2230
+ return `webkit-${str.substring(8).replace(/\./g, 'p').replace(/\s+/g, '-').replace(/[^a-zA-Z0-9-]/g, '')}`;
2310
2231
  }
2311
- 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');
2232
+ // Single-pass normalization: replace dots with 'p', spaces with '-', strip non-alphanumeric
2233
+ return str.replace(/\./g, 'p').replace(/\s+/g, '-').replace(/[^a-zA-Z0-9-]/g, '');
2312
2234
  },
2313
2235
  generateUniqueClassName(css) {
2314
2236
  if (rawCssCache.has(css)) {
@@ -2483,8 +2405,11 @@ class UtilityClassManager {
2483
2405
  const cssProperty = propertyToKebabCase(property);
2484
2406
  let valueForCss = processedValue;
2485
2407
  // Handle numeric values for CSS
2486
- if (typeof valueForCss === 'number' && numericCssProperties.has(cssProperty)) {
2487
- valueForCss = `${valueForCss}px`;
2408
+ if (typeof valueForCss === 'number') {
2409
+ // lineHeight only accepts integers: 1-3 are unitless multipliers, 4+ are pixel sizes
2410
+ if (property === 'lineHeight' && Number.isInteger(valueForCss) && valueForCss <= 3) ; else if (numericCssProperties.has(cssProperty)) {
2411
+ valueForCss = `${valueForCss}px`;
2412
+ }
2488
2413
  }
2489
2414
  // Check if this property needs vendor prefixes
2490
2415
  const needsPrefixes = needsVendorPrefix(property);
@@ -2672,23 +2597,77 @@ function processStyles(styles, context, modifier, getColor, mediaQueries, device
2672
2597
  devices = {};
2673
2598
  }
2674
2599
  const classes = [];
2675
- Object.keys(styles).forEach(property => {
2676
- const value = styles[property];
2677
- let mediaQueriesForClass = [];
2678
- if (context === 'media') {
2679
- if (mediaQueries[modifier]) {
2680
- mediaQueriesForClass = [mediaQueries[modifier]];
2681
- } else if (devices[modifier]) {
2682
- mediaQueriesForClass = devices[modifier].map(mq => mediaQueries[mq]).filter(mq => mq);
2683
- }
2600
+ const activeManager = manager || utilityClassManager;
2601
+ // Pre-compute media queries for this modifier (only done once per call)
2602
+ let mediaQueriesForClass = [];
2603
+ if (context === 'media') {
2604
+ if (mediaQueries[modifier]) {
2605
+ mediaQueriesForClass = [mediaQueries[modifier]];
2606
+ } else if (devices[modifier]) {
2607
+ mediaQueriesForClass = devices[modifier].map(mq => mediaQueries[mq]).filter(mq => mq);
2684
2608
  }
2609
+ }
2610
+ const expandedStyles = expandShorthandStyles(styles);
2611
+ const keys = Object.keys(expandedStyles);
2612
+ for (let i = 0; i < keys.length; i++) {
2613
+ const value = expandedStyles[keys[i]];
2685
2614
  if (value !== undefined && value !== '') {
2686
- const classNames = (manager || utilityClassManager).getClassNames(property, value, context, modifier, getColor, mediaQueriesForClass);
2615
+ const classNames = activeManager.getClassNames(keys[i], value, context, modifier, getColor, mediaQueriesForClass);
2687
2616
  classes.push(...classNames);
2688
2617
  }
2689
- });
2618
+ }
2690
2619
  return classes;
2691
2620
  }
2621
+ /**
2622
+ * Expand shorthand props (widthHeight, paddingHorizontal, marginVertical, ...)
2623
+ * into their canonical CSS properties. Returns a new object so the caller's
2624
+ * input is not mutated. Keeps unknown shorthands only if their value is set.
2625
+ */
2626
+ function expandShorthandStyles(styles) {
2627
+ const wh = styles.widthHeight;
2628
+ const ph = styles.paddingHorizontal;
2629
+ const pv = styles.paddingVertical;
2630
+ const mh = styles.marginHorizontal;
2631
+ const mv = styles.marginVertical;
2632
+ if (wh === undefined && ph === undefined && pv === undefined && mh === undefined && mv === undefined) {
2633
+ return styles;
2634
+ }
2635
+ const out = {};
2636
+ const keys = Object.keys(styles);
2637
+ for (let i = 0; i < keys.length; i++) {
2638
+ const k = keys[i];
2639
+ if (k === 'widthHeight' || k === 'paddingHorizontal' || k === 'paddingVertical' || k === 'marginHorizontal' || k === 'marginVertical') {
2640
+ continue;
2641
+ }
2642
+ out[k] = styles[k];
2643
+ }
2644
+ if (wh !== undefined) {
2645
+ const v = typeof wh === 'number' ? `${wh}px` : wh;
2646
+ if (out.width === undefined) out.width = v;
2647
+ if (out.height === undefined) out.height = v;
2648
+ }
2649
+ if (ph !== undefined) {
2650
+ const v = typeof ph === 'number' ? `${ph}px` : ph;
2651
+ if (out.paddingLeft === undefined) out.paddingLeft = v;
2652
+ if (out.paddingRight === undefined) out.paddingRight = v;
2653
+ }
2654
+ if (pv !== undefined) {
2655
+ const v = typeof pv === 'number' ? `${pv}px` : pv;
2656
+ if (out.paddingTop === undefined) out.paddingTop = v;
2657
+ if (out.paddingBottom === undefined) out.paddingBottom = v;
2658
+ }
2659
+ if (mh !== undefined) {
2660
+ const v = typeof mh === 'number' ? `${mh}px` : mh;
2661
+ if (out.marginLeft === undefined) out.marginLeft = v;
2662
+ if (out.marginRight === undefined) out.marginRight = v;
2663
+ }
2664
+ if (mv !== undefined) {
2665
+ const v = typeof mv === 'number' ? `${mv}px` : mv;
2666
+ if (out.marginTop === undefined) out.marginTop = v;
2667
+ if (out.marginBottom === undefined) out.marginBottom = v;
2668
+ }
2669
+ return out;
2670
+ }
2692
2671
  // Add a function to handle nested pseudo-classes
2693
2672
  function processPseudoStyles(styles, parentPseudo, getColor, manager) {
2694
2673
  if (parentPseudo === void 0) {
@@ -2805,6 +2784,7 @@ function processEventStyles(eventName, eventStyles, getColor, manager) {
2805
2784
  const extractUtilityClasses = (props, getColor, mediaQueries, devices, manager) => {
2806
2785
  const classes = [];
2807
2786
  const computedStyles = {};
2787
+ const activeManager = manager || utilityClassManager;
2808
2788
  // Handle widthHeight (shorthand for both width and height)
2809
2789
  if (props.widthHeight || props.height !== undefined && props.width !== undefined && props.height === props.width) {
2810
2790
  const widthHeightValue = props.widthHeight || props.width;
@@ -2812,21 +2792,30 @@ const extractUtilityClasses = (props, getColor, mediaQueries, devices, manager)
2812
2792
  computedStyles.width = formattedValue;
2813
2793
  computedStyles.height = formattedValue;
2814
2794
  }
2815
- // Handle padding and margin shorthands
2816
- const shorthandProps = {
2817
- paddingHorizontal: ['paddingLeft', 'paddingRight'],
2818
- paddingVertical: ['paddingTop', 'paddingBottom'],
2819
- marginHorizontal: ['marginLeft', 'marginRight'],
2820
- marginVertical: ['marginTop', 'marginBottom']
2821
- };
2822
- for (const [shorthand, properties] of Object.entries(shorthandProps)) {
2823
- const value = props[shorthand];
2824
- if (value !== undefined) {
2825
- const formattedValue = typeof value === 'number' ? `${value}px` : value;
2826
- properties.forEach(prop => {
2827
- computedStyles[prop] = formattedValue;
2828
- });
2829
- }
2795
+ // Handle padding and margin shorthands (inlined to avoid Object.entries overhead)
2796
+ const ph = props.paddingHorizontal;
2797
+ if (ph !== undefined) {
2798
+ const v = typeof ph === 'number' ? `${ph}px` : ph;
2799
+ computedStyles.paddingLeft = v;
2800
+ computedStyles.paddingRight = v;
2801
+ }
2802
+ const pv = props.paddingVertical;
2803
+ if (pv !== undefined) {
2804
+ const v = typeof pv === 'number' ? `${pv}px` : pv;
2805
+ computedStyles.paddingTop = v;
2806
+ computedStyles.paddingBottom = v;
2807
+ }
2808
+ const mh = props.marginHorizontal;
2809
+ if (mh !== undefined) {
2810
+ const v = typeof mh === 'number' ? `${mh}px` : mh;
2811
+ computedStyles.marginLeft = v;
2812
+ computedStyles.marginRight = v;
2813
+ }
2814
+ const mv = props.marginVertical;
2815
+ if (mv !== undefined) {
2816
+ const v = typeof mv === 'number' ? `${mv}px` : mv;
2817
+ computedStyles.marginTop = v;
2818
+ computedStyles.marginBottom = v;
2830
2819
  }
2831
2820
  // Handle shadows
2832
2821
  if (props.shadow !== undefined) {
@@ -2855,80 +2844,103 @@ const extractUtilityClasses = (props, getColor, mediaQueries, devices, manager)
2855
2844
  const animations = Array.isArray(props.animate) ? props.animate : [props.animate];
2856
2845
  Object.assign(computedStyles, AnimationUtils.processAnimations(animations, manager));
2857
2846
  }
2858
- const blendConfig = {
2859
- mode: 'difference',
2860
- color: 'white',
2861
- modeWithBg: 'overlay'
2862
- };
2863
- const setBlend = (props, style) => {
2847
+ // Handle default blend
2848
+ if (props.blend === true) {
2864
2849
  if (props.bgColor) {
2865
- style.mixBlendMode = blendConfig.modeWithBg;
2866
- style.color = 'white';
2850
+ computedStyles.mixBlendMode = 'overlay';
2851
+ computedStyles.color = 'white';
2867
2852
  } else {
2868
- style.mixBlendMode = blendConfig.mode;
2869
- style.color = blendConfig.color;
2853
+ computedStyles.mixBlendMode = 'difference';
2854
+ computedStyles.color = 'white';
2870
2855
  }
2871
- };
2872
- // Handle default blend
2873
- if (props.blend === true) {
2874
- setBlend(props, computedStyles);
2875
- Object.keys(props).forEach(property => {
2876
- if (props[property]?.color === undefined && (property.startsWith('_') || property === 'on' || property === 'media')) {
2877
- setBlend(props[property], props[property]);
2878
- }
2879
- });
2880
2856
  }
2881
- // Process base styles
2857
+ // Process base computed styles
2882
2858
  classes.push(...processStyles(computedStyles, 'base', '', getColor, {}, {}, manager));
2883
- // Collect underscore-prefixed properties (_hover, _focus, etc.)
2884
- const underscoreProps = {};
2885
- Object.keys(props).forEach(property => {
2886
- if (property.startsWith('_') && property.length > 1) {
2859
+ // SINGLE PASS over props: classify each prop into style, event, or underscore
2860
+ const propKeys = Object.keys(props);
2861
+ for (let i = 0; i < propKeys.length; i++) {
2862
+ const property = propKeys[i];
2863
+ const value = props[property];
2864
+ // Handle underscore-prefixed event properties (_hover, _focus, etc.)
2865
+ if (property.charCodeAt(0) === 95 && property.length > 1) {
2866
+ // 95 = '_'
2887
2867
  const eventName = property.substring(1);
2888
- underscoreProps[eventName] = props[property];
2868
+ classes.push(...processEventStyles(eventName, value, getColor, manager));
2869
+ // Handle blend for underscore props
2870
+ if (props.blend === true && value?.color === undefined) {
2871
+ if (props.bgColor) {
2872
+ value.mixBlendMode = 'overlay';
2873
+ value.color = 'white';
2874
+ } else {
2875
+ value.mixBlendMode = 'difference';
2876
+ value.color = 'white';
2877
+ }
2878
+ }
2879
+ continue;
2889
2880
  }
2890
- });
2891
- // Process standard style props
2892
- Object.keys(props).forEach(property => {
2893
- if (property !== 'style' && property !== 'css' && !property.startsWith('_') && (isStyleProp(property) || ['on', 'media'].includes(property))) {
2894
- const value = props[property];
2881
+ // Skip non-style props
2882
+ if (property === 'style' || property === 'css') continue;
2883
+ if (property === 'on') {
2884
+ // Process event-based styles
2895
2885
  if (typeof value === 'object' && value !== null) {
2896
- if (property === 'on') {
2897
- // Process event-based styles
2898
- Object.keys(value).forEach(event => {
2899
- classes.push(...processEventStyles(event, value[event], getColor, manager));
2900
- });
2901
- } else if (property === 'media') {
2902
- // Process media query styles
2903
- Object.keys(value).forEach(screenOrDevice => {
2904
- classes.push(...processStyles(value[screenOrDevice], 'media', screenOrDevice, getColor, mediaQueries, devices, manager));
2905
- });
2886
+ const events = Object.keys(value);
2887
+ for (let j = 0; j < events.length; j++) {
2888
+ classes.push(...processEventStyles(events[j], value[events[j]], getColor, manager));
2889
+ }
2890
+ // Handle blend for 'on' prop
2891
+ if (props.blend === true && value?.color === undefined) {
2892
+ if (props.bgColor) {
2893
+ value.mixBlendMode = 'overlay';
2894
+ value.color = 'white';
2895
+ } else {
2896
+ value.mixBlendMode = 'difference';
2897
+ value.color = 'white';
2898
+ }
2906
2899
  }
2907
- } else if (value !== undefined && value !== '') {
2908
- // Direct style property
2909
- classes.push(...(manager || utilityClassManager).getClassNames(property, value, 'base', '', getColor, []));
2910
2900
  }
2901
+ continue;
2911
2902
  }
2912
- });
2903
+ if (property === 'media') {
2904
+ // Process media query styles
2905
+ if (typeof value === 'object' && value !== null) {
2906
+ const screens = Object.keys(value);
2907
+ for (let j = 0; j < screens.length; j++) {
2908
+ classes.push(...processStyles(value[screens[j]], 'media', screens[j], getColor, mediaQueries, devices, manager));
2909
+ }
2910
+ // Handle blend for 'media' prop
2911
+ if (props.blend === true && value?.color === undefined) {
2912
+ if (props.bgColor) {
2913
+ value.mixBlendMode = 'overlay';
2914
+ value.color = 'white';
2915
+ } else {
2916
+ value.mixBlendMode = 'difference';
2917
+ value.color = 'white';
2918
+ }
2919
+ }
2920
+ }
2921
+ continue;
2922
+ }
2923
+ // Standard style props
2924
+ if (isStyleProp(property)) {
2925
+ if (value !== undefined && value !== '') {
2926
+ if (typeof value === 'object' && value !== null) {
2927
+ // Object-style props are not directly processed as base styles
2928
+ continue;
2929
+ }
2930
+ classes.push(...activeManager.getClassNames(property, value, 'base', '', getColor, []));
2931
+ }
2932
+ }
2933
+ }
2913
2934
  // Handle raw CSS - uses 'override' context for higher specificity
2914
2935
  if (props.css) {
2915
2936
  if (typeof props.css === 'object') {
2916
- // Object-style CSS gets processed with override context for higher priority
2917
- Object.assign(computedStyles, props.css);
2918
2937
  classes.push(...processStyles(props.css, 'override', '', getColor, {}, {}, manager));
2919
2938
  } else if (typeof props.css === 'string') {
2920
- // String-style CSS gets its own class in override context
2921
2939
  const uniqueClassName = ValueUtils.generateUniqueClassName(props.css);
2922
- (manager || utilityClassManager).injectRule(`.${uniqueClassName} { ${props.css} }`, 'override');
2940
+ activeManager.injectRule(`.${uniqueClassName} { ${props.css} }`, 'override');
2923
2941
  classes.push(uniqueClassName);
2924
2942
  }
2925
2943
  }
2926
- // Process underscore-prefixed event properties
2927
- if (Object.keys(underscoreProps).length > 0) {
2928
- Object.keys(underscoreProps).forEach(event => {
2929
- classes.push(...processEventStyles(event, underscoreProps[event], getColor, manager));
2930
- });
2931
- }
2932
2944
  return classes;
2933
2945
  };
2934
2946
 
@@ -2995,27 +3007,47 @@ const AnalyticsProvider = _ref => {
2995
3007
  }, children);
2996
3008
  };
2997
3009
 
3010
+ // Set of special prop names that affect CSS generation
3011
+ const styleRelevantProps = /*#__PURE__*/new Set(['on', 'media', 'animate', 'css', 'shadow', 'blend', 'widthHeight', 'paddingHorizontal', 'paddingVertical', 'marginHorizontal', 'marginVertical']);
3012
+ // Skip these props from hash computation
3013
+ const skipHashProps = /*#__PURE__*/new Set(['children', 'ref', 'key', 'style']);
3014
+ /**
3015
+ * Fast serialization of a value for hashing purposes.
3016
+ * Avoids JSON.stringify overhead for common cases (strings, numbers, booleans).
3017
+ */
3018
+ function fastSerialize(value) {
3019
+ if (value === null) return 'n';
3020
+ const t = typeof value;
3021
+ if (t === 'string') return `s${value}`;
3022
+ if (t === 'number') return `d${value}`;
3023
+ if (t === 'boolean') return value ? 'T' : 'F';
3024
+ // Fall back to JSON.stringify only for complex objects
3025
+ return JSON.stringify(value);
3026
+ }
2998
3027
  /**
2999
3028
  * Computes a stable hash of style-relevant props.
3000
- * This is used to determine if style extraction needs to be re-run.
3029
+ * Optimized: avoids sorting, uses fast serialization, feeds directly to hash.
3001
3030
  */
3002
3031
  function hashStyleProps(props) {
3003
3032
  // Build a deterministic string representation of style-relevant props
3004
- const parts = [];
3005
- const sortedKeys = Object.keys(props).sort();
3006
- for (const key of sortedKeys) {
3033
+ // We use a single string accumulator instead of array + join
3034
+ let hashInput = '';
3035
+ const keys = Object.keys(props);
3036
+ for (let i = 0; i < keys.length; i++) {
3037
+ const key = keys[i];
3007
3038
  // Skip non-style props that don't affect CSS generation
3008
- if (key === 'children' || key === 'ref' || key === 'key') continue;
3039
+ if (skipHashProps.has(key)) continue;
3009
3040
  // Include style-relevant props
3010
- if (isStyleProp(key) || key.startsWith('_') || key === 'on' || key === 'media' || key === 'animate' || key === 'css' || key === 'shadow' || key === 'blend' || key === 'widthHeight' || key === 'paddingHorizontal' || key === 'paddingVertical' || key === 'marginHorizontal' || key === 'marginVertical') {
3041
+ if (isStyleProp(key) || key.charCodeAt(0) === 95 ||
3042
+ // starts with '_'
3043
+ styleRelevantProps.has(key)) {
3011
3044
  const value = props[key];
3012
3045
  if (value !== undefined) {
3013
- // Use JSON.stringify for consistent serialization
3014
- parts.push(`${key}:${JSON.stringify(value)}`);
3046
+ hashInput += `|${key}:${fastSerialize(value)}`;
3015
3047
  }
3016
3048
  }
3017
3049
  }
3018
- return hash(parts.join('|'));
3050
+ return hash(hashInput);
3019
3051
  }
3020
3052
  /**
3021
3053
  * Custom hook that memoizes style extraction based on a stable hash of props.
@@ -3025,8 +3057,9 @@ function useStableStyleMemo(propsToProcess, getColor, mediaQueries, devices, man
3025
3057
  const cacheRef = useRef(null);
3026
3058
  // Compute hash directly — no useMemo since propsToProcess is always a new
3027
3059
  // reference (from destructuring), so the memo deps would always change.
3028
- const themeHash = theme ? JSON.stringify(theme) : '';
3029
- const currentHash = hashStyleProps(propsToProcess) + '|' + hash(themeHash);
3060
+ // Theme hash uses Object.values() concatenation instead of JSON.stringify
3061
+ const themeHash = theme ? hash(Object.values(theme).join('|')) : '';
3062
+ const currentHash = hashStyleProps(propsToProcess) + '|' + themeHash;
3030
3063
  // Only recompute classes if hash changed
3031
3064
  if (!cacheRef.current || cacheRef.current.hash !== currentHash) {
3032
3065
  const classes = extractUtilityClasses(propsToProcess, getColor, mediaQueries, devices, manager);
@@ -3203,18 +3236,24 @@ const Element = /*#__PURE__*/React.memo(/*#__PURE__*/forwardRef((_ref, ref) => {
3203
3236
  after,
3204
3237
  ...otherProps
3205
3238
  } = rest;
3206
- // First, add all event handlers (they start with "on" and have a capital letter after)
3207
- Object.keys(otherProps).forEach(key => {
3208
- if (key.startsWith('on') && key.length > 2 && key[2] === key[2].toUpperCase()) {
3239
+ // Single pass: add event handlers and non-style props together
3240
+ const otherKeys = Object.keys(otherProps);
3241
+ for (let i = 0; i < otherKeys.length; i++) {
3242
+ const key = otherKeys[i];
3243
+ // Event handlers: start with "on" + uppercase letter
3244
+ if (key.charCodeAt(0) === 111 &&
3245
+ // 'o'
3246
+ key.charCodeAt(1) === 110 &&
3247
+ // 'n'
3248
+ key.length > 2 && key.charCodeAt(2) >= 65 && key.charCodeAt(2) <= 90 // uppercase A-Z
3249
+ ) {
3209
3250
  newProps[key] = otherProps[key];
3210
3251
  }
3211
- });
3212
- // Then add all other non-style props
3213
- Object.keys(otherProps).forEach(key => {
3214
- if (!excludedKeys.has(key) && !isStyleProp(key) || includeKeys.has(key)) {
3252
+ // Non-style props (pass through to DOM)
3253
+ else if (!excludedKeys.has(key) && !isStyleProp(key) || includeKeys.has(key)) {
3215
3254
  newProps[key] = otherProps[key];
3216
3255
  }
3217
- });
3256
+ }
3218
3257
  if (style) {
3219
3258
  newProps.style = style;
3220
3259
  }
@@ -3301,11 +3340,17 @@ const Span = /*#__PURE__*/React.forwardRef((props, ref) => (/*#__PURE__*/React.c
3301
3340
  ref: ref
3302
3341
  }))));
3303
3342
 
3304
- const Image = /*#__PURE__*/React.forwardRef((props, ref) => (/*#__PURE__*/React.createElement(Element, Object.assign({
3305
- as: "img"
3306
- }, props, {
3307
- ref: ref
3308
- }))));
3343
+ const Image = /*#__PURE__*/React.forwardRef((props, ref) => {
3344
+ const imageProps = {
3345
+ ...props,
3346
+ alt: props.alt || ''
3347
+ };
3348
+ return /*#__PURE__*/React.createElement(Element, Object.assign({
3349
+ as: "img"
3350
+ }, imageProps, {
3351
+ ref: ref
3352
+ }));
3353
+ });
3309
3354
  const ImageBackground = /*#__PURE__*/React.forwardRef((_ref, ref) => {
3310
3355
  let {
3311
3356
  src,
@@ -3404,11 +3449,18 @@ const Input = /*#__PURE__*/React.forwardRef((props, ref) => (/*#__PURE__*/React.
3404
3449
  }, props, {
3405
3450
  ref: ref
3406
3451
  }))));
3407
- const Button = /*#__PURE__*/React.forwardRef((props, ref) => (/*#__PURE__*/React.createElement(Element, Object.assign({
3408
- as: "button"
3409
- }, props, {
3410
- ref: ref
3411
- }))));
3452
+ const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
3453
+ if (process.env.NODE_ENV !== 'production') {
3454
+ if (!props.children && !props['aria-label']) {
3455
+ console.warn('Accessibility Warning: Button is missing an accessible name. If it is an icon-only button, please provide an `aria-label`.');
3456
+ }
3457
+ }
3458
+ return /*#__PURE__*/React.createElement(Element, Object.assign({
3459
+ as: "button"
3460
+ }, props, {
3461
+ ref: ref
3462
+ }));
3463
+ });
3412
3464
 
3413
3465
  // animations.ts
3414
3466
  const fadeIn = function (_temp) {