@mtes-mct/monitor-ui 14.2.0 → 14.3.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [14.2.0](https://github.com/MTES-MCT/monitor-ui/compare/v14.1.0...v14.2.0) (2024-04-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * **icons:** add new icons ([887c14e](https://github.com/MTES-MCT/monitor-ui/commit/887c14ee4c8246131f21f89d9391d9c010a88d9d))
7
+
1
8
  ## [14.1.0](https://github.com/MTES-MCT/monitor-ui/compare/v14.0.0...v14.1.0) (2024-04-17)
2
9
 
3
10
 
@@ -2,13 +2,16 @@ import { type ReactNode } from 'react';
2
2
  import { Level } from '../../constants';
3
3
  export type BannerProps = {
4
4
  children: string | ReactNode;
5
+ className?: string | undefined;
6
+ closingDelay?: number;
5
7
  isClosable: boolean;
6
8
  isCollapsible: boolean;
7
9
  isHiddenByDefault: boolean | undefined;
8
10
  level: Level;
9
11
  top: string;
12
+ withAutomaticClosing?: boolean;
10
13
  };
11
- declare function Banner({ children, isClosable, isCollapsible, isHiddenByDefault, level, top }: Readonly<BannerProps>): import("react/jsx-runtime").JSX.Element;
14
+ declare function Banner({ children, className, closingDelay, isClosable, isCollapsible, isHiddenByDefault, level, top, withAutomaticClosing }: Readonly<BannerProps>): import("react/jsx-runtime").JSX.Element;
12
15
  declare namespace Banner {
13
16
  var displayName: string;
14
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Banner/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAA;AAIhD,OAAO,EAAgB,KAAK,EAAQ,MAAM,iBAAiB,CAAA;AAE3D,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,UAAU,EAAE,OAAO,CAAA;IACnB,aAAa,EAAE,OAAO,CAAA;IACtB,iBAAiB,EAAE,OAAO,GAAG,SAAS,CAAA;IACtC,KAAK,EAAE,KAAK,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AA6CD,iBAAS,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,QAAQ,CAAC,WAAW,CAAC,2CAwD5G;kBAxDQ,MAAM;;;AA4Df,OAAO,EAAE,MAAM,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Banner/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAA4C,MAAM,OAAO,CAAA;AAIhF,OAAO,EAAgB,KAAK,EAAQ,MAAM,iBAAiB,CAAA;AAE3D,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,OAAO,CAAA;IACnB,aAAa,EAAE,OAAO,CAAA;IACtB,iBAAiB,EAAE,OAAO,GAAG,SAAS,CAAA;IACtC,KAAK,EAAE,KAAK,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,CAAA;AAUD,iBAAS,MAAM,CAAC,EACd,QAAQ,EACR,SAAqB,EACrB,YAAmB,EACnB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,KAAK,EACL,GAAG,EACH,oBAA4B,EAC7B,EAAE,QAAQ,CAAC,WAAW,CAAC,2CAsEvB;kBAhFQ,MAAM;;;AAwHf,OAAO,EAAE,MAAM,EAAE,CAAA"}
package/index.js CHANGED
@@ -53748,36 +53748,9 @@ const getBannerPalette = (level)=>{
53748
53748
  };
53749
53749
  };
53750
53750
 
53751
- const Wrapper = styled.div`
53752
- display: ${(p)=>p.$isHidden ? 'none' : 'flex'};
53753
- flex-direction: row;
53754
- justify-content: space-between;
53755
- align-items: center;
53756
- position: absolute;
53757
- background-color: ${(p)=>getBannerPalette(p.$level).backgroundColor};
53758
- width: 100%;
53759
- min-width: 100%;
53760
- max-width: 100%;
53761
- padding: 0 2rem;
53762
- top: ${(p)=>`${p.$top}`};
53763
- z-index: 1000;
53764
- height: ${(p)=>!p.$isHidden && p.$isCollapsed ? '10px' : '50px'};
53765
- border-bottom: ${({ $isCollapsible, $level })=>$isCollapsible ? `4px solid ${getBannerPalette($level).borderColor}` : 'none'};
53766
- box-shadow: ${({ $isCollapsible })=>$isCollapsible ? 'none' : '0px 3px 4px #7077854D'};
53767
- transition: height 0.3s ease;
53768
- `;
53769
- const ContentWrapper = styled.div`
53770
- color: ${(p)=>getBannerPalette(p.$level).color};
53771
- align-self: center;
53772
- flex-grow: 2;
53773
- text-align: center;
53774
- font-size: 16px;
53775
- font-weight: 500;
53776
- `;
53777
- const ButtonWrapper = styled.div`
53778
- align-self: center;
53779
- `;
53780
- function Banner({ children, isClosable, isCollapsible, isHiddenByDefault, level, top }) {
53751
+ function Banner({ children, className = undefined, closingDelay = 3000, isClosable, isCollapsible, isHiddenByDefault, level, top, withAutomaticClosing = false }) {
53752
+ const timeoutIdRef = useRef(undefined);
53753
+ const controlledClassName = classnames('Component-Banner', className);
53781
53754
  const [isHidden, setIsHidden] = useState(!!isHiddenByDefault);
53782
53755
  const [isCollapsed, setIsCollapsed] = useState(false);
53783
53756
  const [isCollapsing, setIsCollapsing] = useState(false);
@@ -53793,7 +53766,7 @@ function Banner({ children, isClosable, isCollapsible, isHiddenByDefault, level,
53793
53766
  setIsCollapsed(true);
53794
53767
  }
53795
53768
  };
53796
- const onClickAction = ()=>{
53769
+ const onClickAction = useCallback(()=>{
53797
53770
  if (isClosable) {
53798
53771
  setIsHidden(true);
53799
53772
  } else if (isCollapsible) {
@@ -53801,14 +53774,30 @@ function Banner({ children, isClosable, isCollapsible, isHiddenByDefault, level,
53801
53774
  setIsCollapsed(true);
53802
53775
  setHasCollapsed(true);
53803
53776
  }
53804
- };
53777
+ }, [
53778
+ isClosable,
53779
+ isCollapsible
53780
+ ]);
53781
+ useEffect(()=>{
53782
+ if (withAutomaticClosing) {
53783
+ const timeoutId = setTimeout(()=>{
53784
+ onClickAction();
53785
+ }, closingDelay);
53786
+ timeoutIdRef.current = timeoutId;
53787
+ }
53788
+ return ()=>clearTimeout(timeoutIdRef.current);
53789
+ }, [
53790
+ closingDelay,
53791
+ onClickAction,
53792
+ withAutomaticClosing
53793
+ ]);
53805
53794
  return /*#__PURE__*/ jsx(Wrapper, {
53806
53795
  $isCollapsed: isCollapsed,
53807
53796
  $isCollapsible: isCollapsible,
53808
53797
  $isHidden: isHidden,
53809
53798
  $level: level,
53810
53799
  $top: top,
53811
- className: "banner",
53800
+ className: controlledClassName,
53812
53801
  onMouseEnter: enterHover,
53813
53802
  onMouseLeave: leaveHover,
53814
53803
  children: !isHidden && !isCollapsed && /*#__PURE__*/ jsxs(Fragment, {
@@ -53841,6 +53830,35 @@ function Banner({ children, isClosable, isCollapsible, isHiddenByDefault, level,
53841
53830
  })
53842
53831
  });
53843
53832
  }
53833
+ const Wrapper = styled.div`
53834
+ display: ${(p)=>p.$isHidden ? 'none' : 'flex'};
53835
+ flex-direction: row;
53836
+ justify-content: space-between;
53837
+ align-items: center;
53838
+ position: absolute;
53839
+ background-color: ${(p)=>getBannerPalette(p.$level).backgroundColor};
53840
+ width: 100%;
53841
+ min-width: 100%;
53842
+ max-width: 100%;
53843
+ padding: 0 2rem;
53844
+ top: ${(p)=>`${p.$top}`};
53845
+ z-index: 1000;
53846
+ height: ${(p)=>!p.$isHidden && p.$isCollapsed ? '10px' : '50px'};
53847
+ border-bottom: ${({ $isCollapsible, $level })=>$isCollapsible ? `4px solid ${getBannerPalette($level).borderColor}` : 'none'};
53848
+ box-shadow: ${({ $isCollapsible })=>$isCollapsible ? 'none' : '0px 3px 4px #7077854D'};
53849
+ transition: height 0.3s ease;
53850
+ `;
53851
+ const ContentWrapper = styled.div`
53852
+ color: ${(p)=>getBannerPalette(p.$level).color};
53853
+ align-self: center;
53854
+ flex-grow: 2;
53855
+ text-align: center;
53856
+ font-size: 16px;
53857
+ font-weight: 500;
53858
+ `;
53859
+ const ButtonWrapper = styled.div`
53860
+ align-self: center;
53861
+ `;
53844
53862
  Banner.displayName = 'Banner';
53845
53863
 
53846
53864
  const Field$2 = styled.div.attrs((props)=>({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mtes-mct/monitor-ui",
3
3
  "description": "Common React components, hooks, utilities and CSS stylesheets for MonitorFish, MonitorEnv and RapportNav.",
4
- "version": "14.2.0",
4
+ "version": "14.3.0",
5
5
  "license": "AGPL-3.0",
6
6
  "type": "module",
7
7
  "engines": {