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 { InputTypeMap } from './Input.types';
/**
*
* Demos:
*
* - [Input](https://mui.com/base-ui/react-input/)
*
* API:
*
* - [Input API](https://mui.com/base-ui/react-input/components-api/#input)
*/
declare const Input: PolymorphicComponent<InputTypeMap<{}, "div">>;
export { Input };
+311
View File
@@ -0,0 +1,311 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["aria-describedby", "aria-label", "aria-labelledby", "autoComplete", "autoFocus", "className", "defaultValue", "disabled", "endAdornment", "error", "id", "multiline", "name", "onClick", "onChange", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "placeholder", "readOnly", "required", "startAdornment", "value", "type", "rows", "slotProps", "slots", "minRows", "maxRows"];
import * as React from 'react';
import PropTypes from 'prop-types';
import { isHostComponent } from '../utils/isHostComponent';
import { getInputUtilityClass } from './inputClasses';
import { useInput } from '../useInput';
import { useSlotProps } from '../utils';
import { unstable_composeClasses as composeClasses } from '../composeClasses';
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 {
disabled,
error,
focused,
formControlContext,
multiline,
startAdornment,
endAdornment
} = ownerState;
const slots = {
root: ['root', disabled && 'disabled', error && 'error', focused && 'focused', Boolean(formControlContext) && 'formControl', multiline && 'multiline', Boolean(startAdornment) && 'adornedStart', Boolean(endAdornment) && 'adornedEnd'],
input: ['input', disabled && 'disabled', multiline && 'multiline']
};
return composeClasses(slots, useClassNamesOverride(getInputUtilityClass));
};
/**
*
* Demos:
*
* - [Input](https://mui.com/base-ui/react-input/)
*
* API:
*
* - [Input API](https://mui.com/base-ui/react-input/components-api/#input)
*/
const Input = /*#__PURE__*/React.forwardRef(function Input(props, forwardedRef) {
var _slots$root, _slots$textarea, _slots$input;
const {
'aria-describedby': ariaDescribedby,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledby,
autoComplete,
autoFocus,
className,
defaultValue,
disabled,
endAdornment,
error,
id,
multiline = false,
name,
onClick,
onChange,
onKeyDown,
onKeyUp,
onFocus,
onBlur,
placeholder,
readOnly,
required,
startAdornment,
value,
type: typeProp,
rows,
slotProps = {},
slots = {},
minRows,
maxRows
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const {
getRootProps,
getInputProps,
focused,
formControlContext,
error: errorState,
disabled: disabledState
} = useInput({
disabled,
defaultValue,
error,
onBlur,
onClick,
onChange,
onFocus,
required,
value
});
const type = !multiline ? typeProp != null ? typeProp : 'text' : undefined;
const ownerState = _extends({}, props, {
disabled: disabledState,
error: errorState,
focused,
formControlContext,
multiline,
type
});
const classes = useUtilityClasses(ownerState);
const propsToForward = {
'aria-describedby': ariaDescribedby,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledby,
autoComplete,
autoFocus,
id,
onKeyDown,
onKeyUp,
name,
placeholder,
readOnly,
type
};
const Root = (_slots$root = slots.root) != null ? _slots$root : 'div';
const rootProps = useSlotProps({
elementType: Root,
getSlotProps: getRootProps,
externalSlotProps: slotProps.root,
externalForwardedProps: other,
additionalProps: {
ref: forwardedRef
},
ownerState,
className: [classes.root, className]
});
const InputComponent = multiline ? (_slots$textarea = slots.textarea) != null ? _slots$textarea : 'textarea' : (_slots$input = slots.input) != null ? _slots$input : 'input';
const inputProps = useSlotProps({
elementType: InputComponent,
getSlotProps: otherHandlers => {
return getInputProps(_extends({}, propsToForward, otherHandlers));
},
externalSlotProps: slotProps.input,
additionalProps: _extends({
rows: multiline ? rows : undefined
}, multiline && !isHostComponent(InputComponent) && {
minRows: rows || minRows,
maxRows: rows || maxRows
}),
ownerState,
className: classes.input
});
if (process.env.NODE_ENV !== 'production') {
if (multiline) {
if (rows) {
if (minRows || maxRows) {
console.warn('MUI: You can not use the `minRows` or `maxRows` props when the input `rows` prop is set.');
}
}
}
}
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
children: [startAdornment, /*#__PURE__*/_jsx(InputComponent, _extends({}, inputProps)), endAdornment]
}));
});
process.env.NODE_ENV !== "production" ? Input.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
*/
'aria-describedby': PropTypes.string,
/**
* @ignore
*/
'aria-label': PropTypes.string,
/**
* @ignore
*/
'aria-labelledby': PropTypes.string,
/**
* This prop helps users to fill forms faster, especially on mobile devices.
* The name can be confusing, as it's more like an autofill.
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
*/
autoComplete: PropTypes.string,
/**
* If `true`, the `input` element is focused during the first mount.
*/
autoFocus: PropTypes.bool,
/**
* Class name applied to the root element.
*/
className: PropTypes.string,
/**
* The default value. Use when the component is not controlled.
*/
defaultValue: PropTypes.any,
/**
* If `true`, the component is disabled.
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
*/
disabled: PropTypes.bool,
/**
* Trailing adornment for this input.
*/
endAdornment: PropTypes.node,
/**
* If `true`, the `input` will indicate an error by setting the `aria-invalid` attribute on the input and the `baseui--error` class on the root element.
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
*/
error: PropTypes.bool,
/**
* The id of the `input` element.
*/
id: PropTypes.string,
/**
* @ignore
*/
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
current: PropTypes.object
})]),
/**
* Maximum number of rows to display when multiline option is set to true.
*/
maxRows: PropTypes.number,
/**
* Minimum number of rows to display when multiline option is set to true.
*/
minRows: PropTypes.number,
/**
* If `true`, a `textarea` element is rendered.
* @default false
*/
multiline: PropTypes.bool,
/**
* Name attribute of the `input` element.
*/
name: PropTypes.string,
/**
* @ignore
*/
onBlur: PropTypes.func,
/**
* @ignore
*/
onChange: PropTypes.func,
/**
* @ignore
*/
onClick: PropTypes.func,
/**
* @ignore
*/
onFocus: PropTypes.func,
/**
* @ignore
*/
onKeyDown: PropTypes.func,
/**
* @ignore
*/
onKeyUp: PropTypes.func,
/**
* The short hint displayed in the `input` before the user enters a value.
*/
placeholder: PropTypes.string,
/**
* It prevents the user from changing the value of the field
* (not from interacting with the field).
*/
readOnly: PropTypes.bool,
/**
* If `true`, the `input` element is required.
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
*/
required: PropTypes.bool,
/**
* Number of rows to display when multiline option is set to true.
*/
rows: PropTypes.number,
/**
* The props used for each slot inside the Input.
* @default {}
*/
slotProps: PropTypes.shape({
input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
}),
/**
* The components used for each slot inside the InputBase.
* Either a string to use a HTML element or a component.
* @default {}
*/
slots: PropTypes.shape({
input: PropTypes.elementType,
root: PropTypes.elementType,
textarea: PropTypes.elementType
}),
/**
* Leading adornment for this input.
*/
startAdornment: PropTypes.node,
/**
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).
* @default 'text'
*/
type: PropTypes /* @typescript-to-proptypes-ignore */.oneOf(['button', 'checkbox', 'color', 'date', 'datetime-local', 'email', 'file', 'hidden', 'image', 'month', 'number', 'password', 'radio', 'range', 'reset', 'search', 'submit', 'tel', 'text', 'time', 'url', 'week']),
/**
* The value of the `input` element, required for a controlled component.
*/
value: PropTypes.any
} : void 0;
export { Input };
+176
View File
@@ -0,0 +1,176 @@
import * as React from 'react';
import { Simplify } from '@mui/types';
import { FormControlState } from '../FormControl';
import { UseInputParameters, UseInputRootSlotProps } from '../useInput';
import { PolymorphicProps, SlotComponentProps } from '../utils';
export interface InputRootSlotPropsOverrides {
}
export interface InputInputSlotPropsOverrides {
}
export interface SingleLineInputProps {
/**
* Maximum number of rows to display when multiline option is set to true.
*/
maxRows?: undefined;
/**
* Minimum number of rows to display when multiline option is set to true.
*/
minRows?: undefined;
/**
* If `true`, a `textarea` element is rendered.
* @default false
*/
multiline?: false;
/**
* Number of rows to display when multiline option is set to true.
*/
rows?: undefined;
/**
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).
* @default 'text'
*/
type?: React.HTMLInputTypeAttribute;
}
export interface MultiLineInputProps {
/**
* Maximum number of rows to display when multiline option is set to true.
*/
maxRows?: number;
/**
* Minimum number of rows to display when multiline option is set to true.
*/
minRows?: number;
/**
* If `true`, a `textarea` element is rendered.
* @default false
*/
multiline: true;
/**
* Number of rows to display when multiline option is set to true.
*/
rows?: number;
/**
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).
* @default 'text'
*/
type?: undefined;
}
export type InputOwnProps = (SingleLineInputProps | MultiLineInputProps) & Omit<UseInputParameters, 'error'> & {
'aria-describedby'?: string;
'aria-label'?: string;
'aria-labelledby'?: string;
/**
* This prop helps users to fill forms faster, especially on mobile devices.
* The name can be confusing, as it's more like an autofill.
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
*/
autoComplete?: string;
/**
* If `true`, the `input` element is focused during the first mount.
*/
autoFocus?: boolean;
/**
* Class name applied to the root element.
*/
className?: string;
/**
* Trailing adornment for this input.
*/
endAdornment?: React.ReactNode;
/**
* If `true`, the `input` will indicate an error by setting the `aria-invalid` attribute on the input and the `baseui--error` class on the root element.
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
*/
error?: boolean;
/**
* The id of the `input` element.
*/
id?: string;
/**
* Name attribute of the `input` element.
*/
name?: string;
onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;
/**
* The short hint displayed in the `input` before the user enters a value.
*/
placeholder?: string;
/**
* It prevents the user from changing the value of the field
* (not from interacting with the field).
*/
readOnly?: boolean;
/**
* The props used for each slot inside the Input.
* @default {}
*/
slotProps?: {
root?: SlotComponentProps<'div', InputRootSlotPropsOverrides, InputOwnerState>;
input?: SlotComponentProps<'input', InputInputSlotPropsOverrides, InputOwnerState>;
};
/**
* The components used for each slot inside the InputBase.
* Either a string to use a HTML element or a component.
* @default {}
*/
slots?: InputSlots;
/**
* Leading adornment for this input.
*/
startAdornment?: React.ReactNode;
/**
* The value of the `input` element, required for a controlled component.
*/
value?: unknown;
};
export interface InputSlots {
/**
* The component that renders the root.
* @default 'div'
*/
root?: React.ElementType;
/**
* The component that renders the input.
* @default 'input'
*/
input?: React.ElementType;
/**
* The component that renders the textarea.
* @default 'textarea'
*/
textarea?: React.ElementType;
}
export interface InputTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'div'> {
props: InputOwnProps & AdditionalProps;
defaultComponent: RootComponentType;
}
export type InputProps<RootComponentType extends React.ElementType = InputTypeMap['defaultComponent']> = PolymorphicProps<InputTypeMap<{}, RootComponentType>, RootComponentType>;
export type InputOwnerState = Simplify<InputOwnProps & {
formControlContext: FormControlState | undefined;
focused: boolean;
type: React.InputHTMLAttributes<HTMLInputElement>['type'] | undefined;
}>;
export type InputRootSlotProps = Simplify<UseInputRootSlotProps & {
ownerState: InputOwnerState;
className?: string;
children?: React.ReactNode;
ref?: React.Ref<HTMLDivElement>;
}>;
export type InputInputSlotProps = Simplify<Omit<UseInputRootSlotProps, 'onClick'> & {
'aria-describedby': React.AriaAttributes['aria-describedby'];
'aria-label': React.AriaAttributes['aria-label'];
'aria-labelledby': React.AriaAttributes['aria-labelledby'];
autoComplete: string | undefined;
autoFocus: boolean | undefined;
className?: string;
id: string | undefined;
name: string | undefined;
onKeyDown: React.KeyboardEventHandler<HTMLInputElement> | undefined;
onKeyUp: React.KeyboardEventHandler<HTMLInputElement> | undefined;
ownerState: InputOwnerState;
placeholder: string | undefined;
readOnly: boolean | undefined;
ref: React.Ref<HTMLInputElement>;
type: React.HTMLInputTypeAttribute | undefined;
}>;
+1
View File
@@ -0,0 +1 @@
export {};
+3
View File
@@ -0,0 +1,3 @@
export { Input } from './Input';
export * from './Input.types';
export * from './inputClasses';
+5
View File
@@ -0,0 +1,5 @@
'use client';
export { Input } from './Input';
export * from './Input.types';
export * from './inputClasses';
+27
View File
@@ -0,0 +1,27 @@
export interface InputClasses {
/** Class name applied to the root element. */
root: string;
/** Class name applied to the root element if the component is a descendant of `FormControl`. */
formControl: string;
/** Class name applied to the root element if `startAdornment` is provided. */
adornedStart: string;
/** Class name applied to the root element if `endAdornment` is provided. */
adornedEnd: string;
/** State class applied to the root element if the component is focused. */
focused: string;
/** State class applied to the root element if `disabled={true}`. */
disabled: string;
/** State class applied to the root element if `error={true}`. */
error: string;
/** Class name applied to the root element if `multiline={true}`. */
multiline: string;
/** Class name applied to the input element. */
input: string;
/** Class name applied to the input element if `multiline={true}`. */
inputMultiline: string;
/** Class name applied to the input element if `type="search"`. */
inputTypeSearch: string;
}
export type InputClassKey = keyof InputClasses;
export declare function getInputUtilityClass(slot: string): string;
export declare const inputClasses: InputClasses;
+7
View File
@@ -0,0 +1,7 @@
import { generateUtilityClass } from '../generateUtilityClass';
import { generateUtilityClasses } from '../generateUtilityClasses';
const COMPONENT_NAME = 'Input';
export function getInputUtilityClass(slot) {
return generateUtilityClass(COMPONENT_NAME, slot);
}
export const inputClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'formControl', 'focused', 'disabled', 'error', 'multiline', 'input', 'inputMultiline', 'inputTypeSearch', 'adornedStart', 'adornedEnd']);
+6
View File
@@ -0,0 +1,6 @@
{
"sideEffects": false,
"module": "./index.js",
"main": "../node/Input/index.js",
"types": "./index.d.ts"
}