app-studio 0.2.18 → 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,17 +531,15 @@ 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
537
539
  // Excluded keys imported from constants.ts
538
540
  // import { excludedKeys } from './constants';
539
- const StyleProps = /*#__PURE__*/new Set(['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']);
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);
540
543
  const nonStyleAttributes = /*#__PURE__*/new Set(['length', 'parentRule', 'src']);
541
544
  // Function to convert style object to CSS string
542
545
  const styleObjectToCss = styleObj => {
@@ -554,70 +557,7 @@ const toKebabCase = str => str.replace(/([A-Z])/g, match => '-' + match.toLowerC
554
557
  // return !excludedKeys.has(prop);
555
558
  // };
556
559
  const isStyleProp = property => {
557
- return StyleProps.has(property) || nonStyleAttributes.has(property);
558
- };
559
- // Function to process and normalize style properties
560
- const processStyleProperty = (property, value, getColor) => {
561
- if (typeof value === 'number' && !NumberProps.has(property)) {
562
- return `${value}px`;
563
- } else if (property.toLowerCase().includes('color')) {
564
- return getColor(value);
565
- } else {
566
- return value;
567
- }
568
- };
569
-
570
- /* eslint-disable @typescript-eslint/no-unused-vars */
571
- let keyframesCounter = 0;
572
- const keyframesCache = /*#__PURE__*/new Map();
573
- const generateKeyframes = animation => {
574
- // Exclure les propriétés qui ne font pas partie des keyframes
575
- const {
576
- duration,
577
- timingFunction,
578
- delay,
579
- iterationCount,
580
- direction,
581
- fillMode,
582
- playState,
583
- ...keyframesDef
584
- } = animation;
585
- // Générer une clé pour le cache basée sur les keyframes
586
- const animationConfigString = JSON.stringify(keyframesDef);
587
- if (keyframesCache.has(animationConfigString)) {
588
- const keyframesName = keyframesCache.get(animationConfigString);
589
- return {
590
- keyframesName,
591
- keyframes: ''
592
- }; // Les keyframes existent déjà
593
- }
594
-
595
- const keyframesName = `animation-${keyframesCounter++}`;
596
- keyframesCache.set(animationConfigString, keyframesName);
597
- const keyframesContent = [];
598
- // Trier les clés pour assurer un ordre cohérent
599
- const keyframeKeys = Object.keys(keyframesDef).sort((a, b) => {
600
- const getPercentage = key => {
601
- if (key === 'from') return 0;
602
- if (key === 'to' || key === 'enter') return 100;
603
- return parseInt(key.replace('%', ''), 10);
604
- };
605
- return getPercentage(a) - getPercentage(b);
606
- });
607
- keyframeKeys.forEach(key => {
608
- const cssKey = key === 'enter' ? 'to' : key; // Remplacer 'enter' par 'to'
609
- const styles = keyframesDef[key];
610
- keyframesContent.push(`${cssKey} { ${styleObjectToCss(styles)} }`);
611
- });
612
- const keyframes = `
613
- @keyframes ${keyframesName} {
614
- ${keyframesContent.join('\n')}
615
- }
616
- `;
617
- return {
618
- keyframesName,
619
- keyframes
620
- };
560
+ return StyledProps.has(property) || nonStyleAttributes.has(property);
621
561
  };
622
562
 
623
563
  const Shadows = {
@@ -713,254 +653,313 @@ const Shadows = {
713
653
  }
714
654
  };
715
655
 
716
- // Element.tsx
717
- const styleSheet = /*#__PURE__*/(() => {
718
- if (typeof document !== 'undefined') {
719
- let styleTag = /*#__PURE__*/document.getElementById('dynamic-styles');
720
- if (!styleTag) {
721
- styleTag = /*#__PURE__*/document.createElement('style');
722
- styleTag.id = 'dynamic-styles';
723
- document.head.appendChild(styleTag);
724
- }
725
- return styleTag.sheet;
726
- }
727
- return null;
728
- })();
729
- /**
730
- * Fonction de hachage simple et rapide basée sur l'algorithme djb2.
731
- * @param {string} str - La chaîne de caractères à hacher.
732
- * @returns {number} - Le hachage sous forme d'entier non signé 32 bits.
733
- */
734
- const hashString = str => {
735
- let hash = 5381;
736
- for (let i = 0; i < str.length; i++) {
737
- // hash * 33 + c
738
- hash = (hash << 5) + hash + str.charCodeAt(i);
739
- // Pour éviter les dépassements, on utilise l'opérateur >>> 0
740
- hash = hash >>> 0;
741
- }
742
- return hash;
743
- };
744
- /**
745
- * Fonction pour hacher un objet en utilisant JSON.stringify et hashString.
746
- * @param {Object} obj - L'objet à hacher.
747
- * @returns {number} - Le hachage de l'objet.
748
- */
749
- const hashObject = obj => {
750
- const str = JSON.stringify(obj);
751
- return hashString(str).toString();
752
- };
753
- const classCache = /*#__PURE__*/new Map();
754
- const cssRulesCache = /*#__PURE__*/new Map();
755
- let classNameCounter = 0;
756
- const generateClassName = styleProps => {
757
- // Extract only relevant, primitive style properties
758
- // Generate a unique hash based on relevantProps
759
- const hash = hashObject(styleProps);
760
- if (classCache.has(hash)) {
761
- return classCache.get(hash);
762
- } else {
763
- const className = 'clz-' + classNameCounter++;
764
- classCache.set(hash, className);
765
- 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à
766
679
  }
767
- };
768
- const useDynamicStyles = cssRules => {
769
- React.useEffect(() => {
770
- if (!styleSheet) return;
771
- cssRules.forEach(rule => {
772
- try {
773
- if (Array.from(styleSheet.cssRules).some(cssRule => cssRule.cssText === rule)) {
774
- return;
775
- }
776
- styleSheet.insertRule(rule, styleSheet.cssRules.length);
777
- } catch (error) {
778
- console.error('Error inserting CSS rule:', rule, error);
779
- }
780
- });
781
- }, [cssRules]);
782
- };
783
- const generateCssRules = (selector, styles, getColor, mediaQueries) => {
784
- const rules = [];
785
- const mainStyles = {};
786
- const nestedMediaQueries = {};
787
- Object.keys(styles).forEach(key => {
788
- const value = styles[key];
789
- if (key.startsWith('@media ')) {
790
- const mediaQuery = key;
791
- if (!nestedMediaQueries[mediaQuery]) {
792
- nestedMediaQueries[mediaQuery] = {};
793
- }
794
- Object.assign(nestedMediaQueries[mediaQuery], value);
795
- } else if (key.startsWith('&:')) {
796
- const pseudoSelector = key.slice(1);
797
- const nestedStyles = styles[key];
798
- const nestedRules = generateCssRules(`${selector}${pseudoSelector}`, nestedStyles, getColor
799
- // Ne pas passer mediaQueries ici
800
- );
801
680
 
802
- rules.push(...nestedRules);
803
- } else {
804
- mainStyles[key] = value;
805
- }
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);
806
692
  });
807
- // Gestion des media queries
808
- // eslint-disable-next-line prefer-const
809
- let mediaBreakpoints = {};
810
- if (mediaQueries) {
811
- for (const query in mediaQueries) {
812
- const queries = mediaQueries[query].trim();
813
- mediaBreakpoints['@media ' + queries] = query;
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)} }`);
697
+ });
698
+ const keyframes = `
699
+ @keyframes ${keyframesName} {
700
+ ${keyframesContent.join('\n')}
814
701
  }
815
- }
816
- if (Object.keys(mainStyles).length > 0 || Object.keys(nestedMediaQueries).length > 0) {
817
- const processedStyles = {};
818
- for (const property in mainStyles) {
819
- 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;
820
714
  }
821
- const cssRule = `${selector} { ${styleObjectToCss(processedStyles)} }`;
822
- rules.push(cssRule);
823
- for (let mediaQuery in nestedMediaQueries) {
824
- mediaQuery = mediaQuery.trim();
825
- const mediaStyles = nestedMediaQueries[mediaQuery];
826
- const processedMediaStyles = {};
827
- for (const property in mediaStyles) {
828
- processedMediaStyles[property] = processStyleProperty(property, mediaStyles[property], getColor);
829
- }
830
- const cssProperties = styleObjectToCss(processedMediaStyles);
831
- const mediaRule = `${mediaQuery} { ${selector} { ${cssProperties} } }`;
832
- rules.push(mediaRule);
833
- if (mediaBreakpoints[mediaQuery]) {
834
- const breakpoint = mediaBreakpoints[mediaQuery];
835
- const bpRule = `.${breakpoint} ${selector} { ${cssProperties} }`;
836
- 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);
837
728
  }
729
+ this.styleSheet = styleTag.sheet;
838
730
  }
839
731
  }
840
- return rules;
841
- };
842
- // Function to apply styles to a component
843
- const computeStyleProps = props => {
844
- const styleProps = {};
845
- const keyframesList = [];
846
- // Gestion de la taille de l'élément
847
- const size = props.height !== undefined && props.width !== undefined && props.height === props.width ? props.height : props.size ? props.size : null;
848
- if (size) {
849
- styleProps.height = styleProps.width = size;
850
- }
851
- // Gestion du padding et de la marge
852
- if (props.paddingHorizontal) {
853
- styleProps.paddingLeft = props.paddingHorizontal;
854
- styleProps.paddingRight = props.paddingHorizontal;
732
+ escapeClassName(className) {
733
+ return className.replace(/:/g, '\\:');
855
734
  }
856
- if (props.marginHorizontal) {
857
- styleProps.marginLeft = props.marginHorizontal;
858
- styleProps.marginRight = props.marginHorizontal;
859
- }
860
- if (props.paddingVertical) {
861
- styleProps.paddingTop = props.paddingVertical;
862
- styleProps.paddingBottom = props.paddingVertical;
863
- }
864
- if (props.marginVertical) {
865
- styleProps.marginTop = props.marginVertical;
866
- styleProps.marginBottom = props.marginVertical;
867
- }
868
- // Application des ombres si spécifié
869
- if (props.shadow) {
870
- if (typeof props.shadow === 'number' || typeof props.shadow === 'boolean') {
871
- const shadowValue = typeof props.shadow === 'number' && Shadows[props.shadow] !== undefined ? props.shadow : 2;
872
- if (Shadows[shadowValue]) {
873
- const shadowColor = Color.hex.rgb(Shadows[shadowValue].shadowColor) || [];
874
- 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);
875
744
  }
876
- } else {
877
- const shadowColor = Color.hex.rgb(props.shadow.shadowColor) || [];
878
- styleProps['boxShadow'] = `${props.shadow.shadowOffset.height}px ${props.shadow.shadowOffset.width}px ${props.shadow.shadowRadius}px rgba(${shadowColor.join(',')},${props.shadow.shadowOpacity})`;
879
745
  }
880
746
  }
881
- // Gestion des animations
882
- if (props.animate) {
883
- const animation = props.animate;
884
- const {
885
- keyframesName,
886
- keyframes
887
- } = generateKeyframes(animation);
888
- if (keyframes) {
889
- 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);
890
751
  }
891
- styleProps.animationName = keyframesName;
892
- styleProps.animationDuration = animation.duration || '1s';
893
- styleProps.animationTimingFunction = animation.timingFunction || 'ease';
894
- styleProps.animationDelay = animation.delay || '0s';
895
- styleProps.animationIterationCount = `${animation.iterationCount || '1'}`;
896
- styleProps.animationDirection = animation.direction || 'normal';
897
- styleProps.animationFillMode = animation.fillMode || 'both';
898
- styleProps.animationPlayState = animation.playState || 'running';
752
+ this.classCache.set(key, className);
899
753
  }
900
- Object.keys(props).forEach(property => {
901
- if (property !== 'style' && (isStyleProp(property) || extraKeys.has(property))) {
902
- // Simple style property
903
- 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';
904
767
  }
905
- });
906
- return {
907
- styleProps,
908
- 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'
909
872
  };
873
+ return eventMap[event] || null;
910
874
  };
911
- // Function to apply styles to a component
912
- const applyStyle = function (props, mediaQueries, devices, depth,
913
- // Add a depth parameter
914
- maxDepth // Set a maximum depth
915
- ) {
916
- if (depth === void 0) {
917
- depth = 0;
918
- }
919
- if (maxDepth === void 0) {
920
- maxDepth = 10;
921
- }
922
- if (depth > maxDepth) {
923
- console.error('Maximum recursion depth reached in applyStyle');
924
- return {
925
- styleProps: {},
926
- keyframes: []
927
- };
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;
904
+ }
905
+ for (const prop of styledProps) {
906
+ propertyShorthand[prop] = generateAbbreviation(prop);
928
907
  }
929
- const styleProps = {};
930
- const keyframesList = [];
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 = {};
931
916
  // Gestion de la taille de l'élément
932
917
  const size = props.height !== undefined && props.width !== undefined && props.height === props.width ? props.height : props.size ? props.size : null;
933
918
  if (size) {
934
- styleProps.height = styleProps.width = size;
919
+ const sizeValue = typeof size === 'number' ? `${size}px` : size;
920
+ computedStyles.width = sizeValue;
921
+ computedStyles.height = sizeValue;
935
922
  }
936
923
  // Gestion du padding et de la marge
937
924
  if (props.paddingHorizontal) {
938
- styleProps.paddingLeft = props.paddingHorizontal;
939
- styleProps.paddingRight = props.paddingHorizontal;
925
+ const paddingH = typeof props.paddingHorizontal === 'number' ? `${props.paddingHorizontal}px` : props.paddingHorizontal;
926
+ computedStyles.paddingLeft = paddingH;
927
+ computedStyles.paddingRight = paddingH;
940
928
  }
941
929
  if (props.marginHorizontal) {
942
- styleProps.marginLeft = props.marginHorizontal;
943
- styleProps.marginRight = props.marginHorizontal;
930
+ const marginH = typeof props.marginHorizontal === 'number' ? `${props.marginHorizontal}px` : props.marginHorizontal;
931
+ computedStyles.marginLeft = marginH;
932
+ computedStyles.marginRight = marginH;
944
933
  }
945
934
  if (props.paddingVertical) {
946
- styleProps.paddingTop = props.paddingVertical;
947
- styleProps.paddingBottom = props.paddingVertical;
935
+ const paddingV = typeof props.paddingVertical === 'number' ? `${props.paddingVertical}px` : props.paddingVertical;
936
+ computedStyles.paddingTop = paddingV;
937
+ computedStyles.paddingBottom = paddingV;
948
938
  }
949
939
  if (props.marginVertical) {
950
- styleProps.marginTop = props.marginVertical;
951
- styleProps.marginBottom = props.marginVertical;
940
+ const marginV = typeof props.marginVertical === 'number' ? `${props.marginVertical}px` : props.marginVertical;
941
+ computedStyles.marginTop = marginV;
942
+ computedStyles.marginBottom = marginV;
952
943
  }
953
944
  // Application des ombres si spécifié
954
945
  if (props.shadow) {
955
- if (typeof props.shadow === 'number' || typeof props.shadow === 'boolean') {
956
- const shadowValue = typeof props.shadow === 'number' && Shadows[props.shadow] !== undefined ? props.shadow : 2;
957
- if (Shadows[shadowValue]) {
958
- const shadowColor = Color.hex.rgb(Shadows[shadowValue].shadowColor) || [];
959
- styleProps['boxShadow'] = `${Shadows[shadowValue].shadowOffset.height}px ${Shadows[shadowValue].shadowOffset.width}px ${Shadows[shadowValue].shadowRadius}px rgba(${shadowColor.join(',')},${Shadows[shadowValue].shadowOpacity})`;
960
- }
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;
961
951
  } else {
962
- const shadowColor = Color.hex.rgb(props.shadow.shadowColor) || [];
963
- 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}`;
964
963
  }
965
964
  }
966
965
  // Gestion des animations
@@ -970,119 +969,99 @@ maxDepth // Set a maximum depth
970
969
  keyframesName,
971
970
  keyframes
972
971
  } = generateKeyframes(animation);
973
- if (keyframes) {
974
- keyframesList.push(keyframes);
972
+ if (keyframes && typeof document !== 'undefined') {
973
+ utilityClassManager.injectRule(keyframes);
975
974
  }
976
- styleProps.animationName = keyframesName;
977
- styleProps.animationDuration = animation.duration || '1s';
978
- styleProps.animationTimingFunction = animation.timingFunction || 'ease';
979
- styleProps.animationDelay = animation.delay || '0s';
980
- styleProps.animationIterationCount = `${animation.iterationCount || '1'}`;
981
- styleProps.animationDirection = animation.direction || 'normal';
982
- styleProps.animationFillMode = animation.fillMode || 'both';
983
- 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;
984
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
985
1016
  Object.keys(props).forEach(property => {
986
- if (property !== 'style' && (isStyleProp(property) || extraKeys.has(property))) {
1017
+ if (property !== 'style' && (isStyleProp(property) || ['on', 'media'].includes(property))) {
987
1018
  const value = props[property];
988
1019
  if (typeof value === 'object' && value !== null) {
989
1020
  if (property === 'on') {
990
- for (const event in value) {
991
- if (!styleProps[`&:${event}`]) {
992
- 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');
993
1037
  }
994
- const nestedResult = computeStyleProps(value[event]);
995
- Object.assign(styleProps[`&:${event}`], nestedResult.styleProps);
996
- keyframesList.push(...(nestedResult.keyframes || []));
997
- }
998
- } else if (property === 'media') {
999
- for (const screenOrDevices in value) {
1000
- const mediaValue = value[screenOrDevices];
1001
- if (mediaQueries[screenOrDevices]) {
1002
- const mediaQuery = '@media ' + mediaQueries[screenOrDevices];
1003
- if (!styleProps[mediaQuery]) {
1004
- 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);
1005
1043
  }
1006
- const nestedResult = computeStyleProps(mediaValue);
1007
- Object.assign(styleProps[mediaQuery], nestedResult.styleProps);
1008
- keyframesList.push(...(nestedResult.keyframes || []));
1009
- } else if (devices[screenOrDevices]) {
1010
- const deviceScreens = devices[screenOrDevices];
1011
- deviceScreens.forEach(screen => {
1012
- if (mediaQueries[screen]) {
1013
- const mediaQuery = '@media ' + mediaQueries[screen];
1014
- if (!styleProps[mediaQuery]) {
1015
- styleProps[mediaQuery] = {};
1016
- }
1017
- const nestedResult = computeStyleProps(mediaValue);
1018
- Object.assign(styleProps[mediaQuery], nestedResult.styleProps);
1019
- keyframesList.push(...(nestedResult.keyframes || []));
1020
- }
1021
- });
1022
1044
  }
1023
- }
1024
- } else {
1025
- // For other nested styles, exclude 'on' and 'media'
1026
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1027
- const {
1028
- on,
1029
- media,
1030
- ...nestedProps
1031
- } = value;
1032
- const nestedResult = computeStyleProps(nestedProps);
1033
- styleProps[property] = nestedResult.styleProps;
1034
- 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
+ });
1035
1052
  }
1036
1053
  } else {
1037
- // Simple style property
1038
- 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);
1039
1057
  }
1040
1058
  }
1041
1059
  });
1042
- return {
1043
- styleProps,
1044
- keyframes: keyframesList
1045
- };
1060
+ return classes;
1046
1061
  };
1047
- const getStyledProps = (props, getColor, mediaQueries, devices) => {
1048
- const {
1049
- styleProps,
1050
- keyframes
1051
- } = applyStyle(props, mediaQueries, devices);
1052
- const className = generateClassName(styleProps);
1053
- let cssRules = [];
1054
- if (cssRulesCache.has(className)) {
1055
- cssRules = cssRulesCache.get(className);
1056
- } else {
1057
- cssRules = generateCssRules(`.${className}`, styleProps, getColor, mediaQueries);
1058
- if (keyframes && keyframes.length > 0) {
1059
- cssRules = keyframes.concat(cssRules);
1060
- }
1061
- cssRulesCache.set(className, cssRules);
1062
- }
1063
- const {
1064
- style,
1065
- ...restProps
1066
- } = props;
1067
- const newProps = Object.keys(restProps).reduce((acc, key) => {
1068
- if (!excludedKeys.has(key) && !isStyleProp(key) || includeKeys.has(key)) {
1069
- acc[key] = restProps[key];
1070
- }
1071
- return acc;
1072
- }, {});
1073
- if (className) {
1074
- newProps.className = className;
1075
- }
1076
- if (style) {
1077
- newProps.style = style;
1078
- }
1079
- return {
1080
- newProps,
1081
- className,
1082
- cssRules
1083
- };
1084
- };
1085
- const Element = props => {
1062
+
1063
+ /* eslint-disable @typescript-eslint/no-unused-vars */
1064
+ const Element = /*#__PURE__*/React__default.memo(props => {
1086
1065
  const {
1087
1066
  onPress,
1088
1067
  ...rest
@@ -1094,18 +1073,37 @@ const Element = props => {
1094
1073
  mediaQueries,
1095
1074
  devices
1096
1075
  } = useResponsiveContext();
1097
- const {
1098
- newProps,
1099
- cssRules
1100
- } = 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 = {};
1101
1080
  if (onPress) {
1102
1081
  newProps.onClick = onPress;
1103
1082
  }
1104
- 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
1105
1103
  const Component = newProps.as || 'div';
1106
1104
  delete newProps.as;
1107
- return /*#__PURE__*/React__default.createElement(Component, Object.assign({}, newProps), props.children);
1108
- };
1105
+ return /*#__PURE__*/React__default.createElement(Component, Object.assign({}, newProps), children);
1106
+ });
1109
1107
 
1110
1108
  const View = /*#__PURE__*/React__default.memo(props => /*#__PURE__*/React__default.createElement(Element, Object.assign({}, props)));
1111
1109
  const Div = View;