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

+16
View File
@@ -0,0 +1,16 @@
import { SnackbarTypeMap } from './Snackbar.types';
import { PolymorphicComponent } from '../utils';
/**
*
* Demos:
*
* - [Snackbar](https://mui.com/base-ui/react-snackbar/)
* - [Snackbar](https://mui.com/joy-ui/react-snackbar/)
* - [Snackbar](https://mui.com/material-ui/react-snackbar/)
*
* API:
*
* - [Snackbar API](https://mui.com/base-ui/react-snackbar/components-api/#snackbar)
*/
declare const Snackbar: PolymorphicComponent<SnackbarTypeMap<{}, "div">>;
export { Snackbar };
+164
View File
@@ -0,0 +1,164 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["autoHideDuration", "children", "disableWindowBlurListener", "exited", "onBlur", "onClose", "onFocus", "onMouseEnter", "onMouseLeave", "open", "resumeHideDuration", "slotProps", "slots"];
import * as React from 'react';
import PropTypes from 'prop-types';
import { ClickAwayListener } from '../ClickAwayListener';
import { unstable_composeClasses as composeClasses } from '../composeClasses';
import { getSnackbarUtilityClass } from './snackbarClasses';
import { useSnackbar } from '../useSnackbar';
import { useSlotProps } from '../utils';
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
import { jsx as _jsx } from "react/jsx-runtime";
const useUtilityClasses = () => {
const slots = {
root: ['root']
};
return composeClasses(slots, useClassNamesOverride(getSnackbarUtilityClass));
};
/**
*
* Demos:
*
* - [Snackbar](https://mui.com/base-ui/react-snackbar/)
* - [Snackbar](https://mui.com/joy-ui/react-snackbar/)
* - [Snackbar](https://mui.com/material-ui/react-snackbar/)
*
* API:
*
* - [Snackbar API](https://mui.com/base-ui/react-snackbar/components-api/#snackbar)
*/
const Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(props, forwardedRef) {
const {
autoHideDuration = null,
children,
disableWindowBlurListener = false,
exited = true,
onClose,
open,
resumeHideDuration,
slotProps = {},
slots = {}
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const classes = useUtilityClasses();
const {
getRootProps,
onClickAway
} = useSnackbar(_extends({}, props, {
autoHideDuration,
disableWindowBlurListener,
onClose,
open,
resumeHideDuration
}));
const ownerState = props;
const Root = slots.root || 'div';
const rootProps = useSlotProps({
elementType: Root,
getSlotProps: getRootProps,
externalForwardedProps: other,
externalSlotProps: slotProps.root,
additionalProps: {
ref: forwardedRef
},
ownerState,
className: classes.root
});
const clickAwayListenerProps = useSlotProps({
elementType: ClickAwayListener,
externalSlotProps: slotProps.clickAwayListener,
additionalProps: {
onClickAway
},
ownerState
});
// ClickAwayListener doesn't support ownerState
delete clickAwayListenerProps.ownerState;
// So that we only render active snackbars.
if (!open && exited) {
return null;
}
return /*#__PURE__*/_jsx(ClickAwayListener, _extends({}, clickAwayListenerProps, {
children: /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
children: children
}))
}));
});
process.env.NODE_ENV !== "production" ? Snackbar.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 number of milliseconds to wait before automatically calling the
* `onClose` function. `onClose` should then set the state of the `open`
* prop to hide the Snackbar. This behavior is disabled by default with
* the `null` value.
* @default null
*/
autoHideDuration: PropTypes.number,
/**
* @ignore
*/
children: PropTypes.node,
/**
* If `true`, the `autoHideDuration` timer will expire even if the window is not focused.
* @default false
*/
disableWindowBlurListener: PropTypes.bool,
/**
* The prop used to handle exited transition and unmount the component.
* @default true
*/
exited: PropTypes.bool,
/**
* Callback fired when the component requests to be closed.
* Typically `onClose` is used to set state in the parent component,
* which is used to control the `Snackbar` `open` prop.
* The `reason` parameter can optionally be used to control the response to `onClose`,
* for example ignoring `clickaway`.
*
* @param {React.SyntheticEvent<any> | Event} event The event source of the callback.
* @param {string} reason Can be: `"timeout"` (`autoHideDuration` expired), `"clickaway"`, or `"escapeKeyDown"`.
*/
onClose: PropTypes.func,
/**
* If `true`, the component is shown.
*/
open: PropTypes.bool,
/**
* The number of milliseconds to wait before dismissing after user interaction.
* If `autoHideDuration` prop isn't specified, it does nothing.
* If `autoHideDuration` prop is specified but `resumeHideDuration` isn't,
* we default to `autoHideDuration / 2` ms.
*/
resumeHideDuration: PropTypes.number,
/**
* The props used for each slot inside the Snackbar.
* @default {}
*/
slotProps: PropTypes.shape({
clickAwayListener: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
children: PropTypes.element.isRequired,
disableReactTree: PropTypes.bool,
mouseEvent: PropTypes.oneOf(['onClick', 'onMouseDown', 'onMouseUp', 'onPointerDown', 'onPointerUp', false]),
onClickAway: PropTypes.func,
touchEvent: PropTypes.oneOf(['onTouchEnd', 'onTouchStart', false])
})]),
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
}),
/**
* The components used for each slot inside the Snackbar.
* Either a string to use a HTML element or a component.
* @default {}
*/
slots: PropTypes.shape({
root: PropTypes.elementType
})
} : void 0;
export { Snackbar };
+52
View File
@@ -0,0 +1,52 @@
import * as React from 'react';
import { ClickAwayListener, ClickAwayListenerProps } from '../ClickAwayListener';
import { UseSnackbarParameters } from '../useSnackbar';
import { PolymorphicProps, SlotComponentProps } from '../utils';
export interface SnackbarRootSlotPropsOverrides {
}
export interface SnackbarClickAwayListenerSlotPropsOverrides {
}
export interface SnackbarOwnProps extends Omit<UseSnackbarParameters, 'ref'> {
children?: React.ReactNode;
/**
* The components used for each slot inside the Snackbar.
* Either a string to use a HTML element or a component.
* @default {}
*/
slots?: SnackbarSlots;
/**
* The props used for each slot inside the Snackbar.
* @default {}
*/
slotProps?: {
clickAwayListener?: SlotComponentProps<typeof ClickAwayListener, SnackbarClickAwayListenerSlotPropsOverrides, SnackbarOwnerState>;
root?: SlotComponentProps<'div', SnackbarRootSlotPropsOverrides, SnackbarOwnerState>;
};
/**
* The prop used to handle exited transition and unmount the component.
* @default true
*/
exited?: boolean;
}
export interface SnackbarSlots {
/**
* The component that renders the root.
* @default 'div'
*/
root?: React.ElementType;
}
export interface SnackbarTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'div'> {
props: SnackbarOwnProps & AdditionalProps;
defaultComponent: RootComponentType;
}
export type SnackbarProps<RootComponentType extends React.ElementType = SnackbarTypeMap['defaultComponent']> = PolymorphicProps<SnackbarTypeMap<{}, RootComponentType>, RootComponentType>;
export type SnackbarOwnerState = SnackbarOwnProps;
export type SnackbarRootSlotProps = {
ownerState: SnackbarOwnerState;
className?: string;
children?: React.ReactNode;
ref: React.Ref<any>;
};
export interface SnackbarClickAwayListenerSlotProps extends ClickAwayListenerProps {
ownerState: SnackbarOwnerState;
}
+1
View File
@@ -0,0 +1 @@
export {};
+3
View File
@@ -0,0 +1,3 @@
export { Snackbar } from './Snackbar';
export * from './Snackbar.types';
export * from './snackbarClasses';
+5
View File
@@ -0,0 +1,5 @@
'use client';
export { Snackbar } from './Snackbar';
export * from './Snackbar.types';
export * from './snackbarClasses';
+6
View File
@@ -0,0 +1,6 @@
{
"sideEffects": false,
"module": "./index.js",
"main": "../node/Snackbar/index.js",
"types": "./index.d.ts"
}
+6
View File
@@ -0,0 +1,6 @@
export interface SnackbarClasses {
/** Class name applied to the root element. */
root: string;
}
export declare function getSnackbarUtilityClass(slot: string): string;
export declare const snackbarClasses: SnackbarClasses;
+7
View File
@@ -0,0 +1,7 @@
import { generateUtilityClass } from '../generateUtilityClass';
import { generateUtilityClasses } from '../generateUtilityClasses';
const COMPONENT_NAME = 'Snackbar';
export function getSnackbarUtilityClass(slot) {
return generateUtilityClass(COMPONENT_NAME, slot);
}
export const snackbarClasses = generateUtilityClasses(COMPONENT_NAME, ['root']);