@yakad/ui 1.3.139 → 1.3.141
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 +33 -0
- package/dist/Button/Button.js +2 -2
- package/dist/LoadingIcon/LoadingIcon.js +1 -1
- package/dist/RenderByScroll/RenderByScroll.d.ts +11 -0
- package/dist/{RenderByVisibility/RenderByVisibility.js → RenderByScroll/RenderByScroll.js} +43 -26
- package/dist/Stack/Stack.d.ts +0 -1
- package/dist/Stack/Stack.js +2 -2
- package/dist/WithInteractions/WithInteractions.d.ts +3 -1
- package/dist/WithInteractions/WithInteractions.js +15 -14
- package/dist/WithOverlay/WithOverlay.d.ts +1 -3
- package/dist/WithOverlay/WithOverlay.js +13 -24
- package/dist/index.d.ts +4 -5
- package/dist/index.js +11 -13
- package/package.json +3 -3
- 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/RenderByVisibility/RenderByVisibility.d.ts +0 -9
- 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,33 @@
|
|
|
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, useImperativeHandle, useRef, useState, } from "react";
|
|
15
|
+
import { WithInteractions } from "..";
|
|
16
|
+
export const ActiveOnVisible = forwardRef(function ActiveOnVisible(_a, forwardedRef) {
|
|
17
|
+
var { style, children } = _a, restProps = __rest(_a, ["style", "children"]);
|
|
18
|
+
const localRef = useRef(null);
|
|
19
|
+
// Let the parent access our DOM node
|
|
20
|
+
useImperativeHandle(forwardedRef, () => localRef.current);
|
|
21
|
+
const [boxHeight, setBoxHeight] = useState(0);
|
|
22
|
+
const isVisible = boxHeight === 0;
|
|
23
|
+
const handleOnVisible = () => {
|
|
24
|
+
setBoxHeight(0);
|
|
25
|
+
};
|
|
26
|
+
const handleOnHidden = () => {
|
|
27
|
+
if (localRef.current) {
|
|
28
|
+
const boxRect = localRef.current.getBoundingClientRect();
|
|
29
|
+
setBoxHeight(boxRect.height);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return (_jsx(WithInteractions, Object.assign({ ref: localRef }, restProps, { style: Object.assign({ height: boxHeight || "auto" }, style), onVisible: handleOnVisible, onHidden: handleOnHidden, children: _jsx(Activity, { mode: isVisible ? "visible" : "hidden", children: children }) })));
|
|
33
|
+
});
|
package/dist/Button/Button.js
CHANGED
|
@@ -16,8 +16,8 @@ import { LoadingIcon } from "..";
|
|
|
16
16
|
import styles from "./Button.module.css";
|
|
17
17
|
export const Button = forwardRef(function Button(_a, ref) {
|
|
18
18
|
var { fullWidth = false, size = "medium", variant = "text", borderStyle = "rounded", icon, iconPosition = "start", loadingPosition = "auto", loadingVariant, className, children } = _a, restProps = __rest(_a, ["fullWidth", "size", "variant", "borderStyle", "icon", "iconPosition", "loadingPosition", "loadingVariant", "className", "children"]);
|
|
19
|
-
const childrenFirst =
|
|
20
|
-
const isloadingPositionCenter =
|
|
19
|
+
const childrenFirst = iconPosition === "end";
|
|
20
|
+
const isloadingPositionCenter = !icon || loadingPosition === "center";
|
|
21
21
|
const joinedClassNames = classNames({ fullWidth: fullWidth }, styles.button, styles[variant], { [styles.loading]: loadingVariant }, { [styles.loadingPositionCenter]: isloadingPositionCenter }, styles[size], styles[borderStyle], { [styles.iconButton]: !children && icon }, className);
|
|
22
22
|
return (_jsxs("button", Object.assign({ ref: ref, className: joinedClassNames }, restProps, { children: [childrenFirst && children, loadingVariant && (_jsx("div", { className: classNames(styles.displayOnDisabled, {
|
|
23
23
|
[styles.positionCenter]: isloadingPositionCenter,
|
|
@@ -14,7 +14,7 @@ import { forwardRef } from "react";
|
|
|
14
14
|
import classNames from "classnames";
|
|
15
15
|
import styles from "./LoadingIcon.module.css";
|
|
16
16
|
export const LoadingIcon = forwardRef(function LoadingIcon(_a, ref) {
|
|
17
|
-
var { size = "medium", variant = "
|
|
17
|
+
var { size = "medium", variant = "dots", className } = _a, restProps = __rest(_a, ["size", "variant", "className"]);
|
|
18
18
|
const joinedClassNames = classNames(styles.loadingIcon, styles[size], styles[variant], className);
|
|
19
19
|
return (_jsx("div", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: _jsx("div", {}) })));
|
|
20
20
|
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StackProps } from "..";
|
|
3
|
+
export interface RenderByScrollProps extends StackProps {
|
|
4
|
+
scrollMarginTop?: number;
|
|
5
|
+
extraRender?: number;
|
|
6
|
+
jumpToIndex?: number;
|
|
7
|
+
stopNewRenders?: boolean;
|
|
8
|
+
newChildRendered?: (index: number) => void;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare const RenderByScroll: React.ForwardRefExoticComponent<RenderByScrollProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -12,19 +12,21 @@ 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
|
-
export const
|
|
18
|
-
var {
|
|
17
|
+
export const RenderByScroll = forwardRef(function RenderByScroll(_a, ref) {
|
|
18
|
+
var { scrollMarginTop = 8, // Sticky Header Height
|
|
19
|
+
extraRender = 5, jumpToIndex = 0, stopNewRenders, newChildRendered, style, children } = _a, restProps = __rest(_a, ["scrollMarginTop", "extraRender", "jumpToIndex", "stopNewRenders", "newChildRendered", "style", "children"]);
|
|
20
|
+
const childrenArray = React.Children.toArray(children);
|
|
21
|
+
// Scroll Zone
|
|
19
22
|
const childRefs = useRef({});
|
|
20
|
-
const scrollTo = (i) => {
|
|
23
|
+
const scrollTo = (i, smooth) => {
|
|
21
24
|
var _a;
|
|
22
25
|
return (_a = childRefs.current[i]) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
23
|
-
behavior: "smooth",
|
|
26
|
+
behavior: smooth ? "smooth" : "auto",
|
|
24
27
|
});
|
|
25
28
|
};
|
|
26
|
-
|
|
27
|
-
// Collect Visibility Status
|
|
29
|
+
// Collect Visibled Childs
|
|
28
30
|
const [visibled, setVisibled] = useState({ lowest: jumpToIndex, highest: jumpToIndex });
|
|
29
31
|
const handleOnVisible = (i) => {
|
|
30
32
|
if (i < visibled.lowest)
|
|
@@ -32,44 +34,59 @@ export const RenderByVisibility = forwardRef(function RenderByVisibility(_a, ref
|
|
|
32
34
|
if (i > visibled.highest)
|
|
33
35
|
setVisibled(Object.assign(Object.assign({}, visibled), { highest: i }));
|
|
34
36
|
};
|
|
35
|
-
// Collect Rendered Childs
|
|
37
|
+
// Collect Rendered Childs
|
|
36
38
|
const [rendered, setRendered] = useState({ lowest: jumpToIndex, highest: jumpToIndex });
|
|
37
|
-
// Calculate Over Screen Renders
|
|
38
39
|
const overRenderedOnLowSide = visibled.lowest - rendered.lowest;
|
|
39
40
|
const overRenderedOnHighSide = rendered.highest - visibled.highest;
|
|
41
|
+
// Is Visible Loading Box
|
|
42
|
+
const [isVisibleLowSideLimitBox, setIsVisibleLowSideLimitBox] = useState(false);
|
|
40
43
|
// Render new Childs if needed
|
|
41
44
|
useEffect(() => {
|
|
42
45
|
if (!stopNewRenders) {
|
|
43
|
-
if (overRenderedOnHighSide
|
|
46
|
+
if (overRenderedOnHighSide < 1 ||
|
|
47
|
+
overRenderedOnHighSide - 1 <= overRenderedOnLowSide) {
|
|
44
48
|
if (rendered.highest < data.length &&
|
|
45
49
|
overRenderedOnHighSide < extraRender) {
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
const newHigh = rendered.highest + 1;
|
|
51
|
+
setRendered(Object.assign(Object.assign({}, rendered), { highest: newHigh }));
|
|
52
|
+
newChildRendered === null || newChildRendered === void 0 ? void 0 : newChildRendered(newHigh);
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
else {
|
|
51
56
|
if (rendered.lowest > 0 &&
|
|
52
57
|
overRenderedOnLowSide < extraRender) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
if (isVisibleLowSideLimitBox) {
|
|
59
|
+
scrollTo(rendered.lowest);
|
|
60
|
+
}
|
|
61
|
+
const newLow = rendered.lowest - 1;
|
|
62
|
+
setRendered(Object.assign(Object.assign({}, rendered), { lowest: newLow }));
|
|
63
|
+
newChildRendered === null || newChildRendered === void 0 ? void 0 : newChildRendered(newLow);
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
|
-
|
|
67
|
+
// eslint-disable-next-line
|
|
68
|
+
}, [visibled, rendered, extraRender, stopNewRenders]);
|
|
61
69
|
// Scroll to jumpToIndex
|
|
62
70
|
useEffect(() => {
|
|
63
|
-
|
|
64
|
-
(
|
|
65
|
-
|
|
71
|
+
const isJumpToIndexOutOfRenderedRange = jumpToIndex < rendered.lowest || jumpToIndex > rendered.highest;
|
|
72
|
+
if (isJumpToIndexOutOfRenderedRange) {
|
|
73
|
+
setVisibled({ lowest: jumpToIndex, highest: jumpToIndex });
|
|
74
|
+
setRendered({ lowest: jumpToIndex, highest: jumpToIndex });
|
|
75
|
+
}
|
|
76
|
+
const timeout = setTimeout(() => {
|
|
77
|
+
scrollTo(jumpToIndex, true);
|
|
78
|
+
}, 100);
|
|
79
|
+
return () => clearTimeout(timeout);
|
|
80
|
+
// eslint-disable-next-line
|
|
66
81
|
}, [jumpToIndex]);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
return (_jsxs(Stack, Object.assign({ ref: ref }, restProps, { style: Object.assign({ minHeight: "100vh" }, style), children: [rendered.lowest > 0 && (_jsx(WithInteractions, { style: {
|
|
83
|
+
height: "1px",
|
|
84
|
+
backgroundColor: "red",
|
|
85
|
+
marginBottom: `${scrollMarginTop}rem`,
|
|
86
|
+
}, onVisibilityChange: (v) => setIsVisibleLowSideLimitBox(v) })), childrenArray.map((child, i) => i >= rendered.lowest &&
|
|
71
87
|
i <= rendered.highest && (_jsx(WithInteractions, { ref: (el) => {
|
|
72
88
|
childRefs.current[i] = el;
|
|
73
|
-
}, onVisible: () => handleOnVisible(i),
|
|
89
|
+
}, onVisible: () => handleOnVisible(i), style: {
|
|
90
|
+
scrollMarginTop: `${scrollMarginTop}rem`,
|
|
91
|
+
}, children: child }, i)))] })));
|
|
74
92
|
});
|
|
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;
|
|
@@ -17,6 +18,7 @@ export interface WithInteractionsProps {
|
|
|
17
18
|
onVisibilityChange?: (visible: boolean) => void;
|
|
18
19
|
onVisible?: () => void;
|
|
19
20
|
onHidden?: () => void;
|
|
21
|
+
onMouseHoverChange?: (isHover: boolean, e: MouseEvent) => void;
|
|
20
22
|
onMouseHoverStart?: (e: MouseEvent) => void;
|
|
21
23
|
onMouseHoverLeave?: (e: MouseEvent) => void;
|
|
22
24
|
children?: React.ReactNode;
|
|
@@ -11,11 +11,10 @@ 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
|
|
18
|
-
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"]);
|
|
17
|
+
var { children, onRightClick, onTap, onDoubleTap, onOutsideClick, onSwipeLeft, onSwipeRight, onSwipeUp, onSwipeDown, onPinchIn, onPinchOut, onRotate, onScrollStart, onScrollStop, onResize, onVisibilityChange, onVisible, onHidden, onMouseHoverChange, onMouseHoverStart, onMouseHoverLeave } = _a, restProps = __rest(_a, ["children", "onRightClick", "onTap", "onDoubleTap", "onOutsideClick", "onSwipeLeft", "onSwipeRight", "onSwipeUp", "onSwipeDown", "onPinchIn", "onPinchOut", "onRotate", "onScrollStart", "onScrollStop", "onResize", "onVisibilityChange", "onVisible", "onHidden", "onMouseHoverChange", "onMouseHoverStart", "onMouseHoverLeave"]);
|
|
19
18
|
const localRef = useRef(null);
|
|
20
19
|
// Let the parent access our DOM node
|
|
21
20
|
useImperativeHandle(forwardedRef, () => localRef.current);
|
|
@@ -162,9 +161,16 @@ export const WithInteractions = forwardRef(function WithInteractions(_a, forward
|
|
|
162
161
|
}
|
|
163
162
|
// === On Hover Change ===
|
|
164
163
|
const hasFinePointer = window.matchMedia("(pointer: fine)").matches;
|
|
165
|
-
if (hasFinePointer &&
|
|
166
|
-
|
|
167
|
-
const
|
|
164
|
+
if (hasFinePointer &&
|
|
165
|
+
(onMouseHoverChange || onMouseHoverStart || onMouseHoverLeave)) {
|
|
166
|
+
const mouseEnter = (e) => {
|
|
167
|
+
onMouseHoverChange === null || onMouseHoverChange === void 0 ? void 0 : onMouseHoverChange(true, e);
|
|
168
|
+
onMouseHoverStart === null || onMouseHoverStart === void 0 ? void 0 : onMouseHoverStart(e);
|
|
169
|
+
};
|
|
170
|
+
const mouseLeave = (e) => {
|
|
171
|
+
onMouseHoverChange === null || onMouseHoverChange === void 0 ? void 0 : onMouseHoverChange(true, e);
|
|
172
|
+
onMouseHoverLeave === null || onMouseHoverLeave === void 0 ? void 0 : onMouseHoverLeave(e);
|
|
173
|
+
};
|
|
168
174
|
el.addEventListener("mouseenter", mouseEnter);
|
|
169
175
|
el.addEventListener("mouseleave", mouseLeave);
|
|
170
176
|
cleanupFns.push(() => {
|
|
@@ -212,14 +218,9 @@ export const WithInteractions = forwardRef(function WithInteractions(_a, forward
|
|
|
212
218
|
onVisibilityChange,
|
|
213
219
|
onVisible,
|
|
214
220
|
onHidden,
|
|
221
|
+
onMouseHoverChange,
|
|
215
222
|
onMouseHoverStart,
|
|
216
223
|
onMouseHoverLeave,
|
|
217
224
|
]);
|
|
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) }));
|
|
225
|
+
return (_jsx(Stack, Object.assign({ ref: localRef }, restProps, { children: children })));
|
|
225
226
|
});
|
|
@@ -8,9 +8,7 @@ type AllowedOverlays = React.ReactElement<PopupProps, typeof Popup> | React.Reac
|
|
|
8
8
|
export interface WithOverlayProps {
|
|
9
9
|
trigger?: "onClick" | "onRightClick";
|
|
10
10
|
overlay?: AllowedOverlays;
|
|
11
|
-
children?: React.ReactElement
|
|
12
|
-
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
13
|
-
}>;
|
|
11
|
+
children?: React.ReactElement;
|
|
14
12
|
}
|
|
15
13
|
export declare function WithOverlay({ trigger, overlay, children, }: WithOverlayProps): import("react/jsx-runtime").JSX.Element;
|
|
16
14
|
export {};
|
|
@@ -2,38 +2,27 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, cloneElement, useEffect, useRef } from "react";
|
|
4
4
|
import { WithInteractions, } from "..";
|
|
5
|
-
import { mergeRefs } from "@yakad/lib";
|
|
6
5
|
import { createPortal } from "react-dom";
|
|
7
6
|
export function WithOverlay({ trigger = "onClick", overlay, children, }) {
|
|
8
|
-
|
|
7
|
+
// Get Triggers ref and send to Overlay
|
|
9
8
|
const triggerRef = useRef(null);
|
|
10
9
|
const [showOverlay, setShowOverlay] = useState(false);
|
|
10
|
+
// Disable Body Scroll on showOverlay
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
document.body.style.overflow = showOverlay ? "hidden" : "initial";
|
|
13
13
|
return () => {
|
|
14
14
|
document.body.style.overflow = "initial";
|
|
15
15
|
};
|
|
16
16
|
}, [showOverlay]);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}) }), showOverlay &&
|
|
29
|
-
overlay &&
|
|
30
|
-
createPortal(cloneElement(overlay, {
|
|
31
|
-
triggerref: triggerRef,
|
|
32
|
-
onClose: () => {
|
|
33
|
-
var _a, _b;
|
|
34
|
-
(_b = (_a = overlay.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
35
|
-
setShowOverlay(false);
|
|
36
|
-
},
|
|
37
|
-
}), document.getElementsByClassName("portalRoot")[0] ||
|
|
38
|
-
document.body)] }));
|
|
17
|
+
// Teleport Overlay to portalRoot or body
|
|
18
|
+
const teleport = overlay &&
|
|
19
|
+
createPortal(cloneElement(overlay, {
|
|
20
|
+
triggerref: triggerRef,
|
|
21
|
+
onClose: () => {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
(_b = (_a = overlay.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
24
|
+
setShowOverlay(false);
|
|
25
|
+
},
|
|
26
|
+
}), document.getElementsByClassName("portalRoot")[0] || document.body);
|
|
27
|
+
return (_jsxs(_Fragment, { children: [_jsx(WithInteractions, { ref: triggerRef, onRightClick: () => trigger === "onRightClick" && setShowOverlay(true), onClick: () => trigger === "onClick" && setShowOverlay(true), children: children }), showOverlay && teleport] }));
|
|
39
28
|
}
|
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 "./RenderByScroll/RenderByScroll";
|
|
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 "./RenderByScroll/RenderByScroll"; // 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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yakad/ui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.141",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Natiq",
|
|
6
6
|
"description": "UI components for NextJS/React",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"classnames": "2.5.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"react": "^
|
|
40
|
-
"react-dom": "^
|
|
39
|
+
"react": "^19.2.0",
|
|
40
|
+
"react-dom": "^19.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/css-modules": "1.0.5",
|
|
@@ -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,9 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface RenderByVisibilityProps {
|
|
3
|
-
extraRender?: number;
|
|
4
|
-
jumpToIndex?: number;
|
|
5
|
-
stopNewRenders?: boolean;
|
|
6
|
-
newChildRendered?: (index: number) => void;
|
|
7
|
-
children?: React.ReactNode;
|
|
8
|
-
}
|
|
9
|
-
export declare const RenderByVisibility: React.ForwardRefExoticComponent<RenderByVisibilityProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -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
|
-
});
|