@mtes-mct/monitor-ui 14.2.0 → 14.3.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.
- package/CHANGELOG.md +14 -0
- package/components/Banner/index.d.ts +4 -1
- package/components/Banner/index.d.ts.map +1 -1
- package/index.js +61 -34
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [14.3.0](https://github.com/MTES-MCT/monitor-ui/compare/v14.2.0...v14.3.0) (2024-04-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **components:** add automatic closing ([759c131](https://github.com/MTES-MCT/monitor-ui/commit/759c13101f048ecd7745480d775c6953d2a31229))
|
|
7
|
+
|
|
8
|
+
## [14.2.0](https://github.com/MTES-MCT/monitor-ui/compare/v14.1.0...v14.2.0) (2024-04-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **icons:** add new icons ([887c14e](https://github.com/MTES-MCT/monitor-ui/commit/887c14ee4c8246131f21f89d9391d9c010a88d9d))
|
|
14
|
+
|
|
1
15
|
## [14.1.0](https://github.com/MTES-MCT/monitor-ui/compare/v14.0.0...v14.1.0) (2024-04-17)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -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":"
|
|
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,2CA0EvB;kBApFQ,MAAM;;;AAoIf,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
package/index.js
CHANGED
|
@@ -53748,36 +53748,9 @@ const getBannerPalette = (level)=>{
|
|
|
53748
53748
|
};
|
|
53749
53749
|
};
|
|
53750
53750
|
|
|
53751
|
-
|
|
53752
|
-
|
|
53753
|
-
|
|
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:
|
|
53800
|
+
className: controlledClassName,
|
|
53812
53801
|
onMouseEnter: enterHover,
|
|
53813
53802
|
onMouseLeave: leaveHover,
|
|
53814
53803
|
children: !isHidden && !isCollapsed && /*#__PURE__*/ jsxs(Fragment, {
|
|
@@ -53833,7 +53822,10 @@ function Banner({ children, isClosable, isCollapsible, isHiddenByDefault, level,
|
|
|
53833
53822
|
}),
|
|
53834
53823
|
!isClosable && isCollapsible && /*#__PURE__*/ jsx(LinkButton, {
|
|
53835
53824
|
size: Size.LARGE,
|
|
53836
|
-
children:
|
|
53825
|
+
children: /*#__PURE__*/ jsx(HideText, {
|
|
53826
|
+
$level: level,
|
|
53827
|
+
children: "Masquer"
|
|
53828
|
+
})
|
|
53837
53829
|
})
|
|
53838
53830
|
]
|
|
53839
53831
|
})
|
|
@@ -53841,6 +53833,41 @@ function Banner({ children, isClosable, isCollapsible, isHiddenByDefault, level,
|
|
|
53841
53833
|
})
|
|
53842
53834
|
});
|
|
53843
53835
|
}
|
|
53836
|
+
const Wrapper = styled.div`
|
|
53837
|
+
display: ${(p)=>p.$isHidden ? 'none' : 'flex'};
|
|
53838
|
+
flex-direction: row;
|
|
53839
|
+
justify-content: space-between;
|
|
53840
|
+
align-items: center;
|
|
53841
|
+
position: absolute;
|
|
53842
|
+
background-color: ${(p)=>getBannerPalette(p.$level).backgroundColor};
|
|
53843
|
+
width: 100%;
|
|
53844
|
+
min-width: 100%;
|
|
53845
|
+
max-width: 100%;
|
|
53846
|
+
padding: 0 2rem;
|
|
53847
|
+
top: ${(p)=>`${p.$top}`};
|
|
53848
|
+
z-index: 1000;
|
|
53849
|
+
height: ${(p)=>!p.$isHidden && p.$isCollapsed ? '10px' : '50px'};
|
|
53850
|
+
border-bottom: ${({ $isCollapsible, $level })=>$isCollapsible ? `4px solid ${getBannerPalette($level).borderColor}` : 'none'};
|
|
53851
|
+
box-shadow: ${({ $isCollapsible })=>$isCollapsible ? 'none' : '0px 3px 4px #7077854D'};
|
|
53852
|
+
transition: height 0.3s ease;
|
|
53853
|
+
`;
|
|
53854
|
+
const ContentWrapper = styled.div`
|
|
53855
|
+
color: ${(p)=>getBannerPalette(p.$level).color};
|
|
53856
|
+
align-self: center;
|
|
53857
|
+
flex-grow: 2;
|
|
53858
|
+
text-align: center;
|
|
53859
|
+
font-size: 16px;
|
|
53860
|
+
font-weight: 500;
|
|
53861
|
+
`;
|
|
53862
|
+
const ButtonWrapper = styled.div`
|
|
53863
|
+
align-self: center;
|
|
53864
|
+
`;
|
|
53865
|
+
const HideText = styled.span`
|
|
53866
|
+
${(p)=>p.$level === Level.ERROR ? css`
|
|
53867
|
+
color: ${getBannerPalette(p.$level).color};
|
|
53868
|
+
text-decoration: ${getBannerPalette(p.$level).color} underline;
|
|
53869
|
+
` : ''}
|
|
53870
|
+
`;
|
|
53844
53871
|
Banner.displayName = 'Banner';
|
|
53845
53872
|
|
|
53846
53873
|
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.
|
|
4
|
+
"version": "14.3.1",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|