@yakad/ui 1.3.119 → 1.3.121

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.
@@ -7,7 +7,6 @@
7
7
  color: rgb(var(--onSurfaceColor, 28 27 31));
8
8
  fill: rgb(var(--onSurfaceColor, 28 27 31));
9
9
  overflow: hidden;
10
- background-color: red;
11
10
  }
12
11
 
13
12
  .card.blur {
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { CardProps } from "..";
3
+ export interface PopupProps extends CardProps {
4
+ align?: "start" | "space" | "center" | "end";
5
+ heading?: string;
6
+ onCloseButtClick?: () => void;
7
+ children?: React.ReactNode;
8
+ }
9
+ export declare const Popup: import("react").ForwardRefExoticComponent<PopupProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,21 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { forwardRef } from "react";
14
+ import classNames from "classnames";
15
+ import { Symbol } from "@yakad/symbols";
16
+ import { Button, Card, Row, Spacer, Stack, Text, WithInteractions, } from "..";
17
+ import styles from "./Popup.module.css";
18
+ export const Popup = forwardRef(function Popup(_a, ref) {
19
+ var { align, heading, onCloseButtClick, className, children } = _a, restProps = __rest(_a, ["align", "heading", "onCloseButtClick", "className", "children"]);
20
+ return (_jsx("div", { className: styles.popupscreen, children: _jsx(WithInteractions, { onOutsideClick: onCloseButtClick, children: _jsxs(Card, Object.assign({ ref: ref }, 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: onCloseButtClick })] }), _jsx(Stack, { align: align, style: { width: "100%", overflowY: "auto" }, children: children })] })) }) }));
21
+ });
@@ -0,0 +1,20 @@
1
+ .popupscreen {
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ display: flex;
8
+ justify-content: center;
9
+ align-items: center;
10
+ background-color: rgba(var(--surfaceContainerColor, 243 237 247), 0.2);
11
+ backdrop-filter: blur(0.2rem);
12
+ z-index: 3;
13
+ }
14
+
15
+ .popup {
16
+ width: 90%;
17
+ max-width: 60rem;
18
+ min-height: 10rem;
19
+ max-height: 90vh;
20
+ }
@@ -34,8 +34,8 @@ export function WithDropdawn(_a) {
34
34
  const padding = 10;
35
35
  let dTop = buttonRect.bottom + padding;
36
36
  let dX = buttonRect.x + buttonRect.width / 2;
37
- let aTop = top;
38
- let aX = dX;
37
+ let aTop = dTop;
38
+ const aX = dX;
39
39
  // Prevent overflow bottom
40
40
  if (dTop + dropdawnRect.height > window.innerHeight) {
41
41
  dTop = buttonRect.top - dropdawnRect.height - padding;
@@ -214,5 +214,8 @@ export const WithInteractions = forwardRef(function WithInteractions(_a, forward
214
214
  ]);
215
215
  if (!isValidElement(children))
216
216
  return null;
217
- return cloneElement(children, Object.assign(Object.assign({}, restProps), { ref: mergeRefs(localRef, forwardedRef, (_b = children.props) === null || _b === void 0 ? void 0 : _b.ref) }));
217
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
218
+ return cloneElement(children, Object.assign(Object.assign({}, restProps), { ref: mergeRefs(localRef, forwardedRef,
219
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
220
+ (_b = children.props) === null || _b === void 0 ? void 0 : _b.ref) }));
218
221
  });
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { PopupProps } from "..";
3
+ export interface WithPopupProps extends Omit<PopupProps, "onCloseButtClick"> {
4
+ align?: "start" | "space" | "center" | "end";
5
+ blur?: boolean;
6
+ trigger?: "onClick" | "onRightClick";
7
+ popupChildren?: React.ReactElement;
8
+ children?: React.ReactElement<{
9
+ onClick?: (e: React.MouseEvent<HTMLElement>) => void;
10
+ }>;
11
+ }
12
+ export declare function WithPopup({ trigger, popupChildren, children, ...restProps }: WithPopupProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,27 @@
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, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { useState, cloneElement } from "react";
15
+ import { Popup, WithInteractions } from "..";
16
+ export function WithPopup(_a) {
17
+ var { trigger = "onClick", popupChildren, children } = _a, restProps = __rest(_a, ["trigger", "popupChildren", "children"]);
18
+ const [showPopup, setShowPopup] = useState(false);
19
+ return (_jsxs("div", { children: [_jsx(WithInteractions, { onRightClick: () => trigger === "onRightClick" && setShowPopup(true), children: children &&
20
+ cloneElement(children, {
21
+ onClick: (e) => {
22
+ var _a, _b;
23
+ (_b = (_a = children.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
24
+ trigger === "onClick" && setShowPopup(true);
25
+ },
26
+ }) }), _jsx("div", { children: showPopup && (_jsx(Popup, Object.assign({ onCloseButtClick: () => setShowPopup(false) }, restProps, { children: popupChildren }))) })] }));
27
+ }
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export * from "./Card/Card";
12
12
  export * from "./Theme/Theme";
13
13
  export * from "./Spacer/Spacer";
14
14
  export * from "./Hr/Hr";
15
+ export * from "./Popup/Popup";
15
16
  export * from "./List/List";
16
17
  export * from "./ListItem/ListItem";
17
18
  export * from "./Table/Table";
@@ -30,3 +31,4 @@ export * from "./CodeBox/CodeBox";
30
31
  export * from "./Display/Display";
31
32
  export * from "./WithInteractions/WithInteractions";
32
33
  export * from "./WithDropdawn/WithDropdawn";
34
+ export * from "./WithPopup/WithPopup";
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ export * from "./Theme/Theme";
15
15
  export * from "./Spacer/Spacer";
16
16
  export * from "./Hr/Hr";
17
17
  // UI Components
18
+ export * from "./Popup/Popup";
18
19
  export * from "./List/List";
19
20
  export * from "./ListItem/ListItem";
20
21
  export * from "./Table/Table";
@@ -35,3 +36,4 @@ export * from "./CodeBox/CodeBox";
35
36
  export * from "./Display/Display";
36
37
  export * from "./WithInteractions/WithInteractions";
37
38
  export * from "./WithDropdawn/WithDropdawn";
39
+ export * from "./WithPopup/WithPopup";
package/package.json CHANGED
@@ -1,17 +1,11 @@
1
1
  {
2
2
  "name": "@yakad/ui",
3
- "version": "1.3.119",
3
+ "version": "1.3.121",
4
4
  "private": false,
5
5
  "author": "Natiq",
6
6
  "description": "UI components for NextJS/React",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "import": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
13
- }
14
- },
15
9
  "keywords": [
16
10
  "yakad",
17
11
  "react",
@@ -34,7 +28,7 @@
34
28
  "typecheck": "tsc --noEmit",
35
29
  "lint": "eslint src/**/*.{ts,tsx}",
36
30
  "test": "echo \"No tests specified\" && exit 0",
37
- "prepublishOnly": "npm run test && npm run build && npm run typecheck",
31
+ "prepublishOnly": "npm run lint && npm run test && npm run build && npm run typecheck",
38
32
  "newPublish": "npm version patch && npm publish"
39
33
  },
40
34
  "dependencies": {