@mtes-mct/monitor-ui 18.8.0 → 18.9.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/elements/IconButton.d.ts +4 -2
- package/elements/IconButton.d.ts.map +1 -1
- package/index.js +64 -10
- package/package.json +1 -1
package/elements/IconButton.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { type IconProps } from '../types/definitions';
|
|
|
4
4
|
export type IconButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> & {
|
|
5
5
|
Icon: FunctionComponent<IconProps>;
|
|
6
6
|
accent?: Accent | undefined;
|
|
7
|
-
|
|
7
|
+
badgeBackgroundColor?: string | undefined;
|
|
8
|
+
badgeColor?: string | undefined;
|
|
9
|
+
badgeNumber?: number | undefined;
|
|
8
10
|
color?: string | undefined;
|
|
9
11
|
/** In pixels, override `size` prop default values. */
|
|
10
12
|
iconSize?: number | undefined;
|
|
@@ -14,5 +16,5 @@ export type IconButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'chi
|
|
|
14
16
|
/** Prevent onClick event propagation. */
|
|
15
17
|
withUnpropagatedClick?: boolean | undefined;
|
|
16
18
|
};
|
|
17
|
-
export declare function IconButton({ accent, className, color, Icon, iconSize, isCompact, onClick, size, type, withUnpropagatedClick, ...nativeProps }: IconButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function IconButton({ accent, badgeBackgroundColor, badgeColor, badgeNumber, className, color, Icon, iconSize, isCompact, onClick, size, type, withUnpropagatedClick, ...nativeProps }: IconButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
18
20
|
//# sourceMappingURL=IconButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../src/elements/IconButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,oBAAoB,EAAE,KAAK,iBAAiB,EAAe,MAAM,OAAO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SAAS,CAAA;CAC5C,CAAA;AACD,wBAAgB,UAAU,CAAC,EACzB,MAAuB,EACvB,oBAAoB,EACpB,UAAU,EACV,WAAW,EACX,SAAS,EACT,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,IAAkB,EAClB,IAAe,EACf,qBAA6B,EAC7B,GAAG,WAAW,EACf,EAAE,eAAe,2CAqEjB"}
|
package/index.js
CHANGED
|
@@ -53519,7 +53519,7 @@ const ICON_SIZE_IN_PX = {
|
|
|
53519
53519
|
[Size.NORMAL]: 20,
|
|
53520
53520
|
[Size.SMALL]: 14
|
|
53521
53521
|
};
|
|
53522
|
-
function IconButton({ accent = Accent.PRIMARY, className, color, Icon, iconSize, isCompact, onClick, size = Size.NORMAL, type = 'button', withUnpropagatedClick = false, ...nativeProps }) {
|
|
53522
|
+
function IconButton({ accent = Accent.PRIMARY, badgeBackgroundColor, badgeColor, badgeNumber, className, color, Icon, iconSize, isCompact, onClick, size = Size.NORMAL, type = 'button', withUnpropagatedClick = false, ...nativeProps }) {
|
|
53523
53523
|
const handleClick = useCallback((event)=>{
|
|
53524
53524
|
if (withUnpropagatedClick) {
|
|
53525
53525
|
stopMouseEventPropagation(event);
|
|
@@ -53559,19 +53559,49 @@ function IconButton({ accent = Accent.PRIMARY, className, color, Icon, iconSize,
|
|
|
53559
53559
|
]);
|
|
53560
53560
|
switch(accent){
|
|
53561
53561
|
case Accent.SECONDARY:
|
|
53562
|
-
return /*#__PURE__*/
|
|
53563
|
-
|
|
53564
|
-
|
|
53562
|
+
return /*#__PURE__*/ jsxs(Wrapper$2, {
|
|
53563
|
+
children: [
|
|
53564
|
+
!!badgeNumber && /*#__PURE__*/ jsx(BadgeNumber, {
|
|
53565
|
+
backgroundColor: badgeBackgroundColor,
|
|
53566
|
+
color: badgeColor,
|
|
53567
|
+
size: size,
|
|
53568
|
+
children: badgeNumber
|
|
53569
|
+
}),
|
|
53570
|
+
/*#__PURE__*/ jsx(SecondaryButton, {
|
|
53571
|
+
as: StyledButton,
|
|
53572
|
+
...commonProps
|
|
53573
|
+
})
|
|
53574
|
+
]
|
|
53565
53575
|
});
|
|
53566
53576
|
case Accent.TERTIARY:
|
|
53567
|
-
return /*#__PURE__*/
|
|
53568
|
-
|
|
53569
|
-
|
|
53577
|
+
return /*#__PURE__*/ jsxs(Wrapper$2, {
|
|
53578
|
+
children: [
|
|
53579
|
+
!!badgeNumber && /*#__PURE__*/ jsx(BadgeNumber, {
|
|
53580
|
+
backgroundColor: badgeBackgroundColor,
|
|
53581
|
+
color: badgeColor,
|
|
53582
|
+
size: size,
|
|
53583
|
+
children: badgeNumber
|
|
53584
|
+
}),
|
|
53585
|
+
/*#__PURE__*/ jsx(TertiaryButton, {
|
|
53586
|
+
as: StyledButton,
|
|
53587
|
+
...commonProps
|
|
53588
|
+
})
|
|
53589
|
+
]
|
|
53570
53590
|
});
|
|
53571
53591
|
default:
|
|
53572
|
-
return /*#__PURE__*/
|
|
53573
|
-
|
|
53574
|
-
|
|
53592
|
+
return /*#__PURE__*/ jsxs(Wrapper$2, {
|
|
53593
|
+
children: [
|
|
53594
|
+
!!badgeNumber && /*#__PURE__*/ jsx(BadgeNumber, {
|
|
53595
|
+
backgroundColor: badgeBackgroundColor,
|
|
53596
|
+
color: badgeColor,
|
|
53597
|
+
size: size,
|
|
53598
|
+
children: badgeNumber
|
|
53599
|
+
}),
|
|
53600
|
+
/*#__PURE__*/ jsx(PrimaryButton, {
|
|
53601
|
+
as: StyledButton,
|
|
53602
|
+
...commonProps
|
|
53603
|
+
})
|
|
53604
|
+
]
|
|
53575
53605
|
});
|
|
53576
53606
|
}
|
|
53577
53607
|
}
|
|
@@ -53580,6 +53610,30 @@ const PADDING$1 = {
|
|
|
53580
53610
|
[Size.NORMAL]: '5px',
|
|
53581
53611
|
[Size.SMALL]: '3px'
|
|
53582
53612
|
};
|
|
53613
|
+
const Wrapper$2 = styled.div`
|
|
53614
|
+
position: relative;
|
|
53615
|
+
`;
|
|
53616
|
+
const LEFT_MARGIN = {
|
|
53617
|
+
[Size.LARGE]: 35,
|
|
53618
|
+
[Size.NORMAL]: 25,
|
|
53619
|
+
[Size.SMALL]: 15
|
|
53620
|
+
};
|
|
53621
|
+
const BadgeNumber = styled.div`
|
|
53622
|
+
display: inline-block;
|
|
53623
|
+
position: absolute;
|
|
53624
|
+
height: 15px;
|
|
53625
|
+
padding: 0 4px;
|
|
53626
|
+
text-align: center;
|
|
53627
|
+
border-radius: 10px;
|
|
53628
|
+
top: -5px;
|
|
53629
|
+
line-height: 14px;
|
|
53630
|
+
left: ${(p)=>p.size ? LEFT_MARGIN[p.size] : 25}px;
|
|
53631
|
+
background: ${(p)=>p.backgroundColor ? p.backgroundColor : p.theme.color.maximumRed};
|
|
53632
|
+
color: ${(p)=>p.color ? p.color : p.theme.color.white};
|
|
53633
|
+
font-size: 12px;
|
|
53634
|
+
letter-spacing: 0px;
|
|
53635
|
+
font-weight: 700;
|
|
53636
|
+
`;
|
|
53583
53637
|
// We can't use $-prefixed props here for some reason (maybe because the `as` prop exclude them?).
|
|
53584
53638
|
const StyledButton = styled.button`
|
|
53585
53639
|
align-items: center;
|
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": "18.
|
|
4
|
+
"version": "18.9.0",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|