Grabbed dndbeyond's source code
``` ~/go/bin/sourcemapper -output ddb -jsurl https://media.dndbeyond.com/character-app/static/js/main.90aa78c5.js ```
This commit is contained in:
+340
@@ -0,0 +1,340 @@
|
||||
'use client';
|
||||
|
||||
/* eslint-disable consistent-return, jsx-a11y/no-noninteractive-tabindex */
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { exactProp, elementAcceptingRef, unstable_useForkRef as useForkRef, unstable_ownerDocument as ownerDocument } from '@mui/utils';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
// Inspired by https://github.com/focus-trap/tabbable
|
||||
const candidatesSelector = ['input', 'select', 'textarea', 'a[href]', 'button', '[tabindex]', 'audio[controls]', 'video[controls]', '[contenteditable]:not([contenteditable="false"])'].join(',');
|
||||
function getTabIndex(node) {
|
||||
const tabindexAttr = parseInt(node.getAttribute('tabindex') || '', 10);
|
||||
if (!Number.isNaN(tabindexAttr)) {
|
||||
return tabindexAttr;
|
||||
}
|
||||
|
||||
// Browsers do not return `tabIndex` correctly for contentEditable nodes;
|
||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=661108&q=contenteditable%20tabindex&can=2
|
||||
// so if they don't have a tabindex attribute specifically set, assume it's 0.
|
||||
// in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
|
||||
// `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
|
||||
// yet they are still part of the regular tab order; in FF, they get a default
|
||||
// `tabIndex` of 0; since Chrome still puts those elements in the regular tab
|
||||
// order, consider their tab index to be 0.
|
||||
if (node.contentEditable === 'true' || (node.nodeName === 'AUDIO' || node.nodeName === 'VIDEO' || node.nodeName === 'DETAILS') && node.getAttribute('tabindex') === null) {
|
||||
return 0;
|
||||
}
|
||||
return node.tabIndex;
|
||||
}
|
||||
function isNonTabbableRadio(node) {
|
||||
if (node.tagName !== 'INPUT' || node.type !== 'radio') {
|
||||
return false;
|
||||
}
|
||||
if (!node.name) {
|
||||
return false;
|
||||
}
|
||||
const getRadio = selector => node.ownerDocument.querySelector(`input[type="radio"]${selector}`);
|
||||
let roving = getRadio(`[name="${node.name}"]:checked`);
|
||||
if (!roving) {
|
||||
roving = getRadio(`[name="${node.name}"]`);
|
||||
}
|
||||
return roving !== node;
|
||||
}
|
||||
function isNodeMatchingSelectorFocusable(node) {
|
||||
if (node.disabled || node.tagName === 'INPUT' && node.type === 'hidden' || isNonTabbableRadio(node)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function defaultGetTabbable(root) {
|
||||
const regularTabNodes = [];
|
||||
const orderedTabNodes = [];
|
||||
Array.from(root.querySelectorAll(candidatesSelector)).forEach((node, i) => {
|
||||
const nodeTabIndex = getTabIndex(node);
|
||||
if (nodeTabIndex === -1 || !isNodeMatchingSelectorFocusable(node)) {
|
||||
return;
|
||||
}
|
||||
if (nodeTabIndex === 0) {
|
||||
regularTabNodes.push(node);
|
||||
} else {
|
||||
orderedTabNodes.push({
|
||||
documentOrder: i,
|
||||
tabIndex: nodeTabIndex,
|
||||
node: node
|
||||
});
|
||||
}
|
||||
});
|
||||
return orderedTabNodes.sort((a, b) => a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex).map(a => a.node).concat(regularTabNodes);
|
||||
}
|
||||
function defaultIsEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility component that locks focus inside the component.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Focus Trap](https://mui.com/base-ui/react-focus-trap/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [FocusTrap API](https://mui.com/base-ui/react-focus-trap/components-api/#focus-trap)
|
||||
*/
|
||||
function FocusTrap(props) {
|
||||
const {
|
||||
children,
|
||||
disableAutoFocus = false,
|
||||
disableEnforceFocus = false,
|
||||
disableRestoreFocus = false,
|
||||
getTabbable = defaultGetTabbable,
|
||||
isEnabled = defaultIsEnabled,
|
||||
open
|
||||
} = props;
|
||||
const ignoreNextEnforceFocus = React.useRef(false);
|
||||
const sentinelStart = React.useRef(null);
|
||||
const sentinelEnd = React.useRef(null);
|
||||
const nodeToRestore = React.useRef(null);
|
||||
const reactFocusEventTarget = React.useRef(null);
|
||||
// This variable is useful when disableAutoFocus is true.
|
||||
// It waits for the active element to move into the component to activate.
|
||||
const activated = React.useRef(false);
|
||||
const rootRef = React.useRef(null);
|
||||
// @ts-expect-error TODO upstream fix
|
||||
const handleRef = useForkRef(children.ref, rootRef);
|
||||
const lastKeydown = React.useRef(null);
|
||||
React.useEffect(() => {
|
||||
// We might render an empty child.
|
||||
if (!open || !rootRef.current) {
|
||||
return;
|
||||
}
|
||||
activated.current = !disableAutoFocus;
|
||||
}, [disableAutoFocus, open]);
|
||||
React.useEffect(() => {
|
||||
// We might render an empty child.
|
||||
if (!open || !rootRef.current) {
|
||||
return;
|
||||
}
|
||||
const doc = ownerDocument(rootRef.current);
|
||||
if (!rootRef.current.contains(doc.activeElement)) {
|
||||
if (!rootRef.current.hasAttribute('tabIndex')) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
console.error(['MUI: The modal content node does not accept focus.', 'For the benefit of assistive technologies, ' + 'the tabIndex of the node is being set to "-1".'].join('\n'));
|
||||
}
|
||||
rootRef.current.setAttribute('tabIndex', '-1');
|
||||
}
|
||||
if (activated.current) {
|
||||
rootRef.current.focus();
|
||||
}
|
||||
}
|
||||
return () => {
|
||||
// restoreLastFocus()
|
||||
if (!disableRestoreFocus) {
|
||||
// In IE11 it is possible for document.activeElement to be null resulting
|
||||
// in nodeToRestore.current being null.
|
||||
// Not all elements in IE11 have a focus method.
|
||||
// Once IE11 support is dropped the focus() call can be unconditional.
|
||||
if (nodeToRestore.current && nodeToRestore.current.focus) {
|
||||
ignoreNextEnforceFocus.current = true;
|
||||
nodeToRestore.current.focus();
|
||||
}
|
||||
nodeToRestore.current = null;
|
||||
}
|
||||
};
|
||||
// Missing `disableRestoreFocus` which is fine.
|
||||
// We don't support changing that prop on an open FocusTrap
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [open]);
|
||||
React.useEffect(() => {
|
||||
// We might render an empty child.
|
||||
if (!open || !rootRef.current) {
|
||||
return;
|
||||
}
|
||||
const doc = ownerDocument(rootRef.current);
|
||||
const loopFocus = nativeEvent => {
|
||||
lastKeydown.current = nativeEvent;
|
||||
if (disableEnforceFocus || !isEnabled() || nativeEvent.key !== 'Tab') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the next tab starts from the right place.
|
||||
// doc.activeElement refers to the origin.
|
||||
if (doc.activeElement === rootRef.current && nativeEvent.shiftKey) {
|
||||
// We need to ignore the next contain as
|
||||
// it will try to move the focus back to the rootRef element.
|
||||
ignoreNextEnforceFocus.current = true;
|
||||
if (sentinelEnd.current) {
|
||||
sentinelEnd.current.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
const contain = () => {
|
||||
const rootElement = rootRef.current;
|
||||
|
||||
// Cleanup functions are executed lazily in React 17.
|
||||
// Contain can be called between the component being unmounted and its cleanup function being run.
|
||||
if (rootElement === null) {
|
||||
return;
|
||||
}
|
||||
if (!doc.hasFocus() || !isEnabled() || ignoreNextEnforceFocus.current) {
|
||||
ignoreNextEnforceFocus.current = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// The focus is already inside
|
||||
if (rootElement.contains(doc.activeElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The disableEnforceFocus is set and the focus is outside of the focus trap (and sentinel nodes)
|
||||
if (disableEnforceFocus && doc.activeElement !== sentinelStart.current && doc.activeElement !== sentinelEnd.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if the focus event is not coming from inside the children's react tree, reset the refs
|
||||
if (doc.activeElement !== reactFocusEventTarget.current) {
|
||||
reactFocusEventTarget.current = null;
|
||||
} else if (reactFocusEventTarget.current !== null) {
|
||||
return;
|
||||
}
|
||||
if (!activated.current) {
|
||||
return;
|
||||
}
|
||||
let tabbable = [];
|
||||
if (doc.activeElement === sentinelStart.current || doc.activeElement === sentinelEnd.current) {
|
||||
tabbable = getTabbable(rootRef.current);
|
||||
}
|
||||
|
||||
// one of the sentinel nodes was focused, so move the focus
|
||||
// to the first/last tabbable element inside the focus trap
|
||||
if (tabbable.length > 0) {
|
||||
var _lastKeydown$current, _lastKeydown$current2;
|
||||
const isShiftTab = Boolean(((_lastKeydown$current = lastKeydown.current) == null ? void 0 : _lastKeydown$current.shiftKey) && ((_lastKeydown$current2 = lastKeydown.current) == null ? void 0 : _lastKeydown$current2.key) === 'Tab');
|
||||
const focusNext = tabbable[0];
|
||||
const focusPrevious = tabbable[tabbable.length - 1];
|
||||
if (typeof focusNext !== 'string' && typeof focusPrevious !== 'string') {
|
||||
if (isShiftTab) {
|
||||
focusPrevious.focus();
|
||||
} else {
|
||||
focusNext.focus();
|
||||
}
|
||||
}
|
||||
// no tabbable elements in the trap focus or the focus was outside of the focus trap
|
||||
} else {
|
||||
rootElement.focus();
|
||||
}
|
||||
};
|
||||
doc.addEventListener('focusin', contain);
|
||||
doc.addEventListener('keydown', loopFocus, true);
|
||||
|
||||
// With Edge, Safari and Firefox, no focus related events are fired when the focused area stops being a focused area.
|
||||
// for example https://bugzilla.mozilla.org/show_bug.cgi?id=559561.
|
||||
// Instead, we can look if the active element was restored on the BODY element.
|
||||
//
|
||||
// The whatwg spec defines how the browser should behave but does not explicitly mention any events:
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#focus-fixup-rule.
|
||||
const interval = setInterval(() => {
|
||||
if (doc.activeElement && doc.activeElement.tagName === 'BODY') {
|
||||
contain();
|
||||
}
|
||||
}, 50);
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
doc.removeEventListener('focusin', contain);
|
||||
doc.removeEventListener('keydown', loopFocus, true);
|
||||
};
|
||||
}, [disableAutoFocus, disableEnforceFocus, disableRestoreFocus, isEnabled, open, getTabbable]);
|
||||
const onFocus = event => {
|
||||
if (nodeToRestore.current === null) {
|
||||
nodeToRestore.current = event.relatedTarget;
|
||||
}
|
||||
activated.current = true;
|
||||
reactFocusEventTarget.current = event.target;
|
||||
const childrenPropsHandler = children.props.onFocus;
|
||||
if (childrenPropsHandler) {
|
||||
childrenPropsHandler(event);
|
||||
}
|
||||
};
|
||||
const handleFocusSentinel = event => {
|
||||
if (nodeToRestore.current === null) {
|
||||
nodeToRestore.current = event.relatedTarget;
|
||||
}
|
||||
activated.current = true;
|
||||
};
|
||||
return /*#__PURE__*/_jsxs(React.Fragment, {
|
||||
children: [/*#__PURE__*/_jsx("div", {
|
||||
tabIndex: open ? 0 : -1,
|
||||
onFocus: handleFocusSentinel,
|
||||
ref: sentinelStart,
|
||||
"data-testid": "sentinelStart"
|
||||
}), /*#__PURE__*/React.cloneElement(children, {
|
||||
ref: handleRef,
|
||||
onFocus
|
||||
}), /*#__PURE__*/_jsx("div", {
|
||||
tabIndex: open ? 0 : -1,
|
||||
onFocus: handleFocusSentinel,
|
||||
ref: sentinelEnd,
|
||||
"data-testid": "sentinelEnd"
|
||||
})]
|
||||
});
|
||||
}
|
||||
process.env.NODE_ENV !== "production" ? FocusTrap.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 single child content element.
|
||||
*/
|
||||
children: elementAcceptingRef,
|
||||
/**
|
||||
* If `true`, the focus trap will not automatically shift focus to itself when it opens, and
|
||||
* replace it to the last focused element when it closes.
|
||||
* This also works correctly with any focus trap children that have the `disableAutoFocus` prop.
|
||||
*
|
||||
* Generally this should never be set to `true` as it makes the focus trap less
|
||||
* accessible to assistive technologies, like screen readers.
|
||||
* @default false
|
||||
*/
|
||||
disableAutoFocus: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the focus trap will not prevent focus from leaving the focus trap while open.
|
||||
*
|
||||
* Generally this should never be set to `true` as it makes the focus trap less
|
||||
* accessible to assistive technologies, like screen readers.
|
||||
* @default false
|
||||
*/
|
||||
disableEnforceFocus: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the focus trap will not restore focus to previously focused element once
|
||||
* focus trap is hidden or unmounted.
|
||||
* @default false
|
||||
*/
|
||||
disableRestoreFocus: PropTypes.bool,
|
||||
/**
|
||||
* Returns an array of ordered tabbable nodes (i.e. in tab order) within the root.
|
||||
* For instance, you can provide the "tabbable" npm dependency.
|
||||
* @param {HTMLElement} root
|
||||
*/
|
||||
getTabbable: PropTypes.func,
|
||||
/**
|
||||
* This prop extends the `open` prop.
|
||||
* It allows to toggle the open state without having to wait for a rerender when changing the `open` prop.
|
||||
* This prop should be memoized.
|
||||
* It can be used to support multiple focus trap mounted at the same time.
|
||||
* @default function defaultIsEnabled(): boolean {
|
||||
* return true;
|
||||
* }
|
||||
*/
|
||||
isEnabled: PropTypes.func,
|
||||
/**
|
||||
* If `true`, focus is locked.
|
||||
*/
|
||||
open: PropTypes.bool.isRequired
|
||||
} : void 0;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// eslint-disable-next-line
|
||||
FocusTrap['propTypes' + ''] = exactProp(FocusTrap.propTypes);
|
||||
}
|
||||
export { FocusTrap };
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import PropTypes from 'prop-types';
|
||||
import { exactProp, HTMLElementType, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useForkRef as useForkRef, unstable_setRef as setRef } from '@mui/utils';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function getContainer(container) {
|
||||
return typeof container === 'function' ? container() : container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Portals provide a first-class way to render children into a DOM node
|
||||
* that exists outside the DOM hierarchy of the parent component.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Portal](https://mui.com/base-ui/react-portal/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Portal API](https://mui.com/base-ui/react-portal/components-api/#portal)
|
||||
*/
|
||||
const Portal = /*#__PURE__*/React.forwardRef(function Portal(props, forwardedRef) {
|
||||
const {
|
||||
children,
|
||||
container,
|
||||
disablePortal = false
|
||||
} = props;
|
||||
const [mountNode, setMountNode] = React.useState(null);
|
||||
// @ts-expect-error TODO upstream fix
|
||||
const handleRef = useForkRef( /*#__PURE__*/React.isValidElement(children) ? children.ref : null, forwardedRef);
|
||||
useEnhancedEffect(() => {
|
||||
if (!disablePortal) {
|
||||
setMountNode(getContainer(container) || document.body);
|
||||
}
|
||||
}, [container, disablePortal]);
|
||||
useEnhancedEffect(() => {
|
||||
if (mountNode && !disablePortal) {
|
||||
setRef(forwardedRef, mountNode);
|
||||
return () => {
|
||||
setRef(forwardedRef, null);
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}, [forwardedRef, mountNode, disablePortal]);
|
||||
if (disablePortal) {
|
||||
if ( /*#__PURE__*/React.isValidElement(children)) {
|
||||
const newProps = {
|
||||
ref: handleRef
|
||||
};
|
||||
return /*#__PURE__*/React.cloneElement(children, newProps);
|
||||
}
|
||||
return /*#__PURE__*/_jsx(React.Fragment, {
|
||||
children: children
|
||||
});
|
||||
}
|
||||
return /*#__PURE__*/_jsx(React.Fragment, {
|
||||
children: mountNode ? /*#__PURE__*/ReactDOM.createPortal(children, mountNode) : mountNode
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Portal.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 children to render into the `container`.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* An HTML element or function that returns one.
|
||||
* The `container` will have the portal children appended to it.
|
||||
*
|
||||
* You can also provide a callback, which is called in a React layout effect.
|
||||
* This lets you set the container from a ref, and also makes server-side rendering possible.
|
||||
*
|
||||
* By default, it uses the body of the top-level document object,
|
||||
* so it's simply `document.body` most of the time.
|
||||
*/
|
||||
container: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([HTMLElementType, PropTypes.func]),
|
||||
/**
|
||||
* The `children` will be under the DOM hierarchy of the parent component.
|
||||
* @default false
|
||||
*/
|
||||
disablePortal: PropTypes.bool
|
||||
} : void 0;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// eslint-disable-next-line
|
||||
Portal['propTypes' + ''] = exactProp(Portal.propTypes);
|
||||
}
|
||||
export { Portal };
|
||||
+219
@@ -0,0 +1,219 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["onChange", "maxRows", "minRows", "style", "value"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_debounce as debounce, unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, unstable_ownerWindow as ownerWindow } from '@mui/utils';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
function getStyleValue(value) {
|
||||
return parseInt(value, 10) || 0;
|
||||
}
|
||||
const styles = {
|
||||
shadow: {
|
||||
// Visibility needed to hide the extra text area on iPads
|
||||
visibility: 'hidden',
|
||||
// Remove from the content flow
|
||||
position: 'absolute',
|
||||
// Ignore the scrollbar width
|
||||
overflow: 'hidden',
|
||||
height: 0,
|
||||
top: 0,
|
||||
left: 0,
|
||||
// Create a new layer, increase the isolation of the computed values
|
||||
transform: 'translateZ(0)'
|
||||
}
|
||||
};
|
||||
function isEmpty(obj) {
|
||||
return obj === undefined || obj === null || Object.keys(obj).length === 0 || obj.outerHeightStyle === 0 && !obj.overflowing;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Textarea Autosize](https://mui.com/base-ui/react-textarea-autosize/)
|
||||
* - [Textarea Autosize](https://mui.com/material-ui/react-textarea-autosize/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [TextareaAutosize API](https://mui.com/base-ui/react-textarea-autosize/components-api/#textarea-autosize)
|
||||
*/
|
||||
const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize(props, forwardedRef) {
|
||||
const {
|
||||
onChange,
|
||||
maxRows,
|
||||
minRows = 1,
|
||||
style,
|
||||
value
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const {
|
||||
current: isControlled
|
||||
} = React.useRef(value != null);
|
||||
const inputRef = React.useRef(null);
|
||||
const handleRef = useForkRef(forwardedRef, inputRef);
|
||||
const shadowRef = React.useRef(null);
|
||||
const calculateTextareaStyles = React.useCallback(() => {
|
||||
const input = inputRef.current;
|
||||
const containerWindow = ownerWindow(input);
|
||||
const computedStyle = containerWindow.getComputedStyle(input);
|
||||
|
||||
// If input's width is shrunk and it's not visible, don't sync height.
|
||||
if (computedStyle.width === '0px') {
|
||||
return {
|
||||
outerHeightStyle: 0,
|
||||
overflowing: false
|
||||
};
|
||||
}
|
||||
const inputShallow = shadowRef.current;
|
||||
inputShallow.style.width = computedStyle.width;
|
||||
inputShallow.value = input.value || props.placeholder || 'x';
|
||||
if (inputShallow.value.slice(-1) === '\n') {
|
||||
// Certain fonts which overflow the line height will cause the textarea
|
||||
// to report a different scrollHeight depending on whether the last line
|
||||
// is empty. Make it non-empty to avoid this issue.
|
||||
inputShallow.value += ' ';
|
||||
}
|
||||
const boxSizing = computedStyle.boxSizing;
|
||||
const padding = getStyleValue(computedStyle.paddingBottom) + getStyleValue(computedStyle.paddingTop);
|
||||
const border = getStyleValue(computedStyle.borderBottomWidth) + getStyleValue(computedStyle.borderTopWidth);
|
||||
|
||||
// The height of the inner content
|
||||
const innerHeight = inputShallow.scrollHeight;
|
||||
|
||||
// Measure height of a textarea with a single row
|
||||
inputShallow.value = 'x';
|
||||
const singleRowHeight = inputShallow.scrollHeight;
|
||||
|
||||
// The height of the outer content
|
||||
let outerHeight = innerHeight;
|
||||
if (minRows) {
|
||||
outerHeight = Math.max(Number(minRows) * singleRowHeight, outerHeight);
|
||||
}
|
||||
if (maxRows) {
|
||||
outerHeight = Math.min(Number(maxRows) * singleRowHeight, outerHeight);
|
||||
}
|
||||
outerHeight = Math.max(outerHeight, singleRowHeight);
|
||||
|
||||
// Take the box sizing into account for applying this value as a style.
|
||||
const outerHeightStyle = outerHeight + (boxSizing === 'border-box' ? padding + border : 0);
|
||||
const overflowing = Math.abs(outerHeight - innerHeight) <= 1;
|
||||
return {
|
||||
outerHeightStyle,
|
||||
overflowing
|
||||
};
|
||||
}, [maxRows, minRows, props.placeholder]);
|
||||
const syncHeight = React.useCallback(() => {
|
||||
const textareaStyles = calculateTextareaStyles();
|
||||
if (isEmpty(textareaStyles)) {
|
||||
return;
|
||||
}
|
||||
const input = inputRef.current;
|
||||
input.style.height = `${textareaStyles.outerHeightStyle}px`;
|
||||
input.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
|
||||
}, [calculateTextareaStyles]);
|
||||
useEnhancedEffect(() => {
|
||||
const handleResize = () => {
|
||||
syncHeight();
|
||||
};
|
||||
// Workaround a "ResizeObserver loop completed with undelivered notifications" error
|
||||
// in test.
|
||||
// Note that we might need to use this logic in production per https://github.com/WICG/resize-observer/issues/38
|
||||
// Also see https://github.com/mui/mui-x/issues/8733
|
||||
let rAF;
|
||||
const rAFHandleResize = () => {
|
||||
cancelAnimationFrame(rAF);
|
||||
rAF = requestAnimationFrame(() => {
|
||||
handleResize();
|
||||
});
|
||||
};
|
||||
const debounceHandleResize = debounce(handleResize);
|
||||
const input = inputRef.current;
|
||||
const containerWindow = ownerWindow(input);
|
||||
containerWindow.addEventListener('resize', debounceHandleResize);
|
||||
let resizeObserver;
|
||||
if (typeof ResizeObserver !== 'undefined') {
|
||||
resizeObserver = new ResizeObserver(process.env.NODE_ENV === 'test' ? rAFHandleResize : handleResize);
|
||||
resizeObserver.observe(input);
|
||||
}
|
||||
return () => {
|
||||
debounceHandleResize.clear();
|
||||
cancelAnimationFrame(rAF);
|
||||
containerWindow.removeEventListener('resize', debounceHandleResize);
|
||||
if (resizeObserver) {
|
||||
resizeObserver.disconnect();
|
||||
}
|
||||
};
|
||||
}, [calculateTextareaStyles, syncHeight]);
|
||||
useEnhancedEffect(() => {
|
||||
syncHeight();
|
||||
});
|
||||
const handleChange = event => {
|
||||
if (!isControlled) {
|
||||
syncHeight();
|
||||
}
|
||||
if (onChange) {
|
||||
onChange(event);
|
||||
}
|
||||
};
|
||||
return /*#__PURE__*/_jsxs(React.Fragment, {
|
||||
children: [/*#__PURE__*/_jsx("textarea", _extends({
|
||||
value: value,
|
||||
onChange: handleChange,
|
||||
ref: handleRef
|
||||
// Apply the rows prop to get a "correct" first SSR paint
|
||||
,
|
||||
rows: minRows,
|
||||
style: style
|
||||
}, other)), /*#__PURE__*/_jsx("textarea", {
|
||||
"aria-hidden": true,
|
||||
className: props.className,
|
||||
readOnly: true,
|
||||
ref: shadowRef,
|
||||
tabIndex: -1,
|
||||
style: _extends({}, styles.shadow, style, {
|
||||
paddingTop: 0,
|
||||
paddingBottom: 0
|
||||
})
|
||||
})]
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? TextareaAutosize.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
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* Maximum number of rows to display.
|
||||
*/
|
||||
maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* Minimum number of rows to display.
|
||||
* @default 1
|
||||
*/
|
||||
minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
placeholder: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
style: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.number, PropTypes.string])
|
||||
} : void 0;
|
||||
export { TextareaAutosize };
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
import { unstable_ownerWindow as ownerWindow, unstable_ownerDocument as ownerDocument, unstable_getScrollbarSize as getScrollbarSize } from '@mui/utils';
|
||||
// Is a vertical scrollbar displayed?
|
||||
function isOverflowing(container) {
|
||||
const doc = ownerDocument(container);
|
||||
if (doc.body === container) {
|
||||
return ownerWindow(container).innerWidth > doc.documentElement.clientWidth;
|
||||
}
|
||||
return container.scrollHeight > container.clientHeight;
|
||||
}
|
||||
export function ariaHidden(element, show) {
|
||||
if (show) {
|
||||
element.setAttribute('aria-hidden', 'true');
|
||||
} else {
|
||||
element.removeAttribute('aria-hidden');
|
||||
}
|
||||
}
|
||||
function getPaddingRight(element) {
|
||||
return parseInt(ownerWindow(element).getComputedStyle(element).paddingRight, 10) || 0;
|
||||
}
|
||||
function isAriaHiddenForbiddenOnElement(element) {
|
||||
// The forbidden HTML tags are the ones from ARIA specification that
|
||||
// can be children of body and can't have aria-hidden attribute.
|
||||
// cf. https://www.w3.org/TR/html-aria/#docconformance
|
||||
const forbiddenTagNames = ['TEMPLATE', 'SCRIPT', 'STYLE', 'LINK', 'MAP', 'META', 'NOSCRIPT', 'PICTURE', 'COL', 'COLGROUP', 'PARAM', 'SLOT', 'SOURCE', 'TRACK'];
|
||||
const isForbiddenTagName = forbiddenTagNames.indexOf(element.tagName) !== -1;
|
||||
const isInputHidden = element.tagName === 'INPUT' && element.getAttribute('type') === 'hidden';
|
||||
return isForbiddenTagName || isInputHidden;
|
||||
}
|
||||
function ariaHiddenSiblings(container, mountElement, currentElement, elementsToExclude, show) {
|
||||
const blacklist = [mountElement, currentElement, ...elementsToExclude];
|
||||
[].forEach.call(container.children, element => {
|
||||
const isNotExcludedElement = blacklist.indexOf(element) === -1;
|
||||
const isNotForbiddenElement = !isAriaHiddenForbiddenOnElement(element);
|
||||
if (isNotExcludedElement && isNotForbiddenElement) {
|
||||
ariaHidden(element, show);
|
||||
}
|
||||
});
|
||||
}
|
||||
function findIndexOf(items, callback) {
|
||||
let idx = -1;
|
||||
items.some((item, index) => {
|
||||
if (callback(item)) {
|
||||
idx = index;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return idx;
|
||||
}
|
||||
function handleContainer(containerInfo, props) {
|
||||
const restoreStyle = [];
|
||||
const container = containerInfo.container;
|
||||
if (!props.disableScrollLock) {
|
||||
if (isOverflowing(container)) {
|
||||
// Compute the size before applying overflow hidden to avoid any scroll jumps.
|
||||
const scrollbarSize = getScrollbarSize(ownerDocument(container));
|
||||
restoreStyle.push({
|
||||
value: container.style.paddingRight,
|
||||
property: 'padding-right',
|
||||
el: container
|
||||
});
|
||||
// Use computed style, here to get the real padding to add our scrollbar width.
|
||||
container.style.paddingRight = `${getPaddingRight(container) + scrollbarSize}px`;
|
||||
|
||||
// .mui-fixed is a global helper.
|
||||
const fixedElements = ownerDocument(container).querySelectorAll('.mui-fixed');
|
||||
[].forEach.call(fixedElements, element => {
|
||||
restoreStyle.push({
|
||||
value: element.style.paddingRight,
|
||||
property: 'padding-right',
|
||||
el: element
|
||||
});
|
||||
element.style.paddingRight = `${getPaddingRight(element) + scrollbarSize}px`;
|
||||
});
|
||||
}
|
||||
let scrollContainer;
|
||||
if (container.parentNode instanceof DocumentFragment) {
|
||||
scrollContainer = ownerDocument(container).body;
|
||||
} else {
|
||||
// Support html overflow-y: auto for scroll stability between pages
|
||||
// https://css-tricks.com/snippets/css/force-vertical-scrollbar/
|
||||
const parent = container.parentElement;
|
||||
const containerWindow = ownerWindow(container);
|
||||
scrollContainer = (parent == null ? void 0 : parent.nodeName) === 'HTML' && containerWindow.getComputedStyle(parent).overflowY === 'scroll' ? parent : container;
|
||||
}
|
||||
|
||||
// Block the scroll even if no scrollbar is visible to account for mobile keyboard
|
||||
// screensize shrink.
|
||||
restoreStyle.push({
|
||||
value: scrollContainer.style.overflow,
|
||||
property: 'overflow',
|
||||
el: scrollContainer
|
||||
}, {
|
||||
value: scrollContainer.style.overflowX,
|
||||
property: 'overflow-x',
|
||||
el: scrollContainer
|
||||
}, {
|
||||
value: scrollContainer.style.overflowY,
|
||||
property: 'overflow-y',
|
||||
el: scrollContainer
|
||||
});
|
||||
scrollContainer.style.overflow = 'hidden';
|
||||
}
|
||||
const restore = () => {
|
||||
restoreStyle.forEach(({
|
||||
value,
|
||||
el,
|
||||
property
|
||||
}) => {
|
||||
if (value) {
|
||||
el.style.setProperty(property, value);
|
||||
} else {
|
||||
el.style.removeProperty(property);
|
||||
}
|
||||
});
|
||||
};
|
||||
return restore;
|
||||
}
|
||||
function getHiddenSiblings(container) {
|
||||
const hiddenSiblings = [];
|
||||
[].forEach.call(container.children, element => {
|
||||
if (element.getAttribute('aria-hidden') === 'true') {
|
||||
hiddenSiblings.push(element);
|
||||
}
|
||||
});
|
||||
return hiddenSiblings;
|
||||
}
|
||||
/**
|
||||
* @ignore - do not document.
|
||||
*
|
||||
* Proper state management for containers and the modals in those containers.
|
||||
* Simplified, but inspired by react-overlay's ModalManager class.
|
||||
* Used by the Modal to ensure proper styling of containers.
|
||||
*/
|
||||
export class ModalManager {
|
||||
constructor() {
|
||||
this.containers = void 0;
|
||||
this.modals = void 0;
|
||||
this.modals = [];
|
||||
this.containers = [];
|
||||
}
|
||||
add(modal, container) {
|
||||
let modalIndex = this.modals.indexOf(modal);
|
||||
if (modalIndex !== -1) {
|
||||
return modalIndex;
|
||||
}
|
||||
modalIndex = this.modals.length;
|
||||
this.modals.push(modal);
|
||||
|
||||
// If the modal we are adding is already in the DOM.
|
||||
if (modal.modalRef) {
|
||||
ariaHidden(modal.modalRef, false);
|
||||
}
|
||||
const hiddenSiblings = getHiddenSiblings(container);
|
||||
ariaHiddenSiblings(container, modal.mount, modal.modalRef, hiddenSiblings, true);
|
||||
const containerIndex = findIndexOf(this.containers, item => item.container === container);
|
||||
if (containerIndex !== -1) {
|
||||
this.containers[containerIndex].modals.push(modal);
|
||||
return modalIndex;
|
||||
}
|
||||
this.containers.push({
|
||||
modals: [modal],
|
||||
container,
|
||||
restore: null,
|
||||
hiddenSiblings
|
||||
});
|
||||
return modalIndex;
|
||||
}
|
||||
mount(modal, props) {
|
||||
const containerIndex = findIndexOf(this.containers, item => item.modals.indexOf(modal) !== -1);
|
||||
const containerInfo = this.containers[containerIndex];
|
||||
if (!containerInfo.restore) {
|
||||
containerInfo.restore = handleContainer(containerInfo, props);
|
||||
}
|
||||
}
|
||||
remove(modal, ariaHiddenState = true) {
|
||||
const modalIndex = this.modals.indexOf(modal);
|
||||
if (modalIndex === -1) {
|
||||
return modalIndex;
|
||||
}
|
||||
const containerIndex = findIndexOf(this.containers, item => item.modals.indexOf(modal) !== -1);
|
||||
const containerInfo = this.containers[containerIndex];
|
||||
containerInfo.modals.splice(containerInfo.modals.indexOf(modal), 1);
|
||||
this.modals.splice(modalIndex, 1);
|
||||
|
||||
// If that was the last modal in a container, clean up the container.
|
||||
if (containerInfo.modals.length === 0) {
|
||||
// The modal might be closed before it had the chance to be mounted in the DOM.
|
||||
if (containerInfo.restore) {
|
||||
containerInfo.restore();
|
||||
}
|
||||
if (modal.modalRef) {
|
||||
// In case the modal wasn't in the DOM yet.
|
||||
ariaHidden(modal.modalRef, ariaHiddenState);
|
||||
}
|
||||
ariaHiddenSiblings(containerInfo.container, modal.mount, modal.modalRef, containerInfo.hiddenSiblings, false);
|
||||
this.containers.splice(containerIndex, 1);
|
||||
} else {
|
||||
// Otherwise make sure the next top modal is visible to a screen reader.
|
||||
const nextTop = containerInfo.modals[containerInfo.modals.length - 1];
|
||||
// as soon as a modal is adding its modalRef is undefined. it can't set
|
||||
// aria-hidden because the dom element doesn't exist either
|
||||
// when modal was unmounted before modalRef gets null
|
||||
if (nextTop.modalRef) {
|
||||
ariaHidden(nextTop.modalRef, false);
|
||||
}
|
||||
}
|
||||
return modalIndex;
|
||||
}
|
||||
isTopModal(modal) {
|
||||
return this.modals.length > 0 && this.modals[this.modals.length - 1] === modal;
|
||||
}
|
||||
}
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import * as React from 'react';
|
||||
import { unstable_ownerDocument as ownerDocument, unstable_useForkRef as useForkRef, unstable_useEventCallback as useEventCallback, unstable_createChainedFunction as createChainedFunction } from '@mui/utils';
|
||||
import { extractEventHandlers } from '../utils';
|
||||
import { ModalManager, ariaHidden } from './ModalManager';
|
||||
function getContainer(container) {
|
||||
return typeof container === 'function' ? container() : container;
|
||||
}
|
||||
function getHasTransition(children) {
|
||||
return children ? children.props.hasOwnProperty('in') : false;
|
||||
}
|
||||
|
||||
// A modal manager used to track and manage the state of open Modals.
|
||||
// Modals don't open on the server so this won't conflict with concurrent requests.
|
||||
const defaultManager = new ModalManager();
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Modal](https://mui.com/base-ui/react-modal/#hook)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [useModal API](https://mui.com/base-ui/react-modal/hooks-api/#use-modal)
|
||||
*/
|
||||
export function useModal(parameters) {
|
||||
const {
|
||||
container,
|
||||
disableEscapeKeyDown = false,
|
||||
disableScrollLock = false,
|
||||
// @ts-ignore internal logic - Base UI supports the manager as a prop too
|
||||
manager = defaultManager,
|
||||
closeAfterTransition = false,
|
||||
onTransitionEnter,
|
||||
onTransitionExited,
|
||||
children,
|
||||
onClose,
|
||||
open,
|
||||
rootRef
|
||||
} = parameters;
|
||||
|
||||
// @ts-ignore internal logic
|
||||
const modal = React.useRef({});
|
||||
const mountNodeRef = React.useRef(null);
|
||||
const modalRef = React.useRef(null);
|
||||
const handleRef = useForkRef(modalRef, rootRef);
|
||||
const [exited, setExited] = React.useState(!open);
|
||||
const hasTransition = getHasTransition(children);
|
||||
let ariaHiddenProp = true;
|
||||
if (parameters['aria-hidden'] === 'false' || parameters['aria-hidden'] === false) {
|
||||
ariaHiddenProp = false;
|
||||
}
|
||||
const getDoc = () => ownerDocument(mountNodeRef.current);
|
||||
const getModal = () => {
|
||||
modal.current.modalRef = modalRef.current;
|
||||
modal.current.mount = mountNodeRef.current;
|
||||
return modal.current;
|
||||
};
|
||||
const handleMounted = () => {
|
||||
manager.mount(getModal(), {
|
||||
disableScrollLock
|
||||
});
|
||||
|
||||
// Fix a bug on Chrome where the scroll isn't initially 0.
|
||||
if (modalRef.current) {
|
||||
modalRef.current.scrollTop = 0;
|
||||
}
|
||||
};
|
||||
const handleOpen = useEventCallback(() => {
|
||||
const resolvedContainer = getContainer(container) || getDoc().body;
|
||||
manager.add(getModal(), resolvedContainer);
|
||||
|
||||
// The element was already mounted.
|
||||
if (modalRef.current) {
|
||||
handleMounted();
|
||||
}
|
||||
});
|
||||
const isTopModal = React.useCallback(() => manager.isTopModal(getModal()), [manager]);
|
||||
const handlePortalRef = useEventCallback(node => {
|
||||
mountNodeRef.current = node;
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
if (open && isTopModal()) {
|
||||
handleMounted();
|
||||
} else if (modalRef.current) {
|
||||
ariaHidden(modalRef.current, ariaHiddenProp);
|
||||
}
|
||||
});
|
||||
const handleClose = React.useCallback(() => {
|
||||
manager.remove(getModal(), ariaHiddenProp);
|
||||
}, [ariaHiddenProp, manager]);
|
||||
React.useEffect(() => {
|
||||
return () => {
|
||||
handleClose();
|
||||
};
|
||||
}, [handleClose]);
|
||||
React.useEffect(() => {
|
||||
if (open) {
|
||||
handleOpen();
|
||||
} else if (!hasTransition || !closeAfterTransition) {
|
||||
handleClose();
|
||||
}
|
||||
}, [open, handleClose, hasTransition, closeAfterTransition, handleOpen]);
|
||||
const createHandleKeyDown = otherHandlers => event => {
|
||||
var _otherHandlers$onKeyD;
|
||||
(_otherHandlers$onKeyD = otherHandlers.onKeyDown) == null || _otherHandlers$onKeyD.call(otherHandlers, event);
|
||||
|
||||
// The handler doesn't take event.defaultPrevented into account:
|
||||
//
|
||||
// event.preventDefault() is meant to stop default behaviors like
|
||||
// clicking a checkbox to check it, hitting a button to submit a form,
|
||||
// and hitting left arrow to move the cursor in a text input etc.
|
||||
// Only special HTML elements have these default behaviors.
|
||||
if (event.key !== 'Escape' || event.which === 229 ||
|
||||
// Wait until IME is settled.
|
||||
!isTopModal()) {
|
||||
return;
|
||||
}
|
||||
if (!disableEscapeKeyDown) {
|
||||
// Swallow the event, in case someone is listening for the escape key on the body.
|
||||
event.stopPropagation();
|
||||
if (onClose) {
|
||||
onClose(event, 'escapeKeyDown');
|
||||
}
|
||||
}
|
||||
};
|
||||
const createHandleBackdropClick = otherHandlers => event => {
|
||||
var _otherHandlers$onClic;
|
||||
(_otherHandlers$onClic = otherHandlers.onClick) == null || _otherHandlers$onClic.call(otherHandlers, event);
|
||||
if (event.target !== event.currentTarget) {
|
||||
return;
|
||||
}
|
||||
if (onClose) {
|
||||
onClose(event, 'backdropClick');
|
||||
}
|
||||
};
|
||||
const getRootProps = (otherHandlers = {}) => {
|
||||
const propsEventHandlers = extractEventHandlers(parameters);
|
||||
|
||||
// The custom event handlers shouldn't be spread on the root element
|
||||
delete propsEventHandlers.onTransitionEnter;
|
||||
delete propsEventHandlers.onTransitionExited;
|
||||
const externalEventHandlers = _extends({}, propsEventHandlers, otherHandlers);
|
||||
return _extends({
|
||||
role: 'presentation'
|
||||
}, externalEventHandlers, {
|
||||
onKeyDown: createHandleKeyDown(externalEventHandlers),
|
||||
ref: handleRef
|
||||
});
|
||||
};
|
||||
const getBackdropProps = (otherHandlers = {}) => {
|
||||
const externalEventHandlers = otherHandlers;
|
||||
return _extends({
|
||||
'aria-hidden': true
|
||||
}, externalEventHandlers, {
|
||||
onClick: createHandleBackdropClick(externalEventHandlers),
|
||||
open
|
||||
});
|
||||
};
|
||||
const getTransitionProps = () => {
|
||||
const handleEnter = () => {
|
||||
setExited(false);
|
||||
if (onTransitionEnter) {
|
||||
onTransitionEnter();
|
||||
}
|
||||
};
|
||||
const handleExited = () => {
|
||||
setExited(true);
|
||||
if (onTransitionExited) {
|
||||
onTransitionExited();
|
||||
}
|
||||
if (closeAfterTransition) {
|
||||
handleClose();
|
||||
}
|
||||
};
|
||||
return {
|
||||
onEnter: createChainedFunction(handleEnter, children == null ? void 0 : children.props.onEnter),
|
||||
onExited: createChainedFunction(handleExited, children == null ? void 0 : children.props.onExited)
|
||||
};
|
||||
};
|
||||
return {
|
||||
getRootProps,
|
||||
getBackdropProps,
|
||||
getTransitionProps,
|
||||
rootRef: handleRef,
|
||||
portalRef: handlePortalRef,
|
||||
isTopModal,
|
||||
exited,
|
||||
hasTransition
|
||||
};
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import { isHostComponent } from './isHostComponent';
|
||||
|
||||
/**
|
||||
* Type of the ownerState based on the type of an element it applies to.
|
||||
* This resolves to the provided OwnerState for React components and `undefined` for host components.
|
||||
* Falls back to `OwnerState | undefined` when the exact type can't be determined in development time.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Appends the ownerState object to the props, merging with the existing one if necessary.
|
||||
*
|
||||
* @param elementType Type of the element that owns the `existingProps`. If the element is a DOM node or undefined, `ownerState` is not applied.
|
||||
* @param otherProps Props of the element.
|
||||
* @param ownerState
|
||||
*/
|
||||
export function appendOwnerState(elementType, otherProps, ownerState) {
|
||||
if (elementType === undefined || isHostComponent(elementType)) {
|
||||
return otherProps;
|
||||
}
|
||||
return _extends({}, otherProps, {
|
||||
ownerState: _extends({}, otherProps.ownerState, ownerState)
|
||||
});
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Extracts event handlers from a given object.
|
||||
* A prop is considered an event handler if it is a function and its name starts with `on`.
|
||||
*
|
||||
* @param object An object to extract event handlers from.
|
||||
* @param excludeKeys An array of keys to exclude from the returned object.
|
||||
*/
|
||||
export function extractEventHandlers(object, excludeKeys = []) {
|
||||
if (object === undefined) {
|
||||
return {};
|
||||
}
|
||||
const result = {};
|
||||
Object.keys(object).filter(prop => prop.match(/^on[A-Z]/) && typeof object[prop] === 'function' && !excludeKeys.includes(prop)).forEach(prop => {
|
||||
result[prop] = object[prop];
|
||||
});
|
||||
return result;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Determines if a given element is a DOM element name (i.e. not a React component).
|
||||
*/
|
||||
export function isHostComponent(element) {
|
||||
return typeof element === 'string';
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import clsx from 'clsx';
|
||||
import { extractEventHandlers } from './extractEventHandlers';
|
||||
import { omitEventHandlers } from './omitEventHandlers';
|
||||
/**
|
||||
* Merges the slot component internal props (usually coming from a hook)
|
||||
* with the externally provided ones.
|
||||
*
|
||||
* The merge order is (the latter overrides the former):
|
||||
* 1. The internal props (specified as a getter function to work with get*Props hook result)
|
||||
* 2. Additional props (specified internally on a Base UI component)
|
||||
* 3. External props specified on the owner component. These should only be used on a root slot.
|
||||
* 4. External props specified in the `slotProps.*` prop.
|
||||
* 5. The `className` prop - combined from all the above.
|
||||
* @param parameters
|
||||
* @returns
|
||||
*/
|
||||
export function mergeSlotProps(parameters) {
|
||||
const {
|
||||
getSlotProps,
|
||||
additionalProps,
|
||||
externalSlotProps,
|
||||
externalForwardedProps,
|
||||
className
|
||||
} = parameters;
|
||||
if (!getSlotProps) {
|
||||
// The simpler case - getSlotProps is not defined, so no internal event handlers are defined,
|
||||
// so we can simply merge all the props without having to worry about extracting event handlers.
|
||||
const joinedClasses = clsx(additionalProps == null ? void 0 : additionalProps.className, className, externalForwardedProps == null ? void 0 : externalForwardedProps.className, externalSlotProps == null ? void 0 : externalSlotProps.className);
|
||||
const mergedStyle = _extends({}, additionalProps == null ? void 0 : additionalProps.style, externalForwardedProps == null ? void 0 : externalForwardedProps.style, externalSlotProps == null ? void 0 : externalSlotProps.style);
|
||||
const props = _extends({}, additionalProps, externalForwardedProps, externalSlotProps);
|
||||
if (joinedClasses.length > 0) {
|
||||
props.className = joinedClasses;
|
||||
}
|
||||
if (Object.keys(mergedStyle).length > 0) {
|
||||
props.style = mergedStyle;
|
||||
}
|
||||
return {
|
||||
props,
|
||||
internalRef: undefined
|
||||
};
|
||||
}
|
||||
|
||||
// In this case, getSlotProps is responsible for calling the external event handlers.
|
||||
// We don't need to include them in the merged props because of this.
|
||||
|
||||
const eventHandlers = extractEventHandlers(_extends({}, externalForwardedProps, externalSlotProps));
|
||||
const componentsPropsWithoutEventHandlers = omitEventHandlers(externalSlotProps);
|
||||
const otherPropsWithoutEventHandlers = omitEventHandlers(externalForwardedProps);
|
||||
const internalSlotProps = getSlotProps(eventHandlers);
|
||||
|
||||
// The order of classes is important here.
|
||||
// Emotion (that we use in libraries consuming Base UI) depends on this order
|
||||
// to properly override style. It requires the most important classes to be last
|
||||
// (see https://github.com/mui/material-ui/pull/33205) for the related discussion.
|
||||
const joinedClasses = clsx(internalSlotProps == null ? void 0 : internalSlotProps.className, additionalProps == null ? void 0 : additionalProps.className, className, externalForwardedProps == null ? void 0 : externalForwardedProps.className, externalSlotProps == null ? void 0 : externalSlotProps.className);
|
||||
const mergedStyle = _extends({}, internalSlotProps == null ? void 0 : internalSlotProps.style, additionalProps == null ? void 0 : additionalProps.style, externalForwardedProps == null ? void 0 : externalForwardedProps.style, externalSlotProps == null ? void 0 : externalSlotProps.style);
|
||||
const props = _extends({}, internalSlotProps, additionalProps, otherPropsWithoutEventHandlers, componentsPropsWithoutEventHandlers);
|
||||
if (joinedClasses.length > 0) {
|
||||
props.className = joinedClasses;
|
||||
}
|
||||
if (Object.keys(mergedStyle).length > 0) {
|
||||
props.style = mergedStyle;
|
||||
}
|
||||
return {
|
||||
props,
|
||||
internalRef: internalSlotProps.ref
|
||||
};
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Removes event handlers from the given object.
|
||||
* A field is considered an event handler if it is a function with a name beginning with `on`.
|
||||
*
|
||||
* @param object Object to remove event handlers from.
|
||||
* @returns Object with event handlers removed.
|
||||
*/
|
||||
export function omitEventHandlers(object) {
|
||||
if (object === undefined) {
|
||||
return {};
|
||||
}
|
||||
const result = {};
|
||||
Object.keys(object).filter(prop => !(prop.match(/^on[A-Z]/) && typeof object[prop] === 'function')).forEach(prop => {
|
||||
result[prop] = object[prop];
|
||||
});
|
||||
return result;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* If `componentProps` is a function, calls it with the provided `ownerState`.
|
||||
* Otherwise, just returns `componentProps`.
|
||||
*/
|
||||
export function resolveComponentProps(componentProps, ownerState, slotState) {
|
||||
if (typeof componentProps === 'function') {
|
||||
return componentProps(ownerState, slotState);
|
||||
}
|
||||
return componentProps;
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["elementType", "externalSlotProps", "ownerState", "skipResolvingSlotProps"];
|
||||
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
||||
import { appendOwnerState } from './appendOwnerState';
|
||||
import { mergeSlotProps } from './mergeSlotProps';
|
||||
import { resolveComponentProps } from './resolveComponentProps';
|
||||
/**
|
||||
* @ignore - do not document.
|
||||
* Builds the props to be passed into the slot of an unstyled component.
|
||||
* It merges the internal props of the component with the ones supplied by the user, allowing to customize the behavior.
|
||||
* If the slot component is not a host component, it also merges in the `ownerState`.
|
||||
*
|
||||
* @param parameters.getSlotProps - A function that returns the props to be passed to the slot component.
|
||||
*/
|
||||
export function useSlotProps(parameters) {
|
||||
var _parameters$additiona;
|
||||
const {
|
||||
elementType,
|
||||
externalSlotProps,
|
||||
ownerState,
|
||||
skipResolvingSlotProps = false
|
||||
} = parameters,
|
||||
rest = _objectWithoutPropertiesLoose(parameters, _excluded);
|
||||
const resolvedComponentsProps = skipResolvingSlotProps ? {} : resolveComponentProps(externalSlotProps, ownerState);
|
||||
const {
|
||||
props: mergedProps,
|
||||
internalRef
|
||||
} = mergeSlotProps(_extends({}, rest, {
|
||||
externalSlotProps: resolvedComponentsProps
|
||||
}));
|
||||
const ref = useForkRef(internalRef, resolvedComponentsProps == null ? void 0 : resolvedComponentsProps.ref, (_parameters$additiona = parameters.additionalProps) == null ? void 0 : _parameters$additiona.ref);
|
||||
const props = appendOwnerState(elementType, _extends({}, mergedProps, {
|
||||
ref
|
||||
}), ownerState);
|
||||
return props;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"
|
||||
}), 'Add');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M6.23 20.23 8 22l10-10L8 2 6.23 3.77 14.46 12z"
|
||||
}), 'ArrowForwardIos');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M16.01 11H4v2h12.01v3L20 12l-3.99-4z"
|
||||
}), 'ArrowRightAlt');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"
|
||||
}), 'ChevronRight');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
|
||||
}), 'Close');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"
|
||||
}), 'KeyboardArrowDown');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M11.07 12.85c.77-1.39 2.25-2.21 3.11-3.44.91-1.29.4-3.7-2.18-3.7-1.69 0-2.52 1.28-2.87 2.34L6.54 6.96C7.25 4.83 9.18 3 11.99 3c2.35 0 3.96 1.07 4.78 2.41.7 1.15 1.11 3.3.03 4.9-1.2 1.77-2.35 2.31-2.97 3.45-.25.46-.35.76-.35 2.24h-2.89c-.01-.78-.13-2.05.48-3.15M14 20c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2"
|
||||
}), 'QuestionMark');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M19 13H5v-2h14z"
|
||||
}), 'Remove');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"
|
||||
}), 'Settings');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M19.43 12.98c.04-.32.07-.64.07-.98 0-.34-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.09-.16-.26-.25-.44-.25-.06 0-.12.01-.17.03l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.06-.02-.12-.03-.18-.03-.17 0-.34.09-.43.25l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98 0 .33.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.09.16.26.25.44.25.06 0 .12-.01.17-.03l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.06.02.12.03.18.03.17 0 .34-.09.43-.25l2-3.46c.12-.22.07-.49-.12-.64zm-1.98-1.71c.04.31.05.52.05.73 0 .21-.02.43-.05.73l-.14 1.13.89.7 1.08.84-.7 1.21-1.27-.51-1.04-.42-.9.68c-.43.32-.84.56-1.25.73l-1.06.43-.16 1.13-.2 1.35h-1.4l-.19-1.35-.16-1.13-1.06-.43c-.43-.18-.83-.41-1.23-.71l-.91-.7-1.06.43-1.27.51-.7-1.21 1.08-.84.89-.7-.14-1.13c-.03-.31-.05-.54-.05-.74s.02-.43.05-.73l.14-1.13-.89-.7-1.08-.84.7-1.21 1.27.51 1.04.42.9-.68c.43-.32.84-.56 1.25-.73l1.06-.43.16-1.13.2-1.35h1.39l.19 1.35.16 1.13 1.06.43c.43.18.83.41 1.23.71l.91.7 1.06-.43 1.27-.51.7 1.21-1.07.85-.89.7zM12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4m0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2"
|
||||
}), 'SettingsOutlined');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11z"
|
||||
}), 'Videocam');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
var _default = exports.default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
||||
d: "M3 9v6h4l5 5V4L7 9zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02M14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77"
|
||||
}), 'VolumeUp');
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import createSvgIcon from './utils/createSvgIcon';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
export default createSvgIcon( /*#__PURE__*/_jsx("path", {
|
||||
d: "M11.29 8.71 6.7 13.3c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 10.83l3.88 3.88c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L12.7 8.71c-.38-.39-1.02-.39-1.41 0"
|
||||
}), 'ExpandLessRounded');
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import createSvgIcon from './utils/createSvgIcon';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
export default createSvgIcon( /*#__PURE__*/_jsx("path", {
|
||||
d: "M15.88 9.29 12 13.17 8.12 9.29a.9959.9959 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0"
|
||||
}), 'ExpandMoreRounded');
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import createSvgIcon from './utils/createSvgIcon';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
export default createSvgIcon( /*#__PURE__*/_jsx("path", {
|
||||
d: "M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"
|
||||
}), 'RestartAlt');
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
'use client';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _utils.createSvgIcon;
|
||||
}
|
||||
});
|
||||
var _utils = require("@mui/material/utils");
|
||||
+348
@@ -0,0 +1,348 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["action", "children", "className", "closeText", "color", "components", "componentsProps", "icon", "iconMapping", "onClose", "role", "severity", "slotProps", "slots", "variant"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import { darken, lighten } from '@mui/system/colorManipulator';
|
||||
import { styled, createUseThemeProps } from '../zero-styled';
|
||||
import useSlot from '../utils/useSlot';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import Paper from '../Paper';
|
||||
import alertClasses, { getAlertUtilityClass } from './alertClasses';
|
||||
import IconButton from '../IconButton';
|
||||
import SuccessOutlinedIcon from '../internal/svg-icons/SuccessOutlined';
|
||||
import ReportProblemOutlinedIcon from '../internal/svg-icons/ReportProblemOutlined';
|
||||
import ErrorOutlineIcon from '../internal/svg-icons/ErrorOutline';
|
||||
import InfoOutlinedIcon from '../internal/svg-icons/InfoOutlined';
|
||||
import CloseIcon from '../internal/svg-icons/Close';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
const useThemeProps = createUseThemeProps('MuiAlert');
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
variant,
|
||||
color,
|
||||
severity,
|
||||
classes
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', `color${capitalize(color || severity)}`, `${variant}${capitalize(color || severity)}`, `${variant}`],
|
||||
icon: ['icon'],
|
||||
message: ['message'],
|
||||
action: ['action']
|
||||
};
|
||||
return composeClasses(slots, getAlertUtilityClass, classes);
|
||||
};
|
||||
const AlertRoot = styled(Paper, {
|
||||
name: 'MuiAlert',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, styles[ownerState.variant], styles[`${ownerState.variant}${capitalize(ownerState.color || ownerState.severity)}`]];
|
||||
}
|
||||
})(({
|
||||
theme
|
||||
}) => {
|
||||
const getColor = theme.palette.mode === 'light' ? darken : lighten;
|
||||
const getBackgroundColor = theme.palette.mode === 'light' ? lighten : darken;
|
||||
return _extends({}, theme.typography.body2, {
|
||||
backgroundColor: 'transparent',
|
||||
display: 'flex',
|
||||
padding: '6px 16px',
|
||||
variants: [...Object.entries(theme.palette).filter(([, value]) => value.main && value.light).map(([color]) => ({
|
||||
props: {
|
||||
colorSeverity: color,
|
||||
variant: 'standard'
|
||||
},
|
||||
style: {
|
||||
color: theme.vars ? theme.vars.palette.Alert[`${color}Color`] : getColor(theme.palette[color].light, 0.6),
|
||||
backgroundColor: theme.vars ? theme.vars.palette.Alert[`${color}StandardBg`] : getBackgroundColor(theme.palette[color].light, 0.9),
|
||||
[`& .${alertClasses.icon}`]: theme.vars ? {
|
||||
color: theme.vars.palette.Alert[`${color}IconColor`]
|
||||
} : {
|
||||
color: theme.palette[color].main
|
||||
}
|
||||
}
|
||||
})), ...Object.entries(theme.palette).filter(([, value]) => value.main && value.light).map(([color]) => ({
|
||||
props: {
|
||||
colorSeverity: color,
|
||||
variant: 'outlined'
|
||||
},
|
||||
style: {
|
||||
color: theme.vars ? theme.vars.palette.Alert[`${color}Color`] : getColor(theme.palette[color].light, 0.6),
|
||||
border: `1px solid ${(theme.vars || theme).palette[color].light}`,
|
||||
[`& .${alertClasses.icon}`]: theme.vars ? {
|
||||
color: theme.vars.palette.Alert[`${color}IconColor`]
|
||||
} : {
|
||||
color: theme.palette[color].main
|
||||
}
|
||||
}
|
||||
})), ...Object.entries(theme.palette).filter(([, value]) => value.main && value.dark).map(([color]) => ({
|
||||
props: {
|
||||
colorSeverity: color,
|
||||
variant: 'filled'
|
||||
},
|
||||
style: _extends({
|
||||
fontWeight: theme.typography.fontWeightMedium
|
||||
}, theme.vars ? {
|
||||
color: theme.vars.palette.Alert[`${color}FilledColor`],
|
||||
backgroundColor: theme.vars.palette.Alert[`${color}FilledBg`]
|
||||
} : {
|
||||
backgroundColor: theme.palette.mode === 'dark' ? theme.palette[color].dark : theme.palette[color].main,
|
||||
color: theme.palette.getContrastText(theme.palette[color].main)
|
||||
})
|
||||
}))]
|
||||
});
|
||||
});
|
||||
const AlertIcon = styled('div', {
|
||||
name: 'MuiAlert',
|
||||
slot: 'Icon',
|
||||
overridesResolver: (props, styles) => styles.icon
|
||||
})({
|
||||
marginRight: 12,
|
||||
padding: '7px 0',
|
||||
display: 'flex',
|
||||
fontSize: 22,
|
||||
opacity: 0.9
|
||||
});
|
||||
const AlertMessage = styled('div', {
|
||||
name: 'MuiAlert',
|
||||
slot: 'Message',
|
||||
overridesResolver: (props, styles) => styles.message
|
||||
})({
|
||||
padding: '8px 0',
|
||||
minWidth: 0,
|
||||
overflow: 'auto'
|
||||
});
|
||||
const AlertAction = styled('div', {
|
||||
name: 'MuiAlert',
|
||||
slot: 'Action',
|
||||
overridesResolver: (props, styles) => styles.action
|
||||
})({
|
||||
display: 'flex',
|
||||
alignItems: 'flex-start',
|
||||
padding: '4px 0 0 16px',
|
||||
marginLeft: 'auto',
|
||||
marginRight: -8
|
||||
});
|
||||
const defaultIconMapping = {
|
||||
success: /*#__PURE__*/_jsx(SuccessOutlinedIcon, {
|
||||
fontSize: "inherit"
|
||||
}),
|
||||
warning: /*#__PURE__*/_jsx(ReportProblemOutlinedIcon, {
|
||||
fontSize: "inherit"
|
||||
}),
|
||||
error: /*#__PURE__*/_jsx(ErrorOutlineIcon, {
|
||||
fontSize: "inherit"
|
||||
}),
|
||||
info: /*#__PURE__*/_jsx(InfoOutlinedIcon, {
|
||||
fontSize: "inherit"
|
||||
})
|
||||
};
|
||||
const Alert = /*#__PURE__*/React.forwardRef(function Alert(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiAlert'
|
||||
});
|
||||
const {
|
||||
action,
|
||||
children,
|
||||
className,
|
||||
closeText = 'Close',
|
||||
color,
|
||||
components = {},
|
||||
componentsProps = {},
|
||||
icon,
|
||||
iconMapping = defaultIconMapping,
|
||||
onClose,
|
||||
role = 'alert',
|
||||
severity = 'success',
|
||||
slotProps = {},
|
||||
slots = {},
|
||||
variant = 'standard'
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
color,
|
||||
severity,
|
||||
variant,
|
||||
colorSeverity: color || severity
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const externalForwardedProps = {
|
||||
slots: _extends({
|
||||
closeButton: components.CloseButton,
|
||||
closeIcon: components.CloseIcon
|
||||
}, slots),
|
||||
slotProps: _extends({}, componentsProps, slotProps)
|
||||
};
|
||||
const [CloseButtonSlot, closeButtonProps] = useSlot('closeButton', {
|
||||
elementType: IconButton,
|
||||
externalForwardedProps,
|
||||
ownerState
|
||||
});
|
||||
const [CloseIconSlot, closeIconProps] = useSlot('closeIcon', {
|
||||
elementType: CloseIcon,
|
||||
externalForwardedProps,
|
||||
ownerState
|
||||
});
|
||||
return /*#__PURE__*/_jsxs(AlertRoot, _extends({
|
||||
role: role,
|
||||
elevation: 0,
|
||||
ownerState: ownerState,
|
||||
className: clsx(classes.root, className),
|
||||
ref: ref
|
||||
}, other, {
|
||||
children: [icon !== false ? /*#__PURE__*/_jsx(AlertIcon, {
|
||||
ownerState: ownerState,
|
||||
className: classes.icon,
|
||||
children: icon || iconMapping[severity] || defaultIconMapping[severity]
|
||||
}) : null, /*#__PURE__*/_jsx(AlertMessage, {
|
||||
ownerState: ownerState,
|
||||
className: classes.message,
|
||||
children: children
|
||||
}), action != null ? /*#__PURE__*/_jsx(AlertAction, {
|
||||
ownerState: ownerState,
|
||||
className: classes.action,
|
||||
children: action
|
||||
}) : null, action == null && onClose ? /*#__PURE__*/_jsx(AlertAction, {
|
||||
ownerState: ownerState,
|
||||
className: classes.action,
|
||||
children: /*#__PURE__*/_jsx(CloseButtonSlot, _extends({
|
||||
size: "small",
|
||||
"aria-label": closeText,
|
||||
title: closeText,
|
||||
color: "inherit",
|
||||
onClick: onClose
|
||||
}, closeButtonProps, {
|
||||
children: /*#__PURE__*/_jsx(CloseIconSlot, _extends({
|
||||
fontSize: "small"
|
||||
}, closeIconProps))
|
||||
}))
|
||||
}) : null]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Alert.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The action to display. It renders after the message, at the end of the alert.
|
||||
*/
|
||||
action: PropTypes.node,
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* Override the default label for the *close popup* icon button.
|
||||
*
|
||||
* For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
|
||||
* @default 'Close'
|
||||
*/
|
||||
closeText: PropTypes.string,
|
||||
/**
|
||||
* The color of the component. Unless provided, the value is taken from the `severity` prop.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'success', 'warning']), PropTypes.string]),
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
*
|
||||
* @deprecated use the `slots` prop instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
components: PropTypes.shape({
|
||||
CloseButton: PropTypes.elementType,
|
||||
CloseIcon: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The extra props for the slot components.
|
||||
* You can override the existing props or add new ones.
|
||||
*
|
||||
* @deprecated use the `slotProps` prop instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
componentsProps: PropTypes.shape({
|
||||
closeButton: PropTypes.object,
|
||||
closeIcon: PropTypes.object
|
||||
}),
|
||||
/**
|
||||
* Override the icon displayed before the children.
|
||||
* Unless provided, the icon is mapped to the value of the `severity` prop.
|
||||
* Set to `false` to remove the `icon`.
|
||||
*/
|
||||
icon: PropTypes.node,
|
||||
/**
|
||||
* The component maps the `severity` prop to a range of different icons,
|
||||
* for instance success to `<SuccessOutlined>`.
|
||||
* If you wish to change this mapping, you can provide your own.
|
||||
* Alternatively, you can use the `icon` prop to override the icon displayed.
|
||||
*/
|
||||
iconMapping: PropTypes.shape({
|
||||
error: PropTypes.node,
|
||||
info: PropTypes.node,
|
||||
success: PropTypes.node,
|
||||
warning: PropTypes.node
|
||||
}),
|
||||
/**
|
||||
* Callback fired when the component requests to be closed.
|
||||
* When provided and no `action` prop is set, a close icon button is displayed that triggers the callback when clicked.
|
||||
* @param {React.SyntheticEvent} event The event source of the callback.
|
||||
*/
|
||||
onClose: PropTypes.func,
|
||||
/**
|
||||
* The ARIA role attribute of the element.
|
||||
* @default 'alert'
|
||||
*/
|
||||
role: PropTypes.string,
|
||||
/**
|
||||
* The severity of the alert. This defines the color and icon used.
|
||||
* @default 'success'
|
||||
*/
|
||||
severity: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'success', 'warning']), PropTypes.string]),
|
||||
/**
|
||||
* The props used for each slot inside.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
closeButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
closeIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
closeButton: PropTypes.elementType,
|
||||
closeIcon: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* The variant to use.
|
||||
* @default 'standard'
|
||||
*/
|
||||
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['filled', 'outlined', 'standard']), PropTypes.string])
|
||||
} : void 0;
|
||||
export default Alert;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getAlertUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiAlert', slot);
|
||||
}
|
||||
const alertClasses = generateUtilityClasses('MuiAlert', ['root', 'action', 'icon', 'message', 'filled', 'colorSuccess', 'colorInfo', 'colorWarning', 'colorError', 'filledSuccess', 'filledInfo', 'filledWarning', 'filledError', 'outlined', 'outlinedSuccess', 'outlinedInfo', 'outlinedWarning', 'outlinedError', 'standard', 'standardSuccess', 'standardInfo', 'standardWarning', 'standardError']);
|
||||
export default alertClasses;
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["className", "color", "enableColorOnDark", "position"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import Paper from '../Paper';
|
||||
import { getAppBarUtilityClass } from './appBarClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
color,
|
||||
position,
|
||||
classes
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', `color${capitalize(color)}`, `position${capitalize(position)}`]
|
||||
};
|
||||
return composeClasses(slots, getAppBarUtilityClass, classes);
|
||||
};
|
||||
|
||||
// var2 is the fallback.
|
||||
// Ex. var1: 'var(--a)', var2: 'var(--b)'; return: 'var(--a, var(--b))'
|
||||
const joinVars = (var1, var2) => var1 ? `${var1 == null ? void 0 : var1.replace(')', '')}, ${var2})` : var2;
|
||||
const AppBarRoot = styled(Paper, {
|
||||
name: 'MuiAppBar',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, styles[`position${capitalize(ownerState.position)}`], styles[`color${capitalize(ownerState.color)}`]];
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => {
|
||||
const backgroundColorDefault = theme.palette.mode === 'light' ? theme.palette.grey[100] : theme.palette.grey[900];
|
||||
return _extends({
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
width: '100%',
|
||||
boxSizing: 'border-box',
|
||||
// Prevent padding issue with the Modal and fixed positioned AppBar.
|
||||
flexShrink: 0
|
||||
}, ownerState.position === 'fixed' && {
|
||||
position: 'fixed',
|
||||
zIndex: (theme.vars || theme).zIndex.appBar,
|
||||
top: 0,
|
||||
left: 'auto',
|
||||
right: 0,
|
||||
'@media print': {
|
||||
// Prevent the app bar to be visible on each printed page.
|
||||
position: 'absolute'
|
||||
}
|
||||
}, ownerState.position === 'absolute' && {
|
||||
position: 'absolute',
|
||||
zIndex: (theme.vars || theme).zIndex.appBar,
|
||||
top: 0,
|
||||
left: 'auto',
|
||||
right: 0
|
||||
}, ownerState.position === 'sticky' && {
|
||||
// ⚠️ sticky is not supported by IE11.
|
||||
position: 'sticky',
|
||||
zIndex: (theme.vars || theme).zIndex.appBar,
|
||||
top: 0,
|
||||
left: 'auto',
|
||||
right: 0
|
||||
}, ownerState.position === 'static' && {
|
||||
position: 'static'
|
||||
}, ownerState.position === 'relative' && {
|
||||
position: 'relative'
|
||||
}, !theme.vars && _extends({}, ownerState.color === 'default' && {
|
||||
backgroundColor: backgroundColorDefault,
|
||||
color: theme.palette.getContrastText(backgroundColorDefault)
|
||||
}, ownerState.color && ownerState.color !== 'default' && ownerState.color !== 'inherit' && ownerState.color !== 'transparent' && {
|
||||
backgroundColor: theme.palette[ownerState.color].main,
|
||||
color: theme.palette[ownerState.color].contrastText
|
||||
}, ownerState.color === 'inherit' && {
|
||||
color: 'inherit'
|
||||
}, theme.palette.mode === 'dark' && !ownerState.enableColorOnDark && {
|
||||
backgroundColor: null,
|
||||
color: null
|
||||
}, ownerState.color === 'transparent' && _extends({
|
||||
backgroundColor: 'transparent',
|
||||
color: 'inherit'
|
||||
}, theme.palette.mode === 'dark' && {
|
||||
backgroundImage: 'none'
|
||||
})), theme.vars && _extends({}, ownerState.color === 'default' && {
|
||||
'--AppBar-background': ownerState.enableColorOnDark ? theme.vars.palette.AppBar.defaultBg : joinVars(theme.vars.palette.AppBar.darkBg, theme.vars.palette.AppBar.defaultBg),
|
||||
'--AppBar-color': ownerState.enableColorOnDark ? theme.vars.palette.text.primary : joinVars(theme.vars.palette.AppBar.darkColor, theme.vars.palette.text.primary)
|
||||
}, ownerState.color && !ownerState.color.match(/^(default|inherit|transparent)$/) && {
|
||||
'--AppBar-background': ownerState.enableColorOnDark ? theme.vars.palette[ownerState.color].main : joinVars(theme.vars.palette.AppBar.darkBg, theme.vars.palette[ownerState.color].main),
|
||||
'--AppBar-color': ownerState.enableColorOnDark ? theme.vars.palette[ownerState.color].contrastText : joinVars(theme.vars.palette.AppBar.darkColor, theme.vars.palette[ownerState.color].contrastText)
|
||||
}, {
|
||||
backgroundColor: 'var(--AppBar-background)',
|
||||
color: ownerState.color === 'inherit' ? 'inherit' : 'var(--AppBar-color)'
|
||||
}, ownerState.color === 'transparent' && {
|
||||
backgroundImage: 'none',
|
||||
backgroundColor: 'transparent',
|
||||
color: 'inherit'
|
||||
}));
|
||||
});
|
||||
const AppBar = /*#__PURE__*/React.forwardRef(function AppBar(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiAppBar'
|
||||
});
|
||||
const {
|
||||
className,
|
||||
color = 'primary',
|
||||
enableColorOnDark = false,
|
||||
position = 'fixed'
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
color,
|
||||
position,
|
||||
enableColorOnDark
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(AppBarRoot, _extends({
|
||||
square: true,
|
||||
component: "header",
|
||||
ownerState: ownerState,
|
||||
elevation: 4,
|
||||
className: clsx(classes.root, className, position === 'fixed' && 'mui-fixed'),
|
||||
ref: ref
|
||||
}, other));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? AppBar.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
* @default 'primary'
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['default', 'inherit', 'primary', 'secondary', 'transparent', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
||||
/**
|
||||
* If true, the `color` prop is applied in dark mode.
|
||||
* @default false
|
||||
*/
|
||||
enableColorOnDark: PropTypes.bool,
|
||||
/**
|
||||
* The positioning type. The behavior of the different options is described
|
||||
* [in the MDN web docs](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Positioning).
|
||||
* Note: `sticky` is not universally supported and will fall back to `static` when unavailable.
|
||||
* @default 'fixed'
|
||||
*/
|
||||
position: PropTypes.oneOf(['absolute', 'fixed', 'relative', 'static', 'sticky']),
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default AppBar;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getAppBarUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiAppBar', slot);
|
||||
}
|
||||
const appBarClasses = generateUtilityClasses('MuiAppBar', ['root', 'positionFixed', 'positionAbsolute', 'positionSticky', 'positionStatic', 'positionRelative', 'colorDefault', 'colorPrimary', 'colorSecondary', 'colorInherit', 'colorTransparent', 'colorError', 'colorInfo', 'colorSuccess', 'colorWarning']);
|
||||
export default appBarClasses;
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["alt", "children", "className", "component", "slots", "slotProps", "imgProps", "sizes", "src", "srcSet", "variant"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import { styled, createUseThemeProps } from '../zero-styled';
|
||||
import Person from '../internal/svg-icons/Person';
|
||||
import { getAvatarUtilityClass } from './avatarClasses';
|
||||
import useSlot from '../utils/useSlot';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useThemeProps = createUseThemeProps('MuiAvatar');
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
variant,
|
||||
colorDefault
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', variant, colorDefault && 'colorDefault'],
|
||||
img: ['img'],
|
||||
fallback: ['fallback']
|
||||
};
|
||||
return composeClasses(slots, getAvatarUtilityClass, classes);
|
||||
};
|
||||
const AvatarRoot = styled('div', {
|
||||
name: 'MuiAvatar',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, styles[ownerState.variant], ownerState.colorDefault && styles.colorDefault];
|
||||
}
|
||||
})(({
|
||||
theme
|
||||
}) => ({
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
flexShrink: 0,
|
||||
width: 40,
|
||||
height: 40,
|
||||
fontFamily: theme.typography.fontFamily,
|
||||
fontSize: theme.typography.pxToRem(20),
|
||||
lineHeight: 1,
|
||||
borderRadius: '50%',
|
||||
overflow: 'hidden',
|
||||
userSelect: 'none',
|
||||
variants: [{
|
||||
props: {
|
||||
variant: 'rounded'
|
||||
},
|
||||
style: {
|
||||
borderRadius: (theme.vars || theme).shape.borderRadius
|
||||
}
|
||||
}, {
|
||||
props: {
|
||||
variant: 'square'
|
||||
},
|
||||
style: {
|
||||
borderRadius: 0
|
||||
}
|
||||
}, {
|
||||
props: {
|
||||
colorDefault: true
|
||||
},
|
||||
style: _extends({
|
||||
color: (theme.vars || theme).palette.background.default
|
||||
}, theme.vars ? {
|
||||
backgroundColor: theme.vars.palette.Avatar.defaultBg
|
||||
} : _extends({
|
||||
backgroundColor: theme.palette.grey[400]
|
||||
}, theme.applyStyles('dark', {
|
||||
backgroundColor: theme.palette.grey[600]
|
||||
})))
|
||||
}]
|
||||
}));
|
||||
const AvatarImg = styled('img', {
|
||||
name: 'MuiAvatar',
|
||||
slot: 'Img',
|
||||
overridesResolver: (props, styles) => styles.img
|
||||
})({
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
textAlign: 'center',
|
||||
// Handle non-square image. The property isn't supported by IE11.
|
||||
objectFit: 'cover',
|
||||
// Hide alt text.
|
||||
color: 'transparent',
|
||||
// Hide the image broken icon, only works on Chrome.
|
||||
textIndent: 10000
|
||||
});
|
||||
const AvatarFallback = styled(Person, {
|
||||
name: 'MuiAvatar',
|
||||
slot: 'Fallback',
|
||||
overridesResolver: (props, styles) => styles.fallback
|
||||
})({
|
||||
width: '75%',
|
||||
height: '75%'
|
||||
});
|
||||
function useLoaded({
|
||||
crossOrigin,
|
||||
referrerPolicy,
|
||||
src,
|
||||
srcSet
|
||||
}) {
|
||||
const [loaded, setLoaded] = React.useState(false);
|
||||
React.useEffect(() => {
|
||||
if (!src && !srcSet) {
|
||||
return undefined;
|
||||
}
|
||||
setLoaded(false);
|
||||
let active = true;
|
||||
const image = new Image();
|
||||
image.onload = () => {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
setLoaded('loaded');
|
||||
};
|
||||
image.onerror = () => {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
setLoaded('error');
|
||||
};
|
||||
image.crossOrigin = crossOrigin;
|
||||
image.referrerPolicy = referrerPolicy;
|
||||
image.src = src;
|
||||
if (srcSet) {
|
||||
image.srcset = srcSet;
|
||||
}
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [crossOrigin, referrerPolicy, src, srcSet]);
|
||||
return loaded;
|
||||
}
|
||||
const Avatar = /*#__PURE__*/React.forwardRef(function Avatar(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiAvatar'
|
||||
});
|
||||
const {
|
||||
alt,
|
||||
children: childrenProp,
|
||||
className,
|
||||
component = 'div',
|
||||
slots = {},
|
||||
slotProps = {},
|
||||
imgProps,
|
||||
sizes,
|
||||
src,
|
||||
srcSet,
|
||||
variant = 'circular'
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
let children = null;
|
||||
|
||||
// Use a hook instead of onError on the img element to support server-side rendering.
|
||||
const loaded = useLoaded(_extends({}, imgProps, {
|
||||
src,
|
||||
srcSet
|
||||
}));
|
||||
const hasImg = src || srcSet;
|
||||
const hasImgNotFailing = hasImg && loaded !== 'error';
|
||||
const ownerState = _extends({}, props, {
|
||||
colorDefault: !hasImgNotFailing,
|
||||
component,
|
||||
variant
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const [ImgSlot, imgSlotProps] = useSlot('img', {
|
||||
className: classes.img,
|
||||
elementType: AvatarImg,
|
||||
externalForwardedProps: {
|
||||
slots,
|
||||
slotProps: {
|
||||
img: _extends({}, imgProps, slotProps.img)
|
||||
}
|
||||
},
|
||||
additionalProps: {
|
||||
alt,
|
||||
src,
|
||||
srcSet,
|
||||
sizes
|
||||
},
|
||||
ownerState
|
||||
});
|
||||
if (hasImgNotFailing) {
|
||||
children = /*#__PURE__*/_jsx(ImgSlot, _extends({}, imgSlotProps));
|
||||
// We only render valid children, non valid children are rendered with a fallback
|
||||
// We consider that invalid children are all falsy values, except 0, which is valid.
|
||||
} else if (!!childrenProp || childrenProp === 0) {
|
||||
children = childrenProp;
|
||||
} else if (hasImg && alt) {
|
||||
children = alt[0];
|
||||
} else {
|
||||
children = /*#__PURE__*/_jsx(AvatarFallback, {
|
||||
ownerState: ownerState,
|
||||
className: classes.fallback
|
||||
});
|
||||
}
|
||||
return /*#__PURE__*/_jsx(AvatarRoot, _extends({
|
||||
as: component,
|
||||
ownerState: ownerState,
|
||||
className: clsx(classes.root, className),
|
||||
ref: ref
|
||||
}, other, {
|
||||
children: children
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Avatar.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* Used in combination with `src` or `srcSet` to
|
||||
* provide an alt attribute for the rendered `img` element.
|
||||
*/
|
||||
alt: PropTypes.string,
|
||||
/**
|
||||
* Used to render icon or text elements inside the Avatar if `src` is not set.
|
||||
* This can be an element, or just a string.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: PropTypes.elementType,
|
||||
/**
|
||||
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes) applied to the `img` element if the component is used to display an image.
|
||||
* It can be used to listen for the loading error event.
|
||||
* @deprecated Use `slotProps.img` instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
|
||||
*/
|
||||
imgProps: PropTypes.object,
|
||||
/**
|
||||
* The `sizes` attribute for the `img` element.
|
||||
*/
|
||||
sizes: PropTypes.string,
|
||||
/**
|
||||
* The props used for each slot inside.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
img: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
img: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The `src` attribute for the `img` element.
|
||||
*/
|
||||
src: PropTypes.string,
|
||||
/**
|
||||
* The `srcSet` attribute for the `img` element.
|
||||
* Use this attribute for responsive image display.
|
||||
*/
|
||||
srcSet: PropTypes.string,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* The shape of the avatar.
|
||||
* @default 'circular'
|
||||
*/
|
||||
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['circular', 'rounded', 'square']), PropTypes.string])
|
||||
} : void 0;
|
||||
export default Avatar;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getAvatarUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiAvatar', slot);
|
||||
}
|
||||
const avatarClasses = generateUtilityClasses('MuiAvatar', ['root', 'colorDefault', 'circular', 'rounded', 'square', 'img', 'fallback']);
|
||||
export default avatarClasses;
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["children", "className", "component", "components", "componentsProps", "invisible", "open", "slotProps", "slots", "TransitionComponent", "transitionDuration"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import Fade from '../Fade';
|
||||
import { getBackdropUtilityClass } from './backdropClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
invisible
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', invisible && 'invisible']
|
||||
};
|
||||
return composeClasses(slots, getBackdropUtilityClass, classes);
|
||||
};
|
||||
const BackdropRoot = styled('div', {
|
||||
name: 'MuiBackdrop',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, ownerState.invisible && styles.invisible];
|
||||
}
|
||||
})(({
|
||||
ownerState
|
||||
}) => _extends({
|
||||
position: 'fixed',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
top: 0,
|
||||
left: 0,
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
||||
WebkitTapHighlightColor: 'transparent'
|
||||
}, ownerState.invisible && {
|
||||
backgroundColor: 'transparent'
|
||||
}));
|
||||
const Backdrop = /*#__PURE__*/React.forwardRef(function Backdrop(inProps, ref) {
|
||||
var _slotProps$root, _ref, _slots$root;
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiBackdrop'
|
||||
});
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
component = 'div',
|
||||
components = {},
|
||||
componentsProps = {},
|
||||
invisible = false,
|
||||
open,
|
||||
slotProps = {},
|
||||
slots = {},
|
||||
TransitionComponent = Fade,
|
||||
transitionDuration
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
component,
|
||||
invisible
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const rootSlotProps = (_slotProps$root = slotProps.root) != null ? _slotProps$root : componentsProps.root;
|
||||
return /*#__PURE__*/_jsx(TransitionComponent, _extends({
|
||||
in: open,
|
||||
timeout: transitionDuration
|
||||
}, other, {
|
||||
children: /*#__PURE__*/_jsx(BackdropRoot, _extends({
|
||||
"aria-hidden": true
|
||||
}, rootSlotProps, {
|
||||
as: (_ref = (_slots$root = slots.root) != null ? _slots$root : components.Root) != null ? _ref : component,
|
||||
className: clsx(classes.root, className, rootSlotProps == null ? void 0 : rootSlotProps.className),
|
||||
ownerState: _extends({}, ownerState, rootSlotProps == null ? void 0 : rootSlotProps.ownerState),
|
||||
classes: classes,
|
||||
ref: ref,
|
||||
children: children
|
||||
}))
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Backdrop.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: PropTypes.elementType,
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
*
|
||||
* This prop is an alias for the `slots` prop.
|
||||
* It's recommended to use the `slots` prop instead.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
components: PropTypes.shape({
|
||||
Root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The extra props for the slot components.
|
||||
* You can override the existing props or add new ones.
|
||||
*
|
||||
* This prop is an alias for the `slotProps` prop.
|
||||
* It's recommended to use the `slotProps` prop instead, as `componentsProps` will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
componentsProps: PropTypes.shape({
|
||||
root: PropTypes.object
|
||||
}),
|
||||
/**
|
||||
* If `true`, the backdrop is invisible.
|
||||
* It can be used when rendering a popover or a custom select component.
|
||||
* @default false
|
||||
*/
|
||||
invisible: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the component is shown.
|
||||
*/
|
||||
open: PropTypes.bool.isRequired,
|
||||
/**
|
||||
* The extra props for the slot components.
|
||||
* You can override the existing props or add new ones.
|
||||
*
|
||||
* This prop is an alias for the `componentsProps` prop, which will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.object
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
*
|
||||
* This prop is an alias for the `components` prop, which will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* The component used for the transition.
|
||||
* [Follow this guide](/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
|
||||
* @default Fade
|
||||
*/
|
||||
TransitionComponent: PropTypes.elementType,
|
||||
/**
|
||||
* The duration for the transition, in milliseconds.
|
||||
* You may specify a single timeout for all transitions, or individually with an object.
|
||||
*/
|
||||
transitionDuration: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
||||
appear: PropTypes.number,
|
||||
enter: PropTypes.number,
|
||||
exit: PropTypes.number
|
||||
})])
|
||||
} : void 0;
|
||||
export default Backdrop;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getBackdropUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiBackdrop', slot);
|
||||
}
|
||||
const backdropClasses = generateUtilityClasses('MuiBackdrop', ['root', 'invisible']);
|
||||
export default backdropClasses;
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
'use client';
|
||||
|
||||
import { createBox } from '@mui/system';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_ClassNameGenerator as ClassNameGenerator } from '../className';
|
||||
import { createTheme } from '../styles';
|
||||
import THEME_ID from '../styles/identifier';
|
||||
import boxClasses from './boxClasses';
|
||||
const defaultTheme = createTheme();
|
||||
const Box = createBox({
|
||||
themeId: THEME_ID,
|
||||
defaultTheme,
|
||||
defaultClassName: boxClasses.root,
|
||||
generateClassName: ClassNameGenerator.generate
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Box.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: PropTypes.elementType,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default Box;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
const boxClasses = generateUtilityClasses('MuiBox', ['root']);
|
||||
export default boxClasses;
|
||||
+379
@@ -0,0 +1,379 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["children", "color", "component", "className", "disabled", "disableElevation", "disableFocusRipple", "endIcon", "focusVisibleClassName", "fullWidth", "size", "startIcon", "type", "variant"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import resolveProps from '@mui/utils/resolveProps';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import { alpha } from '@mui/system/colorManipulator';
|
||||
import styled, { rootShouldForwardProp } from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import ButtonBase from '../ButtonBase';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import buttonClasses, { getButtonUtilityClass } from './buttonClasses';
|
||||
import ButtonGroupContext from '../ButtonGroup/ButtonGroupContext';
|
||||
import ButtonGroupButtonContext from '../ButtonGroup/ButtonGroupButtonContext';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
color,
|
||||
disableElevation,
|
||||
fullWidth,
|
||||
size,
|
||||
variant,
|
||||
classes
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', variant, `${variant}${capitalize(color)}`, `size${capitalize(size)}`, `${variant}Size${capitalize(size)}`, `color${capitalize(color)}`, disableElevation && 'disableElevation', fullWidth && 'fullWidth'],
|
||||
label: ['label'],
|
||||
startIcon: ['icon', 'startIcon', `iconSize${capitalize(size)}`],
|
||||
endIcon: ['icon', 'endIcon', `iconSize${capitalize(size)}`]
|
||||
};
|
||||
const composedClasses = composeClasses(slots, getButtonUtilityClass, classes);
|
||||
return _extends({}, classes, composedClasses);
|
||||
};
|
||||
const commonIconStyles = ownerState => _extends({}, ownerState.size === 'small' && {
|
||||
'& > *:nth-of-type(1)': {
|
||||
fontSize: 18
|
||||
}
|
||||
}, ownerState.size === 'medium' && {
|
||||
'& > *:nth-of-type(1)': {
|
||||
fontSize: 20
|
||||
}
|
||||
}, ownerState.size === 'large' && {
|
||||
'& > *:nth-of-type(1)': {
|
||||
fontSize: 22
|
||||
}
|
||||
});
|
||||
const ButtonRoot = styled(ButtonBase, {
|
||||
shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
|
||||
name: 'MuiButton',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, styles[ownerState.variant], styles[`${ownerState.variant}${capitalize(ownerState.color)}`], styles[`size${capitalize(ownerState.size)}`], styles[`${ownerState.variant}Size${capitalize(ownerState.size)}`], ownerState.color === 'inherit' && styles.colorInherit, ownerState.disableElevation && styles.disableElevation, ownerState.fullWidth && styles.fullWidth];
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => {
|
||||
var _theme$palette$getCon, _theme$palette;
|
||||
const inheritContainedBackgroundColor = theme.palette.mode === 'light' ? theme.palette.grey[300] : theme.palette.grey[800];
|
||||
const inheritContainedHoverBackgroundColor = theme.palette.mode === 'light' ? theme.palette.grey.A100 : theme.palette.grey[700];
|
||||
return _extends({}, theme.typography.button, {
|
||||
minWidth: 64,
|
||||
padding: '6px 16px',
|
||||
borderRadius: (theme.vars || theme).shape.borderRadius,
|
||||
transition: theme.transitions.create(['background-color', 'box-shadow', 'border-color', 'color'], {
|
||||
duration: theme.transitions.duration.short
|
||||
}),
|
||||
'&:hover': _extends({
|
||||
textDecoration: 'none',
|
||||
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.text.primaryChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette.text.primary, theme.palette.action.hoverOpacity),
|
||||
// Reset on touch devices, it doesn't add specificity
|
||||
'@media (hover: none)': {
|
||||
backgroundColor: 'transparent'
|
||||
}
|
||||
}, ownerState.variant === 'text' && ownerState.color !== 'inherit' && {
|
||||
backgroundColor: theme.vars ? `rgba(${theme.vars.palette[ownerState.color].mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette[ownerState.color].main, theme.palette.action.hoverOpacity),
|
||||
// Reset on touch devices, it doesn't add specificity
|
||||
'@media (hover: none)': {
|
||||
backgroundColor: 'transparent'
|
||||
}
|
||||
}, ownerState.variant === 'outlined' && ownerState.color !== 'inherit' && {
|
||||
border: `1px solid ${(theme.vars || theme).palette[ownerState.color].main}`,
|
||||
backgroundColor: theme.vars ? `rgba(${theme.vars.palette[ownerState.color].mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette[ownerState.color].main, theme.palette.action.hoverOpacity),
|
||||
// Reset on touch devices, it doesn't add specificity
|
||||
'@media (hover: none)': {
|
||||
backgroundColor: 'transparent'
|
||||
}
|
||||
}, ownerState.variant === 'contained' && {
|
||||
backgroundColor: theme.vars ? theme.vars.palette.Button.inheritContainedHoverBg : inheritContainedHoverBackgroundColor,
|
||||
boxShadow: (theme.vars || theme).shadows[4],
|
||||
// Reset on touch devices, it doesn't add specificity
|
||||
'@media (hover: none)': {
|
||||
boxShadow: (theme.vars || theme).shadows[2],
|
||||
backgroundColor: (theme.vars || theme).palette.grey[300]
|
||||
}
|
||||
}, ownerState.variant === 'contained' && ownerState.color !== 'inherit' && {
|
||||
backgroundColor: (theme.vars || theme).palette[ownerState.color].dark,
|
||||
// Reset on touch devices, it doesn't add specificity
|
||||
'@media (hover: none)': {
|
||||
backgroundColor: (theme.vars || theme).palette[ownerState.color].main
|
||||
}
|
||||
}),
|
||||
'&:active': _extends({}, ownerState.variant === 'contained' && {
|
||||
boxShadow: (theme.vars || theme).shadows[8]
|
||||
}),
|
||||
[`&.${buttonClasses.focusVisible}`]: _extends({}, ownerState.variant === 'contained' && {
|
||||
boxShadow: (theme.vars || theme).shadows[6]
|
||||
}),
|
||||
[`&.${buttonClasses.disabled}`]: _extends({
|
||||
color: (theme.vars || theme).palette.action.disabled
|
||||
}, ownerState.variant === 'outlined' && {
|
||||
border: `1px solid ${(theme.vars || theme).palette.action.disabledBackground}`
|
||||
}, ownerState.variant === 'contained' && {
|
||||
color: (theme.vars || theme).palette.action.disabled,
|
||||
boxShadow: (theme.vars || theme).shadows[0],
|
||||
backgroundColor: (theme.vars || theme).palette.action.disabledBackground
|
||||
})
|
||||
}, ownerState.variant === 'text' && {
|
||||
padding: '6px 8px'
|
||||
}, ownerState.variant === 'text' && ownerState.color !== 'inherit' && {
|
||||
color: (theme.vars || theme).palette[ownerState.color].main
|
||||
}, ownerState.variant === 'outlined' && {
|
||||
padding: '5px 15px',
|
||||
border: '1px solid currentColor'
|
||||
}, ownerState.variant === 'outlined' && ownerState.color !== 'inherit' && {
|
||||
color: (theme.vars || theme).palette[ownerState.color].main,
|
||||
border: theme.vars ? `1px solid rgba(${theme.vars.palette[ownerState.color].mainChannel} / 0.5)` : `1px solid ${alpha(theme.palette[ownerState.color].main, 0.5)}`
|
||||
}, ownerState.variant === 'contained' && {
|
||||
color: theme.vars ?
|
||||
// this is safe because grey does not change between default light/dark mode
|
||||
theme.vars.palette.text.primary : (_theme$palette$getCon = (_theme$palette = theme.palette).getContrastText) == null ? void 0 : _theme$palette$getCon.call(_theme$palette, theme.palette.grey[300]),
|
||||
backgroundColor: theme.vars ? theme.vars.palette.Button.inheritContainedBg : inheritContainedBackgroundColor,
|
||||
boxShadow: (theme.vars || theme).shadows[2]
|
||||
}, ownerState.variant === 'contained' && ownerState.color !== 'inherit' && {
|
||||
color: (theme.vars || theme).palette[ownerState.color].contrastText,
|
||||
backgroundColor: (theme.vars || theme).palette[ownerState.color].main
|
||||
}, ownerState.color === 'inherit' && {
|
||||
color: 'inherit',
|
||||
borderColor: 'currentColor'
|
||||
}, ownerState.size === 'small' && ownerState.variant === 'text' && {
|
||||
padding: '4px 5px',
|
||||
fontSize: theme.typography.pxToRem(13)
|
||||
}, ownerState.size === 'large' && ownerState.variant === 'text' && {
|
||||
padding: '8px 11px',
|
||||
fontSize: theme.typography.pxToRem(15)
|
||||
}, ownerState.size === 'small' && ownerState.variant === 'outlined' && {
|
||||
padding: '3px 9px',
|
||||
fontSize: theme.typography.pxToRem(13)
|
||||
}, ownerState.size === 'large' && ownerState.variant === 'outlined' && {
|
||||
padding: '7px 21px',
|
||||
fontSize: theme.typography.pxToRem(15)
|
||||
}, ownerState.size === 'small' && ownerState.variant === 'contained' && {
|
||||
padding: '4px 10px',
|
||||
fontSize: theme.typography.pxToRem(13)
|
||||
}, ownerState.size === 'large' && ownerState.variant === 'contained' && {
|
||||
padding: '8px 22px',
|
||||
fontSize: theme.typography.pxToRem(15)
|
||||
}, ownerState.fullWidth && {
|
||||
width: '100%'
|
||||
});
|
||||
}, ({
|
||||
ownerState
|
||||
}) => ownerState.disableElevation && {
|
||||
boxShadow: 'none',
|
||||
'&:hover': {
|
||||
boxShadow: 'none'
|
||||
},
|
||||
[`&.${buttonClasses.focusVisible}`]: {
|
||||
boxShadow: 'none'
|
||||
},
|
||||
'&:active': {
|
||||
boxShadow: 'none'
|
||||
},
|
||||
[`&.${buttonClasses.disabled}`]: {
|
||||
boxShadow: 'none'
|
||||
}
|
||||
});
|
||||
const ButtonStartIcon = styled('span', {
|
||||
name: 'MuiButton',
|
||||
slot: 'StartIcon',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.startIcon, styles[`iconSize${capitalize(ownerState.size)}`]];
|
||||
}
|
||||
})(({
|
||||
ownerState
|
||||
}) => _extends({
|
||||
display: 'inherit',
|
||||
marginRight: 8,
|
||||
marginLeft: -4
|
||||
}, ownerState.size === 'small' && {
|
||||
marginLeft: -2
|
||||
}, commonIconStyles(ownerState)));
|
||||
const ButtonEndIcon = styled('span', {
|
||||
name: 'MuiButton',
|
||||
slot: 'EndIcon',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.endIcon, styles[`iconSize${capitalize(ownerState.size)}`]];
|
||||
}
|
||||
})(({
|
||||
ownerState
|
||||
}) => _extends({
|
||||
display: 'inherit',
|
||||
marginRight: -4,
|
||||
marginLeft: 8
|
||||
}, ownerState.size === 'small' && {
|
||||
marginRight: -2
|
||||
}, commonIconStyles(ownerState)));
|
||||
const Button = /*#__PURE__*/React.forwardRef(function Button(inProps, ref) {
|
||||
// props priority: `inProps` > `contextProps` > `themeDefaultProps`
|
||||
const contextProps = React.useContext(ButtonGroupContext);
|
||||
const buttonGroupButtonContextPositionClassName = React.useContext(ButtonGroupButtonContext);
|
||||
const resolvedProps = resolveProps(contextProps, inProps);
|
||||
const props = useThemeProps({
|
||||
props: resolvedProps,
|
||||
name: 'MuiButton'
|
||||
});
|
||||
const {
|
||||
children,
|
||||
color = 'primary',
|
||||
component = 'button',
|
||||
className,
|
||||
disabled = false,
|
||||
disableElevation = false,
|
||||
disableFocusRipple = false,
|
||||
endIcon: endIconProp,
|
||||
focusVisibleClassName,
|
||||
fullWidth = false,
|
||||
size = 'medium',
|
||||
startIcon: startIconProp,
|
||||
type,
|
||||
variant = 'text'
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
color,
|
||||
component,
|
||||
disabled,
|
||||
disableElevation,
|
||||
disableFocusRipple,
|
||||
fullWidth,
|
||||
size,
|
||||
type,
|
||||
variant
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const startIcon = startIconProp && /*#__PURE__*/_jsx(ButtonStartIcon, {
|
||||
className: classes.startIcon,
|
||||
ownerState: ownerState,
|
||||
children: startIconProp
|
||||
});
|
||||
const endIcon = endIconProp && /*#__PURE__*/_jsx(ButtonEndIcon, {
|
||||
className: classes.endIcon,
|
||||
ownerState: ownerState,
|
||||
children: endIconProp
|
||||
});
|
||||
const positionClassName = buttonGroupButtonContextPositionClassName || '';
|
||||
return /*#__PURE__*/_jsxs(ButtonRoot, _extends({
|
||||
ownerState: ownerState,
|
||||
className: clsx(contextProps.className, classes.root, className, positionClassName),
|
||||
component: component,
|
||||
disabled: disabled,
|
||||
focusRipple: !disableFocusRipple,
|
||||
focusVisibleClassName: clsx(classes.focusVisible, focusVisibleClassName),
|
||||
ref: ref,
|
||||
type: type
|
||||
}, other, {
|
||||
classes: classes,
|
||||
children: [startIcon, children, endIcon]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Button.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
* @default 'primary'
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['inherit', 'primary', 'secondary', 'success', 'error', 'info', 'warning']), PropTypes.string]),
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: PropTypes.elementType,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, no elevation is used.
|
||||
* @default false
|
||||
*/
|
||||
disableElevation: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the keyboard focus ripple is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disableFocusRipple: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the ripple effect is disabled.
|
||||
*
|
||||
* ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure
|
||||
* to highlight the element by applying separate styles with the `.Mui-focusVisible` class.
|
||||
* @default false
|
||||
*/
|
||||
disableRipple: PropTypes.bool,
|
||||
/**
|
||||
* Element placed after the children.
|
||||
*/
|
||||
endIcon: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
focusVisibleClassName: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the button will take up the full width of its container.
|
||||
* @default false
|
||||
*/
|
||||
fullWidth: PropTypes.bool,
|
||||
/**
|
||||
* The URL to link to when the button is clicked.
|
||||
* If defined, an `a` element will be used as the root node.
|
||||
*/
|
||||
href: PropTypes.string,
|
||||
/**
|
||||
* The size of the component.
|
||||
* `small` is equivalent to the dense button styling.
|
||||
* @default 'medium'
|
||||
*/
|
||||
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['small', 'medium', 'large']), PropTypes.string]),
|
||||
/**
|
||||
* Element placed before the children.
|
||||
*/
|
||||
startIcon: PropTypes.node,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
type: PropTypes.oneOfType([PropTypes.oneOf(['button', 'reset', 'submit']), PropTypes.string]),
|
||||
/**
|
||||
* The variant to use.
|
||||
* @default 'text'
|
||||
*/
|
||||
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['contained', 'outlined', 'text']), PropTypes.string])
|
||||
} : void 0;
|
||||
export default Button;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getButtonUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiButton', slot);
|
||||
}
|
||||
const buttonClasses = generateUtilityClasses('MuiButton', ['root', 'text', 'textInherit', 'textPrimary', 'textSecondary', 'textSuccess', 'textError', 'textInfo', 'textWarning', 'outlined', 'outlinedInherit', 'outlinedPrimary', 'outlinedSecondary', 'outlinedSuccess', 'outlinedError', 'outlinedInfo', 'outlinedWarning', 'contained', 'containedInherit', 'containedPrimary', 'containedSecondary', 'containedSuccess', 'containedError', 'containedInfo', 'containedWarning', 'disableElevation', 'focusVisible', 'disabled', 'colorInherit', 'colorPrimary', 'colorSecondary', 'colorSuccess', 'colorError', 'colorInfo', 'colorWarning', 'textSizeSmall', 'textSizeMedium', 'textSizeLarge', 'outlinedSizeSmall', 'outlinedSizeMedium', 'outlinedSizeLarge', 'containedSizeSmall', 'containedSizeMedium', 'containedSizeLarge', 'sizeMedium', 'sizeSmall', 'sizeLarge', 'fullWidth', 'startIcon', 'endIcon', 'icon', 'iconSizeSmall', 'iconSizeMedium', 'iconSizeLarge']);
|
||||
export default buttonClasses;
|
||||
+477
@@ -0,0 +1,477 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["action", "centerRipple", "children", "className", "component", "disabled", "disableRipple", "disableTouchRipple", "focusRipple", "focusVisibleClassName", "LinkComponent", "onBlur", "onClick", "onContextMenu", "onDragLeave", "onFocus", "onFocusVisible", "onKeyDown", "onKeyUp", "onMouseDown", "onMouseLeave", "onMouseUp", "onTouchEnd", "onTouchMove", "onTouchStart", "tabIndex", "TouchRippleProps", "touchRippleRef", "type"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import refType from '@mui/utils/refType';
|
||||
import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import useForkRef from '../utils/useForkRef';
|
||||
import useEventCallback from '../utils/useEventCallback';
|
||||
import useIsFocusVisible from '../utils/useIsFocusVisible';
|
||||
import TouchRipple from './TouchRipple';
|
||||
import buttonBaseClasses, { getButtonBaseUtilityClass } from './buttonBaseClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
disabled,
|
||||
focusVisible,
|
||||
focusVisibleClassName,
|
||||
classes
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', disabled && 'disabled', focusVisible && 'focusVisible']
|
||||
};
|
||||
const composedClasses = composeClasses(slots, getButtonBaseUtilityClass, classes);
|
||||
if (focusVisible && focusVisibleClassName) {
|
||||
composedClasses.root += ` ${focusVisibleClassName}`;
|
||||
}
|
||||
return composedClasses;
|
||||
};
|
||||
export const ButtonBaseRoot = styled('button', {
|
||||
name: 'MuiButtonBase',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => styles.root
|
||||
})({
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
position: 'relative',
|
||||
boxSizing: 'border-box',
|
||||
WebkitTapHighlightColor: 'transparent',
|
||||
backgroundColor: 'transparent',
|
||||
// Reset default value
|
||||
// We disable the focus ring for mouse, touch and keyboard users.
|
||||
outline: 0,
|
||||
border: 0,
|
||||
margin: 0,
|
||||
// Remove the margin in Safari
|
||||
borderRadius: 0,
|
||||
padding: 0,
|
||||
// Remove the padding in Firefox
|
||||
cursor: 'pointer',
|
||||
userSelect: 'none',
|
||||
verticalAlign: 'middle',
|
||||
MozAppearance: 'none',
|
||||
// Reset
|
||||
WebkitAppearance: 'none',
|
||||
// Reset
|
||||
textDecoration: 'none',
|
||||
// So we take precedent over the style of a native <a /> element.
|
||||
color: 'inherit',
|
||||
'&::-moz-focus-inner': {
|
||||
borderStyle: 'none' // Remove Firefox dotted outline.
|
||||
},
|
||||
[`&.${buttonBaseClasses.disabled}`]: {
|
||||
pointerEvents: 'none',
|
||||
// Disable link interactions
|
||||
cursor: 'default'
|
||||
},
|
||||
'@media print': {
|
||||
colorAdjust: 'exact'
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* `ButtonBase` contains as few styles as possible.
|
||||
* It aims to be a simple building block for creating a button.
|
||||
* It contains a load of style reset and some focus/ripple logic.
|
||||
*/
|
||||
const ButtonBase = /*#__PURE__*/React.forwardRef(function ButtonBase(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiButtonBase'
|
||||
});
|
||||
const {
|
||||
action,
|
||||
centerRipple = false,
|
||||
children,
|
||||
className,
|
||||
component = 'button',
|
||||
disabled = false,
|
||||
disableRipple = false,
|
||||
disableTouchRipple = false,
|
||||
focusRipple = false,
|
||||
LinkComponent = 'a',
|
||||
onBlur,
|
||||
onClick,
|
||||
onContextMenu,
|
||||
onDragLeave,
|
||||
onFocus,
|
||||
onFocusVisible,
|
||||
onKeyDown,
|
||||
onKeyUp,
|
||||
onMouseDown,
|
||||
onMouseLeave,
|
||||
onMouseUp,
|
||||
onTouchEnd,
|
||||
onTouchMove,
|
||||
onTouchStart,
|
||||
tabIndex = 0,
|
||||
TouchRippleProps,
|
||||
touchRippleRef,
|
||||
type
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const buttonRef = React.useRef(null);
|
||||
const rippleRef = React.useRef(null);
|
||||
const handleRippleRef = useForkRef(rippleRef, touchRippleRef);
|
||||
const {
|
||||
isFocusVisibleRef,
|
||||
onFocus: handleFocusVisible,
|
||||
onBlur: handleBlurVisible,
|
||||
ref: focusVisibleRef
|
||||
} = useIsFocusVisible();
|
||||
const [focusVisible, setFocusVisible] = React.useState(false);
|
||||
if (disabled && focusVisible) {
|
||||
setFocusVisible(false);
|
||||
}
|
||||
React.useImperativeHandle(action, () => ({
|
||||
focusVisible: () => {
|
||||
setFocusVisible(true);
|
||||
buttonRef.current.focus();
|
||||
}
|
||||
}), []);
|
||||
const [mountedState, setMountedState] = React.useState(false);
|
||||
React.useEffect(() => {
|
||||
setMountedState(true);
|
||||
}, []);
|
||||
const enableTouchRipple = mountedState && !disableRipple && !disabled;
|
||||
React.useEffect(() => {
|
||||
if (focusVisible && focusRipple && !disableRipple && mountedState) {
|
||||
rippleRef.current.pulsate();
|
||||
}
|
||||
}, [disableRipple, focusRipple, focusVisible, mountedState]);
|
||||
function useRippleHandler(rippleAction, eventCallback, skipRippleAction = disableTouchRipple) {
|
||||
return useEventCallback(event => {
|
||||
if (eventCallback) {
|
||||
eventCallback(event);
|
||||
}
|
||||
const ignore = skipRippleAction;
|
||||
if (!ignore && rippleRef.current) {
|
||||
rippleRef.current[rippleAction](event);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
const handleMouseDown = useRippleHandler('start', onMouseDown);
|
||||
const handleContextMenu = useRippleHandler('stop', onContextMenu);
|
||||
const handleDragLeave = useRippleHandler('stop', onDragLeave);
|
||||
const handleMouseUp = useRippleHandler('stop', onMouseUp);
|
||||
const handleMouseLeave = useRippleHandler('stop', event => {
|
||||
if (focusVisible) {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (onMouseLeave) {
|
||||
onMouseLeave(event);
|
||||
}
|
||||
});
|
||||
const handleTouchStart = useRippleHandler('start', onTouchStart);
|
||||
const handleTouchEnd = useRippleHandler('stop', onTouchEnd);
|
||||
const handleTouchMove = useRippleHandler('stop', onTouchMove);
|
||||
const handleBlur = useRippleHandler('stop', event => {
|
||||
handleBlurVisible(event);
|
||||
if (isFocusVisibleRef.current === false) {
|
||||
setFocusVisible(false);
|
||||
}
|
||||
if (onBlur) {
|
||||
onBlur(event);
|
||||
}
|
||||
}, false);
|
||||
const handleFocus = useEventCallback(event => {
|
||||
// Fix for https://github.com/facebook/react/issues/7769
|
||||
if (!buttonRef.current) {
|
||||
buttonRef.current = event.currentTarget;
|
||||
}
|
||||
handleFocusVisible(event);
|
||||
if (isFocusVisibleRef.current === true) {
|
||||
setFocusVisible(true);
|
||||
if (onFocusVisible) {
|
||||
onFocusVisible(event);
|
||||
}
|
||||
}
|
||||
if (onFocus) {
|
||||
onFocus(event);
|
||||
}
|
||||
});
|
||||
const isNonNativeButton = () => {
|
||||
const button = buttonRef.current;
|
||||
return component && component !== 'button' && !(button.tagName === 'A' && button.href);
|
||||
};
|
||||
|
||||
/**
|
||||
* IE11 shim for https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat
|
||||
*/
|
||||
const keydownRef = React.useRef(false);
|
||||
const handleKeyDown = useEventCallback(event => {
|
||||
// Check if key is already down to avoid repeats being counted as multiple activations
|
||||
if (focusRipple && !keydownRef.current && focusVisible && rippleRef.current && event.key === ' ') {
|
||||
keydownRef.current = true;
|
||||
rippleRef.current.stop(event, () => {
|
||||
rippleRef.current.start(event);
|
||||
});
|
||||
}
|
||||
if (event.target === event.currentTarget && isNonNativeButton() && event.key === ' ') {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (onKeyDown) {
|
||||
onKeyDown(event);
|
||||
}
|
||||
|
||||
// Keyboard accessibility for non interactive elements
|
||||
if (event.target === event.currentTarget && isNonNativeButton() && event.key === 'Enter' && !disabled) {
|
||||
event.preventDefault();
|
||||
if (onClick) {
|
||||
onClick(event);
|
||||
}
|
||||
}
|
||||
});
|
||||
const handleKeyUp = useEventCallback(event => {
|
||||
// calling preventDefault in keyUp on a <button> will not dispatch a click event if Space is pressed
|
||||
// https://codesandbox.io/p/sandbox/button-keyup-preventdefault-dn7f0
|
||||
if (focusRipple && event.key === ' ' && rippleRef.current && focusVisible && !event.defaultPrevented) {
|
||||
keydownRef.current = false;
|
||||
rippleRef.current.stop(event, () => {
|
||||
rippleRef.current.pulsate(event);
|
||||
});
|
||||
}
|
||||
if (onKeyUp) {
|
||||
onKeyUp(event);
|
||||
}
|
||||
|
||||
// Keyboard accessibility for non interactive elements
|
||||
if (onClick && event.target === event.currentTarget && isNonNativeButton() && event.key === ' ' && !event.defaultPrevented) {
|
||||
onClick(event);
|
||||
}
|
||||
});
|
||||
let ComponentProp = component;
|
||||
if (ComponentProp === 'button' && (other.href || other.to)) {
|
||||
ComponentProp = LinkComponent;
|
||||
}
|
||||
const buttonProps = {};
|
||||
if (ComponentProp === 'button') {
|
||||
buttonProps.type = type === undefined ? 'button' : type;
|
||||
buttonProps.disabled = disabled;
|
||||
} else {
|
||||
if (!other.href && !other.to) {
|
||||
buttonProps.role = 'button';
|
||||
}
|
||||
if (disabled) {
|
||||
buttonProps['aria-disabled'] = disabled;
|
||||
}
|
||||
}
|
||||
const handleRef = useForkRef(ref, focusVisibleRef, buttonRef);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
React.useEffect(() => {
|
||||
if (enableTouchRipple && !rippleRef.current) {
|
||||
console.error(['MUI: The `component` prop provided to ButtonBase is invalid.', 'Please make sure the children prop is rendered in this custom component.'].join('\n'));
|
||||
}
|
||||
}, [enableTouchRipple]);
|
||||
}
|
||||
const ownerState = _extends({}, props, {
|
||||
centerRipple,
|
||||
component,
|
||||
disabled,
|
||||
disableRipple,
|
||||
disableTouchRipple,
|
||||
focusRipple,
|
||||
tabIndex,
|
||||
focusVisible
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsxs(ButtonBaseRoot, _extends({
|
||||
as: ComponentProp,
|
||||
className: clsx(classes.root, className),
|
||||
ownerState: ownerState,
|
||||
onBlur: handleBlur,
|
||||
onClick: onClick,
|
||||
onContextMenu: handleContextMenu,
|
||||
onFocus: handleFocus,
|
||||
onKeyDown: handleKeyDown,
|
||||
onKeyUp: handleKeyUp,
|
||||
onMouseDown: handleMouseDown,
|
||||
onMouseLeave: handleMouseLeave,
|
||||
onMouseUp: handleMouseUp,
|
||||
onDragLeave: handleDragLeave,
|
||||
onTouchEnd: handleTouchEnd,
|
||||
onTouchMove: handleTouchMove,
|
||||
onTouchStart: handleTouchStart,
|
||||
ref: handleRef,
|
||||
tabIndex: disabled ? -1 : tabIndex,
|
||||
type: type
|
||||
}, buttonProps, other, {
|
||||
children: [children, enableTouchRipple ?
|
||||
/*#__PURE__*/
|
||||
/* TouchRipple is only needed client-side, x2 boost on the server. */
|
||||
_jsx(TouchRipple, _extends({
|
||||
ref: handleRippleRef,
|
||||
center: centerRipple
|
||||
}, TouchRippleProps)) : null]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? ButtonBase.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* A ref for imperative actions.
|
||||
* It currently only supports `focusVisible()` action.
|
||||
*/
|
||||
action: refType,
|
||||
/**
|
||||
* If `true`, the ripples are centered.
|
||||
* They won't start at the cursor interaction position.
|
||||
* @default false
|
||||
*/
|
||||
centerRipple: PropTypes.bool,
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: elementTypeAcceptingRef,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the ripple effect is disabled.
|
||||
*
|
||||
* ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure
|
||||
* to highlight the element by applying separate styles with the `.Mui-focusVisible` class.
|
||||
* @default false
|
||||
*/
|
||||
disableRipple: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the touch ripple effect is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disableTouchRipple: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the base button will have a keyboard focus ripple.
|
||||
* @default false
|
||||
*/
|
||||
focusRipple: PropTypes.bool,
|
||||
/**
|
||||
* This prop can help identify which element has keyboard focus.
|
||||
* The class name will be applied when the element gains the focus through keyboard interaction.
|
||||
* It's a polyfill for the [CSS :focus-visible selector](https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo).
|
||||
* The rationale for using this feature [is explained here](https://github.com/WICG/focus-visible/blob/HEAD/explainer.md).
|
||||
* A [polyfill can be used](https://github.com/WICG/focus-visible) to apply a `focus-visible` class to other components
|
||||
* if needed.
|
||||
*/
|
||||
focusVisibleClassName: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
href: PropTypes /* @typescript-to-proptypes-ignore */.any,
|
||||
/**
|
||||
* The component used to render a link when the `href` prop is provided.
|
||||
* @default 'a'
|
||||
*/
|
||||
LinkComponent: PropTypes.elementType,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onBlur: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onContextMenu: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onDragLeave: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onFocus: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the component is focused with a keyboard.
|
||||
* We trigger a `onFocus` callback too.
|
||||
*/
|
||||
onFocusVisible: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onKeyDown: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onKeyUp: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onMouseDown: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onMouseLeave: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onMouseUp: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onTouchEnd: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onTouchMove: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onTouchStart: PropTypes.func,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* @default 0
|
||||
*/
|
||||
tabIndex: PropTypes.number,
|
||||
/**
|
||||
* Props applied to the `TouchRipple` element.
|
||||
*/
|
||||
TouchRippleProps: PropTypes.object,
|
||||
/**
|
||||
* A ref that points to the `TouchRipple` element.
|
||||
*/
|
||||
touchRippleRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
||||
current: PropTypes.shape({
|
||||
pulsate: PropTypes.func.isRequired,
|
||||
start: PropTypes.func.isRequired,
|
||||
stop: PropTypes.func.isRequired
|
||||
})
|
||||
})]),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
type: PropTypes.oneOfType([PropTypes.oneOf(['button', 'reset', 'submit']), PropTypes.string])
|
||||
} : void 0;
|
||||
export default ButtonBase;
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function Ripple(props) {
|
||||
const {
|
||||
className,
|
||||
classes,
|
||||
pulsate = false,
|
||||
rippleX,
|
||||
rippleY,
|
||||
rippleSize,
|
||||
in: inProp,
|
||||
onExited,
|
||||
timeout
|
||||
} = props;
|
||||
const [leaving, setLeaving] = React.useState(false);
|
||||
const rippleClassName = clsx(className, classes.ripple, classes.rippleVisible, pulsate && classes.ripplePulsate);
|
||||
const rippleStyles = {
|
||||
width: rippleSize,
|
||||
height: rippleSize,
|
||||
top: -(rippleSize / 2) + rippleY,
|
||||
left: -(rippleSize / 2) + rippleX
|
||||
};
|
||||
const childClassName = clsx(classes.child, leaving && classes.childLeaving, pulsate && classes.childPulsate);
|
||||
if (!inProp && !leaving) {
|
||||
setLeaving(true);
|
||||
}
|
||||
React.useEffect(() => {
|
||||
if (!inProp && onExited != null) {
|
||||
// react-transition-group#onExited
|
||||
const timeoutId = setTimeout(onExited, timeout);
|
||||
return () => {
|
||||
clearTimeout(timeoutId);
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}, [onExited, inProp, timeout]);
|
||||
return /*#__PURE__*/_jsx("span", {
|
||||
className: rippleClassName,
|
||||
style: rippleStyles,
|
||||
children: /*#__PURE__*/_jsx("span", {
|
||||
className: childClassName
|
||||
})
|
||||
});
|
||||
}
|
||||
process.env.NODE_ENV !== "production" ? Ripple.propTypes = {
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object.isRequired,
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* @ignore - injected from TransitionGroup
|
||||
*/
|
||||
in: PropTypes.bool,
|
||||
/**
|
||||
* @ignore - injected from TransitionGroup
|
||||
*/
|
||||
onExited: PropTypes.func,
|
||||
/**
|
||||
* If `true`, the ripple pulsates, typically indicating the keyboard focus state of an element.
|
||||
*/
|
||||
pulsate: PropTypes.bool,
|
||||
/**
|
||||
* Diameter of the ripple.
|
||||
*/
|
||||
rippleSize: PropTypes.number,
|
||||
/**
|
||||
* Horizontal position of the ripple center.
|
||||
*/
|
||||
rippleX: PropTypes.number,
|
||||
/**
|
||||
* Vertical position of the ripple center.
|
||||
*/
|
||||
rippleY: PropTypes.number,
|
||||
/**
|
||||
* exit delay
|
||||
*/
|
||||
timeout: PropTypes.number.isRequired
|
||||
} : void 0;
|
||||
export default Ripple;
|
||||
+333
@@ -0,0 +1,333 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["center", "classes", "className"];
|
||||
let _ = t => t,
|
||||
_t,
|
||||
_t2,
|
||||
_t3,
|
||||
_t4;
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { TransitionGroup } from 'react-transition-group';
|
||||
import clsx from 'clsx';
|
||||
import { keyframes } from '@mui/system';
|
||||
import useTimeout from '@mui/utils/useTimeout';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import Ripple from './Ripple';
|
||||
import touchRippleClasses from './touchRippleClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const DURATION = 550;
|
||||
export const DELAY_RIPPLE = 80;
|
||||
const enterKeyframe = keyframes(_t || (_t = _`
|
||||
0% {
|
||||
transform: scale(0);
|
||||
opacity: 0.1;
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 0.3;
|
||||
}
|
||||
`));
|
||||
const exitKeyframe = keyframes(_t2 || (_t2 = _`
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
`));
|
||||
const pulsateKeyframe = keyframes(_t3 || (_t3 = _`
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scale(0.92);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
`));
|
||||
export const TouchRippleRoot = styled('span', {
|
||||
name: 'MuiTouchRipple',
|
||||
slot: 'Root'
|
||||
})({
|
||||
overflow: 'hidden',
|
||||
pointerEvents: 'none',
|
||||
position: 'absolute',
|
||||
zIndex: 0,
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
borderRadius: 'inherit'
|
||||
});
|
||||
|
||||
// This `styled()` function invokes keyframes. `styled-components` only supports keyframes
|
||||
// in string templates. Do not convert these styles in JS object as it will break.
|
||||
export const TouchRippleRipple = styled(Ripple, {
|
||||
name: 'MuiTouchRipple',
|
||||
slot: 'Ripple'
|
||||
})(_t4 || (_t4 = _`
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
|
||||
&.${0} {
|
||||
opacity: 0.3;
|
||||
transform: scale(1);
|
||||
animation-name: ${0};
|
||||
animation-duration: ${0}ms;
|
||||
animation-timing-function: ${0};
|
||||
}
|
||||
|
||||
&.${0} {
|
||||
animation-duration: ${0}ms;
|
||||
}
|
||||
|
||||
& .${0} {
|
||||
opacity: 1;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
background-color: currentColor;
|
||||
}
|
||||
|
||||
& .${0} {
|
||||
opacity: 0;
|
||||
animation-name: ${0};
|
||||
animation-duration: ${0}ms;
|
||||
animation-timing-function: ${0};
|
||||
}
|
||||
|
||||
& .${0} {
|
||||
position: absolute;
|
||||
/* @noflip */
|
||||
left: 0px;
|
||||
top: 0;
|
||||
animation-name: ${0};
|
||||
animation-duration: 2500ms;
|
||||
animation-timing-function: ${0};
|
||||
animation-iteration-count: infinite;
|
||||
animation-delay: 200ms;
|
||||
}
|
||||
`), touchRippleClasses.rippleVisible, enterKeyframe, DURATION, ({
|
||||
theme
|
||||
}) => theme.transitions.easing.easeInOut, touchRippleClasses.ripplePulsate, ({
|
||||
theme
|
||||
}) => theme.transitions.duration.shorter, touchRippleClasses.child, touchRippleClasses.childLeaving, exitKeyframe, DURATION, ({
|
||||
theme
|
||||
}) => theme.transitions.easing.easeInOut, touchRippleClasses.childPulsate, pulsateKeyframe, ({
|
||||
theme
|
||||
}) => theme.transitions.easing.easeInOut);
|
||||
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*
|
||||
* TODO v5: Make private
|
||||
*/
|
||||
const TouchRipple = /*#__PURE__*/React.forwardRef(function TouchRipple(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiTouchRipple'
|
||||
});
|
||||
const {
|
||||
center: centerProp = false,
|
||||
classes = {},
|
||||
className
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const [ripples, setRipples] = React.useState([]);
|
||||
const nextKey = React.useRef(0);
|
||||
const rippleCallback = React.useRef(null);
|
||||
React.useEffect(() => {
|
||||
if (rippleCallback.current) {
|
||||
rippleCallback.current();
|
||||
rippleCallback.current = null;
|
||||
}
|
||||
}, [ripples]);
|
||||
|
||||
// Used to filter out mouse emulated events on mobile.
|
||||
const ignoringMouseDown = React.useRef(false);
|
||||
// We use a timer in order to only show the ripples for touch "click" like events.
|
||||
// We don't want to display the ripple for touch scroll events.
|
||||
const startTimer = useTimeout();
|
||||
|
||||
// This is the hook called once the previous timeout is ready.
|
||||
const startTimerCommit = React.useRef(null);
|
||||
const container = React.useRef(null);
|
||||
const startCommit = React.useCallback(params => {
|
||||
const {
|
||||
pulsate,
|
||||
rippleX,
|
||||
rippleY,
|
||||
rippleSize,
|
||||
cb
|
||||
} = params;
|
||||
setRipples(oldRipples => [...oldRipples, /*#__PURE__*/_jsx(TouchRippleRipple, {
|
||||
classes: {
|
||||
ripple: clsx(classes.ripple, touchRippleClasses.ripple),
|
||||
rippleVisible: clsx(classes.rippleVisible, touchRippleClasses.rippleVisible),
|
||||
ripplePulsate: clsx(classes.ripplePulsate, touchRippleClasses.ripplePulsate),
|
||||
child: clsx(classes.child, touchRippleClasses.child),
|
||||
childLeaving: clsx(classes.childLeaving, touchRippleClasses.childLeaving),
|
||||
childPulsate: clsx(classes.childPulsate, touchRippleClasses.childPulsate)
|
||||
},
|
||||
timeout: DURATION,
|
||||
pulsate: pulsate,
|
||||
rippleX: rippleX,
|
||||
rippleY: rippleY,
|
||||
rippleSize: rippleSize
|
||||
}, nextKey.current)]);
|
||||
nextKey.current += 1;
|
||||
rippleCallback.current = cb;
|
||||
}, [classes]);
|
||||
const start = React.useCallback((event = {}, options = {}, cb = () => {}) => {
|
||||
const {
|
||||
pulsate = false,
|
||||
center = centerProp || options.pulsate,
|
||||
fakeElement = false // For test purposes
|
||||
} = options;
|
||||
if ((event == null ? void 0 : event.type) === 'mousedown' && ignoringMouseDown.current) {
|
||||
ignoringMouseDown.current = false;
|
||||
return;
|
||||
}
|
||||
if ((event == null ? void 0 : event.type) === 'touchstart') {
|
||||
ignoringMouseDown.current = true;
|
||||
}
|
||||
const element = fakeElement ? null : container.current;
|
||||
const rect = element ? element.getBoundingClientRect() : {
|
||||
width: 0,
|
||||
height: 0,
|
||||
left: 0,
|
||||
top: 0
|
||||
};
|
||||
|
||||
// Get the size of the ripple
|
||||
let rippleX;
|
||||
let rippleY;
|
||||
let rippleSize;
|
||||
if (center || event === undefined || event.clientX === 0 && event.clientY === 0 || !event.clientX && !event.touches) {
|
||||
rippleX = Math.round(rect.width / 2);
|
||||
rippleY = Math.round(rect.height / 2);
|
||||
} else {
|
||||
const {
|
||||
clientX,
|
||||
clientY
|
||||
} = event.touches && event.touches.length > 0 ? event.touches[0] : event;
|
||||
rippleX = Math.round(clientX - rect.left);
|
||||
rippleY = Math.round(clientY - rect.top);
|
||||
}
|
||||
if (center) {
|
||||
rippleSize = Math.sqrt((2 * rect.width ** 2 + rect.height ** 2) / 3);
|
||||
|
||||
// For some reason the animation is broken on Mobile Chrome if the size is even.
|
||||
if (rippleSize % 2 === 0) {
|
||||
rippleSize += 1;
|
||||
}
|
||||
} else {
|
||||
const sizeX = Math.max(Math.abs((element ? element.clientWidth : 0) - rippleX), rippleX) * 2 + 2;
|
||||
const sizeY = Math.max(Math.abs((element ? element.clientHeight : 0) - rippleY), rippleY) * 2 + 2;
|
||||
rippleSize = Math.sqrt(sizeX ** 2 + sizeY ** 2);
|
||||
}
|
||||
|
||||
// Touche devices
|
||||
if (event != null && event.touches) {
|
||||
// check that this isn't another touchstart due to multitouch
|
||||
// otherwise we will only clear a single timer when unmounting while two
|
||||
// are running
|
||||
if (startTimerCommit.current === null) {
|
||||
// Prepare the ripple effect.
|
||||
startTimerCommit.current = () => {
|
||||
startCommit({
|
||||
pulsate,
|
||||
rippleX,
|
||||
rippleY,
|
||||
rippleSize,
|
||||
cb
|
||||
});
|
||||
};
|
||||
// Delay the execution of the ripple effect.
|
||||
// We have to make a tradeoff with this delay value.
|
||||
startTimer.start(DELAY_RIPPLE, () => {
|
||||
if (startTimerCommit.current) {
|
||||
startTimerCommit.current();
|
||||
startTimerCommit.current = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
startCommit({
|
||||
pulsate,
|
||||
rippleX,
|
||||
rippleY,
|
||||
rippleSize,
|
||||
cb
|
||||
});
|
||||
}
|
||||
}, [centerProp, startCommit, startTimer]);
|
||||
const pulsate = React.useCallback(() => {
|
||||
start({}, {
|
||||
pulsate: true
|
||||
});
|
||||
}, [start]);
|
||||
const stop = React.useCallback((event, cb) => {
|
||||
startTimer.clear();
|
||||
|
||||
// The touch interaction occurs too quickly.
|
||||
// We still want to show ripple effect.
|
||||
if ((event == null ? void 0 : event.type) === 'touchend' && startTimerCommit.current) {
|
||||
startTimerCommit.current();
|
||||
startTimerCommit.current = null;
|
||||
startTimer.start(0, () => {
|
||||
stop(event, cb);
|
||||
});
|
||||
return;
|
||||
}
|
||||
startTimerCommit.current = null;
|
||||
setRipples(oldRipples => {
|
||||
if (oldRipples.length > 0) {
|
||||
return oldRipples.slice(1);
|
||||
}
|
||||
return oldRipples;
|
||||
});
|
||||
rippleCallback.current = cb;
|
||||
}, [startTimer]);
|
||||
React.useImperativeHandle(ref, () => ({
|
||||
pulsate,
|
||||
start,
|
||||
stop
|
||||
}), [pulsate, start, stop]);
|
||||
return /*#__PURE__*/_jsx(TouchRippleRoot, _extends({
|
||||
className: clsx(touchRippleClasses.root, classes.root, className),
|
||||
ref: container
|
||||
}, other, {
|
||||
children: /*#__PURE__*/_jsx(TransitionGroup, {
|
||||
component: null,
|
||||
exit: true,
|
||||
children: ripples
|
||||
})
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? TouchRipple.propTypes = {
|
||||
/**
|
||||
* If `true`, the ripple starts at the center of the component
|
||||
* rather than at the point of interaction.
|
||||
*/
|
||||
center: PropTypes.bool,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string
|
||||
} : void 0;
|
||||
export default TouchRipple;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getButtonBaseUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiButtonBase', slot);
|
||||
}
|
||||
const buttonBaseClasses = generateUtilityClasses('MuiButtonBase', ['root', 'disabled', 'focusVisible']);
|
||||
export default buttonBaseClasses;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getTouchRippleUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiTouchRipple', slot);
|
||||
}
|
||||
const touchRippleClasses = generateUtilityClasses('MuiTouchRipple', ['root', 'ripple', 'rippleVisible', 'ripplePulsate', 'child', 'childLeaving', 'childPulsate']);
|
||||
export default touchRippleClasses;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import * as React from 'react';
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
const ButtonGroupButtonContext = /*#__PURE__*/React.createContext(undefined);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ButtonGroupButtonContext.displayName = 'ButtonGroupButtonContext';
|
||||
}
|
||||
export default ButtonGroupButtonContext;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import * as React from 'react';
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
const ButtonGroupContext = /*#__PURE__*/React.createContext({});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ButtonGroupContext.displayName = 'ButtonGroupContext';
|
||||
}
|
||||
export default ButtonGroupContext;
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["className", "raised"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import chainPropTypes from '@mui/utils/chainPropTypes';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import Paper from '../Paper';
|
||||
import { getCardUtilityClass } from './cardClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root']
|
||||
};
|
||||
return composeClasses(slots, getCardUtilityClass, classes);
|
||||
};
|
||||
const CardRoot = styled(Paper, {
|
||||
name: 'MuiCard',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => styles.root
|
||||
})(() => {
|
||||
return {
|
||||
overflow: 'hidden'
|
||||
};
|
||||
});
|
||||
const Card = /*#__PURE__*/React.forwardRef(function Card(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiCard'
|
||||
});
|
||||
const {
|
||||
className,
|
||||
raised = false
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
raised
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(CardRoot, _extends({
|
||||
className: clsx(classes.root, className),
|
||||
elevation: raised ? 8 : undefined,
|
||||
ref: ref,
|
||||
ownerState: ownerState
|
||||
}, other));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Card.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the card will use raised styling.
|
||||
* @default false
|
||||
*/
|
||||
raised: chainPropTypes(PropTypes.bool, props => {
|
||||
if (props.raised && props.variant === 'outlined') {
|
||||
return new Error('MUI: Combining `raised={true}` with `variant="outlined"` has no effect.');
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default Card;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getCardUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiCard', slot);
|
||||
}
|
||||
const cardClasses = generateUtilityClasses('MuiCard', ['root']);
|
||||
export default cardClasses;
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["children", "className", "focusVisibleClassName"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import styled from '../styles/styled';
|
||||
import cardActionAreaClasses, { getCardActionAreaUtilityClass } from './cardActionAreaClasses';
|
||||
import ButtonBase from '../ButtonBase';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root'],
|
||||
focusHighlight: ['focusHighlight']
|
||||
};
|
||||
return composeClasses(slots, getCardActionAreaUtilityClass, classes);
|
||||
};
|
||||
const CardActionAreaRoot = styled(ButtonBase, {
|
||||
name: 'MuiCardActionArea',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => styles.root
|
||||
})(({
|
||||
theme
|
||||
}) => ({
|
||||
display: 'block',
|
||||
textAlign: 'inherit',
|
||||
borderRadius: 'inherit',
|
||||
// for Safari to work https://github.com/mui/material-ui/issues/36285.
|
||||
width: '100%',
|
||||
[`&:hover .${cardActionAreaClasses.focusHighlight}`]: {
|
||||
opacity: (theme.vars || theme).palette.action.hoverOpacity,
|
||||
'@media (hover: none)': {
|
||||
opacity: 0
|
||||
}
|
||||
},
|
||||
[`&.${cardActionAreaClasses.focusVisible} .${cardActionAreaClasses.focusHighlight}`]: {
|
||||
opacity: (theme.vars || theme).palette.action.focusOpacity
|
||||
}
|
||||
}));
|
||||
const CardActionAreaFocusHighlight = styled('span', {
|
||||
name: 'MuiCardActionArea',
|
||||
slot: 'FocusHighlight',
|
||||
overridesResolver: (props, styles) => styles.focusHighlight
|
||||
})(({
|
||||
theme
|
||||
}) => ({
|
||||
overflow: 'hidden',
|
||||
pointerEvents: 'none',
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
borderRadius: 'inherit',
|
||||
opacity: 0,
|
||||
backgroundColor: 'currentcolor',
|
||||
transition: theme.transitions.create('opacity', {
|
||||
duration: theme.transitions.duration.short
|
||||
})
|
||||
}));
|
||||
const CardActionArea = /*#__PURE__*/React.forwardRef(function CardActionArea(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiCardActionArea'
|
||||
});
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
focusVisibleClassName
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = props;
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsxs(CardActionAreaRoot, _extends({
|
||||
className: clsx(classes.root, className),
|
||||
focusVisibleClassName: clsx(focusVisibleClassName, classes.focusVisible),
|
||||
ref: ref,
|
||||
ownerState: ownerState
|
||||
}, other, {
|
||||
children: [children, /*#__PURE__*/_jsx(CardActionAreaFocusHighlight, {
|
||||
className: classes.focusHighlight,
|
||||
ownerState: ownerState
|
||||
})]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? CardActionArea.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
focusVisibleClassName: PropTypes.string,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default CardActionArea;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getCardActionAreaUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiCardActionArea', slot);
|
||||
}
|
||||
const cardActionAreaClasses = generateUtilityClasses('MuiCardActionArea', ['root', 'focusVisible', 'focusHighlight']);
|
||||
export default cardActionAreaClasses;
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["disableSpacing", "className"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import { getCardActionsUtilityClass } from './cardActionsClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
disableSpacing
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', !disableSpacing && 'spacing']
|
||||
};
|
||||
return composeClasses(slots, getCardActionsUtilityClass, classes);
|
||||
};
|
||||
const CardActionsRoot = styled('div', {
|
||||
name: 'MuiCardActions',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, !ownerState.disableSpacing && styles.spacing];
|
||||
}
|
||||
})(({
|
||||
ownerState
|
||||
}) => _extends({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
padding: 8
|
||||
}, !ownerState.disableSpacing && {
|
||||
'& > :not(style) ~ :not(style)': {
|
||||
marginLeft: 8
|
||||
}
|
||||
}));
|
||||
const CardActions = /*#__PURE__*/React.forwardRef(function CardActions(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiCardActions'
|
||||
});
|
||||
const {
|
||||
disableSpacing = false,
|
||||
className
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
disableSpacing
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(CardActionsRoot, _extends({
|
||||
className: clsx(classes.root, className),
|
||||
ownerState: ownerState,
|
||||
ref: ref
|
||||
}, other));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? CardActions.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the actions do not have additional margin.
|
||||
* @default false
|
||||
*/
|
||||
disableSpacing: PropTypes.bool,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default CardActions;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getCardActionsUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiCardActions', slot);
|
||||
}
|
||||
const cardActionsClasses = generateUtilityClasses('MuiCardActions', ['root', 'spacing']);
|
||||
export default cardActionsClasses;
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["className", "component"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import { getCardContentUtilityClass } from './cardContentClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root']
|
||||
};
|
||||
return composeClasses(slots, getCardContentUtilityClass, classes);
|
||||
};
|
||||
const CardContentRoot = styled('div', {
|
||||
name: 'MuiCardContent',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => styles.root
|
||||
})(() => {
|
||||
return {
|
||||
padding: 16,
|
||||
'&:last-child': {
|
||||
paddingBottom: 24
|
||||
}
|
||||
};
|
||||
});
|
||||
const CardContent = /*#__PURE__*/React.forwardRef(function CardContent(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiCardContent'
|
||||
});
|
||||
const {
|
||||
className,
|
||||
component = 'div'
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
component
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(CardContentRoot, _extends({
|
||||
as: component,
|
||||
className: clsx(classes.root, className),
|
||||
ownerState: ownerState,
|
||||
ref: ref
|
||||
}, other));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? CardContent.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: PropTypes.elementType,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default CardContent;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getCardContentUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiCardContent', slot);
|
||||
}
|
||||
const cardContentClasses = generateUtilityClasses('MuiCardContent', ['root']);
|
||||
export default cardContentClasses;
|
||||
+196
@@ -0,0 +1,196 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["action", "avatar", "className", "component", "disableTypography", "subheader", "subheaderTypographyProps", "title", "titleTypographyProps"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import Typography from '../Typography';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import styled from '../styles/styled';
|
||||
import cardHeaderClasses, { getCardHeaderUtilityClass } from './cardHeaderClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root'],
|
||||
avatar: ['avatar'],
|
||||
action: ['action'],
|
||||
content: ['content'],
|
||||
title: ['title'],
|
||||
subheader: ['subheader']
|
||||
};
|
||||
return composeClasses(slots, getCardHeaderUtilityClass, classes);
|
||||
};
|
||||
const CardHeaderRoot = styled('div', {
|
||||
name: 'MuiCardHeader',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => _extends({
|
||||
[`& .${cardHeaderClasses.title}`]: styles.title,
|
||||
[`& .${cardHeaderClasses.subheader}`]: styles.subheader
|
||||
}, styles.root)
|
||||
})({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
padding: 16
|
||||
});
|
||||
const CardHeaderAvatar = styled('div', {
|
||||
name: 'MuiCardHeader',
|
||||
slot: 'Avatar',
|
||||
overridesResolver: (props, styles) => styles.avatar
|
||||
})({
|
||||
display: 'flex',
|
||||
flex: '0 0 auto',
|
||||
marginRight: 16
|
||||
});
|
||||
const CardHeaderAction = styled('div', {
|
||||
name: 'MuiCardHeader',
|
||||
slot: 'Action',
|
||||
overridesResolver: (props, styles) => styles.action
|
||||
})({
|
||||
flex: '0 0 auto',
|
||||
alignSelf: 'flex-start',
|
||||
marginTop: -4,
|
||||
marginRight: -8,
|
||||
marginBottom: -4
|
||||
});
|
||||
const CardHeaderContent = styled('div', {
|
||||
name: 'MuiCardHeader',
|
||||
slot: 'Content',
|
||||
overridesResolver: (props, styles) => styles.content
|
||||
})({
|
||||
flex: '1 1 auto'
|
||||
});
|
||||
const CardHeader = /*#__PURE__*/React.forwardRef(function CardHeader(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiCardHeader'
|
||||
});
|
||||
const {
|
||||
action,
|
||||
avatar,
|
||||
className,
|
||||
component = 'div',
|
||||
disableTypography = false,
|
||||
subheader: subheaderProp,
|
||||
subheaderTypographyProps,
|
||||
title: titleProp,
|
||||
titleTypographyProps
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
component,
|
||||
disableTypography
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
let title = titleProp;
|
||||
if (title != null && title.type !== Typography && !disableTypography) {
|
||||
title = /*#__PURE__*/_jsx(Typography, _extends({
|
||||
variant: avatar ? 'body2' : 'h5',
|
||||
className: classes.title,
|
||||
component: "span",
|
||||
display: "block"
|
||||
}, titleTypographyProps, {
|
||||
children: title
|
||||
}));
|
||||
}
|
||||
let subheader = subheaderProp;
|
||||
if (subheader != null && subheader.type !== Typography && !disableTypography) {
|
||||
subheader = /*#__PURE__*/_jsx(Typography, _extends({
|
||||
variant: avatar ? 'body2' : 'body1',
|
||||
className: classes.subheader,
|
||||
color: "text.secondary",
|
||||
component: "span",
|
||||
display: "block"
|
||||
}, subheaderTypographyProps, {
|
||||
children: subheader
|
||||
}));
|
||||
}
|
||||
return /*#__PURE__*/_jsxs(CardHeaderRoot, _extends({
|
||||
className: clsx(classes.root, className),
|
||||
as: component,
|
||||
ref: ref,
|
||||
ownerState: ownerState
|
||||
}, other, {
|
||||
children: [avatar && /*#__PURE__*/_jsx(CardHeaderAvatar, {
|
||||
className: classes.avatar,
|
||||
ownerState: ownerState,
|
||||
children: avatar
|
||||
}), /*#__PURE__*/_jsxs(CardHeaderContent, {
|
||||
className: classes.content,
|
||||
ownerState: ownerState,
|
||||
children: [title, subheader]
|
||||
}), action && /*#__PURE__*/_jsx(CardHeaderAction, {
|
||||
className: classes.action,
|
||||
ownerState: ownerState,
|
||||
children: action
|
||||
})]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The action to display in the card header.
|
||||
*/
|
||||
action: PropTypes.node,
|
||||
/**
|
||||
* The Avatar element to display.
|
||||
*/
|
||||
avatar: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: PropTypes.elementType,
|
||||
/**
|
||||
* If `true`, `subheader` and `title` won't be wrapped by a Typography component.
|
||||
* This can be useful to render an alternative Typography variant by wrapping
|
||||
* the `title` text, and optional `subheader` text
|
||||
* with the Typography component.
|
||||
* @default false
|
||||
*/
|
||||
disableTypography: PropTypes.bool,
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
subheader: PropTypes.node,
|
||||
/**
|
||||
* These props will be forwarded to the subheader
|
||||
* (as long as disableTypography is not `true`).
|
||||
*/
|
||||
subheaderTypographyProps: PropTypes.object,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
title: PropTypes.node,
|
||||
/**
|
||||
* These props will be forwarded to the title
|
||||
* (as long as disableTypography is not `true`).
|
||||
*/
|
||||
titleTypographyProps: PropTypes.object
|
||||
} : void 0;
|
||||
export default CardHeader;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getCardHeaderUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiCardHeader', slot);
|
||||
}
|
||||
const cardHeaderClasses = generateUtilityClasses('MuiCardHeader', ['root', 'avatar', 'action', 'content', 'title', 'subheader']);
|
||||
export default cardHeaderClasses;
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["checkedIcon", "color", "icon", "indeterminate", "indeterminateIcon", "inputProps", "size", "className"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import refType from '@mui/utils/refType';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import { alpha } from '@mui/system/colorManipulator';
|
||||
import SwitchBase from '../internal/SwitchBase';
|
||||
import CheckBoxOutlineBlankIcon from '../internal/svg-icons/CheckBoxOutlineBlank';
|
||||
import CheckBoxIcon from '../internal/svg-icons/CheckBox';
|
||||
import IndeterminateCheckBoxIcon from '../internal/svg-icons/IndeterminateCheckBox';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import styled, { rootShouldForwardProp } from '../styles/styled';
|
||||
import checkboxClasses, { getCheckboxUtilityClass } from './checkboxClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
indeterminate,
|
||||
color,
|
||||
size
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', indeterminate && 'indeterminate', `color${capitalize(color)}`, `size${capitalize(size)}`]
|
||||
};
|
||||
const composedClasses = composeClasses(slots, getCheckboxUtilityClass, classes);
|
||||
return _extends({}, classes, composedClasses);
|
||||
};
|
||||
const CheckboxRoot = styled(SwitchBase, {
|
||||
shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
|
||||
name: 'MuiCheckbox',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, ownerState.indeterminate && styles.indeterminate, styles[`size${capitalize(ownerState.size)}`], ownerState.color !== 'default' && styles[`color${capitalize(ownerState.color)}`]];
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => _extends({
|
||||
color: (theme.vars || theme).palette.text.secondary
|
||||
}, !ownerState.disableRipple && {
|
||||
'&:hover': {
|
||||
backgroundColor: theme.vars ? `rgba(${ownerState.color === 'default' ? theme.vars.palette.action.activeChannel : theme.vars.palette[ownerState.color].mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(ownerState.color === 'default' ? theme.palette.action.active : theme.palette[ownerState.color].main, theme.palette.action.hoverOpacity),
|
||||
// Reset on touch devices, it doesn't add specificity
|
||||
'@media (hover: none)': {
|
||||
backgroundColor: 'transparent'
|
||||
}
|
||||
}
|
||||
}, ownerState.color !== 'default' && {
|
||||
[`&.${checkboxClasses.checked}, &.${checkboxClasses.indeterminate}`]: {
|
||||
color: (theme.vars || theme).palette[ownerState.color].main
|
||||
},
|
||||
[`&.${checkboxClasses.disabled}`]: {
|
||||
color: (theme.vars || theme).palette.action.disabled
|
||||
}
|
||||
}));
|
||||
const defaultCheckedIcon = /*#__PURE__*/_jsx(CheckBoxIcon, {});
|
||||
const defaultIcon = /*#__PURE__*/_jsx(CheckBoxOutlineBlankIcon, {});
|
||||
const defaultIndeterminateIcon = /*#__PURE__*/_jsx(IndeterminateCheckBoxIcon, {});
|
||||
const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(inProps, ref) {
|
||||
var _icon$props$fontSize, _indeterminateIcon$pr;
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiCheckbox'
|
||||
});
|
||||
const {
|
||||
checkedIcon = defaultCheckedIcon,
|
||||
color = 'primary',
|
||||
icon: iconProp = defaultIcon,
|
||||
indeterminate = false,
|
||||
indeterminateIcon: indeterminateIconProp = defaultIndeterminateIcon,
|
||||
inputProps,
|
||||
size = 'medium',
|
||||
className
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const icon = indeterminate ? indeterminateIconProp : iconProp;
|
||||
const indeterminateIcon = indeterminate ? indeterminateIconProp : checkedIcon;
|
||||
const ownerState = _extends({}, props, {
|
||||
color,
|
||||
indeterminate,
|
||||
size
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(CheckboxRoot, _extends({
|
||||
type: "checkbox",
|
||||
inputProps: _extends({
|
||||
'data-indeterminate': indeterminate
|
||||
}, inputProps),
|
||||
icon: /*#__PURE__*/React.cloneElement(icon, {
|
||||
fontSize: (_icon$props$fontSize = icon.props.fontSize) != null ? _icon$props$fontSize : size
|
||||
}),
|
||||
checkedIcon: /*#__PURE__*/React.cloneElement(indeterminateIcon, {
|
||||
fontSize: (_indeterminateIcon$pr = indeterminateIcon.props.fontSize) != null ? _indeterminateIcon$pr : size
|
||||
}),
|
||||
ownerState: ownerState,
|
||||
ref: ref,
|
||||
className: clsx(classes.root, className)
|
||||
}, other, {
|
||||
classes: classes
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Checkbox.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* If `true`, the component is checked.
|
||||
*/
|
||||
checked: PropTypes.bool,
|
||||
/**
|
||||
* The icon to display when the component is checked.
|
||||
* @default <CheckBoxIcon />
|
||||
*/
|
||||
checkedIcon: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
* @default 'primary'
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['default', 'primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
||||
/**
|
||||
* The default checked state. Use when the component is not controlled.
|
||||
*/
|
||||
defaultChecked: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the ripple effect is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disableRipple: PropTypes.bool,
|
||||
/**
|
||||
* The icon to display when the component is unchecked.
|
||||
* @default <CheckBoxOutlineBlankIcon />
|
||||
*/
|
||||
icon: PropTypes.node,
|
||||
/**
|
||||
* The id of the `input` element.
|
||||
*/
|
||||
id: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the component appears indeterminate.
|
||||
* This does not set the native input element to indeterminate due
|
||||
* to inconsistent behavior across browsers.
|
||||
* However, we set a `data-indeterminate` attribute on the `input`.
|
||||
* @default false
|
||||
*/
|
||||
indeterminate: PropTypes.bool,
|
||||
/**
|
||||
* The icon to display when the component is indeterminate.
|
||||
* @default <IndeterminateCheckBoxIcon />
|
||||
*/
|
||||
indeterminateIcon: PropTypes.node,
|
||||
/**
|
||||
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
||||
*/
|
||||
inputProps: PropTypes.object,
|
||||
/**
|
||||
* Pass a ref to the `input` element.
|
||||
*/
|
||||
inputRef: refType,
|
||||
/**
|
||||
* Callback fired when the state is changed.
|
||||
*
|
||||
* @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
|
||||
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* If `true`, the `input` element is required.
|
||||
* @default false
|
||||
*/
|
||||
required: PropTypes.bool,
|
||||
/**
|
||||
* The size of the component.
|
||||
* `small` is equivalent to the dense checkbox styling.
|
||||
* @default 'medium'
|
||||
*/
|
||||
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* The value of the component. The DOM API casts this to a string.
|
||||
* The browser uses "on" as the default value.
|
||||
*/
|
||||
value: PropTypes.any
|
||||
} : void 0;
|
||||
export default Checkbox;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getCheckboxUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiCheckbox', slot);
|
||||
}
|
||||
const checkboxClasses = generateUtilityClasses('MuiCheckbox', ['root', 'checked', 'disabled', 'indeterminate', 'colorPrimary', 'colorSecondary', 'sizeSmall', 'sizeMedium']);
|
||||
export default checkboxClasses;
|
||||
+506
@@ -0,0 +1,506 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["avatar", "className", "clickable", "color", "component", "deleteIcon", "disabled", "icon", "label", "onClick", "onDelete", "onKeyDown", "onKeyUp", "size", "variant", "tabIndex", "skipFocusWhenDisabled"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import { alpha } from '@mui/system/colorManipulator';
|
||||
import CancelIcon from '../internal/svg-icons/Cancel';
|
||||
import useForkRef from '../utils/useForkRef';
|
||||
import unsupportedProp from '../utils/unsupportedProp';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import ButtonBase from '../ButtonBase';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import styled from '../styles/styled';
|
||||
import chipClasses, { getChipUtilityClass } from './chipClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
disabled,
|
||||
size,
|
||||
color,
|
||||
iconColor,
|
||||
onDelete,
|
||||
clickable,
|
||||
variant
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', variant, disabled && 'disabled', `size${capitalize(size)}`, `color${capitalize(color)}`, clickable && 'clickable', clickable && `clickableColor${capitalize(color)}`, onDelete && 'deletable', onDelete && `deletableColor${capitalize(color)}`, `${variant}${capitalize(color)}`],
|
||||
label: ['label', `label${capitalize(size)}`],
|
||||
avatar: ['avatar', `avatar${capitalize(size)}`, `avatarColor${capitalize(color)}`],
|
||||
icon: ['icon', `icon${capitalize(size)}`, `iconColor${capitalize(iconColor)}`],
|
||||
deleteIcon: ['deleteIcon', `deleteIcon${capitalize(size)}`, `deleteIconColor${capitalize(color)}`, `deleteIcon${capitalize(variant)}Color${capitalize(color)}`]
|
||||
};
|
||||
return composeClasses(slots, getChipUtilityClass, classes);
|
||||
};
|
||||
const ChipRoot = styled('div', {
|
||||
name: 'MuiChip',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
const {
|
||||
color,
|
||||
iconColor,
|
||||
clickable,
|
||||
onDelete,
|
||||
size,
|
||||
variant
|
||||
} = ownerState;
|
||||
return [{
|
||||
[`& .${chipClasses.avatar}`]: styles.avatar
|
||||
}, {
|
||||
[`& .${chipClasses.avatar}`]: styles[`avatar${capitalize(size)}`]
|
||||
}, {
|
||||
[`& .${chipClasses.avatar}`]: styles[`avatarColor${capitalize(color)}`]
|
||||
}, {
|
||||
[`& .${chipClasses.icon}`]: styles.icon
|
||||
}, {
|
||||
[`& .${chipClasses.icon}`]: styles[`icon${capitalize(size)}`]
|
||||
}, {
|
||||
[`& .${chipClasses.icon}`]: styles[`iconColor${capitalize(iconColor)}`]
|
||||
}, {
|
||||
[`& .${chipClasses.deleteIcon}`]: styles.deleteIcon
|
||||
}, {
|
||||
[`& .${chipClasses.deleteIcon}`]: styles[`deleteIcon${capitalize(size)}`]
|
||||
}, {
|
||||
[`& .${chipClasses.deleteIcon}`]: styles[`deleteIconColor${capitalize(color)}`]
|
||||
}, {
|
||||
[`& .${chipClasses.deleteIcon}`]: styles[`deleteIcon${capitalize(variant)}Color${capitalize(color)}`]
|
||||
}, styles.root, styles[`size${capitalize(size)}`], styles[`color${capitalize(color)}`], clickable && styles.clickable, clickable && color !== 'default' && styles[`clickableColor${capitalize(color)})`], onDelete && styles.deletable, onDelete && color !== 'default' && styles[`deletableColor${capitalize(color)}`], styles[variant], styles[`${variant}${capitalize(color)}`]];
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => {
|
||||
const textColor = theme.palette.mode === 'light' ? theme.palette.grey[700] : theme.palette.grey[300];
|
||||
return _extends({
|
||||
maxWidth: '100%',
|
||||
fontFamily: theme.typography.fontFamily,
|
||||
fontSize: theme.typography.pxToRem(13),
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
height: 32,
|
||||
color: (theme.vars || theme).palette.text.primary,
|
||||
backgroundColor: (theme.vars || theme).palette.action.selected,
|
||||
borderRadius: 32 / 2,
|
||||
whiteSpace: 'nowrap',
|
||||
transition: theme.transitions.create(['background-color', 'box-shadow']),
|
||||
// reset cursor explicitly in case ButtonBase is used
|
||||
cursor: 'unset',
|
||||
// We disable the focus ring for mouse, touch and keyboard users.
|
||||
outline: 0,
|
||||
textDecoration: 'none',
|
||||
border: 0,
|
||||
// Remove `button` border
|
||||
padding: 0,
|
||||
// Remove `button` padding
|
||||
verticalAlign: 'middle',
|
||||
boxSizing: 'border-box',
|
||||
[`&.${chipClasses.disabled}`]: {
|
||||
opacity: (theme.vars || theme).palette.action.disabledOpacity,
|
||||
pointerEvents: 'none'
|
||||
},
|
||||
[`& .${chipClasses.avatar}`]: {
|
||||
marginLeft: 5,
|
||||
marginRight: -6,
|
||||
width: 24,
|
||||
height: 24,
|
||||
color: theme.vars ? theme.vars.palette.Chip.defaultAvatarColor : textColor,
|
||||
fontSize: theme.typography.pxToRem(12)
|
||||
},
|
||||
[`& .${chipClasses.avatarColorPrimary}`]: {
|
||||
color: (theme.vars || theme).palette.primary.contrastText,
|
||||
backgroundColor: (theme.vars || theme).palette.primary.dark
|
||||
},
|
||||
[`& .${chipClasses.avatarColorSecondary}`]: {
|
||||
color: (theme.vars || theme).palette.secondary.contrastText,
|
||||
backgroundColor: (theme.vars || theme).palette.secondary.dark
|
||||
},
|
||||
[`& .${chipClasses.avatarSmall}`]: {
|
||||
marginLeft: 4,
|
||||
marginRight: -4,
|
||||
width: 18,
|
||||
height: 18,
|
||||
fontSize: theme.typography.pxToRem(10)
|
||||
},
|
||||
[`& .${chipClasses.icon}`]: _extends({
|
||||
marginLeft: 5,
|
||||
marginRight: -6
|
||||
}, ownerState.size === 'small' && {
|
||||
fontSize: 18,
|
||||
marginLeft: 4,
|
||||
marginRight: -4
|
||||
}, ownerState.iconColor === ownerState.color && _extends({
|
||||
color: theme.vars ? theme.vars.palette.Chip.defaultIconColor : textColor
|
||||
}, ownerState.color !== 'default' && {
|
||||
color: 'inherit'
|
||||
})),
|
||||
[`& .${chipClasses.deleteIcon}`]: _extends({
|
||||
WebkitTapHighlightColor: 'transparent',
|
||||
color: theme.vars ? `rgba(${theme.vars.palette.text.primaryChannel} / 0.26)` : alpha(theme.palette.text.primary, 0.26),
|
||||
fontSize: 22,
|
||||
cursor: 'pointer',
|
||||
margin: '0 5px 0 -6px',
|
||||
'&:hover': {
|
||||
color: theme.vars ? `rgba(${theme.vars.palette.text.primaryChannel} / 0.4)` : alpha(theme.palette.text.primary, 0.4)
|
||||
}
|
||||
}, ownerState.size === 'small' && {
|
||||
fontSize: 16,
|
||||
marginRight: 4,
|
||||
marginLeft: -4
|
||||
}, ownerState.color !== 'default' && {
|
||||
color: theme.vars ? `rgba(${theme.vars.palette[ownerState.color].contrastTextChannel} / 0.7)` : alpha(theme.palette[ownerState.color].contrastText, 0.7),
|
||||
'&:hover, &:active': {
|
||||
color: (theme.vars || theme).palette[ownerState.color].contrastText
|
||||
}
|
||||
})
|
||||
}, ownerState.size === 'small' && {
|
||||
height: 24
|
||||
}, ownerState.color !== 'default' && {
|
||||
backgroundColor: (theme.vars || theme).palette[ownerState.color].main,
|
||||
color: (theme.vars || theme).palette[ownerState.color].contrastText
|
||||
}, ownerState.onDelete && {
|
||||
[`&.${chipClasses.focusVisible}`]: {
|
||||
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.action.selectedChannel} / calc(${theme.vars.palette.action.selectedOpacity} + ${theme.vars.palette.action.focusOpacity}))` : alpha(theme.palette.action.selected, theme.palette.action.selectedOpacity + theme.palette.action.focusOpacity)
|
||||
}
|
||||
}, ownerState.onDelete && ownerState.color !== 'default' && {
|
||||
[`&.${chipClasses.focusVisible}`]: {
|
||||
backgroundColor: (theme.vars || theme).palette[ownerState.color].dark
|
||||
}
|
||||
});
|
||||
}, ({
|
||||
theme,
|
||||
ownerState
|
||||
}) => _extends({}, ownerState.clickable && {
|
||||
userSelect: 'none',
|
||||
WebkitTapHighlightColor: 'transparent',
|
||||
cursor: 'pointer',
|
||||
'&:hover': {
|
||||
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.action.selectedChannel} / calc(${theme.vars.palette.action.selectedOpacity} + ${theme.vars.palette.action.hoverOpacity}))` : alpha(theme.palette.action.selected, theme.palette.action.selectedOpacity + theme.palette.action.hoverOpacity)
|
||||
},
|
||||
[`&.${chipClasses.focusVisible}`]: {
|
||||
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.action.selectedChannel} / calc(${theme.vars.palette.action.selectedOpacity} + ${theme.vars.palette.action.focusOpacity}))` : alpha(theme.palette.action.selected, theme.palette.action.selectedOpacity + theme.palette.action.focusOpacity)
|
||||
},
|
||||
'&:active': {
|
||||
boxShadow: (theme.vars || theme).shadows[1]
|
||||
}
|
||||
}, ownerState.clickable && ownerState.color !== 'default' && {
|
||||
[`&:hover, &.${chipClasses.focusVisible}`]: {
|
||||
backgroundColor: (theme.vars || theme).palette[ownerState.color].dark
|
||||
}
|
||||
}), ({
|
||||
theme,
|
||||
ownerState
|
||||
}) => _extends({}, ownerState.variant === 'outlined' && {
|
||||
backgroundColor: 'transparent',
|
||||
border: theme.vars ? `1px solid ${theme.vars.palette.Chip.defaultBorder}` : `1px solid ${theme.palette.mode === 'light' ? theme.palette.grey[400] : theme.palette.grey[700]}`,
|
||||
[`&.${chipClasses.clickable}:hover`]: {
|
||||
backgroundColor: (theme.vars || theme).palette.action.hover
|
||||
},
|
||||
[`&.${chipClasses.focusVisible}`]: {
|
||||
backgroundColor: (theme.vars || theme).palette.action.focus
|
||||
},
|
||||
[`& .${chipClasses.avatar}`]: {
|
||||
marginLeft: 4
|
||||
},
|
||||
[`& .${chipClasses.avatarSmall}`]: {
|
||||
marginLeft: 2
|
||||
},
|
||||
[`& .${chipClasses.icon}`]: {
|
||||
marginLeft: 4
|
||||
},
|
||||
[`& .${chipClasses.iconSmall}`]: {
|
||||
marginLeft: 2
|
||||
},
|
||||
[`& .${chipClasses.deleteIcon}`]: {
|
||||
marginRight: 5
|
||||
},
|
||||
[`& .${chipClasses.deleteIconSmall}`]: {
|
||||
marginRight: 3
|
||||
}
|
||||
}, ownerState.variant === 'outlined' && ownerState.color !== 'default' && {
|
||||
color: (theme.vars || theme).palette[ownerState.color].main,
|
||||
border: `1px solid ${theme.vars ? `rgba(${theme.vars.palette[ownerState.color].mainChannel} / 0.7)` : alpha(theme.palette[ownerState.color].main, 0.7)}`,
|
||||
[`&.${chipClasses.clickable}:hover`]: {
|
||||
backgroundColor: theme.vars ? `rgba(${theme.vars.palette[ownerState.color].mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette[ownerState.color].main, theme.palette.action.hoverOpacity)
|
||||
},
|
||||
[`&.${chipClasses.focusVisible}`]: {
|
||||
backgroundColor: theme.vars ? `rgba(${theme.vars.palette[ownerState.color].mainChannel} / ${theme.vars.palette.action.focusOpacity})` : alpha(theme.palette[ownerState.color].main, theme.palette.action.focusOpacity)
|
||||
},
|
||||
[`& .${chipClasses.deleteIcon}`]: {
|
||||
color: theme.vars ? `rgba(${theme.vars.palette[ownerState.color].mainChannel} / 0.7)` : alpha(theme.palette[ownerState.color].main, 0.7),
|
||||
'&:hover, &:active': {
|
||||
color: (theme.vars || theme).palette[ownerState.color].main
|
||||
}
|
||||
}
|
||||
}));
|
||||
const ChipLabel = styled('span', {
|
||||
name: 'MuiChip',
|
||||
slot: 'Label',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
const {
|
||||
size
|
||||
} = ownerState;
|
||||
return [styles.label, styles[`label${capitalize(size)}`]];
|
||||
}
|
||||
})(({
|
||||
ownerState
|
||||
}) => _extends({
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
paddingLeft: 12,
|
||||
paddingRight: 12,
|
||||
whiteSpace: 'nowrap'
|
||||
}, ownerState.variant === 'outlined' && {
|
||||
paddingLeft: 11,
|
||||
paddingRight: 11
|
||||
}, ownerState.size === 'small' && {
|
||||
paddingLeft: 8,
|
||||
paddingRight: 8
|
||||
}, ownerState.size === 'small' && ownerState.variant === 'outlined' && {
|
||||
paddingLeft: 7,
|
||||
paddingRight: 7
|
||||
}));
|
||||
function isDeleteKeyboardEvent(keyboardEvent) {
|
||||
return keyboardEvent.key === 'Backspace' || keyboardEvent.key === 'Delete';
|
||||
}
|
||||
|
||||
/**
|
||||
* Chips represent complex entities in small blocks, such as a contact.
|
||||
*/
|
||||
const Chip = /*#__PURE__*/React.forwardRef(function Chip(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiChip'
|
||||
});
|
||||
const {
|
||||
avatar: avatarProp,
|
||||
className,
|
||||
clickable: clickableProp,
|
||||
color = 'default',
|
||||
component: ComponentProp,
|
||||
deleteIcon: deleteIconProp,
|
||||
disabled = false,
|
||||
icon: iconProp,
|
||||
label,
|
||||
onClick,
|
||||
onDelete,
|
||||
onKeyDown,
|
||||
onKeyUp,
|
||||
size = 'medium',
|
||||
variant = 'filled',
|
||||
tabIndex,
|
||||
skipFocusWhenDisabled = false // TODO v6: Rename to `focusableWhenDisabled`.
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const chipRef = React.useRef(null);
|
||||
const handleRef = useForkRef(chipRef, ref);
|
||||
const handleDeleteIconClick = event => {
|
||||
// Stop the event from bubbling up to the `Chip`
|
||||
event.stopPropagation();
|
||||
if (onDelete) {
|
||||
onDelete(event);
|
||||
}
|
||||
};
|
||||
const handleKeyDown = event => {
|
||||
// Ignore events from children of `Chip`.
|
||||
if (event.currentTarget === event.target && isDeleteKeyboardEvent(event)) {
|
||||
// Will be handled in keyUp, otherwise some browsers
|
||||
// might init navigation
|
||||
event.preventDefault();
|
||||
}
|
||||
if (onKeyDown) {
|
||||
onKeyDown(event);
|
||||
}
|
||||
};
|
||||
const handleKeyUp = event => {
|
||||
// Ignore events from children of `Chip`.
|
||||
if (event.currentTarget === event.target) {
|
||||
if (onDelete && isDeleteKeyboardEvent(event)) {
|
||||
onDelete(event);
|
||||
} else if (event.key === 'Escape' && chipRef.current) {
|
||||
chipRef.current.blur();
|
||||
}
|
||||
}
|
||||
if (onKeyUp) {
|
||||
onKeyUp(event);
|
||||
}
|
||||
};
|
||||
const clickable = clickableProp !== false && onClick ? true : clickableProp;
|
||||
const component = clickable || onDelete ? ButtonBase : ComponentProp || 'div';
|
||||
const ownerState = _extends({}, props, {
|
||||
component,
|
||||
disabled,
|
||||
size,
|
||||
color,
|
||||
iconColor: /*#__PURE__*/React.isValidElement(iconProp) ? iconProp.props.color || color : color,
|
||||
onDelete: !!onDelete,
|
||||
clickable,
|
||||
variant
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const moreProps = component === ButtonBase ? _extends({
|
||||
component: ComponentProp || 'div',
|
||||
focusVisibleClassName: classes.focusVisible
|
||||
}, onDelete && {
|
||||
disableRipple: true
|
||||
}) : {};
|
||||
let deleteIcon = null;
|
||||
if (onDelete) {
|
||||
deleteIcon = deleteIconProp && /*#__PURE__*/React.isValidElement(deleteIconProp) ? ( /*#__PURE__*/React.cloneElement(deleteIconProp, {
|
||||
className: clsx(deleteIconProp.props.className, classes.deleteIcon),
|
||||
onClick: handleDeleteIconClick
|
||||
})) : /*#__PURE__*/_jsx(CancelIcon, {
|
||||
className: clsx(classes.deleteIcon),
|
||||
onClick: handleDeleteIconClick
|
||||
});
|
||||
}
|
||||
let avatar = null;
|
||||
if (avatarProp && /*#__PURE__*/React.isValidElement(avatarProp)) {
|
||||
avatar = /*#__PURE__*/React.cloneElement(avatarProp, {
|
||||
className: clsx(classes.avatar, avatarProp.props.className)
|
||||
});
|
||||
}
|
||||
let icon = null;
|
||||
if (iconProp && /*#__PURE__*/React.isValidElement(iconProp)) {
|
||||
icon = /*#__PURE__*/React.cloneElement(iconProp, {
|
||||
className: clsx(classes.icon, iconProp.props.className)
|
||||
});
|
||||
}
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (avatar && icon) {
|
||||
console.error('MUI: The Chip component can not handle the avatar ' + 'and the icon prop at the same time. Pick one.');
|
||||
}
|
||||
}
|
||||
return /*#__PURE__*/_jsxs(ChipRoot, _extends({
|
||||
as: component,
|
||||
className: clsx(classes.root, className),
|
||||
disabled: clickable && disabled ? true : undefined,
|
||||
onClick: onClick,
|
||||
onKeyDown: handleKeyDown,
|
||||
onKeyUp: handleKeyUp,
|
||||
ref: handleRef,
|
||||
tabIndex: skipFocusWhenDisabled && disabled ? -1 : tabIndex,
|
||||
ownerState: ownerState
|
||||
}, moreProps, other, {
|
||||
children: [avatar || icon, /*#__PURE__*/_jsx(ChipLabel, {
|
||||
className: clsx(classes.label),
|
||||
ownerState: ownerState,
|
||||
children: label
|
||||
}), deleteIcon]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Chip.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The Avatar element to display.
|
||||
*/
|
||||
avatar: PropTypes.element,
|
||||
/**
|
||||
* This prop isn't supported.
|
||||
* Use the `component` prop if you need to change the children structure.
|
||||
*/
|
||||
children: unsupportedProp,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the chip will appear clickable, and will raise when pressed,
|
||||
* even if the onClick prop is not defined.
|
||||
* If `false`, the chip will not appear clickable, even if onClick prop is defined.
|
||||
* This can be used, for example,
|
||||
* along with the component prop to indicate an anchor Chip is clickable.
|
||||
* Note: this controls the UI and does not affect the onClick event.
|
||||
*/
|
||||
clickable: PropTypes.bool,
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
* @default 'default'
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['default', 'primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: PropTypes.elementType,
|
||||
/**
|
||||
* Override the default delete icon element. Shown only if `onDelete` is set.
|
||||
*/
|
||||
deleteIcon: PropTypes.element,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* Icon element.
|
||||
*/
|
||||
icon: PropTypes.element,
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
label: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the delete icon is clicked.
|
||||
* If set, the delete icon will be shown.
|
||||
*/
|
||||
onDelete: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onKeyDown: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onKeyUp: PropTypes.func,
|
||||
/**
|
||||
* The size of the component.
|
||||
* @default 'medium'
|
||||
*/
|
||||
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
||||
/**
|
||||
* If `true`, allows the disabled chip to escape focus.
|
||||
* If `false`, allows the disabled chip to receive focus.
|
||||
* @default false
|
||||
*/
|
||||
skipFocusWhenDisabled: PropTypes.bool,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
tabIndex: PropTypes.number,
|
||||
/**
|
||||
* The variant to use.
|
||||
* @default 'filled'
|
||||
*/
|
||||
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['filled', 'outlined']), PropTypes.string])
|
||||
} : void 0;
|
||||
export default Chip;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getChipUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiChip', slot);
|
||||
}
|
||||
const chipClasses = generateUtilityClasses('MuiChip', ['root', 'sizeSmall', 'sizeMedium', 'colorError', 'colorInfo', 'colorPrimary', 'colorSecondary', 'colorSuccess', 'colorWarning', 'disabled', 'clickable', 'clickableColorPrimary', 'clickableColorSecondary', 'deletable', 'deletableColorPrimary', 'deletableColorSecondary', 'outlined', 'filled', 'outlinedPrimary', 'outlinedSecondary', 'filledPrimary', 'filledSecondary', 'avatar', 'avatarSmall', 'avatarMedium', 'avatarColorPrimary', 'avatarColorSecondary', 'icon', 'iconSmall', 'iconMedium', 'iconColorPrimary', 'iconColorSecondary', 'label', 'labelSmall', 'labelMedium', 'deleteIcon', 'deleteIconSmall', 'deleteIconMedium', 'deleteIconColorPrimary', 'deleteIconColorSecondary', 'deleteIconOutlinedColorPrimary', 'deleteIconOutlinedColorSecondary', 'deleteIconFilledColorPrimary', 'deleteIconFilledColorSecondary', 'focusVisible']);
|
||||
export default chipClasses;
|
||||
+401
@@ -0,0 +1,401 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["aria-describedby", "aria-labelledby", "BackdropComponent", "BackdropProps", "children", "className", "disableEscapeKeyDown", "fullScreen", "fullWidth", "maxWidth", "onBackdropClick", "onClick", "onClose", "open", "PaperComponent", "PaperProps", "scroll", "TransitionComponent", "transitionDuration", "TransitionProps"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import useId from '@mui/utils/useId';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import Modal from '../Modal';
|
||||
import Fade from '../Fade';
|
||||
import Paper from '../Paper';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import styled from '../styles/styled';
|
||||
import dialogClasses, { getDialogUtilityClass } from './dialogClasses';
|
||||
import DialogContext from './DialogContext';
|
||||
import Backdrop from '../Backdrop';
|
||||
import useTheme from '../styles/useTheme';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const DialogBackdrop = styled(Backdrop, {
|
||||
name: 'MuiDialog',
|
||||
slot: 'Backdrop',
|
||||
overrides: (props, styles) => styles.backdrop
|
||||
})({
|
||||
// Improve scrollable dialog support.
|
||||
zIndex: -1
|
||||
});
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
scroll,
|
||||
maxWidth,
|
||||
fullWidth,
|
||||
fullScreen
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root'],
|
||||
container: ['container', `scroll${capitalize(scroll)}`],
|
||||
paper: ['paper', `paperScroll${capitalize(scroll)}`, `paperWidth${capitalize(String(maxWidth))}`, fullWidth && 'paperFullWidth', fullScreen && 'paperFullScreen']
|
||||
};
|
||||
return composeClasses(slots, getDialogUtilityClass, classes);
|
||||
};
|
||||
const DialogRoot = styled(Modal, {
|
||||
name: 'MuiDialog',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => styles.root
|
||||
})({
|
||||
'@media print': {
|
||||
// Use !important to override the Modal inline-style.
|
||||
position: 'absolute !important'
|
||||
}
|
||||
});
|
||||
const DialogContainer = styled('div', {
|
||||
name: 'MuiDialog',
|
||||
slot: 'Container',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.container, styles[`scroll${capitalize(ownerState.scroll)}`]];
|
||||
}
|
||||
})(({
|
||||
ownerState
|
||||
}) => _extends({
|
||||
height: '100%',
|
||||
'@media print': {
|
||||
height: 'auto'
|
||||
},
|
||||
// We disable the focus ring for mouse, touch and keyboard users.
|
||||
outline: 0
|
||||
}, ownerState.scroll === 'paper' && {
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center'
|
||||
}, ownerState.scroll === 'body' && {
|
||||
overflowY: 'auto',
|
||||
overflowX: 'hidden',
|
||||
textAlign: 'center',
|
||||
'&::after': {
|
||||
content: '""',
|
||||
display: 'inline-block',
|
||||
verticalAlign: 'middle',
|
||||
height: '100%',
|
||||
width: '0'
|
||||
}
|
||||
}));
|
||||
const DialogPaper = styled(Paper, {
|
||||
name: 'MuiDialog',
|
||||
slot: 'Paper',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.paper, styles[`scrollPaper${capitalize(ownerState.scroll)}`], styles[`paperWidth${capitalize(String(ownerState.maxWidth))}`], ownerState.fullWidth && styles.paperFullWidth, ownerState.fullScreen && styles.paperFullScreen];
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => _extends({
|
||||
margin: 32,
|
||||
position: 'relative',
|
||||
overflowY: 'auto',
|
||||
// Fix IE11 issue, to remove at some point.
|
||||
'@media print': {
|
||||
overflowY: 'visible',
|
||||
boxShadow: 'none'
|
||||
}
|
||||
}, ownerState.scroll === 'paper' && {
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
maxHeight: 'calc(100% - 64px)'
|
||||
}, ownerState.scroll === 'body' && {
|
||||
display: 'inline-block',
|
||||
verticalAlign: 'middle',
|
||||
textAlign: 'left' // 'initial' doesn't work on IE11
|
||||
}, !ownerState.maxWidth && {
|
||||
maxWidth: 'calc(100% - 64px)'
|
||||
}, ownerState.maxWidth === 'xs' && {
|
||||
maxWidth: theme.breakpoints.unit === 'px' ? Math.max(theme.breakpoints.values.xs, 444) : `max(${theme.breakpoints.values.xs}${theme.breakpoints.unit}, 444px)`,
|
||||
[`&.${dialogClasses.paperScrollBody}`]: {
|
||||
[theme.breakpoints.down(Math.max(theme.breakpoints.values.xs, 444) + 32 * 2)]: {
|
||||
maxWidth: 'calc(100% - 64px)'
|
||||
}
|
||||
}
|
||||
}, ownerState.maxWidth && ownerState.maxWidth !== 'xs' && {
|
||||
maxWidth: `${theme.breakpoints.values[ownerState.maxWidth]}${theme.breakpoints.unit}`,
|
||||
[`&.${dialogClasses.paperScrollBody}`]: {
|
||||
[theme.breakpoints.down(theme.breakpoints.values[ownerState.maxWidth] + 32 * 2)]: {
|
||||
maxWidth: 'calc(100% - 64px)'
|
||||
}
|
||||
}
|
||||
}, ownerState.fullWidth && {
|
||||
width: 'calc(100% - 64px)'
|
||||
}, ownerState.fullScreen && {
|
||||
margin: 0,
|
||||
width: '100%',
|
||||
maxWidth: '100%',
|
||||
height: '100%',
|
||||
maxHeight: 'none',
|
||||
borderRadius: 0,
|
||||
[`&.${dialogClasses.paperScrollBody}`]: {
|
||||
margin: 0,
|
||||
maxWidth: '100%'
|
||||
}
|
||||
}));
|
||||
|
||||
/**
|
||||
* Dialogs are overlaid modal paper based components with a backdrop.
|
||||
*/
|
||||
const Dialog = /*#__PURE__*/React.forwardRef(function Dialog(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiDialog'
|
||||
});
|
||||
const theme = useTheme();
|
||||
const defaultTransitionDuration = {
|
||||
enter: theme.transitions.duration.enteringScreen,
|
||||
exit: theme.transitions.duration.leavingScreen
|
||||
};
|
||||
const {
|
||||
'aria-describedby': ariaDescribedby,
|
||||
'aria-labelledby': ariaLabelledbyProp,
|
||||
BackdropComponent,
|
||||
BackdropProps,
|
||||
children,
|
||||
className,
|
||||
disableEscapeKeyDown = false,
|
||||
fullScreen = false,
|
||||
fullWidth = false,
|
||||
maxWidth = 'sm',
|
||||
onBackdropClick,
|
||||
onClick,
|
||||
onClose,
|
||||
open,
|
||||
PaperComponent = Paper,
|
||||
PaperProps = {},
|
||||
scroll = 'paper',
|
||||
TransitionComponent = Fade,
|
||||
transitionDuration = defaultTransitionDuration,
|
||||
TransitionProps
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
disableEscapeKeyDown,
|
||||
fullScreen,
|
||||
fullWidth,
|
||||
maxWidth,
|
||||
scroll
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const backdropClick = React.useRef();
|
||||
const handleMouseDown = event => {
|
||||
// We don't want to close the dialog when clicking the dialog content.
|
||||
// Make sure the event starts and ends on the same DOM element.
|
||||
backdropClick.current = event.target === event.currentTarget;
|
||||
};
|
||||
const handleBackdropClick = event => {
|
||||
if (onClick) {
|
||||
onClick(event);
|
||||
}
|
||||
|
||||
// Ignore the events not coming from the "backdrop".
|
||||
if (!backdropClick.current) {
|
||||
return;
|
||||
}
|
||||
backdropClick.current = null;
|
||||
if (onBackdropClick) {
|
||||
onBackdropClick(event);
|
||||
}
|
||||
if (onClose) {
|
||||
onClose(event, 'backdropClick');
|
||||
}
|
||||
};
|
||||
const ariaLabelledby = useId(ariaLabelledbyProp);
|
||||
const dialogContextValue = React.useMemo(() => {
|
||||
return {
|
||||
titleId: ariaLabelledby
|
||||
};
|
||||
}, [ariaLabelledby]);
|
||||
return /*#__PURE__*/_jsx(DialogRoot, _extends({
|
||||
className: clsx(classes.root, className),
|
||||
closeAfterTransition: true,
|
||||
components: {
|
||||
Backdrop: DialogBackdrop
|
||||
},
|
||||
componentsProps: {
|
||||
backdrop: _extends({
|
||||
transitionDuration,
|
||||
as: BackdropComponent
|
||||
}, BackdropProps)
|
||||
},
|
||||
disableEscapeKeyDown: disableEscapeKeyDown,
|
||||
onClose: onClose,
|
||||
open: open,
|
||||
ref: ref,
|
||||
onClick: handleBackdropClick,
|
||||
ownerState: ownerState
|
||||
}, other, {
|
||||
children: /*#__PURE__*/_jsx(TransitionComponent, _extends({
|
||||
appear: true,
|
||||
in: open,
|
||||
timeout: transitionDuration,
|
||||
role: "presentation"
|
||||
}, TransitionProps, {
|
||||
children: /*#__PURE__*/_jsx(DialogContainer, {
|
||||
className: clsx(classes.container),
|
||||
onMouseDown: handleMouseDown,
|
||||
ownerState: ownerState,
|
||||
children: /*#__PURE__*/_jsx(DialogPaper, _extends({
|
||||
as: PaperComponent,
|
||||
elevation: 24,
|
||||
role: "dialog",
|
||||
"aria-describedby": ariaDescribedby,
|
||||
"aria-labelledby": ariaLabelledby
|
||||
}, PaperProps, {
|
||||
className: clsx(classes.paper, PaperProps.className),
|
||||
ownerState: ownerState,
|
||||
children: /*#__PURE__*/_jsx(DialogContext.Provider, {
|
||||
value: dialogContextValue,
|
||||
children: children
|
||||
})
|
||||
}))
|
||||
})
|
||||
}))
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Dialog.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The id(s) of the element(s) that describe the dialog.
|
||||
*/
|
||||
'aria-describedby': PropTypes.string,
|
||||
/**
|
||||
* The id(s) of the element(s) that label the dialog.
|
||||
*/
|
||||
'aria-labelledby': PropTypes.string,
|
||||
/**
|
||||
* A backdrop component. This prop enables custom backdrop rendering.
|
||||
* @deprecated Use `slots.backdrop` instead. While this prop currently works, it will be removed in the next major version.
|
||||
* Use the `slots.backdrop` prop to make your application ready for the next version of Material UI.
|
||||
* @default styled(Backdrop, {
|
||||
* name: 'MuiModal',
|
||||
* slot: 'Backdrop',
|
||||
* overridesResolver: (props, styles) => {
|
||||
* return styles.backdrop;
|
||||
* },
|
||||
* })({
|
||||
* zIndex: -1,
|
||||
* })
|
||||
*/
|
||||
BackdropComponent: PropTypes.elementType,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
BackdropProps: PropTypes.object,
|
||||
/**
|
||||
* Dialog children, usually the included sub-components.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, hitting escape will not fire the `onClose` callback.
|
||||
* @default false
|
||||
*/
|
||||
disableEscapeKeyDown: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the dialog is full-screen.
|
||||
* @default false
|
||||
*/
|
||||
fullScreen: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the dialog stretches to `maxWidth`.
|
||||
*
|
||||
* Notice that the dialog width grow is limited by the default margin.
|
||||
* @default false
|
||||
*/
|
||||
fullWidth: PropTypes.bool,
|
||||
/**
|
||||
* Determine the max-width of the dialog.
|
||||
* The dialog width grows with the size of the screen.
|
||||
* Set to `false` to disable `maxWidth`.
|
||||
* @default 'sm'
|
||||
*/
|
||||
maxWidth: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false]), PropTypes.string]),
|
||||
/**
|
||||
* Callback fired when the backdrop is clicked.
|
||||
* @deprecated Use the `onClose` prop with the `reason` argument to handle the `backdropClick` events.
|
||||
*/
|
||||
onBackdropClick: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the component requests to be closed.
|
||||
*
|
||||
* @param {object} event The event source of the callback.
|
||||
* @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
|
||||
*/
|
||||
onClose: PropTypes.func,
|
||||
/**
|
||||
* If `true`, the component is shown.
|
||||
*/
|
||||
open: PropTypes.bool.isRequired,
|
||||
/**
|
||||
* The component used to render the body of the dialog.
|
||||
* @default Paper
|
||||
*/
|
||||
PaperComponent: PropTypes.elementType,
|
||||
/**
|
||||
* Props applied to the [`Paper`](/material-ui/api/paper/) element.
|
||||
* @default {}
|
||||
*/
|
||||
PaperProps: PropTypes.object,
|
||||
/**
|
||||
* Determine the container for scrolling the dialog.
|
||||
* @default 'paper'
|
||||
*/
|
||||
scroll: PropTypes.oneOf(['body', 'paper']),
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* The component used for the transition.
|
||||
* [Follow this guide](/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
|
||||
* @default Fade
|
||||
*/
|
||||
TransitionComponent: PropTypes.elementType,
|
||||
/**
|
||||
* The duration for the transition, in milliseconds.
|
||||
* You may specify a single timeout for all transitions, or individually with an object.
|
||||
* @default {
|
||||
* enter: theme.transitions.duration.enteringScreen,
|
||||
* exit: theme.transitions.duration.leavingScreen,
|
||||
* }
|
||||
*/
|
||||
transitionDuration: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
||||
appear: PropTypes.number,
|
||||
enter: PropTypes.number,
|
||||
exit: PropTypes.number
|
||||
})]),
|
||||
/**
|
||||
* Props applied to the transition element.
|
||||
* By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
|
||||
*/
|
||||
TransitionProps: PropTypes.object
|
||||
} : void 0;
|
||||
export default Dialog;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import * as React from 'react';
|
||||
const DialogContext = /*#__PURE__*/React.createContext({});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
DialogContext.displayName = 'DialogContext';
|
||||
}
|
||||
export default DialogContext;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getDialogUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiDialog', slot);
|
||||
}
|
||||
const dialogClasses = generateUtilityClasses('MuiDialog', ['root', 'scrollPaper', 'scrollBody', 'container', 'paper', 'paperScrollPaper', 'paperScrollBody', 'paperWidthFalse', 'paperWidthXs', 'paperWidthSm', 'paperWidthMd', 'paperWidthLg', 'paperWidthXl', 'paperFullWidth', 'paperFullScreen']);
|
||||
export default dialogClasses;
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["className", "disableSpacing"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import { getDialogActionsUtilityClass } from './dialogActionsClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
disableSpacing
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', !disableSpacing && 'spacing']
|
||||
};
|
||||
return composeClasses(slots, getDialogActionsUtilityClass, classes);
|
||||
};
|
||||
const DialogActionsRoot = styled('div', {
|
||||
name: 'MuiDialogActions',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, !ownerState.disableSpacing && styles.spacing];
|
||||
}
|
||||
})(({
|
||||
ownerState
|
||||
}) => _extends({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
padding: 8,
|
||||
justifyContent: 'flex-end',
|
||||
flex: '0 0 auto'
|
||||
}, !ownerState.disableSpacing && {
|
||||
'& > :not(style) ~ :not(style)': {
|
||||
marginLeft: 8
|
||||
}
|
||||
}));
|
||||
const DialogActions = /*#__PURE__*/React.forwardRef(function DialogActions(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiDialogActions'
|
||||
});
|
||||
const {
|
||||
className,
|
||||
disableSpacing = false
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
disableSpacing
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(DialogActionsRoot, _extends({
|
||||
className: clsx(classes.root, className),
|
||||
ownerState: ownerState,
|
||||
ref: ref
|
||||
}, other));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? DialogActions.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the actions do not have additional margin.
|
||||
* @default false
|
||||
*/
|
||||
disableSpacing: PropTypes.bool,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default DialogActions;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getDialogActionsUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiDialogActions', slot);
|
||||
}
|
||||
const dialogActionsClasses = generateUtilityClasses('MuiDialogActions', ['root', 'spacing']);
|
||||
export default dialogActionsClasses;
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["className", "dividers"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import { getDialogContentUtilityClass } from './dialogContentClasses';
|
||||
import dialogTitleClasses from '../DialogTitle/dialogTitleClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
dividers
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', dividers && 'dividers']
|
||||
};
|
||||
return composeClasses(slots, getDialogContentUtilityClass, classes);
|
||||
};
|
||||
const DialogContentRoot = styled('div', {
|
||||
name: 'MuiDialogContent',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, ownerState.dividers && styles.dividers];
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => _extends({
|
||||
flex: '1 1 auto',
|
||||
// Add iOS momentum scrolling for iOS < 13.0
|
||||
WebkitOverflowScrolling: 'touch',
|
||||
overflowY: 'auto',
|
||||
padding: '20px 24px'
|
||||
}, ownerState.dividers ? {
|
||||
padding: '16px 24px',
|
||||
borderTop: `1px solid ${(theme.vars || theme).palette.divider}`,
|
||||
borderBottom: `1px solid ${(theme.vars || theme).palette.divider}`
|
||||
} : {
|
||||
[`.${dialogTitleClasses.root} + &`]: {
|
||||
paddingTop: 0
|
||||
}
|
||||
}));
|
||||
const DialogContent = /*#__PURE__*/React.forwardRef(function DialogContent(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiDialogContent'
|
||||
});
|
||||
const {
|
||||
className,
|
||||
dividers = false
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
dividers
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(DialogContentRoot, _extends({
|
||||
className: clsx(classes.root, className),
|
||||
ownerState: ownerState,
|
||||
ref: ref
|
||||
}, other));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? DialogContent.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* Display the top and bottom dividers.
|
||||
* @default false
|
||||
*/
|
||||
dividers: PropTypes.bool,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default DialogContent;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getDialogContentUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiDialogContent', slot);
|
||||
}
|
||||
const dialogContentClasses = generateUtilityClasses('MuiDialogContent', ['root', 'dividers']);
|
||||
export default dialogContentClasses;
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["children", "className"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import styled, { rootShouldForwardProp } from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import Typography from '../Typography';
|
||||
import { getDialogContentTextUtilityClass } from './dialogContentTextClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root']
|
||||
};
|
||||
const composedClasses = composeClasses(slots, getDialogContentTextUtilityClass, classes);
|
||||
return _extends({}, classes, composedClasses);
|
||||
};
|
||||
const DialogContentTextRoot = styled(Typography, {
|
||||
shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
|
||||
name: 'MuiDialogContentText',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => styles.root
|
||||
})({});
|
||||
const DialogContentText = /*#__PURE__*/React.forwardRef(function DialogContentText(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiDialogContentText'
|
||||
});
|
||||
const {
|
||||
className
|
||||
} = props,
|
||||
ownerState = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(DialogContentTextRoot, _extends({
|
||||
component: "p",
|
||||
variant: "body1",
|
||||
color: "text.secondary",
|
||||
ref: ref,
|
||||
ownerState: ownerState,
|
||||
className: clsx(classes.root, className)
|
||||
}, props, {
|
||||
classes: classes
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? DialogContentText.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default DialogContentText;
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getDialogContentTextUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiDialogContentText', slot);
|
||||
}
|
||||
const dialogContentTextClasses = generateUtilityClasses('MuiDialogContentText', ['root']);
|
||||
export default dialogContentTextClasses;
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["className", "id"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import Typography from '../Typography';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import { getDialogTitleUtilityClass } from './dialogTitleClasses';
|
||||
import DialogContext from '../Dialog/DialogContext';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root']
|
||||
};
|
||||
return composeClasses(slots, getDialogTitleUtilityClass, classes);
|
||||
};
|
||||
const DialogTitleRoot = styled(Typography, {
|
||||
name: 'MuiDialogTitle',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => styles.root
|
||||
})({
|
||||
padding: '16px 24px',
|
||||
flex: '0 0 auto'
|
||||
});
|
||||
const DialogTitle = /*#__PURE__*/React.forwardRef(function DialogTitle(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiDialogTitle'
|
||||
});
|
||||
const {
|
||||
className,
|
||||
id: idProp
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = props;
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const {
|
||||
titleId = idProp
|
||||
} = React.useContext(DialogContext);
|
||||
return /*#__PURE__*/_jsx(DialogTitleRoot, _extends({
|
||||
component: "h2",
|
||||
className: clsx(classes.root, className),
|
||||
ownerState: ownerState,
|
||||
ref: ref,
|
||||
variant: "h6",
|
||||
id: idProp != null ? idProp : titleId
|
||||
}, other));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? DialogTitle.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
id: PropTypes.string,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default DialogTitle;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getDialogTitleUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiDialogTitle', slot);
|
||||
}
|
||||
const dialogTitleClasses = generateUtilityClasses('MuiDialogTitle', ['root']);
|
||||
export default dialogTitleClasses;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getDividerUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiDivider', slot);
|
||||
}
|
||||
const dividerClasses = generateUtilityClasses('MuiDivider', ['root', 'absolute', 'fullWidth', 'inset', 'middle', 'flexItem', 'light', 'vertical', 'withChildren', 'withChildrenVertical', 'textAlignRight', 'textAlignLeft', 'wrapper', 'wrapperVertical']);
|
||||
export default dividerClasses;
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["addEndListener", "appear", "children", "easing", "in", "onEnter", "onEntered", "onEntering", "onExit", "onExited", "onExiting", "style", "timeout", "TransitionComponent"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Transition } from 'react-transition-group';
|
||||
import elementAcceptingRef from '@mui/utils/elementAcceptingRef';
|
||||
import useTheme from '../styles/useTheme';
|
||||
import { reflow, getTransitionProps } from '../transitions/utils';
|
||||
import useForkRef from '../utils/useForkRef';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const styles = {
|
||||
entering: {
|
||||
opacity: 1
|
||||
},
|
||||
entered: {
|
||||
opacity: 1
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The Fade transition is used by the [Modal](/material-ui/react-modal/) component.
|
||||
* It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
|
||||
*/
|
||||
const Fade = /*#__PURE__*/React.forwardRef(function Fade(props, ref) {
|
||||
const theme = useTheme();
|
||||
const defaultTimeout = {
|
||||
enter: theme.transitions.duration.enteringScreen,
|
||||
exit: theme.transitions.duration.leavingScreen
|
||||
};
|
||||
const {
|
||||
addEndListener,
|
||||
appear = true,
|
||||
children,
|
||||
easing,
|
||||
in: inProp,
|
||||
onEnter,
|
||||
onEntered,
|
||||
onEntering,
|
||||
onExit,
|
||||
onExited,
|
||||
onExiting,
|
||||
style,
|
||||
timeout = defaultTimeout,
|
||||
// eslint-disable-next-line react/prop-types
|
||||
TransitionComponent = Transition
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const enableStrictModeCompat = true;
|
||||
const nodeRef = React.useRef(null);
|
||||
const handleRef = useForkRef(nodeRef, children.ref, ref);
|
||||
const normalizedTransitionCallback = callback => maybeIsAppearing => {
|
||||
if (callback) {
|
||||
const node = nodeRef.current;
|
||||
|
||||
// onEnterXxx and onExitXxx callbacks have a different arguments.length value.
|
||||
if (maybeIsAppearing === undefined) {
|
||||
callback(node);
|
||||
} else {
|
||||
callback(node, maybeIsAppearing);
|
||||
}
|
||||
}
|
||||
};
|
||||
const handleEntering = normalizedTransitionCallback(onEntering);
|
||||
const handleEnter = normalizedTransitionCallback((node, isAppearing) => {
|
||||
reflow(node); // So the animation always start from the start.
|
||||
|
||||
const transitionProps = getTransitionProps({
|
||||
style,
|
||||
timeout,
|
||||
easing
|
||||
}, {
|
||||
mode: 'enter'
|
||||
});
|
||||
node.style.webkitTransition = theme.transitions.create('opacity', transitionProps);
|
||||
node.style.transition = theme.transitions.create('opacity', transitionProps);
|
||||
if (onEnter) {
|
||||
onEnter(node, isAppearing);
|
||||
}
|
||||
});
|
||||
const handleEntered = normalizedTransitionCallback(onEntered);
|
||||
const handleExiting = normalizedTransitionCallback(onExiting);
|
||||
const handleExit = normalizedTransitionCallback(node => {
|
||||
const transitionProps = getTransitionProps({
|
||||
style,
|
||||
timeout,
|
||||
easing
|
||||
}, {
|
||||
mode: 'exit'
|
||||
});
|
||||
node.style.webkitTransition = theme.transitions.create('opacity', transitionProps);
|
||||
node.style.transition = theme.transitions.create('opacity', transitionProps);
|
||||
if (onExit) {
|
||||
onExit(node);
|
||||
}
|
||||
});
|
||||
const handleExited = normalizedTransitionCallback(onExited);
|
||||
const handleAddEndListener = next => {
|
||||
if (addEndListener) {
|
||||
// Old call signature before `react-transition-group` implemented `nodeRef`
|
||||
addEndListener(nodeRef.current, next);
|
||||
}
|
||||
};
|
||||
return /*#__PURE__*/_jsx(TransitionComponent, _extends({
|
||||
appear: appear,
|
||||
in: inProp,
|
||||
nodeRef: enableStrictModeCompat ? nodeRef : undefined,
|
||||
onEnter: handleEnter,
|
||||
onEntered: handleEntered,
|
||||
onEntering: handleEntering,
|
||||
onExit: handleExit,
|
||||
onExited: handleExited,
|
||||
onExiting: handleExiting,
|
||||
addEndListener: handleAddEndListener,
|
||||
timeout: timeout
|
||||
}, other, {
|
||||
children: (state, childProps) => {
|
||||
return /*#__PURE__*/React.cloneElement(children, _extends({
|
||||
style: _extends({
|
||||
opacity: 0,
|
||||
visibility: state === 'exited' && !inProp ? 'hidden' : undefined
|
||||
}, styles[state], style, children.props.style),
|
||||
ref: handleRef
|
||||
}, childProps));
|
||||
}
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Fade.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* Add a custom transition end trigger. Called with the transitioning DOM
|
||||
* node and a done callback. Allows for more fine grained transition end
|
||||
* logic. Note: Timeouts are still used as a fallback if provided.
|
||||
*/
|
||||
addEndListener: PropTypes.func,
|
||||
/**
|
||||
* Perform the enter transition when it first mounts if `in` is also `true`.
|
||||
* Set this to `false` to disable this behavior.
|
||||
* @default true
|
||||
*/
|
||||
appear: PropTypes.bool,
|
||||
/**
|
||||
* A single child content element.
|
||||
*/
|
||||
children: elementAcceptingRef.isRequired,
|
||||
/**
|
||||
* The transition timing function.
|
||||
* You may specify a single easing or a object containing enter and exit values.
|
||||
*/
|
||||
easing: PropTypes.oneOfType([PropTypes.shape({
|
||||
enter: PropTypes.string,
|
||||
exit: PropTypes.string
|
||||
}), PropTypes.string]),
|
||||
/**
|
||||
* If `true`, the component will transition in.
|
||||
*/
|
||||
in: PropTypes.bool,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEnter: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEntered: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEntering: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExit: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExited: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExiting: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
style: PropTypes.object,
|
||||
/**
|
||||
* The duration for the transition, in milliseconds.
|
||||
* You may specify a single timeout for all transitions, or individually with an object.
|
||||
* @default {
|
||||
* enter: theme.transitions.duration.enteringScreen,
|
||||
* exit: theme.transitions.duration.leavingScreen,
|
||||
* }
|
||||
*/
|
||||
timeout: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
||||
appear: PropTypes.number,
|
||||
enter: PropTypes.number,
|
||||
exit: PropTypes.number
|
||||
})])
|
||||
} : void 0;
|
||||
export default Fade;
|
||||
+429
@@ -0,0 +1,429 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["disableUnderline", "components", "componentsProps", "fullWidth", "hiddenLabel", "inputComponent", "multiline", "slotProps", "slots", "type"];
|
||||
import * as React from 'react';
|
||||
import deepmerge from '@mui/utils/deepmerge';
|
||||
import refType from '@mui/utils/refType';
|
||||
import PropTypes from 'prop-types';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import InputBase from '../InputBase';
|
||||
import styled, { rootShouldForwardProp } from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import filledInputClasses, { getFilledInputUtilityClass } from './filledInputClasses';
|
||||
import { rootOverridesResolver as inputBaseRootOverridesResolver, inputOverridesResolver as inputBaseInputOverridesResolver, InputBaseRoot, InputBaseComponent as InputBaseInput } from '../InputBase/InputBase';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
disableUnderline
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', !disableUnderline && 'underline'],
|
||||
input: ['input']
|
||||
};
|
||||
const composedClasses = composeClasses(slots, getFilledInputUtilityClass, classes);
|
||||
return _extends({}, classes, composedClasses);
|
||||
};
|
||||
const FilledInputRoot = styled(InputBaseRoot, {
|
||||
shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
|
||||
name: 'MuiFilledInput',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [...inputBaseRootOverridesResolver(props, styles), !ownerState.disableUnderline && styles.underline];
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => {
|
||||
var _palette;
|
||||
const light = theme.palette.mode === 'light';
|
||||
const bottomLineColor = light ? 'rgba(0, 0, 0, 0.42)' : 'rgba(255, 255, 255, 0.7)';
|
||||
const backgroundColor = light ? 'rgba(0, 0, 0, 0.06)' : 'rgba(255, 255, 255, 0.09)';
|
||||
const hoverBackground = light ? 'rgba(0, 0, 0, 0.09)' : 'rgba(255, 255, 255, 0.13)';
|
||||
const disabledBackground = light ? 'rgba(0, 0, 0, 0.12)' : 'rgba(255, 255, 255, 0.12)';
|
||||
return _extends({
|
||||
position: 'relative',
|
||||
backgroundColor: theme.vars ? theme.vars.palette.FilledInput.bg : backgroundColor,
|
||||
borderTopLeftRadius: (theme.vars || theme).shape.borderRadius,
|
||||
borderTopRightRadius: (theme.vars || theme).shape.borderRadius,
|
||||
transition: theme.transitions.create('background-color', {
|
||||
duration: theme.transitions.duration.shorter,
|
||||
easing: theme.transitions.easing.easeOut
|
||||
}),
|
||||
'&:hover': {
|
||||
backgroundColor: theme.vars ? theme.vars.palette.FilledInput.hoverBg : hoverBackground,
|
||||
// Reset on touch devices, it doesn't add specificity
|
||||
'@media (hover: none)': {
|
||||
backgroundColor: theme.vars ? theme.vars.palette.FilledInput.bg : backgroundColor
|
||||
}
|
||||
},
|
||||
[`&.${filledInputClasses.focused}`]: {
|
||||
backgroundColor: theme.vars ? theme.vars.palette.FilledInput.bg : backgroundColor
|
||||
},
|
||||
[`&.${filledInputClasses.disabled}`]: {
|
||||
backgroundColor: theme.vars ? theme.vars.palette.FilledInput.disabledBg : disabledBackground
|
||||
}
|
||||
}, !ownerState.disableUnderline && {
|
||||
'&::after': {
|
||||
borderBottom: `2px solid ${(_palette = (theme.vars || theme).palette[ownerState.color || 'primary']) == null ? void 0 : _palette.main}`,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
// Doing the other way around crash on IE11 "''" https://github.com/cssinjs/jss/issues/242
|
||||
content: '""',
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
transform: 'scaleX(0)',
|
||||
transition: theme.transitions.create('transform', {
|
||||
duration: theme.transitions.duration.shorter,
|
||||
easing: theme.transitions.easing.easeOut
|
||||
}),
|
||||
pointerEvents: 'none' // Transparent to the hover style.
|
||||
},
|
||||
[`&.${filledInputClasses.focused}:after`]: {
|
||||
// translateX(0) is a workaround for Safari transform scale bug
|
||||
// See https://github.com/mui/material-ui/issues/31766
|
||||
transform: 'scaleX(1) translateX(0)'
|
||||
},
|
||||
[`&.${filledInputClasses.error}`]: {
|
||||
'&::before, &::after': {
|
||||
borderBottomColor: (theme.vars || theme).palette.error.main
|
||||
}
|
||||
},
|
||||
'&::before': {
|
||||
borderBottom: `1px solid ${theme.vars ? `rgba(${theme.vars.palette.common.onBackgroundChannel} / ${theme.vars.opacity.inputUnderline})` : bottomLineColor}`,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
// Doing the other way around crash on IE11 "''" https://github.com/cssinjs/jss/issues/242
|
||||
content: '"\\00a0"',
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
transition: theme.transitions.create('border-bottom-color', {
|
||||
duration: theme.transitions.duration.shorter
|
||||
}),
|
||||
pointerEvents: 'none' // Transparent to the hover style.
|
||||
},
|
||||
[`&:hover:not(.${filledInputClasses.disabled}, .${filledInputClasses.error}):before`]: {
|
||||
borderBottom: `1px solid ${(theme.vars || theme).palette.text.primary}`
|
||||
},
|
||||
[`&.${filledInputClasses.disabled}:before`]: {
|
||||
borderBottomStyle: 'dotted'
|
||||
}
|
||||
}, ownerState.startAdornment && {
|
||||
paddingLeft: 12
|
||||
}, ownerState.endAdornment && {
|
||||
paddingRight: 12
|
||||
}, ownerState.multiline && _extends({
|
||||
padding: '25px 12px 8px'
|
||||
}, ownerState.size === 'small' && {
|
||||
paddingTop: 21,
|
||||
paddingBottom: 4
|
||||
}, ownerState.hiddenLabel && {
|
||||
paddingTop: 16,
|
||||
paddingBottom: 17
|
||||
}, ownerState.hiddenLabel && ownerState.size === 'small' && {
|
||||
paddingTop: 8,
|
||||
paddingBottom: 9
|
||||
}));
|
||||
});
|
||||
const FilledInputInput = styled(InputBaseInput, {
|
||||
name: 'MuiFilledInput',
|
||||
slot: 'Input',
|
||||
overridesResolver: inputBaseInputOverridesResolver
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => _extends({
|
||||
paddingTop: 25,
|
||||
paddingRight: 12,
|
||||
paddingBottom: 8,
|
||||
paddingLeft: 12
|
||||
}, !theme.vars && {
|
||||
'&:-webkit-autofill': {
|
||||
WebkitBoxShadow: theme.palette.mode === 'light' ? null : '0 0 0 100px #266798 inset',
|
||||
WebkitTextFillColor: theme.palette.mode === 'light' ? null : '#fff',
|
||||
caretColor: theme.palette.mode === 'light' ? null : '#fff',
|
||||
borderTopLeftRadius: 'inherit',
|
||||
borderTopRightRadius: 'inherit'
|
||||
}
|
||||
}, theme.vars && {
|
||||
'&:-webkit-autofill': {
|
||||
borderTopLeftRadius: 'inherit',
|
||||
borderTopRightRadius: 'inherit'
|
||||
},
|
||||
[theme.getColorSchemeSelector('dark')]: {
|
||||
'&:-webkit-autofill': {
|
||||
WebkitBoxShadow: '0 0 0 100px #266798 inset',
|
||||
WebkitTextFillColor: '#fff',
|
||||
caretColor: '#fff'
|
||||
}
|
||||
}
|
||||
}, ownerState.size === 'small' && {
|
||||
paddingTop: 21,
|
||||
paddingBottom: 4
|
||||
}, ownerState.hiddenLabel && {
|
||||
paddingTop: 16,
|
||||
paddingBottom: 17
|
||||
}, ownerState.startAdornment && {
|
||||
paddingLeft: 0
|
||||
}, ownerState.endAdornment && {
|
||||
paddingRight: 0
|
||||
}, ownerState.hiddenLabel && ownerState.size === 'small' && {
|
||||
paddingTop: 8,
|
||||
paddingBottom: 9
|
||||
}, ownerState.multiline && {
|
||||
paddingTop: 0,
|
||||
paddingBottom: 0,
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0
|
||||
}));
|
||||
const FilledInput = /*#__PURE__*/React.forwardRef(function FilledInput(inProps, ref) {
|
||||
var _ref, _slots$root, _ref2, _slots$input;
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiFilledInput'
|
||||
});
|
||||
const {
|
||||
components = {},
|
||||
componentsProps: componentsPropsProp,
|
||||
fullWidth = false,
|
||||
// declare here to prevent spreading to DOM
|
||||
inputComponent = 'input',
|
||||
multiline = false,
|
||||
slotProps,
|
||||
slots = {},
|
||||
type = 'text'
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
fullWidth,
|
||||
inputComponent,
|
||||
multiline,
|
||||
type
|
||||
});
|
||||
const classes = useUtilityClasses(props);
|
||||
const filledInputComponentsProps = {
|
||||
root: {
|
||||
ownerState
|
||||
},
|
||||
input: {
|
||||
ownerState
|
||||
}
|
||||
};
|
||||
const componentsProps = (slotProps != null ? slotProps : componentsPropsProp) ? deepmerge(filledInputComponentsProps, slotProps != null ? slotProps : componentsPropsProp) : filledInputComponentsProps;
|
||||
const RootSlot = (_ref = (_slots$root = slots.root) != null ? _slots$root : components.Root) != null ? _ref : FilledInputRoot;
|
||||
const InputSlot = (_ref2 = (_slots$input = slots.input) != null ? _slots$input : components.Input) != null ? _ref2 : FilledInputInput;
|
||||
return /*#__PURE__*/_jsx(InputBase, _extends({
|
||||
slots: {
|
||||
root: RootSlot,
|
||||
input: InputSlot
|
||||
},
|
||||
componentsProps: componentsProps,
|
||||
fullWidth: fullWidth,
|
||||
inputComponent: inputComponent,
|
||||
multiline: multiline,
|
||||
ref: ref,
|
||||
type: type
|
||||
}, other, {
|
||||
classes: classes
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? FilledInput.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* 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,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
* The prop defaults to the value (`'primary'`) inherited from the parent FormControl component.
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary']), PropTypes.string]),
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
*
|
||||
* This prop is an alias for the `slots` prop.
|
||||
* It's recommended to use the `slots` prop instead.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
components: PropTypes.shape({
|
||||
Input: PropTypes.elementType,
|
||||
Root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The extra props for the slot components.
|
||||
* You can override the existing props or add new ones.
|
||||
*
|
||||
* This prop is an alias for the `slotProps` prop.
|
||||
* It's recommended to use the `slotProps` prop instead, as `componentsProps` will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
componentsProps: PropTypes.shape({
|
||||
input: PropTypes.object,
|
||||
root: PropTypes.object
|
||||
}),
|
||||
/**
|
||||
* 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,
|
||||
/**
|
||||
* If `true`, the input will not have an underline.
|
||||
*/
|
||||
disableUnderline: PropTypes.bool,
|
||||
/**
|
||||
* End `InputAdornment` for this component.
|
||||
*/
|
||||
endAdornment: PropTypes.node,
|
||||
/**
|
||||
* If `true`, the `input` will indicate an error.
|
||||
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
|
||||
*/
|
||||
error: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the `input` will take up the full width of its container.
|
||||
* @default false
|
||||
*/
|
||||
fullWidth: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the label is hidden.
|
||||
* This is used to increase density for a `FilledInput`.
|
||||
* Be sure to add `aria-label` to the `input` element.
|
||||
* @default false
|
||||
*/
|
||||
hiddenLabel: PropTypes.bool,
|
||||
/**
|
||||
* The id of the `input` element.
|
||||
*/
|
||||
id: PropTypes.string,
|
||||
/**
|
||||
* The component used for the `input` element.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default 'input'
|
||||
*/
|
||||
inputComponent: PropTypes.elementType,
|
||||
/**
|
||||
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
||||
* @default {}
|
||||
*/
|
||||
inputProps: PropTypes.object,
|
||||
/**
|
||||
* Pass a ref to the `input` element.
|
||||
*/
|
||||
inputRef: refType,
|
||||
/**
|
||||
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
||||
* FormControl.
|
||||
* The prop defaults to the value (`'none'`) inherited from the parent FormControl component.
|
||||
*/
|
||||
margin: PropTypes.oneOf(['dense', 'none']),
|
||||
/**
|
||||
* Maximum number of rows to display when multiline option is set to true.
|
||||
*/
|
||||
maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* Minimum number of rows to display when multiline option is set to true.
|
||||
*/
|
||||
minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* If `true`, a [TextareaAutosize](/material-ui/react-textarea-autosize/) element is rendered.
|
||||
* @default false
|
||||
*/
|
||||
multiline: PropTypes.bool,
|
||||
/**
|
||||
* Name attribute of the `input` element.
|
||||
*/
|
||||
name: PropTypes.string,
|
||||
/**
|
||||
* Callback fired when the value is changed.
|
||||
*
|
||||
* @param {React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>} event The event source of the callback.
|
||||
* You can pull out the new value by accessing `event.target.value` (string).
|
||||
*/
|
||||
onChange: 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.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* The extra props for the slot components.
|
||||
* You can override the existing props or add new ones.
|
||||
*
|
||||
* This prop is an alias for the `componentsProps` prop, which will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
input: PropTypes.object,
|
||||
root: PropTypes.object
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
*
|
||||
* This prop is an alias for the `components` prop, which will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
input: PropTypes.elementType,
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* Start `InputAdornment` for this component.
|
||||
*/
|
||||
startAdornment: PropTypes.node,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* 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.string,
|
||||
/**
|
||||
* The value of the `input` element, required for a controlled component.
|
||||
*/
|
||||
value: PropTypes.any
|
||||
} : void 0;
|
||||
FilledInput.muiName = 'Input';
|
||||
export default FilledInput;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
import { inputBaseClasses } from '../InputBase';
|
||||
export function getFilledInputUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiFilledInput', slot);
|
||||
}
|
||||
const filledInputClasses = _extends({}, inputBaseClasses, generateUtilityClasses('MuiFilledInput', ['root', 'underline', 'input']));
|
||||
export default filledInputClasses;
|
||||
+290
@@ -0,0 +1,290 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["children", "className", "color", "component", "disabled", "error", "focused", "fullWidth", "hiddenLabel", "margin", "required", "size", "variant"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import styled from '../styles/styled';
|
||||
import { isFilled, isAdornedStart } from '../InputBase/utils';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import isMuiElement from '../utils/isMuiElement';
|
||||
import FormControlContext from './FormControlContext';
|
||||
import { getFormControlUtilityClasses } from './formControlClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
margin,
|
||||
fullWidth
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', margin !== 'none' && `margin${capitalize(margin)}`, fullWidth && 'fullWidth']
|
||||
};
|
||||
return composeClasses(slots, getFormControlUtilityClasses, classes);
|
||||
};
|
||||
const FormControlRoot = styled('div', {
|
||||
name: 'MuiFormControl',
|
||||
slot: 'Root',
|
||||
overridesResolver: ({
|
||||
ownerState
|
||||
}, styles) => {
|
||||
return _extends({}, styles.root, styles[`margin${capitalize(ownerState.margin)}`], ownerState.fullWidth && styles.fullWidth);
|
||||
}
|
||||
})(({
|
||||
ownerState
|
||||
}) => _extends({
|
||||
display: 'inline-flex',
|
||||
flexDirection: 'column',
|
||||
position: 'relative',
|
||||
// Reset fieldset default style.
|
||||
minWidth: 0,
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
border: 0,
|
||||
verticalAlign: 'top'
|
||||
}, ownerState.margin === 'normal' && {
|
||||
marginTop: 16,
|
||||
marginBottom: 8
|
||||
}, ownerState.margin === 'dense' && {
|
||||
marginTop: 8,
|
||||
marginBottom: 4
|
||||
}, ownerState.fullWidth && {
|
||||
width: '100%'
|
||||
}));
|
||||
|
||||
/**
|
||||
* Provides context such as filled/focused/error/required for form inputs.
|
||||
* Relying on the context provides high flexibility and ensures that the state always stays
|
||||
* consistent across the children of the `FormControl`.
|
||||
* This context is used by the following components:
|
||||
*
|
||||
* - FormLabel
|
||||
* - FormHelperText
|
||||
* - Input
|
||||
* - InputLabel
|
||||
*
|
||||
* You can find one composition example below and more going to [the demos](/material-ui/react-text-field/#components).
|
||||
*
|
||||
* ```jsx
|
||||
* <FormControl>
|
||||
* <InputLabel htmlFor="my-input">Email address</InputLabel>
|
||||
* <Input id="my-input" aria-describedby="my-helper-text" />
|
||||
* <FormHelperText id="my-helper-text">We'll never share your email.</FormHelperText>
|
||||
* </FormControl>
|
||||
* ```
|
||||
*
|
||||
* ⚠️ Only one `InputBase` can be used within a FormControl because it creates visual inconsistencies.
|
||||
* For instance, only one input can be focused at the same time, the state shouldn't be shared.
|
||||
*/
|
||||
const FormControl = /*#__PURE__*/React.forwardRef(function FormControl(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiFormControl'
|
||||
});
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
color = 'primary',
|
||||
component = 'div',
|
||||
disabled = false,
|
||||
error = false,
|
||||
focused: visuallyFocused,
|
||||
fullWidth = false,
|
||||
hiddenLabel = false,
|
||||
margin = 'none',
|
||||
required = false,
|
||||
size = 'medium',
|
||||
variant = 'outlined'
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
color,
|
||||
component,
|
||||
disabled,
|
||||
error,
|
||||
fullWidth,
|
||||
hiddenLabel,
|
||||
margin,
|
||||
required,
|
||||
size,
|
||||
variant
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const [adornedStart, setAdornedStart] = React.useState(() => {
|
||||
// We need to iterate through the children and find the Input in order
|
||||
// to fully support server-side rendering.
|
||||
let initialAdornedStart = false;
|
||||
if (children) {
|
||||
React.Children.forEach(children, child => {
|
||||
if (!isMuiElement(child, ['Input', 'Select'])) {
|
||||
return;
|
||||
}
|
||||
const input = isMuiElement(child, ['Select']) ? child.props.input : child;
|
||||
if (input && isAdornedStart(input.props)) {
|
||||
initialAdornedStart = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
return initialAdornedStart;
|
||||
});
|
||||
const [filled, setFilled] = React.useState(() => {
|
||||
// We need to iterate through the children and find the Input in order
|
||||
// to fully support server-side rendering.
|
||||
let initialFilled = false;
|
||||
if (children) {
|
||||
React.Children.forEach(children, child => {
|
||||
if (!isMuiElement(child, ['Input', 'Select'])) {
|
||||
return;
|
||||
}
|
||||
if (isFilled(child.props, true) || isFilled(child.props.inputProps, true)) {
|
||||
initialFilled = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
return initialFilled;
|
||||
});
|
||||
const [focusedState, setFocused] = React.useState(false);
|
||||
if (disabled && focusedState) {
|
||||
setFocused(false);
|
||||
}
|
||||
const focused = visuallyFocused !== undefined && !disabled ? visuallyFocused : focusedState;
|
||||
let registerEffect;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const registeredInput = React.useRef(false);
|
||||
registerEffect = () => {
|
||||
if (registeredInput.current) {
|
||||
console.error(['MUI: There are multiple `InputBase` components inside a FormControl.', 'This creates visual inconsistencies, only use one `InputBase`.'].join('\n'));
|
||||
}
|
||||
registeredInput.current = true;
|
||||
return () => {
|
||||
registeredInput.current = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
const childContext = React.useMemo(() => {
|
||||
return {
|
||||
adornedStart,
|
||||
setAdornedStart,
|
||||
color,
|
||||
disabled,
|
||||
error,
|
||||
filled,
|
||||
focused,
|
||||
fullWidth,
|
||||
hiddenLabel,
|
||||
size,
|
||||
onBlur: () => {
|
||||
setFocused(false);
|
||||
},
|
||||
onEmpty: () => {
|
||||
setFilled(false);
|
||||
},
|
||||
onFilled: () => {
|
||||
setFilled(true);
|
||||
},
|
||||
onFocus: () => {
|
||||
setFocused(true);
|
||||
},
|
||||
registerEffect,
|
||||
required,
|
||||
variant
|
||||
};
|
||||
}, [adornedStart, color, disabled, error, filled, focused, fullWidth, hiddenLabel, registerEffect, required, size, variant]);
|
||||
return /*#__PURE__*/_jsx(FormControlContext.Provider, {
|
||||
value: childContext,
|
||||
children: /*#__PURE__*/_jsx(FormControlRoot, _extends({
|
||||
as: component,
|
||||
ownerState: ownerState,
|
||||
className: clsx(classes.root, className),
|
||||
ref: ref
|
||||
}, other, {
|
||||
children: children
|
||||
}))
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? FormControl.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
* @default 'primary'
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: PropTypes.elementType,
|
||||
/**
|
||||
* If `true`, the label, input and helper text should be displayed in a disabled state.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the label is displayed in an error state.
|
||||
* @default false
|
||||
*/
|
||||
error: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the component is displayed in focused state.
|
||||
*/
|
||||
focused: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the component will take up the full width of its container.
|
||||
* @default false
|
||||
*/
|
||||
fullWidth: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the label is hidden.
|
||||
* This is used to increase density for a `FilledInput`.
|
||||
* Be sure to add `aria-label` to the `input` element.
|
||||
* @default false
|
||||
*/
|
||||
hiddenLabel: PropTypes.bool,
|
||||
/**
|
||||
* If `dense` or `normal`, will adjust vertical spacing of this and contained components.
|
||||
* @default 'none'
|
||||
*/
|
||||
margin: PropTypes.oneOf(['dense', 'none', 'normal']),
|
||||
/**
|
||||
* If `true`, the label will indicate that the `input` is required.
|
||||
* @default false
|
||||
*/
|
||||
required: PropTypes.bool,
|
||||
/**
|
||||
* The size of the component.
|
||||
* @default 'medium'
|
||||
*/
|
||||
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* The variant to use.
|
||||
* @default 'outlined'
|
||||
*/
|
||||
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
||||
} : void 0;
|
||||
export default FormControl;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import * as React from 'react';
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
const FormControlContext = /*#__PURE__*/React.createContext(undefined);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
FormControlContext.displayName = 'FormControlContext';
|
||||
}
|
||||
export default FormControlContext;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getFormControlUtilityClasses(slot) {
|
||||
return generateUtilityClass('MuiFormControl', slot);
|
||||
}
|
||||
const formControlClasses = generateUtilityClasses('MuiFormControl', ['root', 'marginNone', 'marginNormal', 'marginDense', 'fullWidth', 'disabled']);
|
||||
export default formControlClasses;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
export default function formControlState({
|
||||
props,
|
||||
states,
|
||||
muiFormControl
|
||||
}) {
|
||||
return states.reduce((acc, state) => {
|
||||
acc[state] = props[state];
|
||||
if (muiFormControl) {
|
||||
if (typeof props[state] === 'undefined') {
|
||||
acc[state] = muiFormControl[state];
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import FormControlContext from './FormControlContext';
|
||||
export default function useFormControl() {
|
||||
return React.useContext(FormControlContext);
|
||||
}
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["checked", "className", "componentsProps", "control", "disabled", "disableTypography", "inputRef", "label", "labelPlacement", "name", "onChange", "required", "slotProps", "value"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import refType from '@mui/utils/refType';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import { useFormControl } from '../FormControl';
|
||||
import Stack from '../Stack';
|
||||
import Typography from '../Typography';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import formControlLabelClasses, { getFormControlLabelUtilityClasses } from './formControlLabelClasses';
|
||||
import formControlState from '../FormControl/formControlState';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
disabled,
|
||||
labelPlacement,
|
||||
error,
|
||||
required
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', disabled && 'disabled', `labelPlacement${capitalize(labelPlacement)}`, error && 'error', required && 'required'],
|
||||
label: ['label', disabled && 'disabled'],
|
||||
asterisk: ['asterisk', error && 'error']
|
||||
};
|
||||
return composeClasses(slots, getFormControlLabelUtilityClasses, classes);
|
||||
};
|
||||
export const FormControlLabelRoot = styled('label', {
|
||||
name: 'MuiFormControlLabel',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [{
|
||||
[`& .${formControlLabelClasses.label}`]: styles.label
|
||||
}, styles.root, styles[`labelPlacement${capitalize(ownerState.labelPlacement)}`]];
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => _extends({
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
cursor: 'pointer',
|
||||
// For correct alignment with the text.
|
||||
verticalAlign: 'middle',
|
||||
WebkitTapHighlightColor: 'transparent',
|
||||
marginLeft: -11,
|
||||
marginRight: 16,
|
||||
// used for row presentation of radio/checkbox
|
||||
[`&.${formControlLabelClasses.disabled}`]: {
|
||||
cursor: 'default'
|
||||
}
|
||||
}, ownerState.labelPlacement === 'start' && {
|
||||
flexDirection: 'row-reverse',
|
||||
marginLeft: 16,
|
||||
// used for row presentation of radio/checkbox
|
||||
marginRight: -11
|
||||
}, ownerState.labelPlacement === 'top' && {
|
||||
flexDirection: 'column-reverse',
|
||||
marginLeft: 16
|
||||
}, ownerState.labelPlacement === 'bottom' && {
|
||||
flexDirection: 'column',
|
||||
marginLeft: 16
|
||||
}, {
|
||||
[`& .${formControlLabelClasses.label}`]: {
|
||||
[`&.${formControlLabelClasses.disabled}`]: {
|
||||
color: (theme.vars || theme).palette.text.disabled
|
||||
}
|
||||
}
|
||||
}));
|
||||
const AsteriskComponent = styled('span', {
|
||||
name: 'MuiFormControlLabel',
|
||||
slot: 'Asterisk',
|
||||
overridesResolver: (props, styles) => styles.asterisk
|
||||
})(({
|
||||
theme
|
||||
}) => ({
|
||||
[`&.${formControlLabelClasses.error}`]: {
|
||||
color: (theme.vars || theme).palette.error.main
|
||||
}
|
||||
}));
|
||||
|
||||
/**
|
||||
* Drop-in replacement of the `Radio`, `Switch` and `Checkbox` component.
|
||||
* Use this component if you want to display an extra label.
|
||||
*/
|
||||
const FormControlLabel = /*#__PURE__*/React.forwardRef(function FormControlLabel(inProps, ref) {
|
||||
var _ref, _slotProps$typography;
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiFormControlLabel'
|
||||
});
|
||||
const {
|
||||
className,
|
||||
componentsProps = {},
|
||||
control,
|
||||
disabled: disabledProp,
|
||||
disableTypography,
|
||||
label: labelProp,
|
||||
labelPlacement = 'end',
|
||||
required: requiredProp,
|
||||
slotProps = {}
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const muiFormControl = useFormControl();
|
||||
const disabled = (_ref = disabledProp != null ? disabledProp : control.props.disabled) != null ? _ref : muiFormControl == null ? void 0 : muiFormControl.disabled;
|
||||
const required = requiredProp != null ? requiredProp : control.props.required;
|
||||
const controlProps = {
|
||||
disabled,
|
||||
required
|
||||
};
|
||||
['checked', 'name', 'onChange', 'value', 'inputRef'].forEach(key => {
|
||||
if (typeof control.props[key] === 'undefined' && typeof props[key] !== 'undefined') {
|
||||
controlProps[key] = props[key];
|
||||
}
|
||||
});
|
||||
const fcs = formControlState({
|
||||
props,
|
||||
muiFormControl,
|
||||
states: ['error']
|
||||
});
|
||||
const ownerState = _extends({}, props, {
|
||||
disabled,
|
||||
labelPlacement,
|
||||
required,
|
||||
error: fcs.error
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const typographySlotProps = (_slotProps$typography = slotProps.typography) != null ? _slotProps$typography : componentsProps.typography;
|
||||
let label = labelProp;
|
||||
if (label != null && label.type !== Typography && !disableTypography) {
|
||||
label = /*#__PURE__*/_jsx(Typography, _extends({
|
||||
component: "span"
|
||||
}, typographySlotProps, {
|
||||
className: clsx(classes.label, typographySlotProps == null ? void 0 : typographySlotProps.className),
|
||||
children: label
|
||||
}));
|
||||
}
|
||||
return /*#__PURE__*/_jsxs(FormControlLabelRoot, _extends({
|
||||
className: clsx(classes.root, className),
|
||||
ownerState: ownerState,
|
||||
ref: ref
|
||||
}, other, {
|
||||
children: [/*#__PURE__*/React.cloneElement(control, controlProps), required ? /*#__PURE__*/_jsxs(Stack, {
|
||||
display: "block",
|
||||
children: [label, /*#__PURE__*/_jsxs(AsteriskComponent, {
|
||||
ownerState: ownerState,
|
||||
"aria-hidden": true,
|
||||
className: classes.asterisk,
|
||||
children: ["\u2009", '*']
|
||||
})]
|
||||
}) : label]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? FormControlLabel.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* If `true`, the component appears selected.
|
||||
*/
|
||||
checked: PropTypes.bool,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The props used for each slot inside.
|
||||
* @default {}
|
||||
*/
|
||||
componentsProps: PropTypes.shape({
|
||||
typography: PropTypes.object
|
||||
}),
|
||||
/**
|
||||
* A control element. For instance, it can be a `Radio`, a `Switch` or a `Checkbox`.
|
||||
*/
|
||||
control: PropTypes.element.isRequired,
|
||||
/**
|
||||
* If `true`, the control is disabled.
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the label is rendered as it is passed without an additional typography node.
|
||||
*/
|
||||
disableTypography: PropTypes.bool,
|
||||
/**
|
||||
* Pass a ref to the `input` element.
|
||||
*/
|
||||
inputRef: refType,
|
||||
/**
|
||||
* A text or an element to be used in an enclosing label element.
|
||||
*/
|
||||
label: PropTypes.node,
|
||||
/**
|
||||
* The position of the label.
|
||||
* @default 'end'
|
||||
*/
|
||||
labelPlacement: PropTypes.oneOf(['bottom', 'end', 'start', 'top']),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
name: PropTypes.string,
|
||||
/**
|
||||
* Callback fired when the state is changed.
|
||||
*
|
||||
* @param {React.SyntheticEvent} event The event source of the callback.
|
||||
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* If `true`, the label will indicate that the `input` is required.
|
||||
*/
|
||||
required: PropTypes.bool,
|
||||
/**
|
||||
* The props used for each slot inside.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
typography: PropTypes.object
|
||||
}),
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* The value of the component.
|
||||
*/
|
||||
value: PropTypes.any
|
||||
} : void 0;
|
||||
export default FormControlLabel;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getFormControlLabelUtilityClasses(slot) {
|
||||
return generateUtilityClass('MuiFormControlLabel', slot);
|
||||
}
|
||||
const formControlLabelClasses = generateUtilityClasses('MuiFormControlLabel', ['root', 'labelPlacementStart', 'labelPlacementTop', 'labelPlacementBottom', 'disabled', 'label', 'error', 'required', 'asterisk']);
|
||||
export default formControlLabelClasses;
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["className", "row"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import { getFormGroupUtilityClass } from './formGroupClasses';
|
||||
import useFormControl from '../FormControl/useFormControl';
|
||||
import formControlState from '../FormControl/formControlState';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
row,
|
||||
error
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', row && 'row', error && 'error']
|
||||
};
|
||||
return composeClasses(slots, getFormGroupUtilityClass, classes);
|
||||
};
|
||||
const FormGroupRoot = styled('div', {
|
||||
name: 'MuiFormGroup',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, ownerState.row && styles.row];
|
||||
}
|
||||
})(({
|
||||
ownerState
|
||||
}) => _extends({
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
flexWrap: 'wrap'
|
||||
}, ownerState.row && {
|
||||
flexDirection: 'row'
|
||||
}));
|
||||
|
||||
/**
|
||||
* `FormGroup` wraps controls such as `Checkbox` and `Switch`.
|
||||
* It provides compact row layout.
|
||||
* For the `Radio`, you should be using the `RadioGroup` component instead of this one.
|
||||
*/
|
||||
const FormGroup = /*#__PURE__*/React.forwardRef(function FormGroup(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiFormGroup'
|
||||
});
|
||||
const {
|
||||
className,
|
||||
row = false
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const muiFormControl = useFormControl();
|
||||
const fcs = formControlState({
|
||||
props,
|
||||
muiFormControl,
|
||||
states: ['error']
|
||||
});
|
||||
const ownerState = _extends({}, props, {
|
||||
row,
|
||||
error: fcs.error
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(FormGroupRoot, _extends({
|
||||
className: clsx(classes.root, className),
|
||||
ownerState: ownerState,
|
||||
ref: ref
|
||||
}, other));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? FormGroup.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* Display group of elements in a compact row.
|
||||
* @default false
|
||||
*/
|
||||
row: PropTypes.bool,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default FormGroup;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getFormGroupUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiFormGroup', slot);
|
||||
}
|
||||
const formGroupClasses = generateUtilityClasses('MuiFormGroup', ['root', 'row', 'error']);
|
||||
export default formGroupClasses;
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["children", "className", "color", "component", "disabled", "error", "filled", "focused", "required"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import formControlState from '../FormControl/formControlState';
|
||||
import useFormControl from '../FormControl/useFormControl';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import styled from '../styles/styled';
|
||||
import formLabelClasses, { getFormLabelUtilityClasses } from './formLabelClasses';
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
color,
|
||||
focused,
|
||||
disabled,
|
||||
error,
|
||||
filled,
|
||||
required
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', `color${capitalize(color)}`, disabled && 'disabled', error && 'error', filled && 'filled', focused && 'focused', required && 'required'],
|
||||
asterisk: ['asterisk', error && 'error']
|
||||
};
|
||||
return composeClasses(slots, getFormLabelUtilityClasses, classes);
|
||||
};
|
||||
export const FormLabelRoot = styled('label', {
|
||||
name: 'MuiFormLabel',
|
||||
slot: 'Root',
|
||||
overridesResolver: ({
|
||||
ownerState
|
||||
}, styles) => {
|
||||
return _extends({}, styles.root, ownerState.color === 'secondary' && styles.colorSecondary, ownerState.filled && styles.filled);
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => _extends({
|
||||
color: (theme.vars || theme).palette.text.secondary
|
||||
}, theme.typography.body1, {
|
||||
lineHeight: '1.4375em',
|
||||
padding: 0,
|
||||
position: 'relative',
|
||||
[`&.${formLabelClasses.focused}`]: {
|
||||
color: (theme.vars || theme).palette[ownerState.color].main
|
||||
},
|
||||
[`&.${formLabelClasses.disabled}`]: {
|
||||
color: (theme.vars || theme).palette.text.disabled
|
||||
},
|
||||
[`&.${formLabelClasses.error}`]: {
|
||||
color: (theme.vars || theme).palette.error.main
|
||||
}
|
||||
}));
|
||||
const AsteriskComponent = styled('span', {
|
||||
name: 'MuiFormLabel',
|
||||
slot: 'Asterisk',
|
||||
overridesResolver: (props, styles) => styles.asterisk
|
||||
})(({
|
||||
theme
|
||||
}) => ({
|
||||
[`&.${formLabelClasses.error}`]: {
|
||||
color: (theme.vars || theme).palette.error.main
|
||||
}
|
||||
}));
|
||||
const FormLabel = /*#__PURE__*/React.forwardRef(function FormLabel(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiFormLabel'
|
||||
});
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
component = 'label'
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const muiFormControl = useFormControl();
|
||||
const fcs = formControlState({
|
||||
props,
|
||||
muiFormControl,
|
||||
states: ['color', 'required', 'focused', 'disabled', 'error', 'filled']
|
||||
});
|
||||
const ownerState = _extends({}, props, {
|
||||
color: fcs.color || 'primary',
|
||||
component,
|
||||
disabled: fcs.disabled,
|
||||
error: fcs.error,
|
||||
filled: fcs.filled,
|
||||
focused: fcs.focused,
|
||||
required: fcs.required
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsxs(FormLabelRoot, _extends({
|
||||
as: component,
|
||||
ownerState: ownerState,
|
||||
className: clsx(classes.root, className),
|
||||
ref: ref
|
||||
}, other, {
|
||||
children: [children, fcs.required && /*#__PURE__*/_jsxs(AsteriskComponent, {
|
||||
ownerState: ownerState,
|
||||
"aria-hidden": true,
|
||||
className: classes.asterisk,
|
||||
children: ["\u2009", '*']
|
||||
})]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? FormLabel.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']), PropTypes.string]),
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: PropTypes.elementType,
|
||||
/**
|
||||
* If `true`, the label should be displayed in a disabled state.
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the label is displayed in an error state.
|
||||
*/
|
||||
error: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the label should use filled classes key.
|
||||
*/
|
||||
filled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the input of this label is focused (used by `FormGroup` components).
|
||||
*/
|
||||
focused: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the label will indicate that the `input` is required.
|
||||
*/
|
||||
required: PropTypes.bool,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default FormLabel;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getFormLabelUtilityClasses(slot) {
|
||||
return generateUtilityClass('MuiFormLabel', slot);
|
||||
}
|
||||
const formLabelClasses = generateUtilityClasses('MuiFormLabel', ['root', 'colorSecondary', 'focused', 'disabled', 'error', 'filled', 'required', 'asterisk']);
|
||||
export default formLabelClasses;
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { GlobalStyles as SystemGlobalStyles } from '@mui/system';
|
||||
import defaultTheme from '../styles/defaultTheme';
|
||||
import THEME_ID from '../styles/identifier';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function GlobalStyles(props) {
|
||||
return /*#__PURE__*/_jsx(SystemGlobalStyles, _extends({}, props, {
|
||||
defaultTheme: defaultTheme,
|
||||
themeId: THEME_ID
|
||||
}));
|
||||
}
|
||||
process.env.NODE_ENV !== "production" ? GlobalStyles.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The styles you want to apply globally.
|
||||
*/
|
||||
styles: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.array, PropTypes.func, PropTypes.number, PropTypes.object, PropTypes.string, PropTypes.bool])
|
||||
} : void 0;
|
||||
export default GlobalStyles;
|
||||
+569
@@ -0,0 +1,569 @@
|
||||
'use client';
|
||||
|
||||
// A grid component using the following libs as inspiration.
|
||||
//
|
||||
// For the implementation:
|
||||
// - https://getbootstrap.com/docs/4.3/layout/grid/
|
||||
// - https://github.com/kristoferjoseph/flexboxgrid/blob/master/src/css/flexboxgrid.css
|
||||
// - https://github.com/roylee0704/react-flexbox-grid
|
||||
// - https://material.angularjs.org/latest/layout/introduction
|
||||
//
|
||||
// Follow this flexbox Guide to better understand the underlying model:
|
||||
// - https://css-tricks.com/snippets/css/a-guide-to-flexbox/
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["className", "columns", "columnSpacing", "component", "container", "direction", "item", "rowSpacing", "spacing", "wrap", "zeroMinWidth"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import { handleBreakpoints, unstable_resolveBreakpointValues as resolveBreakpointValues } from '@mui/system';
|
||||
import { extendSxProp } from '@mui/system/styleFunctionSx';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import requirePropFactory from '../utils/requirePropFactory';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import useTheme from '../styles/useTheme';
|
||||
import GridContext from './GridContext';
|
||||
import gridClasses, { getGridUtilityClass } from './gridClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function getOffset(val) {
|
||||
const parse = parseFloat(val);
|
||||
return `${parse}${String(val).replace(String(parse), '') || 'px'}`;
|
||||
}
|
||||
export function generateGrid({
|
||||
theme,
|
||||
ownerState
|
||||
}) {
|
||||
let size;
|
||||
return theme.breakpoints.keys.reduce((globalStyles, breakpoint) => {
|
||||
// Use side effect over immutability for better performance.
|
||||
let styles = {};
|
||||
if (ownerState[breakpoint]) {
|
||||
size = ownerState[breakpoint];
|
||||
}
|
||||
if (!size) {
|
||||
return globalStyles;
|
||||
}
|
||||
if (size === true) {
|
||||
// For the auto layouting
|
||||
styles = {
|
||||
flexBasis: 0,
|
||||
flexGrow: 1,
|
||||
maxWidth: '100%'
|
||||
};
|
||||
} else if (size === 'auto') {
|
||||
styles = {
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 0,
|
||||
flexShrink: 0,
|
||||
maxWidth: 'none',
|
||||
width: 'auto'
|
||||
};
|
||||
} else {
|
||||
const columnsBreakpointValues = resolveBreakpointValues({
|
||||
values: ownerState.columns,
|
||||
breakpoints: theme.breakpoints.values
|
||||
});
|
||||
const columnValue = typeof columnsBreakpointValues === 'object' ? columnsBreakpointValues[breakpoint] : columnsBreakpointValues;
|
||||
if (columnValue === undefined || columnValue === null) {
|
||||
return globalStyles;
|
||||
}
|
||||
// Keep 7 significant numbers.
|
||||
const width = `${Math.round(size / columnValue * 10e7) / 10e5}%`;
|
||||
let more = {};
|
||||
if (ownerState.container && ownerState.item && ownerState.columnSpacing !== 0) {
|
||||
const themeSpacing = theme.spacing(ownerState.columnSpacing);
|
||||
if (themeSpacing !== '0px') {
|
||||
const fullWidth = `calc(${width} + ${getOffset(themeSpacing)})`;
|
||||
more = {
|
||||
flexBasis: fullWidth,
|
||||
maxWidth: fullWidth
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Close to the bootstrap implementation:
|
||||
// https://github.com/twbs/bootstrap/blob/8fccaa2439e97ec72a4b7dc42ccc1f649790adb0/scss/mixins/_grid.scss#L41
|
||||
styles = _extends({
|
||||
flexBasis: width,
|
||||
flexGrow: 0,
|
||||
maxWidth: width
|
||||
}, more);
|
||||
}
|
||||
|
||||
// No need for a media query for the first size.
|
||||
if (theme.breakpoints.values[breakpoint] === 0) {
|
||||
Object.assign(globalStyles, styles);
|
||||
} else {
|
||||
globalStyles[theme.breakpoints.up(breakpoint)] = styles;
|
||||
}
|
||||
return globalStyles;
|
||||
}, {});
|
||||
}
|
||||
export function generateDirection({
|
||||
theme,
|
||||
ownerState
|
||||
}) {
|
||||
const directionValues = resolveBreakpointValues({
|
||||
values: ownerState.direction,
|
||||
breakpoints: theme.breakpoints.values
|
||||
});
|
||||
return handleBreakpoints({
|
||||
theme
|
||||
}, directionValues, propValue => {
|
||||
const output = {
|
||||
flexDirection: propValue
|
||||
};
|
||||
if (propValue.indexOf('column') === 0) {
|
||||
output[`& > .${gridClasses.item}`] = {
|
||||
maxWidth: 'none'
|
||||
};
|
||||
}
|
||||
return output;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts zero value breakpoint keys before a non-zero value breakpoint key.
|
||||
* @example { xs: 0, sm: 0, md: 2, lg: 0, xl: 0 } or [0, 0, 2, 0, 0]
|
||||
* @returns [xs, sm]
|
||||
*/
|
||||
function extractZeroValueBreakpointKeys({
|
||||
breakpoints,
|
||||
values
|
||||
}) {
|
||||
let nonZeroKey = '';
|
||||
Object.keys(values).forEach(key => {
|
||||
if (nonZeroKey !== '') {
|
||||
return;
|
||||
}
|
||||
if (values[key] !== 0) {
|
||||
nonZeroKey = key;
|
||||
}
|
||||
});
|
||||
const sortedBreakpointKeysByValue = Object.keys(breakpoints).sort((a, b) => {
|
||||
return breakpoints[a] - breakpoints[b];
|
||||
});
|
||||
return sortedBreakpointKeysByValue.slice(0, sortedBreakpointKeysByValue.indexOf(nonZeroKey));
|
||||
}
|
||||
export function generateRowGap({
|
||||
theme,
|
||||
ownerState
|
||||
}) {
|
||||
const {
|
||||
container,
|
||||
rowSpacing
|
||||
} = ownerState;
|
||||
let styles = {};
|
||||
if (container && rowSpacing !== 0) {
|
||||
const rowSpacingValues = resolveBreakpointValues({
|
||||
values: rowSpacing,
|
||||
breakpoints: theme.breakpoints.values
|
||||
});
|
||||
let zeroValueBreakpointKeys;
|
||||
if (typeof rowSpacingValues === 'object') {
|
||||
zeroValueBreakpointKeys = extractZeroValueBreakpointKeys({
|
||||
breakpoints: theme.breakpoints.values,
|
||||
values: rowSpacingValues
|
||||
});
|
||||
}
|
||||
styles = handleBreakpoints({
|
||||
theme
|
||||
}, rowSpacingValues, (propValue, breakpoint) => {
|
||||
var _zeroValueBreakpointK;
|
||||
const themeSpacing = theme.spacing(propValue);
|
||||
if (themeSpacing !== '0px') {
|
||||
return {
|
||||
marginTop: `-${getOffset(themeSpacing)}`,
|
||||
[`& > .${gridClasses.item}`]: {
|
||||
paddingTop: getOffset(themeSpacing)
|
||||
}
|
||||
};
|
||||
}
|
||||
if ((_zeroValueBreakpointK = zeroValueBreakpointKeys) != null && _zeroValueBreakpointK.includes(breakpoint)) {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
marginTop: 0,
|
||||
[`& > .${gridClasses.item}`]: {
|
||||
paddingTop: 0
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
return styles;
|
||||
}
|
||||
export function generateColumnGap({
|
||||
theme,
|
||||
ownerState
|
||||
}) {
|
||||
const {
|
||||
container,
|
||||
columnSpacing
|
||||
} = ownerState;
|
||||
let styles = {};
|
||||
if (container && columnSpacing !== 0) {
|
||||
const columnSpacingValues = resolveBreakpointValues({
|
||||
values: columnSpacing,
|
||||
breakpoints: theme.breakpoints.values
|
||||
});
|
||||
let zeroValueBreakpointKeys;
|
||||
if (typeof columnSpacingValues === 'object') {
|
||||
zeroValueBreakpointKeys = extractZeroValueBreakpointKeys({
|
||||
breakpoints: theme.breakpoints.values,
|
||||
values: columnSpacingValues
|
||||
});
|
||||
}
|
||||
styles = handleBreakpoints({
|
||||
theme
|
||||
}, columnSpacingValues, (propValue, breakpoint) => {
|
||||
var _zeroValueBreakpointK2;
|
||||
const themeSpacing = theme.spacing(propValue);
|
||||
if (themeSpacing !== '0px') {
|
||||
return {
|
||||
width: `calc(100% + ${getOffset(themeSpacing)})`,
|
||||
marginLeft: `-${getOffset(themeSpacing)}`,
|
||||
[`& > .${gridClasses.item}`]: {
|
||||
paddingLeft: getOffset(themeSpacing)
|
||||
}
|
||||
};
|
||||
}
|
||||
if ((_zeroValueBreakpointK2 = zeroValueBreakpointKeys) != null && _zeroValueBreakpointK2.includes(breakpoint)) {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
width: '100%',
|
||||
marginLeft: 0,
|
||||
[`& > .${gridClasses.item}`]: {
|
||||
paddingLeft: 0
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
return styles;
|
||||
}
|
||||
export function resolveSpacingStyles(spacing, breakpoints, styles = {}) {
|
||||
// undefined/null or `spacing` <= 0
|
||||
if (!spacing || spacing <= 0) {
|
||||
return [];
|
||||
}
|
||||
// in case of string/number `spacing`
|
||||
if (typeof spacing === 'string' && !Number.isNaN(Number(spacing)) || typeof spacing === 'number') {
|
||||
return [styles[`spacing-xs-${String(spacing)}`]];
|
||||
}
|
||||
// in case of object `spacing`
|
||||
const spacingStyles = [];
|
||||
breakpoints.forEach(breakpoint => {
|
||||
const value = spacing[breakpoint];
|
||||
if (Number(value) > 0) {
|
||||
spacingStyles.push(styles[`spacing-${breakpoint}-${String(value)}`]);
|
||||
}
|
||||
});
|
||||
return spacingStyles;
|
||||
}
|
||||
|
||||
// Default CSS values
|
||||
// flex: '0 1 auto',
|
||||
// flexDirection: 'row',
|
||||
// alignItems: 'flex-start',
|
||||
// flexWrap: 'nowrap',
|
||||
// justifyContent: 'flex-start',
|
||||
const GridRoot = styled('div', {
|
||||
name: 'MuiGrid',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
const {
|
||||
container,
|
||||
direction,
|
||||
item,
|
||||
spacing,
|
||||
wrap,
|
||||
zeroMinWidth,
|
||||
breakpoints
|
||||
} = ownerState;
|
||||
let spacingStyles = [];
|
||||
|
||||
// in case of grid item
|
||||
if (container) {
|
||||
spacingStyles = resolveSpacingStyles(spacing, breakpoints, styles);
|
||||
}
|
||||
const breakpointsStyles = [];
|
||||
breakpoints.forEach(breakpoint => {
|
||||
const value = ownerState[breakpoint];
|
||||
if (value) {
|
||||
breakpointsStyles.push(styles[`grid-${breakpoint}-${String(value)}`]);
|
||||
}
|
||||
});
|
||||
return [styles.root, container && styles.container, item && styles.item, zeroMinWidth && styles.zeroMinWidth, ...spacingStyles, direction !== 'row' && styles[`direction-xs-${String(direction)}`], wrap !== 'wrap' && styles[`wrap-xs-${String(wrap)}`], ...breakpointsStyles];
|
||||
}
|
||||
})(({
|
||||
ownerState
|
||||
}) => _extends({
|
||||
boxSizing: 'border-box'
|
||||
}, ownerState.container && {
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap',
|
||||
width: '100%'
|
||||
}, ownerState.item && {
|
||||
margin: 0 // For instance, it's useful when used with a `figure` element.
|
||||
}, ownerState.zeroMinWidth && {
|
||||
minWidth: 0
|
||||
}, ownerState.wrap !== 'wrap' && {
|
||||
flexWrap: ownerState.wrap
|
||||
}), generateDirection, generateRowGap, generateColumnGap, generateGrid);
|
||||
export function resolveSpacingClasses(spacing, breakpoints) {
|
||||
// undefined/null or `spacing` <= 0
|
||||
if (!spacing || spacing <= 0) {
|
||||
return [];
|
||||
}
|
||||
// in case of string/number `spacing`
|
||||
if (typeof spacing === 'string' && !Number.isNaN(Number(spacing)) || typeof spacing === 'number') {
|
||||
return [`spacing-xs-${String(spacing)}`];
|
||||
}
|
||||
// in case of object `spacing`
|
||||
const classes = [];
|
||||
breakpoints.forEach(breakpoint => {
|
||||
const value = spacing[breakpoint];
|
||||
if (Number(value) > 0) {
|
||||
const className = `spacing-${breakpoint}-${String(value)}`;
|
||||
classes.push(className);
|
||||
}
|
||||
});
|
||||
return classes;
|
||||
}
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
container,
|
||||
direction,
|
||||
item,
|
||||
spacing,
|
||||
wrap,
|
||||
zeroMinWidth,
|
||||
breakpoints
|
||||
} = ownerState;
|
||||
let spacingClasses = [];
|
||||
|
||||
// in case of grid item
|
||||
if (container) {
|
||||
spacingClasses = resolveSpacingClasses(spacing, breakpoints);
|
||||
}
|
||||
const breakpointsClasses = [];
|
||||
breakpoints.forEach(breakpoint => {
|
||||
const value = ownerState[breakpoint];
|
||||
if (value) {
|
||||
breakpointsClasses.push(`grid-${breakpoint}-${String(value)}`);
|
||||
}
|
||||
});
|
||||
const slots = {
|
||||
root: ['root', container && 'container', item && 'item', zeroMinWidth && 'zeroMinWidth', ...spacingClasses, direction !== 'row' && `direction-xs-${String(direction)}`, wrap !== 'wrap' && `wrap-xs-${String(wrap)}`, ...breakpointsClasses]
|
||||
};
|
||||
return composeClasses(slots, getGridUtilityClass, classes);
|
||||
};
|
||||
const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
|
||||
const themeProps = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiGrid'
|
||||
});
|
||||
const {
|
||||
breakpoints
|
||||
} = useTheme();
|
||||
const props = extendSxProp(themeProps);
|
||||
const {
|
||||
className,
|
||||
columns: columnsProp,
|
||||
columnSpacing: columnSpacingProp,
|
||||
component = 'div',
|
||||
container = false,
|
||||
direction = 'row',
|
||||
item = false,
|
||||
rowSpacing: rowSpacingProp,
|
||||
spacing = 0,
|
||||
wrap = 'wrap',
|
||||
zeroMinWidth = false
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const rowSpacing = rowSpacingProp || spacing;
|
||||
const columnSpacing = columnSpacingProp || spacing;
|
||||
const columnsContext = React.useContext(GridContext);
|
||||
|
||||
// columns set with default breakpoint unit of 12
|
||||
const columns = container ? columnsProp || 12 : columnsContext;
|
||||
const breakpointsValues = {};
|
||||
const otherFiltered = _extends({}, other);
|
||||
breakpoints.keys.forEach(breakpoint => {
|
||||
if (other[breakpoint] != null) {
|
||||
breakpointsValues[breakpoint] = other[breakpoint];
|
||||
delete otherFiltered[breakpoint];
|
||||
}
|
||||
});
|
||||
const ownerState = _extends({}, props, {
|
||||
columns,
|
||||
container,
|
||||
direction,
|
||||
item,
|
||||
rowSpacing,
|
||||
columnSpacing,
|
||||
wrap,
|
||||
zeroMinWidth,
|
||||
spacing
|
||||
}, breakpointsValues, {
|
||||
breakpoints: breakpoints.keys
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(GridContext.Provider, {
|
||||
value: columns,
|
||||
children: /*#__PURE__*/_jsx(GridRoot, _extends({
|
||||
ownerState: ownerState,
|
||||
className: clsx(classes.root, className),
|
||||
as: component,
|
||||
ref: ref
|
||||
}, otherFiltered))
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The number of columns.
|
||||
* @default 12
|
||||
*/
|
||||
columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
|
||||
/**
|
||||
* Defines the horizontal space between the type `item` components.
|
||||
* It overrides the value of the `spacing` prop.
|
||||
*/
|
||||
columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: PropTypes.elementType,
|
||||
/**
|
||||
* If `true`, the component will have the flex *container* behavior.
|
||||
* You should be wrapping *items* with a *container*.
|
||||
* @default false
|
||||
*/
|
||||
container: PropTypes.bool,
|
||||
/**
|
||||
* Defines the `flex-direction` style property.
|
||||
* It is applied for all screen sizes.
|
||||
* @default 'row'
|
||||
*/
|
||||
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
||||
/**
|
||||
* If `true`, the component will have the flex *item* behavior.
|
||||
* You should be wrapping *items* with a *container*.
|
||||
* @default false
|
||||
*/
|
||||
item: PropTypes.bool,
|
||||
/**
|
||||
* If a number, it sets the number of columns the grid item uses.
|
||||
* It can't be greater than the total number of columns of the container (12 by default).
|
||||
* If 'auto', the grid item's width matches its content.
|
||||
* If false, the prop is ignored.
|
||||
* If true, the grid item's width grows to use the space available in the grid container.
|
||||
* The value is applied for the `lg` breakpoint and wider screens if not overridden.
|
||||
* @default false
|
||||
*/
|
||||
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
||||
/**
|
||||
* If a number, it sets the number of columns the grid item uses.
|
||||
* It can't be greater than the total number of columns of the container (12 by default).
|
||||
* If 'auto', the grid item's width matches its content.
|
||||
* If false, the prop is ignored.
|
||||
* If true, the grid item's width grows to use the space available in the grid container.
|
||||
* The value is applied for the `md` breakpoint and wider screens if not overridden.
|
||||
* @default false
|
||||
*/
|
||||
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
||||
/**
|
||||
* Defines the vertical space between the type `item` components.
|
||||
* It overrides the value of the `spacing` prop.
|
||||
*/
|
||||
rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
||||
/**
|
||||
* If a number, it sets the number of columns the grid item uses.
|
||||
* It can't be greater than the total number of columns of the container (12 by default).
|
||||
* If 'auto', the grid item's width matches its content.
|
||||
* If false, the prop is ignored.
|
||||
* If true, the grid item's width grows to use the space available in the grid container.
|
||||
* The value is applied for the `sm` breakpoint and wider screens if not overridden.
|
||||
* @default false
|
||||
*/
|
||||
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
||||
/**
|
||||
* Defines the space between the type `item` components.
|
||||
* It can only be used on a type `container` component.
|
||||
* @default 0
|
||||
*/
|
||||
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* Defines the `flex-wrap` style property.
|
||||
* It's applied for all screen sizes.
|
||||
* @default 'wrap'
|
||||
*/
|
||||
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
||||
/**
|
||||
* If a number, it sets the number of columns the grid item uses.
|
||||
* It can't be greater than the total number of columns of the container (12 by default).
|
||||
* If 'auto', the grid item's width matches its content.
|
||||
* If false, the prop is ignored.
|
||||
* If true, the grid item's width grows to use the space available in the grid container.
|
||||
* The value is applied for the `xl` breakpoint and wider screens if not overridden.
|
||||
* @default false
|
||||
*/
|
||||
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
||||
/**
|
||||
* If a number, it sets the number of columns the grid item uses.
|
||||
* It can't be greater than the total number of columns of the container (12 by default).
|
||||
* If 'auto', the grid item's width matches its content.
|
||||
* If false, the prop is ignored.
|
||||
* If true, the grid item's width grows to use the space available in the grid container.
|
||||
* The value is applied for all the screen sizes with the lowest priority.
|
||||
* @default false
|
||||
*/
|
||||
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
||||
/**
|
||||
* If `true`, it sets `min-width: 0` on the item.
|
||||
* Refer to the limitations section of the documentation to better understand the use case.
|
||||
* @default false
|
||||
*/
|
||||
zeroMinWidth: PropTypes.bool
|
||||
} : void 0;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const requireProp = requirePropFactory('Grid', Grid);
|
||||
// eslint-disable-next-line no-useless-concat
|
||||
Grid['propTypes' + ''] = _extends({}, Grid.propTypes, {
|
||||
direction: requireProp('container'),
|
||||
lg: requireProp('item'),
|
||||
md: requireProp('item'),
|
||||
sm: requireProp('item'),
|
||||
spacing: requireProp('container'),
|
||||
wrap: requireProp('container'),
|
||||
xs: requireProp('item'),
|
||||
zeroMinWidth: requireProp('item')
|
||||
});
|
||||
}
|
||||
export default Grid;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
const GridContext = /*#__PURE__*/React.createContext();
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
GridContext.displayName = 'GridContext';
|
||||
}
|
||||
export default GridContext;
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getGridUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiGrid', slot);
|
||||
}
|
||||
const SPACINGS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
const DIRECTIONS = ['column-reverse', 'column', 'row-reverse', 'row'];
|
||||
const WRAPS = ['nowrap', 'wrap-reverse', 'wrap'];
|
||||
const GRID_SIZES = ['auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
const gridClasses = generateUtilityClasses('MuiGrid', ['root', 'container', 'item', 'zeroMinWidth',
|
||||
// spacings
|
||||
...SPACINGS.map(spacing => `spacing-xs-${spacing}`),
|
||||
// direction values
|
||||
...DIRECTIONS.map(direction => `direction-xs-${direction}`),
|
||||
// wrap values
|
||||
...WRAPS.map(wrap => `wrap-xs-${wrap}`),
|
||||
// grid sizes for all breakpoints
|
||||
...GRID_SIZES.map(size => `grid-xs-${size}`), ...GRID_SIZES.map(size => `grid-sm-${size}`), ...GRID_SIZES.map(size => `grid-md-${size}`), ...GRID_SIZES.map(size => `grid-lg-${size}`), ...GRID_SIZES.map(size => `grid-xl-${size}`)]);
|
||||
export default gridClasses;
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["addEndListener", "appear", "children", "easing", "in", "onEnter", "onEntered", "onEntering", "onExit", "onExited", "onExiting", "style", "timeout", "TransitionComponent"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import useTimeout from '@mui/utils/useTimeout';
|
||||
import elementAcceptingRef from '@mui/utils/elementAcceptingRef';
|
||||
import { Transition } from 'react-transition-group';
|
||||
import useTheme from '../styles/useTheme';
|
||||
import { getTransitionProps, reflow } from '../transitions/utils';
|
||||
import useForkRef from '../utils/useForkRef';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function getScale(value) {
|
||||
return `scale(${value}, ${value ** 2})`;
|
||||
}
|
||||
const styles = {
|
||||
entering: {
|
||||
opacity: 1,
|
||||
transform: getScale(1)
|
||||
},
|
||||
entered: {
|
||||
opacity: 1,
|
||||
transform: 'none'
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
TODO v6: remove
|
||||
Conditionally apply a workaround for the CSS transition bug in Safari 15.4 / WebKit browsers.
|
||||
*/
|
||||
const isWebKit154 = typeof navigator !== 'undefined' && /^((?!chrome|android).)*(safari|mobile)/i.test(navigator.userAgent) && /(os |version\/)15(.|_)4/i.test(navigator.userAgent);
|
||||
|
||||
/**
|
||||
* The Grow transition is used by the [Tooltip](/material-ui/react-tooltip/) and
|
||||
* [Popover](/material-ui/react-popover/) components.
|
||||
* It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
|
||||
*/
|
||||
const Grow = /*#__PURE__*/React.forwardRef(function Grow(props, ref) {
|
||||
const {
|
||||
addEndListener,
|
||||
appear = true,
|
||||
children,
|
||||
easing,
|
||||
in: inProp,
|
||||
onEnter,
|
||||
onEntered,
|
||||
onEntering,
|
||||
onExit,
|
||||
onExited,
|
||||
onExiting,
|
||||
style,
|
||||
timeout = 'auto',
|
||||
// eslint-disable-next-line react/prop-types
|
||||
TransitionComponent = Transition
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const timer = useTimeout();
|
||||
const autoTimeout = React.useRef();
|
||||
const theme = useTheme();
|
||||
const nodeRef = React.useRef(null);
|
||||
const handleRef = useForkRef(nodeRef, children.ref, ref);
|
||||
const normalizedTransitionCallback = callback => maybeIsAppearing => {
|
||||
if (callback) {
|
||||
const node = nodeRef.current;
|
||||
|
||||
// onEnterXxx and onExitXxx callbacks have a different arguments.length value.
|
||||
if (maybeIsAppearing === undefined) {
|
||||
callback(node);
|
||||
} else {
|
||||
callback(node, maybeIsAppearing);
|
||||
}
|
||||
}
|
||||
};
|
||||
const handleEntering = normalizedTransitionCallback(onEntering);
|
||||
const handleEnter = normalizedTransitionCallback((node, isAppearing) => {
|
||||
reflow(node); // So the animation always start from the start.
|
||||
|
||||
const {
|
||||
duration: transitionDuration,
|
||||
delay,
|
||||
easing: transitionTimingFunction
|
||||
} = getTransitionProps({
|
||||
style,
|
||||
timeout,
|
||||
easing
|
||||
}, {
|
||||
mode: 'enter'
|
||||
});
|
||||
let duration;
|
||||
if (timeout === 'auto') {
|
||||
duration = theme.transitions.getAutoHeightDuration(node.clientHeight);
|
||||
autoTimeout.current = duration;
|
||||
} else {
|
||||
duration = transitionDuration;
|
||||
}
|
||||
node.style.transition = [theme.transitions.create('opacity', {
|
||||
duration,
|
||||
delay
|
||||
}), theme.transitions.create('transform', {
|
||||
duration: isWebKit154 ? duration : duration * 0.666,
|
||||
delay,
|
||||
easing: transitionTimingFunction
|
||||
})].join(',');
|
||||
if (onEnter) {
|
||||
onEnter(node, isAppearing);
|
||||
}
|
||||
});
|
||||
const handleEntered = normalizedTransitionCallback(onEntered);
|
||||
const handleExiting = normalizedTransitionCallback(onExiting);
|
||||
const handleExit = normalizedTransitionCallback(node => {
|
||||
const {
|
||||
duration: transitionDuration,
|
||||
delay,
|
||||
easing: transitionTimingFunction
|
||||
} = getTransitionProps({
|
||||
style,
|
||||
timeout,
|
||||
easing
|
||||
}, {
|
||||
mode: 'exit'
|
||||
});
|
||||
let duration;
|
||||
if (timeout === 'auto') {
|
||||
duration = theme.transitions.getAutoHeightDuration(node.clientHeight);
|
||||
autoTimeout.current = duration;
|
||||
} else {
|
||||
duration = transitionDuration;
|
||||
}
|
||||
node.style.transition = [theme.transitions.create('opacity', {
|
||||
duration,
|
||||
delay
|
||||
}), theme.transitions.create('transform', {
|
||||
duration: isWebKit154 ? duration : duration * 0.666,
|
||||
delay: isWebKit154 ? delay : delay || duration * 0.333,
|
||||
easing: transitionTimingFunction
|
||||
})].join(',');
|
||||
node.style.opacity = 0;
|
||||
node.style.transform = getScale(0.75);
|
||||
if (onExit) {
|
||||
onExit(node);
|
||||
}
|
||||
});
|
||||
const handleExited = normalizedTransitionCallback(onExited);
|
||||
const handleAddEndListener = next => {
|
||||
if (timeout === 'auto') {
|
||||
timer.start(autoTimeout.current || 0, next);
|
||||
}
|
||||
if (addEndListener) {
|
||||
// Old call signature before `react-transition-group` implemented `nodeRef`
|
||||
addEndListener(nodeRef.current, next);
|
||||
}
|
||||
};
|
||||
return /*#__PURE__*/_jsx(TransitionComponent, _extends({
|
||||
appear: appear,
|
||||
in: inProp,
|
||||
nodeRef: nodeRef,
|
||||
onEnter: handleEnter,
|
||||
onEntered: handleEntered,
|
||||
onEntering: handleEntering,
|
||||
onExit: handleExit,
|
||||
onExited: handleExited,
|
||||
onExiting: handleExiting,
|
||||
addEndListener: handleAddEndListener,
|
||||
timeout: timeout === 'auto' ? null : timeout
|
||||
}, other, {
|
||||
children: (state, childProps) => {
|
||||
return /*#__PURE__*/React.cloneElement(children, _extends({
|
||||
style: _extends({
|
||||
opacity: 0,
|
||||
transform: getScale(0.75),
|
||||
visibility: state === 'exited' && !inProp ? 'hidden' : undefined
|
||||
}, styles[state], style, children.props.style),
|
||||
ref: handleRef
|
||||
}, childProps));
|
||||
}
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Grow.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* Add a custom transition end trigger. Called with the transitioning DOM
|
||||
* node and a done callback. Allows for more fine grained transition end
|
||||
* logic. Note: Timeouts are still used as a fallback if provided.
|
||||
*/
|
||||
addEndListener: PropTypes.func,
|
||||
/**
|
||||
* Perform the enter transition when it first mounts if `in` is also `true`.
|
||||
* Set this to `false` to disable this behavior.
|
||||
* @default true
|
||||
*/
|
||||
appear: PropTypes.bool,
|
||||
/**
|
||||
* A single child content element.
|
||||
*/
|
||||
children: elementAcceptingRef.isRequired,
|
||||
/**
|
||||
* The transition timing function.
|
||||
* You may specify a single easing or a object containing enter and exit values.
|
||||
*/
|
||||
easing: PropTypes.oneOfType([PropTypes.shape({
|
||||
enter: PropTypes.string,
|
||||
exit: PropTypes.string
|
||||
}), PropTypes.string]),
|
||||
/**
|
||||
* If `true`, the component will transition in.
|
||||
*/
|
||||
in: PropTypes.bool,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEnter: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEntered: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEntering: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExit: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExited: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExiting: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
style: PropTypes.object,
|
||||
/**
|
||||
* The duration for the transition, in milliseconds.
|
||||
* You may specify a single timeout for all transitions, or individually with an object.
|
||||
*
|
||||
* Set to 'auto' to automatically calculate transition time based on height.
|
||||
* @default 'auto'
|
||||
*/
|
||||
timeout: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.shape({
|
||||
appear: PropTypes.number,
|
||||
enter: PropTypes.number,
|
||||
exit: PropTypes.number
|
||||
})])
|
||||
} : void 0;
|
||||
Grow.muiSupportAuto = true;
|
||||
export default Grow;
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["edge", "children", "className", "color", "disabled", "disableFocusRipple", "size"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import chainPropTypes from '@mui/utils/chainPropTypes';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import { alpha } from '@mui/system/colorManipulator';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import ButtonBase from '../ButtonBase';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import iconButtonClasses, { getIconButtonUtilityClass } from './iconButtonClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
disabled,
|
||||
color,
|
||||
edge,
|
||||
size
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', disabled && 'disabled', color !== 'default' && `color${capitalize(color)}`, edge && `edge${capitalize(edge)}`, `size${capitalize(size)}`]
|
||||
};
|
||||
return composeClasses(slots, getIconButtonUtilityClass, classes);
|
||||
};
|
||||
const IconButtonRoot = styled(ButtonBase, {
|
||||
name: 'MuiIconButton',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, ownerState.color !== 'default' && styles[`color${capitalize(ownerState.color)}`], ownerState.edge && styles[`edge${capitalize(ownerState.edge)}`], styles[`size${capitalize(ownerState.size)}`]];
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => _extends({
|
||||
textAlign: 'center',
|
||||
flex: '0 0 auto',
|
||||
fontSize: theme.typography.pxToRem(24),
|
||||
padding: 8,
|
||||
borderRadius: '50%',
|
||||
overflow: 'visible',
|
||||
// Explicitly set the default value to solve a bug on IE11.
|
||||
color: (theme.vars || theme).palette.action.active,
|
||||
transition: theme.transitions.create('background-color', {
|
||||
duration: theme.transitions.duration.shortest
|
||||
})
|
||||
}, !ownerState.disableRipple && {
|
||||
'&:hover': {
|
||||
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.action.activeChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette.action.active, theme.palette.action.hoverOpacity),
|
||||
// Reset on touch devices, it doesn't add specificity
|
||||
'@media (hover: none)': {
|
||||
backgroundColor: 'transparent'
|
||||
}
|
||||
}
|
||||
}, ownerState.edge === 'start' && {
|
||||
marginLeft: ownerState.size === 'small' ? -3 : -12
|
||||
}, ownerState.edge === 'end' && {
|
||||
marginRight: ownerState.size === 'small' ? -3 : -12
|
||||
}), ({
|
||||
theme,
|
||||
ownerState
|
||||
}) => {
|
||||
var _palette;
|
||||
const palette = (_palette = (theme.vars || theme).palette) == null ? void 0 : _palette[ownerState.color];
|
||||
return _extends({}, ownerState.color === 'inherit' && {
|
||||
color: 'inherit'
|
||||
}, ownerState.color !== 'inherit' && ownerState.color !== 'default' && _extends({
|
||||
color: palette == null ? void 0 : palette.main
|
||||
}, !ownerState.disableRipple && {
|
||||
'&:hover': _extends({}, palette && {
|
||||
backgroundColor: theme.vars ? `rgba(${palette.mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(palette.main, theme.palette.action.hoverOpacity)
|
||||
}, {
|
||||
// Reset on touch devices, it doesn't add specificity
|
||||
'@media (hover: none)': {
|
||||
backgroundColor: 'transparent'
|
||||
}
|
||||
})
|
||||
}), ownerState.size === 'small' && {
|
||||
padding: 5,
|
||||
fontSize: theme.typography.pxToRem(18)
|
||||
}, ownerState.size === 'large' && {
|
||||
padding: 12,
|
||||
fontSize: theme.typography.pxToRem(28)
|
||||
}, {
|
||||
[`&.${iconButtonClasses.disabled}`]: {
|
||||
backgroundColor: 'transparent',
|
||||
color: (theme.vars || theme).palette.action.disabled
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Refer to the [Icons](/material-ui/icons/) section of the documentation
|
||||
* regarding the available icon options.
|
||||
*/
|
||||
const IconButton = /*#__PURE__*/React.forwardRef(function IconButton(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiIconButton'
|
||||
});
|
||||
const {
|
||||
edge = false,
|
||||
children,
|
||||
className,
|
||||
color = 'default',
|
||||
disabled = false,
|
||||
disableFocusRipple = false,
|
||||
size = 'medium'
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
edge,
|
||||
color,
|
||||
disabled,
|
||||
disableFocusRipple,
|
||||
size
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(IconButtonRoot, _extends({
|
||||
className: clsx(classes.root, className),
|
||||
centerRipple: true,
|
||||
focusRipple: !disableFocusRipple,
|
||||
disabled: disabled,
|
||||
ref: ref
|
||||
}, other, {
|
||||
ownerState: ownerState,
|
||||
children: children
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? IconButton.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The icon to display.
|
||||
*/
|
||||
children: chainPropTypes(PropTypes.node, props => {
|
||||
const found = React.Children.toArray(props.children).some(child => /*#__PURE__*/React.isValidElement(child) && child.props.onClick);
|
||||
if (found) {
|
||||
return new Error(['MUI: You are providing an onClick event listener to a child of a button element.', 'Prefer applying it to the IconButton directly.', 'This guarantees that the whole <button> will be responsive to click events.'].join('\n'));
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
* @default 'default'
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['inherit', 'default', 'primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the keyboard focus ripple is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disableFocusRipple: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the ripple effect is disabled.
|
||||
*
|
||||
* ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure
|
||||
* to highlight the element by applying separate styles with the `.Mui-focusVisible` class.
|
||||
* @default false
|
||||
*/
|
||||
disableRipple: PropTypes.bool,
|
||||
/**
|
||||
* If given, uses a negative margin to counteract the padding on one
|
||||
* side (this is often helpful for aligning the left or right
|
||||
* side of the icon with content above or below, without ruining the border
|
||||
* size and shape).
|
||||
* @default false
|
||||
*/
|
||||
edge: PropTypes.oneOf(['end', 'start', false]),
|
||||
/**
|
||||
* The size of the component.
|
||||
* `small` is equivalent to the dense button styling.
|
||||
* @default 'medium'
|
||||
*/
|
||||
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['small', 'medium', 'large']), PropTypes.string]),
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
||||
} : void 0;
|
||||
export default IconButton;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getIconButtonUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiIconButton', slot);
|
||||
}
|
||||
const iconButtonClasses = generateUtilityClasses('MuiIconButton', ['root', 'disabled', 'colorInherit', 'colorPrimary', 'colorSecondary', 'colorError', 'colorInfo', 'colorSuccess', 'colorWarning', 'edgeStart', 'edgeEnd', 'sizeSmall', 'sizeMedium', 'sizeLarge']);
|
||||
export default iconButtonClasses;
|
||||
+342
@@ -0,0 +1,342 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["disableUnderline", "components", "componentsProps", "fullWidth", "inputComponent", "multiline", "slotProps", "slots", "type"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import deepmerge from '@mui/utils/deepmerge';
|
||||
import refType from '@mui/utils/refType';
|
||||
import InputBase from '../InputBase';
|
||||
import styled, { rootShouldForwardProp } from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import inputClasses, { getInputUtilityClass } from './inputClasses';
|
||||
import { rootOverridesResolver as inputBaseRootOverridesResolver, inputOverridesResolver as inputBaseInputOverridesResolver, InputBaseRoot, InputBaseComponent as InputBaseInput } from '../InputBase/InputBase';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
disableUnderline
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', !disableUnderline && 'underline'],
|
||||
input: ['input']
|
||||
};
|
||||
const composedClasses = composeClasses(slots, getInputUtilityClass, classes);
|
||||
return _extends({}, classes, composedClasses);
|
||||
};
|
||||
const InputRoot = styled(InputBaseRoot, {
|
||||
shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
|
||||
name: 'MuiInput',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [...inputBaseRootOverridesResolver(props, styles), !ownerState.disableUnderline && styles.underline];
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => {
|
||||
const light = theme.palette.mode === 'light';
|
||||
let bottomLineColor = light ? 'rgba(0, 0, 0, 0.42)' : 'rgba(255, 255, 255, 0.7)';
|
||||
if (theme.vars) {
|
||||
bottomLineColor = `rgba(${theme.vars.palette.common.onBackgroundChannel} / ${theme.vars.opacity.inputUnderline})`;
|
||||
}
|
||||
return _extends({
|
||||
position: 'relative'
|
||||
}, ownerState.formControl && {
|
||||
'label + &': {
|
||||
marginTop: 16
|
||||
}
|
||||
}, !ownerState.disableUnderline && {
|
||||
'&::after': {
|
||||
borderBottom: `2px solid ${(theme.vars || theme).palette[ownerState.color].main}`,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
// Doing the other way around crash on IE11 "''" https://github.com/cssinjs/jss/issues/242
|
||||
content: '""',
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
transform: 'scaleX(0)',
|
||||
transition: theme.transitions.create('transform', {
|
||||
duration: theme.transitions.duration.shorter,
|
||||
easing: theme.transitions.easing.easeOut
|
||||
}),
|
||||
pointerEvents: 'none' // Transparent to the hover style.
|
||||
},
|
||||
[`&.${inputClasses.focused}:after`]: {
|
||||
// translateX(0) is a workaround for Safari transform scale bug
|
||||
// See https://github.com/mui/material-ui/issues/31766
|
||||
transform: 'scaleX(1) translateX(0)'
|
||||
},
|
||||
[`&.${inputClasses.error}`]: {
|
||||
'&::before, &::after': {
|
||||
borderBottomColor: (theme.vars || theme).palette.error.main
|
||||
}
|
||||
},
|
||||
'&::before': {
|
||||
borderBottom: `1px solid ${bottomLineColor}`,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
// Doing the other way around crash on IE11 "''" https://github.com/cssinjs/jss/issues/242
|
||||
content: '"\\00a0"',
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
transition: theme.transitions.create('border-bottom-color', {
|
||||
duration: theme.transitions.duration.shorter
|
||||
}),
|
||||
pointerEvents: 'none' // Transparent to the hover style.
|
||||
},
|
||||
[`&:hover:not(.${inputClasses.disabled}, .${inputClasses.error}):before`]: {
|
||||
borderBottom: `2px solid ${(theme.vars || theme).palette.text.primary}`,
|
||||
// Reset on touch devices, it doesn't add specificity
|
||||
'@media (hover: none)': {
|
||||
borderBottom: `1px solid ${bottomLineColor}`
|
||||
}
|
||||
},
|
||||
[`&.${inputClasses.disabled}:before`]: {
|
||||
borderBottomStyle: 'dotted'
|
||||
}
|
||||
});
|
||||
});
|
||||
const InputInput = styled(InputBaseInput, {
|
||||
name: 'MuiInput',
|
||||
slot: 'Input',
|
||||
overridesResolver: inputBaseInputOverridesResolver
|
||||
})({});
|
||||
const Input = /*#__PURE__*/React.forwardRef(function Input(inProps, ref) {
|
||||
var _ref, _slots$root, _ref2, _slots$input;
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiInput'
|
||||
});
|
||||
const {
|
||||
disableUnderline,
|
||||
components = {},
|
||||
componentsProps: componentsPropsProp,
|
||||
fullWidth = false,
|
||||
inputComponent = 'input',
|
||||
multiline = false,
|
||||
slotProps,
|
||||
slots = {},
|
||||
type = 'text'
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const classes = useUtilityClasses(props);
|
||||
const ownerState = {
|
||||
disableUnderline
|
||||
};
|
||||
const inputComponentsProps = {
|
||||
root: {
|
||||
ownerState
|
||||
}
|
||||
};
|
||||
const componentsProps = (slotProps != null ? slotProps : componentsPropsProp) ? deepmerge(slotProps != null ? slotProps : componentsPropsProp, inputComponentsProps) : inputComponentsProps;
|
||||
const RootSlot = (_ref = (_slots$root = slots.root) != null ? _slots$root : components.Root) != null ? _ref : InputRoot;
|
||||
const InputSlot = (_ref2 = (_slots$input = slots.input) != null ? _slots$input : components.Input) != null ? _ref2 : InputInput;
|
||||
return /*#__PURE__*/_jsx(InputBase, _extends({
|
||||
slots: {
|
||||
root: RootSlot,
|
||||
input: InputSlot
|
||||
},
|
||||
slotProps: componentsProps,
|
||||
fullWidth: fullWidth,
|
||||
inputComponent: inputComponent,
|
||||
multiline: multiline,
|
||||
ref: ref,
|
||||
type: type
|
||||
}, other, {
|
||||
classes: classes
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Input.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* 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,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
* The prop defaults to the value (`'primary'`) inherited from the parent FormControl component.
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary']), PropTypes.string]),
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
*
|
||||
* This prop is an alias for the `slots` prop.
|
||||
* It's recommended to use the `slots` prop instead.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
components: PropTypes.shape({
|
||||
Input: PropTypes.elementType,
|
||||
Root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The extra props for the slot components.
|
||||
* You can override the existing props or add new ones.
|
||||
*
|
||||
* This prop is an alias for the `slotProps` prop.
|
||||
* It's recommended to use the `slotProps` prop instead, as `componentsProps` will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
componentsProps: PropTypes.shape({
|
||||
input: PropTypes.object,
|
||||
root: PropTypes.object
|
||||
}),
|
||||
/**
|
||||
* 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,
|
||||
/**
|
||||
* If `true`, the `input` will not have an underline.
|
||||
*/
|
||||
disableUnderline: PropTypes.bool,
|
||||
/**
|
||||
* End `InputAdornment` for this component.
|
||||
*/
|
||||
endAdornment: PropTypes.node,
|
||||
/**
|
||||
* If `true`, the `input` will indicate an error.
|
||||
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
|
||||
*/
|
||||
error: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the `input` will take up the full width of its container.
|
||||
* @default false
|
||||
*/
|
||||
fullWidth: PropTypes.bool,
|
||||
/**
|
||||
* The id of the `input` element.
|
||||
*/
|
||||
id: PropTypes.string,
|
||||
/**
|
||||
* The component used for the `input` element.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default 'input'
|
||||
*/
|
||||
inputComponent: PropTypes.elementType,
|
||||
/**
|
||||
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
||||
* @default {}
|
||||
*/
|
||||
inputProps: PropTypes.object,
|
||||
/**
|
||||
* Pass a ref to the `input` element.
|
||||
*/
|
||||
inputRef: refType,
|
||||
/**
|
||||
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
||||
* FormControl.
|
||||
* The prop defaults to the value (`'none'`) inherited from the parent FormControl component.
|
||||
*/
|
||||
margin: PropTypes.oneOf(['dense', 'none']),
|
||||
/**
|
||||
* Maximum number of rows to display when multiline option is set to true.
|
||||
*/
|
||||
maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* Minimum number of rows to display when multiline option is set to true.
|
||||
*/
|
||||
minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* If `true`, a [TextareaAutosize](/material-ui/react-textarea-autosize/) element is rendered.
|
||||
* @default false
|
||||
*/
|
||||
multiline: PropTypes.bool,
|
||||
/**
|
||||
* Name attribute of the `input` element.
|
||||
*/
|
||||
name: PropTypes.string,
|
||||
/**
|
||||
* Callback fired when the value is changed.
|
||||
*
|
||||
* @param {React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>} event The event source of the callback.
|
||||
* You can pull out the new value by accessing `event.target.value` (string).
|
||||
*/
|
||||
onChange: 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.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* The extra props for the slot components.
|
||||
* You can override the existing props or add new ones.
|
||||
*
|
||||
* This prop is an alias for the `componentsProps` prop, which will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
input: PropTypes.object,
|
||||
root: PropTypes.object
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
*
|
||||
* This prop is an alias for the `components` prop, which will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
input: PropTypes.elementType,
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* Start `InputAdornment` for this component.
|
||||
*/
|
||||
startAdornment: PropTypes.node,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* 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.string,
|
||||
/**
|
||||
* The value of the `input` element, required for a controlled component.
|
||||
*/
|
||||
value: PropTypes.any
|
||||
} : void 0;
|
||||
Input.muiName = 'Input';
|
||||
export default Input;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
import { inputBaseClasses } from '../InputBase';
|
||||
export function getInputUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiInput', slot);
|
||||
}
|
||||
const inputClasses = _extends({}, inputBaseClasses, generateUtilityClasses('MuiInput', ['root', 'underline', 'input']));
|
||||
export default inputClasses;
|
||||
+710
@@ -0,0 +1,710 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
||||
const _excluded = ["aria-describedby", "autoComplete", "autoFocus", "className", "color", "components", "componentsProps", "defaultValue", "disabled", "disableInjectingGlobalStyles", "endAdornment", "error", "fullWidth", "id", "inputComponent", "inputProps", "inputRef", "margin", "maxRows", "minRows", "multiline", "name", "onBlur", "onChange", "onClick", "onFocus", "onKeyDown", "onKeyUp", "placeholder", "readOnly", "renderSuffix", "rows", "size", "slotProps", "slots", "startAdornment", "type", "value"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
|
||||
import refType from '@mui/utils/refType';
|
||||
import { TextareaAutosize } from '@mui/base';
|
||||
import { isHostComponent } from '@mui/base/utils';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import formControlState from '../FormControl/formControlState';
|
||||
import FormControlContext from '../FormControl/FormControlContext';
|
||||
import useFormControl from '../FormControl/useFormControl';
|
||||
import styled from '../styles/styled';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import useForkRef from '../utils/useForkRef';
|
||||
import useEnhancedEffect from '../utils/useEnhancedEffect';
|
||||
import GlobalStyles from '../GlobalStyles';
|
||||
import { isFilled } from './utils';
|
||||
import inputBaseClasses, { getInputBaseUtilityClass } from './inputBaseClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
export const rootOverridesResolver = (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.root, ownerState.formControl && styles.formControl, ownerState.startAdornment && styles.adornedStart, ownerState.endAdornment && styles.adornedEnd, ownerState.error && styles.error, ownerState.size === 'small' && styles.sizeSmall, ownerState.multiline && styles.multiline, ownerState.color && styles[`color${capitalize(ownerState.color)}`], ownerState.fullWidth && styles.fullWidth, ownerState.hiddenLabel && styles.hiddenLabel];
|
||||
};
|
||||
export const inputOverridesResolver = (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [styles.input, ownerState.size === 'small' && styles.inputSizeSmall, ownerState.multiline && styles.inputMultiline, ownerState.type === 'search' && styles.inputTypeSearch, ownerState.startAdornment && styles.inputAdornedStart, ownerState.endAdornment && styles.inputAdornedEnd, ownerState.hiddenLabel && styles.inputHiddenLabel];
|
||||
};
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
color,
|
||||
disabled,
|
||||
error,
|
||||
endAdornment,
|
||||
focused,
|
||||
formControl,
|
||||
fullWidth,
|
||||
hiddenLabel,
|
||||
multiline,
|
||||
readOnly,
|
||||
size,
|
||||
startAdornment,
|
||||
type
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', `color${capitalize(color)}`, disabled && 'disabled', error && 'error', fullWidth && 'fullWidth', focused && 'focused', formControl && 'formControl', size && size !== 'medium' && `size${capitalize(size)}`, multiline && 'multiline', startAdornment && 'adornedStart', endAdornment && 'adornedEnd', hiddenLabel && 'hiddenLabel', readOnly && 'readOnly'],
|
||||
input: ['input', disabled && 'disabled', type === 'search' && 'inputTypeSearch', multiline && 'inputMultiline', size === 'small' && 'inputSizeSmall', hiddenLabel && 'inputHiddenLabel', startAdornment && 'inputAdornedStart', endAdornment && 'inputAdornedEnd', readOnly && 'readOnly']
|
||||
};
|
||||
return composeClasses(slots, getInputBaseUtilityClass, classes);
|
||||
};
|
||||
export const InputBaseRoot = styled('div', {
|
||||
name: 'MuiInputBase',
|
||||
slot: 'Root',
|
||||
overridesResolver: rootOverridesResolver
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => _extends({}, theme.typography.body1, {
|
||||
color: (theme.vars || theme).palette.text.primary,
|
||||
lineHeight: '1.4375em',
|
||||
// 23px
|
||||
boxSizing: 'border-box',
|
||||
// Prevent padding issue with fullWidth.
|
||||
position: 'relative',
|
||||
cursor: 'text',
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
[`&.${inputBaseClasses.disabled}`]: {
|
||||
color: (theme.vars || theme).palette.text.disabled,
|
||||
cursor: 'default'
|
||||
}
|
||||
}, ownerState.multiline && _extends({
|
||||
padding: '4px 0 5px'
|
||||
}, ownerState.size === 'small' && {
|
||||
paddingTop: 1
|
||||
}), ownerState.fullWidth && {
|
||||
width: '100%'
|
||||
}));
|
||||
export const InputBaseComponent = styled('input', {
|
||||
name: 'MuiInputBase',
|
||||
slot: 'Input',
|
||||
overridesResolver: inputOverridesResolver
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => {
|
||||
const light = theme.palette.mode === 'light';
|
||||
const placeholder = _extends({
|
||||
color: 'currentColor'
|
||||
}, theme.vars ? {
|
||||
opacity: theme.vars.opacity.inputPlaceholder
|
||||
} : {
|
||||
opacity: light ? 0.42 : 0.5
|
||||
}, {
|
||||
transition: theme.transitions.create('opacity', {
|
||||
duration: theme.transitions.duration.shorter
|
||||
})
|
||||
});
|
||||
const placeholderHidden = {
|
||||
opacity: '0 !important'
|
||||
};
|
||||
const placeholderVisible = theme.vars ? {
|
||||
opacity: theme.vars.opacity.inputPlaceholder
|
||||
} : {
|
||||
opacity: light ? 0.42 : 0.5
|
||||
};
|
||||
return _extends({
|
||||
font: 'inherit',
|
||||
letterSpacing: 'inherit',
|
||||
color: 'currentColor',
|
||||
padding: '4px 0 5px',
|
||||
border: 0,
|
||||
boxSizing: 'content-box',
|
||||
background: 'none',
|
||||
height: '1.4375em',
|
||||
// Reset 23pxthe native input line-height
|
||||
margin: 0,
|
||||
// Reset for Safari
|
||||
WebkitTapHighlightColor: 'transparent',
|
||||
display: 'block',
|
||||
// Make the flex item shrink with Firefox
|
||||
minWidth: 0,
|
||||
width: '100%',
|
||||
// Fix IE11 width issue
|
||||
animationName: 'mui-auto-fill-cancel',
|
||||
animationDuration: '10ms',
|
||||
'&::-webkit-input-placeholder': placeholder,
|
||||
'&::-moz-placeholder': placeholder,
|
||||
// Firefox 19+
|
||||
'&:-ms-input-placeholder': placeholder,
|
||||
// IE11
|
||||
'&::-ms-input-placeholder': placeholder,
|
||||
// Edge
|
||||
'&:focus': {
|
||||
outline: 0
|
||||
},
|
||||
// Reset Firefox invalid required input style
|
||||
'&:invalid': {
|
||||
boxShadow: 'none'
|
||||
},
|
||||
'&::-webkit-search-decoration': {
|
||||
// Remove the padding when type=search.
|
||||
WebkitAppearance: 'none'
|
||||
},
|
||||
// Show and hide the placeholder logic
|
||||
[`label[data-shrink=false] + .${inputBaseClasses.formControl} &`]: {
|
||||
'&::-webkit-input-placeholder': placeholderHidden,
|
||||
'&::-moz-placeholder': placeholderHidden,
|
||||
// Firefox 19+
|
||||
'&:-ms-input-placeholder': placeholderHidden,
|
||||
// IE11
|
||||
'&::-ms-input-placeholder': placeholderHidden,
|
||||
// Edge
|
||||
'&:focus::-webkit-input-placeholder': placeholderVisible,
|
||||
'&:focus::-moz-placeholder': placeholderVisible,
|
||||
// Firefox 19+
|
||||
'&:focus:-ms-input-placeholder': placeholderVisible,
|
||||
// IE11
|
||||
'&:focus::-ms-input-placeholder': placeholderVisible // Edge
|
||||
},
|
||||
[`&.${inputBaseClasses.disabled}`]: {
|
||||
opacity: 1,
|
||||
// Reset iOS opacity
|
||||
WebkitTextFillColor: (theme.vars || theme).palette.text.disabled // Fix opacity Safari bug
|
||||
},
|
||||
'&:-webkit-autofill': {
|
||||
animationDuration: '5000s',
|
||||
animationName: 'mui-auto-fill'
|
||||
}
|
||||
}, ownerState.size === 'small' && {
|
||||
paddingTop: 1
|
||||
}, ownerState.multiline && {
|
||||
height: 'auto',
|
||||
resize: 'none',
|
||||
padding: 0,
|
||||
paddingTop: 0
|
||||
}, ownerState.type === 'search' && {
|
||||
// Improve type search style.
|
||||
MozAppearance: 'textfield'
|
||||
});
|
||||
});
|
||||
const inputGlobalStyles = /*#__PURE__*/_jsx(GlobalStyles, {
|
||||
styles: {
|
||||
'@keyframes mui-auto-fill': {
|
||||
from: {
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
'@keyframes mui-auto-fill-cancel': {
|
||||
from: {
|
||||
display: 'block'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* `InputBase` contains as few styles as possible.
|
||||
* It aims to be a simple building block for creating an input.
|
||||
* It contains a load of style reset and some state logic.
|
||||
*/
|
||||
const InputBase = /*#__PURE__*/React.forwardRef(function InputBase(inProps, ref) {
|
||||
var _slotProps$input;
|
||||
const props = useThemeProps({
|
||||
props: inProps,
|
||||
name: 'MuiInputBase'
|
||||
});
|
||||
const {
|
||||
'aria-describedby': ariaDescribedby,
|
||||
autoComplete,
|
||||
autoFocus,
|
||||
className,
|
||||
components = {},
|
||||
componentsProps = {},
|
||||
defaultValue,
|
||||
disabled,
|
||||
disableInjectingGlobalStyles,
|
||||
endAdornment,
|
||||
fullWidth = false,
|
||||
id,
|
||||
inputComponent = 'input',
|
||||
inputProps: inputPropsProp = {},
|
||||
inputRef: inputRefProp,
|
||||
maxRows,
|
||||
minRows,
|
||||
multiline = false,
|
||||
name,
|
||||
onBlur,
|
||||
onChange,
|
||||
onClick,
|
||||
onFocus,
|
||||
onKeyDown,
|
||||
onKeyUp,
|
||||
placeholder,
|
||||
readOnly,
|
||||
renderSuffix,
|
||||
rows,
|
||||
slotProps = {},
|
||||
slots = {},
|
||||
startAdornment,
|
||||
type = 'text',
|
||||
value: valueProp
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const value = inputPropsProp.value != null ? inputPropsProp.value : valueProp;
|
||||
const {
|
||||
current: isControlled
|
||||
} = React.useRef(value != null);
|
||||
const inputRef = React.useRef();
|
||||
const handleInputRefWarning = React.useCallback(instance => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (instance && instance.nodeName !== 'INPUT' && !instance.focus) {
|
||||
console.error(['MUI: You have provided a `inputComponent` to the input component', 'that does not correctly handle the `ref` prop.', 'Make sure the `ref` prop is called with a HTMLInputElement.'].join('\n'));
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
const handleInputRef = useForkRef(inputRef, inputRefProp, inputPropsProp.ref, handleInputRefWarning);
|
||||
const [focused, setFocused] = React.useState(false);
|
||||
const muiFormControl = useFormControl();
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
React.useEffect(() => {
|
||||
if (muiFormControl) {
|
||||
return muiFormControl.registerEffect();
|
||||
}
|
||||
return undefined;
|
||||
}, [muiFormControl]);
|
||||
}
|
||||
const fcs = formControlState({
|
||||
props,
|
||||
muiFormControl,
|
||||
states: ['color', 'disabled', 'error', 'hiddenLabel', 'size', 'required', 'filled']
|
||||
});
|
||||
fcs.focused = muiFormControl ? muiFormControl.focused : focused;
|
||||
|
||||
// The blur won't fire when the disabled state is set on a focused input.
|
||||
// We need to book keep the focused state manually.
|
||||
React.useEffect(() => {
|
||||
if (!muiFormControl && disabled && focused) {
|
||||
setFocused(false);
|
||||
if (onBlur) {
|
||||
onBlur();
|
||||
}
|
||||
}
|
||||
}, [muiFormControl, disabled, focused, onBlur]);
|
||||
const onFilled = muiFormControl && muiFormControl.onFilled;
|
||||
const onEmpty = muiFormControl && muiFormControl.onEmpty;
|
||||
const checkDirty = React.useCallback(obj => {
|
||||
if (isFilled(obj)) {
|
||||
if (onFilled) {
|
||||
onFilled();
|
||||
}
|
||||
} else if (onEmpty) {
|
||||
onEmpty();
|
||||
}
|
||||
}, [onFilled, onEmpty]);
|
||||
useEnhancedEffect(() => {
|
||||
if (isControlled) {
|
||||
checkDirty({
|
||||
value
|
||||
});
|
||||
}
|
||||
}, [value, checkDirty, isControlled]);
|
||||
const handleFocus = event => {
|
||||
// Fix a bug with IE11 where the focus/blur events are triggered
|
||||
// while the component is disabled.
|
||||
if (fcs.disabled) {
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
if (onFocus) {
|
||||
onFocus(event);
|
||||
}
|
||||
if (inputPropsProp.onFocus) {
|
||||
inputPropsProp.onFocus(event);
|
||||
}
|
||||
if (muiFormControl && muiFormControl.onFocus) {
|
||||
muiFormControl.onFocus(event);
|
||||
} else {
|
||||
setFocused(true);
|
||||
}
|
||||
};
|
||||
const handleBlur = event => {
|
||||
if (onBlur) {
|
||||
onBlur(event);
|
||||
}
|
||||
if (inputPropsProp.onBlur) {
|
||||
inputPropsProp.onBlur(event);
|
||||
}
|
||||
if (muiFormControl && muiFormControl.onBlur) {
|
||||
muiFormControl.onBlur(event);
|
||||
} else {
|
||||
setFocused(false);
|
||||
}
|
||||
};
|
||||
const handleChange = (event, ...args) => {
|
||||
if (!isControlled) {
|
||||
const element = event.target || inputRef.current;
|
||||
if (element == null) {
|
||||
throw new Error(process.env.NODE_ENV !== "production" ? `MUI: Expected valid input target. Did you use a custom \`inputComponent\` and forget to forward refs? See https://mui.com/r/input-component-ref-interface for more info.` : _formatMuiErrorMessage(1));
|
||||
}
|
||||
checkDirty({
|
||||
value: element.value
|
||||
});
|
||||
}
|
||||
if (inputPropsProp.onChange) {
|
||||
inputPropsProp.onChange(event, ...args);
|
||||
}
|
||||
|
||||
// Perform in the willUpdate
|
||||
if (onChange) {
|
||||
onChange(event, ...args);
|
||||
}
|
||||
};
|
||||
|
||||
// Check the input state on mount, in case it was filled by the user
|
||||
// or auto filled by the browser before the hydration (for SSR).
|
||||
React.useEffect(() => {
|
||||
checkDirty(inputRef.current);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
const handleClick = event => {
|
||||
if (inputRef.current && event.currentTarget === event.target) {
|
||||
inputRef.current.focus();
|
||||
}
|
||||
if (onClick) {
|
||||
onClick(event);
|
||||
}
|
||||
};
|
||||
let InputComponent = inputComponent;
|
||||
let inputProps = inputPropsProp;
|
||||
if (multiline && InputComponent === 'input') {
|
||||
if (rows) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (minRows || maxRows) {
|
||||
console.warn('MUI: You can not use the `minRows` or `maxRows` props when the input `rows` prop is set.');
|
||||
}
|
||||
}
|
||||
inputProps = _extends({
|
||||
type: undefined,
|
||||
minRows: rows,
|
||||
maxRows: rows
|
||||
}, inputProps);
|
||||
} else {
|
||||
inputProps = _extends({
|
||||
type: undefined,
|
||||
maxRows,
|
||||
minRows
|
||||
}, inputProps);
|
||||
}
|
||||
InputComponent = TextareaAutosize;
|
||||
}
|
||||
const handleAutoFill = event => {
|
||||
// Provide a fake value as Chrome might not let you access it for security reasons.
|
||||
checkDirty(event.animationName === 'mui-auto-fill-cancel' ? inputRef.current : {
|
||||
value: 'x'
|
||||
});
|
||||
};
|
||||
React.useEffect(() => {
|
||||
if (muiFormControl) {
|
||||
muiFormControl.setAdornedStart(Boolean(startAdornment));
|
||||
}
|
||||
}, [muiFormControl, startAdornment]);
|
||||
const ownerState = _extends({}, props, {
|
||||
color: fcs.color || 'primary',
|
||||
disabled: fcs.disabled,
|
||||
endAdornment,
|
||||
error: fcs.error,
|
||||
focused: fcs.focused,
|
||||
formControl: muiFormControl,
|
||||
fullWidth,
|
||||
hiddenLabel: fcs.hiddenLabel,
|
||||
multiline,
|
||||
size: fcs.size,
|
||||
startAdornment,
|
||||
type
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const Root = slots.root || components.Root || InputBaseRoot;
|
||||
const rootProps = slotProps.root || componentsProps.root || {};
|
||||
const Input = slots.input || components.Input || InputBaseComponent;
|
||||
inputProps = _extends({}, inputProps, (_slotProps$input = slotProps.input) != null ? _slotProps$input : componentsProps.input);
|
||||
return /*#__PURE__*/_jsxs(React.Fragment, {
|
||||
children: [!disableInjectingGlobalStyles && inputGlobalStyles, /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, !isHostComponent(Root) && {
|
||||
ownerState: _extends({}, ownerState, rootProps.ownerState)
|
||||
}, {
|
||||
ref: ref,
|
||||
onClick: handleClick
|
||||
}, other, {
|
||||
className: clsx(classes.root, rootProps.className, className, readOnly && 'MuiInputBase-readOnly'),
|
||||
children: [startAdornment, /*#__PURE__*/_jsx(FormControlContext.Provider, {
|
||||
value: null,
|
||||
children: /*#__PURE__*/_jsx(Input, _extends({
|
||||
ownerState: ownerState,
|
||||
"aria-invalid": fcs.error,
|
||||
"aria-describedby": ariaDescribedby,
|
||||
autoComplete: autoComplete,
|
||||
autoFocus: autoFocus,
|
||||
defaultValue: defaultValue,
|
||||
disabled: fcs.disabled,
|
||||
id: id,
|
||||
onAnimationStart: handleAutoFill,
|
||||
name: name,
|
||||
placeholder: placeholder,
|
||||
readOnly: readOnly,
|
||||
required: fcs.required,
|
||||
rows: rows,
|
||||
value: value,
|
||||
onKeyDown: onKeyDown,
|
||||
onKeyUp: onKeyUp,
|
||||
type: type
|
||||
}, inputProps, !isHostComponent(Input) && {
|
||||
as: InputComponent,
|
||||
ownerState: _extends({}, ownerState, inputProps.ownerState)
|
||||
}, {
|
||||
ref: handleInputRef,
|
||||
className: clsx(classes.input, inputProps.className, readOnly && 'MuiInputBase-readOnly'),
|
||||
onBlur: handleBlur,
|
||||
onChange: handleChange,
|
||||
onFocus: handleFocus
|
||||
}))
|
||||
}), endAdornment, renderSuffix ? renderSuffix(_extends({}, fcs, {
|
||||
startAdornment
|
||||
})) : null]
|
||||
}))]
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? InputBase.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
'aria-describedby': 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,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
* The prop defaults to the value (`'primary'`) inherited from the parent FormControl component.
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
*
|
||||
* This prop is an alias for the `slots` prop.
|
||||
* It's recommended to use the `slots` prop instead.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
components: PropTypes.shape({
|
||||
Input: PropTypes.elementType,
|
||||
Root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The extra props for the slot components.
|
||||
* You can override the existing props or add new ones.
|
||||
*
|
||||
* This prop is an alias for the `slotProps` prop.
|
||||
* It's recommended to use the `slotProps` prop instead, as `componentsProps` will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
componentsProps: PropTypes.shape({
|
||||
input: PropTypes.object,
|
||||
root: PropTypes.object
|
||||
}),
|
||||
/**
|
||||
* 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,
|
||||
/**
|
||||
* If `true`, GlobalStyles for the auto-fill keyframes will not be injected/removed on mount/unmount. Make sure to inject them at the top of your application.
|
||||
* This option is intended to help with boosting the initial rendering performance if you are loading a big amount of Input components at once.
|
||||
* @default false
|
||||
*/
|
||||
disableInjectingGlobalStyles: PropTypes.bool,
|
||||
/**
|
||||
* End `InputAdornment` for this component.
|
||||
*/
|
||||
endAdornment: PropTypes.node,
|
||||
/**
|
||||
* If `true`, the `input` will indicate an error.
|
||||
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
|
||||
*/
|
||||
error: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the `input` will take up the full width of its container.
|
||||
* @default false
|
||||
*/
|
||||
fullWidth: PropTypes.bool,
|
||||
/**
|
||||
* The id of the `input` element.
|
||||
*/
|
||||
id: PropTypes.string,
|
||||
/**
|
||||
* The component used for the `input` element.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default 'input'
|
||||
*/
|
||||
inputComponent: elementTypeAcceptingRef,
|
||||
/**
|
||||
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
||||
* @default {}
|
||||
*/
|
||||
inputProps: PropTypes.object,
|
||||
/**
|
||||
* Pass a ref to the `input` element.
|
||||
*/
|
||||
inputRef: refType,
|
||||
/**
|
||||
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
||||
* FormControl.
|
||||
* The prop defaults to the value (`'none'`) inherited from the parent FormControl component.
|
||||
*/
|
||||
margin: PropTypes.oneOf(['dense', 'none']),
|
||||
/**
|
||||
* Maximum number of rows to display when multiline option is set to true.
|
||||
*/
|
||||
maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* Minimum number of rows to display when multiline option is set to true.
|
||||
*/
|
||||
minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* If `true`, a [TextareaAutosize](/material-ui/react-textarea-autosize/) element is rendered.
|
||||
* @default false
|
||||
*/
|
||||
multiline: PropTypes.bool,
|
||||
/**
|
||||
* Name attribute of the `input` element.
|
||||
*/
|
||||
name: PropTypes.string,
|
||||
/**
|
||||
* Callback fired when the `input` is blurred.
|
||||
*
|
||||
* Notice that the first argument (event) might be undefined.
|
||||
*/
|
||||
onBlur: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the value is changed.
|
||||
*
|
||||
* @param {React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>} event The event source of the callback.
|
||||
* You can pull out the new value by accessing `event.target.value` (string).
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onFocus: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the `input` doesn't satisfy its constraints.
|
||||
*/
|
||||
onInvalid: 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,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
renderSuffix: PropTypes.func,
|
||||
/**
|
||||
* 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.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* The size of the component.
|
||||
*/
|
||||
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
||||
/**
|
||||
* The extra props for the slot components.
|
||||
* You can override the existing props or add new ones.
|
||||
*
|
||||
* This prop is an alias for the `componentsProps` prop, which will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
input: PropTypes.object,
|
||||
root: PropTypes.object
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
*
|
||||
* This prop is an alias for the `components` prop, which will be deprecated in the future.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
input: PropTypes.elementType,
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* Start `InputAdornment` for this component.
|
||||
*/
|
||||
startAdornment: PropTypes.node,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* 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.string,
|
||||
/**
|
||||
* The value of the `input` element, required for a controlled component.
|
||||
*/
|
||||
value: PropTypes.any
|
||||
} : void 0;
|
||||
export default InputBase;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getInputBaseUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiInputBase', slot);
|
||||
}
|
||||
const inputBaseClasses = generateUtilityClasses('MuiInputBase', ['root', 'formControl', 'focused', 'disabled', 'adornedStart', 'adornedEnd', 'error', 'sizeSmall', 'multiline', 'colorSecondary', 'fullWidth', 'hiddenLabel', 'readOnly', 'input', 'inputSizeSmall', 'inputMultiline', 'inputTypeSearch', 'inputAdornedStart', 'inputAdornedEnd', 'inputHiddenLabel']);
|
||||
export default inputBaseClasses;
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// Supports determination of isControlled().
|
||||
// Controlled input accepts its current value as a prop.
|
||||
//
|
||||
// @see https://facebook.github.io/react/docs/forms.html#controlled-components
|
||||
// @param value
|
||||
// @returns {boolean} true if string (including '') or number (including zero)
|
||||
export function hasValue(value) {
|
||||
return value != null && !(Array.isArray(value) && value.length === 0);
|
||||
}
|
||||
|
||||
// Determine if field is empty or filled.
|
||||
// Response determines if label is presented above field or as placeholder.
|
||||
//
|
||||
// @param obj
|
||||
// @param SSR
|
||||
// @returns {boolean} False when not present or empty string.
|
||||
// True when any number or string with length.
|
||||
export function isFilled(obj, SSR = false) {
|
||||
return obj && (hasValue(obj.value) && obj.value !== '' || SSR && hasValue(obj.defaultValue) && obj.defaultValue !== '');
|
||||
}
|
||||
|
||||
// Determine if an Input is adorned on start.
|
||||
// It's corresponding to the left with LTR.
|
||||
//
|
||||
// @param obj
|
||||
// @returns {boolean} False when no adornments.
|
||||
// True when adorned at the start.
|
||||
export function isAdornedStart(obj) {
|
||||
return obj.startAdornment;
|
||||
}
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
'use client';
|
||||
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
const _excluded = ["disableAnimation", "margin", "shrink", "variant", "className"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import clsx from 'clsx';
|
||||
import formControlState from '../FormControl/formControlState';
|
||||
import useFormControl from '../FormControl/useFormControl';
|
||||
import FormLabel, { formLabelClasses } from '../FormLabel';
|
||||
import useThemeProps from '../styles/useThemeProps';
|
||||
import capitalize from '../utils/capitalize';
|
||||
import styled, { rootShouldForwardProp } from '../styles/styled';
|
||||
import { getInputLabelUtilityClasses } from './inputLabelClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
classes,
|
||||
formControl,
|
||||
size,
|
||||
shrink,
|
||||
disableAnimation,
|
||||
variant,
|
||||
required
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', formControl && 'formControl', !disableAnimation && 'animated', shrink && 'shrink', size && size !== 'normal' && `size${capitalize(size)}`, variant],
|
||||
asterisk: [required && 'asterisk']
|
||||
};
|
||||
const composedClasses = composeClasses(slots, getInputLabelUtilityClasses, classes);
|
||||
return _extends({}, classes, composedClasses);
|
||||
};
|
||||
const InputLabelRoot = styled(FormLabel, {
|
||||
shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
|
||||
name: 'MuiInputLabel',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => {
|
||||
const {
|
||||
ownerState
|
||||
} = props;
|
||||
return [{
|
||||
[`& .${formLabelClasses.asterisk}`]: styles.asterisk
|
||||
}, styles.root, ownerState.formControl && styles.formControl, ownerState.size === 'small' && styles.sizeSmall, ownerState.shrink && styles.shrink, !ownerState.disableAnimation && styles.animated, ownerState.focused && styles.focused, styles[ownerState.variant]];
|
||||
}
|
||||
})(({
|
||||
theme,
|
||||
ownerState
|
||||
}) => _extends({
|
||||
display: 'block',
|
||||
transformOrigin: 'top left',
|
||||
whiteSpace: 'nowrap',
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
maxWidth: '100%'
|
||||
}, ownerState.formControl && {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
top: 0,
|
||||
// slight alteration to spec spacing to match visual spec result
|
||||
transform: 'translate(0, 20px) scale(1)'
|
||||
}, ownerState.size === 'small' && {
|
||||
// Compensation for the `Input.inputSizeSmall` style.
|
||||
transform: 'translate(0, 17px) scale(1)'
|
||||
}, ownerState.shrink && {
|
||||
transform: 'translate(0, -1.5px) scale(0.75)',
|
||||
transformOrigin: 'top left',
|
||||
maxWidth: '133%'
|
||||
}, !ownerState.disableAnimation && {
|
||||
transition: theme.transitions.create(['color', 'transform', 'max-width'], {
|
||||
duration: theme.transitions.duration.shorter,
|
||||
easing: theme.transitions.easing.easeOut
|
||||
})
|
||||
}, ownerState.variant === 'filled' && _extends({
|
||||
// Chrome's autofill feature gives the input field a yellow background.
|
||||
// Since the input field is behind the label in the HTML tree,
|
||||
// the input field is drawn last and hides the label with an opaque background color.
|
||||
// zIndex: 1 will raise the label above opaque background-colors of input.
|
||||
zIndex: 1,
|
||||
pointerEvents: 'none',
|
||||
transform: 'translate(12px, 16px) scale(1)',
|
||||
maxWidth: 'calc(100% - 24px)'
|
||||
}, ownerState.size === 'small' && {
|
||||
transform: 'translate(12px, 13px) scale(1)'
|
||||
}, ownerState.shrink && _extends({
|
||||
userSelect: 'none',
|
||||
pointerEvents: 'auto',
|
||||
transform: 'translate(12px, 7px) scale(0.75)',
|
||||
maxWidth: 'calc(133% - 24px)'
|
||||
}, ownerState.size === 'small' && {
|
||||
transform: 'translate(12px, 4px) scale(0.75)'
|
||||
})), ownerState.variant === 'outlined' && _extends({
|
||||
// see comment above on filled.zIndex
|
||||
zIndex: 1,
|
||||
pointerEvents: 'none',
|
||||
transform: 'translate(14px, 16px) scale(1)',
|
||||
maxWidth: 'calc(100% - 24px)'
|
||||
}, ownerState.size === 'small' && {
|
||||
transform: 'translate(14px, 9px) scale(1)'
|
||||
}, ownerState.shrink && {
|
||||
userSelect: 'none',
|
||||
pointerEvents: 'auto',
|
||||
// Theoretically, we should have (8+5)*2/0.75 = 34px
|
||||
// but it feels a better when it bleeds a bit on the left, so 32px.
|
||||
maxWidth: 'calc(133% - 32px)',
|
||||
transform: 'translate(14px, -9px) scale(0.75)'
|
||||
})));
|
||||
const InputLabel = /*#__PURE__*/React.forwardRef(function InputLabel(inProps, ref) {
|
||||
const props = useThemeProps({
|
||||
name: 'MuiInputLabel',
|
||||
props: inProps
|
||||
});
|
||||
const {
|
||||
disableAnimation = false,
|
||||
shrink: shrinkProp,
|
||||
className
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const muiFormControl = useFormControl();
|
||||
let shrink = shrinkProp;
|
||||
if (typeof shrink === 'undefined' && muiFormControl) {
|
||||
shrink = muiFormControl.filled || muiFormControl.focused || muiFormControl.adornedStart;
|
||||
}
|
||||
const fcs = formControlState({
|
||||
props,
|
||||
muiFormControl,
|
||||
states: ['size', 'variant', 'required', 'focused']
|
||||
});
|
||||
const ownerState = _extends({}, props, {
|
||||
disableAnimation,
|
||||
formControl: muiFormControl,
|
||||
shrink,
|
||||
size: fcs.size,
|
||||
variant: fcs.variant,
|
||||
required: fcs.required,
|
||||
focused: fcs.focused
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsx(InputLabelRoot, _extends({
|
||||
"data-shrink": shrink,
|
||||
ownerState: ownerState,
|
||||
ref: ref,
|
||||
className: clsx(classes.root, className)
|
||||
}, other, {
|
||||
classes: classes
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? InputLabel.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
*/
|
||||
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']), PropTypes.string]),
|
||||
/**
|
||||
* If `true`, the transition animation is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disableAnimation: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the label is displayed in an error state.
|
||||
*/
|
||||
error: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the `input` of this label is focused.
|
||||
*/
|
||||
focused: PropTypes.bool,
|
||||
/**
|
||||
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
||||
* FormControl.
|
||||
*/
|
||||
margin: PropTypes.oneOf(['dense']),
|
||||
/**
|
||||
* if `true`, the label will indicate that the `input` is required.
|
||||
*/
|
||||
required: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the label is shrunk.
|
||||
*/
|
||||
shrink: PropTypes.bool,
|
||||
/**
|
||||
* The size of the component.
|
||||
* @default 'normal'
|
||||
*/
|
||||
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['normal', 'small']), PropTypes.string]),
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* The variant to use.
|
||||
*/
|
||||
variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
||||
} : void 0;
|
||||
export default InputLabel;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user