foris 6.3.0 → 6.4.0

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.
@@ -5,7 +5,7 @@
5
5
  * See /LICENSE for more information.
6
6
  */
7
7
 
8
- import React, { useRef } from "react";
8
+ import React, { useRef, useEffect, useState } from "react";
9
9
 
10
10
  import PropTypes from "prop-types";
11
11
 
@@ -40,20 +40,36 @@ Alert.defaultProps = {
40
40
 
41
41
  function Alert({ type, onDismiss, children }) {
42
42
  const alertRef = useRef();
43
+ const [isVisible, setIsVisible] = useState(true);
43
44
  useFocusTrap(alertRef, !!onDismiss);
45
+
46
+ useEffect(() => {
47
+ if (onDismiss) {
48
+ const timeout = setTimeout(() => setIsVisible(false), 7000);
49
+ return () => clearTimeout(timeout);
50
+ }
51
+ }, [onDismiss]);
52
+
53
+ const handleAnimationEnd = () => {
54
+ if (!isVisible && onDismiss) {
55
+ onDismiss();
56
+ }
57
+ };
58
+
44
59
  return (
45
60
  <div
46
61
  ref={alertRef}
47
- className={`alert alert-${type} ${
62
+ className={`alert alert-${type} ${isVisible ? "alert-fade-in" : "alert-slide-out-top"} ${
48
63
  onDismiss ? "alert-dismissible" : ""
49
64
  }`.trim()}
50
65
  role="alert"
66
+ onAnimationEnd={handleAnimationEnd}
51
67
  >
52
68
  {onDismiss && (
53
69
  <button
54
70
  type="button"
55
71
  className="btn-close"
56
- onClick={onDismiss}
72
+ onClick={() => setIsVisible(false)}
57
73
  aria-label={_("Close")}
58
74
  />
59
75
  )}
@@ -18,9 +18,9 @@ ThreeDotsMenu.propTypes = {
18
18
  children: PropTypes.arrayOf(PropTypes.node).isRequired,
19
19
  };
20
20
 
21
- function ThreeDotsMenu({ children }) {
21
+ function ThreeDotsMenu({ children, ...props }) {
22
22
  return (
23
- <div className="dropdown">
23
+ <div className="dropdown position-static" {...props}>
24
24
  <Button
25
25
  className="btn-sm btn-link text-body"
26
26
  data-bs-toggle="dropdown"
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foris",
3
- "version": "6.3.0",
3
+ "version": "6.4.0",
4
4
  "description": "Foris JS library is a set of components and utils for reForis application and plugins.",
5
5
  "author": "CZ.NIC, z.s.p.o.",
6
6
  "repository": {
package/foris-6.3.0.tgz DELETED
Binary file