@yakad/ui 1.3.156 → 1.3.157

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.
Files changed (43) hide show
  1. package/dist/Button/Button.js +2 -1
  2. package/dist/CheckBox/CheckBox.js +2 -1
  3. package/dist/CodeBox/CodeBox.js +2 -1
  4. package/dist/CodeField/CodeField.js +2 -1
  5. package/dist/Container/Container.js +1 -1
  6. package/dist/Display/Display.js +1 -1
  7. package/dist/Form/Form.js +1 -1
  8. package/dist/GridItem/GridItem.js +1 -1
  9. package/dist/InputField/InputField.js +2 -1
  10. package/dist/List/List.js +2 -1
  11. package/dist/ListItem/ListItem.js +1 -1
  12. package/dist/Main/Main.js +1 -1
  13. package/dist/Navigation/Navigation.js +1 -1
  14. package/dist/Row/Row.js +1 -1
  15. package/dist/Screen/Screen.js +1 -1
  16. package/dist/Select/Select.js +2 -1
  17. package/dist/Stack/Stack.js +1 -1
  18. package/dist/Table/Table.js +2 -1
  19. package/dist/Theme/Theme.js +1 -1
  20. package/dist/boxing.module.css +1 -1
  21. package/dist/index.d.ts +10 -0
  22. package/dist/index.js +10 -0
  23. package/dist/interactionHooks/useOnDoubleTap.d.ts +2 -0
  24. package/dist/interactionHooks/useOnDoubleTap.js +22 -0
  25. package/dist/interactionHooks/useOnHoverChange.d.ts +2 -0
  26. package/dist/interactionHooks/useOnHoverChange.js +22 -0
  27. package/dist/interactionHooks/useOnOutsideClick.d.ts +2 -0
  28. package/dist/interactionHooks/useOnOutsideClick.js +20 -0
  29. package/dist/interactionHooks/useOnPinch.d.ts +2 -0
  30. package/dist/interactionHooks/useOnPinch.js +34 -0
  31. package/dist/interactionHooks/useOnResizeObserver.d.ts +2 -0
  32. package/dist/interactionHooks/useOnResizeObserver.js +22 -0
  33. package/dist/interactionHooks/useOnRightClick.d.ts +2 -0
  34. package/dist/interactionHooks/useOnRightClick.js +18 -0
  35. package/dist/interactionHooks/useOnRotate.d.ts +2 -0
  36. package/dist/interactionHooks/useOnRotate.js +35 -0
  37. package/dist/interactionHooks/useOnScroll.d.ts +2 -0
  38. package/dist/interactionHooks/useOnScroll.js +29 -0
  39. package/dist/interactionHooks/useOnSwipe.d.ts +2 -0
  40. package/dist/interactionHooks/useOnSwipe.js +52 -0
  41. package/dist/interactionHooks/useOnVisibilityObserver.d.ts +2 -0
  42. package/dist/interactionHooks/useOnVisibilityObserver.js +20 -0
  43. package/package.json +3 -3
@@ -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
  });
@@ -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
  });
@@ -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
  });
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/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
  });
@@ -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
  });
@@ -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
  });
@@ -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
  });
@@ -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) {
@@ -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,5 +1,5 @@
1
1
  /* Full Width Childs */
2
- :global(.demandChildsToBeFullWidth) > :global(.fullWidthOnParentDemand) {
2
+ .demandChildsToBeFullWidth > .fullWidthOnParentDemand {
3
3
  width: 100%;
4
4
  }
5
5
 
package/dist/index.d.ts CHANGED
@@ -35,3 +35,13 @@ export * from "./ActiveOnVisible/ActiveOnVisible";
35
35
  export * from "./Dropdown/Dropdown";
36
36
  export * from "./Popup/Popup";
37
37
  export * from "./Avatar/Avatar";
38
+ export * from "./interactionHooks/useOnRightClick";
39
+ export * from "./interactionHooks/useOnOutsideClick";
40
+ export * from "./interactionHooks/useOnDoubleTap";
41
+ export * from "./interactionHooks/useOnSwipe";
42
+ export * from "./interactionHooks/useOnPinch";
43
+ export * from "./interactionHooks/useOnRotate";
44
+ export * from "./interactionHooks/useOnResizeObserver";
45
+ export * from "./interactionHooks/useOnVisibilityObserver";
46
+ export * from "./interactionHooks/useOnHoverChange";
47
+ export * from "./interactionHooks/useOnScroll";
package/dist/index.js CHANGED
@@ -41,3 +41,13 @@ export * from "./ActiveOnVisible/ActiveOnVisible"; // Stack Based
41
41
  export * from "./Dropdown/Dropdown"; // Card Based
42
42
  export * from "./Popup/Popup"; // Card Based
43
43
  export * from "./Avatar/Avatar";
44
+ export * from "./interactionHooks/useOnRightClick";
45
+ export * from "./interactionHooks/useOnOutsideClick";
46
+ export * from "./interactionHooks/useOnDoubleTap";
47
+ export * from "./interactionHooks/useOnSwipe";
48
+ export * from "./interactionHooks/useOnPinch";
49
+ export * from "./interactionHooks/useOnRotate";
50
+ export * from "./interactionHooks/useOnResizeObserver";
51
+ export * from "./interactionHooks/useOnVisibilityObserver";
52
+ export * from "./interactionHooks/useOnHoverChange";
53
+ export * from "./interactionHooks/useOnScroll";
@@ -0,0 +1,2 @@
1
+ import { RefObject } from "react";
2
+ export declare function useOnDoubleTap<T extends HTMLElement = HTMLElement>(callback: (e: TouchEvent) => void): RefObject<T | null>;
@@ -0,0 +1,22 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ export function useOnDoubleTap(callback) {
3
+ const ref = useRef(null);
4
+ const [lastTap, setLastTap] = useState(0);
5
+ const handleDoubleTap = useCallback((e) => {
6
+ const now = Date.now();
7
+ if (now - lastTap < 300) {
8
+ callback(e);
9
+ }
10
+ setLastTap(now);
11
+ }, [callback, lastTap]);
12
+ useEffect(() => {
13
+ const element = ref.current;
14
+ if (!element)
15
+ return;
16
+ element.addEventListener("touchend", handleDoubleTap);
17
+ return () => {
18
+ element.removeEventListener("touchend", handleDoubleTap);
19
+ };
20
+ }, [handleDoubleTap]);
21
+ return ref;
22
+ }
@@ -0,0 +1,2 @@
1
+ import { RefObject } from "react";
2
+ export declare function useOnHoverChange<T extends HTMLElement = HTMLElement>(callback: (e: MouseEvent, change: "leave" | "enter") => void): RefObject<T | null>;
@@ -0,0 +1,22 @@
1
+ import { useCallback, useEffect, useRef } from "react";
2
+ export function useOnHoverChange(callback) {
3
+ const ref = useRef(null);
4
+ const handleMouseEnter = useCallback((e) => {
5
+ window.matchMedia("(pointer: fine)").matches && callback(e, "enter");
6
+ }, [callback]);
7
+ const handleMouseLeave = useCallback((e) => {
8
+ window.matchMedia("(pointer: fine)").matches && callback(e, "leave");
9
+ }, [callback]);
10
+ useEffect(() => {
11
+ const element = ref.current;
12
+ if (!element)
13
+ return;
14
+ element.addEventListener("mouseenter", handleMouseEnter);
15
+ element.addEventListener("mouseleave", handleMouseLeave);
16
+ return () => {
17
+ element.removeEventListener("mouseenter", handleMouseEnter);
18
+ element.removeEventListener("mouseleave", handleMouseLeave);
19
+ };
20
+ }, [handleMouseEnter, handleMouseLeave]);
21
+ return ref;
22
+ }
@@ -0,0 +1,2 @@
1
+ import { RefObject } from "react";
2
+ export declare function useOnOutsideClick<T extends HTMLElement = HTMLElement>(callback: (e: MouseEvent) => void): RefObject<T | null>;
@@ -0,0 +1,20 @@
1
+ import { useCallback, useEffect, useRef } from "react";
2
+ export function useOnOutsideClick(callback) {
3
+ const ref = useRef(null);
4
+ const handleClick = useCallback((e) => {
5
+ e.preventDefault();
6
+ const element = ref.current;
7
+ if (!element)
8
+ return;
9
+ if (!element.contains(e.target)) {
10
+ callback(e);
11
+ }
12
+ }, [callback]);
13
+ useEffect(() => {
14
+ document.addEventListener("click", handleClick);
15
+ return () => {
16
+ document.removeEventListener("click", handleClick);
17
+ };
18
+ }, [handleClick]);
19
+ return ref;
20
+ }
@@ -0,0 +1,2 @@
1
+ import { RefObject } from "react";
2
+ export declare function useOnPinch<T extends HTMLElement = HTMLElement>(callback: (e: TouchEvent, action: "in" | "out") => void): RefObject<T | null>;
@@ -0,0 +1,34 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ export function useOnPinch(callback) {
3
+ const ref = useRef(null);
4
+ const [startDistance, setStartDistance] = useState(0);
5
+ const getDistance = (t1, t2) => Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
6
+ const handleStart = useCallback((e) => {
7
+ if (e.touches.length === 2) {
8
+ const [t1, t2] = e.touches;
9
+ setStartDistance(getDistance(t1, t2));
10
+ }
11
+ }, []);
12
+ const handleMove = useCallback((e) => {
13
+ if (e.touches.length === 2) {
14
+ const [t1, t2] = e.touches;
15
+ const dist = getDistance(t1, t2);
16
+ if (dist < startDistance - 20)
17
+ callback(e, "in");
18
+ if (dist > startDistance + 20)
19
+ callback(e, "out");
20
+ }
21
+ }, [callback, startDistance]);
22
+ useEffect(() => {
23
+ const element = ref.current;
24
+ if (!element)
25
+ return;
26
+ element.addEventListener("touchstart", handleStart);
27
+ element.addEventListener("touchmove", handleMove);
28
+ return () => {
29
+ element.removeEventListener("touchstart", handleStart);
30
+ element.removeEventListener("touchmove", handleMove);
31
+ };
32
+ }, [handleMove, handleStart]);
33
+ return ref;
34
+ }
@@ -0,0 +1,2 @@
1
+ import { RefObject } from "react";
2
+ export declare function useOnResizeObserver<T extends HTMLElement = HTMLElement>(callback: (e: ResizeObserverEntry) => void): RefObject<T | null>;
@@ -0,0 +1,22 @@
1
+ import { useCallback, useEffect, useRef } from "react";
2
+ export function useOnResizeObserver(callback) {
3
+ const ref = useRef(null);
4
+ const handleResize = useCallback((e) => {
5
+ callback(e);
6
+ }, [callback]);
7
+ useEffect(() => {
8
+ const element = ref.current;
9
+ if (!element)
10
+ return;
11
+ const resizeObserver = new ResizeObserver((entries) => {
12
+ for (const entry of entries) {
13
+ handleResize(entry);
14
+ }
15
+ });
16
+ resizeObserver.observe(element);
17
+ return () => {
18
+ resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
19
+ };
20
+ }, [handleResize]);
21
+ return ref;
22
+ }
@@ -0,0 +1,2 @@
1
+ import { RefObject } from "react";
2
+ export declare function useOnRightClick<T extends HTMLElement = HTMLElement>(callback: (e: MouseEvent) => void): RefObject<T | null>;
@@ -0,0 +1,18 @@
1
+ import { useCallback, useEffect, useRef } from "react";
2
+ export function useOnRightClick(callback) {
3
+ const ref = useRef(null);
4
+ const handleContextMenu = useCallback((e) => {
5
+ e.preventDefault();
6
+ callback(e);
7
+ }, [callback]);
8
+ useEffect(() => {
9
+ const element = ref.current;
10
+ if (!element)
11
+ return;
12
+ element.addEventListener("contextmenu", handleContextMenu);
13
+ return () => {
14
+ element.removeEventListener("contextmenu", handleContextMenu);
15
+ };
16
+ }, [handleContextMenu]);
17
+ return ref;
18
+ }
@@ -0,0 +1,2 @@
1
+ import { RefObject } from "react";
2
+ export declare function useOnRotate<T extends HTMLElement = HTMLElement>(callback: (e: TouchEvent, deltaAngle: number) => void): RefObject<T | null>;
@@ -0,0 +1,35 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ export function useOnRotate(callback) {
3
+ const ref = useRef(null);
4
+ const [startAngle, setStartAngle] = useState(0);
5
+ const getAngle = (t1, t2) => Math.atan2(t2.clientY - t1.clientY, t2.clientX - t1.clientX) *
6
+ (180 / Math.PI);
7
+ const handleStart = useCallback((e) => {
8
+ if (e.touches.length === 2) {
9
+ const [t1, t2] = e.touches;
10
+ setStartAngle(getAngle(t1, t2));
11
+ }
12
+ }, []);
13
+ const handleMove = useCallback((e) => {
14
+ if (e.touches.length === 2) {
15
+ const [t1, t2] = e.touches;
16
+ const angle = getAngle(t1, t2);
17
+ const deltaAngle = angle - startAngle;
18
+ if (Math.abs(deltaAngle) > 15) {
19
+ callback(e, deltaAngle);
20
+ }
21
+ }
22
+ }, [callback, startAngle]);
23
+ useEffect(() => {
24
+ const element = ref.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]);
34
+ return ref;
35
+ }
@@ -0,0 +1,2 @@
1
+ import { RefObject } from "react";
2
+ export declare function useOnScroll<T extends HTMLElement = HTMLElement>(callback: (action: "start" | "stop") => void): RefObject<T | null>;
@@ -0,0 +1,29 @@
1
+ import { useCallback, useEffect, useRef } from "react";
2
+ export function useOnScroll(callback) {
3
+ const ref = useRef(null);
4
+ const scrollTimeoutRef = useRef(undefined);
5
+ const scrollingRef = useRef(false);
6
+ const handleScroll = useCallback(() => {
7
+ console.log("bb123");
8
+ if (!scrollingRef.current) {
9
+ scrollingRef.current = true;
10
+ callback("start");
11
+ }
12
+ clearTimeout(scrollTimeoutRef.current);
13
+ scrollTimeoutRef.current = setTimeout(() => {
14
+ scrollingRef.current = false;
15
+ callback("stop");
16
+ }, 150);
17
+ }, [callback]);
18
+ useEffect(() => {
19
+ const element = ref.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]);
28
+ return ref;
29
+ }
@@ -0,0 +1,2 @@
1
+ import { RefObject } from "react";
2
+ export declare function useOnSwipe<T extends HTMLElement = HTMLElement>(callback: (e: TouchEvent, direction: "left" | "right" | "up" | "down") => void): RefObject<T | null>;
@@ -0,0 +1,52 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ export function useOnSwipe(callback) {
3
+ const ref = useRef(null);
4
+ const [swipeCoordinates, setSwipeCoordinates] = useState({
5
+ startX: 0,
6
+ startY: 0,
7
+ endX: 0,
8
+ endY: 0,
9
+ });
10
+ const touchStart = useCallback((e) => {
11
+ const t = e.touches[0];
12
+ setSwipeCoordinates(prev => (Object.assign(Object.assign({}, prev), { startX: t.clientX, startY: t.clientY, endX: t.clientX, endY: t.clientY })));
13
+ }, []);
14
+ const touchMove = useCallback((e) => {
15
+ const t = e.touches[0];
16
+ setSwipeCoordinates(prev => (Object.assign(Object.assign({}, prev), { endX: t.clientX, endY: t.clientY })));
17
+ }, []);
18
+ const touchEnd = useCallback((e) => {
19
+ // Could do unpacking of object but its not necessary
20
+ const dx = swipeCoordinates.endX - swipeCoordinates.startX;
21
+ const dy = swipeCoordinates.endY - swipeCoordinates.startY;
22
+ const absDx = Math.abs(dx);
23
+ const absDy = Math.abs(dy);
24
+ const threshold = 30;
25
+ if (absDx > absDy) {
26
+ if (dx > threshold)
27
+ callback(e, "right");
28
+ if (dx < -threshold)
29
+ callback(e, "left");
30
+ }
31
+ else {
32
+ if (dy > threshold)
33
+ callback(e, "down");
34
+ if (dy < -threshold)
35
+ callback(e, "up");
36
+ }
37
+ }, [callback, swipeCoordinates.endX, swipeCoordinates.startX, swipeCoordinates.endY, swipeCoordinates.startY]);
38
+ useEffect(() => {
39
+ const element = ref.current;
40
+ if (!element)
41
+ return;
42
+ element.addEventListener("touchstart", touchStart, { passive: true });
43
+ element.addEventListener("touchmove", touchMove, { passive: true });
44
+ element.addEventListener("touchend", touchEnd, { passive: true });
45
+ return () => {
46
+ element.removeEventListener("touchstart", touchStart);
47
+ element.removeEventListener("touchmove", touchMove);
48
+ element.removeEventListener("touchend", touchEnd);
49
+ };
50
+ }, [touchStart, touchMove, touchEnd]);
51
+ return ref;
52
+ }
@@ -0,0 +1,2 @@
1
+ import { RefObject } from "react";
2
+ export declare function useOnVisibilityObserver<T extends HTMLElement = HTMLElement>(callback: (action: "visible" | "hidden") => void): RefObject<T | null>;
@@ -0,0 +1,20 @@
1
+ import { useCallback, useEffect, useRef } from "react";
2
+ export function useOnVisibilityObserver(callback) {
3
+ const ref = useRef(null);
4
+ const handleVisibility = useCallback((action) => {
5
+ callback(action);
6
+ }, [callback]);
7
+ useEffect(() => {
8
+ const element = ref.current;
9
+ if (!element)
10
+ return;
11
+ const intersectionObserver = new IntersectionObserver((entries) => {
12
+ entries[0].isIntersecting ? handleVisibility("visible") : handleVisibility("hidden");
13
+ });
14
+ intersectionObserver.observe(element);
15
+ return () => {
16
+ intersectionObserver === null || intersectionObserver === void 0 ? void 0 : intersectionObserver.disconnect();
17
+ };
18
+ }, [handleVisibility]);
19
+ return ref;
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yakad/ui",
3
- "version": "1.3.156",
3
+ "version": "1.3.157",
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.25",
36
+ "@yakad/symbols": "^1.0.28",
37
37
  "classnames": "2.5.1"
38
38
  },
39
39
  "peerDependencies": {
@@ -47,4 +47,4 @@
47
47
  "react": "^19.0.0",
48
48
  "react-dom": "^19.0.0"
49
49
  }
50
- }
50
+ }