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