@superrb/react-addons 3.0.0-22 → 3.0.0-24
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/components/accordion.d.ts +4 -5
- package/components/accordion.d.ts.map +1 -1
- package/components/accordion.js +4 -5
- package/components/back-to-top.d.ts +1 -2
- package/components/back-to-top.d.ts.map +1 -1
- package/components/back-to-top.js +2 -3
- package/components/button.d.ts.map +1 -1
- package/components/button.js +3 -3
- package/components/context-wrapper.d.ts +1 -2
- package/components/context-wrapper.d.ts.map +1 -1
- package/components/context-wrapper.js +3 -2
- package/components/cookie-banner.d.ts +2 -3
- package/components/cookie-banner.d.ts.map +1 -1
- package/components/cookie-banner.js +2 -3
- package/components/form/error-message.d.ts +1 -2
- package/components/form/error-message.d.ts.map +1 -1
- package/components/form/error-message.js +2 -3
- package/components/form/field.d.ts +2 -2
- package/components/form/field.d.ts.map +1 -1
- package/components/form/field.js +2 -3
- package/components/form/submit-button.d.ts +2 -3
- package/components/form/submit-button.d.ts.map +1 -1
- package/components/form/submit-button.js +2 -3
- package/components/form/success-message.d.ts +1 -2
- package/components/form/success-message.d.ts.map +1 -1
- package/components/form/success-message.js +3 -2
- package/components/form.d.ts.map +1 -1
- package/components/form.js +17 -15
- package/components/menu-toggle.d.ts +2 -2
- package/components/menu-toggle.d.ts.map +1 -1
- package/components/menu-toggle.js +2 -3
- package/components/modal.d.ts +2 -2
- package/components/modal.d.ts.map +1 -1
- package/components/modal.js +2 -3
- package/components/skip-to.d.ts +1 -2
- package/components/skip-to.d.ts.map +1 -1
- package/components/skip-to.js +2 -3
- package/components/slideshow-buttons.d.ts +2 -3
- package/components/slideshow-buttons.d.ts.map +1 -1
- package/components/slideshow-buttons.js +2 -3
- package/components/slideshow-pagination.d.ts +2 -3
- package/components/slideshow-pagination.d.ts.map +1 -1
- package/components/slideshow-pagination.js +3 -2
- package/context/modal-context-provider.d.ts +1 -1
- package/context/modal-context-provider.d.ts.map +1 -1
- package/context/modal-context-provider.js +2 -2
- package/context/nav-context-provider.d.ts +1 -1
- package/context/nav-context-provider.d.ts.map +1 -1
- package/context/nav-context-provider.js +2 -2
- package/hooks/use-async.d.ts +3 -2
- package/hooks/use-async.d.ts.map +1 -1
- package/hooks/use-async.js +3 -4
- package/hooks/use-draggable-scroll.d.ts +3 -3
- package/hooks/use-draggable-scroll.d.ts.map +1 -1
- package/hooks/use-draggable-scroll.js +2 -3
- package/hooks/use-event-listener.d.ts +2 -2
- package/hooks/use-event-listener.d.ts.map +1 -1
- package/hooks/use-event-listener.js +3 -10
- package/hooks/use-hide-on-scroll.d.ts +1 -2
- package/hooks/use-hide-on-scroll.d.ts.map +1 -1
- package/hooks/use-hide-on-scroll.js +2 -3
- package/hooks/use-id.d.ts +1 -2
- package/hooks/use-id.d.ts.map +1 -1
- package/hooks/use-id.js +2 -3
- package/hooks/use-is-in-viewport.d.ts +1 -2
- package/hooks/use-is-in-viewport.d.ts.map +1 -1
- package/hooks/use-is-in-viewport.js +2 -3
- package/hooks/use-is-mobile.d.ts +1 -2
- package/hooks/use-is-mobile.d.ts.map +1 -1
- package/hooks/use-is-mobile.js +2 -3
- package/hooks/use-is-overflowing.d.ts +1 -2
- package/hooks/use-is-overflowing.d.ts.map +1 -1
- package/hooks/use-is-overflowing.js +5 -4
- package/hooks/use-lock-body-scroll.d.ts +1 -2
- package/hooks/use-lock-body-scroll.d.ts.map +1 -1
- package/hooks/use-lock-body-scroll.js +1 -2
- package/hooks/use-modal.d.ts +1 -2
- package/hooks/use-modal.d.ts.map +1 -1
- package/hooks/use-modal.js +2 -3
- package/hooks/use-motion-allowed.d.ts +1 -2
- package/hooks/use-motion-allowed.d.ts.map +1 -1
- package/hooks/use-motion-allowed.js +2 -3
- package/hooks/use-parallax.d.ts +1 -2
- package/hooks/use-parallax.d.ts.map +1 -1
- package/hooks/use-parallax.js +2 -3
- package/hooks/use-slideshow.d.ts +5 -6
- package/hooks/use-slideshow.d.ts.map +1 -1
- package/hooks/use-slideshow.js +33 -25
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/utils/animate.d.ts +1 -2
- package/utils/animate.d.ts.map +1 -1
- package/utils/animate.js +24 -23
- package/utils/extend-class.d.ts +1 -2
- package/utils/extend-class.d.ts.map +1 -1
- package/utils/extend-class.js +8 -7
- package/utils/get-y-pos.d.ts +1 -2
- package/utils/get-y-pos.d.ts.map +1 -1
- package/utils/get-y-pos.js +2 -3
- package/utils/get.d.ts +2 -2
- package/utils/get.d.ts.map +1 -1
- package/utils/get.js +1 -2
- package/utils/is-external-link.d.ts +1 -2
- package/utils/is-external-link.d.ts.map +1 -1
- package/utils/is-external-link.js +2 -3
- package/utils/scroll-to-hash.d.ts +1 -2
- package/utils/scroll-to-hash.d.ts.map +1 -1
- package/utils/scroll-to-hash.js +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-draggable-scroll.d.ts","sourceRoot":"","sources":["../src/hooks/use-draggable-scroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,gBAAgB,EAIjB,MAAM,OAAO,CAAA;AAId,UAAU,MAAM;IACd,WAAW,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAA;CAC5C;AAED,
|
|
1
|
+
{"version":3,"file":"use-draggable-scroll.d.ts","sourceRoot":"","sources":["../src/hooks/use-draggable-scroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,gBAAgB,EAIjB,MAAM,OAAO,CAAA;AAId,UAAU,MAAM;IACd,WAAW,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAA;CAC5C;AAED,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,GAAG,EAAE,gBAAgB,CAAC,WAAW,CAAC,EAClC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE;;EA8E9C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef, useState, } from 'react';
|
|
2
2
|
import { useDraggable } from 'react-use-draggable-scroll';
|
|
3
3
|
import { useEventListener, useIsInViewport } from '../hooks';
|
|
4
|
-
|
|
4
|
+
export default function useDraggableScroll(ref, { className, ...opts }) {
|
|
5
5
|
const { isInViewport, setRef } = useIsInViewport(false);
|
|
6
6
|
const { events } = useDraggable(ref, {
|
|
7
7
|
...opts,
|
|
@@ -52,5 +52,4 @@ const useDraggableScroll = (ref, { className, ...opts }) => {
|
|
|
52
52
|
});
|
|
53
53
|
}, [ref, ref.current, setModifiedEvents, shouldScroll]);
|
|
54
54
|
return { events: modifiedEvents };
|
|
55
|
-
}
|
|
56
|
-
export default useDraggableScroll;
|
|
55
|
+
}
|
|
@@ -2,6 +2,6 @@ type Target = Document | Window | Element;
|
|
|
2
2
|
type EventMap<T extends Target> = T extends Window ? WindowEventHandlersEventMap & GlobalEventHandlersEventMap : T extends Document ? DocumentEventMap : GlobalEventHandlersEventMap;
|
|
3
3
|
type EventName<T extends Target> = keyof EventMap<T>;
|
|
4
4
|
type EventListener<T extends Target, E extends EventName<T>> = (event: EventMap<T>[E]) => void | boolean;
|
|
5
|
-
|
|
6
|
-
export
|
|
5
|
+
export default function useEventListener<T extends Target, E extends EventName<T>>(eventName: E, handler: EventListener<T, E>, options?: boolean | AddEventListenerOptions, element?: T, flag?: boolean): void;
|
|
6
|
+
export {};
|
|
7
7
|
//# sourceMappingURL=use-event-listener.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-event-listener.d.ts","sourceRoot":"","sources":["../src/hooks/use-event-listener.ts"],"names":[],"mappings":"AAEA,KAAK,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAEzC,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,GAC9C,2BAA2B,GAAG,2BAA2B,GACzD,CAAC,SAAS,QAAQ,
|
|
1
|
+
{"version":3,"file":"use-event-listener.d.ts","sourceRoot":"","sources":["../src/hooks/use-event-listener.ts"],"names":[],"mappings":"AAEA,KAAK,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAEzC,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,GAC9C,2BAA2B,GAAG,2BAA2B,GACzD,CAAC,SAAS,QAAQ,GAChB,gBAAgB,GAChB,2BAA2B,CAAA;AAEjC,KAAK,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAA;AAEpD,KAAK,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,IAAI,CAC7D,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAClB,IAAI,GAAG,OAAO,CAAA;AAGnB,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAEtB,SAAS,EAAE,CAAC,EACZ,OAAO,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC5B,OAAO,GAAE,OAAO,GAAG,uBAA4B,EAC/C,OAAO,CAAC,EAAE,CAAC,EACX,IAAI,GAAE,OAAc,QAqDrB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
// Hook
|
|
3
|
-
|
|
3
|
+
export default function useEventListener(eventName, handler, options = {}, element, flag = true) {
|
|
4
4
|
// Create a ref that stores handler
|
|
5
5
|
const savedHandler = useRef();
|
|
6
6
|
const elementRef = useRef();
|
|
@@ -33,12 +33,5 @@ const useEventListener = (eventName, handler, options = {}, element, flag = true
|
|
|
33
33
|
return () => {
|
|
34
34
|
elementRef.current.removeEventListener(eventName, eventListener);
|
|
35
35
|
};
|
|
36
|
-
}, [
|
|
37
|
-
|
|
38
|
-
handler,
|
|
39
|
-
options,
|
|
40
|
-
element,
|
|
41
|
-
flag,
|
|
42
|
-
]);
|
|
43
|
-
};
|
|
44
|
-
export default useEventListener;
|
|
36
|
+
}, [eventName, handler, options, element, flag]);
|
|
37
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-hide-on-scroll.d.ts","sourceRoot":"","sources":["../src/hooks/use-hide-on-scroll.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"use-hide-on-scroll.d.ts","sourceRoot":"","sources":["../src/hooks/use-hide-on-scroll.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,YAAY,GAAE,OAAe,GAC5B,OAAO,CA+DT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEventListener } from '../hooks';
|
|
2
2
|
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
-
|
|
3
|
+
export default function useHideOnScroll(hiddenOnLoad = false) {
|
|
4
4
|
const [hidden, setHidden] = useState(hiddenOnLoad);
|
|
5
5
|
const handleScroll = useCallback(() => {
|
|
6
6
|
const previousY = window.scrollY;
|
|
@@ -31,5 +31,4 @@ const useHideOnScroll = (hiddenOnLoad = false) => {
|
|
|
31
31
|
useEventListener('popstate', handleLoad, { passive: true }, typeof window !== 'undefined' ? window : undefined);
|
|
32
32
|
useEventListener('pageshow', handleLoad, { passive: true }, typeof window !== 'undefined' ? window : undefined);
|
|
33
33
|
return hidden;
|
|
34
|
-
}
|
|
35
|
-
export default useHideOnScroll;
|
|
34
|
+
}
|
package/hooks/use-id.d.ts
CHANGED
package/hooks/use-id.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-id.d.ts","sourceRoot":"","sources":["../src/hooks/use-id.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"use-id.d.ts","sourceRoot":"","sources":["../src/hooks/use-id.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,MAAM,EAAE,MAAM,UAU3C"}
|
package/hooks/use-id.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
2
|
+
export default function useId(prefix) {
|
|
3
3
|
const [id, setId] = useState(`${prefix}-${Math.random().toString(36).substring(2, 9)}`);
|
|
4
4
|
useEffect(() => {
|
|
5
5
|
setId(`${prefix}-${Math.random().toString(36).substring(2, 9)}`);
|
|
6
6
|
}, [prefix]);
|
|
7
7
|
return id;
|
|
8
|
-
}
|
|
9
|
-
export default useId;
|
|
8
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export default function useIsInViewport(initial?: boolean, rootMargin?: string, threshold?: number[]): {
|
|
2
2
|
isInViewport: boolean;
|
|
3
3
|
setRef: (ref: HTMLElement | null) => void;
|
|
4
4
|
};
|
|
5
|
-
export default useIsInViewport;
|
|
6
5
|
//# sourceMappingURL=use-is-in-viewport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-is-in-viewport.d.ts","sourceRoot":"","sources":["../src/hooks/use-is-in-viewport.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"use-is-in-viewport.d.ts","sourceRoot":"","sources":["../src/hooks/use-is-in-viewport.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,OAAO,UAAQ,EACf,UAAU,SAAY,EACtB,SAAS,WAA0B;;kBA6Dd,WAAW,GAAG,IAAI;EAiBxC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
|
|
2
|
+
export default function useIsInViewport(initial = false, rootMargin = '0px 0px', threshold = [0, 0.25, 0.5, 0.75, 1]) {
|
|
3
3
|
const [isInViewport, setIsInViewport] = useState(initial);
|
|
4
4
|
const element = useRef();
|
|
5
5
|
const observer = useRef();
|
|
@@ -63,5 +63,4 @@ const useIsInViewport = (initial = false, rootMargin = '0px 0px', threshold = [0
|
|
|
63
63
|
})();
|
|
64
64
|
};
|
|
65
65
|
return { isInViewport, setRef };
|
|
66
|
-
}
|
|
67
|
-
export default useIsInViewport;
|
|
66
|
+
}
|
package/hooks/use-is-mobile.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-is-mobile.d.ts","sourceRoot":"","sources":["../src/hooks/use-is-mobile.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"use-is-mobile.d.ts","sourceRoot":"","sources":["../src/hooks/use-is-mobile.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,OAAO,UAAO,EAAE,IAAI,SAAY,WAiBnE"}
|
package/hooks/use-is-mobile.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
|
|
2
|
+
export default function useIsMobile(initial = true, size = '63.75em') {
|
|
3
3
|
const [isMobile, setIsMobile] = useState(initial);
|
|
4
4
|
const setScreenSize = useCallback(() => {
|
|
5
5
|
setIsMobile(!window.matchMedia(`(min-width: ${size})`).matches);
|
|
@@ -12,5 +12,4 @@ const useIsMobile = (initial = true, size = '63.75em') => {
|
|
|
12
12
|
};
|
|
13
13
|
}, [setScreenSize]);
|
|
14
14
|
return isMobile;
|
|
15
|
-
}
|
|
16
|
-
export default useIsMobile;
|
|
15
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { MutableRefObject } from 'react';
|
|
2
|
-
|
|
3
|
-
export default useIsOverflowing;
|
|
2
|
+
export default function useIsOverflowing({ current, }: MutableRefObject<HTMLElement>): boolean;
|
|
4
3
|
//# sourceMappingURL=use-is-overflowing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-is-overflowing.d.ts","sourceRoot":"","sources":["../src/hooks/use-is-overflowing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAExC,
|
|
1
|
+
{"version":3,"file":"use-is-overflowing.d.ts","sourceRoot":"","sources":["../src/hooks/use-is-overflowing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAExC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,OAAO,GACR,EAAE,gBAAgB,CAAC,WAAW,CAAC,WAM/B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
(current
|
|
3
|
-
current.
|
|
4
|
-
|
|
1
|
+
export default function useIsOverflowing({ current, }) {
|
|
2
|
+
return (current &&
|
|
3
|
+
(current.scrollWidth > current.clientWidth ||
|
|
4
|
+
current.scrollHeight > current.clientHeight));
|
|
5
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-lock-body-scroll.d.ts","sourceRoot":"","sources":["../src/hooks/use-lock-body-scroll.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"use-lock-body-scroll.d.ts","sourceRoot":"","sources":["../src/hooks/use-lock-body-scroll.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAO/D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
function useLockBodyScroll(toggle) {
|
|
2
|
+
export default function useLockBodyScroll(toggle) {
|
|
3
3
|
useEffect(() => {
|
|
4
4
|
document.body.style.overflow = toggle ? 'hidden' : 'unset';
|
|
5
5
|
return () => {
|
|
@@ -7,4 +7,3 @@ function useLockBodyScroll(toggle) {
|
|
|
7
7
|
};
|
|
8
8
|
}, [toggle]);
|
|
9
9
|
}
|
|
10
|
-
export default useLockBodyScroll;
|
package/hooks/use-modal.d.ts
CHANGED
package/hooks/use-modal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-modal.d.ts","sourceRoot":"","sources":["../src/hooks/use-modal.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"use-modal.d.ts","sourceRoot":"","sources":["../src/hooks/use-modal.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,IAAI,EAAE,MAAM;;;;EAU5C"}
|
package/hooks/use-modal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import useModalStore from '../store/modal';
|
|
2
|
-
|
|
2
|
+
export default function useModal(name) {
|
|
3
3
|
const isOpen = useModalStore((state) => state.openState[name]);
|
|
4
4
|
const openModal = useModalStore((state) => state.openModal);
|
|
5
5
|
const closeModal = useModalStore((state) => state.closeModal);
|
|
@@ -8,5 +8,4 @@ const useModal = (name) => {
|
|
|
8
8
|
openModal: () => openModal(name),
|
|
9
9
|
closeModal: () => closeModal(name),
|
|
10
10
|
};
|
|
11
|
-
}
|
|
12
|
-
export default useModal;
|
|
11
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-motion-allowed.d.ts","sourceRoot":"","sources":["../src/hooks/use-motion-allowed.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"use-motion-allowed.d.ts","sourceRoot":"","sources":["../src/hooks/use-motion-allowed.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,gBAAgB,YAUvC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
2
|
+
export default function useMotionAllowed() {
|
|
3
3
|
const [motionAllowed, setMotionAllowed] = useState(true);
|
|
4
4
|
useEffect(() => {
|
|
5
5
|
setMotionAllowed(!window.matchMedia('(prefers-reduced-motion: reduce)').matches);
|
|
6
6
|
}, [setMotionAllowed]);
|
|
7
7
|
return motionAllowed;
|
|
8
|
-
}
|
|
9
|
-
export default useMotionAllowed;
|
|
8
|
+
}
|
package/hooks/use-parallax.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-parallax.d.ts","sourceRoot":"","sources":["../src/hooks/use-parallax.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"use-parallax.d.ts","sourceRoot":"","sources":["../src/hooks/use-parallax.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,KAAK,EAAE,WAAW,EAAE,EACpB,IAAI,GAAE,OAAc,QA4BrB"}
|
package/hooks/use-parallax.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEventListener, useMotionAllowed } from '../hooks';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
|
|
3
|
+
export default function useParallax(items, flag = true) {
|
|
4
4
|
const isMotionAllowed = useMotionAllowed();
|
|
5
5
|
const onScroll = useCallback((event) => {
|
|
6
6
|
items.forEach((item, index) => {
|
|
@@ -14,5 +14,4 @@ const useParallax = (items, flag = true) => {
|
|
|
14
14
|
});
|
|
15
15
|
}, [items]);
|
|
16
16
|
useEventListener('scroll', onScroll, { passive: true }, undefined, flag && isMotionAllowed);
|
|
17
|
-
}
|
|
18
|
-
export default useParallax;
|
|
17
|
+
}
|
package/hooks/use-slideshow.d.ts
CHANGED
|
@@ -10,10 +10,9 @@ export type Slideshow = {
|
|
|
10
10
|
atStart: boolean;
|
|
11
11
|
atEnd: boolean;
|
|
12
12
|
};
|
|
13
|
-
export declare
|
|
14
|
-
export declare
|
|
15
|
-
export declare
|
|
16
|
-
export declare
|
|
17
|
-
|
|
18
|
-
export default useSlideshow;
|
|
13
|
+
export declare function isHorizontal(element: SlideshowElement): boolean;
|
|
14
|
+
export declare function isCentered(element: SlideshowElement): boolean;
|
|
15
|
+
export declare function getScrollProgress(target: SlideshowElement): number;
|
|
16
|
+
export declare function getCurrentSlideIndex(element: SlideshowElement, currentIndex: number): number;
|
|
17
|
+
export default function useSlideshow(slideshow: MutableRefObject<SlideshowElement>): Slideshow;
|
|
19
18
|
//# sourceMappingURL=use-slideshow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-slideshow.d.ts","sourceRoot":"","sources":["../src/hooks/use-slideshow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAoC,MAAM,OAAO,CAAA;AAG1E,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,YAAY,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAA;IAChD,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,
|
|
1
|
+
{"version":3,"file":"use-slideshow.d.ts","sourceRoot":"","sources":["../src/hooks/use-slideshow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAoC,MAAM,OAAO,CAAA;AAG1E,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,YAAY,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAA;IAChD,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAE/D;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAK7D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,UAMzD;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,gBAAgB,EACzB,YAAY,EAAE,MAAM,GACnB,MAAM,CAwDR;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,SAAS,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,GAC5C,SAAS,CAuFX"}
|
package/hooks/use-slideshow.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import useEventListener from './use-event-listener';
|
|
3
|
-
export
|
|
3
|
+
export function isHorizontal(element) {
|
|
4
4
|
return window.getComputedStyle(element).scrollSnapType.startsWith('x');
|
|
5
|
-
}
|
|
6
|
-
export
|
|
5
|
+
}
|
|
6
|
+
export function isCentered(element) {
|
|
7
7
|
return (window.getComputedStyle(element.firstElementChild)
|
|
8
8
|
?.scrollSnapAlign === 'center');
|
|
9
|
-
}
|
|
10
|
-
export
|
|
9
|
+
}
|
|
10
|
+
export function getScrollProgress(target) {
|
|
11
11
|
if (!target || target.scrollWidth === target.clientWidth) {
|
|
12
12
|
return -1;
|
|
13
13
|
}
|
|
14
14
|
return target.scrollLeft / (target.scrollWidth - target.clientWidth);
|
|
15
|
-
}
|
|
16
|
-
export
|
|
15
|
+
}
|
|
16
|
+
export function getCurrentSlideIndex(element, currentIndex) {
|
|
17
17
|
if (!element) {
|
|
18
18
|
return currentIndex;
|
|
19
19
|
}
|
|
@@ -24,7 +24,7 @@ export const getCurrentSlideIndex = (element, currentIndex) => {
|
|
|
24
24
|
const centered = isCentered(element);
|
|
25
25
|
const horizontal = isHorizontal(element);
|
|
26
26
|
const direction = element.scrollLeft > element.previousScroll ? 'right' : 'left';
|
|
27
|
-
const offset =
|
|
27
|
+
const offset = 25;
|
|
28
28
|
let gap = parseFloat(window.getComputedStyle(element).gap) || 0;
|
|
29
29
|
if (isNaN(gap)) {
|
|
30
30
|
gap = 0;
|
|
@@ -39,7 +39,8 @@ export const getCurrentSlideIndex = (element, currentIndex) => {
|
|
|
39
39
|
? element.clientWidth / 2
|
|
40
40
|
: element.clientHeight / 2;
|
|
41
41
|
if (edge >= 0 && edge < threshold) {
|
|
42
|
-
|
|
42
|
+
newIndex = i;
|
|
43
|
+
break;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
@@ -47,15 +48,16 @@ export const getCurrentSlideIndex = (element, currentIndex) => {
|
|
|
47
48
|
? (horizontal ? child.clientWidth : child.clientHeight) - gap - offset
|
|
48
49
|
: 0 + gap + offset;
|
|
49
50
|
if (edge >= 0 - threshold) {
|
|
50
|
-
|
|
51
|
+
newIndex = i;
|
|
52
|
+
break;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
i++;
|
|
54
56
|
}
|
|
55
57
|
element.previousScroll = element.scrollLeft;
|
|
56
58
|
return newIndex;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
+
}
|
|
60
|
+
export default function useSlideshow(slideshow) {
|
|
59
61
|
const [currentSlide, setCurrentSlide] = useState(0);
|
|
60
62
|
const [progress, setProgress] = useState(-1);
|
|
61
63
|
const [ready, setReady] = useState(false);
|
|
@@ -78,33 +80,39 @@ const useSlideshow = (slideshow) => {
|
|
|
78
80
|
}
|
|
79
81
|
}, [slideshow, update]);
|
|
80
82
|
useEffect(() => {
|
|
81
|
-
|
|
83
|
+
;
|
|
84
|
+
[...slideshow.current?.children].forEach((child) => child.setAttribute('aria-hidden', 'true'));
|
|
82
85
|
slideshow.current?.children[currentSlide].setAttribute('aria-hidden', 'false');
|
|
83
86
|
}, [currentSlide, slideshow]);
|
|
84
87
|
return {
|
|
85
88
|
slideshowRef: slideshow,
|
|
86
89
|
currentSlide,
|
|
87
90
|
slideCount: slideshow.current?.children.length || 0,
|
|
88
|
-
goTo
|
|
91
|
+
goTo(index) {
|
|
92
|
+
index = Math.min(slideshow.current?.children.length - 1, Math.max(0, index));
|
|
93
|
+
const newElement = slideshow.current?.children[index];
|
|
89
94
|
const scrollOpts = {
|
|
90
95
|
behavior: 'smooth',
|
|
91
|
-
block: 'start',
|
|
92
|
-
inline: 'start',
|
|
93
96
|
};
|
|
94
|
-
if (isCentered(slideshow.current)) {
|
|
95
|
-
scrollOpts.block = 'center';
|
|
96
|
-
scrollOpts.inline = 'center';
|
|
97
|
-
}
|
|
98
97
|
if (isHorizontal(slideshow.current)) {
|
|
99
|
-
|
|
98
|
+
if (isCentered(slideshow.current)) {
|
|
99
|
+
scrollOpts.left = newElement?.offsetLeft + newElement?.clientWidth / 2;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
scrollOpts.left = newElement?.offsetLeft;
|
|
103
|
+
}
|
|
100
104
|
}
|
|
101
105
|
else {
|
|
102
|
-
|
|
106
|
+
if (isCentered(slideshow.current)) {
|
|
107
|
+
scrollOpts.top = newElement?.offsetTop + newElement?.clientHeight / 2;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
scrollOpts.top = newElement?.offsetTop;
|
|
111
|
+
}
|
|
103
112
|
}
|
|
104
|
-
slideshow.current?.
|
|
113
|
+
slideshow.current?.scrollTo(scrollOpts);
|
|
105
114
|
},
|
|
106
115
|
atStart: progress <= 0 || progress === -1,
|
|
107
116
|
atEnd: progress >= 1 || progress === -1,
|
|
108
117
|
};
|
|
109
|
-
}
|
|
110
|
-
export default useSlideshow;
|
|
118
|
+
}
|