Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101379084
BadgeUnstyled.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 9, 21:17
Size
3 KB
Mime Type
text/x-java
Expires
Tue, Feb 11, 21:17 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24148112
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
BadgeUnstyled.js
View Options
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["badgeContent", "component", "children", "invisible", "max", "slotProps", "slots", "showZero"];
import * as React from 'react';
import PropTypes from 'prop-types';
import composeClasses from '../composeClasses';
import useBadge from './useBadge';
import { getBadgeUnstyledUtilityClass } from './badgeUnstyledClasses';
import { useSlotProps } from '../utils';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
const useUtilityClasses = ownerState => {
const {
invisible
} = ownerState;
const slots = {
root: ['root'],
badge: ['badge', invisible && 'invisible']
};
return composeClasses(slots, getBadgeUnstyledUtilityClass, undefined);
};
/**
*
* Demos:
*
* - [Unstyled badge](https://mui.com/base/react-badge/)
*
* API:
*
* - [BadgeUnstyled API](https://mui.com/base/api/badge-unstyled/)
*/
const BadgeUnstyled = /*#__PURE__*/React.forwardRef(function BadgeUnstyled(props, ref) {
const {
component,
children,
max: maxProp = 99,
slotProps = {},
slots = {},
showZero = false
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const {
badgeContent,
max,
displayValue,
invisible
} = useBadge(_extends({}, props, {
max: maxProp
}));
const ownerState = _extends({}, props, {
badgeContent,
invisible,
max,
showZero
});
const classes = useUtilityClasses(ownerState);
const Root = component || slots.root || 'span';
const rootProps = useSlotProps({
elementType: Root,
externalSlotProps: slotProps.root,
externalForwardedProps: other,
additionalProps: {
ref
},
ownerState,
className: classes.root
});
const Badge = slots.badge || 'span';
const badgeProps = useSlotProps({
elementType: Badge,
externalSlotProps: slotProps.badge,
ownerState,
className: classes.badge
});
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
children: [children, /*#__PURE__*/_jsx(Badge, _extends({}, badgeProps, {
children: displayValue
}))]
}));
});
process.env.NODE_ENV !== "production" ? BadgeUnstyled.propTypes /* remove-proptypes */ = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* The content rendered within the badge.
*/
badgeContent: PropTypes.node,
/**
* The badge will be added relative to this node.
*/
children: PropTypes.node,
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
*/
component: PropTypes.elementType,
/**
* If `true`, the badge is invisible.
* @default false
*/
invisible: PropTypes.bool,
/**
* Max count to show.
* @default 99
*/
max: PropTypes.number,
/**
* Controls whether the badge is hidden when `badgeContent` is zero.
* @default false
*/
showZero: PropTypes.bool,
/**
* The props used for each slot inside the Badge.
* @default {}
*/
slotProps: PropTypes.shape({
badge: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
}),
/**
* The components used for each slot inside the Badge.
* Either a string to use a HTML element or a component.
* @default {}
*/
slots: PropTypes.shape({
badge: PropTypes.elementType,
root: PropTypes.elementType
})
} : void 0;
export default BadgeUnstyled;
Event Timeline
Log In to Comment