UNPKG

2.34 kBTypeScriptView Raw
1import * as React from 'react';
2import { OverrideProps, Simplify } from '@mui/types';
3import { SlotComponentProps } from '../utils';
4export interface BadgeRootSlotPropsOverrides {
5}
6export interface BadgeBadgeSlotPropsOverrides {
7}
8export type BadgeOwnerState = Simplify<BadgeOwnProps & {
9 badgeContent: React.ReactNode;
10 invisible: boolean;
11 max: number;
12 showZero: boolean;
13}>;
14export interface BadgeOwnProps {
15 /**
16 * The content rendered within the badge.
17 */
18 badgeContent?: React.ReactNode;
19 /**
20 * The badge will be added relative to this node.
21 */
22 children?: React.ReactNode;
23 /**
24 * If `true`, the badge is invisible.
25 * @default false
26 */
27 invisible?: boolean;
28 /**
29 * Max count to show.
30 * @default 99
31 */
32 max?: number;
33 /**
34 * The props used for each slot inside the Badge.
35 * @default {}
36 */
37 slotProps?: {
38 root?: SlotComponentProps<'span', BadgeRootSlotPropsOverrides, BadgeOwnerState>;
39 badge?: SlotComponentProps<'span', BadgeBadgeSlotPropsOverrides, BadgeOwnerState>;
40 };
41 /**
42 * The components used for each slot inside the Badge.
43 * Either a string to use a HTML element or a component.
44 * @default {}
45 */
46 slots?: BadgeSlots;
47 /**
48 * Controls whether the badge is hidden when `badgeContent` is zero.
49 * @default false
50 */
51 showZero?: boolean;
52}
53export interface BadgeSlots {
54 /**
55 * The component that renders the root.
56 * @default 'span'
57 */
58 root?: React.ElementType;
59 /**
60 * The component that renders the badge.
61 * @default 'span'
62 */
63 badge?: React.ElementType;
64}
65export interface BadgeTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'span'> {
66 props: BadgeOwnProps & AdditionalProps;
67 defaultComponent: RootComponentType;
68}
69export type BadgeProps<RootComponentType extends React.ElementType = BadgeTypeMap['defaultComponent']> = OverrideProps<BadgeTypeMap<{}, RootComponentType>, RootComponentType>;
70export type BadgeRootSlotProps = {
71 children?: React.ReactNode;
72 className?: string;
73 ownerState: BadgeOwnerState;
74 ref: React.Ref<HTMLSpanElement>;
75};
76export type BadgeBadgeSlotProps = {
77 className?: string;
78 children?: React.ReactNode;
79 ownerState: BadgeOwnerState;
80};