@yakad/ui 1.3.156 → 1.3.158
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 +1 -0
- package/dist/ActiveOnVisible/ActiveOnVisible.js +15 -13
- package/dist/Button/Button.js +2 -1
- package/dist/CheckBox/CheckBox.js +2 -1
- package/dist/CodeBox/CodeBox.js +2 -1
- package/dist/CodeField/CodeField.js +2 -1
- package/dist/Container/Container.js +1 -1
- package/dist/Display/Display.js +1 -1
- package/dist/Dropdown/Dropdown.js +5 -2
- package/dist/Form/Form.js +1 -1
- package/dist/GridItem/GridItem.js +1 -1
- package/dist/InputField/InputField.js +2 -1
- package/dist/List/List.js +2 -1
- package/dist/ListItem/ListItem.js +1 -1
- package/dist/Main/Main.js +1 -1
- package/dist/Navigation/Navigation.js +1 -1
- package/dist/Popup/Popup.js +8 -4
- package/dist/RenderByScroll/RenderByScroll.js +11 -7
- package/dist/Row/Row.js +1 -1
- package/dist/Screen/Screen.js +1 -1
- package/dist/Select/Select.js +2 -1
- package/dist/Stack/Stack.js +1 -1
- package/dist/Table/Table.js +2 -1
- package/dist/Theme/Theme.js +1 -1
- package/dist/WithOverlay/WithOverlay.d.ts +2 -2
- package/dist/WithOverlay/WithOverlay.js +14 -13
- package/dist/boxing.module.css +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +10 -1
- package/dist/interactionHooks/useOnDoubleTap.d.ts +2 -0
- package/dist/interactionHooks/useOnDoubleTap.js +23 -0
- package/dist/interactionHooks/useOnHoverChange.d.ts +2 -0
- package/dist/interactionHooks/useOnHoverChange.js +23 -0
- package/dist/interactionHooks/useOnOutsideClick.d.ts +2 -0
- package/dist/interactionHooks/useOnOutsideClick.js +21 -0
- package/dist/interactionHooks/useOnPinch.d.ts +2 -0
- package/dist/interactionHooks/useOnPinch.js +35 -0
- package/dist/interactionHooks/useOnResizeChange.d.ts +2 -0
- package/dist/interactionHooks/useOnResizeChange.js +23 -0
- package/dist/interactionHooks/useOnRightClick.d.ts +2 -0
- package/dist/interactionHooks/useOnRightClick.js +19 -0
- package/dist/interactionHooks/useOnRotate.d.ts +2 -0
- package/dist/interactionHooks/useOnRotate.js +36 -0
- package/dist/interactionHooks/useOnScroll.d.ts +2 -0
- package/dist/interactionHooks/useOnScroll.js +29 -0
- package/dist/interactionHooks/useOnSwipe.d.ts +2 -0
- package/dist/interactionHooks/useOnSwipe.js +53 -0
- package/dist/interactionHooks/useOnVisibilityChange.d.ts +2 -0
- package/dist/interactionHooks/useOnVisibilityChange.js +21 -0
- package/package.json +2 -2
- package/dist/WithInteractions/WithInteractions.d.ts +0 -25
- package/dist/WithInteractions/WithInteractions.js +0 -226
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { StackProps } from "..";
|
|
3
3
|
export interface ActiveOnVisibleProps extends StackProps {
|
|
4
|
+
onVisibilityChange?: (visible: boolean) => void;
|
|
4
5
|
}
|
|
5
6
|
export declare const ActiveOnVisible: import("react").ForwardRefExoticComponent<ActiveOnVisibleProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -11,23 +11,25 @@ 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, useImperativeHandle, useRef, useState } from "react";
|
|
15
|
+
import { Stack, useOnVisibilityChange } from "..";
|
|
16
16
|
export const ActiveOnVisible = forwardRef(function ActiveOnVisible(_a, forwardedRef) {
|
|
17
|
-
var { style, children } = _a, restProps = __rest(_a, ["style", "children"]);
|
|
17
|
+
var { onVisibilityChange, style, children } = _a, restProps = __rest(_a, ["onVisibilityChange", "style", "children"]);
|
|
18
18
|
const localRef = useRef(null);
|
|
19
|
+
const [boxHeight, setBoxHeight] = useState(0);
|
|
20
|
+
// const isVisible = boxHeight === 0;
|
|
19
21
|
// Let the parent access our DOM node
|
|
20
22
|
useImperativeHandle(forwardedRef, () => localRef.current);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const boxRect = localRef.current.getBoundingClientRect();
|
|
23
|
+
useOnVisibilityChange((visible) => {
|
|
24
|
+
var _a;
|
|
25
|
+
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(visible);
|
|
26
|
+
if (visible) {
|
|
27
|
+
setBoxHeight(0);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const boxRect = (_a = localRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
29
31
|
setBoxHeight(boxRect.height);
|
|
30
32
|
}
|
|
31
|
-
};
|
|
32
|
-
return (_jsx(
|
|
33
|
+
}, localRef);
|
|
34
|
+
return (_jsx(Stack, Object.assign({ ref: localRef }, restProps, { style: Object.assign({ height: boxHeight || "auto" }, style), children: children })));
|
|
33
35
|
});
|
package/dist/Button/Button.js
CHANGED
|
@@ -13,12 +13,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { forwardRef } from "react";
|
|
14
14
|
import classNames from "classnames";
|
|
15
15
|
import { LoadingIcon } from "..";
|
|
16
|
+
import boxingStyles from "../boxing.module.css";
|
|
16
17
|
import styles from "./Button.module.css";
|
|
17
18
|
export const Button = forwardRef(function Button(_a, ref) {
|
|
18
19
|
var { fullWidthOnParentDemand = false, size = "medium", variant = "text", borderStyle = "rounded", icon, iconPosition = "start", loadingPosition = "auto", loadingVariant, className, children } = _a, restProps = __rest(_a, ["fullWidthOnParentDemand", "size", "variant", "borderStyle", "icon", "iconPosition", "loadingPosition", "loadingVariant", "className", "children"]);
|
|
19
20
|
const childrenFirst = iconPosition === "end";
|
|
20
21
|
const isloadingPositionCenter = !icon || loadingPosition === "center";
|
|
21
|
-
const joinedClassNames = classNames({ fullWidthOnParentDemand: fullWidthOnParentDemand }, styles.button, styles[variant], { [styles.loading]: loadingVariant }, { [styles.loadingPositionCenter]: isloadingPositionCenter }, styles[size], styles[borderStyle], { [styles.iconButton]: !children && icon }, className);
|
|
22
|
+
const joinedClassNames = classNames({ [boxingStyles.fullWidthOnParentDemand]: fullWidthOnParentDemand }, styles.button, styles[variant], { [styles.loading]: loadingVariant }, { [styles.loadingPositionCenter]: isloadingPositionCenter }, styles[size], styles[borderStyle], { [styles.iconButton]: !children && icon }, className);
|
|
22
23
|
return (_jsxs("button", Object.assign({ ref: ref, className: joinedClassNames }, restProps, { children: [childrenFirst && children, loadingVariant && (_jsx("div", { className: classNames(styles.displayOnDisabled, {
|
|
23
24
|
[styles.positionCenter]: isloadingPositionCenter,
|
|
24
25
|
}), children: _jsx(LoadingIcon, { size: size, variant: loadingVariant }) })), icon, !childrenFirst && children] })));
|
|
@@ -13,9 +13,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { forwardRef } from "react";
|
|
14
14
|
import classNames from "classnames";
|
|
15
15
|
import { Symbol } from "@yakad/symbols";
|
|
16
|
+
import boxingStyles from "../boxing.module.css";
|
|
16
17
|
import styles from "./CheckBox.module.css";
|
|
17
18
|
export const CheckBox = forwardRef(function CheckBox(_a, ref) {
|
|
18
19
|
var { label, className, style } = _a, restProps = __rest(_a, ["label", "className", "style"]);
|
|
19
|
-
const joinedClassNames = classNames({ fullWidthOnParentDemand: label }, styles.label, { [styles.labeled]: label }, { [styles.disabled]: restProps.disabled }, className);
|
|
20
|
+
const joinedClassNames = classNames({ [boxingStyles.fullWidthOnParentDemand]: label }, styles.label, { [styles.labeled]: label }, { [styles.disabled]: restProps.disabled }, className);
|
|
20
21
|
return (_jsxs("label", { className: joinedClassNames, style: style, children: [label, _jsx("input", Object.assign({ ref: ref }, restProps, { className: styles.input, type: "checkbox" })), _jsxs("div", { className: styles.symbolContainer, children: [_jsx(Symbol, { className: styles.symbolChecked, icon: "check_box" }), _jsx(Symbol, { className: styles.symbolUnChecked, icon: "check_box_outline_blank" })] })] }));
|
|
21
22
|
});
|
package/dist/CodeBox/CodeBox.js
CHANGED
|
@@ -14,9 +14,10 @@ import { forwardRef } from "react";
|
|
|
14
14
|
import classNames from "classnames";
|
|
15
15
|
import { Symbol } from "@yakad/symbols";
|
|
16
16
|
import { Button, Card } from "..";
|
|
17
|
+
import boxingStyles from "../boxing.module.css";
|
|
17
18
|
import styles from "./CodeBox.module.css";
|
|
18
19
|
export const CodeBox = forwardRef(function CodeBox(_a, ref) {
|
|
19
20
|
var { copyButton, className, children } = _a, restProps = __rest(_a, ["copyButton", "className", "children"]);
|
|
20
|
-
const joinedClassNames = classNames({ fullWidthOnParentDemand: true }, styles.ZZZZZZZZZZ, className);
|
|
21
|
+
const joinedClassNames = classNames({ [boxingStyles.fullWidthOnParentDemand]: true }, styles.ZZZZZZZZZZ, className);
|
|
21
22
|
return (_jsxs(Card, Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: [_jsx("pre", { children: children }), copyButton && _jsx(Button, { icon: _jsx(Symbol, { icon: "copy_all" }) })] })));
|
|
22
23
|
});
|
|
@@ -13,6 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { forwardRef } from "react";
|
|
15
15
|
import classNames from "classnames";
|
|
16
|
+
import boxingStyles from "../boxing.module.css";
|
|
16
17
|
import styles from "./CodeField.module.css";
|
|
17
18
|
function isInputFilled(event, inputLength) {
|
|
18
19
|
const targetInputElement = event.target;
|
|
@@ -32,7 +33,7 @@ function removeUnNumberChars(inputElement) {
|
|
|
32
33
|
}
|
|
33
34
|
export const CodeField = forwardRef(function CodeField(_a, ref) {
|
|
34
35
|
var { length = 6, onFilled, autoComplete, pattern, onInput, className, style } = _a, restProps = __rest(_a, ["length", "onFilled", "autoComplete", "pattern", "onInput", "className", "style"]);
|
|
35
|
-
const joinedClassNames = classNames({ fullWidthOnParentDemand: true }, styles.input, className);
|
|
36
|
+
const joinedClassNames = classNames({ [boxingStyles.fullWidthOnParentDemand]: true }, styles.input, className);
|
|
36
37
|
const joinedStyles = Object.assign(Object.assign({}, style), { width: `calc(1.5ch * ${length})` });
|
|
37
38
|
return (_jsx("input", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, style: joinedStyles, type: "number", minLength: length, maxLength: length, autoComplete: autoComplete || "off", pattern: pattern || "[0-9]", onInput: (event) => {
|
|
38
39
|
isInputFilled(event, length) && onFilled;
|
|
@@ -16,6 +16,6 @@ import boxingStyles from "../boxing.module.css";
|
|
|
16
16
|
import styles from "./Container.module.css";
|
|
17
17
|
export const Container = forwardRef(function Container(_a, ref) {
|
|
18
18
|
var { size = "xl", align, className, children } = _a, restProps = __rest(_a, ["size", "align", "className", "children"]);
|
|
19
|
-
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { demandChildsToBeFullWidth: true }, styles.container, styles[size], className);
|
|
19
|
+
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { [boxingStyles.demandChildsToBeFullWidth]: true }, styles.container, styles[size], className);
|
|
20
20
|
return (_jsx("div", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
21
21
|
});
|
package/dist/Display/Display.js
CHANGED
|
@@ -16,6 +16,6 @@ import boxingStyles from "../boxing.module.css";
|
|
|
16
16
|
import styles from "./Display.module.css";
|
|
17
17
|
export const Display = forwardRef(function Display(_a, ref) {
|
|
18
18
|
var { align, fullWidthOnParentDemand = true, minWidth, maxWidth, className, children } = _a, restProps = __rest(_a, ["align", "fullWidthOnParentDemand", "minWidth", "maxWidth", "className", "children"]);
|
|
19
|
-
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { demandChildsToBeFullWidth: true }, { fullWidthOnParentDemand: fullWidthOnParentDemand }, { [styles[`${minWidth}MinWidth`]]: minWidth }, { [styles[`${maxWidth}MaxWidth`]]: maxWidth }, className);
|
|
19
|
+
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { [boxingStyles.demandChildsToBeFullWidth]: true }, { [boxingStyles.fullWidthOnParentDemand]: fullWidthOnParentDemand }, { [styles[`${minWidth}MinWidth`]]: minWidth }, { [styles[`${maxWidth}MaxWidth`]]: maxWidth }, className);
|
|
20
20
|
return (_jsx("div", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
21
21
|
});
|
|
@@ -13,7 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { useRef, useState, useEffect, forwardRef, useImperativeHandle, } from "react";
|
|
15
15
|
import classNames from "classnames";
|
|
16
|
-
import { Card,
|
|
16
|
+
import { Card, useOnOutsideClick } from "..";
|
|
17
17
|
import styles from "./Dropdown.module.css";
|
|
18
18
|
export const Dropdown = forwardRef(function Dropdown(_a, forwardedRef) {
|
|
19
19
|
var { fullWidthOnParentDemand = false, // Def in Card is True
|
|
@@ -72,7 +72,10 @@ export const Dropdown = forwardRef(function Dropdown(_a, forwardedRef) {
|
|
|
72
72
|
setIsPlaced(true);
|
|
73
73
|
}
|
|
74
74
|
}, [children, placementTargetRef]);
|
|
75
|
-
|
|
75
|
+
useOnOutsideClick(() => {
|
|
76
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
77
|
+
}, dropdownRef);
|
|
78
|
+
return (_jsxs(_Fragment, { children: [!triggerref && _jsx("div", { ref: fallbackTriggerRef }), _jsx(Card, Object.assign({ ref: dropdownRef, fullWidthOnParentDemand: fullWidthOnParentDemand, blur: blur, level: level }, restProps, { className: classNames(styles.dropdownCard, { [styles.isPlacedAbove]: isPlacedAbove }, className), style: Object.assign({ top: dropdownPosition.top, left: dropdownPosition.left, visibility: isPlaced ? "visible" : "hidden" }, style), children: children })), _jsx("span", { className: classNames(styles.arrow, {
|
|
76
79
|
[styles.isPlacedAbove]: isPlacedAbove,
|
|
77
80
|
}, { [styles.blur]: blur }), style: {
|
|
78
81
|
top: arrowPosition.top,
|
package/dist/Form/Form.js
CHANGED
|
@@ -16,6 +16,6 @@ import styles from "./Form.module.css";
|
|
|
16
16
|
import boxingStyles from "../boxing.module.css";
|
|
17
17
|
export const Form = forwardRef(function Form(_a, ref) {
|
|
18
18
|
var { align, fullWidthOnParentDemand = true, className, children } = _a, restProps = __rest(_a, ["align", "fullWidthOnParentDemand", "className", "children"]);
|
|
19
|
-
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { demandChildsToBeFullWidth: true }, { fullWidthOnParentDemand: fullWidthOnParentDemand }, styles.form, className);
|
|
19
|
+
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { [boxingStyles.demandChildsToBeFullWidth]: true }, { [boxingStyles.fullWidthOnParentDemand]: fullWidthOnParentDemand }, styles.form, className);
|
|
20
20
|
return (_jsx("form", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
21
21
|
});
|
|
@@ -16,6 +16,6 @@ import boxingStyles from "../boxing.module.css";
|
|
|
16
16
|
import styles from "./GridItem.module.css";
|
|
17
17
|
export const GridItem = forwardRef(function GridItem(_a, ref) {
|
|
18
18
|
var { align, xs, sm, md, lg, xl, className, children } = _a, restProps = __rest(_a, ["align", "xs", "sm", "md", "lg", "xl", "className", "children"]);
|
|
19
|
-
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { demandChildsToBeFullWidth: true }, styles.gridItem, { [styles[`xs${xs}`]]: xs }, { [styles[`sm${sm}`]]: sm }, { [styles[`md${md}`]]: md }, { [styles[`lg${lg}`]]: lg }, { [styles[`xl${xl}`]]: xl }, className);
|
|
19
|
+
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { [boxingStyles.demandChildsToBeFullWidth]: true }, styles.gridItem, { [styles[`xs${xs}`]]: xs }, { [styles[`sm${sm}`]]: sm }, { [styles[`md${md}`]]: md }, { [styles[`lg${lg}`]]: lg }, { [styles[`xl${xl}`]]: xl }, className);
|
|
20
20
|
return (_jsx("div", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
21
21
|
});
|
|
@@ -12,9 +12,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { forwardRef } from "react";
|
|
14
14
|
import classNames from "classnames";
|
|
15
|
+
import boxingStyles from "../boxing.module.css";
|
|
15
16
|
import styles from "./InputField.module.css";
|
|
16
17
|
export const InputField = forwardRef(function InputField(_a, ref) {
|
|
17
18
|
var { variant = "outlined", boxSize = "normal", placeholder, className } = _a, restProps = __rest(_a, ["variant", "boxSize", "placeholder", "className"]);
|
|
18
19
|
const joinedClassNames = classNames(styles.input, styles[variant], styles[boxSize], placeholder && styles.havePlaceHolder, className);
|
|
19
|
-
return (_jsxs("div", { className: classNames({ fullWidthOnParentDemand: true }, styles.div), children: [_jsx("input", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, placeholder: " " })), placeholder && (_jsx("label", { className: styles.label, children: placeholder }))] }));
|
|
20
|
+
return (_jsxs("div", { className: classNames({ [boxingStyles.fullWidthOnParentDemand]: true }, styles.div), children: [_jsx("input", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, placeholder: " " })), placeholder && (_jsx("label", { className: styles.label, children: placeholder }))] }));
|
|
20
21
|
});
|
package/dist/List/List.js
CHANGED
|
@@ -12,9 +12,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { forwardRef } from "react";
|
|
14
14
|
import classNames from "classnames";
|
|
15
|
+
import boxingStyles from "../boxing.module.css";
|
|
15
16
|
import styles from "./List.module.css";
|
|
16
17
|
export const List = forwardRef(function List(_a, ref) {
|
|
17
18
|
var { direction = "row", collapsed, className, children } = _a, restProps = __rest(_a, ["direction", "collapsed", "className", "children"]);
|
|
18
|
-
const joinedClassNames = classNames({ fullWidthOnParentDemand: true }, styles.list, styles[direction], { [styles.collapsed]: collapsed }, className);
|
|
19
|
+
const joinedClassNames = classNames({ [boxingStyles.fullWidthOnParentDemand]: true }, styles.list, styles[direction], { [styles.collapsed]: collapsed }, className);
|
|
19
20
|
return (_jsx("ul", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
20
21
|
});
|
|
@@ -16,5 +16,5 @@ import boxingStyles from "../boxing.module.css";
|
|
|
16
16
|
import styles from "./ListItem.module.css";
|
|
17
17
|
export const ListItem = forwardRef(function ListItem(_a, ref) {
|
|
18
18
|
var { align, className, children } = _a, restProps = __rest(_a, ["align", "className", "children"]);
|
|
19
|
-
return (_jsx("li", Object.assign({ ref: ref }, restProps, { className: classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { demandChildsToBeFullWidth: true }, styles.listItem, className), children: children })));
|
|
19
|
+
return (_jsx("li", Object.assign({ ref: ref }, restProps, { className: classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { [boxingStyles.demandChildsToBeFullWidth]: true }, styles.listItem, className), children: children })));
|
|
20
20
|
});
|
package/dist/Main/Main.js
CHANGED
|
@@ -16,6 +16,6 @@ import boxingStyles from "../boxing.module.css";
|
|
|
16
16
|
import styles from "./Main.module.css";
|
|
17
17
|
export const Main = forwardRef(function Main(_a, ref) {
|
|
18
18
|
var { align, navOpen = false, className, children } = _a, restProps = __rest(_a, ["align", "navOpen", "className", "children"]);
|
|
19
|
-
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { demandChildsToBeFullWidth: true }, styles.main, { [styles.navOpen]: navOpen }, className);
|
|
19
|
+
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { [boxingStyles.demandChildsToBeFullWidth]: true }, styles.main, { [styles.navOpen]: navOpen }, className);
|
|
20
20
|
return (_jsx("main", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
21
21
|
});
|
|
@@ -16,7 +16,7 @@ import boxingStyles from "../boxing.module.css";
|
|
|
16
16
|
import styles from "./Navigation.module.css";
|
|
17
17
|
export const Navigation = forwardRef(function Navigation(_a, ref) {
|
|
18
18
|
var { align, anchor = "auto", open = false, className, children } = _a, restProps = __rest(_a, ["align", "anchor", "open", "className", "children"]);
|
|
19
|
-
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { demandChildsToBeFullWidth: true }, styles.navigation, styles[anchor], {
|
|
19
|
+
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { [boxingStyles.demandChildsToBeFullWidth]: true }, styles.navigation, styles[anchor], {
|
|
20
20
|
[styles.open]: open,
|
|
21
21
|
}, className);
|
|
22
22
|
return (_jsx("nav", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
package/dist/Popup/Popup.js
CHANGED
|
@@ -11,12 +11,16 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { forwardRef } from "react";
|
|
14
|
+
import { forwardRef, useImperativeHandle } from "react";
|
|
15
15
|
import classNames from "classnames";
|
|
16
16
|
import { Symbol } from "@yakad/symbols";
|
|
17
|
-
import { Button, Card, Row, Screen, Spacer, Stack, Text,
|
|
17
|
+
import { Button, Card, Row, Screen, Spacer, Stack, Text, useOnOutsideClick, } from "..";
|
|
18
18
|
import styles from "./Popup.module.css";
|
|
19
|
-
export const Popup = forwardRef(function Popup(_a,
|
|
19
|
+
export const Popup = forwardRef(function Popup(_a, forwardedRef) {
|
|
20
20
|
var { align, onClose, heading, className, children } = _a, restProps = __rest(_a, ["align", "onClose", "heading", "className", "children"]);
|
|
21
|
-
|
|
21
|
+
const localRef = useOnOutsideClick(() => {
|
|
22
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
23
|
+
});
|
|
24
|
+
useImperativeHandle(forwardedRef, () => localRef.current);
|
|
25
|
+
return (_jsx(Screen, { align: "center", className: styles.popupscreen, children: _jsxs(Card, Object.assign({ ref: localRef }, restProps, { className: classNames(styles.popup, className), children: [_jsxs(Row, { style: { marginBottom: "2rem" }, children: [_jsx(Text, { variant: "heading4", children: heading }), _jsx(Spacer, {}), _jsx(Button, { title: "Close", icon: _jsx(Symbol, { icon: "close" }), onClick: onClose })] }), _jsx(Stack, { align: align, style: { width: "100%", overflowY: "auto" }, children: children })] })) }));
|
|
22
26
|
});
|
|
@@ -12,8 +12,7 @@ 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 { Stack,
|
|
16
|
-
const data = Array.from({ length: 78 });
|
|
15
|
+
import { ActiveOnVisible, Stack, useOnVisibilityChange } from "..";
|
|
17
16
|
export const RenderByScroll = forwardRef(function RenderByScroll(_a, ref) {
|
|
18
17
|
var { scrollMarginTop = 8, // Sticky Header Height
|
|
19
18
|
extraRender = 5, jumpToIndex = 0, stopNewRenders, newChildRendered, style, children } = _a, restProps = __rest(_a, ["scrollMarginTop", "extraRender", "jumpToIndex", "stopNewRenders", "newChildRendered", "style", "children"]);
|
|
@@ -44,7 +43,7 @@ export const RenderByScroll = forwardRef(function RenderByScroll(_a, ref) {
|
|
|
44
43
|
useEffect(() => {
|
|
45
44
|
const isPriorityBYHighSide = overRenderedOnHighSide < 1 ||
|
|
46
45
|
overRenderedOnHighSide - 1 <= overRenderedOnLowSide;
|
|
47
|
-
const isHighSideNewRenderRemains = rendered.highest <
|
|
46
|
+
const isHighSideNewRenderRemains = rendered.highest < childrenArray.length - 1;
|
|
48
47
|
const isLowSideNewRenderRemains = rendered.lowest > 0;
|
|
49
48
|
if (!stopNewRenders) {
|
|
50
49
|
if (isPriorityBYHighSide &&
|
|
@@ -81,12 +80,17 @@ export const RenderByScroll = forwardRef(function RenderByScroll(_a, ref) {
|
|
|
81
80
|
return () => clearTimeout(timeout);
|
|
82
81
|
// eslint-disable-next-line
|
|
83
82
|
}, [jumpToIndex]);
|
|
84
|
-
|
|
83
|
+
const onvisibRef = useOnVisibilityChange((visible) => {
|
|
84
|
+
setIsVisibleLowSideLimitSensor(visible);
|
|
85
|
+
});
|
|
86
|
+
return (_jsxs(Stack, Object.assign({ ref: ref }, restProps, { style: Object.assign({ minHeight: "100vh" }, style), children: [rendered.lowest > 0 && (_jsx("div", { ref: onvisibRef, style: {
|
|
85
87
|
marginBottom: `${scrollMarginTop}rem`,
|
|
86
|
-
}
|
|
87
|
-
i <= rendered.highest && (_jsx(
|
|
88
|
+
} })), childrenArray.map((child, i) => i >= rendered.lowest &&
|
|
89
|
+
i <= rendered.highest && (_jsx(ActiveOnVisible, { ref: (el) => {
|
|
88
90
|
childRefs.current[i] = el;
|
|
89
91
|
}, style: {
|
|
90
92
|
scrollMarginTop: `${scrollMarginTop}rem`,
|
|
91
|
-
},
|
|
93
|
+
}, onVisibilityChange: (visible) => {
|
|
94
|
+
visible && handleOnVisible(i);
|
|
95
|
+
}, children: child }, i)))] })));
|
|
92
96
|
});
|
package/dist/Row/Row.js
CHANGED
|
@@ -16,6 +16,6 @@ import boxingStyles from "../boxing.module.css";
|
|
|
16
16
|
import styles from "./Row.module.css";
|
|
17
17
|
export const Row = forwardRef(function Row(_a, ref) {
|
|
18
18
|
var { align, fullWidthOnParentDemand = true, overflow = "shrink", size = "xl", className, children } = _a, restProps = __rest(_a, ["align", "fullWidthOnParentDemand", "overflow", "size", "className", "children"]);
|
|
19
|
-
const joinedClassNames = classNames(boxingStyles.flexRowBox, { [boxingStyles[align]]: align }, boxingStyles[overflow], styles.row, { fullWidthOnParentDemand: fullWidthOnParentDemand }, styles[size], className);
|
|
19
|
+
const joinedClassNames = classNames(boxingStyles.flexRowBox, { [boxingStyles[align]]: align }, boxingStyles[overflow], styles.row, { [boxingStyles.fullWidthOnParentDemand]: fullWidthOnParentDemand }, styles[size], className);
|
|
20
20
|
return (_jsx("div", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
21
21
|
});
|
package/dist/Screen/Screen.js
CHANGED
|
@@ -16,6 +16,6 @@ import boxingStyles from "../boxing.module.css";
|
|
|
16
16
|
import styles from "./Screen.module.css";
|
|
17
17
|
export const Screen = forwardRef(function Screen(_a, ref) {
|
|
18
18
|
var { align, className, children } = _a, restProps = __rest(_a, ["align", "className", "children"]);
|
|
19
|
-
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { demandChildsToBeFullWidth: true }, styles.screen, className);
|
|
19
|
+
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { [boxingStyles.demandChildsToBeFullWidth]: true }, styles.screen, className);
|
|
20
20
|
return (_jsx("div", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
21
21
|
});
|
package/dist/Select/Select.js
CHANGED
|
@@ -12,10 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { forwardRef } from "react";
|
|
14
14
|
import classNames from "classnames";
|
|
15
|
+
import boxingStyles from "../boxing.module.css";
|
|
15
16
|
import styles from "./Select.module.css";
|
|
16
17
|
import inputStyles from "../InputField/InputField.module.css";
|
|
17
18
|
export const Select = forwardRef(function Select(_a, ref) {
|
|
18
19
|
var { variant = "outlined", boxsize = "normal", placeholder, className, children } = _a, restProps = __rest(_a, ["variant", "boxsize", "placeholder", "className", "children"]);
|
|
19
20
|
const joinedClassNames = classNames(styles.select, inputStyles.input, inputStyles[variant], inputStyles[boxsize], { [inputStyles.havePlaceHolder]: placeholder }, className);
|
|
20
|
-
return (_jsxs("div", { className: classNames({ fullWidthOnParentDemand: true }, inputStyles.div), children: [_jsx("select", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })), placeholder ? (_jsx("label", { className: inputStyles.label, children: placeholder })) : null] }));
|
|
21
|
+
return (_jsxs("div", { className: classNames({ [boxingStyles.fullWidthOnParentDemand]: true }, inputStyles.div), children: [_jsx("select", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })), placeholder ? (_jsx("label", { className: inputStyles.label, children: placeholder })) : null] }));
|
|
21
22
|
});
|
package/dist/Stack/Stack.js
CHANGED
|
@@ -16,6 +16,6 @@ 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
18
|
var { align, fullWidthOnParentDemand = true, className, children } = _a, restProps = __rest(_a, ["align", "fullWidthOnParentDemand", "className", "children"]);
|
|
19
|
-
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { demandChildsToBeFullWidth: true }, { fullWidthOnParentDemand: fullWidthOnParentDemand }, styles.stack, className);
|
|
19
|
+
const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { [boxingStyles.demandChildsToBeFullWidth]: true }, { [boxingStyles.fullWidthOnParentDemand]: fullWidthOnParentDemand }, styles.stack, className);
|
|
20
20
|
return (_jsx("div", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
21
21
|
});
|
package/dist/Table/Table.js
CHANGED
|
@@ -12,10 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { forwardRef } from "react";
|
|
14
14
|
import classNames from "classnames";
|
|
15
|
+
import boxingStyles from "../boxing.module.css";
|
|
15
16
|
import styles from "./Table.module.css";
|
|
16
17
|
export const Table = forwardRef(function Table(_a, ref) {
|
|
17
18
|
var { className, children } = _a, restProps = __rest(_a, ["className", "children"]);
|
|
18
|
-
const joinedClassNames = classNames({ fullWidthOnParentDemand: true }, styles.table, className);
|
|
19
|
+
const joinedClassNames = classNames({ [boxingStyles.fullWidthOnParentDemand]: true }, styles.table, className);
|
|
19
20
|
return (_jsx("table", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
20
21
|
});
|
|
21
22
|
export const Thead = forwardRef(function Thead(_a, ref) {
|
package/dist/Theme/Theme.js
CHANGED
|
@@ -22,6 +22,6 @@ export const Theme = forwardRef(function Theme(_a, ref) {
|
|
|
22
22
|
useEffect(() => {
|
|
23
23
|
document.documentElement.style.setProperty("font-size", zoomPercentage + "%");
|
|
24
24
|
}, [zoomPercentage]);
|
|
25
|
-
const joinedClassNames = classNames({ portalRoot: true }, boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { demandChildsToBeFullWidth: true }, styles.theme, styles[darkStyle], styles[color], className);
|
|
25
|
+
const joinedClassNames = classNames({ portalRoot: true }, boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, { [boxingStyles.demandChildsToBeFullWidth]: true }, styles.theme, styles[darkStyle], styles[color], className);
|
|
26
26
|
return (_jsx("div", Object.assign({ ref: ref }, restProps, { className: joinedClassNames, children: children })));
|
|
27
27
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RefObject } from "react";
|
|
2
|
-
import { Dropdown, DropdownProps, Popup, PopupProps,
|
|
2
|
+
import { Dropdown, DropdownProps, Popup, PopupProps, StackProps } from "..";
|
|
3
3
|
export interface OverlayProps {
|
|
4
4
|
triggerref?: RefObject<HTMLElement | null>;
|
|
5
5
|
onClose?: () => void;
|
|
6
6
|
}
|
|
7
7
|
type AllowedOverlays = React.ReactElement<PopupProps, typeof Popup> | React.ReactElement<DropdownProps, typeof Dropdown>;
|
|
8
|
-
export interface WithOverlayProps extends
|
|
8
|
+
export interface WithOverlayProps extends StackProps {
|
|
9
9
|
trigger?: "onClick" | "onRightClick";
|
|
10
10
|
overlay?: AllowedOverlays;
|
|
11
11
|
children?: React.ReactElement;
|
|
@@ -13,14 +13,21 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { useState, cloneElement, useEffect, useRef, forwardRef, useImperativeHandle, } from "react";
|
|
15
15
|
import { createPortal } from "react-dom";
|
|
16
|
-
import {
|
|
16
|
+
import { Stack, useOnRightClick, } from "..";
|
|
17
17
|
export const WithOverlay = forwardRef(function WithOverlay(_a, forwardedRef) {
|
|
18
|
-
var { trigger = "onClick", overlay, children,
|
|
18
|
+
var { trigger = "onClick", overlay, children, onClick } = _a, restProps = __rest(_a, ["trigger", "overlay", "children", "onClick"]);
|
|
19
19
|
// Get Triggers ref and send to Overlay
|
|
20
|
-
const
|
|
21
|
-
// Let the parent access our DOM node
|
|
22
|
-
useImperativeHandle(forwardedRef, () => triggerRef.current);
|
|
20
|
+
const localRef = useRef(null);
|
|
23
21
|
const [showOverlay, setShowOverlay] = useState(false);
|
|
22
|
+
useOnRightClick(() => {
|
|
23
|
+
setShowOverlay(true);
|
|
24
|
+
}, localRef);
|
|
25
|
+
const onClickHandler = (e) => {
|
|
26
|
+
trigger === "onClick" && setShowOverlay((prev) => !prev);
|
|
27
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
28
|
+
};
|
|
29
|
+
// Let the parent access our DOM node
|
|
30
|
+
useImperativeHandle(forwardedRef, () => localRef.current);
|
|
24
31
|
// Disable Body Scroll on showOverlay
|
|
25
32
|
useEffect(() => {
|
|
26
33
|
document.body.style.overflow = showOverlay ? "hidden" : "initial";
|
|
@@ -33,18 +40,12 @@ export const WithOverlay = forwardRef(function WithOverlay(_a, forwardedRef) {
|
|
|
33
40
|
const teleport = overlay &&
|
|
34
41
|
portalRoot &&
|
|
35
42
|
createPortal(cloneElement(overlay, {
|
|
36
|
-
triggerref:
|
|
43
|
+
triggerref: localRef,
|
|
37
44
|
onClose: () => {
|
|
38
45
|
var _a, _b;
|
|
39
46
|
(_b = (_a = overlay.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
40
47
|
setShowOverlay(false);
|
|
41
48
|
},
|
|
42
49
|
}), portalRoot);
|
|
43
|
-
return (_jsxs(_Fragment, { children: [_jsx(
|
|
44
|
-
trigger === "onRightClick" && setShowOverlay(true);
|
|
45
|
-
onRightClick === null || onRightClick === void 0 ? void 0 : onRightClick(e);
|
|
46
|
-
}, onClick: (e) => {
|
|
47
|
-
trigger === "onClick" && setShowOverlay(true);
|
|
48
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
49
|
-
}, children: children })), showOverlay && teleport] }));
|
|
50
|
+
return (_jsxs(_Fragment, { children: [_jsx(Stack, Object.assign({ ref: localRef }, restProps, { onClick: onClickHandler, children: children })), showOverlay && teleport] }));
|
|
50
51
|
});
|
package/dist/boxing.module.css
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -29,9 +29,18 @@ export * from "./RadioButton/RadioButton";
|
|
|
29
29
|
export * from "./CodeBox/CodeBox";
|
|
30
30
|
export * from "./Display/Display";
|
|
31
31
|
export * from "./WithOverlay/WithOverlay";
|
|
32
|
-
export * from "./WithInteractions/WithInteractions";
|
|
33
32
|
export * from "./RenderByScroll/RenderByScroll";
|
|
34
33
|
export * from "./ActiveOnVisible/ActiveOnVisible";
|
|
35
34
|
export * from "./Dropdown/Dropdown";
|
|
36
35
|
export * from "./Popup/Popup";
|
|
37
36
|
export * from "./Avatar/Avatar";
|
|
37
|
+
export * from "./interactionHooks/useOnRightClick";
|
|
38
|
+
export * from "./interactionHooks/useOnOutsideClick";
|
|
39
|
+
export * from "./interactionHooks/useOnDoubleTap";
|
|
40
|
+
export * from "./interactionHooks/useOnSwipe";
|
|
41
|
+
export * from "./interactionHooks/useOnPinch";
|
|
42
|
+
export * from "./interactionHooks/useOnRotate";
|
|
43
|
+
export * from "./interactionHooks/useOnResizeChange";
|
|
44
|
+
export * from "./interactionHooks/useOnVisibilityChange";
|
|
45
|
+
export * from "./interactionHooks/useOnHoverChange";
|
|
46
|
+
export * from "./interactionHooks/useOnScroll";
|
package/dist/index.js
CHANGED
|
@@ -34,10 +34,19 @@ export * from "./CodeBox/CodeBox";
|
|
|
34
34
|
// Utilities
|
|
35
35
|
export * from "./Display/Display"; // Stack Based
|
|
36
36
|
export * from "./WithOverlay/WithOverlay";
|
|
37
|
-
export * from "./WithInteractions/WithInteractions"; // Stack Based
|
|
38
37
|
export * from "./RenderByScroll/RenderByScroll"; // Stack Based
|
|
39
38
|
export * from "./ActiveOnVisible/ActiveOnVisible"; // Stack Based
|
|
40
39
|
// Overlays
|
|
41
40
|
export * from "./Dropdown/Dropdown"; // Card Based
|
|
42
41
|
export * from "./Popup/Popup"; // Card Based
|
|
43
42
|
export * from "./Avatar/Avatar";
|
|
43
|
+
export * from "./interactionHooks/useOnRightClick";
|
|
44
|
+
export * from "./interactionHooks/useOnOutsideClick";
|
|
45
|
+
export * from "./interactionHooks/useOnDoubleTap";
|
|
46
|
+
export * from "./interactionHooks/useOnSwipe";
|
|
47
|
+
export * from "./interactionHooks/useOnPinch";
|
|
48
|
+
export * from "./interactionHooks/useOnRotate";
|
|
49
|
+
export * from "./interactionHooks/useOnResizeChange";
|
|
50
|
+
export * from "./interactionHooks/useOnVisibilityChange";
|
|
51
|
+
export * from "./interactionHooks/useOnHoverChange";
|
|
52
|
+
export * from "./interactionHooks/useOnScroll";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
export function useOnDoubleTap(callback, ref) {
|
|
3
|
+
const defaultRef = useRef(null);
|
|
4
|
+
const targetRef = ref !== null && ref !== void 0 ? ref : defaultRef;
|
|
5
|
+
const [lastTap, setLastTap] = useState(0);
|
|
6
|
+
const handleDoubleTap = useCallback((e) => {
|
|
7
|
+
const now = Date.now();
|
|
8
|
+
if (now - lastTap < 300) {
|
|
9
|
+
callback(e);
|
|
10
|
+
}
|
|
11
|
+
setLastTap(now);
|
|
12
|
+
}, [callback, lastTap]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const element = targetRef.current;
|
|
15
|
+
if (!element)
|
|
16
|
+
return;
|
|
17
|
+
element.addEventListener("touchend", handleDoubleTap);
|
|
18
|
+
return () => {
|
|
19
|
+
element.removeEventListener("touchend", handleDoubleTap);
|
|
20
|
+
};
|
|
21
|
+
}, [handleDoubleTap, targetRef]);
|
|
22
|
+
return targetRef;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
export function useOnHoverChange(callback, ref) {
|
|
3
|
+
const defaultRef = useRef(null);
|
|
4
|
+
const targetRef = ref !== null && ref !== void 0 ? ref : defaultRef;
|
|
5
|
+
const handleMouseEnter = useCallback((e) => {
|
|
6
|
+
window.matchMedia("(pointer: fine)").matches && callback(e, true);
|
|
7
|
+
}, [callback]);
|
|
8
|
+
const handleMouseLeave = useCallback((e) => {
|
|
9
|
+
window.matchMedia("(pointer: fine)").matches && callback(e, false);
|
|
10
|
+
}, [callback]);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const element = targetRef.current;
|
|
13
|
+
if (!element)
|
|
14
|
+
return;
|
|
15
|
+
element.addEventListener("mouseenter", handleMouseEnter);
|
|
16
|
+
element.addEventListener("mouseleave", handleMouseLeave);
|
|
17
|
+
return () => {
|
|
18
|
+
element.removeEventListener("mouseenter", handleMouseEnter);
|
|
19
|
+
element.removeEventListener("mouseleave", handleMouseLeave);
|
|
20
|
+
};
|
|
21
|
+
}, [handleMouseEnter, handleMouseLeave, targetRef]);
|
|
22
|
+
return targetRef;
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
export function useOnOutsideClick(callback, ref) {
|
|
3
|
+
const defaultRef = useRef(null);
|
|
4
|
+
const targetRef = ref !== null && ref !== void 0 ? ref : defaultRef;
|
|
5
|
+
const handleClick = useCallback((e) => {
|
|
6
|
+
e.preventDefault();
|
|
7
|
+
const element = targetRef.current;
|
|
8
|
+
if (!element)
|
|
9
|
+
return;
|
|
10
|
+
if (!element.contains(e.target)) {
|
|
11
|
+
callback(e);
|
|
12
|
+
}
|
|
13
|
+
}, [callback, targetRef]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
document.addEventListener("click", handleClick);
|
|
16
|
+
return () => {
|
|
17
|
+
document.removeEventListener("click", handleClick);
|
|
18
|
+
};
|
|
19
|
+
}, [handleClick]);
|
|
20
|
+
return targetRef;
|
|
21
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
export function useOnPinch(callback, ref) {
|
|
3
|
+
const defaultRef = useRef(null);
|
|
4
|
+
const targetRef = ref !== null && ref !== void 0 ? ref : defaultRef;
|
|
5
|
+
const [startDistance, setStartDistance] = useState(0);
|
|
6
|
+
const getDistance = (t1, t2) => Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
|
|
7
|
+
const handleStart = useCallback((e) => {
|
|
8
|
+
if (e.touches.length === 2) {
|
|
9
|
+
const [t1, t2] = e.touches;
|
|
10
|
+
setStartDistance(getDistance(t1, t2));
|
|
11
|
+
}
|
|
12
|
+
}, []);
|
|
13
|
+
const handleMove = useCallback((e) => {
|
|
14
|
+
if (e.touches.length === 2) {
|
|
15
|
+
const [t1, t2] = e.touches;
|
|
16
|
+
const dist = getDistance(t1, t2);
|
|
17
|
+
if (dist < startDistance - 20)
|
|
18
|
+
callback(e, "in");
|
|
19
|
+
if (dist > startDistance + 20)
|
|
20
|
+
callback(e, "out");
|
|
21
|
+
}
|
|
22
|
+
}, [callback, startDistance]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const element = targetRef.current;
|
|
25
|
+
if (!element)
|
|
26
|
+
return;
|
|
27
|
+
element.addEventListener("touchstart", handleStart);
|
|
28
|
+
element.addEventListener("touchmove", handleMove);
|
|
29
|
+
return () => {
|
|
30
|
+
element.removeEventListener("touchstart", handleStart);
|
|
31
|
+
element.removeEventListener("touchmove", handleMove);
|
|
32
|
+
};
|
|
33
|
+
}, [handleMove, handleStart, targetRef]);
|
|
34
|
+
return targetRef;
|
|
35
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
export function useOnResizeChange(callback, ref) {
|
|
3
|
+
const defaultRef = useRef(null);
|
|
4
|
+
const targetRef = ref !== null && ref !== void 0 ? ref : defaultRef;
|
|
5
|
+
const handleResize = useCallback((e) => {
|
|
6
|
+
callback(e);
|
|
7
|
+
}, [callback]);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const element = targetRef.current;
|
|
10
|
+
if (!element)
|
|
11
|
+
return;
|
|
12
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
handleResize(entry);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
resizeObserver.observe(element);
|
|
18
|
+
return () => {
|
|
19
|
+
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
|
|
20
|
+
};
|
|
21
|
+
}, [handleResize, targetRef]);
|
|
22
|
+
return targetRef;
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
export function useOnRightClick(callback, ref) {
|
|
3
|
+
const defaultRef = useRef(null);
|
|
4
|
+
const targetRef = ref !== null && ref !== void 0 ? ref : defaultRef;
|
|
5
|
+
const handleContextMenu = useCallback((e) => {
|
|
6
|
+
e.preventDefault();
|
|
7
|
+
callback(e);
|
|
8
|
+
}, [callback]);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const element = targetRef.current;
|
|
11
|
+
if (!element)
|
|
12
|
+
return;
|
|
13
|
+
element.addEventListener("contextmenu", handleContextMenu);
|
|
14
|
+
return () => {
|
|
15
|
+
element.removeEventListener("contextmenu", handleContextMenu);
|
|
16
|
+
};
|
|
17
|
+
}, [handleContextMenu, targetRef]);
|
|
18
|
+
return targetRef;
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
export function useOnRotate(callback, ref) {
|
|
3
|
+
const defaultRef = useRef(null);
|
|
4
|
+
const targetRef = ref !== null && ref !== void 0 ? ref : defaultRef;
|
|
5
|
+
const [startAngle, setStartAngle] = useState(0);
|
|
6
|
+
const getAngle = (t1, t2) => Math.atan2(t2.clientY - t1.clientY, t2.clientX - t1.clientX) *
|
|
7
|
+
(180 / Math.PI);
|
|
8
|
+
const handleStart = useCallback((e) => {
|
|
9
|
+
if (e.touches.length === 2) {
|
|
10
|
+
const [t1, t2] = e.touches;
|
|
11
|
+
setStartAngle(getAngle(t1, t2));
|
|
12
|
+
}
|
|
13
|
+
}, []);
|
|
14
|
+
const handleMove = useCallback((e) => {
|
|
15
|
+
if (e.touches.length === 2) {
|
|
16
|
+
const [t1, t2] = e.touches;
|
|
17
|
+
const angle = getAngle(t1, t2);
|
|
18
|
+
const deltaAngle = angle - startAngle;
|
|
19
|
+
if (Math.abs(deltaAngle) > 15) {
|
|
20
|
+
callback(e, deltaAngle);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}, [callback, startAngle]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const element = targetRef.current;
|
|
26
|
+
if (!element)
|
|
27
|
+
return;
|
|
28
|
+
element.addEventListener("touchstart", handleStart);
|
|
29
|
+
element.addEventListener("touchmove", handleMove);
|
|
30
|
+
return () => {
|
|
31
|
+
element.removeEventListener("touchstart", handleStart);
|
|
32
|
+
element.removeEventListener("touchmove", handleMove);
|
|
33
|
+
};
|
|
34
|
+
}, [handleMove, handleStart, targetRef]);
|
|
35
|
+
return targetRef;
|
|
36
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
export function useOnScroll(callback, ref) {
|
|
3
|
+
const defaultRef = useRef(null);
|
|
4
|
+
const targetRef = ref !== null && ref !== void 0 ? ref : defaultRef;
|
|
5
|
+
const scrollTimeoutRef = useRef(undefined);
|
|
6
|
+
const scrollingRef = useRef(false);
|
|
7
|
+
const handleScroll = useCallback(() => {
|
|
8
|
+
if (!scrollingRef.current) {
|
|
9
|
+
scrollingRef.current = true;
|
|
10
|
+
callback(true);
|
|
11
|
+
}
|
|
12
|
+
clearTimeout(scrollTimeoutRef.current);
|
|
13
|
+
scrollTimeoutRef.current = setTimeout(() => {
|
|
14
|
+
scrollingRef.current = false;
|
|
15
|
+
callback(false);
|
|
16
|
+
}, 150);
|
|
17
|
+
}, [callback]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const element = targetRef.current;
|
|
20
|
+
if (!element)
|
|
21
|
+
return;
|
|
22
|
+
element.addEventListener("scroll", handleScroll);
|
|
23
|
+
return () => {
|
|
24
|
+
element.removeEventListener("scroll", handleScroll);
|
|
25
|
+
clearTimeout(scrollTimeoutRef.current);
|
|
26
|
+
};
|
|
27
|
+
}, [handleScroll, targetRef]);
|
|
28
|
+
return targetRef;
|
|
29
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
export function useOnSwipe(callback, ref) {
|
|
3
|
+
const defaultRef = useRef(null);
|
|
4
|
+
const targetRef = ref !== null && ref !== void 0 ? ref : defaultRef;
|
|
5
|
+
const [swipeCoordinates, setSwipeCoordinates] = useState({
|
|
6
|
+
startX: 0,
|
|
7
|
+
startY: 0,
|
|
8
|
+
endX: 0,
|
|
9
|
+
endY: 0,
|
|
10
|
+
});
|
|
11
|
+
const touchStart = useCallback((e) => {
|
|
12
|
+
const t = e.touches[0];
|
|
13
|
+
setSwipeCoordinates(prev => (Object.assign(Object.assign({}, prev), { startX: t.clientX, startY: t.clientY, endX: t.clientX, endY: t.clientY })));
|
|
14
|
+
}, []);
|
|
15
|
+
const touchMove = useCallback((e) => {
|
|
16
|
+
const t = e.touches[0];
|
|
17
|
+
setSwipeCoordinates(prev => (Object.assign(Object.assign({}, prev), { endX: t.clientX, endY: t.clientY })));
|
|
18
|
+
}, []);
|
|
19
|
+
const touchEnd = useCallback((e) => {
|
|
20
|
+
// Could do unpacking of object but its not necessary
|
|
21
|
+
const dx = swipeCoordinates.endX - swipeCoordinates.startX;
|
|
22
|
+
const dy = swipeCoordinates.endY - swipeCoordinates.startY;
|
|
23
|
+
const absDx = Math.abs(dx);
|
|
24
|
+
const absDy = Math.abs(dy);
|
|
25
|
+
const threshold = 30;
|
|
26
|
+
if (absDx > absDy) {
|
|
27
|
+
if (dx > threshold)
|
|
28
|
+
callback(e, "right");
|
|
29
|
+
if (dx < -threshold)
|
|
30
|
+
callback(e, "left");
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (dy > threshold)
|
|
34
|
+
callback(e, "down");
|
|
35
|
+
if (dy < -threshold)
|
|
36
|
+
callback(e, "up");
|
|
37
|
+
}
|
|
38
|
+
}, [callback, swipeCoordinates.endX, swipeCoordinates.startX, swipeCoordinates.endY, swipeCoordinates.startY]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const element = targetRef.current;
|
|
41
|
+
if (!element)
|
|
42
|
+
return;
|
|
43
|
+
element.addEventListener("touchstart", touchStart, { passive: true });
|
|
44
|
+
element.addEventListener("touchmove", touchMove, { passive: true });
|
|
45
|
+
element.addEventListener("touchend", touchEnd, { passive: true });
|
|
46
|
+
return () => {
|
|
47
|
+
element.removeEventListener("touchstart", touchStart);
|
|
48
|
+
element.removeEventListener("touchmove", touchMove);
|
|
49
|
+
element.removeEventListener("touchend", touchEnd);
|
|
50
|
+
};
|
|
51
|
+
}, [touchStart, touchMove, touchEnd, targetRef]);
|
|
52
|
+
return targetRef;
|
|
53
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
export function useOnVisibilityChange(callback, ref) {
|
|
3
|
+
const defaultRef = useRef(null);
|
|
4
|
+
const targetRef = ref !== null && ref !== void 0 ? ref : defaultRef;
|
|
5
|
+
const handleVisibility = useCallback((visible) => {
|
|
6
|
+
callback(visible);
|
|
7
|
+
}, [callback]);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const element = targetRef.current;
|
|
10
|
+
if (!element)
|
|
11
|
+
return;
|
|
12
|
+
const intersectionObserver = new IntersectionObserver((entries) => {
|
|
13
|
+
entries[0].isIntersecting ? handleVisibility(true) : handleVisibility(false);
|
|
14
|
+
});
|
|
15
|
+
intersectionObserver.observe(element);
|
|
16
|
+
return () => {
|
|
17
|
+
intersectionObserver === null || intersectionObserver === void 0 ? void 0 : intersectionObserver.disconnect();
|
|
18
|
+
};
|
|
19
|
+
}, [handleVisibility, targetRef]);
|
|
20
|
+
return targetRef;
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yakad/ui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.158",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Natiq",
|
|
6
6
|
"description": "UI components for NextJS/React",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@yakad/lib": "1.0.22",
|
|
36
|
-
"@yakad/symbols": "1.0.
|
|
36
|
+
"@yakad/symbols": "1.0.28",
|
|
37
37
|
"classnames": "2.5.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { StackProps } from "../Stack/Stack";
|
|
3
|
-
export interface WithInteractionsProps extends StackProps {
|
|
4
|
-
onRightClick?: (e: MouseEvent) => void;
|
|
5
|
-
onTap?: (e: TouchEvent) => void;
|
|
6
|
-
onDoubleTap?: (e: TouchEvent) => void;
|
|
7
|
-
onOutsideClick?: () => void;
|
|
8
|
-
onSwipeLeft?: () => void;
|
|
9
|
-
onSwipeRight?: () => void;
|
|
10
|
-
onSwipeUp?: () => void;
|
|
11
|
-
onSwipeDown?: () => void;
|
|
12
|
-
onPinchIn?: () => void;
|
|
13
|
-
onPinchOut?: () => void;
|
|
14
|
-
onRotate?: (angle: number) => void;
|
|
15
|
-
onScrollStart?: () => void;
|
|
16
|
-
onScrollStop?: () => void;
|
|
17
|
-
onResize?: (entry: ResizeObserverEntry) => void;
|
|
18
|
-
onVisibilityChange?: (visible: boolean) => void;
|
|
19
|
-
onVisible?: () => void;
|
|
20
|
-
onHidden?: () => void;
|
|
21
|
-
onMouseHoverChange?: (isHover: boolean, e: MouseEvent) => void;
|
|
22
|
-
onMouseHoverStart?: (e: MouseEvent) => void;
|
|
23
|
-
onMouseHoverLeave?: (e: MouseEvent) => void;
|
|
24
|
-
}
|
|
25
|
-
export declare const WithInteractions: import("react").ForwardRefExoticComponent<WithInteractionsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,226 +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, useEffect, useImperativeHandle, useRef } from "react";
|
|
15
|
-
import { Stack } from "../Stack/Stack";
|
|
16
|
-
export const WithInteractions = forwardRef(function WithInteractions(_a, forwardedRef) {
|
|
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"]);
|
|
18
|
-
const localRef = useRef(null);
|
|
19
|
-
// Let the parent access our DOM node
|
|
20
|
-
useImperativeHandle(forwardedRef, () => localRef.current);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
const el = localRef.current;
|
|
23
|
-
if (!el)
|
|
24
|
-
return;
|
|
25
|
-
// Event cleanup store
|
|
26
|
-
const cleanupFns = [];
|
|
27
|
-
// === RIGHT CLICK ===
|
|
28
|
-
if (onRightClick) {
|
|
29
|
-
const handler = (e) => {
|
|
30
|
-
e.preventDefault();
|
|
31
|
-
onRightClick(e);
|
|
32
|
-
};
|
|
33
|
-
el.addEventListener("contextmenu", handler);
|
|
34
|
-
cleanupFns.push(() => el.removeEventListener("contextmenu", handler));
|
|
35
|
-
}
|
|
36
|
-
// === OUTSIDE CLICK ===
|
|
37
|
-
if (onOutsideClick) {
|
|
38
|
-
const handler = (e) => {
|
|
39
|
-
if (!el.contains(e.target)) {
|
|
40
|
-
onOutsideClick();
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
document.addEventListener("click", handler);
|
|
44
|
-
cleanupFns.push(() => document.removeEventListener("click", handler));
|
|
45
|
-
}
|
|
46
|
-
// === TAP & DOUBLE TAP ===
|
|
47
|
-
if (onTap || onDoubleTap) {
|
|
48
|
-
let lastTap = 0;
|
|
49
|
-
const tapHandler = (e) => {
|
|
50
|
-
const now = Date.now();
|
|
51
|
-
if (now - lastTap < 300) {
|
|
52
|
-
onDoubleTap === null || onDoubleTap === void 0 ? void 0 : onDoubleTap(e);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
onTap === null || onTap === void 0 ? void 0 : onTap(e);
|
|
56
|
-
}
|
|
57
|
-
lastTap = now;
|
|
58
|
-
};
|
|
59
|
-
el.addEventListener("touchend", tapHandler);
|
|
60
|
-
cleanupFns.push(() => el.removeEventListener("touchend", tapHandler));
|
|
61
|
-
}
|
|
62
|
-
// === SWIPE ===
|
|
63
|
-
if (onSwipeLeft || onSwipeRight || onSwipeUp || onSwipeDown) {
|
|
64
|
-
let startX = 0, startY = 0, endX = 0, endY = 0;
|
|
65
|
-
const touchStart = (e) => {
|
|
66
|
-
const t = e.touches[0];
|
|
67
|
-
startX = t.clientX;
|
|
68
|
-
startY = t.clientY;
|
|
69
|
-
endX = startX;
|
|
70
|
-
endY = startY;
|
|
71
|
-
};
|
|
72
|
-
const touchMove = (e) => {
|
|
73
|
-
const t = e.touches[0];
|
|
74
|
-
endX = t.clientX;
|
|
75
|
-
endY = t.clientY;
|
|
76
|
-
};
|
|
77
|
-
const touchEnd = () => {
|
|
78
|
-
const dx = endX - startX;
|
|
79
|
-
const dy = endY - startY;
|
|
80
|
-
const absDx = Math.abs(dx);
|
|
81
|
-
const absDy = Math.abs(dy);
|
|
82
|
-
const threshold = 30;
|
|
83
|
-
if (absDx > absDy) {
|
|
84
|
-
if (dx > threshold)
|
|
85
|
-
onSwipeRight === null || onSwipeRight === void 0 ? void 0 : onSwipeRight();
|
|
86
|
-
if (dx < -threshold)
|
|
87
|
-
onSwipeLeft === null || onSwipeLeft === void 0 ? void 0 : onSwipeLeft();
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
if (dy > threshold)
|
|
91
|
-
onSwipeDown === null || onSwipeDown === void 0 ? void 0 : onSwipeDown();
|
|
92
|
-
if (dy < -threshold)
|
|
93
|
-
onSwipeUp === null || onSwipeUp === void 0 ? void 0 : onSwipeUp();
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
el.addEventListener("touchstart", touchStart);
|
|
97
|
-
el.addEventListener("touchmove", touchMove);
|
|
98
|
-
el.addEventListener("touchend", touchEnd);
|
|
99
|
-
cleanupFns.push(() => {
|
|
100
|
-
el.removeEventListener("touchstart", touchStart);
|
|
101
|
-
el.removeEventListener("touchmove", touchMove);
|
|
102
|
-
el.removeEventListener("touchend", touchEnd);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
// === PINCH & ROTATE ===
|
|
106
|
-
if (onPinchIn || onPinchOut || onRotate) {
|
|
107
|
-
let startDistance = 0;
|
|
108
|
-
let startAngle = 0;
|
|
109
|
-
const getDistance = (t1, t2) => Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
|
|
110
|
-
const getAngle = (t1, t2) => Math.atan2(t2.clientY - t1.clientY, t2.clientX - t1.clientX) *
|
|
111
|
-
(180 / Math.PI);
|
|
112
|
-
const handleStart = (e) => {
|
|
113
|
-
if (e.touches.length === 2) {
|
|
114
|
-
const [t1, t2] = e.touches;
|
|
115
|
-
startDistance = getDistance(t1, t2);
|
|
116
|
-
startAngle = getAngle(t1, t2);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
const handleMove = (e) => {
|
|
120
|
-
if (e.touches.length === 2) {
|
|
121
|
-
const [t1, t2] = e.touches;
|
|
122
|
-
const dist = getDistance(t1, t2);
|
|
123
|
-
const angle = getAngle(t1, t2);
|
|
124
|
-
if (dist < startDistance - 20)
|
|
125
|
-
onPinchIn === null || onPinchIn === void 0 ? void 0 : onPinchIn();
|
|
126
|
-
if (dist > startDistance + 20)
|
|
127
|
-
onPinchOut === null || onPinchOut === void 0 ? void 0 : onPinchOut();
|
|
128
|
-
const deltaAngle = angle - startAngle;
|
|
129
|
-
if (Math.abs(deltaAngle) > 15) {
|
|
130
|
-
onRotate === null || onRotate === void 0 ? void 0 : onRotate(deltaAngle);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
el.addEventListener("touchstart", handleStart);
|
|
135
|
-
el.addEventListener("touchmove", handleMove);
|
|
136
|
-
cleanupFns.push(() => {
|
|
137
|
-
el.removeEventListener("touchstart", handleStart);
|
|
138
|
-
el.removeEventListener("touchmove", handleMove);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
// === RESIZE OBSERVER ===
|
|
142
|
-
let resizeObserver = null;
|
|
143
|
-
if (onResize) {
|
|
144
|
-
resizeObserver = new ResizeObserver((entries) => {
|
|
145
|
-
for (const entry of entries) {
|
|
146
|
-
onResize(entry);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
resizeObserver.observe(el);
|
|
150
|
-
cleanupFns.push(() => resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect());
|
|
151
|
-
}
|
|
152
|
-
// === VISIBILITY OBSERVER ===
|
|
153
|
-
let intersectionObserver = null;
|
|
154
|
-
if (onVisibilityChange || onVisible || onHidden) {
|
|
155
|
-
intersectionObserver = new IntersectionObserver((entries) => {
|
|
156
|
-
entries[0].isIntersecting ? onVisible === null || onVisible === void 0 ? void 0 : onVisible() : onHidden === null || onHidden === void 0 ? void 0 : onHidden();
|
|
157
|
-
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(entries[0].isIntersecting);
|
|
158
|
-
});
|
|
159
|
-
intersectionObserver.observe(el);
|
|
160
|
-
cleanupFns.push(() => intersectionObserver === null || intersectionObserver === void 0 ? void 0 : intersectionObserver.disconnect());
|
|
161
|
-
}
|
|
162
|
-
// === On Hover Change ===
|
|
163
|
-
const hasFinePointer = window.matchMedia("(pointer: fine)").matches;
|
|
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
|
-
};
|
|
174
|
-
el.addEventListener("mouseenter", mouseEnter);
|
|
175
|
-
el.addEventListener("mouseleave", mouseLeave);
|
|
176
|
-
cleanupFns.push(() => {
|
|
177
|
-
el.removeEventListener("mouseenter", mouseEnter);
|
|
178
|
-
el.removeEventListener("mouseleave", mouseLeave);
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
// === SCROLL START/END ===
|
|
182
|
-
if (onScrollStart) {
|
|
183
|
-
let scrolling = false;
|
|
184
|
-
let scrollTimeout;
|
|
185
|
-
const scrollHandler = () => {
|
|
186
|
-
if (!scrolling) {
|
|
187
|
-
scrolling = true;
|
|
188
|
-
onScrollStart === null || onScrollStart === void 0 ? void 0 : onScrollStart();
|
|
189
|
-
}
|
|
190
|
-
clearTimeout(scrollTimeout);
|
|
191
|
-
scrollTimeout = setTimeout(() => {
|
|
192
|
-
scrolling = false;
|
|
193
|
-
onScrollStop === null || onScrollStop === void 0 ? void 0 : onScrollStop();
|
|
194
|
-
}, 150);
|
|
195
|
-
};
|
|
196
|
-
el.addEventListener("scroll", scrollHandler);
|
|
197
|
-
cleanupFns.push(() => el.removeEventListener("scroll", scrollHandler));
|
|
198
|
-
}
|
|
199
|
-
// Cleanup on unmount
|
|
200
|
-
return () => {
|
|
201
|
-
cleanupFns.forEach((fn) => fn());
|
|
202
|
-
};
|
|
203
|
-
}, [
|
|
204
|
-
onRightClick,
|
|
205
|
-
onTap,
|
|
206
|
-
onDoubleTap,
|
|
207
|
-
onOutsideClick,
|
|
208
|
-
onSwipeLeft,
|
|
209
|
-
onSwipeRight,
|
|
210
|
-
onSwipeUp,
|
|
211
|
-
onSwipeDown,
|
|
212
|
-
onPinchIn,
|
|
213
|
-
onPinchOut,
|
|
214
|
-
onRotate,
|
|
215
|
-
onScrollStart,
|
|
216
|
-
onScrollStop,
|
|
217
|
-
onResize,
|
|
218
|
-
onVisibilityChange,
|
|
219
|
-
onVisible,
|
|
220
|
-
onHidden,
|
|
221
|
-
onMouseHoverChange,
|
|
222
|
-
onMouseHoverStart,
|
|
223
|
-
onMouseHoverLeave,
|
|
224
|
-
]);
|
|
225
|
-
return (_jsx(Stack, Object.assign({ ref: localRef }, restProps, { children: children })));
|
|
226
|
-
});
|