@yakad/ui 1.3.139 → 1.3.140
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/ActiveOnVisible/ActiveOnVisible.d.ts +5 -0
- package/dist/ActiveOnVisible/ActiveOnVisible.js +20 -0
- package/dist/RenderByVisibility/RenderByVisibility.d.ts +3 -1
- package/dist/RenderByVisibility/RenderByVisibility.js +29 -17
- package/dist/Stack/Stack.d.ts +0 -1
- package/dist/Stack/Stack.js +2 -2
- package/dist/WithInteractions/WithInteractions.d.ts +2 -1
- package/dist/WithInteractions/WithInteractions.js +3 -10
- package/dist/index.d.ts +4 -5
- package/dist/index.js +11 -13
- package/package.json +1 -1
- package/dist/DisplayOnVisible/DisplayOnVisible.d.ts +0 -10
- package/dist/DisplayOnVisible/DisplayOnVisible.js +0 -41
- package/dist/DisplayOnVisible/DisplayOnVisible.module.css +0 -3
- package/dist/RenderOnVisible/RenderOnVisible.d.ts +0 -10
- package/dist/RenderOnVisible/RenderOnVisible.js +0 -40
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StackProps } from "..";
|
|
3
|
+
export interface ActiveOnVisibleProps extends StackProps {
|
|
4
|
+
}
|
|
5
|
+
export declare const ActiveOnVisible: import("react").ForwardRefExoticComponent<ActiveOnVisibleProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { Activity, forwardRef, useState } from "react";
|
|
15
|
+
import { WithInteractions } from "..";
|
|
16
|
+
export const ActiveOnVisible = forwardRef(function ActiveOnVisible(_a, ref) {
|
|
17
|
+
var { children } = _a, restProps = __rest(_a, ["children"]);
|
|
18
|
+
const [isVisible, setIsVisible] = useState(true);
|
|
19
|
+
return (_jsx(WithInteractions, Object.assign({ ref: ref }, restProps, { onVisibilityChange: (v) => setIsVisible(v), children: _jsx(Activity, { mode: isVisible ? "visible" : "hidden", children: children }) })));
|
|
20
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
import { StackProps } from "..";
|
|
3
|
+
export interface RenderByVisibilityProps extends StackProps {
|
|
4
|
+
scrollMarginTop?: number;
|
|
3
5
|
extraRender?: number;
|
|
4
6
|
jumpToIndex?: number;
|
|
5
7
|
stopNewRenders?: boolean;
|
|
@@ -12,19 +12,20 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import React, { forwardRef, useEffect, useRef, useState } from "react";
|
|
15
|
-
import {
|
|
15
|
+
import { Stack, WithInteractions } from "..";
|
|
16
16
|
const data = Array.from({ length: 78 });
|
|
17
17
|
export const RenderByVisibility = forwardRef(function RenderByVisibility(_a, ref) {
|
|
18
|
-
var { extraRender = 5, jumpToIndex = 0, stopNewRenders, newChildRendered, children } = _a, restProps = __rest(_a, ["extraRender", "jumpToIndex", "stopNewRenders", "newChildRendered", "children"]);
|
|
18
|
+
var { scrollMarginTop = 2, extraRender = 5, jumpToIndex = 0, stopNewRenders, newChildRendered, style, children } = _a, restProps = __rest(_a, ["scrollMarginTop", "extraRender", "jumpToIndex", "stopNewRenders", "newChildRendered", "style", "children"]);
|
|
19
|
+
const childrenArray = React.Children.toArray(children);
|
|
20
|
+
// Scroll Zone
|
|
19
21
|
const childRefs = useRef({});
|
|
20
|
-
const scrollTo = (i) => {
|
|
22
|
+
const scrollTo = (i, smooth) => {
|
|
21
23
|
var _a;
|
|
22
24
|
return (_a = childRefs.current[i]) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
23
|
-
behavior: "smooth",
|
|
25
|
+
behavior: smooth ? "smooth" : "auto",
|
|
24
26
|
});
|
|
25
27
|
};
|
|
26
|
-
|
|
27
|
-
// Collect Visibility Status
|
|
28
|
+
// Collect Visibled Childs
|
|
28
29
|
const [visibled, setVisibled] = useState({ lowest: jumpToIndex, highest: jumpToIndex });
|
|
29
30
|
const handleOnVisible = (i) => {
|
|
30
31
|
if (i < visibled.lowest)
|
|
@@ -32,11 +33,12 @@ export const RenderByVisibility = forwardRef(function RenderByVisibility(_a, ref
|
|
|
32
33
|
if (i > visibled.highest)
|
|
33
34
|
setVisibled(Object.assign(Object.assign({}, visibled), { highest: i }));
|
|
34
35
|
};
|
|
35
|
-
// Collect Rendered Childs
|
|
36
|
+
// Collect Rendered Childs
|
|
36
37
|
const [rendered, setRendered] = useState({ lowest: jumpToIndex, highest: jumpToIndex });
|
|
37
|
-
// Calculate Over Screen Renders
|
|
38
38
|
const overRenderedOnLowSide = visibled.lowest - rendered.lowest;
|
|
39
39
|
const overRenderedOnHighSide = rendered.highest - visibled.highest;
|
|
40
|
+
// Is Visible Loading Box
|
|
41
|
+
const [isVisibleLowSideLoadingBox, setIsVisibleLowSideLoadingBox] = useState(false);
|
|
40
42
|
// Render new Childs if needed
|
|
41
43
|
useEffect(() => {
|
|
42
44
|
if (!stopNewRenders) {
|
|
@@ -50,26 +52,36 @@ export const RenderByVisibility = forwardRef(function RenderByVisibility(_a, ref
|
|
|
50
52
|
else {
|
|
51
53
|
if (rendered.lowest > 0 &&
|
|
52
54
|
overRenderedOnLowSide < extraRender) {
|
|
55
|
+
if (isVisibleLowSideLoadingBox) {
|
|
56
|
+
scrollTo(rendered.lowest);
|
|
57
|
+
}
|
|
53
58
|
setRendered(Object.assign(Object.assign({}, rendered), { lowest: rendered.lowest - 1 }));
|
|
54
59
|
newChildRendered === null || newChildRendered === void 0 ? void 0 : newChildRendered(rendered.lowest - 1);
|
|
55
|
-
if (overRenderedOnLowSide === 0)
|
|
56
|
-
scrollTo(visibled.lowest);
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
|
-
|
|
63
|
+
// eslint-disable-next-line
|
|
64
|
+
}, [visibled, rendered, extraRender, stopNewRenders]);
|
|
61
65
|
// Scroll to jumpToIndex
|
|
62
66
|
useEffect(() => {
|
|
63
|
-
|
|
64
|
-
(
|
|
65
|
-
|
|
67
|
+
const isJumpToIndexOutOfRenderedRange = jumpToIndex < rendered.lowest || jumpToIndex > rendered.highest;
|
|
68
|
+
if (isJumpToIndexOutOfRenderedRange) {
|
|
69
|
+
setVisibled({ lowest: jumpToIndex, highest: jumpToIndex });
|
|
70
|
+
setRendered({ lowest: jumpToIndex, highest: jumpToIndex });
|
|
71
|
+
}
|
|
72
|
+
const timeout = setTimeout(() => {
|
|
73
|
+
scrollTo(jumpToIndex, true);
|
|
74
|
+
}, 300);
|
|
75
|
+
return () => clearTimeout(timeout);
|
|
76
|
+
// eslint-disable-next-line
|
|
66
77
|
}, [jumpToIndex]);
|
|
67
78
|
// console.log("visibled", visibled);
|
|
68
79
|
// console.log("rendered", rendered);
|
|
69
80
|
// console.log("stopNewRenders", stopNewRenders);
|
|
70
|
-
return (_jsxs(Stack, Object.assign({ ref: ref }, restProps, { style: { minHeight: "100vh" }, children: [rendered.lowest > 0 && _jsx(
|
|
81
|
+
return (_jsxs(Stack, Object.assign({ ref: ref }, restProps, { style: Object.assign({ minHeight: "100vh" }, style), children: [rendered.lowest > 0 && (_jsx(WithInteractions, { style: {
|
|
82
|
+
marginBottom: `${scrollMarginTop}rem`,
|
|
83
|
+
}, onVisibilityChange: (v) => setIsVisibleLowSideLoadingBox(v) })), childrenArray.map((child, i) => i >= rendered.lowest &&
|
|
71
84
|
i <= rendered.highest && (_jsx(WithInteractions, { ref: (el) => {
|
|
72
85
|
childRefs.current[i] = el;
|
|
73
|
-
}, onVisible: () => handleOnVisible(i), children: child }, i)))
|
|
86
|
+
}, onVisible: () => handleOnVisible(i), style: { scrollMarginTop: `${scrollMarginTop}rem` }, children: child }, i)))] })));
|
|
74
87
|
});
|
|
75
|
-
const LoadingBox = () => (_jsx(Card, { style: { height: "15rem" }, children: _jsx(LoadingIcon, { variant: "dots", size: "extraLarge" }) }));
|
package/dist/Stack/Stack.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export interface StackProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
align?: "start" | "space" | "center" | "end";
|
|
4
|
-
fullWidth?: boolean;
|
|
5
4
|
children?: React.ReactNode;
|
|
6
5
|
}
|
|
7
6
|
export declare const Stack: import("react").ForwardRefExoticComponent<StackProps & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/Stack/Stack.js
CHANGED
|
@@ -15,7 +15,7 @@ import classNames from "classnames";
|
|
|
15
15
|
import boxingStyles from "../boxing.module.css";
|
|
16
16
|
import styles from "./Stack.module.css";
|
|
17
17
|
export const Stack = forwardRef(function Stack(_a, ref) {
|
|
18
|
-
var { align,
|
|
19
|
-
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, {
|
|
18
|
+
var { align, className, children } = _a, restProps = __rest(_a, ["align", "className", "children"]);
|
|
19
|
+
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { fullWidthLover: true }, styles.stack, className);
|
|
20
20
|
return (_jsx("div", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
21
21
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import { StackProps } from "../Stack/Stack";
|
|
3
|
+
export interface WithInteractionsProps extends StackProps {
|
|
3
4
|
onRightClick?: (e: MouseEvent) => void;
|
|
4
5
|
onTap?: (e: TouchEvent) => void;
|
|
5
6
|
onDoubleTap?: (e: TouchEvent) => void;
|
|
@@ -11,10 +11,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
|
|
15
|
+
import { Stack } from "../Stack/Stack";
|
|
16
16
|
export const WithInteractions = forwardRef(function WithInteractions(_a, forwardedRef) {
|
|
17
|
-
var _b;
|
|
18
17
|
var { children, onRightClick, onTap, onDoubleTap, onOutsideClick, onSwipeLeft, onSwipeRight, onSwipeUp, onSwipeDown, onPinchIn, onPinchOut, onRotate, onScrollStart, onScrollStop, onResize, onVisibilityChange, onVisible, onHidden, onMouseHoverStart, onMouseHoverLeave } = _a, restProps = __rest(_a, ["children", "onRightClick", "onTap", "onDoubleTap", "onOutsideClick", "onSwipeLeft", "onSwipeRight", "onSwipeUp", "onSwipeDown", "onPinchIn", "onPinchOut", "onRotate", "onScrollStart", "onScrollStop", "onResize", "onVisibilityChange", "onVisible", "onHidden", "onMouseHoverStart", "onMouseHoverLeave"]);
|
|
19
18
|
const localRef = useRef(null);
|
|
20
19
|
// Let the parent access our DOM node
|
|
@@ -215,11 +214,5 @@ export const WithInteractions = forwardRef(function WithInteractions(_a, forward
|
|
|
215
214
|
onMouseHoverStart,
|
|
216
215
|
onMouseHoverLeave,
|
|
217
216
|
]);
|
|
218
|
-
|
|
219
|
-
return null;
|
|
220
|
-
return _jsx("div", { ref: localRef, children: children });
|
|
221
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
222
|
-
return cloneElement(children, Object.assign(Object.assign({}, restProps), { ref: mergeRefs(localRef, forwardedRef,
|
|
223
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
224
|
-
(_b = children.props) === null || _b === void 0 ? void 0 : _b.ref) }));
|
|
217
|
+
return (_jsx(Stack, Object.assign({ ref: localRef }, restProps, { children: children })));
|
|
225
218
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export * from "./Main/Main";
|
|
|
4
4
|
export * from "./Footer/Footer";
|
|
5
5
|
export * from "./Navigation/Navigation";
|
|
6
6
|
export * from "./Container/Container";
|
|
7
|
-
export * from "./Stack/Stack";
|
|
8
7
|
export * from "./Row/Row";
|
|
8
|
+
export * from "./Stack/Stack";
|
|
9
9
|
export * from "./GridContainer/GridContainer";
|
|
10
10
|
export * from "./GridItem/GridItem";
|
|
11
11
|
export * from "./Card/Card";
|
|
@@ -28,10 +28,9 @@ export * from "./RadioGroup/RadioGroup";
|
|
|
28
28
|
export * from "./RadioButton/RadioButton";
|
|
29
29
|
export * from "./CodeBox/CodeBox";
|
|
30
30
|
export * from "./Display/Display";
|
|
31
|
-
export * from "./WithInteractions/WithInteractions";
|
|
32
31
|
export * from "./WithOverlay/WithOverlay";
|
|
32
|
+
export * from "./WithInteractions/WithInteractions";
|
|
33
|
+
export * from "./RenderByVisibility/RenderByVisibility";
|
|
34
|
+
export * from "./ActiveOnVisible/ActiveOnVisible";
|
|
33
35
|
export * from "./Dropdown/Dropdown";
|
|
34
36
|
export * from "./Popup/Popup";
|
|
35
|
-
export * from "./RenderByVisibility/RenderByVisibility";
|
|
36
|
-
export * from "./DisplayOnVisible/DisplayOnVisible";
|
|
37
|
-
export * from "./RenderOnVisible/RenderOnVisible";
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// Layout & Structure
|
|
2
|
-
export * from "./Screen/Screen";
|
|
2
|
+
export * from "./Screen/Screen"; // Stack Based
|
|
3
3
|
export * from "./AppBar/AppBar";
|
|
4
4
|
export * from "./Main/Main";
|
|
5
5
|
export * from "./Footer/Footer";
|
|
6
6
|
export * from "./Navigation/Navigation";
|
|
7
|
-
export * from "./Container/Container";
|
|
8
|
-
export * from "./Stack/Stack";
|
|
7
|
+
export * from "./Container/Container"; // Stack Based
|
|
9
8
|
export * from "./Row/Row";
|
|
9
|
+
export * from "./Stack/Stack";
|
|
10
10
|
export * from "./GridContainer/GridContainer";
|
|
11
11
|
export * from "./GridItem/GridItem";
|
|
12
|
-
export * from "./Card/Card";
|
|
12
|
+
export * from "./Card/Card"; // Stack Based
|
|
13
13
|
// Theme & Styling
|
|
14
|
-
export * from "./Theme/Theme";
|
|
14
|
+
export * from "./Theme/Theme"; // Stack Based
|
|
15
15
|
export * from "./Spacer/Spacer";
|
|
16
16
|
export * from "./Hr/Hr";
|
|
17
17
|
// UI Components
|
|
@@ -32,13 +32,11 @@ export * from "./RadioGroup/RadioGroup";
|
|
|
32
32
|
export * from "./RadioButton/RadioButton";
|
|
33
33
|
export * from "./CodeBox/CodeBox";
|
|
34
34
|
// Utilities
|
|
35
|
-
export * from "./Display/Display";
|
|
36
|
-
export * from "./WithInteractions/WithInteractions";
|
|
35
|
+
export * from "./Display/Display"; // Stack Based
|
|
37
36
|
export * from "./WithOverlay/WithOverlay";
|
|
37
|
+
export * from "./WithInteractions/WithInteractions"; // Stack Based
|
|
38
|
+
export * from "./RenderByVisibility/RenderByVisibility"; // Stack Based
|
|
39
|
+
export * from "./ActiveOnVisible/ActiveOnVisible"; // Stack Based
|
|
38
40
|
// Overlays
|
|
39
|
-
export * from "./Dropdown/Dropdown";
|
|
40
|
-
export * from "./Popup/Popup";
|
|
41
|
-
// Loading Control
|
|
42
|
-
export * from "./RenderByVisibility/RenderByVisibility";
|
|
43
|
-
export * from "./DisplayOnVisible/DisplayOnVisible";
|
|
44
|
-
export * from "./RenderOnVisible/RenderOnVisible";
|
|
41
|
+
export * from "./Dropdown/Dropdown"; // Card Based
|
|
42
|
+
export * from "./Popup/Popup"; // Card Based
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export interface DisplayOnVisibleProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
align?: "start" | "space" | "center" | "end";
|
|
4
|
-
fullWidth?: boolean;
|
|
5
|
-
onVisibilityChange?: (visible: boolean) => void;
|
|
6
|
-
onVisible?: () => void;
|
|
7
|
-
onHidden?: () => void;
|
|
8
|
-
children?: React.ReactNode;
|
|
9
|
-
}
|
|
10
|
-
export declare const DisplayOnVisible: import("react").ForwardRefExoticComponent<DisplayOnVisibleProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
15
|
-
import classNames from "classnames";
|
|
16
|
-
import boxingStyles from "../boxing.module.css";
|
|
17
|
-
import { WithInteractions } from "..";
|
|
18
|
-
import styles from "./DisplayOnVisible.module.css";
|
|
19
|
-
export const DisplayOnVisible = forwardRef(function DisplayOnVisible(_a, forwardedRef) {
|
|
20
|
-
var { align, fullWidth = true, onVisibilityChange, onVisible, onHidden, className, style, children } = _a, restProps = __rest(_a, ["align", "fullWidth", "onVisibilityChange", "onVisible", "onHidden", "className", "style", "children"]);
|
|
21
|
-
const localRef = useRef(null);
|
|
22
|
-
// Let the parent access our DOM node
|
|
23
|
-
useImperativeHandle(forwardedRef, () => localRef.current);
|
|
24
|
-
const [boxHeight, setBoxHeight] = useState(0);
|
|
25
|
-
const isVisible = boxHeight === 0;
|
|
26
|
-
const handleOnVisible = () => {
|
|
27
|
-
setBoxHeight(0);
|
|
28
|
-
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(true);
|
|
29
|
-
onVisible === null || onVisible === void 0 ? void 0 : onVisible();
|
|
30
|
-
};
|
|
31
|
-
const handleOnHidden = () => {
|
|
32
|
-
if (localRef.current) {
|
|
33
|
-
const boxRect = localRef.current.getBoundingClientRect();
|
|
34
|
-
setBoxHeight(boxRect.height);
|
|
35
|
-
}
|
|
36
|
-
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(false);
|
|
37
|
-
onHidden === null || onHidden === void 0 ? void 0 : onHidden();
|
|
38
|
-
};
|
|
39
|
-
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { fullWidth: fullWidth }, { [styles.notVisible]: !isVisible }, className);
|
|
40
|
-
return (_jsx(WithInteractions, { onVisible: handleOnVisible, onHidden: handleOnHidden, children: _jsx("div", Object.assign({ ref: localRef }, restProps, { className: joinedClassNames, style: Object.assign({ height: boxHeight || "auto" }, style), children: children })) }));
|
|
41
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export interface RenderOnVisibleProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
align?: "start" | "space" | "center" | "end";
|
|
4
|
-
fullWidth?: boolean;
|
|
5
|
-
onVisibilityChange?: (visible: boolean) => void;
|
|
6
|
-
onVisible?: () => void;
|
|
7
|
-
onHidden?: () => void;
|
|
8
|
-
children?: React.ReactNode;
|
|
9
|
-
}
|
|
10
|
-
export declare const RenderOnVisible: import("react").ForwardRefExoticComponent<RenderOnVisibleProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
15
|
-
import classNames from "classnames";
|
|
16
|
-
import boxingStyles from "../boxing.module.css";
|
|
17
|
-
import { WithInteractions } from "..";
|
|
18
|
-
export const RenderOnVisible = forwardRef(function RenderOnVisible(_a, forwardedRef) {
|
|
19
|
-
var { align, fullWidth = true, onVisibilityChange, onVisible, onHidden, className, style, children } = _a, restProps = __rest(_a, ["align", "fullWidth", "onVisibilityChange", "onVisible", "onHidden", "className", "style", "children"]);
|
|
20
|
-
const localRef = useRef(null);
|
|
21
|
-
// Let the parent access our DOM node
|
|
22
|
-
useImperativeHandle(forwardedRef, () => localRef.current);
|
|
23
|
-
const [boxHeight, setBoxHeight] = useState(0);
|
|
24
|
-
const isVisible = boxHeight === 0;
|
|
25
|
-
const handleOnVisible = () => {
|
|
26
|
-
setBoxHeight(0);
|
|
27
|
-
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(true);
|
|
28
|
-
onVisible === null || onVisible === void 0 ? void 0 : onVisible();
|
|
29
|
-
};
|
|
30
|
-
const handleOnHidden = () => {
|
|
31
|
-
if (localRef.current) {
|
|
32
|
-
const boxRect = localRef.current.getBoundingClientRect();
|
|
33
|
-
setBoxHeight(boxRect.height);
|
|
34
|
-
}
|
|
35
|
-
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(false);
|
|
36
|
-
onHidden === null || onHidden === void 0 ? void 0 : onHidden();
|
|
37
|
-
};
|
|
38
|
-
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { fullWidth: fullWidth }, className);
|
|
39
|
-
return (_jsx(WithInteractions, { onVisible: handleOnVisible, onHidden: handleOnHidden, children: _jsx("div", Object.assign({ ref: localRef }, restProps, { className: joinedClassNames, style: Object.assign({ height: boxHeight || "auto" }, style), children: isVisible && children })) }));
|
|
40
|
-
});
|