funuicss 2.5.0 → 2.5.1

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,40 +1,56 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
 
3
4
  interface SnackbarProps {
4
5
  message: string;
5
- close: React.ReactNode;
6
+ close?: React.ReactNode;
6
7
  open: boolean;
8
+ setOpen: (val: boolean) => void;
7
9
  position: string;
8
10
  funcss?: string;
9
11
  animation?: string;
10
- duration?: number;
11
- flat?:boolean
12
+ duration?: number; // animation duration (in seconds)
13
+ autoHide?: boolean; // 👈 NEW
14
+ autoHideDuration?: number; // 👈 NEW in milliseconds
15
+ flat?: boolean;
12
16
  }
13
17
 
14
- const SnackBar: React.FC<SnackbarProps> = ({ message, close, open, position, funcss, animation, duration , flat}) => {
15
- if (open) {
16
- return (
17
- <div>
18
- <div className={`snackbar ${position} ${funcss} ${flat ? "flat" : ""}`} style={{ animation: ` ${duration}s ${animation}` }}>
19
- <div className="snackbar-content">
20
- <div className="snackbar-body">
21
- {message}
22
- </div>
23
- {
24
- close &&
25
- <div>
26
- <span className="close-snackbar">
27
- <span>{close}</span>
28
- </span>
29
- </div>
30
- }
18
+ const SnackBar: React.FC<SnackbarProps> = ({
19
+ message,
20
+ close,
21
+ open,
22
+ setOpen,
23
+ position,
24
+ funcss,
25
+ animation,
26
+ duration = 0.3,
27
+ autoHide = false,
28
+ autoHideDuration = 3000,
29
+ flat,
30
+ }) => {
31
+ React.useEffect(() => {
32
+ if (open && autoHide) {
33
+ const timer = setTimeout(() => {
34
+ setOpen(false);
35
+ }, autoHideDuration);
36
+ return () => clearTimeout(timer);
37
+ }
38
+ }, [open, autoHide, autoHideDuration, setOpen]);
39
+
40
+ if (!open) return null;
41
+
42
+ return (
43
+ <div className={`snackbar ${position} ${funcss || ''} ${flat ? 'flat' : ''}`} style={{ animation: `${duration}s ${animation || 'SlideUp'}` }}>
44
+ <div className="snackbar-content">
45
+ <div className="snackbar-body">{message}</div>
46
+ {close && (
47
+ <div className="close-snackbar pointer" onClick={() =>setOpen ? setOpen(false) : null}>
48
+ {close}
31
49
  </div>
32
- </div>
50
+ )}
33
51
  </div>
34
- );
35
- } else {
36
- return <div></div>;
37
- }
52
+ </div>
53
+ );
38
54
  };
39
55
 
40
56
  export default SnackBar;
@@ -48,7 +48,7 @@ var __rest = (this && this.__rest) || function (s, e) {
48
48
  Object.defineProperty(exports, "__esModule", { value: true });
49
49
  var React = __importStar(require("react"));
50
50
  function Circle(_a) {
51
- var size = _a.size, funcss = _a.funcss, bg = _a.bg, color = _a.color, children = _a.children, hoverable = _a.hoverable, raised = _a.raised, key = _a.key, onClick = _a.onClick, rest = __rest(_a, ["size", "funcss", "bg", "color", "children", "hoverable", "raised", "key", "onClick"]);
51
+ var _b = _a.size, size = _b === void 0 ? 2 : _b, funcss = _a.funcss, bg = _a.bg, color = _a.color, children = _a.children, hoverable = _a.hoverable, raised = _a.raised, key = _a.key, onClick = _a.onClick, rest = __rest(_a, ["size", "funcss", "bg", "color", "children", "hoverable", "raised", "key", "onClick"]);
52
52
  return (React.createElement("div", __assign({ className: "pointer avatar ".concat(funcss || '', " ").concat("text-" + (color === null || color === void 0 ? void 0 : color.trim()) || '', " ").concat(raised ? "raised" : '', " ").concat(bg || '', " ").concat(hoverable ? 'hoverable' : ''), style: {
53
53
  width: "".concat(size + "rem" || '2.3rem'),
54
54
  height: "".concat(size + "rem" || '2.3rem'),
@@ -17,7 +17,7 @@ interface Circle_Props extends HTMLProps<HTMLDivElement> {
17
17
 
18
18
 
19
19
  export default function Circle({
20
- size,
20
+ size = 2,
21
21
  funcss,
22
22
  bg,
23
23
  color,