ar-design 0.2.66 → 0.2.68

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,6 +1,7 @@
1
1
  .ar-modal-wrapper {
2
2
  position: fixed;
3
3
  inset: 0;
4
+ z-index: 1050;
4
5
  }
5
6
  .ar-modal-wrapper > .ar-modal-bg {
6
7
  position: fixed;
@@ -1,3 +1,14 @@
1
+ .ar-notification-popup-wrapper {
2
+ position: fixed;
3
+ inset: 0;
4
+ z-index: 1050;
5
+ }
6
+ .ar-notification-popup-wrapper > .ar-notification-popup-bg {
7
+ position: fixed;
8
+ inset: 0;
9
+ background-color: rgba(var(--black-rgb), 0.5);
10
+ }
11
+
1
12
  .ar-notification-popup {
2
13
  visibility: hidden;
3
14
  opacity: 0;
@@ -39,15 +50,15 @@
39
50
  border-radius: var(--border-radius-pill);
40
51
  box-shadow: 0 0 0 5px rgba(var(--success-rgb), 0.25);
41
52
  }
42
- .ar-notification-popup > .icon.success::before {
43
- content: "";
44
- width: 3rem;
45
- height: 1.75rem;
46
- transform: rotate(-45deg);
47
- border: solid 10.5px transparent;
48
- border-radius: var(--border-radius-sm);
49
- border-left-color: var(--white);
50
- border-bottom-color: var(--white);
53
+
54
+ .ar-notification-popup > .icon.warning {
55
+ position: relative;
56
+ display: flex;
57
+ justify-content: center;
58
+ align-items: center;
59
+ background-color: var(--warning);
60
+ border-radius: var(--border-radius-pill);
61
+ box-shadow: 0 0 0 5px rgba(var(--warning-rgb), 0.25);
51
62
  }
52
63
 
53
64
  .ar-notification-popup > .icon.error {
@@ -59,24 +70,6 @@
59
70
  border-radius: var(--border-radius-pill);
60
71
  box-shadow: 0 0 0 5px rgba(var(--danger-rgb), 0.25);
61
72
  }
62
- .ar-notification-popup > .icon.error::before {
63
- position: absolute;
64
- content: "";
65
- background-color: var(--white);
66
- width: 10.5px;
67
- height: 3.5rem;
68
- transform: rotate(-45deg);
69
- border-radius: var(--border-radius-sm);
70
- }
71
- .ar-notification-popup > .icon.error::after {
72
- position: absolute;
73
- content: "";
74
- background-color: var(--white);
75
- width: 10.5px;
76
- height: 3.5rem;
77
- transform: rotate(45deg);
78
- border-radius: var(--border-radius-sm);
79
- }
80
73
 
81
74
  .ar-notification-popup > .content {
82
75
  display: flex;
@@ -88,17 +81,11 @@
88
81
  color: var(--gray-700);
89
82
  }
90
83
  .ar-notification-popup > .content > .title {
84
+ color: var(--gray-700);
91
85
  font-size: 1.75rem;
92
86
  text-align: center;
93
87
  }
94
88
 
95
- .ar-notification-popup > .content > .title.success {
96
- color: var(--success);
97
- }
98
- .ar-notification-popup > .content > .title.error {
99
- color: var(--danger);
100
- }
101
-
102
89
  .ar-notification-popup > .content > .message {
103
90
  color: var(--gray-600);
104
91
  text-align: center;
@@ -1,33 +1,84 @@
1
1
  "use client";
2
- import React, { useContext, useEffect, useState } from "react";
2
+ import React, { useContext, useEffect, useRef, useState } from "react";
3
3
  import "../../../assets/css/components/feedback/popup/popup.css";
4
4
  import Button from "../../form/button";
5
5
  import ReactDOM from "react-dom";
6
6
  import { NotificationContext } from "../../../libs/core/application/contexts/Notification";
7
+ import { ARIcon } from "../../icons";
7
8
  const Popup = ({ title, message, status, isOpen, buttons }) => {
9
+ // contexts
8
10
  const { setIsPopupOpen } = useContext(NotificationContext);
11
+ // refs
12
+ const _arNotificationPopupWrapper = useRef(null);
13
+ const _arNotificationPopup = useRef(null);
9
14
  // states
15
+ const _notificaitonPopupWrapperClassName = ["ar-notification-popup-wrapper"];
10
16
  const [className, setClassName] = useState(["ar-notification-popup", ""]);
17
+ // methods
18
+ const buttonStatus = () => {
19
+ switch (status) {
20
+ case "success":
21
+ return "success";
22
+ case "warning":
23
+ return "warning";
24
+ case "information":
25
+ return "information";
26
+ case "error":
27
+ return "danger";
28
+ default:
29
+ return "light";
30
+ }
31
+ };
32
+ const buttonIcons = () => {
33
+ switch (status) {
34
+ case "success":
35
+ return React.createElement(ARIcon, { icon: "Success", fill: "transparent", stroke: "var(--white)", size: 48 });
36
+ case "warning":
37
+ return React.createElement(ARIcon, { icon: "Warning", fill: "transparent", stroke: "var(--white)", size: 48 });
38
+ case "information":
39
+ return "information";
40
+ case "error":
41
+ return React.createElement(ARIcon, { icon: "CloseCircle", fill: "transparent", stroke: "var(--white)", size: 48 });
42
+ default:
43
+ return "light";
44
+ }
45
+ };
11
46
  // useEffects
12
47
  useEffect(() => {
13
48
  setClassName((prev) => {
14
49
  const updated = [...prev.slice(0, -1), isOpen ? "open" : ""];
15
50
  return updated;
16
51
  });
52
+ if (isOpen)
53
+ document.body.style.overflow = "hidden";
54
+ return () => {
55
+ document.body.style.removeProperty("overflow");
56
+ };
17
57
  }, [isOpen]);
18
58
  return (isOpen &&
19
- ReactDOM.createPortal(React.createElement("div", { className: className.map((c) => c).join(" ") },
20
- React.createElement("div", { className: `icon ${status}` }),
21
- React.createElement("div", { className: "content" },
22
- React.createElement("span", { className: `title ${status}` },
23
- title,
24
- "!"),
25
- React.createElement("span", { className: "message" }, message)),
26
- React.createElement(Button, { variant: "filled", status: status == "success" ? "success" : "danger", onClick: () => {
27
- (() => buttons?.okay?.onClick && buttons.okay?.onClick())();
28
- (() => {
29
- setIsPopupOpen && setIsPopupOpen((prev) => !prev);
30
- })();
31
- } }, buttons?.okay?.text ?? "Tamam")), document.body));
59
+ ReactDOM.createPortal(React.createElement("div", { ref: _arNotificationPopupWrapper, className: _notificaitonPopupWrapperClassName.map((c) => c).join(" ") },
60
+ React.createElement("div", { className: "ar-notification-popup-bg", onMouseDown: (event) => {
61
+ event.stopPropagation();
62
+ const target = event.target;
63
+ if (_arNotificationPopup.current && !_arNotificationPopup.current.contains(target)) {
64
+ setClassName((prev) => {
65
+ const updated = [...prev.slice(0, -1), isOpen ? "open" : ""];
66
+ return updated;
67
+ });
68
+ }
69
+ } }),
70
+ React.createElement("div", { ref: _arNotificationPopup, className: className.map((c) => c).join(" ") },
71
+ React.createElement("div", { className: `icon ${status}` }, buttonIcons()),
72
+ React.createElement("div", { className: "content" },
73
+ React.createElement("span", { className: `title ${status}` },
74
+ title,
75
+ "!"),
76
+ React.createElement("span", { className: "message" }, message)),
77
+ React.createElement(Button, { variant: "filled", status: buttonStatus(), onClick: () => {
78
+ (() => buttons?.okay?.onClick && buttons.okay?.onClick())();
79
+ (() => {
80
+ setIsPopupOpen && setIsPopupOpen((prev) => !prev);
81
+ })();
82
+ } }, buttons?.okay?.text ?? "Tamam"))), document.body));
32
83
  };
33
84
  export default Popup;
@@ -29,8 +29,8 @@ validation, }) => {
29
29
  // variables
30
30
  const toolbarButtons = [
31
31
  { command: "bold", icon: "Bold", tooltip: `Bold (${Utils.GetOSShortCutIcons()} + B)` },
32
- { command: "italic", icon: "Italic", tooltip: `Bold (${Utils.GetOSShortCutIcons()} + I)` },
33
- { command: "underline", icon: "Underline", tooltip: `Bold (${Utils.GetOSShortCutIcons()} + U)` },
32
+ { command: "italic", icon: "Italic", tooltip: `Italic (${Utils.GetOSShortCutIcons()} + I)` },
33
+ { command: "underline", icon: "Underline", tooltip: `Underline (${Utils.GetOSShortCutIcons()} + U)` },
34
34
  { command: "insertUnorderedList", icon: "BulletList", tooltip: "Bulleted List" },
35
35
  { command: "insertOrderedList", icon: "NumberList", tooltip: "Numbered List" },
36
36
  { command: "justifyLeft", icon: "TextAlingLeft", tooltip: "Align Left" },
@@ -212,7 +212,7 @@ validation, }) => {
212
212
  }, []);
213
213
  return (React.createElement("div", { ref: _container, className: "ar-text-editor" },
214
214
  React.createElement("iframe", { ref: _arIframe, name: name, className: _iframeClassName.map((c) => c).join(" "), height: height }),
215
- React.createElement("div", { className: "toolbar" }, toolbarButtons.map(({ command, icon, tooltip }) => (React.createElement(Button, { key: command, type: "button", variant: "borderless", status: "secondary", border: { radius: "none" }, icon: { element: React.createElement(ARIcon, { icon: icon, size: 18, fill: "var(--gray-700)" }) }, tooltip: {
215
+ React.createElement("div", { className: "toolbar" }, toolbarButtons.map(({ command, icon, tooltip }) => (React.createElement(Button, { key: command, type: "button", variant: "borderless", status: "secondary", border: { radius: "none" }, icon: { element: React.createElement(ARIcon, { icon: icon, size: 18, fill: "transparent" }) }, tooltip: {
216
216
  text: tooltip,
217
217
  }, onClick: () => execCommand(command) })))),
218
218
  React.createElement("div", { className: "resize", onMouseDown: handleMouseDown }),
@@ -53,6 +53,11 @@ class Icon {
53
53
  React.createElement("line", { x1: "4", y1: "12", x2: "20", y2: "12", stroke: this._stroke, strokeWidth: this._strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" }),
54
54
  React.createElement("path", { d: "M6 4h12", stroke: this._stroke, strokeWidth: this._strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" }),
55
55
  React.createElement("path", { d: "M6 20h12", stroke: this._stroke, strokeWidth: this._strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })));
56
+ case "Success":
57
+ return (React.createElement(React.Fragment, null,
58
+ React.createElement("path", { d: "M22 11.1V6.9C22 3.4 20.6 2 17.1 2h-4.2C9.4 2 8 3.4 8 6.9V8h3.1c3.5 0 4.9 1.4 4.9 4.9V16h1.1c3.5 0 4.9-1.4 4.9-4.9z", stroke: this._stroke, strokeWidth: this._strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" }),
59
+ React.createElement("path", { d: "M16 17.1v-4.2C16 9.4 14.6 8 11.1 8H6.9C3.4 8 2 9.4 2 12.9v4.2C2 20.6 3.4 22 6.9 22h4.2c3.5 0 4.9-1.4 4.9-4.9z", stroke: this._stroke, strokeWidth: this._strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" }),
60
+ React.createElement("path", { d: "M6.08 15l1.95 1.95 3.89-3.9", stroke: this._stroke, strokeWidth: this._strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })));
56
61
  case "BulletList":
57
62
  return (React.createElement(React.Fragment, null,
58
63
  React.createElement("circle", { cx: 3, cy: this._startIndex, r: 2, fill: "currentColor" }),
@@ -91,6 +96,10 @@ class Icon {
91
96
  return (React.createElement(React.Fragment, null,
92
97
  React.createElement("path", { d: "M12 22c5.5 0 10-4.5 10-10S17.5 2 12 2 2 6.5 2 12s4.5 10 10 10Z", stroke: this._stroke, strokeWidth: this._strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" }),
93
98
  React.createElement("path", { d: "m7.75 12 2.83 2.83 5.67-5.66", stroke: this._stroke, strokeWidth: this._strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })));
99
+ case "Warning":
100
+ return (React.createElement(React.Fragment, null,
101
+ React.createElement("path", { d: "M12 7.75V13M2.92 8.58c0-1.12.6-2.16 1.57-2.73l5.94-3.43c.97-.56 2.17-.56 3.15 0l5.94 3.43c.97.56 1.57 1.6 1.57 2.73v6.84c0 1.12-.6 2.16-1.57 2.73l-5.94 3.43c-.97.56-2.17.56-3.15 0l-5.94-3.43a3.15 3.15 0 0 1-1.57-2.73v-2.76", stroke: this._stroke, strokeWidth: this._strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" }),
102
+ React.createElement("path", { d: "M12 16.2v.1", stroke: this._stroke, strokeWidth: this._strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })));
94
103
  default:
95
104
  return null;
96
105
  }
@@ -50,12 +50,11 @@ export declare const useNotification: () => {
50
50
  message?: string;
51
51
  status: Status | number;
52
52
  }) => void;
53
- popup: ({ title, message, status, buttons, }: {
53
+ popup: ({ title, message, status, }: {
54
54
  title: string;
55
55
  message?: string;
56
56
  status: Status | number;
57
- buttons?: PopupButtonProps | null;
58
- }) => void;
57
+ }, buttons?: PopupButtonProps | null) => void;
59
58
  };
60
59
  export declare const useValidation: <TData extends object>(data: TData, params: ValidationProperties<TData>[], step?: number) => {
61
60
  onSubmit: (callback: (result: boolean) => void) => void;
@@ -33,7 +33,7 @@ export const useNotification = () => {
33
33
  setStatus && setStatus(status);
34
34
  setTrigger && setTrigger((trigger) => !trigger);
35
35
  };
36
- const popup = ({ title, message, status, buttons, }) => {
36
+ const popup = ({ title, message, status, }, buttons) => {
37
37
  setTitle && setTitle(title);
38
38
  setMessage && setMessage(message ?? "");
39
39
  setStatus && setStatus(status);
@@ -69,7 +69,7 @@ export type Errors<TData> = Partial<{
69
69
  }>;
70
70
  export type AllowedTypes = "image/jpeg" | "image/png" | "image/gif" | "image/webp" | "image/svg+xml" | "image/bmp" | "image/tiff" | "application/pdf" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/zip" | "application/x-rar-compressed" | "application/x-7z-compressed" | "application/gzip" | "application/json" | "application/xml" | "text/plain" | "text/csv" | "text/html" | "video/mp4" | "video/quicktime" | "video/x-msvideo" | "video/x-matroska" | "video/webm" | "video/x-flv" | "audio/mpeg" | "audio/wav" | "audio/ogg" | "audio/aac" | "audio/flac" | "application/octet-stream";
71
71
  export type IconVariants = "linear" | "bulk";
72
- export type Icons = "Add" | "ArrowLeft" | "ArrowRight" | "CloseCircle" | "CloseSquare" | "Drive" | "Document" | "Folder" | "Trash" | "Upload" | "Image" | "Import" | "Bold" | "Italic" | "Underline" | "Strikethrough" | "BulletList" | "NumberList" | "TextAlingLeft" | "TextAlingCenter" | "TextAlingRight" | "Filter" | "TickCircle" | "File";
72
+ export type Icons = "Add" | "ArrowLeft" | "ArrowRight" | "CloseCircle" | "CloseSquare" | "Drive" | "Document" | "Folder" | "Trash" | "Upload" | "Image" | "Import" | "Bold" | "Italic" | "Underline" | "Success" | "Strikethrough" | "BulletList" | "NumberList" | "TextAlingLeft" | "TextAlingCenter" | "TextAlingRight" | "Filter" | "TickCircle" | "File" | "Warning";
73
73
  export type PieChartDataType = {
74
74
  value: number;
75
75
  text: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.2.66",
3
+ "version": "0.2.68",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",