funuicss 2.5.0 → 2.5.2

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,4 +1,8 @@
1
+ 'use client'
1
2
  import * as React from 'react';
3
+ import { useState, useEffect } from 'react';
4
+ import { PiList, PiX } from 'react-icons/pi';
5
+
2
6
 
3
7
  interface NavbarProps {
4
8
  fixedTop?: boolean;
@@ -7,14 +11,12 @@ interface NavbarProps {
7
11
  fixedBottom?: boolean;
8
12
  justify?: string;
9
13
  children?: React.ReactNode;
10
- left?:React.ReactNode
11
- center?:React.ReactNode
12
- right?:React.ReactNode
13
- visibleLinks?:boolean,
14
- sidebarTrigger?:React.ReactNode ,
15
- transparent?:Boolean
16
- sideBar?:number
17
- width?:string
14
+ left?: React.ReactNode;
15
+ center?: React.ReactNode;
16
+ right?: React.ReactNode;
17
+ sidebarTrigger?: React.ReactNode;
18
+ transparent?: boolean;
19
+ sideBar?: number;
18
20
  }
19
21
 
20
22
  export default function AppBar({
@@ -23,39 +25,69 @@ export default function AppBar({
23
25
  padding,
24
26
  fixedBottom,
25
27
  justify,
26
- children,
27
- left ,
28
+ left,
28
29
  center,
29
- right ,
30
+ right,
30
31
  sideBar,
31
- width ,
32
- visibleLinks ,
33
- sidebarTrigger ,
34
- transparent
32
+ sidebarTrigger,
33
+ transparent,
35
34
  }: NavbarProps) {
35
+ const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
36
+ const [isMobileScreen, setIsMobileScreen] = useState(false);
37
+
38
+ const toggleMenu = () => setIsMobileMenuOpen((prev) => !prev);
39
+ const closeMenu = () => setIsMobileMenuOpen(false);
40
+
41
+ useEffect(() => {
42
+ const handleResize = () => {
43
+ const isMobile = window.innerWidth < 768;
44
+ setIsMobileScreen(isMobile);
45
+ if (!isMobile) {
46
+ setIsMobileMenuOpen(false); // auto-close on large screens
47
+ }
48
+ };
49
+
50
+ handleResize(); // initial check
51
+ window.addEventListener('resize', handleResize);
52
+ return () => window.removeEventListener('resize', handleResize);
53
+ }, []);
54
+
36
55
  return (
37
- <div>
38
- <nav
39
- className={`
40
- navigation-bar ${funcss ? funcss : ''}
41
- ${fixedTop ? 'fixed_top_navbar' : ''}
42
- ${sideBar ? 'there_is_sidebar' : ''}
43
- ${transparent ? 'transparent' : ''}
44
- ${fixedBottom ? 'fixedBottom' : ''}
45
- `}
46
- style={{ padding: `${padding ? padding : ''}`, justifyContent: `${justify ? justify : ''}`}}
47
- >
48
- <div>
49
- {left}
50
- </div>
51
- <div className={` linkWrapper ${visibleLinks ? "visibleLinks" : ""}`}>
52
- {center}
53
- </div>
54
- <div className={`linkWrapper ${visibleLinks ? "visibleLinks" : ""}`}>
55
- {right}
56
- </div>
57
- {sidebarTrigger ? <span className='sidebar-trigger'>{sidebarTrigger}</span> : ''}
58
- </nav>
59
- </div>
56
+ <nav
57
+ className={`
58
+ navigation-bar
59
+ ${isMobileMenuOpen ? 'navbar-mobile-open' : ''}
60
+ ${funcss || ''}
61
+ ${fixedTop ? 'fixed_top_navbar' : ''}
62
+ ${sideBar ? 'there_is_sidebar' : ''}
63
+ ${transparent ? 'transparent' : ''}
64
+ ${fixedBottom ? 'fixedBottom' : ''}
65
+ `}
66
+ style={{
67
+ padding: `${padding || ''}`,
68
+ justifyContent: `${justify || ''}`,
69
+ }}
70
+ >
71
+ <div className="logoWrapper">
72
+ {left}
73
+
74
+ {/* Show close icon only when mobile and menu is open */}
75
+ {isMobileScreen && isMobileMenuOpen && (
76
+ <div className="hover-text-error pointer _closeNav" onClick={closeMenu}>
77
+ <PiX size={25} />
78
+ </div>
79
+ )}
80
+ </div>
81
+
82
+ <div className="linkWrapper">{center}</div>
83
+ <div className="linkWrapper">{right}</div>
84
+
85
+ {/* Show trigger only when mobile and menu is not open */}
86
+ {isMobileScreen && !isMobileMenuOpen && (
87
+ <span className="sidebar-trigger pointer hover-text-primary" onClick={toggleMenu}>
88
+ {sidebarTrigger || <PiList size={30} />}
89
+ </span>
90
+ )}
91
+ </nav>
60
92
  );
61
93
  }
@@ -1,10 +1,11 @@
1
1
  import * as React from 'react';
2
2
  interface ModalProps {
3
- children: React.ReactNode;
3
+ children?: React.ReactNode;
4
4
  funcss?: string;
5
5
  animation?: string;
6
6
  duration?: number;
7
7
  open: boolean;
8
+ setOpen: (val: boolean) => void;
8
9
  maxWidth?: string;
9
10
  maxHeight?: string;
10
11
  height?: string;
@@ -13,6 +14,7 @@ interface ModalProps {
13
14
  body?: React.ReactNode;
14
15
  bodycss?: string;
15
16
  title?: React.ReactNode;
17
+ okIcon?: React.ReactNode;
16
18
  titlecss?: string;
17
19
  footer?: React.ReactNode;
18
20
  footercss?: string;
@@ -21,6 +23,10 @@ interface ModalProps {
21
23
  id?: string;
22
24
  position?: string;
23
25
  flat?: boolean;
26
+ onOk?: () => void;
27
+ onOkText?: string;
24
28
  }
25
- export default function Modal({ children, funcss, animation, duration, open, maxWidth, maxHeight, height, width, backdrop, title, titlecss, body, bodycss, footer, footercss, close, closecss, position, id, flat, ...rest }: ModalProps): React.JSX.Element;
29
+ export default function Modal({ children, funcss, animation, duration, open, setOpen, maxWidth, maxHeight, okIcon, height, width, backdrop, title, titlecss, body, bodycss, footer, footercss, close, closecss, position, id, flat, onOk, // 👈 added
30
+ onOkText, // 👈 added
31
+ ...rest }: ModalProps): React.JSX.Element;
26
32
  export {};
package/ui/modal/Modal.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  "use strict";
2
3
  var __assign = (this && this.__assign) || function () {
3
4
  __assign = Object.assign || function(t) {
@@ -52,27 +53,38 @@ var React = __importStar(require("react"));
52
53
  var Header_1 = __importDefault(require("./Header"));
53
54
  var Content_1 = __importDefault(require("./Content"));
54
55
  var Action_1 = __importDefault(require("./Action"));
56
+ var pi_1 = require("react-icons/pi");
57
+ var Button_1 = __importDefault(require("../button/Button"));
55
58
  function Modal(_a) {
56
- var children = _a.children, funcss = _a.funcss, animation = _a.animation, duration = _a.duration, open = _a.open, maxWidth = _a.maxWidth, maxHeight = _a.maxHeight, height = _a.height, width = _a.width, backdrop = _a.backdrop, title = _a.title, titlecss = _a.titlecss, body = _a.body, bodycss = _a.bodycss, footer = _a.footer, footercss = _a.footercss, close = _a.close, closecss = _a.closecss, position = _a.position, id = _a.id, flat = _a.flat, rest = __rest(_a, ["children", "funcss", "animation", "duration", "open", "maxWidth", "maxHeight", "height", "width", "backdrop", "title", "titlecss", "body", "bodycss", "footer", "footercss", "close", "closecss", "position", "id", "flat"]);
57
- if (open) {
58
- return (React.createElement("div", { className: " modal ".concat(backdrop ? 'backdrop' : '', " ").concat(position ? position : ''), id: id ? id : '' },
59
- React.createElement("div", __assign({ className: "modal-content ".concat(funcss, " ").concat(flat ? "flat" : ""), style: {
60
- animation: " ".concat(duration ? duration : 0.2, "s ").concat(animation ? animation : "ScaleUp"),
61
- maxWidth: maxWidth ? maxWidth : null,
62
- maxHeight: maxHeight ? maxHeight : null,
63
- width: width ? width : null,
64
- height: height ? height : null,
65
- } }, rest),
66
- title &&
67
- React.createElement(Header_1.default, { funcss: titlecss ? titlecss : '', title: title ? title : "", close: close ? close : "" }),
68
- body &&
69
- React.createElement(Content_1.default, { funcss: bodycss ? bodycss : '' }, body),
70
- footer &&
71
- React.createElement(Action_1.default, { funcss: footercss ? footercss : '' }, footer),
72
- children)));
73
- }
74
- else {
75
- return React.createElement("div", null);
76
- }
59
+ var children = _a.children, funcss = _a.funcss, animation = _a.animation, duration = _a.duration, open = _a.open, setOpen = _a.setOpen, maxWidth = _a.maxWidth, maxHeight = _a.maxHeight, okIcon = _a.okIcon, height = _a.height, width = _a.width, _b = _a.backdrop, backdrop = _b === void 0 ? false : _b, title = _a.title, titlecss = _a.titlecss, body = _a.body, bodycss = _a.bodycss, footer = _a.footer, footercss = _a.footercss, close = _a.close, closecss = _a.closecss, position = _a.position, id = _a.id, flat = _a.flat, onOk = _a.onOk, // 👈 added
60
+ onOkText = _a.onOkText, // 👈 added
61
+ rest = __rest(_a, ["children", "funcss", "animation", "duration", "open", "setOpen", "maxWidth", "maxHeight", "okIcon", "height", "width", "backdrop", "title", "titlecss", "body", "bodycss", "footer", "footercss", "close", "closecss", "position", "id", "flat", "onOk", "onOkText"]);
62
+ var modalId = id || '_mymodal';
63
+ var handleClickOutside = function (e) {
64
+ if (e.target && e.target.id === modalId) {
65
+ setOpen(false);
66
+ }
67
+ };
68
+ var handleOkClick = function () {
69
+ if (onOk)
70
+ onOk();
71
+ else
72
+ setOpen(false); // default behavior if no onOk is provided
73
+ };
74
+ if (!open)
75
+ return null;
76
+ return (React.createElement("div", { className: "modal ".concat(backdrop ? 'backdrop' : '', " ").concat(position || ''), id: modalId, onClick: handleClickOutside },
77
+ React.createElement("div", __assign({ className: "modal-content ".concat(funcss || '', " ").concat(flat ? 'flat' : ''), style: {
78
+ animation: "".concat(duration || 0.2, "s ").concat(animation || 'ScaleUp'),
79
+ maxWidth: maxWidth || undefined,
80
+ maxHeight: maxHeight || undefined,
81
+ width: width || undefined,
82
+ height: height || undefined,
83
+ } }, rest),
84
+ title && (React.createElement(Header_1.default, { funcss: titlecss || '', title: title, close: React.createElement("div", { onClick: function () { return setOpen(false); }, className: "".concat(closecss || '', " pointer hover-text-error") }, close || React.createElement(pi_1.PiX, { size: 25 })) })),
85
+ body && (React.createElement(Content_1.default, { funcss: bodycss || '' }, body)),
86
+ footer ? (React.createElement(Action_1.default, { funcss: footercss || '' }, footer)) : (React.createElement(Action_1.default, { funcss: 'text-right' },
87
+ React.createElement(Button_1.default, { bg: 'success800', endIcon: okIcon || React.createElement(pi_1.PiPaperPlaneRight, null), raised: true, onClick: handleOkClick }, onOkText || 'OK'))),
88
+ children)));
77
89
  }
78
90
  exports.default = Modal;
@@ -1,31 +1,37 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  import ModalHeader from './Header';
3
4
  import ModalContent from './Content';
4
5
  import ModalAction from './Action';
5
- import CloseModal from './Close';
6
+ import { PiX , PiPaperPlaneRight} from 'react-icons/pi';
7
+ import Button from '../button/Button';
6
8
 
7
9
  interface ModalProps {
8
- children: React.ReactNode;
10
+ children?: React.ReactNode;
9
11
  funcss?: string;
10
12
  animation?: string;
11
13
  duration?: number;
12
14
  open: boolean;
15
+ setOpen: (val: boolean) => void;
13
16
  maxWidth?: string;
14
17
  maxHeight?: string;
15
18
  height?: string;
16
19
  width?: string;
17
20
  backdrop?: boolean;
18
- body?:React.ReactNode
19
- bodycss?:string
20
- title?:React.ReactNode
21
- titlecss?:string,
22
- footer?:React.ReactNode
23
- footercss?:string
24
- close?:React.ReactNode
25
- closecss?:string ,
26
- id?:string
27
- position?:string
28
- flat?:boolean
21
+ body?: React.ReactNode;
22
+ bodycss?: string;
23
+ title?: React.ReactNode;
24
+ okIcon?: React.ReactNode;
25
+ titlecss?: string;
26
+ footer?: React.ReactNode;
27
+ footercss?: string;
28
+ close?: React.ReactNode;
29
+ closecss?: string;
30
+ id?: string;
31
+ position?: string;
32
+ flat?: boolean;
33
+ onOk?: () => void; // 👈 new
34
+ onOkText?: string; // 👈 new
29
35
  }
30
36
 
31
37
  export default function Modal({
@@ -34,11 +40,13 @@ export default function Modal({
34
40
  animation,
35
41
  duration,
36
42
  open,
43
+ setOpen,
37
44
  maxWidth,
38
45
  maxHeight,
46
+ okIcon,
39
47
  height,
40
48
  width,
41
- backdrop,
49
+ backdrop = false,
42
50
  title,
43
51
  titlecss,
44
52
  body,
@@ -49,45 +57,84 @@ export default function Modal({
49
57
  closecss,
50
58
  position,
51
59
  id,
52
- flat ,
60
+ flat,
61
+ onOk, // 👈 added
62
+ onOkText, // 👈 added
53
63
  ...rest
54
64
  }: ModalProps) {
55
- if (open) {
56
- return (
57
- <div className={` modal ${backdrop ? 'backdrop' : ''} ${position ? position : ''}`} id={id ? id : ''}>
58
- <div
59
- className={`modal-content ${funcss} ${flat ? "flat" : ""}`}
60
- style={{
61
- animation: ` ${duration ? duration : 0.2}s ${animation ? animation : "ScaleUp"}` ,
62
- maxWidth: maxWidth ? maxWidth : null,
63
- maxHeight: maxHeight ? maxHeight : null,
64
- width: width ? width : null,
65
- height: height ? height : null,
66
- }}
67
-
68
- {...rest}
69
- >
70
- {
71
- title &&
72
- <ModalHeader funcss={titlecss ? titlecss : ''} title={title ? title : ""} close={close ? close : ""} />
73
- }
74
- {
75
- body &&
76
- <ModalContent funcss={bodycss ? bodycss : ''} >
77
- {body}
78
- </ModalContent>
79
- }
80
- {
81
- footer &&
82
- <ModalAction funcss={footercss ? footercss : ''}>
83
- {footer}
84
- </ModalAction>
85
- }
86
- {children}
87
- </div>
65
+ const modalId = id || '_mymodal';
66
+
67
+ const handleClickOutside = (e: React.MouseEvent<HTMLDivElement>) => {
68
+ if (e.target && (e.target as HTMLElement).id === modalId) {
69
+ setOpen(false);
70
+ }
71
+ };
72
+
73
+ const handleOkClick = () => {
74
+ if (onOk) onOk();
75
+ else setOpen(false); // default behavior if no onOk is provided
76
+ };
77
+
78
+ if (!open) return null;
79
+
80
+ return (
81
+ <div
82
+ className={`modal ${backdrop ? 'backdrop' : ''} ${position || ''}`}
83
+ id={modalId}
84
+ onClick={handleClickOutside}
85
+ >
86
+ <div
87
+ className={`modal-content ${funcss || ''} ${flat ? 'flat' : ''}`}
88
+ style={{
89
+ animation: `${duration || 0.2}s ${animation || 'ScaleUp'}`,
90
+ maxWidth: maxWidth || undefined,
91
+ maxHeight: maxHeight || undefined,
92
+ width: width || undefined,
93
+ height: height || undefined,
94
+ }}
95
+ {...rest}
96
+ >
97
+ {title && (
98
+ <ModalHeader
99
+ funcss={titlecss || ''}
100
+ title={title}
101
+ close={
102
+ <div
103
+ onClick={() => setOpen(false)}
104
+ className={`${closecss || ''} pointer hover-text-error`}
105
+ >
106
+ {close || <PiX size={25} />}
107
+ </div>
108
+ }
109
+ />
110
+ )}
111
+
112
+ {body && (
113
+ <ModalContent funcss={bodycss || ''}>
114
+ {body}
115
+ </ModalContent>
116
+ )}
117
+
118
+ {/* Show default Ok button if no custom footer */}
119
+ {footer ? (
120
+ <ModalAction funcss={footercss || ''}>
121
+ {footer}
122
+ </ModalAction>
123
+ ) : (
124
+ <ModalAction funcss='text-right'>
125
+ <Button
126
+ bg='success800'
127
+ endIcon={okIcon || <PiPaperPlaneRight />}
128
+ raised
129
+ onClick={handleOkClick}
130
+ >
131
+ {onOkText || 'OK'}
132
+ </Button>
133
+ </ModalAction>
134
+ )}
135
+
136
+ {children}
88
137
  </div>
89
- );
90
- } else {
91
- return <div></div>;
92
- }
138
+ </div>
139
+ );
93
140
  }
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  "use strict";
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
@@ -41,15 +42,14 @@ function NotFound(_a) {
41
42
  React.createElement("div", { className: "h2 text-warning round-edge" }, "404"),
42
43
  React.createElement("div", { style: { margin: "1.4rem 0px" } }, header ? header
43
44
  :
44
- React.createElement("div", { className: "text-bigger text-dark300", style: { display: "block", transition: "all 0.2s linear 0s" } }, "Page Not Found")),
45
+ React.createElement("div", { className: "text-big text-bold text-dark300", style: { display: "block", transition: "all 0.2s linear 0s" } }, "Page Not Found")),
45
46
  content ? content :
46
47
  React.createElement("div", { className: "article" },
47
48
  React.createElement(Text_1.default, { article: true, text: "Sorry, we couldn't find the page you're looking for.", color: "dark300", block: true })),
48
49
  React.createElement("div", { style: { margin: "2rem 0px" } }, action ? action :
49
50
  React.createElement("div", { className: "row-flex gap", style: { justifyContent: "center", gap: "0.4rem" } },
50
- React.createElement(Button_1.default, { raised: true, rounded: true, startIcon: React.createElement(pi_1.PiHouse, null), bg: 'primary', onClick: function () {
51
- var previousUrl = '/';
52
- window.location.assign(previousUrl);
53
- } }, "Back To Home"))))))));
51
+ React.createElement(Button_1.default, { raised: true, rounded: true, startIcon: React.createElement(pi_1.PiArrowLeft, null), bg: 'primary', onClick: function () {
52
+ window.history.back();
53
+ } }, "Go Back"))))))));
54
54
  }
55
55
  exports.default = NotFound;
@@ -1,6 +1,7 @@
1
+ 'use client'
1
2
  import * as React from 'react';
2
3
  import Button from '../button/Button';
3
- import {PiHouse} from 'react-icons/pi'
4
+ import {PiArrowLeft} from 'react-icons/pi'
4
5
  import Text from '../text/Text';
5
6
 
6
7
  interface NotFoundProps {
@@ -34,7 +35,7 @@ export default function NotFound(
34
35
  {
35
36
  header ? header
36
37
  :
37
- <div className="text-bigger text-dark300" style={{ display: "block", transition: "all 0.2s linear 0s" }}>
38
+ <div className="text-big text-bold text-dark300" style={{ display: "block", transition: "all 0.2s linear 0s" }}>
38
39
  Page Not Found
39
40
  </div>
40
41
  }
@@ -49,12 +50,10 @@ export default function NotFound(
49
50
  {
50
51
  action ? action :
51
52
  <div className="row-flex gap" style={{ justifyContent: "center", gap: "0.4rem" }}>
52
- <Button raised rounded startIcon={<PiHouse />} bg='primary' onClick={() => {
53
- const previousUrl = '/';
54
- window.location.assign(previousUrl)
55
-
53
+ <Button raised rounded startIcon={<PiArrowLeft />} bg='primary' onClick={() => {
54
+ window.history.back()
56
55
  }}>
57
- Back To Home
56
+ Go Back
58
57
  </Button>
59
58
  </div>
60
59
  }
@@ -40,11 +40,13 @@ function UnAuthorized(_a) {
40
40
  React.createElement("div", { className: "h2 text-warning round-edge" }, "401"),
41
41
  React.createElement("div", { style: { margin: "1.4rem 0px" } }, header ? header
42
42
  :
43
- React.createElement("div", { className: "text-bigger text-dark300", style: { display: "block", transition: "all 0.2s linear 0s" } }, "Unauthorized Access")),
43
+ React.createElement("div", { className: "text-bigger text-bold text-dark300", style: { display: "block", transition: "all 0.2s linear 0s" } }, "Unauthorized Access")),
44
44
  content ? content :
45
45
  React.createElement("div", { className: "article" }, "Sorry! You do not have access to this resource."),
46
46
  React.createElement("div", { style: { margin: "2rem 0px" } }, action ? action :
47
47
  React.createElement("div", { className: "row-flex gap", style: { justifyContent: "center", gap: "0.4rem" } },
48
- React.createElement(Button_1.default, { raised: true, startIcon: React.createElement(pi_1.PiHouse, null), bg: 'primary800', onClick: function () { return window.location.assign("/"); } }, "Back To Home"))))))));
48
+ React.createElement(Button_1.default, { raised: true, rounded: true, startIcon: React.createElement(pi_1.PiArrowLeft, null), bg: 'primary', onClick: function () {
49
+ window.history.back();
50
+ } }, "Go Back"))))))));
49
51
  }
50
52
  exports.default = UnAuthorized;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import Button from '../button/Button';
3
- import {PiHouse} from 'react-icons/pi'
3
+ import {PiArrowLeft} from 'react-icons/pi'
4
4
 
5
5
  interface UnAuthorizedProps {
6
6
  header?:React.ReactNode
@@ -33,7 +33,7 @@ export default function UnAuthorized(
33
33
  {
34
34
  header ? header
35
35
  :
36
- <div className="text-bigger text-dark300" style={{ display: "block", transition: "all 0.2s linear 0s" }}>
36
+ <div className="text-bigger text-bold text-dark300" style={{ display: "block", transition: "all 0.2s linear 0s" }}>
37
37
  Unauthorized Access
38
38
  </div>
39
39
  }
@@ -48,9 +48,11 @@ export default function UnAuthorized(
48
48
  {
49
49
  action ? action :
50
50
  <div className="row-flex gap" style={{ justifyContent: "center", gap: "0.4rem" }}>
51
- <Button raised startIcon={<PiHouse />} bg='primary800' onClick={() => window.location.assign("/")}>
52
- Back To Home
53
- </Button>
51
+ <Button raised rounded startIcon={<PiArrowLeft />} bg='primary' onClick={() => {
52
+ window.history.back()
53
+ }}>
54
+ Go Back
55
+ </Button>
54
56
  </div>
55
57
  }
56
58
  </div>
@@ -1,12 +1,15 @@
1
1
  import * as React from 'react';
2
2
  interface SnackbarProps {
3
3
  message: string;
4
- close: React.ReactNode;
4
+ close?: React.ReactNode;
5
5
  open: boolean;
6
+ setOpen: (val: boolean) => void;
6
7
  position: string;
7
8
  funcss?: string;
8
9
  animation?: string;
9
10
  duration?: number;
11
+ autoHide?: boolean;
12
+ autoHideDuration?: number;
10
13
  flat?: boolean;
11
14
  }
12
15
  declare const SnackBar: React.FC<SnackbarProps>;
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  "use strict";
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
@@ -25,19 +26,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
26
  Object.defineProperty(exports, "__esModule", { value: true });
26
27
  var React = __importStar(require("react"));
27
28
  var SnackBar = function (_a) {
28
- var message = _a.message, close = _a.close, open = _a.open, position = _a.position, funcss = _a.funcss, animation = _a.animation, duration = _a.duration, flat = _a.flat;
29
- if (open) {
30
- return (React.createElement("div", null,
31
- React.createElement("div", { className: "snackbar ".concat(position, " ").concat(funcss, " ").concat(flat ? "flat" : ""), style: { animation: " ".concat(duration, "s ").concat(animation) } },
32
- React.createElement("div", { className: "snackbar-content" },
33
- React.createElement("div", { className: "snackbar-body" }, message),
34
- close &&
35
- React.createElement("div", null,
36
- React.createElement("span", { className: "close-snackbar" },
37
- React.createElement("span", null, close)))))));
38
- }
39
- else {
40
- return React.createElement("div", null);
41
- }
29
+ var message = _a.message, close = _a.close, open = _a.open, setOpen = _a.setOpen, position = _a.position, funcss = _a.funcss, animation = _a.animation, _b = _a.duration, duration = _b === void 0 ? 0.3 : _b, _c = _a.autoHide, autoHide = _c === void 0 ? false : _c, _d = _a.autoHideDuration, autoHideDuration = _d === void 0 ? 3000 : _d, flat = _a.flat;
30
+ React.useEffect(function () {
31
+ if (open && autoHide) {
32
+ var timer_1 = setTimeout(function () {
33
+ setOpen(false);
34
+ }, autoHideDuration);
35
+ return function () { return clearTimeout(timer_1); };
36
+ }
37
+ }, [open, autoHide, autoHideDuration, setOpen]);
38
+ if (!open)
39
+ return null;
40
+ return (React.createElement("div", { className: "snackbar ".concat(position, " ").concat(funcss || '', " ").concat(flat ? 'flat' : ''), style: { animation: "".concat(duration, "s ").concat(animation || 'SlideUp') } },
41
+ React.createElement("div", { className: "snackbar-content" },
42
+ React.createElement("div", { className: "snackbar-body" }, message),
43
+ close && (React.createElement("div", { className: "close-snackbar pointer", onClick: function () { return setOpen ? setOpen(false) : null; } }, close)))));
42
44
  };
43
45
  exports.default = SnackBar;