app-studio 0.5.21 → 0.5.28
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/animation/css.d.ts +9 -14
- package/dist/app-studio.cjs.development.js +430 -51
- package/dist/app-studio.cjs.development.js.map +1 -1
- package/dist/app-studio.cjs.production.min.js +1 -1
- package/dist/app-studio.esm.js +416 -53
- package/dist/app-studio.esm.js.map +1 -1
- package/dist/app-studio.umd.development.js +430 -51
- package/dist/app-studio.umd.development.js.map +1 -1
- package/dist/app-studio.umd.production.min.js +1 -1
- package/dist/components/View.d.ts +4 -0
- package/dist/hooks/useActive.d.ts +2 -0
- package/dist/hooks/useClickOutside.d.ts +2 -0
- package/dist/hooks/useFocus.d.ts +2 -0
- package/dist/hooks/useHover.d.ts +2 -0
- package/dist/hooks/useKeyPress.d.ts +1 -0
- package/dist/hooks/useOnScreen.d.ts +2 -0
- package/dist/hooks/useScroll.d.ts +1 -1
- package/dist/hooks/useWindowSize.d.ts +4 -0
- package/dist/index.d.ts +8 -1
- package/package.json +1 -1
|
@@ -742,33 +742,79 @@
|
|
|
742
742
|
if (maxCacheSize === void 0) {
|
|
743
743
|
maxCacheSize = 10000;
|
|
744
744
|
}
|
|
745
|
-
this.
|
|
745
|
+
this.baseStyleSheet = null;
|
|
746
|
+
this.mediaStyleSheet = null;
|
|
747
|
+
this.modifierStyleSheet = null;
|
|
746
748
|
this.classCache = new Map();
|
|
749
|
+
this.injectedRulesBase = new Set();
|
|
750
|
+
this.injectedRulesMedia = new Set();
|
|
751
|
+
this.injectedRulesModifier = new Set();
|
|
747
752
|
this.propertyShorthand = propertyShorthand;
|
|
748
753
|
this.maxCacheSize = maxCacheSize;
|
|
749
|
-
this.
|
|
754
|
+
this.initStyleSheets();
|
|
750
755
|
}
|
|
751
|
-
|
|
756
|
+
initStyleSheets() {
|
|
752
757
|
if (typeof document !== 'undefined') {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
+
// Feuille de style de base
|
|
759
|
+
let baseStyleTag = document.getElementById('utility-classes-base');
|
|
760
|
+
if (!baseStyleTag) {
|
|
761
|
+
baseStyleTag = document.createElement('style');
|
|
762
|
+
baseStyleTag.id = 'utility-classes-base';
|
|
763
|
+
document.head.appendChild(baseStyleTag);
|
|
758
764
|
}
|
|
759
|
-
this.
|
|
765
|
+
this.baseStyleSheet = baseStyleTag.sheet;
|
|
766
|
+
// Feuille de style pour les media queries
|
|
767
|
+
let mediaStyleTag = document.getElementById('utility-classes-media');
|
|
768
|
+
if (!mediaStyleTag) {
|
|
769
|
+
mediaStyleTag = document.createElement('style');
|
|
770
|
+
mediaStyleTag.id = 'utility-classes-media';
|
|
771
|
+
document.head.appendChild(mediaStyleTag);
|
|
772
|
+
}
|
|
773
|
+
this.mediaStyleSheet = mediaStyleTag.sheet;
|
|
774
|
+
// Feuille de style pour les modificateurs
|
|
775
|
+
let modifierStyleTag = document.getElementById('utility-classes-modifier');
|
|
776
|
+
if (!modifierStyleTag) {
|
|
777
|
+
modifierStyleTag = document.createElement('style');
|
|
778
|
+
modifierStyleTag.id = 'utility-classes-modifier';
|
|
779
|
+
document.head.appendChild(modifierStyleTag);
|
|
780
|
+
}
|
|
781
|
+
this.modifierStyleSheet = modifierStyleTag.sheet;
|
|
760
782
|
}
|
|
761
783
|
}
|
|
762
784
|
escapeClassName(className) {
|
|
763
785
|
return className.replace(/:/g, '\\:');
|
|
764
786
|
}
|
|
765
|
-
injectRule(cssRule) {
|
|
766
|
-
if (
|
|
787
|
+
injectRule(cssRule, context) {
|
|
788
|
+
if (context === void 0) {
|
|
789
|
+
context = 'base';
|
|
790
|
+
}
|
|
791
|
+
let styleSheet = null;
|
|
792
|
+
let injectedRules = new Set();
|
|
793
|
+
switch (context) {
|
|
794
|
+
case 'base':
|
|
795
|
+
styleSheet = this.baseStyleSheet;
|
|
796
|
+
injectedRules = this.injectedRulesBase;
|
|
797
|
+
break;
|
|
798
|
+
case 'pseudo':
|
|
799
|
+
styleSheet = this.baseStyleSheet; // Si les pseudo-classes sont dans la feuille de base
|
|
800
|
+
injectedRules = this.injectedRulesBase;
|
|
801
|
+
break;
|
|
802
|
+
case 'media':
|
|
803
|
+
styleSheet = this.mediaStyleSheet;
|
|
804
|
+
injectedRules = this.injectedRulesMedia;
|
|
805
|
+
break;
|
|
806
|
+
case 'modifier':
|
|
807
|
+
styleSheet = this.modifierStyleSheet;
|
|
808
|
+
injectedRules = this.injectedRulesModifier;
|
|
809
|
+
break;
|
|
810
|
+
default:
|
|
811
|
+
styleSheet = this.baseStyleSheet;
|
|
812
|
+
injectedRules = this.injectedRulesBase;
|
|
813
|
+
}
|
|
814
|
+
if (styleSheet && !injectedRules.has(cssRule)) {
|
|
767
815
|
try {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
this.styleSheet.insertRule(cssRule, this.styleSheet.cssRules.length);
|
|
771
|
-
}
|
|
816
|
+
styleSheet.insertRule(cssRule, styleSheet.cssRules.length);
|
|
817
|
+
injectedRules.add(cssRule);
|
|
772
818
|
} catch (e) {
|
|
773
819
|
console.error(`Erreur lors de l'insertion de la règle CSS: "${cssRule}"`, e);
|
|
774
820
|
}
|
|
@@ -781,16 +827,6 @@
|
|
|
781
827
|
}
|
|
782
828
|
this.classCache.set(key, className);
|
|
783
829
|
}
|
|
784
|
-
/**
|
|
785
|
-
* Génère un ou plusieurs noms de classes pour une propriété et une valeur donnée.
|
|
786
|
-
* @param property La propriété CSS (ex: 'padding', 'color').
|
|
787
|
-
* @param value La valeur de la propriété (ex: '10px', '#fff').
|
|
788
|
-
* @param context Le contexte de la classe ('base', 'pseudo', 'media').
|
|
789
|
-
* @param modifier Le modificateur pour les pseudo-classes ou media queries (ex: 'hover', 'sm').
|
|
790
|
-
* @param getColor Fonction pour convertir les couleurs si nécessaire.
|
|
791
|
-
* @param mediaQueries Un tableau de media queries associées (utilisé uniquement pour le contexte 'media').
|
|
792
|
-
* @returns Un tableau de noms de classes générés.
|
|
793
|
-
*/
|
|
794
830
|
getClassNames(property, value, context, modifier, getColor, mediaQueries) {
|
|
795
831
|
if (context === void 0) {
|
|
796
832
|
context = 'base';
|
|
@@ -805,13 +841,12 @@
|
|
|
805
841
|
mediaQueries = [];
|
|
806
842
|
}
|
|
807
843
|
let processedValue = value;
|
|
808
|
-
//
|
|
844
|
+
// Si la propriété est une couleur, la convertir
|
|
809
845
|
if (property.toLowerCase().includes('color')) {
|
|
810
846
|
processedValue = getColor(value);
|
|
811
847
|
}
|
|
812
|
-
//
|
|
848
|
+
// Gérer les valeurs numériques
|
|
813
849
|
if (typeof processedValue === 'number') {
|
|
814
|
-
// Add 'px' to numeric values for properties that typically use length units
|
|
815
850
|
if (numericCssProperties.has(property)) {
|
|
816
851
|
processedValue = `${processedValue}px`;
|
|
817
852
|
}
|
|
@@ -829,42 +864,27 @@
|
|
|
829
864
|
if (!shorthand) {
|
|
830
865
|
shorthand = property.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
831
866
|
}
|
|
832
|
-
|
|
833
|
-
// Normaliser la valeur pour le nom de classe
|
|
834
|
-
let normalizedValue = formattedValue.toString().replace(/\./g, 'p') // Replace dots with 'p'
|
|
835
|
-
.replace(/\s+/g, '-') // Replace spaces with '-'
|
|
836
|
-
.replace(/[^a-zA-Z0-9\-]/g, '') // Remove other special characters
|
|
837
|
-
.replace(/%/g, 'pct') // Replace % with 'pct'
|
|
838
|
-
.replace(/vw/g, 'vw') // Keep 'vw' as is
|
|
839
|
-
.replace(/vh/g, 'vh') // Keep 'vh' as is
|
|
840
|
-
.replace(/em/g, 'em') // Keep 'em' as is
|
|
841
|
-
.replace(/rem/g, 'rem'); // Keep 'rem' as is
|
|
867
|
+
let normalizedValue = formattedValue.toString().replace(/\./g, 'p').replace(/\s+/g, '-').replace(/[^a-zA-Z0-9\-]/g, '').replace(/%/g, 'pct').replace(/vw/g, 'vw').replace(/vh/g, 'vh').replace(/em/g, 'em').replace(/rem/g, 'rem');
|
|
842
868
|
let baseClassName = `${shorthand}-${normalizedValue}`;
|
|
843
|
-
|
|
844
|
-
let classNames = [baseClassName]; // Utiliser le nom de classe de base
|
|
869
|
+
let classNames = [baseClassName];
|
|
845
870
|
if (context === 'pseudo' && modifier) {
|
|
846
|
-
|
|
847
|
-
const pseudoClassName = `${baseClassName}-${modifier}`;
|
|
871
|
+
const pseudoClassName = `${baseClassName}--${modifier}`;
|
|
848
872
|
classNames.push(pseudoClassName);
|
|
849
873
|
} else if (context === 'media' && modifier) {
|
|
850
|
-
// Media query : générer une classe pour chaque media query associée
|
|
851
874
|
mediaQueries.forEach(() => {
|
|
852
|
-
const mediaClassName = `${modifier}
|
|
875
|
+
const mediaClassName = `${modifier}--${baseClassName}`;
|
|
853
876
|
classNames.push(mediaClassName);
|
|
854
877
|
});
|
|
855
878
|
} else {
|
|
856
879
|
classNames.push(baseClassName);
|
|
857
880
|
}
|
|
858
|
-
// Convertir camelCase en kebab-case
|
|
859
881
|
const cssProperty = property.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
860
882
|
let valueForCss = processedValue;
|
|
861
|
-
// Ajouter des unités si nécessaire
|
|
862
883
|
if (typeof valueForCss === 'number') {
|
|
863
884
|
if (numericCssProperties.has(cssProperty)) {
|
|
864
885
|
valueForCss = `${valueForCss}px`;
|
|
865
886
|
}
|
|
866
887
|
}
|
|
867
|
-
// Construire les règles CSS pour chaque classe générée
|
|
868
888
|
classNames.forEach(className => {
|
|
869
889
|
const escapedClassName = this.escapeClassName(className);
|
|
870
890
|
let cssRules = [];
|
|
@@ -873,11 +893,9 @@
|
|
|
873
893
|
cssRules.push(`.${escapedClassName} { ${cssProperty}: ${valueForCss}; }`);
|
|
874
894
|
break;
|
|
875
895
|
case 'pseudo':
|
|
876
|
-
// Appliquer le pseudo-sélecteur au sélecteur de classe
|
|
877
896
|
cssRules.push(`.${escapedClassName}:${modifier} { ${cssProperty}: ${valueForCss}; }`);
|
|
878
897
|
break;
|
|
879
898
|
case 'media':
|
|
880
|
-
// Les media queries sont gérées séparément
|
|
881
899
|
mediaQueries.forEach(mq => {
|
|
882
900
|
cssRules.push(`@media ${mq} { .${escapedClassName} { ${cssProperty}: ${valueForCss}; } }`);
|
|
883
901
|
if (window.isResponsive === true) {
|
|
@@ -888,8 +906,12 @@
|
|
|
888
906
|
default:
|
|
889
907
|
cssRules.push(`.${escapedClassName} { ${cssProperty}: ${valueForCss}; }`);
|
|
890
908
|
}
|
|
891
|
-
//
|
|
892
|
-
|
|
909
|
+
// Déterminer si la classe est un modificateur
|
|
910
|
+
const isModifier = className.includes('--');
|
|
911
|
+
// Définir le contexte approprié
|
|
912
|
+
const ruleContext = isModifier ? 'modifier' : context;
|
|
913
|
+
// Injecter les règles CSS avec le contexte approprié
|
|
914
|
+
cssRules.forEach(rule => this.injectRule(rule, ruleContext));
|
|
893
915
|
// Ajouter au cache
|
|
894
916
|
this.addToCache(key, className);
|
|
895
917
|
});
|
|
@@ -1239,6 +1261,52 @@
|
|
|
1239
1261
|
const View = /*#__PURE__*/React__default.forwardRef((props, ref) => /*#__PURE__*/React__default.createElement(Element, Object.assign({}, props, {
|
|
1240
1262
|
ref: ref
|
|
1241
1263
|
})));
|
|
1264
|
+
const Horizontal = /*#__PURE__*/React__default.forwardRef((props, ref) => /*#__PURE__*/React__default.createElement(Element, Object.assign({
|
|
1265
|
+
display: "flex",
|
|
1266
|
+
flexDirection: "row"
|
|
1267
|
+
}, props, {
|
|
1268
|
+
ref: ref
|
|
1269
|
+
})));
|
|
1270
|
+
const Vertical = /*#__PURE__*/React__default.forwardRef((props, ref) => /*#__PURE__*/React__default.createElement(Element, Object.assign({
|
|
1271
|
+
display: "flex",
|
|
1272
|
+
flexDirection: "column"
|
|
1273
|
+
}, props, {
|
|
1274
|
+
ref: ref
|
|
1275
|
+
})));
|
|
1276
|
+
const HorizontalResponsive = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
1277
|
+
let {
|
|
1278
|
+
media = {},
|
|
1279
|
+
...props
|
|
1280
|
+
} = _ref;
|
|
1281
|
+
return /*#__PURE__*/React__default.createElement(Horizontal, Object.assign({
|
|
1282
|
+
media: {
|
|
1283
|
+
...media,
|
|
1284
|
+
mobile: {
|
|
1285
|
+
...media.mobile,
|
|
1286
|
+
flexDirection: 'column'
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}, props, {
|
|
1290
|
+
ref: ref
|
|
1291
|
+
}));
|
|
1292
|
+
});
|
|
1293
|
+
const VerticalResponsive = /*#__PURE__*/React__default.forwardRef((_ref2, ref) => {
|
|
1294
|
+
let {
|
|
1295
|
+
media = {},
|
|
1296
|
+
...props
|
|
1297
|
+
} = _ref2;
|
|
1298
|
+
return /*#__PURE__*/React__default.createElement(Vertical, Object.assign({
|
|
1299
|
+
media: {
|
|
1300
|
+
...media,
|
|
1301
|
+
mobile: {
|
|
1302
|
+
...media.mobile,
|
|
1303
|
+
flexDirection: 'row'
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
}, props, {
|
|
1307
|
+
ref: ref
|
|
1308
|
+
}));
|
|
1309
|
+
});
|
|
1242
1310
|
const Scroll = /*#__PURE__*/React__default.forwardRef((props, ref) => /*#__PURE__*/React__default.createElement(Element, Object.assign({}, props, {
|
|
1243
1311
|
ref: ref
|
|
1244
1312
|
})));
|
|
@@ -2498,12 +2566,130 @@
|
|
|
2498
2566
|
return navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i);
|
|
2499
2567
|
}
|
|
2500
2568
|
|
|
2569
|
+
function useActive() {
|
|
2570
|
+
const [active, setActive] = React.useState(false);
|
|
2571
|
+
const ref = React.useRef(null);
|
|
2572
|
+
React.useEffect(() => {
|
|
2573
|
+
const node = ref.current;
|
|
2574
|
+
if (!node) return;
|
|
2575
|
+
const handleMouseDown = () => setActive(true);
|
|
2576
|
+
const handleMouseUp = () => setActive(false);
|
|
2577
|
+
const handleTouchStart = () => setActive(true);
|
|
2578
|
+
const handleTouchEnd = () => setActive(false);
|
|
2579
|
+
node.addEventListener('mousedown', handleMouseDown);
|
|
2580
|
+
node.addEventListener('mouseup', handleMouseUp);
|
|
2581
|
+
node.addEventListener('mouseleave', handleMouseUp);
|
|
2582
|
+
node.addEventListener('touchstart', handleTouchStart);
|
|
2583
|
+
node.addEventListener('touchend', handleTouchEnd);
|
|
2584
|
+
return () => {
|
|
2585
|
+
node.removeEventListener('mousedown', handleMouseDown);
|
|
2586
|
+
node.removeEventListener('mouseup', handleMouseUp);
|
|
2587
|
+
node.removeEventListener('mouseleave', handleMouseUp);
|
|
2588
|
+
node.removeEventListener('touchstart', handleTouchStart);
|
|
2589
|
+
node.removeEventListener('touchend', handleTouchEnd);
|
|
2590
|
+
};
|
|
2591
|
+
}, []);
|
|
2592
|
+
return [ref, active];
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
function useClickOutside() {
|
|
2596
|
+
const [clickedOutside, setClickedOutside] = React.useState(false);
|
|
2597
|
+
const ref = React.useRef(null);
|
|
2598
|
+
React.useEffect(() => {
|
|
2599
|
+
const handleClick = e => {
|
|
2600
|
+
if (ref.current && !ref.current.contains(e.target)) {
|
|
2601
|
+
setClickedOutside(true);
|
|
2602
|
+
} else {
|
|
2603
|
+
setClickedOutside(false);
|
|
2604
|
+
}
|
|
2605
|
+
};
|
|
2606
|
+
document.addEventListener('mousedown', handleClick);
|
|
2607
|
+
return () => {
|
|
2608
|
+
document.removeEventListener('mousedown', handleClick);
|
|
2609
|
+
};
|
|
2610
|
+
}, []);
|
|
2611
|
+
return [ref, clickedOutside];
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
function useFocus() {
|
|
2615
|
+
const [focused, setFocused] = React.useState(false);
|
|
2616
|
+
const ref = React.useRef(null);
|
|
2617
|
+
React.useEffect(() => {
|
|
2618
|
+
const node = ref.current;
|
|
2619
|
+
if (!node) return;
|
|
2620
|
+
const handleFocus = () => setFocused(true);
|
|
2621
|
+
const handleBlur = () => setFocused(false);
|
|
2622
|
+
node.addEventListener('focus', handleFocus);
|
|
2623
|
+
node.addEventListener('blur', handleBlur);
|
|
2624
|
+
return () => {
|
|
2625
|
+
node.removeEventListener('focus', handleFocus);
|
|
2626
|
+
node.removeEventListener('blur', handleBlur);
|
|
2627
|
+
};
|
|
2628
|
+
}, []);
|
|
2629
|
+
return [ref, focused];
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
function useHover() {
|
|
2633
|
+
const [hover, setHover] = React.useState(false);
|
|
2634
|
+
const ref = React.useRef(null);
|
|
2635
|
+
React.useEffect(() => {
|
|
2636
|
+
const node = ref.current;
|
|
2637
|
+
if (!node) return;
|
|
2638
|
+
const handleMouseEnter = () => setHover(true);
|
|
2639
|
+
const handleMouseLeave = () => setHover(false);
|
|
2640
|
+
node.addEventListener('mouseenter', handleMouseEnter);
|
|
2641
|
+
node.addEventListener('mouseleave', handleMouseLeave);
|
|
2642
|
+
return () => {
|
|
2643
|
+
node.removeEventListener('mouseenter', handleMouseEnter);
|
|
2644
|
+
node.removeEventListener('mouseleave', handleMouseLeave);
|
|
2645
|
+
};
|
|
2646
|
+
}, []);
|
|
2647
|
+
return [ref, hover];
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
function useKeyPress(targetKey) {
|
|
2651
|
+
const [keyPressed, setKeyPressed] = React.useState(false);
|
|
2652
|
+
React.useEffect(() => {
|
|
2653
|
+
const downHandler = e => {
|
|
2654
|
+
if (e.key === targetKey) setKeyPressed(true);
|
|
2655
|
+
};
|
|
2656
|
+
const upHandler = e => {
|
|
2657
|
+
if (e.key === targetKey) setKeyPressed(false);
|
|
2658
|
+
};
|
|
2659
|
+
window.addEventListener('keydown', downHandler);
|
|
2660
|
+
window.addEventListener('keyup', upHandler);
|
|
2661
|
+
return () => {
|
|
2662
|
+
window.removeEventListener('keydown', downHandler);
|
|
2663
|
+
window.removeEventListener('keyup', upHandler);
|
|
2664
|
+
};
|
|
2665
|
+
}, [targetKey]);
|
|
2666
|
+
return keyPressed;
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2501
2669
|
const useMount = callback => {
|
|
2502
2670
|
React.useEffect(() => {
|
|
2503
2671
|
callback();
|
|
2504
2672
|
}, []);
|
|
2505
2673
|
};
|
|
2506
2674
|
|
|
2675
|
+
function useOnScreen(options) {
|
|
2676
|
+
const ref = React.useRef(null);
|
|
2677
|
+
const [isOnScreen, setOnScreen] = React.useState(false);
|
|
2678
|
+
React.useEffect(() => {
|
|
2679
|
+
const node = ref.current;
|
|
2680
|
+
if (!node) return;
|
|
2681
|
+
const observer = new IntersectionObserver(_ref => {
|
|
2682
|
+
let [entry] = _ref;
|
|
2683
|
+
setOnScreen(entry.isIntersecting);
|
|
2684
|
+
}, options);
|
|
2685
|
+
observer.observe(node);
|
|
2686
|
+
return () => {
|
|
2687
|
+
observer.unobserve(node);
|
|
2688
|
+
};
|
|
2689
|
+
}, [options]);
|
|
2690
|
+
return [ref, isOnScreen];
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2507
2693
|
const createQuery = (keyScreen, query, set) => {
|
|
2508
2694
|
const mql = window.matchMedia(query);
|
|
2509
2695
|
const onChange = () => {
|
|
@@ -2550,11 +2736,190 @@
|
|
|
2550
2736
|
};
|
|
2551
2737
|
};
|
|
2552
2738
|
|
|
2739
|
+
const getScrollDimensions = element => {
|
|
2740
|
+
if (element instanceof Window) {
|
|
2741
|
+
return {
|
|
2742
|
+
scrollHeight: document.documentElement.scrollHeight,
|
|
2743
|
+
scrollWidth: document.documentElement.scrollWidth,
|
|
2744
|
+
clientHeight: window.innerHeight,
|
|
2745
|
+
clientWidth: window.innerWidth,
|
|
2746
|
+
scrollTop: window.scrollY,
|
|
2747
|
+
scrollLeft: window.scrollX
|
|
2748
|
+
};
|
|
2749
|
+
}
|
|
2750
|
+
return {
|
|
2751
|
+
scrollHeight: element.scrollHeight,
|
|
2752
|
+
scrollWidth: element.scrollWidth,
|
|
2753
|
+
clientHeight: element.clientHeight,
|
|
2754
|
+
clientWidth: element.clientWidth,
|
|
2755
|
+
scrollTop: element.scrollTop,
|
|
2756
|
+
scrollLeft: element.scrollLeft
|
|
2757
|
+
};
|
|
2758
|
+
};
|
|
2759
|
+
const useScroll = function (_temp) {
|
|
2760
|
+
let {
|
|
2761
|
+
container,
|
|
2762
|
+
offset = [0, 0]
|
|
2763
|
+
} = _temp === void 0 ? {} : _temp;
|
|
2764
|
+
const [scrollPosition, setScrollPosition] = React.useState({
|
|
2765
|
+
x: 0,
|
|
2766
|
+
y: 0,
|
|
2767
|
+
xProgress: 0,
|
|
2768
|
+
yProgress: 0
|
|
2769
|
+
});
|
|
2770
|
+
const handleScroll = React.useCallback(() => {
|
|
2771
|
+
if (!container || !container.current) return;
|
|
2772
|
+
const element = container.current;
|
|
2773
|
+
const {
|
|
2774
|
+
scrollHeight,
|
|
2775
|
+
scrollWidth,
|
|
2776
|
+
clientHeight,
|
|
2777
|
+
clientWidth,
|
|
2778
|
+
scrollTop,
|
|
2779
|
+
scrollLeft
|
|
2780
|
+
} = getScrollDimensions(element);
|
|
2781
|
+
const x = scrollLeft + offset[0];
|
|
2782
|
+
const y = scrollTop + offset[1];
|
|
2783
|
+
const maxScrollX = scrollWidth - clientWidth;
|
|
2784
|
+
const maxScrollY = scrollHeight - clientHeight;
|
|
2785
|
+
const xProgress = maxScrollX > 0 ? x / maxScrollX : 1;
|
|
2786
|
+
const yProgress = maxScrollY > 0 ? y / maxScrollY : 1;
|
|
2787
|
+
setScrollPosition(prev => {
|
|
2788
|
+
if (prev.x !== x || prev.y !== y || prev.xProgress !== xProgress || prev.yProgress !== yProgress) {
|
|
2789
|
+
return {
|
|
2790
|
+
x,
|
|
2791
|
+
y,
|
|
2792
|
+
xProgress,
|
|
2793
|
+
yProgress
|
|
2794
|
+
};
|
|
2795
|
+
}
|
|
2796
|
+
return prev;
|
|
2797
|
+
});
|
|
2798
|
+
}, [container, offset]);
|
|
2799
|
+
React.useEffect(() => {
|
|
2800
|
+
if (!container || container.current) return;
|
|
2801
|
+
const element = container.current || window;
|
|
2802
|
+
element.addEventListener('scroll', handleScroll, {
|
|
2803
|
+
passive: true
|
|
2804
|
+
});
|
|
2805
|
+
window.addEventListener('resize', handleScroll, {
|
|
2806
|
+
passive: true
|
|
2807
|
+
});
|
|
2808
|
+
handleScroll();
|
|
2809
|
+
return () => {
|
|
2810
|
+
element.removeEventListener('scroll', handleScroll);
|
|
2811
|
+
window.removeEventListener('resize', handleScroll);
|
|
2812
|
+
};
|
|
2813
|
+
}, [handleScroll, container]);
|
|
2814
|
+
return scrollPosition;
|
|
2815
|
+
};
|
|
2816
|
+
const useScrollAnimation = function (ref, options) {
|
|
2817
|
+
if (options === void 0) {
|
|
2818
|
+
options = {};
|
|
2819
|
+
}
|
|
2820
|
+
const [isInView, setIsInView] = React.useState(false);
|
|
2821
|
+
const [progress, setProgress] = React.useState(0);
|
|
2822
|
+
React.useEffect(() => {
|
|
2823
|
+
if (!ref.current) return;
|
|
2824
|
+
const observer = new IntersectionObserver(entries => {
|
|
2825
|
+
entries.forEach(entry => {
|
|
2826
|
+
setIsInView(entry.isIntersecting);
|
|
2827
|
+
setProgress(entry.intersectionRatio);
|
|
2828
|
+
});
|
|
2829
|
+
}, {
|
|
2830
|
+
threshold: options.threshold || 0,
|
|
2831
|
+
rootMargin: options.rootMargin || '0px'
|
|
2832
|
+
});
|
|
2833
|
+
observer.observe(ref.current);
|
|
2834
|
+
return () => observer.disconnect();
|
|
2835
|
+
}, [ref, options.threshold, options.rootMargin]);
|
|
2836
|
+
return {
|
|
2837
|
+
isInView,
|
|
2838
|
+
progress
|
|
2839
|
+
};
|
|
2840
|
+
};
|
|
2841
|
+
const useSmoothScroll = () => {
|
|
2842
|
+
return React.useCallback(function (element, offset) {
|
|
2843
|
+
if (offset === void 0) {
|
|
2844
|
+
offset = 0;
|
|
2845
|
+
}
|
|
2846
|
+
if (!element) return;
|
|
2847
|
+
const targetPosition = element.getBoundingClientRect().top + window.scrollY - offset;
|
|
2848
|
+
window.scrollTo({
|
|
2849
|
+
top: targetPosition,
|
|
2850
|
+
behavior: 'smooth'
|
|
2851
|
+
});
|
|
2852
|
+
}, []);
|
|
2853
|
+
};
|
|
2854
|
+
const useInfiniteScroll = function (callback, options) {
|
|
2855
|
+
if (options === void 0) {
|
|
2856
|
+
options = {};
|
|
2857
|
+
}
|
|
2858
|
+
const [sentinel, setSentinel] = React.useState(null);
|
|
2859
|
+
React.useEffect(() => {
|
|
2860
|
+
if (!sentinel || options.isLoading) return;
|
|
2861
|
+
const observer = new IntersectionObserver(entries => {
|
|
2862
|
+
if (entries[0].isIntersecting) callback();
|
|
2863
|
+
}, {
|
|
2864
|
+
threshold: options.threshold || 0
|
|
2865
|
+
});
|
|
2866
|
+
observer.observe(sentinel);
|
|
2867
|
+
return () => observer.disconnect();
|
|
2868
|
+
}, [sentinel, callback, options.threshold, options.isLoading]);
|
|
2869
|
+
return {
|
|
2870
|
+
sentinelRef: setSentinel
|
|
2871
|
+
};
|
|
2872
|
+
};
|
|
2873
|
+
const useScrollDirection = function (threshold) {
|
|
2874
|
+
if (threshold === void 0) {
|
|
2875
|
+
threshold = 0;
|
|
2876
|
+
}
|
|
2877
|
+
const [scrollDirection, setScrollDirection] = React.useState('up');
|
|
2878
|
+
const [lastScrollY, setLastScrollY] = React.useState(0);
|
|
2879
|
+
const updateScrollDirection = React.useCallback(() => {
|
|
2880
|
+
const scrollY = window.scrollY;
|
|
2881
|
+
const direction = scrollY > lastScrollY ? 'down' : 'up';
|
|
2882
|
+
if (Math.abs(scrollY - lastScrollY) > threshold && direction !== scrollDirection) {
|
|
2883
|
+
setScrollDirection(direction);
|
|
2884
|
+
}
|
|
2885
|
+
setLastScrollY(scrollY > 0 ? scrollY : 0);
|
|
2886
|
+
}, [scrollDirection, lastScrollY, threshold]);
|
|
2887
|
+
React.useEffect(() => {
|
|
2888
|
+
window.addEventListener('scroll', updateScrollDirection, {
|
|
2889
|
+
passive: true
|
|
2890
|
+
});
|
|
2891
|
+
return () => {
|
|
2892
|
+
window.removeEventListener('scroll', updateScrollDirection);
|
|
2893
|
+
};
|
|
2894
|
+
}, [updateScrollDirection]);
|
|
2895
|
+
return scrollDirection;
|
|
2896
|
+
};
|
|
2897
|
+
|
|
2898
|
+
function useWindowSize() {
|
|
2899
|
+
const [size, setSize] = React.useState({
|
|
2900
|
+
width: window.innerWidth,
|
|
2901
|
+
height: window.innerHeight
|
|
2902
|
+
});
|
|
2903
|
+
React.useEffect(() => {
|
|
2904
|
+
const handleResize = () => {
|
|
2905
|
+
setSize({
|
|
2906
|
+
width: window.innerWidth,
|
|
2907
|
+
height: window.innerHeight
|
|
2908
|
+
});
|
|
2909
|
+
};
|
|
2910
|
+
window.addEventListener('resize', handleResize);
|
|
2911
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
2912
|
+
}, []);
|
|
2913
|
+
return size;
|
|
2914
|
+
}
|
|
2915
|
+
|
|
2553
2916
|
exports.Animation = Animation;
|
|
2554
2917
|
exports.Button = Button;
|
|
2555
2918
|
exports.Div = Div;
|
|
2556
2919
|
exports.Element = Element;
|
|
2557
2920
|
exports.Form = Form;
|
|
2921
|
+
exports.Horizontal = Horizontal;
|
|
2922
|
+
exports.HorizontalResponsive = HorizontalResponsive;
|
|
2558
2923
|
exports.Image = Image;
|
|
2559
2924
|
exports.ImageBackground = ImageBackground;
|
|
2560
2925
|
exports.Input = Input;
|
|
@@ -2569,6 +2934,8 @@
|
|
|
2569
2934
|
exports.ThemeContext = ThemeContext;
|
|
2570
2935
|
exports.ThemeProvider = ThemeProvider;
|
|
2571
2936
|
exports.Typography = Typography;
|
|
2937
|
+
exports.Vertical = Vertical;
|
|
2938
|
+
exports.VerticalResponsive = VerticalResponsive;
|
|
2572
2939
|
exports.View = View;
|
|
2573
2940
|
exports.createQuery = createQuery;
|
|
2574
2941
|
exports.defaultColors = defaultColors;
|
|
@@ -2580,10 +2947,22 @@
|
|
|
2580
2947
|
exports.isProd = isProd;
|
|
2581
2948
|
exports.isSSR = isSSR;
|
|
2582
2949
|
exports.palette = palette;
|
|
2950
|
+
exports.useActive = useActive;
|
|
2951
|
+
exports.useClickOutside = useClickOutside;
|
|
2952
|
+
exports.useFocus = useFocus;
|
|
2953
|
+
exports.useHover = useHover;
|
|
2954
|
+
exports.useInfiniteScroll = useInfiniteScroll;
|
|
2955
|
+
exports.useKeyPress = useKeyPress;
|
|
2583
2956
|
exports.useMount = useMount;
|
|
2957
|
+
exports.useOnScreen = useOnScreen;
|
|
2584
2958
|
exports.useResponsive = useResponsive;
|
|
2585
2959
|
exports.useResponsiveContext = useResponsiveContext;
|
|
2960
|
+
exports.useScroll = useScroll;
|
|
2961
|
+
exports.useScrollAnimation = useScrollAnimation;
|
|
2962
|
+
exports.useScrollDirection = useScrollDirection;
|
|
2963
|
+
exports.useSmoothScroll = useSmoothScroll;
|
|
2586
2964
|
exports.useTheme = useTheme;
|
|
2965
|
+
exports.useWindowSize = useWindowSize;
|
|
2587
2966
|
|
|
2588
2967
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2589
2968
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-studio.umd.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-studio.umd.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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