ar-design 0.3.39 → 0.3.40

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.
@@ -62,6 +62,16 @@
62
62
  box-shadow: 0 0 0 5px rgba(var(--warning-rgb), 0.25);
63
63
  }
64
64
 
65
+ .ar-notification-popup > .icon.information {
66
+ position: relative;
67
+ display: flex;
68
+ justify-content: center;
69
+ align-items: center;
70
+ background-color: var(--information);
71
+ border-radius: var(--border-radius-pill);
72
+ box-shadow: 0 0 0 5px rgba(var(--information-rgb), 0.25);
73
+ }
74
+
65
75
  .ar-notification-popup > .icon.error {
66
76
  position: relative;
67
77
  display: flex;
@@ -5,5 +5,6 @@ interface IProps {
5
5
  status: Status | number;
6
6
  isOpen: boolean;
7
7
  buttons?: PopupButtonProps | null;
8
+ onConfirm?: ((confirm: boolean) => void) | null;
8
9
  }
9
10
  export default IProps;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import IProps from "./IProps";
3
3
  import "../../../assets/css/components/feedback/popup/popup.css";
4
- declare const Popup: ({ title, message, status, isOpen, buttons }: IProps) => false | React.ReactPortal;
4
+ declare const Popup: ({ title, message, status, isOpen, buttons, onConfirm }: IProps) => false | React.ReactPortal;
5
5
  export default Popup;
@@ -6,7 +6,7 @@ import ReactDOM from "react-dom";
6
6
  import { NotificationContext } from "../../../libs/core/application/contexts/Notification";
7
7
  import { ARIcon } from "../../icons";
8
8
  import Box from "../../data-display/grid-system/box/Box";
9
- const Popup = ({ title, message, status, isOpen, buttons }) => {
9
+ const Popup = ({ title, message, status, isOpen, buttons, onConfirm }) => {
10
10
  // contexts
11
11
  const { setIsPopupOpen } = useContext(NotificationContext);
12
12
  // refs
@@ -23,7 +23,7 @@ const Popup = ({ title, message, status, isOpen, buttons }) => {
23
23
  case "warning":
24
24
  return "orange";
25
25
  case "information":
26
- return "teal";
26
+ return "cyan";
27
27
  case "error":
28
28
  return "red";
29
29
  default:
@@ -37,7 +37,7 @@ const Popup = ({ title, message, status, isOpen, buttons }) => {
37
37
  case "warning":
38
38
  return React.createElement(ARIcon, { icon: "ExclamationDiamond-Fill", fill: "var(--white)", size: 48 });
39
39
  case "information":
40
- return "information";
40
+ return React.createElement(ARIcon, { icon: "Information-Circle-Fill", fill: "var(--white)", size: 48 });
41
41
  case "error":
42
42
  return React.createElement(ARIcon, { icon: "XCircle-Fill", fill: "var(--white)", size: 48 });
43
43
  default:
@@ -76,17 +76,15 @@ const Popup = ({ title, message, status, isOpen, buttons }) => {
76
76
  "!"),
77
77
  React.createElement("span", { className: "message" }, message)),
78
78
  React.createElement(Box, null,
79
- React.createElement(Button, { variant: "filled", color: buttonColor(), onClick: () => {
80
- (() => buttons?.okay?.onClick && buttons.okay?.onClick())();
81
- (() => {
82
- setIsPopupOpen && setIsPopupOpen((prev) => !prev);
83
- })();
84
- } }, buttons?.okay?.text ?? "Tamam"),
85
- buttons?.cancel && (React.createElement(Button, { variant: "filled", color: "light", onClick: () => {
86
- (() => buttons?.cancel?.onClick && buttons.cancel?.onClick())();
87
- (() => {
88
- setIsPopupOpen && setIsPopupOpen((prev) => !prev);
89
- })();
90
- } }, buttons?.cancel?.text ?? "İptal"))))), document.body));
79
+ React.createElement(Button, { type: "button", color: buttonColor(), onClick: () => {
80
+ buttons?.okay?.onClick?.();
81
+ onConfirm?.(true);
82
+ setIsPopupOpen?.((prev) => !prev);
83
+ } }, buttons?.okay?.text ?? "Evet"),
84
+ buttons?.cancel && (React.createElement(Button, { type: "button", onClick: () => {
85
+ buttons?.cancel?.onClick?.();
86
+ onConfirm?.(false);
87
+ setIsPopupOpen?.((prev) => !prev);
88
+ } }, buttons?.cancel?.text ?? "Hayır"))))), document.body));
91
89
  };
92
90
  export default Popup;
@@ -92,6 +92,8 @@ class Icon {
92
92
  React.createElement("path", { d: "M12 3V16M12 16L16 11.625M12 16L8 11.625", stroke: this._stroke, strokeWidth: this._strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })));
93
93
  case "Inbox-Fill":
94
94
  return (React.createElement("path", { d: "M4.98 4a.5.5 0 0 0-.39.188L1.54 8H6a.5.5 0 0 1 .5.5 1.5 1.5 0 1 0 3 0A.5.5 0 0 1 10 8h4.46l-3.05-3.812A.5.5 0 0 0 11.02 4zm-1.17-.437A1.5 1.5 0 0 1 4.98 3h6.04a1.5 1.5 0 0 1 1.17.563l3.7 4.625a.5.5 0 0 1 .106.374l-.39 3.124A1.5 1.5 0 0 1 14.117 13H1.883a1.5 1.5 0 0 1-1.489-1.314l-.39-3.124a.5.5 0 0 1 .106-.374z" }));
95
+ case "Information-Circle-Fill":
96
+ return (React.createElement("path", { d: "M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2" }));
95
97
  case "Italic":
96
98
  return (React.createElement("path", { d: "M7.991 11.674 9.53 4.455c.123-.595.246-.71 1.347-.807l.11-.52H7.211l-.11.52c1.06.096 1.128.212 1.005.807L6.57 11.674c-.123.595-.246.71-1.346.806l-.11.52h3.774l.11-.52c-1.06-.095-1.129-.211-1.006-.806z" }));
97
99
  case "NumberList":
@@ -1,6 +1,7 @@
1
1
  import { StepProps, ValidationProperties } from "../../../libs/types";
2
2
  import { IChildren } from "../../../libs/types/IGlobalProps";
3
3
  interface IProps<TData extends object> extends IChildren {
4
+ name: string;
4
5
  steps: StepProps[];
5
6
  onChange: (currentStep: number) => void;
6
7
  validation?: {
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import IProps from "./IProps";
3
3
  import "../../../assets/css/components/navigation/steps/styles.css";
4
- declare const Steps: <T extends object>({ children, steps, onChange, validation }: IProps<T>) => React.JSX.Element;
4
+ declare const Steps: <T extends object>({ children, name, steps, onChange, validation }: IProps<T>) => React.JSX.Element;
5
5
  export default Steps;
@@ -5,18 +5,11 @@ import Typography from "../../data-display/typography";
5
5
  import Button from "../../form/button";
6
6
  import { useValidation } from "../../../libs/core/application/hooks";
7
7
  const { Title } = Typography;
8
- const Steps = function ({ children, steps = [], onChange, validation }) {
8
+ const Steps = function ({ children, name, steps = [], onChange, validation }) {
9
9
  // states
10
10
  const [currentStep, setCurrentStep] = useState(0);
11
- let _errors;
12
- let _onSubmit;
13
- let _setSubmit;
14
- if (validation) {
15
- const { errors, onSubmit, setSubmit } = useValidation(validation.data, validation.rules, currentStep + 1);
16
- _errors = errors;
17
- _onSubmit = onSubmit;
18
- _setSubmit = setSubmit;
19
- }
11
+ // hooks
12
+ const { errors, onSubmit, setSubmit } = useValidation(validation?.data, validation?.rules, currentStep + 1);
20
13
  // methods
21
14
  const getStepIconStatus = (currentStep, index) => {
22
15
  if (currentStep < index)
@@ -26,7 +19,12 @@ const Steps = function ({ children, steps = [], onChange, validation }) {
26
19
  return "completed";
27
20
  };
28
21
  // useEffects
29
- useEffect(() => onChange(0), []);
22
+ useEffect(() => {
23
+ const key = `${window.location.pathname}::${name}`;
24
+ const stored = sessionStorage.getItem(key);
25
+ setCurrentStep(stored !== null ? Number(stored) : 0);
26
+ onChange?.(stored !== null ? Number(stored) : 0);
27
+ }, []);
30
28
  return (React.createElement("div", { className: "ar-steps" },
31
29
  React.createElement("div", { className: "steps" }, steps.length > 0 &&
32
30
  steps.map((step, index) => {
@@ -34,18 +32,20 @@ const Steps = function ({ children, steps = [], onChange, validation }) {
34
32
  itemIcon.push(getStepIconStatus(currentStep, index));
35
33
  return (React.createElement("div", { key: step.title || index, className: "item", onClick: () => {
36
34
  if (validation) {
37
- _onSubmit((result) => {
35
+ onSubmit((result) => {
38
36
  if (!result)
39
37
  return;
40
38
  setCurrentStep(index);
41
39
  onChange(index);
42
- _setSubmit(false);
40
+ setSubmit(false);
43
41
  });
44
42
  }
45
43
  else {
46
44
  setCurrentStep(index);
47
45
  onChange(index);
48
46
  }
47
+ const key = `${window.location.pathname}::${name}`;
48
+ sessionStorage.setItem(key, String(index));
49
49
  } },
50
50
  React.createElement("div", { className: itemIcon.map((c) => c).join(" ") },
51
51
  React.createElement("span", { className: getStepIconStatus(currentStep, index) })),
@@ -61,7 +61,7 @@ const Steps = function ({ children, steps = [], onChange, validation }) {
61
61
  if (React.isValidElement(child) && stepIndex === currentStep) {
62
62
  return validation
63
63
  ? React.cloneElement(child, {
64
- errors: _errors,
64
+ errors: errors,
65
65
  })
66
66
  : child;
67
67
  }
@@ -76,18 +76,20 @@ const Steps = function ({ children, steps = [], onChange, validation }) {
76
76
  children && children,
77
77
  currentStep < steps.length - 1 && (React.createElement(Button, { color: "blue", onClick: () => {
78
78
  if (validation) {
79
- _onSubmit((result) => {
79
+ onSubmit((result) => {
80
80
  if (!result)
81
81
  return;
82
82
  setCurrentStep((prev) => prev + 1);
83
83
  onChange(currentStep + 1);
84
- _setSubmit(false);
84
+ setSubmit(false);
85
85
  });
86
86
  }
87
87
  else {
88
88
  setCurrentStep((prev) => prev + 1);
89
89
  onChange(currentStep + 1);
90
90
  }
91
+ const key = `${window.location.pathname}::${name}`;
92
+ sessionStorage.setItem(key, String(currentStep + 1));
91
93
  } }, "\u0130leri"))))));
92
94
  };
93
95
  export default Steps;
@@ -22,6 +22,7 @@ type NotificationContextProps = {
22
22
  setTrigger: React.Dispatch<React.SetStateAction<boolean>>;
23
23
  setIsPopupOpen: React.Dispatch<React.SetStateAction<boolean>>;
24
24
  setPopupButtons: React.Dispatch<React.SetStateAction<PopupButtonProps | null>>;
25
+ setOnConfirm: React.Dispatch<React.SetStateAction<((confirm: boolean) => void) | null>>;
25
26
  };
26
27
  declare const NotificationContext: React.Context<Partial<NotificationContextProps>>;
27
28
  declare const NotificationProvider: ({ children, direction }: Props) => React.JSX.Element;
@@ -10,6 +10,7 @@ const NotificationProvider = ({ children, direction }) => {
10
10
  const [trigger, setTrigger] = useState(false);
11
11
  const [isPopupOpen, setIsPopupOpen] = useState(false);
12
12
  const [popupButtons, setPopupButtons] = useState(null);
13
+ const [onConfirm, setOnConfirm] = useState(null);
13
14
  return (React.createElement(NotificationContext.Provider, { value: {
14
15
  setTitle,
15
16
  setMessage,
@@ -17,9 +18,10 @@ const NotificationProvider = ({ children, direction }) => {
17
18
  setTrigger,
18
19
  setIsPopupOpen,
19
20
  setPopupButtons,
21
+ setOnConfirm,
20
22
  } },
21
23
  children,
22
24
  React.createElement(Notification, { title: title, message: message, status: status, direction: direction, trigger: trigger }),
23
- React.createElement(Popup, { title: title, message: message, status: status, isOpen: isPopupOpen, buttons: popupButtons })));
25
+ React.createElement(Popup, { title: title, message: message, status: status, isOpen: isPopupOpen, buttons: popupButtons, onConfirm: onConfirm })));
24
26
  };
25
27
  export { NotificationContext, NotificationProvider };
@@ -54,7 +54,7 @@ export declare const useNotification: () => {
54
54
  title: string;
55
55
  message?: string;
56
56
  status: Status | number;
57
- }, buttons?: PopupButtonProps | null) => void;
57
+ }, buttons?: PopupButtonProps | null, onConfirm?: (confirm: boolean) => void) => void;
58
58
  };
59
59
  export declare const useValidation: <TData extends object>(data: TData, params: ValidationProperties<TData>[], step?: number) => {
60
60
  onSubmit: (callback: (result: boolean) => void) => void;
@@ -26,20 +26,21 @@ export const useTranslation = function (currentLanguage, translations) {
26
26
  };
27
27
  export const useNotification = () => {
28
28
  // contexts
29
- const { setTitle, setMessage, setStatus, setTrigger, setIsPopupOpen, setPopupButtons } = useContext(NotificationContext);
29
+ const { setTitle, setMessage, setStatus, setTrigger, setIsPopupOpen, setPopupButtons, setOnConfirm } = useContext(NotificationContext);
30
30
  // methods
31
31
  const notification = ({ title, message, status }) => {
32
- setTitle && setTitle(title);
33
- setMessage && setMessage(message ?? "");
34
- setStatus && setStatus(status);
35
- setTrigger && setTrigger((trigger) => !trigger);
32
+ setTitle?.(title);
33
+ setMessage?.(message ?? "");
34
+ setStatus?.(status);
35
+ setTrigger?.((trigger) => !trigger);
36
36
  };
37
- const popup = ({ title, message, status, }, buttons) => {
38
- setTitle && setTitle(title);
39
- setMessage && setMessage(message ?? "");
40
- setStatus && setStatus(status);
41
- setIsPopupOpen && setIsPopupOpen((trigger) => !trigger);
42
- setPopupButtons && setPopupButtons(buttons ?? null);
37
+ const popup = ({ title, message, status, }, buttons, onConfirm) => {
38
+ setTitle?.(title);
39
+ setMessage?.(message ?? "");
40
+ setStatus?.(status);
41
+ setIsPopupOpen?.((trigger) => !trigger);
42
+ setPopupButtons?.(buttons ?? null);
43
+ setOnConfirm?.(() => onConfirm);
43
44
  };
44
45
  return { notification, popup };
45
46
  };
@@ -83,7 +83,7 @@ export type Errors<TData> = Partial<{
83
83
  }>;
84
84
  export type MimeTypes = "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";
85
85
  export type FileCategory = "image" | "document" | "spreadsheet" | "presentation" | "archive" | "text" | "video" | "audio" | "json" | "xml" | "binary" | "other";
86
- export type Icons = "Add" | "ArrowLeft" | "ArrowRight" | "Bold" | "BulletList" | "CameraReels" | "CheckAll" | "CloseCircle" | "CloseSquare" | "CloudUpload-Fill" | "Dash" | "Document" | "Download" | "ExclamationCircle" | "ExclamationDiamond-Fill" | "Eye-Fill" | "File" | "FileEarmark-Fill" | "FileTypeCsv" | "FileTypeDoc" | "FileTypeDocx" | "FileTypeHtml" | "FileTypeJson" | "FileTypePdf" | "FileTypePptx" | "FileTypeTxt" | "FileTypeXls" | "FileTypeXlsx" | "FileTypeXml" | "FileTypeZip" | "Filter" | "Folder" | "Front" | "GripVertical" | "Import" | "Inbox-Fill" | "Italic" | "NumberList" | "Strikethrough" | "TextAlingCenter" | "TextAlingLeft" | "TextAlingRight" | "TickCircle" | "Trash-Fill" | "Underline" | "Upload" | "Warning" | "XCircle-Fill";
86
+ export type Icons = "Add" | "ArrowLeft" | "ArrowRight" | "Bold" | "BulletList" | "CameraReels" | "CheckAll" | "CloseCircle" | "CloseSquare" | "CloudUpload-Fill" | "Dash" | "Document" | "Download" | "ExclamationCircle" | "ExclamationDiamond-Fill" | "Eye-Fill" | "File" | "FileEarmark-Fill" | "FileTypeCsv" | "FileTypeDoc" | "FileTypeDocx" | "FileTypeHtml" | "FileTypeJson" | "FileTypePdf" | "FileTypePptx" | "FileTypeTxt" | "FileTypeXls" | "FileTypeXlsx" | "FileTypeXml" | "FileTypeZip" | "Filter" | "Folder" | "Front" | "GripVertical" | "Import" | "Inbox-Fill" | "Information-Circle-Fill" | "Italic" | "NumberList" | "Strikethrough" | "TextAlingCenter" | "TextAlingLeft" | "TextAlingRight" | "TickCircle" | "Trash-Fill" | "Underline" | "Upload" | "Warning" | "XCircle-Fill";
87
87
  export type PieChartDataType = {
88
88
  value: number;
89
89
  text: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.3.39",
3
+ "version": "0.3.40",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",