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

+15
View File
@@ -0,0 +1,15 @@
import { PolymorphicComponent } from '../utils/PolymorphicComponent';
import { MenuItemTypeMap } from './MenuItem.types';
/**
* An unstyled menu item to be used within a Menu.
*
* Demos:
*
* - [Menu](https://mui.com/base-ui/react-menu/)
*
* API:
*
* - [MenuItem API](https://mui.com/base-ui/react-menu/components-api/#menu-item)
*/
declare const MenuItem: PolymorphicComponent<MenuItemTypeMap<{}, "li">>;
export { MenuItem };
+148
View File
@@ -0,0 +1,148 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["children", "disabled", "label", "id", "slotProps", "slots"];
import * as React from 'react';
import PropTypes from 'prop-types';
import { getMenuItemUtilityClass } from './menuItemClasses';
import { useMenuItem, useMenuItemContextStabilizer } from '../useMenuItem';
import { unstable_composeClasses as composeClasses } from '../composeClasses';
import { useSlotProps } from '../utils/useSlotProps';
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
import { ListContext } from '../useList';
import { jsx as _jsx } from "react/jsx-runtime";
function useUtilityClasses(ownerState) {
const {
disabled,
focusVisible
} = ownerState;
const slots = {
root: ['root', disabled && 'disabled', focusVisible && 'focusVisible']
};
return composeClasses(slots, useClassNamesOverride(getMenuItemUtilityClass));
}
const InnerMenuItem = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function MenuItem(props, forwardedRef) {
var _slots$root;
const {
children,
disabled: disabledProp = false,
label,
id,
slotProps = {},
slots = {}
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const {
getRootProps,
disabled,
focusVisible,
highlighted
} = useMenuItem({
id,
disabled: disabledProp,
rootRef: forwardedRef,
label
});
const ownerState = _extends({}, props, {
disabled,
focusVisible,
highlighted
});
const classes = useUtilityClasses(ownerState);
const Root = (_slots$root = slots.root) != null ? _slots$root : 'li';
const rootProps = useSlotProps({
elementType: Root,
getSlotProps: getRootProps,
externalSlotProps: slotProps.root,
externalForwardedProps: other,
className: classes.root,
ownerState
});
return /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
children: children
}));
}));
/**
* An unstyled menu item to be used within a Menu.
*
* Demos:
*
* - [Menu](https://mui.com/base-ui/react-menu/)
*
* API:
*
* - [MenuItem API](https://mui.com/base-ui/react-menu/components-api/#menu-item)
*/
const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(props, ref) {
const {
id: idProp
} = props;
// This wrapper component is used as a performance optimization.
// `useMenuItemContextStabilizer` ensures that the context value
// is stable across renders, so that the actual MenuItem re-renders
// only when it needs to.
const {
contextValue,
id
} = useMenuItemContextStabilizer(idProp);
return /*#__PURE__*/_jsx(ListContext.Provider, {
value: contextValue,
children: /*#__PURE__*/_jsx(InnerMenuItem, _extends({}, props, {
id: id,
ref: ref
}))
});
});
process.env.NODE_ENV !== "production" ? MenuItem.propTypes /* remove-proptypes */ = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* @ignore
*/
children: PropTypes.node,
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, the menu item will be disabled.
* @default false
*/
disabled: PropTypes.bool,
/**
* If `true`, the menu item won't receive focus when the mouse moves over it.
*
* @default false
*/
disableFocusOnHover: PropTypes.bool,
/**
* A text representation of the menu item's content.
* Used for keyboard text navigation matching.
*/
label: PropTypes.string,
/**
* @ignore
*/
onClick: PropTypes.func,
/**
* The props used for each slot inside the MenuItem.
* @default {}
*/
slotProps: PropTypes.shape({
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
}),
/**
* The components used for each slot inside the MenuItem.
* Either a string to use a HTML element or a component.
* @default {}
*/
slots: PropTypes.shape({
root: PropTypes.elementType
})
} : void 0;
export { MenuItem };
+67
View File
@@ -0,0 +1,67 @@
import * as React from 'react';
import { Simplify } from '@mui/types';
import { PolymorphicProps, SlotComponentProps } from '../utils';
import { UseMenuItemRootSlotProps } from '../useMenuItem';
export interface MenuItemRootSlotPropsOverrides {
}
export type MenuItemOwnerState = Simplify<MenuItemOwnProps & {
disabled: boolean;
focusVisible: boolean;
highlighted: boolean;
}>;
export interface MenuItemOwnProps {
children?: React.ReactNode;
className?: string;
onClick?: React.MouseEventHandler<HTMLElement>;
/**
* If `true`, the menu item will be disabled.
* @default false
*/
disabled?: boolean;
/**
* The components used for each slot inside the MenuItem.
* Either a string to use a HTML element or a component.
* @default {}
*/
slots?: MenuItemSlots;
/**
* The props used for each slot inside the MenuItem.
* @default {}
*/
slotProps?: {
root?: SlotComponentProps<'li', MenuItemRootSlotPropsOverrides, MenuItemOwnerState>;
};
/**
* A text representation of the menu item's content.
* Used for keyboard text navigation matching.
*/
label?: string;
/**
* If `true`, the menu item won't receive focus when the mouse moves over it.
*
* @default false
*/
disableFocusOnHover?: boolean;
}
export interface MenuItemSlots {
/**
* The component that renders the root.
* @default 'li'
*/
root?: React.ElementType;
}
export interface MenuItemTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'li'> {
props: MenuItemOwnProps & AdditionalProps;
defaultComponent: RootComponentType;
}
export type MenuItemProps<RootComponentType extends React.ElementType = MenuItemTypeMap['defaultComponent']> = PolymorphicProps<MenuItemTypeMap<{}, RootComponentType>, RootComponentType>;
export interface MenuItemState {
disabled: boolean;
highlighted: boolean;
}
export type MenuItemRootSlotProps = Simplify<UseMenuItemRootSlotProps & {
children?: React.ReactNode;
className: string;
ref: React.Ref<HTMLElement>;
ownerState: MenuItemOwnerState;
}>;
+1
View File
@@ -0,0 +1 @@
export {};
+3
View File
@@ -0,0 +1,3 @@
export * from './MenuItem';
export * from './MenuItem.types';
export * from './menuItemClasses';
+5
View File
@@ -0,0 +1,5 @@
'use client';
export * from './MenuItem';
export * from './MenuItem.types';
export * from './menuItemClasses';
+11
View File
@@ -0,0 +1,11 @@
export interface MenuItemClasses {
/** Class name applied to the root element. */
root: string;
/** State class applied to the root `button` element if `disabled={true}`. */
disabled: string;
/** State class applied to the root `button` element if `focusVisible={true}`. */
focusVisible: string;
}
export type MenuItemClassKey = keyof MenuItemClasses;
export declare function getMenuItemUtilityClass(slot: string): string;
export declare const menuItemClasses: MenuItemClasses;
+7
View File
@@ -0,0 +1,7 @@
import { generateUtilityClass } from '../generateUtilityClass';
import { generateUtilityClasses } from '../generateUtilityClasses';
const COMPONENT_NAME = 'MenuItem';
export function getMenuItemUtilityClass(slot) {
return generateUtilityClass(COMPONENT_NAME, slot);
}
export const menuItemClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'disabled', 'focusVisible']);
+6
View File
@@ -0,0 +1,6 @@
{
"sideEffects": false,
"module": "./index.js",
"main": "../node/MenuItem/index.js",
"types": "./index.d.ts"
}