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 { ButtonTypeMap } from './Button.types';
/**
* The foundation for building custom-styled buttons.
*
* Demos:
*
* - [Button](https://mui.com/base-ui/react-button/)
*
* API:
*
* - [Button API](https://mui.com/base-ui/react-button/components-api/#button)
*/
declare const Button: PolymorphicComponent<ButtonTypeMap<{}, "button">>;
export { Button };
+156
View File
@@ -0,0 +1,156 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["action", "children", "disabled", "focusableWhenDisabled", "onFocusVisible", "slotProps", "slots", "rootElementName"];
import * as React from 'react';
import PropTypes from 'prop-types';
import { unstable_composeClasses as composeClasses } from '../composeClasses';
import { getButtonUtilityClass } from './buttonClasses';
import { useButton } from '../useButton';
import { useSlotProps } from '../utils';
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
import { jsx as _jsx } from "react/jsx-runtime";
const useUtilityClasses = ownerState => {
const {
active,
disabled,
focusVisible
} = ownerState;
const slots = {
root: ['root', disabled && 'disabled', focusVisible && 'focusVisible', active && 'active']
};
return composeClasses(slots, useClassNamesOverride(getButtonUtilityClass));
};
/**
* The foundation for building custom-styled buttons.
*
* Demos:
*
* - [Button](https://mui.com/base-ui/react-button/)
*
* API:
*
* - [Button API](https://mui.com/base-ui/react-button/components-api/#button)
*/
const Button = /*#__PURE__*/React.forwardRef(function Button(props, forwardedRef) {
var _slots$root;
const {
action,
children,
focusableWhenDisabled = false,
slotProps = {},
slots = {},
rootElementName: rootElementNameProp = 'button'
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const buttonRef = React.useRef();
let rootElementName = rootElementNameProp;
if (typeof slots.root === 'string') {
rootElementName = slots.root;
} else if (other.href || other.to) {
rootElementName = 'a';
}
const {
active,
focusVisible,
setFocusVisible,
getRootProps
} = useButton(_extends({}, props, {
focusableWhenDisabled,
rootElementName
}));
React.useImperativeHandle(action, () => ({
focusVisible: () => {
setFocusVisible(true);
buttonRef.current.focus();
}
}), [setFocusVisible]);
const ownerState = _extends({}, props, {
active,
focusableWhenDisabled,
focusVisible
});
const classes = useUtilityClasses(ownerState);
const defaultElement = other.href || other.to ? 'a' : 'button';
const Root = (_slots$root = slots.root) != null ? _slots$root : defaultElement;
const rootProps = useSlotProps({
elementType: Root,
getSlotProps: getRootProps,
externalForwardedProps: other,
externalSlotProps: slotProps.root,
additionalProps: {
ref: forwardedRef
},
ownerState,
className: classes.root
});
return /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
children: children
}));
});
process.env.NODE_ENV !== "production" ? Button.propTypes /* remove-proptypes */ = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* A ref for imperative actions. It currently only supports `focusVisible()` action.
*/
action: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
current: PropTypes.shape({
focusVisible: PropTypes.func.isRequired
})
})]),
/**
* @ignore
*/
children: PropTypes.node,
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, the component is disabled.
* @default false
*/
disabled: PropTypes.bool,
/**
* If `true`, allows a disabled button to receive focus.
* @default false
*/
focusableWhenDisabled: PropTypes.bool,
/**
* @ignore
*/
href: PropTypes.string,
/**
* @ignore
*/
onFocusVisible: PropTypes.func,
/**
* The HTML element that is ultimately rendered, for example 'button' or 'a'
* @default 'button'
*/
rootElementName: PropTypes /* @typescript-to-proptypes-ignore */.string,
/**
* The props used for each slot inside the Button.
* @default {}
*/
slotProps: PropTypes.shape({
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
}),
/**
* The components used for each slot inside the Button.
* Either a string to use a HTML element or a component.
* @default {}
*/
slots: PropTypes.shape({
root: PropTypes.elementType
}),
/**
* @ignore
*/
to: PropTypes.string
} : void 0;
export { Button };
+57
View File
@@ -0,0 +1,57 @@
import * as React from 'react';
import { Simplify } from '@mui/types';
import { UseButtonParameters, UseButtonRootSlotProps } from '../useButton';
import { SlotComponentProps } from '../utils';
import { PolymorphicProps } from '../utils/PolymorphicComponent';
export interface ButtonActions {
focusVisible(): void;
}
export interface ButtonRootSlotPropsOverrides {
}
export interface ButtonOwnProps extends Omit<UseButtonParameters, 'rootRef'> {
/**
* A ref for imperative actions. It currently only supports `focusVisible()` action.
*/
action?: React.Ref<ButtonActions>;
children?: React.ReactNode;
className?: string;
/**
* The props used for each slot inside the Button.
* @default {}
*/
slotProps?: {
root?: SlotComponentProps<'button', ButtonRootSlotPropsOverrides, ButtonOwnerState>;
};
/**
* The components used for each slot inside the Button.
* Either a string to use a HTML element or a component.
* @default {}
*/
slots?: ButtonSlots;
/**
* The HTML element that is ultimately rendered, for example 'button' or 'a'
* @default 'button'
*/
rootElementName?: keyof HTMLElementTagNameMap;
}
export interface ButtonSlots {
/**
* The component that renders the root.
* @default props.href || props.to ? 'a' : 'button'
*/
root?: React.ElementType;
}
export type ButtonProps<RootComponentType extends React.ElementType = ButtonTypeMap['defaultComponent']> = PolymorphicProps<ButtonTypeMap<{}, RootComponentType>, RootComponentType>;
export interface ButtonTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'button'> {
props: ButtonOwnProps & AdditionalProps;
defaultComponent: RootComponentType;
}
export type ButtonOwnerState = Simplify<ButtonOwnProps & {
active: boolean;
focusVisible: boolean;
}>;
export type ButtonRootSlotProps = Simplify<UseButtonRootSlotProps & {
ownerState: ButtonOwnerState;
className?: string;
children?: React.ReactNode;
}>;
+1
View File
@@ -0,0 +1 @@
export {};
+13
View File
@@ -0,0 +1,13 @@
export interface ButtonClasses {
/** Class name applied to the root element. */
root: string;
/** State class applied to the root `button` element if `active={true}`. */
active: 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 ButtonClassKey = keyof ButtonClasses;
export declare function getButtonUtilityClass(slot: string): string;
export declare const buttonClasses: ButtonClasses;
+7
View File
@@ -0,0 +1,7 @@
import { generateUtilityClass } from '../generateUtilityClass';
import { generateUtilityClasses } from '../generateUtilityClasses';
const COMPONENT_NAME = 'Button';
export function getButtonUtilityClass(slot) {
return generateUtilityClass(COMPONENT_NAME, slot);
}
export const buttonClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'active', 'disabled', 'focusVisible']);
+3
View File
@@ -0,0 +1,3 @@
export { Button } from './Button';
export * from './buttonClasses';
export * from './Button.types';
+5
View File
@@ -0,0 +1,5 @@
'use client';
export { Button } from './Button';
export * from './buttonClasses';
export * from './Button.types';
+6
View File
@@ -0,0 +1,6 @@
{
"sideEffects": false,
"module": "./index.js",
"main": "../node/Button/index.js",
"types": "./index.d.ts"
}