app-studio 0.2.17 → 0.2.20

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.
@@ -471,6 +471,7 @@ const ThemeProvider = _ref => {
471
471
  }, children);
472
472
  };
473
473
 
474
+ // ResponsiveContext.tsx
474
475
  const defaultBreakpointsConfig = {
475
476
  xs: 0,
476
477
  sm: 340,
@@ -478,37 +479,41 @@ const defaultBreakpointsConfig = {
478
479
  lg: 1080,
479
480
  xl: 1300
480
481
  };
481
- const defaultDeviceConfig = {
482
- mobile: ['xs', 'sm'],
483
- tablet: ['md', 'lg'],
484
- desktop: ['lg', 'xl']
485
- };
482
+ // Inclure la fonction corrigée getMediaQueries ici
486
483
  const getMediaQueries = b => {
487
- const defaultKeys = Object.keys(b);
488
- const breakpointValue = defaultKeys.map(breakpoint => {
489
- const value = {
490
- breakpoint: breakpoint,
491
- min: b[breakpoint],
492
- max: 0
493
- };
494
- return value;
495
- }).sort((a, b) => a.min - b.min);
496
- breakpointValue.reduce((a, b) => {
497
- if (b) a.max = b.min;
498
- return b;
499
- });
484
+ const sortedBreakpoints = Object.keys(b).map(key => ({
485
+ breakpoint: key,
486
+ min: b[key],
487
+ max: 0
488
+ })).sort((a, b) => a.min - b.min);
489
+ // Définir les valeurs max pour chaque breakpoint sauf le dernier
490
+ for (let i = 0; i < sortedBreakpoints.length - 1; i++) {
491
+ sortedBreakpoints[i].max = sortedBreakpoints[i + 1].min - 1;
492
+ }
493
+ // Le dernier breakpoint n'a pas de max
500
494
  const query = {};
501
- breakpointValue.map(sizeScreen => {
502
- query[sizeScreen.breakpoint] = `only screen ${sizeScreen.min && sizeScreen.min >= 0 ? 'and (min-width:' + sizeScreen.min + 'px)' : ''} ${sizeScreen.max && sizeScreen.max >= 0 ? 'and (max-width:' + sizeScreen.max + 'px)' : ''}`;
495
+ sortedBreakpoints.forEach(sizeScreen => {
496
+ let mediaQuery = 'only screen';
497
+ if (sizeScreen.min !== undefined && sizeScreen.min >= 0) {
498
+ mediaQuery += ` and (min-width: ${sizeScreen.min}px)`;
499
+ }
500
+ if (sizeScreen.max !== undefined && sizeScreen.max > 0) {
501
+ mediaQuery += ` and (max-width: ${sizeScreen.max}px)`;
502
+ }
503
+ query[sizeScreen.breakpoint] = mediaQuery.trim();
503
504
  });
504
505
  return query;
505
506
  };
506
- const defaultScreenConfig = {
507
+ const defaultDeviceConfig = {
508
+ mobile: ['xs', 'sm'],
509
+ tablet: ['md', 'lg'],
510
+ desktop: ['lg', 'xl']
511
+ };
512
+ const ResponsiveContext = /*#__PURE__*/React.createContext({
507
513
  breakpoints: defaultBreakpointsConfig,
508
514
  devices: defaultDeviceConfig,
509
515
  mediaQueries: /*#__PURE__*/getMediaQueries(defaultBreakpointsConfig)
510
- };
511
- const ResponsiveContext = /*#__PURE__*/React.createContext(defaultScreenConfig);
516
+ });
512
517
  const useResponsiveContext = () => React.useContext(ResponsiveContext);
513
518
  const ResponsiveProvider = _ref => {
514
519
  let {
@@ -526,14 +531,16 @@ const ResponsiveProvider = _ref => {
526
531
  };
527
532
 
528
533
  // List of numeric properties that don't need 'px' suffix
529
- const NumberProps = /*#__PURE__*/new Set(['numberOfLines', 'fontWeight', 'timeStamp', 'flex', 'flexGrow', 'flexShrink', 'order', 'zIndex', 'aspectRatio', 'shadowOpacity', 'shadowRadius', 'scale', 'opacity', 'min', 'max', 'now']);
530
534
  // Keys to exclude when passing props to the component
531
535
  const excludedKeys = /*#__PURE__*/new Set(['on', 'shadow', 'only', 'media', 'css', 'size', 'paddingHorizontal', 'paddingVertical', 'marginHorizontal', 'marginVertical', 'animate']);
532
- // Keys to exclude when passing props to the component
533
- const extraKeys = /*#__PURE__*/new Set(['on', 'shadow', 'only', 'media', 'css']);
534
536
  const includeKeys = /*#__PURE__*/new Set(['src', 'alt', 'style', 'as']);
535
537
 
536
538
  // styleHelpers.ts
539
+ // Excluded keys imported from constants.ts
540
+ // import { excludedKeys } from './constants';
541
+ const StyleProps = ['alignContent', 'alignItems', 'alignSelf', 'alignmentBaseline', 'all', 'animation', 'animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction', 'appearance', 'backdropFilter', 'backfaceVisibility', 'background', 'backgroundAttachment', 'backgroundBlendMode', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPosition', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundRepeatX', 'backgroundRepeatY', 'backgroundSize', 'baselineShift', 'blockSize', 'border', 'borderBlockEnd', 'borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth', 'borderBlockStart', 'borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth', 'borderBottom', 'borderBottomColor', 'borderBottomLeftRadius', 'borderBottomRightRadius', 'borderBottomStyle', 'borderBottomWidth', 'borderCollapse', 'borderColor', 'borderImage', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderInlineEnd', 'borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth', 'borderInlineStart', 'borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth', 'borderLeft', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRadius', 'borderRight', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderSpacing', 'borderStyle', 'borderTop', 'borderTopColor', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderTopStyle', 'borderTopWidth', 'borderWidth', 'bottom', 'boxShadow', 'boxSizing', 'breakAfter', 'breakBefore', 'breakInside', 'bufferedRendering', 'captionSide', 'caretColor', 'clear', 'clip', 'clipPath', 'clipRule', 'color', 'colorInterpolation', 'colorInterpolationFilters', 'colorRendering', 'columnCount', 'columnFill', 'columnGap', 'columnRule', 'columnRuleColor', 'columnRuleStyle', 'columnRuleWidth', 'columnSpan', 'columnWidth', 'columns', 'contain', 'content', 'counterIncrement', 'counterReset', 'cursor', 'cx', 'cy', 'd', 'direction', 'display', 'dominantBaseline', 'emptyCells', 'fill', 'fillOpacity', 'fillRule', 'filter', 'flex', 'flexBasis', 'flexDirection', 'flexFlow', 'flexGrow', 'flexShrink', 'flexWrap', 'float', 'floodColor', 'floodOpacity', 'font', 'fontDisplay', 'fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontSize', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariationSettings', 'fontWeight', 'gap', 'grid', 'gridArea', 'gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridColumn', 'gridColumnEnd', 'gridColumnGap', 'gridColumnStart', 'gridGap', 'gridRow', 'gridRowEnd', 'gridRowGap', 'gridRowStart', 'gridTemplate', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows', 'height', 'hyphens', 'imageRendering', 'inlineSize', 'isolation', 'justifyContent', 'justifyItems', 'justifySelf', 'left', 'letterSpacing', 'lightingColor', 'lineBreak', 'lineHeight', 'listStyle', 'listStyleImage', 'listStylePosition', 'listStyleType', 'margin', 'marginBlockEnd', 'marginBlockStart', 'marginBottom', 'marginInlineEnd', 'marginInlineStart', 'marginLeft', 'marginRight', 'marginTop', 'marker', 'markerEnd', 'markerMid', 'markerStart', 'mask', 'maskType', 'maxBlockSize', 'maxHeight', 'maxInlineSize', 'maxWidth', 'maxZoom', 'minBlockSize', 'minHeight', 'minInlineSize', 'minWidth', 'minZoom', 'mixBlendMode', 'objectFit', 'objectPosition', 'offset', 'offsetDistance', 'offsetPath', 'offsetRotate', 'opacity', 'order', 'orientation', 'orphans', 'outline', 'outlineColor', 'outlineOffset', 'outlineStyle', 'outlineWidth', 'overflow', 'overflowAnchor', 'overflowWrap', 'overflowX', 'overflowY', 'overscrollBehavior', 'overscrollBehaviorBlock', 'overscrollBehaviorInline', 'overscrollBehaviorX', 'overscrollBehaviorY', 'padding', 'paddingBlockEnd', 'paddingBlockStart', 'paddingBottom', 'paddingInlineEnd', 'paddingInlineStart', 'paddingLeft', 'paddingRight', 'paddingTop', 'page', 'pageBreakAfter', 'pageBreakBefore', 'pageBreakInside', 'paintOrder', 'perspective', 'perspectiveOrigin', 'placeContent', 'placeItems', 'placeSelf', 'pointerEvents', 'position', 'quotes', 'r', 'resize', 'right', 'rowGap', 'rx', 'ry', 'scrollBehavior', 'scrollMargin', 'scrollMarginBlock', 'scrollMarginBlockEnd', 'scrollMarginBlockStart', 'scrollMarginBottom', 'scrollMarginInline', 'scrollMarginInlineEnd', 'scrollMarginInlineStart', 'scrollMarginLeft', 'scrollMarginRight', 'scrollMarginTop', 'scrollPadding', 'scrollPaddingBlock', 'scrollPaddingBlockEnd', 'scrollPaddingBlockStart', 'scrollPaddingBottom', 'scrollPaddingInline', 'scrollPaddingInlineEnd', 'scrollPaddingInlineStart', 'scrollPaddingLeft', 'scrollPaddingRight', 'scrollPaddingTop', 'scrollSnapAlign', 'scrollSnapStop', 'scrollSnapType', 'shapeImageThreshold', 'shapeMargin', 'shapeOutside', 'shapeRendering', 'size', 'speak', 'src', 'stopColor', 'stopOpacity', 'stroke', 'strokeDasharray', 'strokeDashoffset', 'strokeLinecap', 'strokeLinejoin', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'tabSize', 'tableLayout', 'textAlign', 'textAlignLast', 'textAnchor', 'textCombineUpright', 'textDecoration', 'textDecorationColor', 'textDecorationLine', 'textDecorationSkipInk', 'textDecorationStyle', 'textDecorationThickness', 'textEmphasis', 'textIndent', 'textOrientation', 'textOverflow', 'textRendering', 'textShadow', 'textSizeAdjust', 'textTransform', 'textUnderlinePosition', 'textJustify', 'top', 'touchAction', 'transform', 'transformBox', 'transformOrigin', 'transformStyle', 'transition', 'transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction', 'unicodeBidi', 'unicodeRange', 'userSelect', 'userZoom', 'vectorEffect', 'verticalAlign', 'visibility', 'wrap', 'whiteSpace', 'widows', 'width', 'willChange', 'wordBreak', 'wordSpacing', 'wordWrap', 'writingMode', 'x', 'y', 'zIndex', 'zoom', 'alwaysBounceHorizontal', 'alwaysBounceVertical', 'automaticallyAdjustContentInsets', 'bounces', 'bouncesZoom', 'canCancelContentTouches', 'centerContent', 'contentLayoutStyle', 'contentInset', 'contentInsetAdjustmentBehavior', 'contentOffset', 'decelerationRate', 'directionalLockEnabled', 'disableIntervalMomentum', 'disableScrollViewPanResponder', 'endFillColor', 'fadingEdgeLength', 'horizontal', 'indicatorStyle', 'invertStickyHeaders', 'keyboardDismissMode', 'keyboardShouldPersistTaps', 'maintainVisibleContentPosition', 'maximumZoomScale', 'minimumZoomScale', 'nestedScrollEnabled', 'onContentSizeChange', 'onMomentumScrollBegin', 'onMomentumScrollEnd', 'onScroll', 'onScrollBeginDrag', 'onScrollEndDrag', 'onScrollToTop', 'overScrollMode', 'pagingEnabled', 'persistentScrollbar', 'pinchGestureEnabled', 'refreshControl', 'removeClippedSubviews', 'scrollBarThumbImage', 'scrollEnabled', 'scrollEventThrottle', 'scrollIndicatorInsets', 'scrollPerfTag', 'scrollToOverflowEnabled', 'scrollsToTop', 'DEPRECATED_sendUpdatedChildFrames', 'showsHorizontalScrollIndicator', 'showsVerticalScrollIndicator', 'snapToAlignment', 'snapToEnd', 'snapToInterval', 'snapToOffsets', 'snapToStart', 'stickyHeaderIndices', 'zoomScale', 'borderRightColor', 'backfaceVisibility', 'borderBottomColor', 'borderBottomEndRadius', 'borderBottomLeftRadius', 'borderBottomRightRadius', 'borderBottomStartRadius', 'borderBottomWidth', 'borderColor', 'borderEndColor', 'borderLeftColor', 'borderLeftWidth', 'borderRadius', 'backgroundColor', 'borderRightWidth', 'borderStartColor', 'borderStyle', 'borderTopColor', 'borderTopEndRadius', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderTopStartRadius', 'borderTopWidth', 'borderWidth', 'border', 'opacity', 'elevation', 'shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius', 'alignContent', 'alignItems', 'alignSelf', 'aspectRatio', 'borderBottomWidth', 'borderEndWidth', 'borderLeftWidth', 'borderRightWidth', 'borderStartWidth', 'borderTopWidth', 'borderWidth', 'bottom', 'direction', 'display', 'end', 'flex', 'flexBasis', 'flexDirection', 'flexGrow', 'flexShrink', 'flexWrap', 'height', 'justifyContent', 'left', 'margin', 'marginBottom', 'marginEnd', 'marginHorizontal', 'marginLeft', 'marginRight', 'marginStart', 'marginTop', 'marginVertical', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'overflow', 'overflowX', 'overflowY', 'padding', 'paddingBottom', 'paddingEnd', 'paddingHorizontal', 'paddingLeft', 'paddingRight', 'paddingStart', 'paddingTop', 'paddingVertical', 'position', 'right', 'start', 'top', 'width', 'zIndex', 'borderTopRightRadius', 'backfaceVisibility', 'borderBottomLeftRadius', 'borderBottomRightRadius', 'borderColor', 'borderRadius', 'borderTopLeftRadius', 'backgroundColor', 'borderWidth', 'opacity', 'overflow', 'overflowX', 'overflowY', 'resizeMode', 'tintColor', 'overlayColor', 'transform', 'transformMatrix', 'rotation', 'scaleX', 'scaleY', 'translateX', 'translateY', 'perspective', 'rotate', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'skewX', 'skewY', 'testID', 'decomposedMatrix', 'gridRowStart', 'gridRowEnd', 'gridColumnStart', 'gridColumnEnd', 'lineClamp', 'writingMode', 'objectFit', 'objectPosition', 'placeItems', 'placeSelf'];
542
+ const StyledProps = /*#__PURE__*/new Set(StyleProps);
543
+ const nonStyleAttributes = /*#__PURE__*/new Set(['length', 'parentRule', 'src']);
537
544
  // Function to convert style object to CSS string
538
545
  const styleObjectToCss = styleObj => {
539
546
  return Object.entries(styleObj).map(_ref => {
@@ -549,88 +556,8 @@ const toKebabCase = str => str.replace(/([A-Z])/g, match => '-' + match.toLowerC
549
556
  // // For simplicity, we assume all props not in excludedKeys are style props
550
557
  // return !excludedKeys.has(prop);
551
558
  // };
552
- const isStyleProp = prop => {
553
- // Convert camelCase to kebab-case
554
- const kebabCase = prop.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
555
- // Check if it's a standard CSS property
556
- if (CSS.supports(kebabCase, 'initial')) {
557
- return true;
558
- }
559
- // Check for vendor prefixes
560
- const prefixes = ['-webkit-', '-moz-', '-ms-', '-o-'];
561
- for (const prefix of prefixes) {
562
- if (CSS.supports(prefix + kebabCase, 'initial')) {
563
- return true;
564
- }
565
- }
566
- // Check if it's a valid CSS custom property
567
- if (CSS.supports('--test', 'initial')) {
568
- return CSS.supports(`--${kebabCase}`, 'initial');
569
- }
570
- return false;
571
- };
572
- // Function to process and normalize style properties
573
- const processStyleProperty = (property, value, getColor) => {
574
- if (typeof value === 'number' && !NumberProps.has(property)) {
575
- return `${value}px`;
576
- } else if (property.toLowerCase().includes('color')) {
577
- return getColor(value);
578
- } else {
579
- return value;
580
- }
581
- };
582
-
583
- /* eslint-disable @typescript-eslint/no-unused-vars */
584
- let keyframesCounter = 0;
585
- const keyframesCache = /*#__PURE__*/new Map();
586
- const generateKeyframes = animation => {
587
- // Exclure les propriétés qui ne font pas partie des keyframes
588
- const {
589
- duration,
590
- timingFunction,
591
- delay,
592
- iterationCount,
593
- direction,
594
- fillMode,
595
- playState,
596
- ...keyframesDef
597
- } = animation;
598
- // Générer une clé pour le cache basée sur les keyframes
599
- const animationConfigString = JSON.stringify(keyframesDef);
600
- if (keyframesCache.has(animationConfigString)) {
601
- const keyframesName = keyframesCache.get(animationConfigString);
602
- return {
603
- keyframesName,
604
- keyframes: ''
605
- }; // Les keyframes existent déjà
606
- }
607
-
608
- const keyframesName = `animation-${keyframesCounter++}`;
609
- keyframesCache.set(animationConfigString, keyframesName);
610
- const keyframesContent = [];
611
- // Trier les clés pour assurer un ordre cohérent
612
- const keyframeKeys = Object.keys(keyframesDef).sort((a, b) => {
613
- const getPercentage = key => {
614
- if (key === 'from') return 0;
615
- if (key === 'to' || key === 'enter') return 100;
616
- return parseInt(key.replace('%', ''), 10);
617
- };
618
- return getPercentage(a) - getPercentage(b);
619
- });
620
- keyframeKeys.forEach(key => {
621
- const cssKey = key === 'enter' ? 'to' : key; // Remplacer 'enter' par 'to'
622
- const styles = keyframesDef[key];
623
- keyframesContent.push(`${cssKey} { ${styleObjectToCss(styles)} }`);
624
- });
625
- const keyframes = `
626
- @keyframes ${keyframesName} {
627
- ${keyframesContent.join('\n')}
628
- }
629
- `;
630
- return {
631
- keyframesName,
632
- keyframes
633
- };
559
+ const isStyleProp = property => {
560
+ return StyledProps.has(property) || nonStyleAttributes.has(property);
634
561
  };
635
562
 
636
563
  const Shadows = {
@@ -726,254 +653,313 @@ const Shadows = {
726
653
  }
727
654
  };
728
655
 
729
- // Element.tsx
730
- const styleSheet = /*#__PURE__*/(() => {
731
- if (typeof document !== 'undefined') {
732
- let styleTag = /*#__PURE__*/document.getElementById('dynamic-styles');
733
- if (!styleTag) {
734
- styleTag = /*#__PURE__*/document.createElement('style');
735
- styleTag.id = 'dynamic-styles';
736
- document.head.appendChild(styleTag);
737
- }
738
- return styleTag.sheet;
739
- }
740
- return null;
741
- })();
742
- /**
743
- * Fonction de hachage simple et rapide basée sur l'algorithme djb2.
744
- * @param {string} str - La chaîne de caractères à hacher.
745
- * @returns {number} - Le hachage sous forme d'entier non signé 32 bits.
746
- */
747
- const hashString = str => {
748
- let hash = 5381;
749
- for (let i = 0; i < str.length; i++) {
750
- // hash * 33 + c
751
- hash = (hash << 5) + hash + str.charCodeAt(i);
752
- // Pour éviter les dépassements, on utilise l'opérateur >>> 0
753
- hash = hash >>> 0;
754
- }
755
- return hash;
756
- };
757
- /**
758
- * Fonction pour hacher un objet en utilisant JSON.stringify et hashString.
759
- * @param {Object} obj - L'objet à hacher.
760
- * @returns {number} - Le hachage de l'objet.
761
- */
762
- const hashObject = obj => {
763
- const str = JSON.stringify(obj);
764
- return hashString(str).toString();
765
- };
766
- const classCache = /*#__PURE__*/new Map();
767
- const cssRulesCache = /*#__PURE__*/new Map();
768
- let classNameCounter = 0;
769
- const generateClassName = styleProps => {
770
- // Extract only relevant, primitive style properties
771
- // Generate a unique hash based on relevantProps
772
- const hash = hashObject(styleProps);
773
- if (classCache.has(hash)) {
774
- return classCache.get(hash);
775
- } else {
776
- const className = 'clz-' + classNameCounter++;
777
- classCache.set(hash, className);
778
- return className;
656
+ /* eslint-disable @typescript-eslint/no-unused-vars */
657
+ let keyframesCounter = 0;
658
+ const keyframesCache = /*#__PURE__*/new Map();
659
+ const generateKeyframes = animation => {
660
+ // Exclure les propriétés qui ne font pas partie des keyframes
661
+ const {
662
+ duration,
663
+ timingFunction,
664
+ delay,
665
+ iterationCount,
666
+ direction,
667
+ fillMode,
668
+ playState,
669
+ ...keyframesDef
670
+ } = animation;
671
+ // Générer une clé pour le cache basée sur les keyframes
672
+ const animationConfigString = JSON.stringify(keyframesDef);
673
+ if (keyframesCache.has(animationConfigString)) {
674
+ const keyframesName = keyframesCache.get(animationConfigString);
675
+ return {
676
+ keyframesName,
677
+ keyframes: ''
678
+ }; // Les keyframes existent déjà
779
679
  }
780
- };
781
- const useDynamicStyles = cssRules => {
782
- React.useEffect(() => {
783
- if (!styleSheet) return;
784
- cssRules.forEach(rule => {
785
- try {
786
- if (Array.from(styleSheet.cssRules).some(cssRule => cssRule.cssText === rule)) {
787
- return;
788
- }
789
- styleSheet.insertRule(rule, styleSheet.cssRules.length);
790
- } catch (error) {
791
- console.error('Error inserting CSS rule:', rule, error);
792
- }
793
- });
794
- }, [cssRules]);
795
- };
796
- const generateCssRules = (selector, styles, getColor, mediaQueries) => {
797
- const rules = [];
798
- const mainStyles = {};
799
- const nestedMediaQueries = {};
800
- Object.keys(styles).forEach(key => {
801
- const value = styles[key];
802
- if (key.startsWith('@media ')) {
803
- const mediaQuery = key;
804
- if (!nestedMediaQueries[mediaQuery]) {
805
- nestedMediaQueries[mediaQuery] = {};
806
- }
807
- Object.assign(nestedMediaQueries[mediaQuery], value);
808
- } else if (key.startsWith('&:')) {
809
- const pseudoSelector = key.slice(1);
810
- const nestedStyles = styles[key];
811
- const nestedRules = generateCssRules(`${selector}${pseudoSelector}`, nestedStyles, getColor
812
- // Ne pas passer mediaQueries ici
813
- );
814
680
 
815
- rules.push(...nestedRules);
816
- } else {
817
- mainStyles[key] = value;
818
- }
681
+ const keyframesName = `animation-${keyframesCounter++}`;
682
+ keyframesCache.set(animationConfigString, keyframesName);
683
+ const keyframesContent = [];
684
+ // Trier les clés pour assurer un ordre cohérent
685
+ const keyframeKeys = Object.keys(keyframesDef).sort((a, b) => {
686
+ const getPercentage = key => {
687
+ if (key === 'from') return 0;
688
+ if (key === 'to' || key === 'enter') return 100;
689
+ return parseInt(key.replace('%', ''), 10);
690
+ };
691
+ return getPercentage(a) - getPercentage(b);
692
+ });
693
+ keyframeKeys.forEach(key => {
694
+ const cssKey = key === 'enter' ? 'to' : key; // Remplacer 'enter' par 'to'
695
+ const styles = keyframesDef[key];
696
+ keyframesContent.push(`${cssKey} { ${styleObjectToCss(styles)} }`);
819
697
  });
820
- // Gestion des media queries
821
- // eslint-disable-next-line prefer-const
822
- let mediaBreakpoints = {};
823
- if (mediaQueries) {
824
- for (const query in mediaQueries) {
825
- const queries = mediaQueries[query].trim();
826
- mediaBreakpoints['@media ' + queries] = query;
698
+ const keyframes = `
699
+ @keyframes ${keyframesName} {
700
+ ${keyframesContent.join('\n')}
827
701
  }
828
- }
829
- if (Object.keys(mainStyles).length > 0 || Object.keys(nestedMediaQueries).length > 0) {
830
- const processedStyles = {};
831
- for (const property in mainStyles) {
832
- processedStyles[property] = processStyleProperty(property, mainStyles[property], getColor);
702
+ `;
703
+ return {
704
+ keyframesName,
705
+ keyframes
706
+ };
707
+ };
708
+
709
+ /* eslint-disable @typescript-eslint/no-unused-vars */
710
+ class UtilityClassManager {
711
+ constructor(propertyShorthand, maxCacheSize) {
712
+ if (maxCacheSize === void 0) {
713
+ maxCacheSize = 10000;
833
714
  }
834
- const cssRule = `${selector} { ${styleObjectToCss(processedStyles)} }`;
835
- rules.push(cssRule);
836
- for (let mediaQuery in nestedMediaQueries) {
837
- mediaQuery = mediaQuery.trim();
838
- const mediaStyles = nestedMediaQueries[mediaQuery];
839
- const processedMediaStyles = {};
840
- for (const property in mediaStyles) {
841
- processedMediaStyles[property] = processStyleProperty(property, mediaStyles[property], getColor);
842
- }
843
- const cssProperties = styleObjectToCss(processedMediaStyles);
844
- const mediaRule = `${mediaQuery} { ${selector} { ${cssProperties} } }`;
845
- rules.push(mediaRule);
846
- if (mediaBreakpoints[mediaQuery]) {
847
- const breakpoint = mediaBreakpoints[mediaQuery];
848
- const bpRule = `.${breakpoint} ${selector} { ${cssProperties} }`;
849
- rules.push(bpRule);
715
+ this.styleSheet = null;
716
+ this.classCache = new Map();
717
+ this.propertyShorthand = propertyShorthand;
718
+ this.maxCacheSize = maxCacheSize;
719
+ this.initStyleSheet();
720
+ }
721
+ initStyleSheet() {
722
+ if (typeof document !== 'undefined') {
723
+ let styleTag = document.getElementById('utility-classes');
724
+ if (!styleTag) {
725
+ styleTag = document.createElement('style');
726
+ styleTag.id = 'utility-classes';
727
+ document.head.appendChild(styleTag);
850
728
  }
729
+ this.styleSheet = styleTag.sheet;
851
730
  }
852
731
  }
853
- return rules;
854
- };
855
- // Function to apply styles to a component
856
- const computeStyleProps = props => {
857
- const styleProps = {};
858
- const keyframesList = [];
859
- // Gestion de la taille de l'élément
860
- const size = props.height !== undefined && props.width !== undefined && props.height === props.width ? props.height : props.size ? props.size : null;
861
- if (size) {
862
- styleProps.height = styleProps.width = size;
863
- }
864
- // Gestion du padding et de la marge
865
- if (props.paddingHorizontal) {
866
- styleProps.paddingLeft = props.paddingHorizontal;
867
- styleProps.paddingRight = props.paddingHorizontal;
868
- }
869
- if (props.marginHorizontal) {
870
- styleProps.marginLeft = props.marginHorizontal;
871
- styleProps.marginRight = props.marginHorizontal;
872
- }
873
- if (props.paddingVertical) {
874
- styleProps.paddingTop = props.paddingVertical;
875
- styleProps.paddingBottom = props.paddingVertical;
876
- }
877
- if (props.marginVertical) {
878
- styleProps.marginTop = props.marginVertical;
879
- styleProps.marginBottom = props.marginVertical;
732
+ escapeClassName(className) {
733
+ return className.replace(/:/g, '\\:');
880
734
  }
881
- // Application des ombres si spécifié
882
- if (props.shadow) {
883
- if (typeof props.shadow === 'number' || typeof props.shadow === 'boolean') {
884
- const shadowValue = typeof props.shadow === 'number' && Shadows[props.shadow] !== undefined ? props.shadow : 2;
885
- if (Shadows[shadowValue]) {
886
- const shadowColor = Color.hex.rgb(Shadows[shadowValue].shadowColor) || [];
887
- styleProps['boxShadow'] = `${Shadows[shadowValue].shadowOffset.height}px ${Shadows[shadowValue].shadowOffset.width}px ${Shadows[shadowValue].shadowRadius}px rgba(${shadowColor.join(',')},${Shadows[shadowValue].shadowOpacity})`;
735
+ injectRule(cssRule) {
736
+ if (this.styleSheet) {
737
+ try {
738
+ const existingRules = Array.from(this.styleSheet.cssRules).map(rule => rule.cssText);
739
+ if (!existingRules.includes(cssRule)) {
740
+ this.styleSheet.insertRule(cssRule, this.styleSheet.cssRules.length);
741
+ }
742
+ } catch (e) {
743
+ console.error(`Erreur lors de l'insertion de la règle CSS: "${cssRule}"`, e);
888
744
  }
889
- } else {
890
- const shadowColor = Color.hex.rgb(props.shadow.shadowColor) || [];
891
- styleProps['boxShadow'] = `${props.shadow.shadowOffset.height}px ${props.shadow.shadowOffset.width}px ${props.shadow.shadowRadius}px rgba(${shadowColor.join(',')},${props.shadow.shadowOpacity})`;
892
745
  }
893
746
  }
894
- // Gestion des animations
895
- if (props.animate) {
896
- const animation = props.animate;
897
- const {
898
- keyframesName,
899
- keyframes
900
- } = generateKeyframes(animation);
901
- if (keyframes) {
902
- keyframesList.push(keyframes);
747
+ addToCache(key, className) {
748
+ if (this.classCache.size >= this.maxCacheSize) {
749
+ const firstKey = this.classCache.keys().next().value;
750
+ this.classCache.delete(firstKey);
903
751
  }
904
- styleProps.animationName = keyframesName;
905
- styleProps.animationDuration = animation.duration || '1s';
906
- styleProps.animationTimingFunction = animation.timingFunction || 'ease';
907
- styleProps.animationDelay = animation.delay || '0s';
908
- styleProps.animationIterationCount = `${animation.iterationCount || '1'}`;
909
- styleProps.animationDirection = animation.direction || 'normal';
910
- styleProps.animationFillMode = animation.fillMode || 'both';
911
- styleProps.animationPlayState = animation.playState || 'running';
752
+ this.classCache.set(key, className);
912
753
  }
913
- Object.keys(props).forEach(property => {
914
- if (property !== 'style' && (isStyleProp(property) || extraKeys.has(property))) {
915
- // Simple style property
916
- styleProps[property] = props[property];
754
+ /**
755
+ * Génère un ou plusieurs noms de classes pour une propriété et une valeur donnée.
756
+ * @param property La propriété CSS (ex: 'padding', 'color').
757
+ * @param value La valeur de la propriété (ex: '10px', '#fff').
758
+ * @param context Le contexte de la classe ('base', 'pseudo', 'media').
759
+ * @param modifier Le modificateur pour les pseudo-classes ou media queries (ex: 'hover', 'sm').
760
+ * @param getColor Fonction pour convertir les couleurs si nécessaire.
761
+ * @param mediaQueries Un tableau de media queries associées (utilisé uniquement pour le contexte 'media').
762
+ * @returns Un tableau de noms de classes générés.
763
+ */
764
+ getClassNames(property, value, context, modifier, getColor, mediaQueries) {
765
+ if (context === void 0) {
766
+ context = 'base';
917
767
  }
918
- });
919
- return {
920
- styleProps,
921
- keyframes: keyframesList
768
+ if (modifier === void 0) {
769
+ modifier = '';
770
+ }
771
+ if (getColor === void 0) {
772
+ getColor = color => color;
773
+ }
774
+ if (mediaQueries === void 0) {
775
+ mediaQueries = [];
776
+ }
777
+ let processedValue = value;
778
+ // Si la propriété est une couleur, la convertir en valeur hexadécimale ou RGB
779
+ if (property.toLowerCase().includes('color')) {
780
+ processedValue = getColor(value);
781
+ }
782
+ let key = `${property}:${processedValue}`;
783
+ if (modifier) {
784
+ key = `${property}:${processedValue}|${modifier}`;
785
+ }
786
+ if (this.classCache.has(key)) {
787
+ return [this.classCache.get(key)];
788
+ }
789
+ // Générer un nom de classe unique avec le modificateur
790
+ let shorthand = this.propertyShorthand[property];
791
+ if (!shorthand) {
792
+ shorthand = property.replace(/([A-Z])/g, '-$1').toLowerCase();
793
+ }
794
+ // Normaliser la valeur pour le nom de classe
795
+ let normalizedValue = processedValue.toString().replace(/\./g, 'p') // Remplacer les points par 'p'
796
+ .replace(/\s+/g, '-') // Remplacer les espaces par '-'
797
+ .replace(/[^a-zA-Z0-9\-]/g, ''); // Supprimer les autres caractères spéciaux
798
+ let baseClassName = `${shorthand}-${normalizedValue}`;
799
+ // Préfixer les noms de classe pour les pseudo-classes et media queries
800
+ let classNames = [];
801
+ if (context === 'pseudo' && modifier) {
802
+ // Pseudo-class : ajouter '-modifier' suffix
803
+ const pseudoClassName = `${baseClassName}-${modifier}`;
804
+ classNames.push(pseudoClassName);
805
+ } else if (context === 'media' && modifier) {
806
+ // Media query : générer une classe pour chaque media query associée
807
+ mediaQueries.forEach(() => {
808
+ const mediaClassName = `${modifier}:${baseClassName}`;
809
+ classNames.push(mediaClassName);
810
+ });
811
+ } else {
812
+ classNames.push(baseClassName);
813
+ }
814
+ // Convertir camelCase en kebab-case
815
+ const cssProperty = property.replace(/([A-Z])/g, '-$1').toLowerCase();
816
+ let valueForCss = processedValue;
817
+ // Ajouter des unités si nécessaire
818
+ if (typeof valueForCss === 'number') {
819
+ const propertiesWithUnits = ['width', 'height', 'padding', 'margin', 'padding-left', 'padding-right', 'padding-top', 'padding-bottom', 'margin-left', 'margin-right', 'margin-top', 'margin-bottom', 'transform', 'transition'];
820
+ if (propertiesWithUnits.includes(cssProperty)) {
821
+ valueForCss = `${valueForCss}px`;
822
+ }
823
+ }
824
+ // Construire les règles CSS pour chaque classe générée
825
+ classNames.forEach(className => {
826
+ const escapedClassName = this.escapeClassName(className);
827
+ let cssRules = [];
828
+ switch (context) {
829
+ case 'base':
830
+ cssRules.push(`.${escapedClassName} { ${cssProperty}: ${valueForCss}; }`);
831
+ break;
832
+ case 'pseudo':
833
+ // Appliquer la pseudo-classe directement à la classe principale
834
+ cssRules.push(`.${escapedClassName} { ${cssProperty}: ${valueForCss}; }`);
835
+ break;
836
+ case 'media':
837
+ // Les media queries sont gérées séparément
838
+ mediaQueries.forEach(mq => {
839
+ cssRules.push(`@media ${mq} { .${escapedClassName} { ${cssProperty}: ${valueForCss}; } }`);
840
+ if (window.isResponsive === true) {
841
+ cssRules.push(`.${modifier} { .${escapedClassName} { ${cssProperty}: ${valueForCss}; } }`);
842
+ }
843
+ });
844
+ break;
845
+ default:
846
+ cssRules.push(`.${escapedClassName} { ${cssProperty}: ${valueForCss}; }`);
847
+ }
848
+ console.log({
849
+ mediaQueries,
850
+ cssRules,
851
+ modifier
852
+ });
853
+ // Injecter les règles CSS
854
+ cssRules.forEach(rule => this.injectRule(rule));
855
+ // Ajouter au cache
856
+ this.addToCache(key, className);
857
+ });
858
+ return classNames;
859
+ }
860
+ }
861
+ /**
862
+ * Mappe un événement React à une pseudo-classe CSS.
863
+ * @param event L'événement React (ex: 'hover', 'active')
864
+ * @returns La pseudo-classe CSS correspondante ou null si non supporté.
865
+ */
866
+ const mapEventToPseudo = event => {
867
+ const eventMap = {
868
+ hover: 'hover',
869
+ active: 'active',
870
+ focus: 'focus',
871
+ visited: 'visited'
922
872
  };
873
+ return eventMap[event] || null;
923
874
  };
924
- // Function to apply styles to a component
925
- const applyStyle = function (props, mediaQueries, devices, depth,
926
- // Add a depth parameter
927
- maxDepth // Set a maximum depth
928
- ) {
929
- if (depth === void 0) {
930
- depth = 0;
931
- }
932
- if (maxDepth === void 0) {
933
- maxDepth = 10;
934
- }
935
- if (depth > maxDepth) {
936
- console.error('Maximum recursion depth reached in applyStyle');
937
- return {
938
- styleProps: {},
939
- keyframes: []
940
- };
875
+ /**
876
+ * Génère des abréviations pour les propriétés CSS.
877
+ * @param styledProps Tableau des propriétés CSS à abréger.
878
+ * @returns Un objet mappant chaque propriété CSS à son abréviation.
879
+ */
880
+ function generatePropertyShorthand(styledProps) {
881
+ const propertyShorthand = {};
882
+ const usedAbbreviations = new Set();
883
+ /**
884
+ * Génère une abréviation unique pour une propriété CSS donnée.
885
+ * @param prop La propriété CSS à abréger.
886
+ * @returns L'abréviation unique générée.
887
+ */
888
+ function generateAbbreviation(prop) {
889
+ const first = prop[0].toLowerCase();
890
+ const last = prop[prop.length - 1].toLowerCase();
891
+ const middle = prop.slice(1, -1).replace(/[a-z]/g, '').toLowerCase();
892
+ let abbr = first + middle + last;
893
+ if (abbr.length < 2) {
894
+ abbr = prop.slice(0, 2).toLowerCase();
895
+ }
896
+ let i = 0;
897
+ let uniqueAbbr = abbr;
898
+ while (usedAbbreviations.has(uniqueAbbr)) {
899
+ i++;
900
+ uniqueAbbr = abbr + prop.slice(-i, prop.length).toLowerCase();
901
+ }
902
+ usedAbbreviations.add(uniqueAbbr);
903
+ return uniqueAbbr;
941
904
  }
942
- const styleProps = {};
943
- const keyframesList = [];
905
+ for (const prop of styledProps) {
906
+ propertyShorthand[prop] = generateAbbreviation(prop);
907
+ }
908
+ return propertyShorthand;
909
+ }
910
+ const propertyShorthand = /*#__PURE__*/generatePropertyShorthand(StyleProps);
911
+ const utilityClassManager = /*#__PURE__*/new UtilityClassManager(propertyShorthand);
912
+ const extractUtilityClasses = (props, getColor, mediaQueries, devices) => {
913
+ const classes = [];
914
+ // Styles calculés basés sur les props
915
+ const computedStyles = {};
944
916
  // Gestion de la taille de l'élément
945
917
  const size = props.height !== undefined && props.width !== undefined && props.height === props.width ? props.height : props.size ? props.size : null;
946
918
  if (size) {
947
- styleProps.height = styleProps.width = size;
919
+ const sizeValue = typeof size === 'number' ? `${size}px` : size;
920
+ computedStyles.width = sizeValue;
921
+ computedStyles.height = sizeValue;
948
922
  }
949
923
  // Gestion du padding et de la marge
950
924
  if (props.paddingHorizontal) {
951
- styleProps.paddingLeft = props.paddingHorizontal;
952
- styleProps.paddingRight = props.paddingHorizontal;
925
+ const paddingH = typeof props.paddingHorizontal === 'number' ? `${props.paddingHorizontal}px` : props.paddingHorizontal;
926
+ computedStyles.paddingLeft = paddingH;
927
+ computedStyles.paddingRight = paddingH;
953
928
  }
954
929
  if (props.marginHorizontal) {
955
- styleProps.marginLeft = props.marginHorizontal;
956
- styleProps.marginRight = props.marginHorizontal;
930
+ const marginH = typeof props.marginHorizontal === 'number' ? `${props.marginHorizontal}px` : props.marginHorizontal;
931
+ computedStyles.marginLeft = marginH;
932
+ computedStyles.marginRight = marginH;
957
933
  }
958
934
  if (props.paddingVertical) {
959
- styleProps.paddingTop = props.paddingVertical;
960
- styleProps.paddingBottom = props.paddingVertical;
935
+ const paddingV = typeof props.paddingVertical === 'number' ? `${props.paddingVertical}px` : props.paddingVertical;
936
+ computedStyles.paddingTop = paddingV;
937
+ computedStyles.paddingBottom = paddingV;
961
938
  }
962
939
  if (props.marginVertical) {
963
- styleProps.marginTop = props.marginVertical;
964
- styleProps.marginBottom = props.marginVertical;
940
+ const marginV = typeof props.marginVertical === 'number' ? `${props.marginVertical}px` : props.marginVertical;
941
+ computedStyles.marginTop = marginV;
942
+ computedStyles.marginBottom = marginV;
965
943
  }
966
944
  // Application des ombres si spécifié
967
945
  if (props.shadow) {
968
- if (typeof props.shadow === 'number' || typeof props.shadow === 'boolean') {
969
- const shadowValue = typeof props.shadow === 'number' && Shadows[props.shadow] !== undefined ? props.shadow : 2;
970
- if (Shadows[shadowValue]) {
971
- const shadowColor = Color.hex.rgb(Shadows[shadowValue].shadowColor) || [];
972
- styleProps['boxShadow'] = `${Shadows[shadowValue].shadowOffset.height}px ${Shadows[shadowValue].shadowOffset.width}px ${Shadows[shadowValue].shadowRadius}px rgba(${shadowColor.join(',')},${Shadows[shadowValue].shadowOpacity})`;
973
- }
946
+ let shadowValue;
947
+ if (typeof props.shadow === 'number' && Shadows[props.shadow] !== undefined) {
948
+ shadowValue = props.shadow;
949
+ } else if (typeof props.shadow === 'boolean') {
950
+ shadowValue = props.shadow ? 2 : 0;
974
951
  } else {
975
- const shadowColor = Color.hex.rgb(props.shadow.shadowColor) || [];
976
- styleProps['boxShadow'] = `${props.shadow.shadowOffset.height}px ${props.shadow.shadowOffset.width}px ${props.shadow.shadowRadius}px rgba(${shadowColor.join(',')},${props.shadow.shadowOpacity})`;
952
+ shadowValue = 2;
953
+ }
954
+ if (Shadows[shadowValue]) {
955
+ const shadowColor = Shadows[shadowValue].shadowColor;
956
+ const shadowOpacity = Shadows[shadowValue].shadowOpacity;
957
+ const shadowOffset = Shadows[shadowValue].shadowOffset;
958
+ const shadowRadius = Shadows[shadowValue].shadowRadius;
959
+ // Convertir la couleur en rgba
960
+ const rgb = Color.hex.rgb(shadowColor);
961
+ const rgbaColor = `rgba(${rgb.join(',')}, ${shadowOpacity})`;
962
+ computedStyles.boxShadow = `${shadowOffset.height}px ${shadowOffset.width}px ${shadowRadius}px ${rgbaColor}`;
977
963
  }
978
964
  }
979
965
  // Gestion des animations
@@ -983,119 +969,99 @@ maxDepth // Set a maximum depth
983
969
  keyframesName,
984
970
  keyframes
985
971
  } = generateKeyframes(animation);
986
- if (keyframes) {
987
- keyframesList.push(keyframes);
972
+ if (keyframes && typeof document !== 'undefined') {
973
+ utilityClassManager.injectRule(keyframes);
988
974
  }
989
- styleProps.animationName = keyframesName;
990
- styleProps.animationDuration = animation.duration || '1s';
991
- styleProps.animationTimingFunction = animation.timingFunction || 'ease';
992
- styleProps.animationDelay = animation.delay || '0s';
993
- styleProps.animationIterationCount = `${animation.iterationCount || '1'}`;
994
- styleProps.animationDirection = animation.direction || 'normal';
995
- styleProps.animationFillMode = animation.fillMode || 'both';
996
- styleProps.animationPlayState = animation.playState || 'running';
975
+ computedStyles.animationName = keyframesName;
976
+ if (animation.duration) computedStyles.animationDuration = animation.duration;
977
+ if (animation.timingFunction) computedStyles.animationTimingFunction = animation.timingFunction;
978
+ if (animation.delay) computedStyles.animationDelay = animation.delay;
979
+ if (animation.iterationCount !== undefined) computedStyles.animationIterationCount = `${animation.iterationCount}`;
980
+ if (animation.direction) computedStyles.animationDirection = animation.direction;
981
+ if (animation.fillMode) computedStyles.animationFillMode = animation.fillMode;
982
+ if (animation.playState) computedStyles.animationPlayState = animation.playState;
997
983
  }
984
+ /**
985
+ * Génère des classes utilitaires pour un ensemble de styles.
986
+ * @param styles Les styles à transformer en classes utilitaires.
987
+ * @param context Le contexte des styles ('base', 'pseudo', 'media').
988
+ * @param modifier Le modificateur pour les pseudo-classes ou media queries.
989
+ */
990
+ const generateUtilityClasses = function (styles, context, modifier) {
991
+ if (context === void 0) {
992
+ context = 'base';
993
+ }
994
+ if (modifier === void 0) {
995
+ modifier = '';
996
+ }
997
+ Object.keys(styles).forEach(property => {
998
+ const value = styles[property];
999
+ let mediaQueriesForClass = [];
1000
+ if (context === 'media') {
1001
+ // 'modifier' peut être un breakpoint ou un dispositif
1002
+ if (mediaQueries[modifier]) {
1003
+ mediaQueriesForClass = [mediaQueries[modifier]];
1004
+ } else if (devices[modifier]) {
1005
+ mediaQueriesForClass = devices[modifier].map(mq => mediaQueries[mq]).filter(mq => mq); // Filtrer les media queries valides
1006
+ }
1007
+ }
1008
+
1009
+ const classNames = utilityClassManager.getClassNames(property, value, context, modifier, getColor, mediaQueriesForClass);
1010
+ classes.push(...classNames);
1011
+ });
1012
+ };
1013
+ // Générer des classes utilitaires pour les styles calculés
1014
+ generateUtilityClasses(computedStyles, 'base');
1015
+ // Parcourir toutes les propriétés de style et générer des classes utilitaires
998
1016
  Object.keys(props).forEach(property => {
999
- if (property !== 'style' && (isStyleProp(property) || extraKeys.has(property))) {
1017
+ if (property !== 'style' && (isStyleProp(property) || ['on', 'media'].includes(property))) {
1000
1018
  const value = props[property];
1001
1019
  if (typeof value === 'object' && value !== null) {
1002
1020
  if (property === 'on') {
1003
- for (const event in value) {
1004
- if (!styleProps[`&:${event}`]) {
1005
- styleProps[`&:${event}`] = {};
1021
+ // Styles liés aux événements (pseudo-classes)
1022
+ Object.keys(value).forEach(event => {
1023
+ const eventStyles = value[event];
1024
+ // Séparer les propriétés de transition et les autres propriétés
1025
+ const transitionStyles = {};
1026
+ const nonTransitionStyles = {};
1027
+ Object.keys(eventStyles).forEach(prop => {
1028
+ if (prop === 'transition') {
1029
+ transitionStyles[prop] = eventStyles[prop];
1030
+ } else {
1031
+ nonTransitionStyles[prop] = eventStyles[prop];
1032
+ }
1033
+ });
1034
+ // Appliquer les transitions aux styles de base
1035
+ if (Object.keys(transitionStyles).length > 0) {
1036
+ generateUtilityClasses(transitionStyles, 'base');
1006
1037
  }
1007
- const nestedResult = computeStyleProps(value[event]);
1008
- Object.assign(styleProps[`&:${event}`], nestedResult.styleProps);
1009
- keyframesList.push(...(nestedResult.keyframes || []));
1010
- }
1011
- } else if (property === 'media') {
1012
- for (const screenOrDevices in value) {
1013
- const mediaValue = value[screenOrDevices];
1014
- if (mediaQueries[screenOrDevices]) {
1015
- const mediaQuery = '@media ' + mediaQueries[screenOrDevices];
1016
- if (!styleProps[mediaQuery]) {
1017
- styleProps[mediaQuery] = {};
1038
+ // Générer les classes pour les pseudo-classes
1039
+ if (Object.keys(nonTransitionStyles).length > 0) {
1040
+ const pseudo = mapEventToPseudo(event);
1041
+ if (pseudo) {
1042
+ generateUtilityClasses(nonTransitionStyles, 'pseudo', pseudo);
1018
1043
  }
1019
- const nestedResult = computeStyleProps(mediaValue);
1020
- Object.assign(styleProps[mediaQuery], nestedResult.styleProps);
1021
- keyframesList.push(...(nestedResult.keyframes || []));
1022
- } else if (devices[screenOrDevices]) {
1023
- const deviceScreens = devices[screenOrDevices];
1024
- deviceScreens.forEach(screen => {
1025
- if (mediaQueries[screen]) {
1026
- const mediaQuery = '@media ' + mediaQueries[screen];
1027
- if (!styleProps[mediaQuery]) {
1028
- styleProps[mediaQuery] = {};
1029
- }
1030
- const nestedResult = computeStyleProps(mediaValue);
1031
- Object.assign(styleProps[mediaQuery], nestedResult.styleProps);
1032
- keyframesList.push(...(nestedResult.keyframes || []));
1033
- }
1034
- });
1035
1044
  }
1036
- }
1037
- } else {
1038
- // For other nested styles, exclude 'on' and 'media'
1039
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1040
- const {
1041
- on,
1042
- media,
1043
- ...nestedProps
1044
- } = value;
1045
- const nestedResult = computeStyleProps(nestedProps);
1046
- styleProps[property] = nestedResult.styleProps;
1047
- keyframesList.push(...(nestedResult.keyframes || []));
1045
+ });
1046
+ } else if (property === 'media') {
1047
+ // Styles conditionnels basés sur les media queries ou devices
1048
+ Object.keys(value).forEach(screenOrDevice => {
1049
+ const mediaStyles = value[screenOrDevice];
1050
+ generateUtilityClasses(mediaStyles, 'media', screenOrDevice);
1051
+ });
1048
1052
  }
1049
1053
  } else {
1050
- // Simple style property
1051
- styleProps[property] = value;
1054
+ // Générer une classe utilitaire pour cette propriété et valeur
1055
+ const classNames = utilityClassManager.getClassNames(property, value, 'base', '', getColor);
1056
+ classes.push(...classNames);
1052
1057
  }
1053
1058
  }
1054
1059
  });
1055
- return {
1056
- styleProps,
1057
- keyframes: keyframesList
1058
- };
1060
+ return classes;
1059
1061
  };
1060
- const getStyledProps = (props, getColor, mediaQueries, devices) => {
1061
- const {
1062
- styleProps,
1063
- keyframes
1064
- } = applyStyle(props, mediaQueries, devices);
1065
- const className = generateClassName(styleProps);
1066
- let cssRules = [];
1067
- if (cssRulesCache.has(className)) {
1068
- cssRules = cssRulesCache.get(className);
1069
- } else {
1070
- cssRules = generateCssRules(`.${className}`, styleProps, getColor, mediaQueries);
1071
- if (keyframes && keyframes.length > 0) {
1072
- cssRules = keyframes.concat(cssRules);
1073
- }
1074
- cssRulesCache.set(className, cssRules);
1075
- }
1076
- const {
1077
- style,
1078
- ...restProps
1079
- } = props;
1080
- const newProps = Object.keys(restProps).reduce((acc, key) => {
1081
- if (!excludedKeys.has(key) && !isStyleProp(key) || includeKeys.has(key)) {
1082
- acc[key] = restProps[key];
1083
- }
1084
- return acc;
1085
- }, {});
1086
- if (className) {
1087
- newProps.className = className;
1088
- }
1089
- if (style) {
1090
- newProps.style = style;
1091
- }
1092
- return {
1093
- newProps,
1094
- className,
1095
- cssRules
1096
- };
1097
- };
1098
- const Element = props => {
1062
+
1063
+ /* eslint-disable @typescript-eslint/no-unused-vars */
1064
+ const Element = /*#__PURE__*/React__default.memo(props => {
1099
1065
  const {
1100
1066
  onPress,
1101
1067
  ...rest
@@ -1107,18 +1073,37 @@ const Element = props => {
1107
1073
  mediaQueries,
1108
1074
  devices
1109
1075
  } = useResponsiveContext();
1110
- const {
1111
- newProps,
1112
- cssRules
1113
- } = React.useMemo(() => getStyledProps(rest, getColor, mediaQueries, devices), [rest, getColor, mediaQueries, devices]);
1076
+ // Extraire les classes utilitaires
1077
+ const utilityClasses = React.useMemo(() => extractUtilityClasses(rest, getColor, mediaQueries, devices), [rest, getColor, mediaQueries, devices]);
1078
+ // Gérer les événements
1079
+ const newProps = {};
1114
1080
  if (onPress) {
1115
1081
  newProps.onClick = onPress;
1116
1082
  }
1117
- useDynamicStyles(cssRules);
1083
+ // Ajouter les classes utilitaires
1084
+ if (utilityClasses.length > 0) {
1085
+ newProps.className = utilityClasses.join(' ');
1086
+ }
1087
+ // Ajouter le reste des props qui ne sont pas des styles
1088
+ const {
1089
+ style,
1090
+ children,
1091
+ ...otherProps
1092
+ } = rest;
1093
+ Object.keys(otherProps).forEach(key => {
1094
+ if (!excludedKeys.has(key) && !isStyleProp(key) || includeKeys.has(key)) {
1095
+ newProps[key] = otherProps[key];
1096
+ }
1097
+ });
1098
+ // Ajouter les styles inline s'il y en a
1099
+ if (style) {
1100
+ newProps.style = style;
1101
+ }
1102
+ // Définir le composant HTML
1118
1103
  const Component = newProps.as || 'div';
1119
1104
  delete newProps.as;
1120
- return /*#__PURE__*/React__default.createElement(Component, Object.assign({}, newProps), props.children);
1121
- };
1105
+ return /*#__PURE__*/React__default.createElement(Component, Object.assign({}, newProps), children);
1106
+ });
1122
1107
 
1123
1108
  const View = /*#__PURE__*/React__default.memo(props => /*#__PURE__*/React__default.createElement(Element, Object.assign({}, props)));
1124
1109
  const Div = View;