app-studio 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/appstudio.cjs.development.js +112 -11
- package/dist/appstudio.cjs.development.js.map +1 -1
- package/dist/appstudio.cjs.production.min.js +1 -1
- package/dist/appstudio.cjs.production.min.js.map +1 -1
- package/dist/appstudio.esm.js +112 -11
- package/dist/appstudio.esm.js.map +1 -1
- package/dist/appstudio.umd.development.js +112 -11
- package/dist/appstudio.umd.development.js.map +1 -1
- package/dist/appstudio.umd.production.min.js +1 -1
- package/dist/appstudio.umd.production.min.js.map +1 -1
- package/package.json +1 -1
package/dist/appstudio.esm.js
CHANGED
|
@@ -763,7 +763,106 @@ const generateCssRules = (selector, styles, getColor, mediaQueries) => {
|
|
|
763
763
|
return rules;
|
|
764
764
|
};
|
|
765
765
|
// Function to apply styles to a component
|
|
766
|
-
const
|
|
766
|
+
const computeStyleProps = (props, getColor, mediaQueries, devices) => {
|
|
767
|
+
const styleProps = {};
|
|
768
|
+
const keyframesList = [];
|
|
769
|
+
// Gestion de la taille de l'élément
|
|
770
|
+
const size = props.height !== undefined && props.width !== undefined && props.height === props.width ? props.height : props.size ? props.size : null;
|
|
771
|
+
if (size) {
|
|
772
|
+
styleProps.height = styleProps.width = size;
|
|
773
|
+
}
|
|
774
|
+
// Gestion du padding et de la marge
|
|
775
|
+
if (props.paddingHorizontal) {
|
|
776
|
+
styleProps.paddingLeft = props.paddingHorizontal;
|
|
777
|
+
styleProps.paddingRight = props.paddingHorizontal;
|
|
778
|
+
}
|
|
779
|
+
if (props.marginHorizontal) {
|
|
780
|
+
styleProps.marginLeft = props.marginHorizontal;
|
|
781
|
+
styleProps.marginRight = props.marginHorizontal;
|
|
782
|
+
}
|
|
783
|
+
if (props.paddingVertical) {
|
|
784
|
+
styleProps.paddingTop = props.paddingVertical;
|
|
785
|
+
styleProps.paddingBottom = props.paddingVertical;
|
|
786
|
+
}
|
|
787
|
+
if (props.marginVertical) {
|
|
788
|
+
styleProps.marginTop = props.marginVertical;
|
|
789
|
+
styleProps.marginBottom = props.marginVertical;
|
|
790
|
+
}
|
|
791
|
+
// Application des ombres si spécifié
|
|
792
|
+
if (props.shadow) {
|
|
793
|
+
if (typeof props.shadow === 'number' || typeof props.shadow === 'boolean') {
|
|
794
|
+
const shadowValue = typeof props.shadow === 'number' && Shadows[props.shadow] !== undefined ? props.shadow : 2;
|
|
795
|
+
if (Shadows[shadowValue]) {
|
|
796
|
+
const shadowColor = Color.hex.rgb(Shadows[shadowValue].shadowColor) || [];
|
|
797
|
+
styleProps['boxShadow'] = `${Shadows[shadowValue].shadowOffset.height}px ${Shadows[shadowValue].shadowOffset.width}px ${Shadows[shadowValue].shadowRadius}px rgba(${shadowColor.join(',')},${Shadows[shadowValue].shadowOpacity})`;
|
|
798
|
+
}
|
|
799
|
+
} else {
|
|
800
|
+
const shadowColor = Color.hex.rgb(props.shadow.shadowColor) || [];
|
|
801
|
+
styleProps['boxShadow'] = `${props.shadow.shadowOffset.height}px ${props.shadow.shadowOffset.width}px ${props.shadow.shadowRadius}px rgba(${shadowColor.join(',')},${props.shadow.shadowOpacity})`;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
// Gestion des animations
|
|
805
|
+
if (props.animate) {
|
|
806
|
+
const animation = props.animate;
|
|
807
|
+
const {
|
|
808
|
+
keyframesName,
|
|
809
|
+
keyframes
|
|
810
|
+
} = generateKeyframes(animation);
|
|
811
|
+
if (keyframes) {
|
|
812
|
+
keyframesList.push(keyframes);
|
|
813
|
+
}
|
|
814
|
+
styleProps.animationName = keyframesName;
|
|
815
|
+
styleProps.animationDuration = animation.duration || '1s';
|
|
816
|
+
styleProps.animationTimingFunction = animation.timingFunction || 'ease';
|
|
817
|
+
styleProps.animationDelay = animation.delay || '0s';
|
|
818
|
+
styleProps.animationIterationCount = `${animation.iterationCount || '1'}`;
|
|
819
|
+
styleProps.animationDirection = animation.direction || 'normal';
|
|
820
|
+
styleProps.animationFillMode = animation.fillMode || 'both';
|
|
821
|
+
styleProps.animationPlayState = animation.playState || 'running';
|
|
822
|
+
}
|
|
823
|
+
Object.keys(props).forEach(property => {
|
|
824
|
+
if (property !== 'style' && (isStyleProp(property) || extraKeys.has(property))) {
|
|
825
|
+
const value = props[property];
|
|
826
|
+
if (typeof value === 'object' && value !== null) {
|
|
827
|
+
// For other nested styles, exclude 'on' and 'media'
|
|
828
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
829
|
+
const {
|
|
830
|
+
on,
|
|
831
|
+
media,
|
|
832
|
+
...nestedProps
|
|
833
|
+
} = value;
|
|
834
|
+
const nestedResult = applyStyle(nestedProps, getColor, mediaQueries, devices);
|
|
835
|
+
styleProps[property] = nestedResult.styleProps;
|
|
836
|
+
keyframesList.push(...(nestedResult.keyframes || []));
|
|
837
|
+
} else {
|
|
838
|
+
// Simple style property
|
|
839
|
+
styleProps[property] = value;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
return {
|
|
844
|
+
styleProps,
|
|
845
|
+
keyframes: keyframesList
|
|
846
|
+
};
|
|
847
|
+
};
|
|
848
|
+
// Function to apply styles to a component
|
|
849
|
+
const applyStyle = function (props, getColor, mediaQueries, devices, depth,
|
|
850
|
+
// Add a depth parameter
|
|
851
|
+
maxDepth // Set a maximum depth
|
|
852
|
+
) {
|
|
853
|
+
if (depth === void 0) {
|
|
854
|
+
depth = 0;
|
|
855
|
+
}
|
|
856
|
+
if (maxDepth === void 0) {
|
|
857
|
+
maxDepth = 10;
|
|
858
|
+
}
|
|
859
|
+
if (depth > maxDepth) {
|
|
860
|
+
console.error('Maximum recursion depth reached in applyStyle');
|
|
861
|
+
return {
|
|
862
|
+
styleProps: {},
|
|
863
|
+
keyframes: []
|
|
864
|
+
};
|
|
865
|
+
}
|
|
767
866
|
const styleProps = {};
|
|
768
867
|
const keyframesList = [];
|
|
769
868
|
// Gestion de la taille de l'élément
|
|
@@ -820,24 +919,20 @@ const applyStyle = (props, getColor, mediaQueries, devices) => {
|
|
|
820
919
|
styleProps.animationFillMode = animation.fillMode || 'both';
|
|
821
920
|
styleProps.animationPlayState = animation.playState || 'running';
|
|
822
921
|
}
|
|
823
|
-
// Traitement des propriétés de style
|
|
824
922
|
Object.keys(props).forEach(property => {
|
|
825
923
|
if (property !== 'style' && (isStyleProp(property) || extraKeys.has(property))) {
|
|
826
924
|
const value = props[property];
|
|
827
925
|
if (typeof value === 'object' && value !== null) {
|
|
828
|
-
// Pour les propriétés comme 'on', 'media'
|
|
829
926
|
if (property === 'on') {
|
|
830
|
-
// Pseudo-sélecteurs
|
|
831
927
|
for (const event in value) {
|
|
832
928
|
if (!styleProps[`&:${event}`]) {
|
|
833
929
|
styleProps[`&:${event}`] = {};
|
|
834
930
|
}
|
|
835
|
-
const nestedResult =
|
|
931
|
+
const nestedResult = computeStyleProps(value[event], getColor, mediaQueries, devices);
|
|
836
932
|
Object.assign(styleProps[`&:${event}`], nestedResult.styleProps);
|
|
837
933
|
keyframesList.push(...(nestedResult.keyframes || []));
|
|
838
934
|
}
|
|
839
935
|
} else if (property === 'media') {
|
|
840
|
-
// Media queries
|
|
841
936
|
for (const screenOrDevices in value) {
|
|
842
937
|
const mediaValue = value[screenOrDevices];
|
|
843
938
|
if (mediaQueries[screenOrDevices]) {
|
|
@@ -845,7 +940,7 @@ const applyStyle = (props, getColor, mediaQueries, devices) => {
|
|
|
845
940
|
if (!styleProps[mediaQuery]) {
|
|
846
941
|
styleProps[mediaQuery] = {};
|
|
847
942
|
}
|
|
848
|
-
const nestedResult =
|
|
943
|
+
const nestedResult = computeStyleProps(mediaValue, getColor, mediaQueries, devices);
|
|
849
944
|
Object.assign(styleProps[mediaQuery], nestedResult.styleProps);
|
|
850
945
|
keyframesList.push(...(nestedResult.keyframes || []));
|
|
851
946
|
} else if (devices[screenOrDevices]) {
|
|
@@ -856,7 +951,7 @@ const applyStyle = (props, getColor, mediaQueries, devices) => {
|
|
|
856
951
|
if (!styleProps[mediaQuery]) {
|
|
857
952
|
styleProps[mediaQuery] = {};
|
|
858
953
|
}
|
|
859
|
-
const nestedResult =
|
|
954
|
+
const nestedResult = computeStyleProps(mediaValue, getColor, mediaQueries, devices);
|
|
860
955
|
Object.assign(styleProps[mediaQuery], nestedResult.styleProps);
|
|
861
956
|
keyframesList.push(...(nestedResult.keyframes || []));
|
|
862
957
|
}
|
|
@@ -864,13 +959,19 @@ const applyStyle = (props, getColor, mediaQueries, devices) => {
|
|
|
864
959
|
}
|
|
865
960
|
}
|
|
866
961
|
} else {
|
|
867
|
-
//
|
|
868
|
-
|
|
962
|
+
// For other nested styles, exclude 'on' and 'media'
|
|
963
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
964
|
+
const {
|
|
965
|
+
on,
|
|
966
|
+
media,
|
|
967
|
+
...nestedProps
|
|
968
|
+
} = value;
|
|
969
|
+
const nestedResult = computeStyleProps(nestedProps, getColor, mediaQueries, devices);
|
|
869
970
|
styleProps[property] = nestedResult.styleProps;
|
|
870
971
|
keyframesList.push(...(nestedResult.keyframes || []));
|
|
871
972
|
}
|
|
872
973
|
} else {
|
|
873
|
-
//
|
|
974
|
+
// Simple style property
|
|
874
975
|
styleProps[property] = value;
|
|
875
976
|
}
|
|
876
977
|
}
|