pre-installations and preparations

This commit is contained in:
MuhammadKhalilzadeh committed 2024-05-05 11:21:00 +03:30
1 parent 3e5a0329cb
commit 201d621ac3
6977 files changed
+742826

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
import { PolymorphicComponent } from '../utils/PolymorphicComponent';
import { BadgeTypeMap } from './Badge.types';
/**
*
* Demos:
*
* - [Badge](https://mui.com/base-ui/react-badge/)
*
* API:
*
* - [Badge API](https://mui.com/base-ui/react-badge/components-api/#badge)
*/
declare const Badge: PolymorphicComponent<BadgeTypeMap<{}, "span">>;
export { Badge };
+130
View File
@@ -0,0 +1,130 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["badgeContent", "children", "invisible", "max", "slotProps", "slots", "showZero"];
import * as React from 'react';
import PropTypes from 'prop-types';
import { unstable_composeClasses as composeClasses } from '../composeClasses';
import { useBadge } from '../useBadge';
import { getBadgeUtilityClass } from './badgeClasses';
import { useSlotProps } from '../utils';
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
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, useClassNamesOverride(getBadgeUtilityClass));
};
/**
*
* Demos:
*
* - [Badge](https://mui.com/base-ui/react-badge/)
*
* API:
*
* - [Badge API](https://mui.com/base-ui/react-badge/components-api/#badge)
*/
const Badge = /*#__PURE__*/React.forwardRef(function Badge(props, forwardedRef) {
var _slots$root, _slots$badge;
const {
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 = (_slots$root = slots.root) != null ? _slots$root : 'span';
const rootProps = useSlotProps({
elementType: Root,
externalSlotProps: slotProps.root,
externalForwardedProps: other,
additionalProps: {
ref: forwardedRef
},
ownerState,
className: classes.root
});
const BadgeComponent = (_slots$badge = slots.badge) != null ? _slots$badge : 'span';
const badgeProps = useSlotProps({
elementType: BadgeComponent,
externalSlotProps: slotProps.badge,
ownerState,
className: classes.badge
});
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
children: [children, /*#__PURE__*/_jsx(BadgeComponent, _extends({}, badgeProps, {
children: displayValue
}))]
}));
});
process.env.NODE_ENV !== "production" ? Badge.propTypes /* remove-proptypes */ = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* The content rendered within the badge.
*/
badgeContent: PropTypes.node,
/**
* The badge will be added relative to this node.
*/
children: PropTypes.node,
/**
* 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 { Badge };
+80
View File
@@ -0,0 +1,80 @@
import * as React from 'react';
import { OverrideProps, Simplify } from '@mui/types';
import { SlotComponentProps } from '../utils';
export interface BadgeRootSlotPropsOverrides {
}
export interface BadgeBadgeSlotPropsOverrides {
}
export type BadgeOwnerState = Simplify<BadgeOwnProps & {
badgeContent: React.ReactNode;
invisible: boolean;
max: number;
showZero: boolean;
}>;
export interface BadgeOwnProps {
/**
* The content rendered within the badge.
*/
badgeContent?: React.ReactNode;
/**
* The badge will be added relative to this node.
*/
children?: React.ReactNode;
/**
* If `true`, the badge is invisible.
* @default false
*/
invisible?: boolean;
/**
* Max count to show.
* @default 99
*/
max?: number;
/**
* The props used for each slot inside the Badge.
* @default {}
*/
slotProps?: {
root?: SlotComponentProps<'span', BadgeRootSlotPropsOverrides, BadgeOwnerState>;
badge?: SlotComponentProps<'span', BadgeBadgeSlotPropsOverrides, BadgeOwnerState>;
};
/**
* The components used for each slot inside the Badge.
* Either a string to use a HTML element or a component.
* @default {}
*/
slots?: BadgeSlots;
/**
* Controls whether the badge is hidden when `badgeContent` is zero.
* @default false
*/
showZero?: boolean;
}
export interface BadgeSlots {
/**
* The component that renders the root.
* @default 'span'
*/
root?: React.ElementType;
/**
* The component that renders the badge.
* @default 'span'
*/
badge?: React.ElementType;
}
export interface BadgeTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'span'> {
props: BadgeOwnProps & AdditionalProps;
defaultComponent: RootComponentType;
}
export type BadgeProps<RootComponentType extends React.ElementType = BadgeTypeMap['defaultComponent']> = OverrideProps<BadgeTypeMap<{}, RootComponentType>, RootComponentType>;
export type BadgeRootSlotProps = {
children?: React.ReactNode;
className?: string;
ownerState: BadgeOwnerState;
ref: React.Ref<HTMLSpanElement>;
};
export type BadgeBadgeSlotProps = {
className?: string;
children?: React.ReactNode;
ownerState: BadgeOwnerState;
};
+1
View File
@@ -0,0 +1 @@
export {};
+11
View File
@@ -0,0 +1,11 @@
export interface BadgeClasses {
/** Class name applied to the root element. */
root: string;
/** Class name applied to the badge `span` element. */
badge: string;
/** State class applied to the badge `span` element if `invisible={true}`. */
invisible: string;
}
export type BadgeClassKey = keyof BadgeClasses;
export declare function getBadgeUtilityClass(slot: string): string;
export declare const badgeClasses: BadgeClasses;
+7
View File
@@ -0,0 +1,7 @@
import { generateUtilityClasses } from '../generateUtilityClasses';
import { generateUtilityClass } from '../generateUtilityClass';
const COMPONENT_NAME = 'Badge';
export function getBadgeUtilityClass(slot) {
return generateUtilityClass(COMPONENT_NAME, slot);
}
export const badgeClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'badge', 'invisible']);
+3
View File
@@ -0,0 +1,3 @@
export { Badge } from './Badge';
export * from './Badge.types';
export * from './badgeClasses';
+5
View File
@@ -0,0 +1,5 @@
'use client';
export { Badge } from './Badge';
export * from './Badge.types';
export * from './badgeClasses';
+6
View File
@@ -0,0 +1,6 @@
{
"sideEffects": false,
"module": "./index.js",
"main": "../node/Badge/index.js",
"types": "./index.d.ts"
}