@yakad/ui 1.3.107 → 1.3.109

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.
@@ -1,10 +1,14 @@
1
1
  /// <reference types="react" />
2
- export interface WithDropdawnProps {
2
+ export interface WithDropdawnProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ align?: "start" | "center" | "end";
4
+ blur?: boolean;
3
5
  trigger?: "onClick" | "onRightClick";
4
- dropdawnstyle?: React.CSSProperties;
5
- dropdawnchildren?: React.ReactElement;
6
+ dropdawnChildren?: React.ReactElement;
6
7
  children?: React.ReactElement<{
7
8
  onClick?: (e: React.MouseEvent<HTMLElement>) => void;
8
9
  }>;
9
10
  }
10
- export declare const WithDropdawn: ({ trigger, dropdawnchildren, dropdawnstyle, children, }: WithDropdawnProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const WithDropdawn: {
12
+ ({ align, blur, trigger, dropdawnChildren, className, style, children, ...restProps }: WithDropdawnProps): import("react/jsx-runtime").JSX.Element;
13
+ displayName: string;
14
+ };
@@ -1,11 +1,27 @@
1
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
+ };
2
13
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
14
  import { useRef, useState, useEffect, cloneElement } from "react";
15
+ import classNames from "classnames";
4
16
  import { WithInteractions } from "../";
5
- export const WithDropdawn = ({ trigger = "onClick", dropdawnchildren, dropdawnstyle, children, }) => {
17
+ import boxingStyles from "../boxing.module.css";
18
+ import styles from "./WithDropdawn.module.css";
19
+ export const WithDropdawn = (_a) => {
20
+ var { align, blur, trigger = "onClick", dropdawnChildren, className, style, children } = _a, restProps = __rest(_a, ["align", "blur", "trigger", "dropdawnChildren", "className", "style", "children"]);
6
21
  const toggleElementRef = useRef(null);
7
22
  const dropdawnRef = useRef(null);
8
23
  const [showDropdawn, setShowDropdawn] = useState(false);
24
+ const [dropdawnOnTop, setDropdawnOnTop] = useState(false);
9
25
  const [top, setTop] = useState(0);
10
26
  const [left, setLeft] = useState(0);
11
27
  const toggleShowDropdawn = () => setShowDropdawn((prev) => !prev);
@@ -19,7 +35,10 @@ export const WithDropdawn = ({ trigger = "onClick", dropdawnchildren, dropdawnst
19
35
  // Prevent overflow bottom
20
36
  if (top + dropdawnRect.height > window.innerHeight) {
21
37
  top = buttonRect.top - dropdawnRect.height - padding;
38
+ setDropdawnOnTop(true);
22
39
  }
40
+ else
41
+ setDropdawnOnTop(false);
23
42
  // Prevent overflow right
24
43
  if (left + dropdawnRect.width > window.innerWidth - padding) {
25
44
  left = window.innerWidth - dropdawnRect.width - padding;
@@ -31,7 +50,8 @@ export const WithDropdawn = ({ trigger = "onClick", dropdawnchildren, dropdawnst
31
50
  setTop(top);
32
51
  setLeft(left);
33
52
  }
34
- }, [showDropdawn, dropdawnchildren]);
53
+ }, [showDropdawn, dropdawnChildren]);
54
+ const joinedClassNames = classNames(boxingStyles.flexColumnBox, { [boxingStyles[align]]: align }, styles.dropdawnCard, { [styles.dropdawnOnTop]: dropdawnOnTop }, { [styles.blur]: blur }, className);
35
55
  return (_jsxs(_Fragment, { children: [_jsx(WithInteractions, { ref: toggleElementRef, onRightClick: () => trigger === "onRightClick" && setShowDropdawn(true), children: children &&
36
56
  cloneElement(children, {
37
57
  onClick: (e) => {
@@ -39,5 +59,6 @@ export const WithDropdawn = ({ trigger = "onClick", dropdawnchildren, dropdawnst
39
59
  (_b = (_a = children.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
40
60
  trigger === "onClick" && toggleShowDropdawn();
41
61
  },
42
- }) }), _jsx(WithInteractions, { onOutsideClick: () => setShowDropdawn(false), children: _jsx("div", { ref: dropdawnRef, style: Object.assign({ position: "fixed", top: top, left: left, maxWidth: "calc(100% - 4rem)", maxHeight: "min(50vh, 50rem)", zIndex: 2, visibility: showDropdawn ? "visible" : "hidden" }, dropdawnstyle), children: dropdawnchildren }) })] }));
62
+ }) }), _jsx(WithInteractions, { onOutsideClick: () => setShowDropdawn(false), children: _jsx("div", Object.assign({ ref: dropdawnRef }, restProps, { className: joinedClassNames, style: Object.assign({ top: top, left: left, visibility: showDropdawn ? "visible" : "hidden" }, style), children: dropdawnChildren })) })] }));
43
63
  };
64
+ WithDropdawn.displayName = "WithDropdawn";
@@ -0,0 +1,48 @@
1
+ .dropdawnCard {
2
+ position: fixed;
3
+ max-width: calc(100% - 4rem);
4
+ max-height: min(50vh, 50rem);
5
+ padding: 2rem;
6
+ border-radius: 2rem;
7
+ box-shadow: 0px 3px 3px -2px rgb(0 0 0 / 20%),
8
+ 0px 3px 4px 0px rgb(0 0 0 / 14%), 0px 1px 8px 0px rgb(0 0 0 / 12%);
9
+ background: rgb(var(--surfaceContainerHighestColor, 230 224 233));
10
+ color: rgb(var(--onSurfaceColor, 28 27 31));
11
+ fill: rgb(var(--onSurfaceColor, 28 27 31));
12
+ z-index: 2;
13
+ }
14
+
15
+ .dropdawnCard.blur {
16
+ background-color: color-mix(
17
+ in srgb,
18
+ rgb(var(--surfaceContainerHighestColor, 230 224 233)) 85%,
19
+ transparent
20
+ );
21
+ backdrop-filter: blur(0.5rem);
22
+ }
23
+
24
+ .dropdawnCard::before {
25
+ content: "";
26
+ position: absolute;
27
+ top: -6px;
28
+ left: calc(50% - 6px);
29
+ width: 0;
30
+ height: 0;
31
+ border-left: 6px solid transparent;
32
+ border-right: 6px solid transparent;
33
+ border-bottom: 6px solid
34
+ rgb(var(--surfaceContainerHighestColor, 230 224 233));
35
+ }
36
+ .dropdawnCard.blur::before {
37
+ border-bottom: 6px solid
38
+ color-mix(
39
+ in srgb,
40
+ rgb(var(--surfaceContainerHighestColor, 230 224 233)) 85%,
41
+ transparent
42
+ );
43
+ }
44
+ .dropdawnCard.dropdawnOnTop::before {
45
+ top: initial;
46
+ bottom: -6px;
47
+ transform: scale(1, -1);
48
+ }
@@ -216,3 +216,4 @@ export const WithInteractions = forwardRef((_a, forwardedRef) => {
216
216
  return null;
217
217
  return cloneElement(children, Object.assign(Object.assign({}, restProps), { ref: mergeRefs(localRef, forwardedRef, (_b = children.props) === null || _b === void 0 ? void 0 : _b.ref) }));
218
218
  });
219
+ WithInteractions.displayName = "WithInteractions";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yakad/ui",
3
- "version": "1.3.107",
3
+ "version": "1.3.109",
4
4
  "private": false,
5
5
  "author": "Natiq",
6
6
  "description": "UI components for NextJS/React",