pre-installations and preparations
This commit is contained in:
1 parent
3e5a0329cb
commit
201d621ac3
6977 files changed
+742826
No files matched your search
+130
@@ -0,0 +1,130 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { useBadge } from '../useBadge';
|
||||
import { getBadgeUtilityClass } from './badgeClasses';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
||||
var invisible = ownerState.invisible;
|
||||
var slots = {
|
||||
root: ['root'],
|
||||
badge: ['badge', invisible && 'invisible']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getBadgeUtilityClass));
|
||||
};
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Badge](https://mui.com/base-ui/react-badge/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Badge API](https://mui.com/base-ui/react-badge/components-api/#badge)
|
||||
*/
|
||||
var Badge = /*#__PURE__*/React.forwardRef(function Badge(props, forwardedRef) {
|
||||
var _slots$root, _slots$badge;
|
||||
var badgeContentProp = props.badgeContent,
|
||||
children = props.children,
|
||||
invisibleProp = props.invisible,
|
||||
_props$max = props.max,
|
||||
maxProp = _props$max === void 0 ? 99 : _props$max,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
_props$showZero = props.showZero,
|
||||
showZero = _props$showZero === void 0 ? false : _props$showZero,
|
||||
other = _objectWithoutProperties(props, ["badgeContent", "children", "invisible", "max", "slotProps", "slots", "showZero"]);
|
||||
var _useBadge = useBadge(_extends({}, props, {
|
||||
max: maxProp
|
||||
})),
|
||||
badgeContent = _useBadge.badgeContent,
|
||||
max = _useBadge.max,
|
||||
displayValue = _useBadge.displayValue,
|
||||
invisible = _useBadge.invisible;
|
||||
var ownerState = _extends({}, props, {
|
||||
badgeContent: badgeContent,
|
||||
invisible: invisible,
|
||||
max: max,
|
||||
showZero: showZero
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'span';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
var BadgeComponent = (_slots$badge = slots.badge) != null ? _slots$badge : 'span';
|
||||
var badgeProps = useSlotProps({
|
||||
elementType: BadgeComponent,
|
||||
externalSlotProps: slotProps.badge,
|
||||
ownerState: ownerState,
|
||||
className: classes.badge
|
||||
});
|
||||
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
|
||||
children: [children, /*#__PURE__*/_jsx(BadgeComponent, _extends({}, badgeProps, {
|
||||
children: displayValue
|
||||
}))]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Badge.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 content rendered within the badge.
|
||||
*/
|
||||
badgeContent: PropTypes.node,
|
||||
/**
|
||||
* The badge will be added relative to this node.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* If `true`, the badge is invisible.
|
||||
* @default false
|
||||
*/
|
||||
invisible: PropTypes.bool,
|
||||
/**
|
||||
* Max count to show.
|
||||
* @default 99
|
||||
*/
|
||||
max: PropTypes.number,
|
||||
/**
|
||||
* Controls whether the badge is hidden when `badgeContent` is zero.
|
||||
* @default false
|
||||
*/
|
||||
showZero: PropTypes.bool,
|
||||
/**
|
||||
* The props used for each slot inside the Badge.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
badge: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Badge.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
badge: PropTypes.elementType,
|
||||
root: PropTypes.elementType
|
||||
})
|
||||
} : void 0;
|
||||
export { Badge };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
var COMPONENT_NAME = 'Badge';
|
||||
export function getBadgeUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var badgeClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'badge', 'invisible']);
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { Badge } from './Badge';
|
||||
export * from './Badge.types';
|
||||
export * from './badgeClasses';
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getButtonUtilityClass } from './buttonClasses';
|
||||
import { useButton } from '../useButton';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
||||
var active = ownerState.active,
|
||||
disabled = ownerState.disabled,
|
||||
focusVisible = ownerState.focusVisible;
|
||||
var slots = {
|
||||
root: ['root', disabled && 'disabled', focusVisible && 'focusVisible', active && 'active']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getButtonUtilityClass));
|
||||
};
|
||||
/**
|
||||
* The foundation for building custom-styled buttons.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Button](https://mui.com/base-ui/react-button/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Button API](https://mui.com/base-ui/react-button/components-api/#button)
|
||||
*/
|
||||
var Button = /*#__PURE__*/React.forwardRef(function Button(props, forwardedRef) {
|
||||
var _slots$root;
|
||||
var action = props.action,
|
||||
children = props.children,
|
||||
disabled = props.disabled,
|
||||
_props$focusableWhenD = props.focusableWhenDisabled,
|
||||
focusableWhenDisabled = _props$focusableWhenD === void 0 ? false : _props$focusableWhenD,
|
||||
onFocusVisible = props.onFocusVisible,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
_props$rootElementNam = props.rootElementName,
|
||||
rootElementNameProp = _props$rootElementNam === void 0 ? 'button' : _props$rootElementNam,
|
||||
other = _objectWithoutProperties(props, ["action", "children", "disabled", "focusableWhenDisabled", "onFocusVisible", "slotProps", "slots", "rootElementName"]);
|
||||
var buttonRef = React.useRef();
|
||||
var rootElementName = rootElementNameProp;
|
||||
if (typeof slots.root === 'string') {
|
||||
rootElementName = slots.root;
|
||||
} else if (other.href || other.to) {
|
||||
rootElementName = 'a';
|
||||
}
|
||||
var _useButton = useButton(_extends({}, props, {
|
||||
focusableWhenDisabled: focusableWhenDisabled,
|
||||
rootElementName: rootElementName
|
||||
})),
|
||||
active = _useButton.active,
|
||||
focusVisible = _useButton.focusVisible,
|
||||
setFocusVisible = _useButton.setFocusVisible,
|
||||
getRootProps = _useButton.getRootProps;
|
||||
React.useImperativeHandle(action, function () {
|
||||
return {
|
||||
focusVisible: function focusVisible() {
|
||||
setFocusVisible(true);
|
||||
buttonRef.current.focus();
|
||||
}
|
||||
};
|
||||
}, [setFocusVisible]);
|
||||
var ownerState = _extends({}, props, {
|
||||
active: active,
|
||||
focusableWhenDisabled: focusableWhenDisabled,
|
||||
focusVisible: focusVisible
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var defaultElement = other.href || other.to ? 'a' : 'button';
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : defaultElement;
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
getSlotProps: getRootProps,
|
||||
externalForwardedProps: other,
|
||||
externalSlotProps: slotProps.root,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
return /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
|
||||
children: children
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Button.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* A ref for imperative actions. It currently only supports `focusVisible()` action.
|
||||
*/
|
||||
action: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
||||
current: PropTypes.shape({
|
||||
focusVisible: PropTypes.func.isRequired
|
||||
})
|
||||
})]),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, allows a disabled button to receive focus.
|
||||
* @default false
|
||||
*/
|
||||
focusableWhenDisabled: PropTypes.bool,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
href: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onFocusVisible: PropTypes.func,
|
||||
/**
|
||||
* The HTML element that is ultimately rendered, for example 'button' or 'a'
|
||||
* @default 'button'
|
||||
*/
|
||||
rootElementName: PropTypes /* @typescript-to-proptypes-ignore */.string,
|
||||
/**
|
||||
* The props used for each slot inside the Button.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Button.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
to: PropTypes.string
|
||||
} : void 0;
|
||||
export { Button };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'Button';
|
||||
export function getButtonUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var buttonClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'active', 'disabled', 'focusVisible']);
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { Button } from './Button';
|
||||
export * from './buttonClasses';
|
||||
export * from './Button.types';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { unstable_ClassNameGenerator } from '@mui/utils';
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { elementAcceptingRef, exactProp, unstable_ownerDocument as ownerDocument, unstable_useForkRef as useForkRef, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
||||
|
||||
// TODO: return `EventHandlerName extends `on${infer EventName}` ? Lowercase<EventName> : never` once generatePropTypes runs with TS 4.1
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function mapEventPropToEvent(eventProp) {
|
||||
return eventProp.substring(2).toLowerCase();
|
||||
}
|
||||
function clickedRootScrollbar(event, doc) {
|
||||
return doc.documentElement.clientWidth < event.clientX || doc.documentElement.clientHeight < event.clientY;
|
||||
}
|
||||
/**
|
||||
* Listen for click events that occur somewhere in the document, outside of the element itself.
|
||||
* For instance, if you need to hide a menu when people click anywhere else on your page.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Click-Away Listener](https://mui.com/base-ui/react-click-away-listener/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [ClickAwayListener API](https://mui.com/base-ui/react-click-away-listener/components-api/#click-away-listener)
|
||||
*/
|
||||
function ClickAwayListener(props) {
|
||||
var children = props.children,
|
||||
_props$disableReactTr = props.disableReactTree,
|
||||
disableReactTree = _props$disableReactTr === void 0 ? false : _props$disableReactTr,
|
||||
_props$mouseEvent = props.mouseEvent,
|
||||
mouseEvent = _props$mouseEvent === void 0 ? 'onClick' : _props$mouseEvent,
|
||||
onClickAway = props.onClickAway,
|
||||
_props$touchEvent = props.touchEvent,
|
||||
touchEvent = _props$touchEvent === void 0 ? 'onTouchEnd' : _props$touchEvent;
|
||||
var movedRef = React.useRef(false);
|
||||
var nodeRef = React.useRef(null);
|
||||
var activatedRef = React.useRef(false);
|
||||
var syntheticEventRef = React.useRef(false);
|
||||
React.useEffect(function () {
|
||||
// Ensure that this component is not "activated" synchronously.
|
||||
// https://github.com/facebook/react/issues/20074
|
||||
setTimeout(function () {
|
||||
activatedRef.current = true;
|
||||
}, 0);
|
||||
return function () {
|
||||
activatedRef.current = false;
|
||||
};
|
||||
}, []);
|
||||
var handleRef = useForkRef(
|
||||
// @ts-expect-error TODO upstream fix
|
||||
children.ref, nodeRef);
|
||||
|
||||
// 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.
|
||||
var handleClickAway = useEventCallback(function (event) {
|
||||
// Given developers can stop the propagation of the synthetic event,
|
||||
// we can only be confident with a positive value.
|
||||
var insideReactTree = syntheticEventRef.current;
|
||||
syntheticEventRef.current = false;
|
||||
var doc = ownerDocument(nodeRef.current);
|
||||
|
||||
// 1. IE11 support, which trigger the handleClickAway even after the unbind
|
||||
// 2. The child might render null.
|
||||
// 3. Behave like a blur listener.
|
||||
if (!activatedRef.current || !nodeRef.current || 'clientX' in event && clickedRootScrollbar(event, doc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not act if user performed touchmove
|
||||
if (movedRef.current) {
|
||||
movedRef.current = false;
|
||||
return;
|
||||
}
|
||||
var insideDOM;
|
||||
|
||||
// If not enough, can use https://github.com/DieterHolvoet/event-propagation-path/blob/master/propagationPath.js
|
||||
if (event.composedPath) {
|
||||
insideDOM = event.composedPath().indexOf(nodeRef.current) > -1;
|
||||
} else {
|
||||
insideDOM = !doc.documentElement.contains(
|
||||
// @ts-expect-error returns `false` as intended when not dispatched from a Node
|
||||
event.target) || nodeRef.current.contains(
|
||||
// @ts-expect-error returns `false` as intended when not dispatched from a Node
|
||||
event.target);
|
||||
}
|
||||
if (!insideDOM && (disableReactTree || !insideReactTree)) {
|
||||
onClickAway(event);
|
||||
}
|
||||
});
|
||||
|
||||
// Keep track of mouse/touch events that bubbled up through the portal.
|
||||
var createHandleSynthetic = function createHandleSynthetic(handlerName) {
|
||||
return function (event) {
|
||||
syntheticEventRef.current = true;
|
||||
var childrenPropsHandler = children.props[handlerName];
|
||||
if (childrenPropsHandler) {
|
||||
childrenPropsHandler(event);
|
||||
}
|
||||
};
|
||||
};
|
||||
var childrenProps = {
|
||||
ref: handleRef
|
||||
};
|
||||
if (touchEvent !== false) {
|
||||
childrenProps[touchEvent] = createHandleSynthetic(touchEvent);
|
||||
}
|
||||
React.useEffect(function () {
|
||||
if (touchEvent !== false) {
|
||||
var mappedTouchEvent = mapEventPropToEvent(touchEvent);
|
||||
var doc = ownerDocument(nodeRef.current);
|
||||
var handleTouchMove = function handleTouchMove() {
|
||||
movedRef.current = true;
|
||||
};
|
||||
doc.addEventListener(mappedTouchEvent, handleClickAway);
|
||||
doc.addEventListener('touchmove', handleTouchMove);
|
||||
return function () {
|
||||
doc.removeEventListener(mappedTouchEvent, handleClickAway);
|
||||
doc.removeEventListener('touchmove', handleTouchMove);
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}, [handleClickAway, touchEvent]);
|
||||
if (mouseEvent !== false) {
|
||||
childrenProps[mouseEvent] = createHandleSynthetic(mouseEvent);
|
||||
}
|
||||
React.useEffect(function () {
|
||||
if (mouseEvent !== false) {
|
||||
var mappedMouseEvent = mapEventPropToEvent(mouseEvent);
|
||||
var doc = ownerDocument(nodeRef.current);
|
||||
doc.addEventListener(mappedMouseEvent, handleClickAway);
|
||||
return function () {
|
||||
doc.removeEventListener(mappedMouseEvent, handleClickAway);
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}, [handleClickAway, mouseEvent]);
|
||||
return /*#__PURE__*/_jsx(React.Fragment, {
|
||||
children: /*#__PURE__*/React.cloneElement(children, childrenProps)
|
||||
});
|
||||
}
|
||||
process.env.NODE_ENV !== "production" ? ClickAwayListener.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 wrapped element.
|
||||
*/
|
||||
children: elementAcceptingRef.isRequired,
|
||||
/**
|
||||
* If `true`, the React tree is ignored and only the DOM tree is considered.
|
||||
* This prop changes how portaled elements are handled.
|
||||
* @default false
|
||||
*/
|
||||
disableReactTree: PropTypes.bool,
|
||||
/**
|
||||
* The mouse event to listen to. You can disable the listener by providing `false`.
|
||||
* @default 'onClick'
|
||||
*/
|
||||
mouseEvent: PropTypes.oneOf(['onClick', 'onMouseDown', 'onMouseUp', 'onPointerDown', 'onPointerUp', false]),
|
||||
/**
|
||||
* Callback fired when a "click away" event is detected.
|
||||
*/
|
||||
onClickAway: PropTypes.func.isRequired,
|
||||
/**
|
||||
* The touch event to listen to. You can disable the listener by providing `false`.
|
||||
* @default 'onTouchEnd'
|
||||
*/
|
||||
touchEvent: PropTypes.oneOf(['onTouchEnd', 'onTouchStart', false])
|
||||
} : void 0;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// eslint-disable-next-line
|
||||
ClickAwayListener['propTypes' + ''] = exactProp(ClickAwayListener.propTypes);
|
||||
}
|
||||
export { ClickAwayListener };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './ClickAwayListener';
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { exactProp } from '@mui/utils';
|
||||
import { DropdownContext } from '../useDropdown/DropdownContext';
|
||||
import { useDropdown } from '../useDropdown/useDropdown';
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Menu](https://mui.com/base-ui/react-menu/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Dropdown API](https://mui.com/base-ui/react-menu/components-api/#dropdown)
|
||||
*/
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function Dropdown(props) {
|
||||
var children = props.children,
|
||||
open = props.open,
|
||||
defaultOpen = props.defaultOpen,
|
||||
onOpenChange = props.onOpenChange;
|
||||
var _useDropdown = useDropdown({
|
||||
defaultOpen: defaultOpen,
|
||||
onOpenChange: onOpenChange,
|
||||
open: open
|
||||
}),
|
||||
contextValue = _useDropdown.contextValue;
|
||||
return /*#__PURE__*/_jsx(DropdownContext.Provider, {
|
||||
value: contextValue,
|
||||
children: children
|
||||
});
|
||||
}
|
||||
process.env.NODE_ENV !== "production" ? Dropdown.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* If `true`, the dropdown is initially open.
|
||||
*/
|
||||
defaultOpen: PropTypes.bool,
|
||||
/**
|
||||
* Callback fired when the component requests to be opened or closed.
|
||||
*/
|
||||
onOpenChange: PropTypes.func,
|
||||
/**
|
||||
* Allows to control whether the dropdown is open.
|
||||
* This is a controlled counterpart of `defaultOpen`.
|
||||
*/
|
||||
open: PropTypes.bool
|
||||
} : void 0;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// eslint-disable-next-line
|
||||
Dropdown['propTypes' + ''] = exactProp(Dropdown.propTypes);
|
||||
}
|
||||
export { Dropdown };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './Dropdown';
|
||||
export * from './Dropdown.types';
|
||||
+349
@@ -0,0 +1,349 @@
|
||||
'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
|
||||
var candidatesSelector = ['input', 'select', 'textarea', 'a[href]', 'button', '[tabindex]', 'audio[controls]', 'video[controls]', '[contenteditable]:not([contenteditable="false"])'].join(',');
|
||||
function getTabIndex(node) {
|
||||
var 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;
|
||||
}
|
||||
var getRadio = function getRadio(selector) {
|
||||
return node.ownerDocument.querySelector("input[type=\"radio\"]".concat(selector));
|
||||
};
|
||||
var roving = getRadio("[name=\"".concat(node.name, "\"]:checked"));
|
||||
if (!roving) {
|
||||
roving = getRadio("[name=\"".concat(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) {
|
||||
var regularTabNodes = [];
|
||||
var orderedTabNodes = [];
|
||||
Array.from(root.querySelectorAll(candidatesSelector)).forEach(function (node, i) {
|
||||
var 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(function (a, b) {
|
||||
return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
|
||||
}).map(function (a) {
|
||||
return 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) {
|
||||
var children = props.children,
|
||||
_props$disableAutoFoc = props.disableAutoFocus,
|
||||
disableAutoFocus = _props$disableAutoFoc === void 0 ? false : _props$disableAutoFoc,
|
||||
_props$disableEnforce = props.disableEnforceFocus,
|
||||
disableEnforceFocus = _props$disableEnforce === void 0 ? false : _props$disableEnforce,
|
||||
_props$disableRestore = props.disableRestoreFocus,
|
||||
disableRestoreFocus = _props$disableRestore === void 0 ? false : _props$disableRestore,
|
||||
_props$getTabbable = props.getTabbable,
|
||||
getTabbable = _props$getTabbable === void 0 ? defaultGetTabbable : _props$getTabbable,
|
||||
_props$isEnabled = props.isEnabled,
|
||||
isEnabled = _props$isEnabled === void 0 ? defaultIsEnabled : _props$isEnabled,
|
||||
open = props.open;
|
||||
var ignoreNextEnforceFocus = React.useRef(false);
|
||||
var sentinelStart = React.useRef(null);
|
||||
var sentinelEnd = React.useRef(null);
|
||||
var nodeToRestore = React.useRef(null);
|
||||
var 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.
|
||||
var activated = React.useRef(false);
|
||||
var rootRef = React.useRef(null);
|
||||
// @ts-expect-error TODO upstream fix
|
||||
var handleRef = useForkRef(children.ref, rootRef);
|
||||
var lastKeydown = React.useRef(null);
|
||||
React.useEffect(function () {
|
||||
// We might render an empty child.
|
||||
if (!open || !rootRef.current) {
|
||||
return;
|
||||
}
|
||||
activated.current = !disableAutoFocus;
|
||||
}, [disableAutoFocus, open]);
|
||||
React.useEffect(function () {
|
||||
// We might render an empty child.
|
||||
if (!open || !rootRef.current) {
|
||||
return;
|
||||
}
|
||||
var 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 function () {
|
||||
// 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(function () {
|
||||
// We might render an empty child.
|
||||
if (!open || !rootRef.current) {
|
||||
return;
|
||||
}
|
||||
var doc = ownerDocument(rootRef.current);
|
||||
var loopFocus = function 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();
|
||||
}
|
||||
}
|
||||
};
|
||||
var contain = function contain() {
|
||||
var 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;
|
||||
}
|
||||
var 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;
|
||||
var isShiftTab = Boolean(((_lastKeydown$current = lastKeydown.current) == null ? void 0 : _lastKeydown$current.shiftKey) && ((_lastKeydown$current2 = lastKeydown.current) == null ? void 0 : _lastKeydown$current2.key) === 'Tab');
|
||||
var focusNext = tabbable[0];
|
||||
var 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.
|
||||
var interval = setInterval(function () {
|
||||
if (doc.activeElement && doc.activeElement.tagName === 'BODY') {
|
||||
contain();
|
||||
}
|
||||
}, 50);
|
||||
return function () {
|
||||
clearInterval(interval);
|
||||
doc.removeEventListener('focusin', contain);
|
||||
doc.removeEventListener('keydown', loopFocus, true);
|
||||
};
|
||||
}, [disableAutoFocus, disableEnforceFocus, disableRestoreFocus, isEnabled, open, getTabbable]);
|
||||
var onFocus = function onFocus(event) {
|
||||
if (nodeToRestore.current === null) {
|
||||
nodeToRestore.current = event.relatedTarget;
|
||||
}
|
||||
activated.current = true;
|
||||
reactFocusEventTarget.current = event.target;
|
||||
var childrenPropsHandler = children.props.onFocus;
|
||||
if (childrenPropsHandler) {
|
||||
childrenPropsHandler(event);
|
||||
}
|
||||
};
|
||||
var handleFocusSentinel = function 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: 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 };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { FocusTrap } from './FocusTrap';
|
||||
export * from './FocusTrap.types';
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import useControlled from '@mui/utils/useControlled';
|
||||
import { FormControlContext } from './FormControlContext';
|
||||
import { getFormControlUtilityClass } from './formControlClasses';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function hasValue(value) {
|
||||
return value != null && !(Array.isArray(value) && value.length === 0) && value !== '';
|
||||
}
|
||||
function useUtilityClasses(ownerState) {
|
||||
var disabled = ownerState.disabled,
|
||||
error = ownerState.error,
|
||||
filled = ownerState.filled,
|
||||
focused = ownerState.focused,
|
||||
required = ownerState.required;
|
||||
var slots = {
|
||||
root: ['root', disabled && 'disabled', focused && 'focused', error && 'error', filled && 'filled', required && 'required']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getFormControlUtilityClass));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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](https://mui.com/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 `Input` can be used within a FormControl because it create visual inconsistencies.
|
||||
* For instance, only one input can be focused at the same time, the state shouldn't be shared.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Form Control](https://mui.com/base-ui/react-form-control/)
|
||||
* - [Input](https://mui.com/joy-ui/react-input/)
|
||||
* - [Checkbox](https://mui.com/material-ui/react-checkbox/)
|
||||
* - [Radio Group](https://mui.com/material-ui/react-radio-button/)
|
||||
* - [Switch](https://mui.com/material-ui/react-switch/)
|
||||
* - [Text Field](https://mui.com/material-ui/react-text-field/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [FormControl API](https://mui.com/base-ui/react-form-control/components-api/#form-control)
|
||||
*/
|
||||
var FormControl = /*#__PURE__*/React.forwardRef(function FormControl(props, forwardedRef) {
|
||||
var _slots$root;
|
||||
var defaultValue = props.defaultValue,
|
||||
children = props.children,
|
||||
_props$disabled = props.disabled,
|
||||
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
||||
_props$error = props.error,
|
||||
error = _props$error === void 0 ? false : _props$error,
|
||||
_onChange = props.onChange,
|
||||
_props$required = props.required,
|
||||
required = _props$required === void 0 ? false : _props$required,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
incomingValue = props.value,
|
||||
other = _objectWithoutProperties(props, ["defaultValue", "children", "disabled", "error", "onChange", "required", "slotProps", "slots", "value"]);
|
||||
var _useControlled = useControlled({
|
||||
controlled: incomingValue,
|
||||
default: defaultValue,
|
||||
name: 'FormControl',
|
||||
state: 'value'
|
||||
}),
|
||||
_useControlled2 = _slicedToArray(_useControlled, 2),
|
||||
value = _useControlled2[0],
|
||||
setValue = _useControlled2[1];
|
||||
var filled = hasValue(value);
|
||||
var _React$useState = React.useState(false),
|
||||
focusedState = _React$useState[0],
|
||||
setFocused = _React$useState[1];
|
||||
var focused = focusedState && !disabled;
|
||||
React.useEffect(function () {
|
||||
return setFocused(function (isFocused) {
|
||||
return disabled ? false : isFocused;
|
||||
});
|
||||
}, [disabled]);
|
||||
var ownerState = _extends({}, props, {
|
||||
disabled: disabled,
|
||||
error: error,
|
||||
filled: filled,
|
||||
focused: focused,
|
||||
required: required
|
||||
});
|
||||
var childContext = React.useMemo(function () {
|
||||
return {
|
||||
disabled: disabled,
|
||||
error: error,
|
||||
filled: filled,
|
||||
focused: focused,
|
||||
onBlur: function onBlur() {
|
||||
setFocused(false);
|
||||
},
|
||||
onChange: function onChange(event) {
|
||||
setValue(event.target.value);
|
||||
_onChange == null || _onChange(event);
|
||||
},
|
||||
onFocus: function onFocus() {
|
||||
setFocused(true);
|
||||
},
|
||||
required: required,
|
||||
value: value != null ? value : ''
|
||||
};
|
||||
}, [disabled, error, filled, focused, _onChange, required, setValue, value]);
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var renderChildren = function renderChildren() {
|
||||
if (typeof children === 'function') {
|
||||
return children(childContext);
|
||||
}
|
||||
return children;
|
||||
};
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef,
|
||||
children: renderChildren()
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
return /*#__PURE__*/_jsx(FormControlContext.Provider, {
|
||||
value: childContext,
|
||||
children: /*#__PURE__*/_jsx(Root, _extends({}, rootProps))
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? FormControl.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 content of the component.
|
||||
*/
|
||||
children: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.node, PropTypes.func]),
|
||||
/**
|
||||
* Class name applied to the root element.
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
defaultValue: PropTypes.any,
|
||||
/**
|
||||
* 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,
|
||||
/**
|
||||
* Callback fired when the form element's value is modified.
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* If `true`, the label will indicate that the `input` is required.
|
||||
* @default false
|
||||
*/
|
||||
required: PropTypes.bool,
|
||||
/**
|
||||
* The props used for each slot inside the FormControl.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the FormControl.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The value of the form element.
|
||||
*/
|
||||
value: PropTypes.any
|
||||
} : void 0;
|
||||
export { FormControl };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import * as React from 'react';
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
var FormControlContext = /*#__PURE__*/React.createContext(undefined);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
FormControlContext.displayName = 'FormControlContext';
|
||||
}
|
||||
export { FormControlContext };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'FormControl';
|
||||
export function getFormControlUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var formControlClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'disabled', 'error', 'filled', 'focused', 'required']);
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export { FormControl } from './FormControl';
|
||||
export { FormControlContext } from './FormControlContext';
|
||||
export * from './FormControl.types';
|
||||
export * from './formControlClasses';
|
||||
export { useFormControlContext } from './useFormControlContext';
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { FormControlContext } from './FormControlContext';
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Form Control](https://mui.com/base-ui/react-form-control/#hook)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [useFormControlContext API](https://mui.com/base-ui/react-form-control/hooks-api/#use-form-control-context)
|
||||
*/
|
||||
export function useFormControlContext() {
|
||||
return React.useContext(FormControlContext);
|
||||
}
|
||||
+308
@@ -0,0 +1,308 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { isHostComponent } from '../utils/isHostComponent';
|
||||
import { getInputUtilityClass } from './inputClasses';
|
||||
import { useInput } from '../useInput';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
||||
var disabled = ownerState.disabled,
|
||||
error = ownerState.error,
|
||||
focused = ownerState.focused,
|
||||
formControlContext = ownerState.formControlContext,
|
||||
multiline = ownerState.multiline,
|
||||
startAdornment = ownerState.startAdornment,
|
||||
endAdornment = ownerState.endAdornment;
|
||||
var slots = {
|
||||
root: ['root', disabled && 'disabled', error && 'error', focused && 'focused', Boolean(formControlContext) && 'formControl', multiline && 'multiline', Boolean(startAdornment) && 'adornedStart', Boolean(endAdornment) && 'adornedEnd'],
|
||||
input: ['input', disabled && 'disabled', multiline && 'multiline']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getInputUtilityClass));
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Input](https://mui.com/base-ui/react-input/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Input API](https://mui.com/base-ui/react-input/components-api/#input)
|
||||
*/
|
||||
var Input = /*#__PURE__*/React.forwardRef(function Input(props, forwardedRef) {
|
||||
var _slots$root, _slots$textarea, _slots$input;
|
||||
var ariaDescribedby = props['aria-describedby'],
|
||||
ariaLabel = props['aria-label'],
|
||||
ariaLabelledby = props['aria-labelledby'],
|
||||
autoComplete = props.autoComplete,
|
||||
autoFocus = props.autoFocus,
|
||||
className = props.className,
|
||||
defaultValue = props.defaultValue,
|
||||
disabled = props.disabled,
|
||||
endAdornment = props.endAdornment,
|
||||
error = props.error,
|
||||
id = props.id,
|
||||
_props$multiline = props.multiline,
|
||||
multiline = _props$multiline === void 0 ? false : _props$multiline,
|
||||
name = props.name,
|
||||
onClick = props.onClick,
|
||||
onChange = props.onChange,
|
||||
onKeyDown = props.onKeyDown,
|
||||
onKeyUp = props.onKeyUp,
|
||||
onFocus = props.onFocus,
|
||||
onBlur = props.onBlur,
|
||||
placeholder = props.placeholder,
|
||||
readOnly = props.readOnly,
|
||||
required = props.required,
|
||||
startAdornment = props.startAdornment,
|
||||
value = props.value,
|
||||
typeProp = props.type,
|
||||
rows = props.rows,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
minRows = props.minRows,
|
||||
maxRows = props.maxRows,
|
||||
other = _objectWithoutProperties(props, ["aria-describedby", "aria-label", "aria-labelledby", "autoComplete", "autoFocus", "className", "defaultValue", "disabled", "endAdornment", "error", "id", "multiline", "name", "onClick", "onChange", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "placeholder", "readOnly", "required", "startAdornment", "value", "type", "rows", "slotProps", "slots", "minRows", "maxRows"]);
|
||||
var _useInput = useInput({
|
||||
disabled: disabled,
|
||||
defaultValue: defaultValue,
|
||||
error: error,
|
||||
onBlur: onBlur,
|
||||
onClick: onClick,
|
||||
onChange: onChange,
|
||||
onFocus: onFocus,
|
||||
required: required,
|
||||
value: value
|
||||
}),
|
||||
getRootProps = _useInput.getRootProps,
|
||||
getInputProps = _useInput.getInputProps,
|
||||
focused = _useInput.focused,
|
||||
formControlContext = _useInput.formControlContext,
|
||||
errorState = _useInput.error,
|
||||
disabledState = _useInput.disabled;
|
||||
var type = !multiline ? typeProp != null ? typeProp : 'text' : undefined;
|
||||
var ownerState = _extends({}, props, {
|
||||
disabled: disabledState,
|
||||
error: errorState,
|
||||
focused: focused,
|
||||
formControlContext: formControlContext,
|
||||
multiline: multiline,
|
||||
type: type
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var propsToForward = {
|
||||
'aria-describedby': ariaDescribedby,
|
||||
'aria-label': ariaLabel,
|
||||
'aria-labelledby': ariaLabelledby,
|
||||
autoComplete: autoComplete,
|
||||
autoFocus: autoFocus,
|
||||
id: id,
|
||||
onKeyDown: onKeyDown,
|
||||
onKeyUp: onKeyUp,
|
||||
name: name,
|
||||
placeholder: placeholder,
|
||||
readOnly: readOnly,
|
||||
type: type
|
||||
};
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
getSlotProps: getRootProps,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: [classes.root, className]
|
||||
});
|
||||
var InputComponent = multiline ? (_slots$textarea = slots.textarea) != null ? _slots$textarea : 'textarea' : (_slots$input = slots.input) != null ? _slots$input : 'input';
|
||||
var inputProps = useSlotProps({
|
||||
elementType: InputComponent,
|
||||
getSlotProps: function getSlotProps(otherHandlers) {
|
||||
return getInputProps(_extends({}, propsToForward, otherHandlers));
|
||||
},
|
||||
externalSlotProps: slotProps.input,
|
||||
additionalProps: _extends({
|
||||
rows: multiline ? rows : undefined
|
||||
}, multiline && !isHostComponent(InputComponent) && {
|
||||
minRows: rows || minRows,
|
||||
maxRows: rows || maxRows
|
||||
}),
|
||||
ownerState: ownerState,
|
||||
className: classes.input
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (multiline) {
|
||||
if (rows) {
|
||||
if (minRows || maxRows) {
|
||||
console.warn('MUI: You can not use the `minRows` or `maxRows` props when the input `rows` prop is set.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
|
||||
children: [startAdornment, /*#__PURE__*/_jsx(InputComponent, _extends({}, inputProps)), endAdornment]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Input.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
'aria-describedby': PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
'aria-label': PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
'aria-labelledby': PropTypes.string,
|
||||
/**
|
||||
* This prop helps users to fill forms faster, especially on mobile devices.
|
||||
* The name can be confusing, as it's more like an autofill.
|
||||
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
|
||||
*/
|
||||
autoComplete: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the `input` element is focused during the first mount.
|
||||
*/
|
||||
autoFocus: PropTypes.bool,
|
||||
/**
|
||||
* Class name applied to the root element.
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The default value. Use when the component is not controlled.
|
||||
*/
|
||||
defaultValue: PropTypes.any,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* Trailing adornment for this input.
|
||||
*/
|
||||
endAdornment: PropTypes.node,
|
||||
/**
|
||||
* If `true`, the `input` will indicate an error by setting the `aria-invalid` attribute on the input and the `baseui--error` class on the root element.
|
||||
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
|
||||
*/
|
||||
error: PropTypes.bool,
|
||||
/**
|
||||
* The id of the `input` element.
|
||||
*/
|
||||
id: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
||||
current: PropTypes.object
|
||||
})]),
|
||||
/**
|
||||
* Maximum number of rows to display when multiline option is set to true.
|
||||
*/
|
||||
maxRows: PropTypes.number,
|
||||
/**
|
||||
* Minimum number of rows to display when multiline option is set to true.
|
||||
*/
|
||||
minRows: PropTypes.number,
|
||||
/**
|
||||
* If `true`, a `textarea` element is rendered.
|
||||
* @default false
|
||||
*/
|
||||
multiline: PropTypes.bool,
|
||||
/**
|
||||
* Name attribute of the `input` element.
|
||||
*/
|
||||
name: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onBlur: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onFocus: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onKeyDown: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onKeyUp: PropTypes.func,
|
||||
/**
|
||||
* The short hint displayed in the `input` before the user enters a value.
|
||||
*/
|
||||
placeholder: PropTypes.string,
|
||||
/**
|
||||
* It prevents the user from changing the value of the field
|
||||
* (not from interacting with the field).
|
||||
*/
|
||||
readOnly: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the `input` element is required.
|
||||
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
|
||||
*/
|
||||
required: PropTypes.bool,
|
||||
/**
|
||||
* Number of rows to display when multiline option is set to true.
|
||||
*/
|
||||
rows: PropTypes.number,
|
||||
/**
|
||||
* The props used for each slot inside the Input.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the InputBase.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
input: PropTypes.elementType,
|
||||
root: PropTypes.elementType,
|
||||
textarea: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* Leading adornment for this input.
|
||||
*/
|
||||
startAdornment: PropTypes.node,
|
||||
/**
|
||||
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).
|
||||
* @default 'text'
|
||||
*/
|
||||
type: PropTypes /* @typescript-to-proptypes-ignore */.oneOf(['button', 'checkbox', 'color', 'date', 'datetime-local', 'email', 'file', 'hidden', 'image', 'month', 'number', 'password', 'radio', 'range', 'reset', 'search', 'submit', 'tel', 'text', 'time', 'url', 'week']),
|
||||
/**
|
||||
* The value of the `input` element, required for a controlled component.
|
||||
*/
|
||||
value: PropTypes.any
|
||||
} : void 0;
|
||||
export { Input };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { Input } from './Input';
|
||||
export * from './Input.types';
|
||||
export * from './inputClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'Input';
|
||||
export function getInputUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var inputClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'formControl', 'focused', 'disabled', 'error', 'multiline', 'input', 'inputMultiline', 'inputTypeSearch', 'adornedStart', 'adornedEnd']);
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { HTMLElementType, refType } from '@mui/utils';
|
||||
import { getMenuUtilityClass } from './menuClasses';
|
||||
import { useMenu } from '../useMenu';
|
||||
import { MenuProvider } from '../useMenu/MenuProvider';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { Unstable_Popup as Popup } from '../Unstable_Popup';
|
||||
import { useSlotProps } from '../utils/useSlotProps';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { ListActionTypes } from '../useList';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function useUtilityClasses(ownerState) {
|
||||
var open = ownerState.open;
|
||||
var slots = {
|
||||
root: ['root', open && 'expanded'],
|
||||
listbox: ['listbox', open && 'expanded']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getMenuUtilityClass));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Menu](https://mui.com/base-ui/react-menu/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Menu API](https://mui.com/base-ui/react-menu/components-api/#menu)
|
||||
*/
|
||||
var Menu = /*#__PURE__*/React.forwardRef(function Menu(props, forwardedRef) {
|
||||
var _slots$root, _slots$listbox;
|
||||
var actions = props.actions,
|
||||
anchorProp = props.anchor,
|
||||
children = props.children,
|
||||
onItemsChange = props.onItemsChange,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["actions", "anchor", "children", "onItemsChange", "slotProps", "slots"]);
|
||||
var _useMenu = useMenu({
|
||||
onItemsChange: onItemsChange,
|
||||
componentName: 'Menu'
|
||||
}),
|
||||
contextValue = _useMenu.contextValue,
|
||||
getListboxProps = _useMenu.getListboxProps,
|
||||
dispatch = _useMenu.dispatch,
|
||||
open = _useMenu.open,
|
||||
triggerElement = _useMenu.triggerElement;
|
||||
var anchor = anchorProp != null ? anchorProp : triggerElement;
|
||||
React.useImperativeHandle(actions, function () {
|
||||
return {
|
||||
dispatch: dispatch,
|
||||
resetHighlight: function resetHighlight() {
|
||||
return dispatch({
|
||||
type: ListActionTypes.resetHighlight,
|
||||
event: null
|
||||
});
|
||||
}
|
||||
};
|
||||
}, [dispatch]);
|
||||
var ownerState = _extends({}, props, {
|
||||
open: open
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef,
|
||||
role: undefined
|
||||
},
|
||||
className: classes.root,
|
||||
ownerState: ownerState
|
||||
});
|
||||
var Listbox = (_slots$listbox = slots.listbox) != null ? _slots$listbox : 'ul';
|
||||
var listboxProps = useSlotProps({
|
||||
elementType: Listbox,
|
||||
getSlotProps: getListboxProps,
|
||||
externalSlotProps: slotProps.listbox,
|
||||
className: classes.listbox,
|
||||
ownerState: ownerState
|
||||
});
|
||||
if (open === true && anchor == null) {
|
||||
return /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
|
||||
children: /*#__PURE__*/_jsx(Listbox, _extends({}, listboxProps, {
|
||||
children: /*#__PURE__*/_jsx(MenuProvider, {
|
||||
value: contextValue,
|
||||
children: children
|
||||
})
|
||||
}))
|
||||
}));
|
||||
}
|
||||
return /*#__PURE__*/_jsx(Popup, _extends({
|
||||
keepMounted: true
|
||||
}, rootProps, {
|
||||
open: open,
|
||||
anchor: anchor,
|
||||
slots: {
|
||||
root: Root
|
||||
},
|
||||
children: /*#__PURE__*/_jsx(Listbox, _extends({}, listboxProps, {
|
||||
children: /*#__PURE__*/_jsx(MenuProvider, {
|
||||
value: contextValue,
|
||||
children: children
|
||||
})
|
||||
}))
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Menu.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* A ref with imperative actions that can be performed on the menu.
|
||||
*/
|
||||
actions: refType,
|
||||
/**
|
||||
* The element based on which the menu is positioned.
|
||||
*/
|
||||
anchor: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([HTMLElementType, PropTypes.object, PropTypes.func]),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* Function called when the items displayed in the menu change.
|
||||
*/
|
||||
onItemsChange: PropTypes.func,
|
||||
/**
|
||||
* The props used for each slot inside the Menu.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
listbox: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Menu.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
listbox: PropTypes.elementType,
|
||||
root: PropTypes.elementType
|
||||
})
|
||||
} : void 0;
|
||||
export { Menu };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export { Menu } from './Menu';
|
||||
export * from './menuClasses';
|
||||
export * from './Menu.types';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'Menu';
|
||||
export function getMenuUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var menuClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'listbox', 'expanded']);
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useMenuButton } from '../useMenuButton';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { getMenuButtonUtilityClass } from './menuButtonClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
||||
var active = ownerState.active,
|
||||
disabled = ownerState.disabled,
|
||||
open = ownerState.open;
|
||||
var slots = {
|
||||
root: ['root', disabled && 'disabled', active && 'active', open && 'expanded']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getMenuButtonUtilityClass));
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Menu](https://mui.com/base-ui/react-menu/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [MenuButton API](https://mui.com/base-ui/react-menu/components-api/#menu-button)
|
||||
*/
|
||||
var MenuButton = /*#__PURE__*/React.forwardRef(function MenuButton(props, forwardedRef) {
|
||||
var children = props.children,
|
||||
_props$disabled = props.disabled,
|
||||
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
||||
label = props.label,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$focusableWhenD = props.focusableWhenDisabled,
|
||||
focusableWhenDisabled = _props$focusableWhenD === void 0 ? false : _props$focusableWhenD,
|
||||
other = _objectWithoutProperties(props, ["children", "disabled", "label", "slots", "slotProps", "focusableWhenDisabled"]);
|
||||
var _useMenuButton = useMenuButton({
|
||||
disabled: disabled,
|
||||
focusableWhenDisabled: focusableWhenDisabled,
|
||||
rootRef: forwardedRef
|
||||
}),
|
||||
getRootProps = _useMenuButton.getRootProps,
|
||||
open = _useMenuButton.open,
|
||||
active = _useMenuButton.active;
|
||||
var ownerState = _extends({}, props, {
|
||||
open: open,
|
||||
active: active,
|
||||
disabled: disabled,
|
||||
focusableWhenDisabled: focusableWhenDisabled
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var Root = slots.root || 'button';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
getSlotProps: getRootProps,
|
||||
externalForwardedProps: other,
|
||||
externalSlotProps: slotProps.root,
|
||||
additionalProps: {
|
||||
ref: forwardedRef,
|
||||
type: 'button'
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
return /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
|
||||
children: children
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? MenuButton.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Class name applied to the root element.
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, allows a disabled button to receive focus.
|
||||
* @default false
|
||||
*/
|
||||
focusableWhenDisabled: PropTypes.bool,
|
||||
/**
|
||||
* Label of the button
|
||||
*/
|
||||
label: PropTypes.string,
|
||||
/**
|
||||
* The components used for each slot inside the MenuButton.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The props used for each slot inside the MenuButton.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
})
|
||||
} : void 0;
|
||||
export { MenuButton };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { MenuButton } from './MenuButton';
|
||||
export * from './MenuButton.types';
|
||||
export * from './menuButtonClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'MenuButton';
|
||||
export function getMenuButtonUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var menuButtonClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'active', 'disabled', 'expanded']);
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { getMenuItemUtilityClass } from './menuItemClasses';
|
||||
import { useMenuItem, useMenuItemContextStabilizer } from '../useMenuItem';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { useSlotProps } from '../utils/useSlotProps';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { ListContext } from '../useList';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function useUtilityClasses(ownerState) {
|
||||
var disabled = ownerState.disabled,
|
||||
focusVisible = ownerState.focusVisible;
|
||||
var slots = {
|
||||
root: ['root', disabled && 'disabled', focusVisible && 'focusVisible']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getMenuItemUtilityClass));
|
||||
}
|
||||
var InnerMenuItem = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function MenuItem(props, forwardedRef) {
|
||||
var _slots$root;
|
||||
var children = props.children,
|
||||
_props$disabled = props.disabled,
|
||||
disabledProp = _props$disabled === void 0 ? false : _props$disabled,
|
||||
label = props.label,
|
||||
id = props.id,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["children", "disabled", "label", "id", "slotProps", "slots"]);
|
||||
var _useMenuItem = useMenuItem({
|
||||
id: id,
|
||||
disabled: disabledProp,
|
||||
rootRef: forwardedRef,
|
||||
label: label
|
||||
}),
|
||||
getRootProps = _useMenuItem.getRootProps,
|
||||
disabled = _useMenuItem.disabled,
|
||||
focusVisible = _useMenuItem.focusVisible,
|
||||
highlighted = _useMenuItem.highlighted;
|
||||
var ownerState = _extends({}, props, {
|
||||
disabled: disabled,
|
||||
focusVisible: focusVisible,
|
||||
highlighted: highlighted
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'li';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
getSlotProps: getRootProps,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
className: classes.root,
|
||||
ownerState: ownerState
|
||||
});
|
||||
return /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
|
||||
children: children
|
||||
}));
|
||||
}));
|
||||
|
||||
/**
|
||||
* An unstyled menu item to be used within a Menu.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Menu](https://mui.com/base-ui/react-menu/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [MenuItem API](https://mui.com/base-ui/react-menu/components-api/#menu-item)
|
||||
*/
|
||||
var MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(props, ref) {
|
||||
var idProp = props.id; // This wrapper component is used as a performance optimization.
|
||||
// `useMenuItemContextStabilizer` ensures that the context value
|
||||
// is stable across renders, so that the actual MenuItem re-renders
|
||||
// only when it needs to.
|
||||
var _useMenuItemContextSt = useMenuItemContextStabilizer(idProp),
|
||||
contextValue = _useMenuItemContextSt.contextValue,
|
||||
id = _useMenuItemContextSt.id;
|
||||
return /*#__PURE__*/_jsx(ListContext.Provider, {
|
||||
value: contextValue,
|
||||
children: /*#__PURE__*/_jsx(InnerMenuItem, _extends({}, props, {
|
||||
id: id,
|
||||
ref: ref
|
||||
}))
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? MenuItem.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the menu item will be disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the menu item won't receive focus when the mouse moves over it.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
disableFocusOnHover: PropTypes.bool,
|
||||
/**
|
||||
* A text representation of the menu item's content.
|
||||
* Used for keyboard text navigation matching.
|
||||
*/
|
||||
label: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
/**
|
||||
* The props used for each slot inside the MenuItem.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the MenuItem.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
})
|
||||
} : void 0;
|
||||
export { MenuItem };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export * from './MenuItem';
|
||||
export * from './MenuItem.types';
|
||||
export * from './menuItemClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'MenuItem';
|
||||
export function getMenuItemUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var menuItemClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'disabled', 'focusVisible']);
|
||||
+286
@@ -0,0 +1,286 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { elementAcceptingRef, HTMLElementType } from '@mui/utils';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { Portal } from '../Portal';
|
||||
import { unstable_useModal as useModal } from '../unstable_useModal';
|
||||
import { FocusTrap } from '../FocusTrap';
|
||||
import { getModalUtilityClass } from './modalClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
||||
var open = ownerState.open,
|
||||
exited = ownerState.exited;
|
||||
var slots = {
|
||||
root: ['root', !open && exited && 'hidden'],
|
||||
backdrop: ['backdrop']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getModalUtilityClass));
|
||||
};
|
||||
|
||||
/**
|
||||
* Modal is a lower-level construct that is leveraged by the following components:
|
||||
*
|
||||
* * [Dialog](https://mui.com/material-ui/api/dialog/)
|
||||
* * [Drawer](https://mui.com/material-ui/api/drawer/)
|
||||
* * [Menu](https://mui.com/material-ui/api/menu/)
|
||||
* * [Popover](https://mui.com/material-ui/api/popover/)
|
||||
*
|
||||
* If you are creating a modal dialog, you probably want to use the [Dialog](https://mui.com/material-ui/api/dialog/) component
|
||||
* rather than directly using Modal.
|
||||
*
|
||||
* This component shares many concepts with [react-overlays](https://react-bootstrap.github.io/react-overlays/#modals).
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Modal](https://mui.com/base-ui/react-modal/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Modal API](https://mui.com/base-ui/react-modal/components-api/#modal)
|
||||
*/
|
||||
var Modal = /*#__PURE__*/React.forwardRef(function Modal(props, forwardedRef) {
|
||||
var _slots$root;
|
||||
var children = props.children,
|
||||
_props$closeAfterTran = props.closeAfterTransition,
|
||||
closeAfterTransition = _props$closeAfterTran === void 0 ? false : _props$closeAfterTran,
|
||||
container = props.container,
|
||||
_props$disableAutoFoc = props.disableAutoFocus,
|
||||
disableAutoFocus = _props$disableAutoFoc === void 0 ? false : _props$disableAutoFoc,
|
||||
_props$disableEnforce = props.disableEnforceFocus,
|
||||
disableEnforceFocus = _props$disableEnforce === void 0 ? false : _props$disableEnforce,
|
||||
_props$disableEscapeK = props.disableEscapeKeyDown,
|
||||
disableEscapeKeyDown = _props$disableEscapeK === void 0 ? false : _props$disableEscapeK,
|
||||
_props$disablePortal = props.disablePortal,
|
||||
disablePortal = _props$disablePortal === void 0 ? false : _props$disablePortal,
|
||||
_props$disableRestore = props.disableRestoreFocus,
|
||||
disableRestoreFocus = _props$disableRestore === void 0 ? false : _props$disableRestore,
|
||||
_props$disableScrollL = props.disableScrollLock,
|
||||
disableScrollLock = _props$disableScrollL === void 0 ? false : _props$disableScrollL,
|
||||
_props$hideBackdrop = props.hideBackdrop,
|
||||
hideBackdrop = _props$hideBackdrop === void 0 ? false : _props$hideBackdrop,
|
||||
_props$keepMounted = props.keepMounted,
|
||||
keepMounted = _props$keepMounted === void 0 ? false : _props$keepMounted,
|
||||
onBackdropClick = props.onBackdropClick,
|
||||
onClose = props.onClose,
|
||||
onKeyDown = props.onKeyDown,
|
||||
open = props.open,
|
||||
onTransitionEnter = props.onTransitionEnter,
|
||||
onTransitionExited = props.onTransitionExited,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["children", "closeAfterTransition", "container", "disableAutoFocus", "disableEnforceFocus", "disableEscapeKeyDown", "disablePortal", "disableRestoreFocus", "disableScrollLock", "hideBackdrop", "keepMounted", "onBackdropClick", "onClose", "onKeyDown", "open", "onTransitionEnter", "onTransitionExited", "slotProps", "slots"]);
|
||||
var propsWithDefaults = _extends({}, props, {
|
||||
closeAfterTransition: closeAfterTransition,
|
||||
disableAutoFocus: disableAutoFocus,
|
||||
disableEnforceFocus: disableEnforceFocus,
|
||||
disableEscapeKeyDown: disableEscapeKeyDown,
|
||||
disablePortal: disablePortal,
|
||||
disableRestoreFocus: disableRestoreFocus,
|
||||
disableScrollLock: disableScrollLock,
|
||||
hideBackdrop: hideBackdrop,
|
||||
keepMounted: keepMounted
|
||||
});
|
||||
var _useModal = useModal(_extends({}, propsWithDefaults, {
|
||||
rootRef: forwardedRef
|
||||
})),
|
||||
getRootProps = _useModal.getRootProps,
|
||||
getBackdropProps = _useModal.getBackdropProps,
|
||||
getTransitionProps = _useModal.getTransitionProps,
|
||||
portalRef = _useModal.portalRef,
|
||||
isTopModal = _useModal.isTopModal,
|
||||
exited = _useModal.exited,
|
||||
hasTransition = _useModal.hasTransition;
|
||||
var ownerState = _extends({}, propsWithDefaults, {
|
||||
exited: exited,
|
||||
hasTransition: hasTransition
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var childProps = {};
|
||||
if (children.props.tabIndex === undefined) {
|
||||
childProps.tabIndex = '-1';
|
||||
}
|
||||
|
||||
// It's a Transition like component
|
||||
if (hasTransition) {
|
||||
var _getTransitionProps = getTransitionProps(),
|
||||
onEnter = _getTransitionProps.onEnter,
|
||||
onExited = _getTransitionProps.onExited;
|
||||
childProps.onEnter = onEnter;
|
||||
childProps.onExited = onExited;
|
||||
}
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
getSlotProps: getRootProps,
|
||||
className: classes.root,
|
||||
ownerState: ownerState
|
||||
});
|
||||
var BackdropComponent = slots.backdrop;
|
||||
var backdropProps = useSlotProps({
|
||||
elementType: BackdropComponent,
|
||||
externalSlotProps: slotProps.backdrop,
|
||||
getSlotProps: function getSlotProps(otherHandlers) {
|
||||
return getBackdropProps(_extends({}, otherHandlers, {
|
||||
onClick: function onClick(e) {
|
||||
if (onBackdropClick) {
|
||||
onBackdropClick(e);
|
||||
}
|
||||
if (otherHandlers != null && otherHandlers.onClick) {
|
||||
otherHandlers.onClick(e);
|
||||
}
|
||||
}
|
||||
}));
|
||||
},
|
||||
className: classes.backdrop,
|
||||
ownerState: ownerState
|
||||
});
|
||||
if (!keepMounted && !open && (!hasTransition || exited)) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/_jsx(Portal, {
|
||||
ref: portalRef,
|
||||
container: container,
|
||||
disablePortal: disablePortal,
|
||||
children: /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
|
||||
children: [!hideBackdrop && BackdropComponent ? /*#__PURE__*/_jsx(BackdropComponent, _extends({}, backdropProps)) : null, /*#__PURE__*/_jsx(FocusTrap, {
|
||||
disableEnforceFocus: disableEnforceFocus,
|
||||
disableAutoFocus: disableAutoFocus,
|
||||
disableRestoreFocus: disableRestoreFocus,
|
||||
isEnabled: isTopModal,
|
||||
open: open,
|
||||
children: /*#__PURE__*/React.cloneElement(children, childProps)
|
||||
})]
|
||||
}))
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Modal.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.isRequired,
|
||||
/**
|
||||
* When set to true the Modal waits until a nested Transition is completed before closing.
|
||||
* @default false
|
||||
*/
|
||||
closeAfterTransition: PropTypes.bool,
|
||||
/**
|
||||
* 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]),
|
||||
/**
|
||||
* If `true`, the modal 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 modal children that have the `disableAutoFocus` prop.
|
||||
*
|
||||
* Generally this should never be set to `true` as it makes the modal less
|
||||
* accessible to assistive technologies, like screen readers.
|
||||
* @default false
|
||||
*/
|
||||
disableAutoFocus: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the modal will not prevent focus from leaving the modal while open.
|
||||
*
|
||||
* Generally this should never be set to `true` as it makes the modal less
|
||||
* accessible to assistive technologies, like screen readers.
|
||||
* @default false
|
||||
*/
|
||||
disableEnforceFocus: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, hitting escape will not fire the `onClose` callback.
|
||||
* @default false
|
||||
*/
|
||||
disableEscapeKeyDown: PropTypes.bool,
|
||||
/**
|
||||
* The `children` will be under the DOM hierarchy of the parent component.
|
||||
* @default false
|
||||
*/
|
||||
disablePortal: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the modal will not restore focus to previously focused element once
|
||||
* modal is hidden or unmounted.
|
||||
* @default false
|
||||
*/
|
||||
disableRestoreFocus: PropTypes.bool,
|
||||
/**
|
||||
* Disable the scroll lock behavior.
|
||||
* @default false
|
||||
*/
|
||||
disableScrollLock: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the backdrop is not rendered.
|
||||
* @default false
|
||||
*/
|
||||
hideBackdrop: PropTypes.bool,
|
||||
/**
|
||||
* Always keep the children in the DOM.
|
||||
* This prop can be useful in SEO situation or
|
||||
* when you want to maximize the responsiveness of the Modal.
|
||||
* @default false
|
||||
*/
|
||||
keepMounted: PropTypes.bool,
|
||||
/**
|
||||
* Callback fired when the backdrop is clicked.
|
||||
* @deprecated Use the `onClose` prop with the `reason` argument to handle the `backdropClick` events.
|
||||
*/
|
||||
onBackdropClick: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the component requests to be closed.
|
||||
* The `reason` parameter can optionally be used to control the response to `onClose`.
|
||||
*
|
||||
* @param {object} event The event source of the callback.
|
||||
* @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
|
||||
*/
|
||||
onClose: PropTypes.func,
|
||||
/**
|
||||
* A function called when a transition enters.
|
||||
*/
|
||||
onTransitionEnter: PropTypes.func,
|
||||
/**
|
||||
* A function called when a transition has exited.
|
||||
*/
|
||||
onTransitionExited: PropTypes.func,
|
||||
/**
|
||||
* If `true`, the component is shown.
|
||||
*/
|
||||
open: PropTypes.bool.isRequired,
|
||||
/**
|
||||
* The props used for each slot inside the Modal.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
backdrop: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Modal.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
backdrop: PropTypes.elementType,
|
||||
root: PropTypes.elementType
|
||||
})
|
||||
} : void 0;
|
||||
export { Modal };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export { Modal } from './Modal';
|
||||
export * from './Modal.types';
|
||||
export * from './modalClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
var COMPONENT_NAME = 'Modal';
|
||||
export function getModalUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var modalClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'hidden', 'backdrop']);
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
'use client';
|
||||
|
||||
var warnedOnce = false;
|
||||
var warn = function warn() {
|
||||
if (!warnedOnce) {
|
||||
console.error(['Base UI: The MultiSelect component was removed from the library.', '', 'The multi-select functionality is now available in the Select component.', 'Replace <MultiSelect> with <Select multiple /> in your code to remove this error.'].join('\n'));
|
||||
warnedOnce = true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The foundation for building custom-styled multi-selection select components.
|
||||
*
|
||||
* @deprecated The multi-select functionality is now available in the Select component. Replace <MultiSelect> with <Select multiple /> in your code.
|
||||
* @ignore - do not document.
|
||||
*/
|
||||
export function MultiSelect() {
|
||||
warn();
|
||||
return null;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
'use client';
|
||||
|
||||
export { MultiSelect } from './MultiSelect';
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { exactProp, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
/**
|
||||
* NoSsr purposely removes components from the subject of Server Side Rendering (SSR).
|
||||
*
|
||||
* This component can be useful in a variety of situations:
|
||||
*
|
||||
* * Escape hatch for broken dependencies not supporting SSR.
|
||||
* * Improve the time-to-first paint on the client by only rendering above the fold.
|
||||
* * Reduce the rendering time on the server.
|
||||
* * Under too heavy server load, you can turn on service degradation.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [No SSR](https://mui.com/base-ui/react-no-ssr/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [NoSsr API](https://mui.com/base-ui/react-no-ssr/components-api/#no-ssr)
|
||||
*/
|
||||
function NoSsr(props) {
|
||||
var children = props.children,
|
||||
_props$defer = props.defer,
|
||||
defer = _props$defer === void 0 ? false : _props$defer,
|
||||
_props$fallback = props.fallback,
|
||||
fallback = _props$fallback === void 0 ? null : _props$fallback;
|
||||
var _React$useState = React.useState(false),
|
||||
mountedState = _React$useState[0],
|
||||
setMountedState = _React$useState[1];
|
||||
useEnhancedEffect(function () {
|
||||
if (!defer) {
|
||||
setMountedState(true);
|
||||
}
|
||||
}, [defer]);
|
||||
React.useEffect(function () {
|
||||
if (defer) {
|
||||
setMountedState(true);
|
||||
}
|
||||
}, [defer]);
|
||||
|
||||
// We need the Fragment here to force react-docgen to recognise NoSsr as a component.
|
||||
return /*#__PURE__*/_jsx(React.Fragment, {
|
||||
children: mountedState ? children : fallback
|
||||
});
|
||||
}
|
||||
process.env.NODE_ENV !== "production" ? NoSsr.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* You can wrap a node.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* If `true`, the component will not only prevent server-side rendering.
|
||||
* It will also defer the rendering of the children into a different screen frame.
|
||||
* @default false
|
||||
*/
|
||||
defer: PropTypes.bool,
|
||||
/**
|
||||
* The fallback content to display.
|
||||
* @default null
|
||||
*/
|
||||
fallback: PropTypes.node
|
||||
} : void 0;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// eslint-disable-next-line
|
||||
NoSsr['propTypes' + ''] = exactProp(NoSsr.propTypes);
|
||||
}
|
||||
export { NoSsr };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
'use client';
|
||||
|
||||
export { NoSsr } from './NoSsr';
|
||||
export * from './NoSsr.types';
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getOptionUtilityClass } from './optionClasses';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useOption, useOptionContextStabilizer } from '../useOption';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { ListContext } from '../useList';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function useUtilityClasses(ownerState) {
|
||||
var disabled = ownerState.disabled,
|
||||
highlighted = ownerState.highlighted,
|
||||
selected = ownerState.selected;
|
||||
var slots = {
|
||||
root: ['root', disabled && 'disabled', highlighted && 'highlighted', selected && 'selected']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getOptionUtilityClass));
|
||||
}
|
||||
var InnerOption = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Option(props, forwardedRef) {
|
||||
var _slots$root, _optionRef$current;
|
||||
var children = props.children,
|
||||
_props$disabled = props.disabled,
|
||||
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
||||
label = props.label,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
value = props.value,
|
||||
other = _objectWithoutProperties(props, ["children", "disabled", "label", "slotProps", "slots", "value"]);
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'li';
|
||||
var optionRef = React.useRef(null);
|
||||
var combinedRef = useForkRef(optionRef, forwardedRef);
|
||||
|
||||
// If `label` is not explicitly provided, the `children` are used for convenience.
|
||||
// This is used to populate the select's trigger with the selected option's label.
|
||||
var computedLabel = label != null ? label : typeof children === 'string' ? children : (_optionRef$current = optionRef.current) == null || (_optionRef$current = _optionRef$current.textContent) == null ? void 0 : _optionRef$current.trim();
|
||||
var _useOption = useOption({
|
||||
disabled: disabled,
|
||||
label: computedLabel,
|
||||
rootRef: combinedRef,
|
||||
value: value
|
||||
}),
|
||||
getRootProps = _useOption.getRootProps,
|
||||
selected = _useOption.selected,
|
||||
highlighted = _useOption.highlighted,
|
||||
index = _useOption.index;
|
||||
var ownerState = _extends({}, props, {
|
||||
disabled: disabled,
|
||||
highlighted: highlighted,
|
||||
index: index,
|
||||
selected: selected
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var rootProps = useSlotProps({
|
||||
getSlotProps: getRootProps,
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
className: classes.root,
|
||||
ownerState: ownerState
|
||||
});
|
||||
return /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
|
||||
children: children
|
||||
}));
|
||||
}));
|
||||
|
||||
/**
|
||||
* An unstyled option to be used within a Select.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Select](https://mui.com/base-ui/react-select/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Option API](https://mui.com/base-ui/react-select/components-api/#option)
|
||||
*/
|
||||
var Option = /*#__PURE__*/React.forwardRef(function Option(props, ref) {
|
||||
var value = props.value; // This wrapper component is used as a performance optimization.
|
||||
// `useOptionContextStabilizer` ensures that the context value
|
||||
// is stable across renders, so that the actual Option re-renders
|
||||
// only when it needs to.
|
||||
var _useOptionContextStab = useOptionContextStabilizer(value),
|
||||
contextValue = _useOptionContextStab.contextValue;
|
||||
return /*#__PURE__*/_jsx(ListContext.Provider, {
|
||||
value: contextValue,
|
||||
children: /*#__PURE__*/_jsx(InnerOption, _extends({}, props, {
|
||||
ref: ref
|
||||
}))
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Option.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the option will be disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* A text representation of the option's content.
|
||||
* Used for keyboard text navigation matching.
|
||||
*/
|
||||
label: PropTypes.string,
|
||||
/**
|
||||
* The props used for each slot inside the Option.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Option.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The value of the option.
|
||||
*/
|
||||
value: PropTypes.any.isRequired
|
||||
} : void 0;
|
||||
export { Option };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export * from './Option';
|
||||
export * from './Option.types';
|
||||
export * from './optionClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'Option';
|
||||
export function getOptionUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var optionClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'disabled', 'selected', 'highlighted']);
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getOptionGroupUtilityClass } from './optionGroupClasses';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
function useUtilityClasses(disabled) {
|
||||
var slots = {
|
||||
root: ['root', disabled && 'disabled'],
|
||||
label: ['label'],
|
||||
list: ['list']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getOptionGroupUtilityClass));
|
||||
}
|
||||
|
||||
/**
|
||||
* An unstyled option group to be used within a Select.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Select](https://mui.com/base-ui/react-select/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [OptionGroup API](https://mui.com/base-ui/react-select/components-api/#option-group)
|
||||
*/
|
||||
var OptionGroup = /*#__PURE__*/React.forwardRef(function OptionGroup(props, forwardedRef) {
|
||||
var _props$disabled = props.disabled,
|
||||
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["disabled", "slotProps", "slots"]);
|
||||
var Root = (slots == null ? void 0 : slots.root) || 'li';
|
||||
var Label = (slots == null ? void 0 : slots.label) || 'span';
|
||||
var List = (slots == null ? void 0 : slots.list) || 'ul';
|
||||
var classes = useUtilityClasses(disabled);
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: props,
|
||||
className: classes.root
|
||||
});
|
||||
var labelProps = useSlotProps({
|
||||
elementType: Label,
|
||||
externalSlotProps: slotProps.label,
|
||||
ownerState: props,
|
||||
className: classes.label
|
||||
});
|
||||
var listProps = useSlotProps({
|
||||
elementType: List,
|
||||
externalSlotProps: slotProps.list,
|
||||
ownerState: props,
|
||||
className: classes.list
|
||||
});
|
||||
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
|
||||
children: [/*#__PURE__*/_jsx(Label, _extends({}, labelProps, {
|
||||
children: props.label
|
||||
})), /*#__PURE__*/_jsx(List, _extends({}, listProps, {
|
||||
children: props.children
|
||||
}))]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? OptionGroup.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true` all the options in the group will be disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* The human-readable description of the group.
|
||||
*/
|
||||
label: PropTypes.node,
|
||||
/**
|
||||
* The props used for each slot inside the Input.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
label: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
list: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the OptionGroup.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
label: PropTypes.elementType,
|
||||
list: PropTypes.elementType,
|
||||
root: PropTypes.elementType
|
||||
})
|
||||
} : void 0;
|
||||
export { OptionGroup };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { OptionGroup } from './OptionGroup';
|
||||
export * from './OptionGroup.types';
|
||||
export * from './optionGroupClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'OptionGroup';
|
||||
export function getOptionGroupUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var optionGroupClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'disabled', 'label', 'list']);
|
||||
+388
@@ -0,0 +1,388 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import { chainPropTypes, HTMLElementType, refType, unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useForkRef as useForkRef } from '@mui/utils';
|
||||
import { createPopper } from '@popperjs/core';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { Portal } from '../Portal';
|
||||
import { getPopperUtilityClass } from './popperClasses';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function flipPlacement(placement, direction) {
|
||||
if (direction === 'ltr') {
|
||||
return placement;
|
||||
}
|
||||
switch (placement) {
|
||||
case 'bottom-end':
|
||||
return 'bottom-start';
|
||||
case 'bottom-start':
|
||||
return 'bottom-end';
|
||||
case 'top-end':
|
||||
return 'top-start';
|
||||
case 'top-start':
|
||||
return 'top-end';
|
||||
default:
|
||||
return placement;
|
||||
}
|
||||
}
|
||||
function resolveAnchorEl(anchorEl) {
|
||||
return typeof anchorEl === 'function' ? anchorEl() : anchorEl;
|
||||
}
|
||||
function isHTMLElement(element) {
|
||||
return element.nodeType !== undefined;
|
||||
}
|
||||
function isVirtualElement(element) {
|
||||
return !isHTMLElement(element);
|
||||
}
|
||||
var useUtilityClasses = function useUtilityClasses() {
|
||||
var slots = {
|
||||
root: ['root']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getPopperUtilityClass));
|
||||
};
|
||||
var defaultPopperOptions = {};
|
||||
var PopperTooltip = /*#__PURE__*/React.forwardRef(function PopperTooltip(props, forwardedRef) {
|
||||
var _slots$root;
|
||||
var anchorEl = props.anchorEl,
|
||||
children = props.children,
|
||||
direction = props.direction,
|
||||
disablePortal = props.disablePortal,
|
||||
modifiers = props.modifiers,
|
||||
open = props.open,
|
||||
initialPlacement = props.placement,
|
||||
popperOptions = props.popperOptions,
|
||||
popperRefProp = props.popperRef,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
TransitionProps = props.TransitionProps,
|
||||
ownerStateProp = props.ownerState,
|
||||
other = _objectWithoutProperties(props, ["anchorEl", "children", "direction", "disablePortal", "modifiers", "open", "placement", "popperOptions", "popperRef", "slotProps", "slots", "TransitionProps", "ownerState"]);
|
||||
var tooltipRef = React.useRef(null);
|
||||
var ownRef = useForkRef(tooltipRef, forwardedRef);
|
||||
var popperRef = React.useRef(null);
|
||||
var handlePopperRef = useForkRef(popperRef, popperRefProp);
|
||||
var handlePopperRefRef = React.useRef(handlePopperRef);
|
||||
useEnhancedEffect(function () {
|
||||
handlePopperRefRef.current = handlePopperRef;
|
||||
}, [handlePopperRef]);
|
||||
React.useImperativeHandle(popperRefProp, function () {
|
||||
return popperRef.current;
|
||||
}, []);
|
||||
var rtlPlacement = flipPlacement(initialPlacement, direction);
|
||||
/**
|
||||
* placement initialized from prop but can change during lifetime if modifiers.flip.
|
||||
* modifiers.flip is essentially a flip for controlled/uncontrolled behavior
|
||||
*/
|
||||
var _React$useState = React.useState(rtlPlacement),
|
||||
placement = _React$useState[0],
|
||||
setPlacement = _React$useState[1];
|
||||
var _React$useState2 = React.useState(resolveAnchorEl(anchorEl)),
|
||||
resolvedAnchorElement = _React$useState2[0],
|
||||
setResolvedAnchorElement = _React$useState2[1];
|
||||
React.useEffect(function () {
|
||||
if (popperRef.current) {
|
||||
popperRef.current.forceUpdate();
|
||||
}
|
||||
});
|
||||
React.useEffect(function () {
|
||||
if (anchorEl) {
|
||||
setResolvedAnchorElement(resolveAnchorEl(anchorEl));
|
||||
}
|
||||
}, [anchorEl]);
|
||||
useEnhancedEffect(function () {
|
||||
if (!resolvedAnchorElement || !open) {
|
||||
return undefined;
|
||||
}
|
||||
var handlePopperUpdate = function handlePopperUpdate(data) {
|
||||
setPlacement(data.placement);
|
||||
};
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (resolvedAnchorElement && isHTMLElement(resolvedAnchorElement) && resolvedAnchorElement.nodeType === 1) {
|
||||
var box = resolvedAnchorElement.getBoundingClientRect();
|
||||
if (process.env.NODE_ENV !== 'test' && box.top === 0 && box.left === 0 && box.right === 0 && box.bottom === 0) {
|
||||
console.warn(['MUI: The `anchorEl` prop provided to the component is invalid.', 'The anchor element should be part of the document layout.', "Make sure the element is present in the document or that it's not display none."].join('\n'));
|
||||
}
|
||||
}
|
||||
}
|
||||
var popperModifiers = [{
|
||||
name: 'preventOverflow',
|
||||
options: {
|
||||
altBoundary: disablePortal
|
||||
}
|
||||
}, {
|
||||
name: 'flip',
|
||||
options: {
|
||||
altBoundary: disablePortal
|
||||
}
|
||||
}, {
|
||||
name: 'onUpdate',
|
||||
enabled: true,
|
||||
phase: 'afterWrite',
|
||||
fn: function fn(_ref) {
|
||||
var state = _ref.state;
|
||||
handlePopperUpdate(state);
|
||||
}
|
||||
}];
|
||||
if (modifiers != null) {
|
||||
popperModifiers = popperModifiers.concat(modifiers);
|
||||
}
|
||||
if (popperOptions && popperOptions.modifiers != null) {
|
||||
popperModifiers = popperModifiers.concat(popperOptions.modifiers);
|
||||
}
|
||||
var popper = createPopper(resolvedAnchorElement, tooltipRef.current, _extends({
|
||||
placement: rtlPlacement
|
||||
}, popperOptions, {
|
||||
modifiers: popperModifiers
|
||||
}));
|
||||
handlePopperRefRef.current(popper);
|
||||
return function () {
|
||||
popper.destroy();
|
||||
handlePopperRefRef.current(null);
|
||||
};
|
||||
}, [resolvedAnchorElement, disablePortal, modifiers, open, popperOptions, rtlPlacement]);
|
||||
var childProps = {
|
||||
placement: placement
|
||||
};
|
||||
if (TransitionProps !== null) {
|
||||
childProps.TransitionProps = TransitionProps;
|
||||
}
|
||||
var classes = useUtilityClasses();
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
role: 'tooltip',
|
||||
ref: ownRef
|
||||
},
|
||||
ownerState: props,
|
||||
className: classes.root
|
||||
});
|
||||
return /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
|
||||
children: typeof children === 'function' ? children(childProps) : children
|
||||
}));
|
||||
});
|
||||
|
||||
/**
|
||||
* Poppers rely on the 3rd party library [Popper.js](https://popper.js.org/docs/v2/) for positioning.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Popper](https://mui.com/base-ui/react-popper/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Popper API](https://mui.com/base-ui/react-popper/components-api/#popper)
|
||||
*/
|
||||
var Popper = /*#__PURE__*/React.forwardRef(function Popper(props, forwardedRef) {
|
||||
var anchorEl = props.anchorEl,
|
||||
children = props.children,
|
||||
containerProp = props.container,
|
||||
_props$direction = props.direction,
|
||||
direction = _props$direction === void 0 ? 'ltr' : _props$direction,
|
||||
_props$disablePortal = props.disablePortal,
|
||||
disablePortal = _props$disablePortal === void 0 ? false : _props$disablePortal,
|
||||
_props$keepMounted = props.keepMounted,
|
||||
keepMounted = _props$keepMounted === void 0 ? false : _props$keepMounted,
|
||||
modifiers = props.modifiers,
|
||||
open = props.open,
|
||||
_props$placement = props.placement,
|
||||
placement = _props$placement === void 0 ? 'bottom' : _props$placement,
|
||||
_props$popperOptions = props.popperOptions,
|
||||
popperOptions = _props$popperOptions === void 0 ? defaultPopperOptions : _props$popperOptions,
|
||||
popperRef = props.popperRef,
|
||||
style = props.style,
|
||||
_props$transition = props.transition,
|
||||
transition = _props$transition === void 0 ? false : _props$transition,
|
||||
_props$slotProps2 = props.slotProps,
|
||||
slotProps = _props$slotProps2 === void 0 ? {} : _props$slotProps2,
|
||||
_props$slots2 = props.slots,
|
||||
slots = _props$slots2 === void 0 ? {} : _props$slots2,
|
||||
other = _objectWithoutProperties(props, ["anchorEl", "children", "container", "direction", "disablePortal", "keepMounted", "modifiers", "open", "placement", "popperOptions", "popperRef", "style", "transition", "slotProps", "slots"]);
|
||||
var _React$useState3 = React.useState(true),
|
||||
exited = _React$useState3[0],
|
||||
setExited = _React$useState3[1];
|
||||
var handleEnter = function handleEnter() {
|
||||
setExited(false);
|
||||
};
|
||||
var handleExited = function handleExited() {
|
||||
setExited(true);
|
||||
};
|
||||
if (!keepMounted && !open && (!transition || exited)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If the container prop is provided, use that
|
||||
// If the anchorEl prop is provided, use its parent body element as the container
|
||||
// If neither are provided let the Modal take care of choosing the container
|
||||
var container;
|
||||
if (containerProp) {
|
||||
container = containerProp;
|
||||
} else if (anchorEl) {
|
||||
var resolvedAnchorEl = resolveAnchorEl(anchorEl);
|
||||
container = resolvedAnchorEl && isHTMLElement(resolvedAnchorEl) ? ownerDocument(resolvedAnchorEl).body : ownerDocument(null).body;
|
||||
}
|
||||
var display = !open && keepMounted && (!transition || exited) ? 'none' : undefined;
|
||||
var transitionProps = transition ? {
|
||||
in: open,
|
||||
onEnter: handleEnter,
|
||||
onExited: handleExited
|
||||
} : undefined;
|
||||
return /*#__PURE__*/_jsx(Portal, {
|
||||
disablePortal: disablePortal,
|
||||
container: container,
|
||||
children: /*#__PURE__*/_jsx(PopperTooltip, _extends({
|
||||
anchorEl: anchorEl,
|
||||
direction: direction,
|
||||
disablePortal: disablePortal,
|
||||
modifiers: modifiers,
|
||||
ref: forwardedRef,
|
||||
open: transition ? !exited : open,
|
||||
placement: placement,
|
||||
popperOptions: popperOptions,
|
||||
popperRef: popperRef,
|
||||
slotProps: slotProps,
|
||||
slots: slots
|
||||
}, other, {
|
||||
style: _extends({
|
||||
// Prevents scroll issue, waiting for Popper.js to add this style once initiated.
|
||||
position: 'fixed',
|
||||
// Fix Popper.js display issue
|
||||
top: 0,
|
||||
left: 0,
|
||||
display: display
|
||||
}, style),
|
||||
TransitionProps: transitionProps,
|
||||
children: children
|
||||
}))
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Popper.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
|
||||
* or a function that returns either.
|
||||
* It's used to set the position of the popper.
|
||||
* The return value will passed as the reference object of the Popper instance.
|
||||
*/
|
||||
anchorEl: chainPropTypes(PropTypes.oneOfType([HTMLElementType, PropTypes.object, PropTypes.func]), function (props) {
|
||||
if (props.open) {
|
||||
var resolvedAnchorEl = resolveAnchorEl(props.anchorEl);
|
||||
if (resolvedAnchorEl && isHTMLElement(resolvedAnchorEl) && resolvedAnchorEl.nodeType === 1) {
|
||||
var box = resolvedAnchorEl.getBoundingClientRect();
|
||||
if (process.env.NODE_ENV !== 'test' && box.top === 0 && box.left === 0 && box.right === 0 && box.bottom === 0) {
|
||||
return new Error(['MUI: The `anchorEl` prop provided to the component is invalid.', 'The anchor element should be part of the document layout.', "Make sure the element is present in the document or that it's not display none."].join('\n'));
|
||||
}
|
||||
} else if (!resolvedAnchorEl || typeof resolvedAnchorEl.getBoundingClientRect !== 'function' || isVirtualElement(resolvedAnchorEl) && resolvedAnchorEl.contextElement != null && resolvedAnchorEl.contextElement.nodeType !== 1) {
|
||||
return new Error(['MUI: The `anchorEl` prop provided to the component is invalid.', 'It should be an HTML element instance or a virtualElement ', '(https://popper.js.org/docs/v2/virtual-elements/).'].join('\n'));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
/**
|
||||
* Popper render function or node.
|
||||
*/
|
||||
children: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.node, PropTypes.func]),
|
||||
/**
|
||||
* 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]),
|
||||
/**
|
||||
* Direction of the text.
|
||||
* @default 'ltr'
|
||||
*/
|
||||
direction: PropTypes.oneOf(['ltr', 'rtl']),
|
||||
/**
|
||||
* The `children` will be under the DOM hierarchy of the parent component.
|
||||
* @default false
|
||||
*/
|
||||
disablePortal: PropTypes.bool,
|
||||
/**
|
||||
* Always keep the children in the DOM.
|
||||
* This prop can be useful in SEO situation or
|
||||
* when you want to maximize the responsiveness of the Popper.
|
||||
* @default false
|
||||
*/
|
||||
keepMounted: PropTypes.bool,
|
||||
/**
|
||||
* Popper.js is based on a "plugin-like" architecture,
|
||||
* most of its features are fully encapsulated "modifiers".
|
||||
*
|
||||
* A modifier is a function that is called each time Popper.js needs to
|
||||
* compute the position of the popper.
|
||||
* For this reason, modifiers should be very performant to avoid bottlenecks.
|
||||
* To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
|
||||
*/
|
||||
modifiers: PropTypes.arrayOf(PropTypes.shape({
|
||||
data: PropTypes.object,
|
||||
effect: PropTypes.func,
|
||||
enabled: PropTypes.bool,
|
||||
fn: PropTypes.func,
|
||||
name: PropTypes.any,
|
||||
options: PropTypes.object,
|
||||
phase: PropTypes.oneOf(['afterMain', 'afterRead', 'afterWrite', 'beforeMain', 'beforeRead', 'beforeWrite', 'main', 'read', 'write']),
|
||||
requires: PropTypes.arrayOf(PropTypes.string),
|
||||
requiresIfExists: PropTypes.arrayOf(PropTypes.string)
|
||||
})),
|
||||
/**
|
||||
* If `true`, the component is shown.
|
||||
*/
|
||||
open: PropTypes.bool.isRequired,
|
||||
/**
|
||||
* Popper placement.
|
||||
* @default 'bottom'
|
||||
*/
|
||||
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
||||
/**
|
||||
* Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
|
||||
* @default {}
|
||||
*/
|
||||
popperOptions: PropTypes.shape({
|
||||
modifiers: PropTypes.array,
|
||||
onFirstUpdate: PropTypes.func,
|
||||
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
||||
strategy: PropTypes.oneOf(['absolute', 'fixed'])
|
||||
}),
|
||||
/**
|
||||
* A ref that points to the used popper instance.
|
||||
*/
|
||||
popperRef: refType,
|
||||
/**
|
||||
* The props used for each slot inside the Popper.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Popper.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* Help supporting a react-transition-group/Transition component.
|
||||
* @default false
|
||||
*/
|
||||
transition: PropTypes.bool
|
||||
} : void 0;
|
||||
export { Popper };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
'use client';
|
||||
|
||||
export { Popper } from './Popper';
|
||||
export { popperClasses, getPopperUtilityClass } from './popperClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'Popper';
|
||||
export function getPopperUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var popperClasses = generateUtilityClasses(COMPONENT_NAME, ['root']);
|
||||
+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)
|
||||
*/
|
||||
var Portal = /*#__PURE__*/React.forwardRef(function Portal(props, forwardedRef) {
|
||||
var children = props.children,
|
||||
container = props.container,
|
||||
_props$disablePortal = props.disablePortal,
|
||||
disablePortal = _props$disablePortal === void 0 ? false : _props$disablePortal;
|
||||
var _React$useState = React.useState(null),
|
||||
mountNode = _React$useState[0],
|
||||
setMountNode = _React$useState[1]; // @ts-expect-error TODO upstream fix
|
||||
var handleRef = useForkRef( /*#__PURE__*/React.isValidElement(children) ? children.ref : null, forwardedRef);
|
||||
useEnhancedEffect(function () {
|
||||
if (!disablePortal) {
|
||||
setMountNode(getContainer(container) || document.body);
|
||||
}
|
||||
}, [container, disablePortal]);
|
||||
useEnhancedEffect(function () {
|
||||
if (mountNode && !disablePortal) {
|
||||
setRef(forwardedRef, mountNode);
|
||||
return function () {
|
||||
setRef(forwardedRef, null);
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}, [forwardedRef, mountNode, disablePortal]);
|
||||
if (disablePortal) {
|
||||
if ( /*#__PURE__*/React.isValidElement(children)) {
|
||||
var 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 };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
'use client';
|
||||
|
||||
export { Portal } from './Portal';
|
||||
export * from './Portal.types';
|
||||
+334
@@ -0,0 +1,334 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
var _span;
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
||||
import { useSelect } from '../useSelect';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { Popup } from '../Unstable_Popup/Popup';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getSelectUtilityClass } from './selectClasses';
|
||||
import { defaultOptionStringifier } from '../useSelect/defaultOptionStringifier';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { SelectProvider } from '../useSelect/SelectProvider';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
function defaultRenderValue(selectedOptions) {
|
||||
var _selectedOptions$labe;
|
||||
if (Array.isArray(selectedOptions)) {
|
||||
return /*#__PURE__*/_jsx(React.Fragment, {
|
||||
children: selectedOptions.map(function (o) {
|
||||
return o.label;
|
||||
}).join(', ')
|
||||
});
|
||||
}
|
||||
return (_selectedOptions$labe = selectedOptions == null ? void 0 : selectedOptions.label) != null ? _selectedOptions$labe : null;
|
||||
}
|
||||
function useUtilityClasses(ownerState) {
|
||||
var active = ownerState.active,
|
||||
disabled = ownerState.disabled,
|
||||
open = ownerState.open,
|
||||
focusVisible = ownerState.focusVisible;
|
||||
var slots = {
|
||||
root: ['root', disabled && 'disabled', focusVisible && 'focusVisible', active && 'active', open && 'expanded'],
|
||||
listbox: ['listbox', disabled && 'disabled'],
|
||||
popup: ['popup']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getSelectUtilityClass));
|
||||
}
|
||||
|
||||
/**
|
||||
* The foundation for building custom-styled select components.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Select](https://mui.com/base-ui/react-select/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Select API](https://mui.com/base-ui/react-select/components-api/#select)
|
||||
*/
|
||||
var Select = /*#__PURE__*/React.forwardRef(function Select(props, forwardedRef) {
|
||||
var _slots$root, _slots$listbox, _slots$popup, _ref, _renderValue;
|
||||
var areOptionsEqual = props.areOptionsEqual,
|
||||
autoComplete = props.autoComplete,
|
||||
autoFocus = props.autoFocus,
|
||||
children = props.children,
|
||||
defaultValue = props.defaultValue,
|
||||
_props$defaultListbox = props.defaultListboxOpen,
|
||||
defaultListboxOpen = _props$defaultListbox === void 0 ? false : _props$defaultListbox,
|
||||
disabledProp = props.disabled,
|
||||
getSerializedValue = props.getSerializedValue,
|
||||
listboxId = props.listboxId,
|
||||
listboxOpenProp = props.listboxOpen,
|
||||
_props$multiple = props.multiple,
|
||||
multiple = _props$multiple === void 0 ? false : _props$multiple,
|
||||
name = props.name,
|
||||
_props$required = props.required,
|
||||
required = _props$required === void 0 ? false : _props$required,
|
||||
onChange = props.onChange,
|
||||
onListboxOpenChange = props.onListboxOpenChange,
|
||||
_props$getOptionAsStr = props.getOptionAsString,
|
||||
getOptionAsString = _props$getOptionAsStr === void 0 ? defaultOptionStringifier : _props$getOptionAsStr,
|
||||
renderValueProp = props.renderValue,
|
||||
placeholder = props.placeholder,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
valueProp = props.value,
|
||||
other = _objectWithoutProperties(props, ["areOptionsEqual", "autoComplete", "autoFocus", "children", "defaultValue", "defaultListboxOpen", "disabled", "getSerializedValue", "listboxId", "listboxOpen", "multiple", "name", "required", "onChange", "onListboxOpenChange", "getOptionAsString", "renderValue", "placeholder", "slotProps", "slots", "value"]);
|
||||
var renderValue = renderValueProp != null ? renderValueProp : defaultRenderValue;
|
||||
var _React$useState = React.useState(false),
|
||||
buttonDefined = _React$useState[0],
|
||||
setButtonDefined = _React$useState[1];
|
||||
var buttonRef = React.useRef(null);
|
||||
var listboxRef = React.useRef(null);
|
||||
var Button = (_slots$root = slots.root) != null ? _slots$root : 'button';
|
||||
var ListboxRoot = (_slots$listbox = slots.listbox) != null ? _slots$listbox : 'ul';
|
||||
var PopupComponent = (_slots$popup = slots.popup) != null ? _slots$popup : 'div';
|
||||
var handleButtonRefChange = React.useCallback(function (element) {
|
||||
setButtonDefined(element != null);
|
||||
}, []);
|
||||
var handleButtonRef = useForkRef(forwardedRef, buttonRef, handleButtonRefChange);
|
||||
React.useEffect(function () {
|
||||
if (autoFocus) {
|
||||
buttonRef.current.focus();
|
||||
}
|
||||
}, [autoFocus]);
|
||||
var _useSelect = useSelect({
|
||||
name: name,
|
||||
required: required,
|
||||
getSerializedValue: getSerializedValue,
|
||||
areOptionsEqual: areOptionsEqual,
|
||||
buttonRef: handleButtonRef,
|
||||
defaultOpen: defaultListboxOpen,
|
||||
defaultValue: defaultValue,
|
||||
disabled: disabledProp,
|
||||
listboxId: listboxId,
|
||||
multiple: multiple,
|
||||
open: listboxOpenProp,
|
||||
onChange: onChange,
|
||||
onOpenChange: onListboxOpenChange,
|
||||
getOptionAsString: getOptionAsString,
|
||||
value: valueProp,
|
||||
componentName: 'Select'
|
||||
}),
|
||||
buttonActive = _useSelect.buttonActive,
|
||||
buttonFocusVisible = _useSelect.buttonFocusVisible,
|
||||
contextValue = _useSelect.contextValue,
|
||||
disabled = _useSelect.disabled,
|
||||
getButtonProps = _useSelect.getButtonProps,
|
||||
getListboxProps = _useSelect.getListboxProps,
|
||||
getHiddenInputProps = _useSelect.getHiddenInputProps,
|
||||
getOptionMetadata = _useSelect.getOptionMetadata,
|
||||
value = _useSelect.value,
|
||||
open = _useSelect.open;
|
||||
var ownerState = _extends({}, props, {
|
||||
active: buttonActive,
|
||||
defaultListboxOpen: defaultListboxOpen,
|
||||
disabled: disabled,
|
||||
focusVisible: buttonFocusVisible,
|
||||
open: open,
|
||||
multiple: multiple,
|
||||
renderValue: renderValue,
|
||||
value: value
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var buttonProps = useSlotProps({
|
||||
elementType: Button,
|
||||
getSlotProps: getButtonProps,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
var listboxProps = useSlotProps({
|
||||
elementType: ListboxRoot,
|
||||
getSlotProps: getListboxProps,
|
||||
externalSlotProps: slotProps.listbox,
|
||||
additionalProps: {
|
||||
ref: listboxRef
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.listbox
|
||||
});
|
||||
var popupProps = useSlotProps({
|
||||
elementType: PopupComponent,
|
||||
externalSlotProps: slotProps.popup,
|
||||
additionalProps: {
|
||||
anchor: buttonRef.current,
|
||||
keepMounted: true,
|
||||
open: open,
|
||||
placement: 'bottom-start',
|
||||
role: undefined
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.popup
|
||||
});
|
||||
var selectedOptionsMetadata;
|
||||
if (multiple) {
|
||||
selectedOptionsMetadata = value.map(function (v) {
|
||||
return getOptionMetadata(v);
|
||||
}).filter(function (o) {
|
||||
return o !== undefined;
|
||||
});
|
||||
} else {
|
||||
var _getOptionMetadata;
|
||||
selectedOptionsMetadata = (_getOptionMetadata = getOptionMetadata(value)) != null ? _getOptionMetadata : null;
|
||||
}
|
||||
return /*#__PURE__*/_jsxs(React.Fragment, {
|
||||
children: [/*#__PURE__*/_jsx(Button, _extends({}, buttonProps, {
|
||||
children: (_ref = (_renderValue = renderValue(selectedOptionsMetadata)) != null ? _renderValue : placeholder) != null ? _ref : // fall back to a zero-width space to prevent layout shift
|
||||
// from https://github.com/mui/material-ui/pull/24563
|
||||
_span || (_span = /*#__PURE__*/_jsx("span", {
|
||||
className: "notranslate",
|
||||
children: "\u200B"
|
||||
}))
|
||||
})), buttonDefined && /*#__PURE__*/_jsx(Popup, _extends({
|
||||
slots: {
|
||||
root: PopupComponent
|
||||
}
|
||||
}, popupProps, {
|
||||
children: /*#__PURE__*/_jsx(ListboxRoot, _extends({}, listboxProps, {
|
||||
children: /*#__PURE__*/_jsx(SelectProvider, {
|
||||
value: contextValue,
|
||||
children: children
|
||||
})
|
||||
}))
|
||||
})), /*#__PURE__*/_jsx("input", _extends({}, getHiddenInputProps(), {
|
||||
autoComplete: autoComplete
|
||||
}))]
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Select.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 function used to determine if two options' values are equal.
|
||||
* By default, reference equality is used.
|
||||
*
|
||||
* There is a performance impact when using the `areOptionsEqual` prop (proportional to the number of options).
|
||||
* Therefore, it's recommented to use the default reference equality comparison whenever possible.
|
||||
*/
|
||||
areOptionsEqual: PropTypes.func,
|
||||
/**
|
||||
* 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 select element is focused during the first mount
|
||||
* @default false
|
||||
*/
|
||||
autoFocus: PropTypes.bool,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the select will be initially open.
|
||||
* @default false
|
||||
*/
|
||||
defaultListboxOpen: PropTypes.bool,
|
||||
/**
|
||||
* The default selected value. Use when the component is not controlled.
|
||||
*/
|
||||
defaultValue: PropTypes.any,
|
||||
/**
|
||||
* If `true`, the select is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* A function used to convert the option label to a string.
|
||||
* It's useful when labels are elements and need to be converted to plain text
|
||||
* to enable navigation using character keys on a keyboard.
|
||||
*
|
||||
* @default defaultOptionStringifier
|
||||
*/
|
||||
getOptionAsString: PropTypes.func,
|
||||
/**
|
||||
* A function to convert the currently selected value to a string.
|
||||
* Used to set a value of a hidden input associated with the select,
|
||||
* so that the selected value can be posted with a form.
|
||||
*/
|
||||
getSerializedValue: PropTypes.func,
|
||||
/**
|
||||
* `id` attribute of the listbox element.
|
||||
*/
|
||||
listboxId: PropTypes.string,
|
||||
/**
|
||||
* Controls the open state of the select's listbox.
|
||||
* @default undefined
|
||||
*/
|
||||
listboxOpen: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, selecting multiple values is allowed.
|
||||
* This affects the type of the `value`, `defaultValue`, and `onChange` props.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
multiple: PropTypes.bool,
|
||||
/**
|
||||
* Name of the element. For example used by the server to identify the fields in form submits.
|
||||
*/
|
||||
name: PropTypes.string,
|
||||
/**
|
||||
* Callback fired when an option is selected.
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the component requests to be opened.
|
||||
* Use in controlled mode (see listboxOpen).
|
||||
*/
|
||||
onListboxOpenChange: PropTypes.func,
|
||||
/**
|
||||
* Text to show when there is no selected value.
|
||||
*/
|
||||
placeholder: PropTypes.node,
|
||||
/**
|
||||
* Function that customizes the rendering of the selected value.
|
||||
*/
|
||||
renderValue: PropTypes.func,
|
||||
/**
|
||||
* If `true`, the Select cannot be empty when submitting form.
|
||||
* @default false
|
||||
*/
|
||||
required: PropTypes.bool,
|
||||
/**
|
||||
* The props used for each slot inside the Input.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes /* @typescript-to-proptypes-ignore */.shape({
|
||||
listbox: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
popup: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Select.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes /* @typescript-to-proptypes-ignore */.shape({
|
||||
listbox: PropTypes.elementType,
|
||||
popup: PropTypes.elementType,
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The selected value.
|
||||
* Set to `null` to deselect all options.
|
||||
*/
|
||||
value: PropTypes.any
|
||||
} : void 0;
|
||||
export { Select };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { Select } from './Select';
|
||||
export * from './selectClasses';
|
||||
export * from './Select.types';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'Select';
|
||||
export function getSelectUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var selectClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'button', 'listbox', 'popup', 'active', 'expanded', 'disabled', 'focusVisible']);
|
||||
+459
@@ -0,0 +1,459 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import { chainPropTypes } from '@mui/utils';
|
||||
import { isHostComponent } from '../utils/isHostComponent';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getSliderUtilityClass } from './sliderClasses';
|
||||
import { useSlider, valueToPercent } from '../useSlider';
|
||||
import { useSlotProps } from '../utils/useSlotProps';
|
||||
import { resolveComponentProps } from '../utils/resolveComponentProps';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
|
||||
// @ts-ignore
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
function Identity(x) {
|
||||
return x;
|
||||
}
|
||||
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
||||
var disabled = ownerState.disabled,
|
||||
dragging = ownerState.dragging,
|
||||
marked = ownerState.marked,
|
||||
orientation = ownerState.orientation,
|
||||
track = ownerState.track;
|
||||
var slots = {
|
||||
root: ['root', disabled && 'disabled', dragging && 'dragging', marked && 'marked', orientation === 'vertical' && 'vertical', track === 'inverted' && 'trackInverted', track === false && 'trackFalse'],
|
||||
rail: ['rail'],
|
||||
track: ['track'],
|
||||
mark: ['mark'],
|
||||
markActive: ['markActive'],
|
||||
markLabel: ['markLabel'],
|
||||
markLabelActive: ['markLabelActive'],
|
||||
valueLabel: ['valueLabel'],
|
||||
thumb: ['thumb', disabled && 'disabled'],
|
||||
active: ['active'],
|
||||
disabled: ['disabled'],
|
||||
focusVisible: ['focusVisible']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getSliderUtilityClass));
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Slider](https://mui.com/base-ui/react-slider/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Slider API](https://mui.com/base-ui/react-slider/components-api/#slider)
|
||||
*/
|
||||
var Slider = /*#__PURE__*/React.forwardRef(function Slider(props, forwardedRef) {
|
||||
var _slots$root, _slots$rail, _slots$track, _slots$thumb, _slots$mark, _slots$markLabel;
|
||||
var ariaLabel = props['aria-label'],
|
||||
ariaValuetext = props['aria-valuetext'],
|
||||
ariaLabelledby = props['aria-labelledby'],
|
||||
className = props.className,
|
||||
_props$disableSwap = props.disableSwap,
|
||||
disableSwap = _props$disableSwap === void 0 ? false : _props$disableSwap,
|
||||
_props$disabled = props.disabled,
|
||||
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
||||
getAriaLabel = props.getAriaLabel,
|
||||
getAriaValueText = props.getAriaValueText,
|
||||
_props$marks = props.marks,
|
||||
marksProp = _props$marks === void 0 ? false : _props$marks,
|
||||
_props$max = props.max,
|
||||
max = _props$max === void 0 ? 100 : _props$max,
|
||||
_props$min = props.min,
|
||||
min = _props$min === void 0 ? 0 : _props$min,
|
||||
name = props.name,
|
||||
onChange = props.onChange,
|
||||
onChangeCommitted = props.onChangeCommitted,
|
||||
_props$orientation = props.orientation,
|
||||
orientation = _props$orientation === void 0 ? 'horizontal' : _props$orientation,
|
||||
_props$shiftStep = props.shiftStep,
|
||||
shiftStep = _props$shiftStep === void 0 ? 10 : _props$shiftStep,
|
||||
_props$scale = props.scale,
|
||||
scale = _props$scale === void 0 ? Identity : _props$scale,
|
||||
_props$step = props.step,
|
||||
step = _props$step === void 0 ? 1 : _props$step,
|
||||
tabIndex = props.tabIndex,
|
||||
_props$track = props.track,
|
||||
track = _props$track === void 0 ? 'normal' : _props$track,
|
||||
valueProp = props.value,
|
||||
_props$valueLabelForm = props.valueLabelFormat,
|
||||
valueLabelFormat = _props$valueLabelForm === void 0 ? Identity : _props$valueLabelForm,
|
||||
_props$isRtl = props.isRtl,
|
||||
isRtl = _props$isRtl === void 0 ? false : _props$isRtl,
|
||||
defaultValue = props.defaultValue,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["aria-label", "aria-valuetext", "aria-labelledby", "className", "disableSwap", "disabled", "getAriaLabel", "getAriaValueText", "marks", "max", "min", "name", "onChange", "onChangeCommitted", "orientation", "shiftStep", "scale", "step", "tabIndex", "track", "value", "valueLabelFormat", "isRtl", "defaultValue", "slotProps", "slots"]); // all props with defaults
|
||||
// consider extracting to hook an reusing the lint rule for the variants
|
||||
var partialOwnerState = _extends({}, props, {
|
||||
marks: marksProp,
|
||||
disabled: disabled,
|
||||
disableSwap: disableSwap,
|
||||
isRtl: isRtl,
|
||||
defaultValue: defaultValue,
|
||||
max: max,
|
||||
min: min,
|
||||
orientation: orientation,
|
||||
scale: scale,
|
||||
step: step,
|
||||
shiftStep: shiftStep,
|
||||
track: track,
|
||||
valueLabelFormat: valueLabelFormat
|
||||
});
|
||||
var _useSlider = useSlider(_extends({}, partialOwnerState, {
|
||||
rootRef: forwardedRef
|
||||
})),
|
||||
axisProps = _useSlider.axisProps,
|
||||
getRootProps = _useSlider.getRootProps,
|
||||
getHiddenInputProps = _useSlider.getHiddenInputProps,
|
||||
getThumbProps = _useSlider.getThumbProps,
|
||||
active = _useSlider.active,
|
||||
axis = _useSlider.axis,
|
||||
range = _useSlider.range,
|
||||
focusedThumbIndex = _useSlider.focusedThumbIndex,
|
||||
dragging = _useSlider.dragging,
|
||||
marks = _useSlider.marks,
|
||||
values = _useSlider.values,
|
||||
trackOffset = _useSlider.trackOffset,
|
||||
trackLeap = _useSlider.trackLeap,
|
||||
getThumbStyle = _useSlider.getThumbStyle;
|
||||
var ownerState = _extends({}, partialOwnerState, {
|
||||
marked: marks.length > 0 && marks.some(function (mark) {
|
||||
return mark.label;
|
||||
}),
|
||||
dragging: dragging,
|
||||
focusedThumbIndex: focusedThumbIndex,
|
||||
activeThumbIndex: active
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'span';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
getSlotProps: getRootProps,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
ownerState: ownerState,
|
||||
className: [classes.root, className]
|
||||
});
|
||||
var Rail = (_slots$rail = slots.rail) != null ? _slots$rail : 'span';
|
||||
var railProps = useSlotProps({
|
||||
elementType: Rail,
|
||||
externalSlotProps: slotProps.rail,
|
||||
ownerState: ownerState,
|
||||
className: classes.rail
|
||||
});
|
||||
var Track = (_slots$track = slots.track) != null ? _slots$track : 'span';
|
||||
var trackProps = useSlotProps({
|
||||
elementType: Track,
|
||||
externalSlotProps: slotProps.track,
|
||||
additionalProps: {
|
||||
style: _extends({}, axisProps[axis].offset(trackOffset), axisProps[axis].leap(trackLeap))
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.track
|
||||
});
|
||||
var Thumb = (_slots$thumb = slots.thumb) != null ? _slots$thumb : 'span';
|
||||
var thumbProps = useSlotProps({
|
||||
elementType: Thumb,
|
||||
getSlotProps: getThumbProps,
|
||||
externalSlotProps: slotProps.thumb,
|
||||
ownerState: ownerState,
|
||||
skipResolvingSlotProps: true
|
||||
});
|
||||
var ValueLabel = slots.valueLabel;
|
||||
var valueLabelProps = useSlotProps({
|
||||
elementType: ValueLabel,
|
||||
externalSlotProps: slotProps.valueLabel,
|
||||
ownerState: ownerState
|
||||
});
|
||||
var Mark = (_slots$mark = slots.mark) != null ? _slots$mark : 'span';
|
||||
var markProps = useSlotProps({
|
||||
elementType: Mark,
|
||||
externalSlotProps: slotProps.mark,
|
||||
ownerState: ownerState,
|
||||
className: classes.mark
|
||||
});
|
||||
var MarkLabel = (_slots$markLabel = slots.markLabel) != null ? _slots$markLabel : 'span';
|
||||
var markLabelProps = useSlotProps({
|
||||
elementType: MarkLabel,
|
||||
externalSlotProps: slotProps.markLabel,
|
||||
ownerState: ownerState
|
||||
});
|
||||
var Input = slots.input || 'input';
|
||||
var inputProps = useSlotProps({
|
||||
elementType: Input,
|
||||
getSlotProps: getHiddenInputProps,
|
||||
externalSlotProps: slotProps.input,
|
||||
ownerState: ownerState
|
||||
});
|
||||
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
|
||||
children: [/*#__PURE__*/_jsx(Rail, _extends({}, railProps)), /*#__PURE__*/_jsx(Track, _extends({}, trackProps)), marks.filter(function (mark) {
|
||||
return mark.value >= min && mark.value <= max;
|
||||
}).map(function (mark, index) {
|
||||
var percent = valueToPercent(mark.value, min, max);
|
||||
var style = axisProps[axis].offset(percent);
|
||||
var markActive;
|
||||
if (track === false) {
|
||||
markActive = values.indexOf(mark.value) !== -1;
|
||||
} else {
|
||||
markActive = track === 'normal' && (range ? mark.value >= values[0] && mark.value <= values[values.length - 1] : mark.value <= values[0]) || track === 'inverted' && (range ? mark.value <= values[0] || mark.value >= values[values.length - 1] : mark.value >= values[0]);
|
||||
}
|
||||
return /*#__PURE__*/_jsxs(React.Fragment, {
|
||||
children: [/*#__PURE__*/_jsx(Mark, _extends({
|
||||
"data-index": index
|
||||
}, markProps, !isHostComponent(Mark) && {
|
||||
markActive: markActive
|
||||
}, {
|
||||
style: _extends({}, style, markProps.style),
|
||||
className: clsx(markProps.className, markActive && classes.markActive)
|
||||
})), mark.label != null ? /*#__PURE__*/_jsx(MarkLabel, _extends({
|
||||
"aria-hidden": true,
|
||||
"data-index": index
|
||||
}, markLabelProps, !isHostComponent(MarkLabel) && {
|
||||
markLabelActive: markActive
|
||||
}, {
|
||||
style: _extends({}, style, markLabelProps.style),
|
||||
className: clsx(classes.markLabel, markLabelProps.className, markActive && classes.markLabelActive),
|
||||
children: mark.label
|
||||
})) : null]
|
||||
}, index);
|
||||
}), values.map(function (value, index) {
|
||||
var percent = valueToPercent(value, min, max);
|
||||
var style = axisProps[axis].offset(percent);
|
||||
var resolvedSlotProps = resolveComponentProps(slotProps.thumb, ownerState, {
|
||||
index: index,
|
||||
focused: focusedThumbIndex === index,
|
||||
active: active === index
|
||||
});
|
||||
return /*#__PURE__*/_jsxs(Thumb, _extends({
|
||||
"data-index": index
|
||||
}, thumbProps, resolvedSlotProps, {
|
||||
className: clsx(classes.thumb, thumbProps.className, resolvedSlotProps == null ? void 0 : resolvedSlotProps.className, active === index && classes.active, focusedThumbIndex === index && classes.focusVisible),
|
||||
style: _extends({}, style, getThumbStyle(index), thumbProps.style, resolvedSlotProps == null ? void 0 : resolvedSlotProps.style),
|
||||
children: [/*#__PURE__*/_jsx(Input, _extends({
|
||||
"data-index": index,
|
||||
"aria-label": getAriaLabel ? getAriaLabel(index) : ariaLabel,
|
||||
"aria-valuenow": scale(value),
|
||||
"aria-labelledby": ariaLabelledby,
|
||||
"aria-valuetext": getAriaValueText ? getAriaValueText(scale(value), index) : ariaValuetext,
|
||||
value: values[index]
|
||||
}, inputProps)), ValueLabel ? /*#__PURE__*/_jsx(ValueLabel, _extends({}, !isHostComponent(ValueLabel) && {
|
||||
valueLabelFormat: valueLabelFormat,
|
||||
index: index,
|
||||
disabled: disabled
|
||||
}, valueLabelProps, {
|
||||
children: typeof valueLabelFormat === 'function' ? valueLabelFormat(scale(value), index) : valueLabelFormat
|
||||
})) : null]
|
||||
}), index);
|
||||
})]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Slider.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 label of the slider.
|
||||
*/
|
||||
'aria-label': chainPropTypes(PropTypes.string, function (props) {
|
||||
var range = Array.isArray(props.value || props.defaultValue);
|
||||
if (range && props['aria-label'] != null) {
|
||||
return new Error('MUI: You need to use the `getAriaLabel` prop instead of `aria-label` when using a range slider.');
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
/**
|
||||
* The id of the element containing a label for the slider.
|
||||
*/
|
||||
'aria-labelledby': PropTypes.string,
|
||||
/**
|
||||
* A string value that provides a user-friendly name for the current value of the slider.
|
||||
*/
|
||||
'aria-valuetext': chainPropTypes(PropTypes.string, function (props) {
|
||||
var range = Array.isArray(props.value || props.defaultValue);
|
||||
if (range && props['aria-valuetext'] != null) {
|
||||
return new Error('MUI: You need to use the `getAriaValueText` prop instead of `aria-valuetext` when using a range slider.');
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
/**
|
||||
* The default value. Use when the component is not controlled.
|
||||
*/
|
||||
defaultValue: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]),
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the active thumb doesn't swap when moving pointer over a thumb while dragging another thumb.
|
||||
* @default false
|
||||
*/
|
||||
disableSwap: PropTypes.bool,
|
||||
/**
|
||||
* Accepts a function which returns a string value that provides a user-friendly name for the thumb labels of the slider.
|
||||
* This is important for screen reader users.
|
||||
* @param {number} index The thumb label's index to format.
|
||||
* @returns {string}
|
||||
*/
|
||||
getAriaLabel: PropTypes.func,
|
||||
/**
|
||||
* Accepts a function which returns a string value that provides a user-friendly name for the current value of the slider.
|
||||
* This is important for screen reader users.
|
||||
* @param {number} value The thumb label's value to format.
|
||||
* @param {number} index The thumb label's index to format.
|
||||
* @returns {string}
|
||||
*/
|
||||
getAriaValueText: PropTypes.func,
|
||||
/**
|
||||
* If `true` the Slider will be rendered right-to-left (with the lowest value on the right-hand side).
|
||||
* @default false
|
||||
*/
|
||||
isRtl: PropTypes.bool,
|
||||
/**
|
||||
* Marks indicate predetermined values to which the user can move the slider.
|
||||
* If `true` the marks are spaced according the value of the `step` prop.
|
||||
* If an array, it should contain objects with `value` and an optional `label` keys.
|
||||
* @default false
|
||||
*/
|
||||
marks: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.shape({
|
||||
label: PropTypes.node,
|
||||
value: PropTypes.number.isRequired
|
||||
})), PropTypes.bool]),
|
||||
/**
|
||||
* The maximum allowed value of the slider.
|
||||
* Should not be equal to min.
|
||||
* @default 100
|
||||
*/
|
||||
max: PropTypes.number,
|
||||
/**
|
||||
* The minimum allowed value of the slider.
|
||||
* Should not be equal to max.
|
||||
* @default 0
|
||||
*/
|
||||
min: PropTypes.number,
|
||||
/**
|
||||
* Name attribute of the hidden `input` element.
|
||||
*/
|
||||
name: PropTypes.string,
|
||||
/**
|
||||
* Callback function that is fired when the slider's value changed.
|
||||
*
|
||||
* @param {Event} event The event source of the callback.
|
||||
* You can pull out the new value by accessing `event.target.value` (any).
|
||||
* **Warning**: This is a generic event not a change event.
|
||||
* @param {number | number[]} value The new value.
|
||||
* @param {number} activeThumb Index of the currently moved thumb.
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* Callback function that is fired when the `mouseup` is triggered.
|
||||
*
|
||||
* @param {React.SyntheticEvent | Event} event The event source of the callback. **Warning**: This is a generic event not a change event.
|
||||
* @param {number | number[]} value The new value.
|
||||
*/
|
||||
onChangeCommitted: PropTypes.func,
|
||||
/**
|
||||
* The component orientation.
|
||||
* @default 'horizontal'
|
||||
*/
|
||||
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
||||
/**
|
||||
* A transformation function, to change the scale of the slider.
|
||||
* @param {any} x
|
||||
* @returns {any}
|
||||
* @default function Identity(x) {
|
||||
* return x;
|
||||
* }
|
||||
*/
|
||||
scale: PropTypes.func,
|
||||
/**
|
||||
* The granularity with which the slider can step through values when using Page Up/Page Down or Shift + Arrow Up/Arrow Down.
|
||||
* @default 10
|
||||
*/
|
||||
shiftStep: PropTypes.number,
|
||||
/**
|
||||
* The props used for each slot inside the Slider.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
mark: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
markLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
rail: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
thumb: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
track: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
valueLabel: PropTypes.oneOfType([PropTypes.any, PropTypes.func])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Slider.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
input: PropTypes.elementType,
|
||||
mark: PropTypes.elementType,
|
||||
markLabel: PropTypes.elementType,
|
||||
rail: PropTypes.elementType,
|
||||
root: PropTypes.elementType,
|
||||
thumb: PropTypes.elementType,
|
||||
track: PropTypes.elementType,
|
||||
valueLabel: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The granularity with which the slider can step through values. (A "discrete" slider.)
|
||||
* The `min` prop serves as the origin for the valid values.
|
||||
* We recommend (max - min) to be evenly divisible by the step.
|
||||
*
|
||||
* When step is `null`, the thumb can only be slid onto marks provided with the `marks` prop.
|
||||
* @default 1
|
||||
*/
|
||||
step: PropTypes.number,
|
||||
/**
|
||||
* Tab index attribute of the hidden `input` element.
|
||||
*/
|
||||
tabIndex: PropTypes.number,
|
||||
/**
|
||||
* The track presentation:
|
||||
*
|
||||
* - `normal` the track will render a bar representing the slider value.
|
||||
* - `inverted` the track will render a bar representing the remaining slider value.
|
||||
* - `false` the track will render without a bar.
|
||||
* @default 'normal'
|
||||
*/
|
||||
track: PropTypes.oneOf(['inverted', 'normal', false]),
|
||||
/**
|
||||
* The value of the slider.
|
||||
* For ranged sliders, provide an array with two values.
|
||||
*/
|
||||
value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]),
|
||||
/**
|
||||
* The format function the value label's value.
|
||||
*
|
||||
* When a function is provided, it should have the following signature:
|
||||
*
|
||||
* - {number} value The value label's value to format
|
||||
* - {number} index The value label's index to format
|
||||
* @param {any} x
|
||||
* @returns {any}
|
||||
* @default function Identity(x) {
|
||||
* return x;
|
||||
* }
|
||||
*/
|
||||
valueLabelFormat: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
|
||||
} : void 0;
|
||||
export { Slider };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { Slider } from './Slider';
|
||||
export * from './Slider.types';
|
||||
export * from './sliderClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
var COMPONENT_NAME = 'Slider';
|
||||
export function getSliderUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var sliderClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'active', 'focusVisible', 'disabled', 'dragging', 'marked', 'vertical', 'trackInverted', 'trackFalse', 'rail', 'track', 'mark', 'markActive', 'markLabel', 'markLabelActive', 'thumb']);
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { ClickAwayListener } from '../ClickAwayListener';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getSnackbarUtilityClass } from './snackbarClasses';
|
||||
import { useSnackbar } from '../useSnackbar';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
var useUtilityClasses = function useUtilityClasses() {
|
||||
var slots = {
|
||||
root: ['root']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getSnackbarUtilityClass));
|
||||
};
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Snackbar](https://mui.com/base-ui/react-snackbar/)
|
||||
* - [Snackbar](https://mui.com/joy-ui/react-snackbar/)
|
||||
* - [Snackbar](https://mui.com/material-ui/react-snackbar/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Snackbar API](https://mui.com/base-ui/react-snackbar/components-api/#snackbar)
|
||||
*/
|
||||
var Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(props, forwardedRef) {
|
||||
var _props$autoHideDurati = props.autoHideDuration,
|
||||
autoHideDuration = _props$autoHideDurati === void 0 ? null : _props$autoHideDurati,
|
||||
children = props.children,
|
||||
_props$disableWindowB = props.disableWindowBlurListener,
|
||||
disableWindowBlurListener = _props$disableWindowB === void 0 ? false : _props$disableWindowB,
|
||||
_props$exited = props.exited,
|
||||
exited = _props$exited === void 0 ? true : _props$exited,
|
||||
onBlur = props.onBlur,
|
||||
onClose = props.onClose,
|
||||
onFocus = props.onFocus,
|
||||
onMouseEnter = props.onMouseEnter,
|
||||
onMouseLeave = props.onMouseLeave,
|
||||
open = props.open,
|
||||
resumeHideDuration = props.resumeHideDuration,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["autoHideDuration", "children", "disableWindowBlurListener", "exited", "onBlur", "onClose", "onFocus", "onMouseEnter", "onMouseLeave", "open", "resumeHideDuration", "slotProps", "slots"]);
|
||||
var classes = useUtilityClasses();
|
||||
var _useSnackbar = useSnackbar(_extends({}, props, {
|
||||
autoHideDuration: autoHideDuration,
|
||||
disableWindowBlurListener: disableWindowBlurListener,
|
||||
onClose: onClose,
|
||||
open: open,
|
||||
resumeHideDuration: resumeHideDuration
|
||||
})),
|
||||
getRootProps = _useSnackbar.getRootProps,
|
||||
onClickAway = _useSnackbar.onClickAway;
|
||||
var ownerState = props;
|
||||
var Root = slots.root || 'div';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
getSlotProps: getRootProps,
|
||||
externalForwardedProps: other,
|
||||
externalSlotProps: slotProps.root,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
var clickAwayListenerProps = useSlotProps({
|
||||
elementType: ClickAwayListener,
|
||||
externalSlotProps: slotProps.clickAwayListener,
|
||||
additionalProps: {
|
||||
onClickAway: onClickAway
|
||||
},
|
||||
ownerState: ownerState
|
||||
});
|
||||
|
||||
// ClickAwayListener doesn't support ownerState
|
||||
delete clickAwayListenerProps.ownerState;
|
||||
|
||||
// So that we only render active snackbars.
|
||||
if (!open && exited) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/_jsx(ClickAwayListener, _extends({}, clickAwayListenerProps, {
|
||||
children: /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
|
||||
children: children
|
||||
}))
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Snackbar.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The number of milliseconds to wait before automatically calling the
|
||||
* `onClose` function. `onClose` should then set the state of the `open`
|
||||
* prop to hide the Snackbar. This behavior is disabled by default with
|
||||
* the `null` value.
|
||||
* @default null
|
||||
*/
|
||||
autoHideDuration: PropTypes.number,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* If `true`, the `autoHideDuration` timer will expire even if the window is not focused.
|
||||
* @default false
|
||||
*/
|
||||
disableWindowBlurListener: PropTypes.bool,
|
||||
/**
|
||||
* The prop used to handle exited transition and unmount the component.
|
||||
* @default true
|
||||
*/
|
||||
exited: PropTypes.bool,
|
||||
/**
|
||||
* Callback fired when the component requests to be closed.
|
||||
* Typically `onClose` is used to set state in the parent component,
|
||||
* which is used to control the `Snackbar` `open` prop.
|
||||
* The `reason` parameter can optionally be used to control the response to `onClose`,
|
||||
* for example ignoring `clickaway`.
|
||||
*
|
||||
* @param {React.SyntheticEvent<any> | Event} event The event source of the callback.
|
||||
* @param {string} reason Can be: `"timeout"` (`autoHideDuration` expired), `"clickaway"`, or `"escapeKeyDown"`.
|
||||
*/
|
||||
onClose: PropTypes.func,
|
||||
/**
|
||||
* If `true`, the component is shown.
|
||||
*/
|
||||
open: PropTypes.bool,
|
||||
/**
|
||||
* The number of milliseconds to wait before dismissing after user interaction.
|
||||
* If `autoHideDuration` prop isn't specified, it does nothing.
|
||||
* If `autoHideDuration` prop is specified but `resumeHideDuration` isn't,
|
||||
* we default to `autoHideDuration / 2` ms.
|
||||
*/
|
||||
resumeHideDuration: PropTypes.number,
|
||||
/**
|
||||
* The props used for each slot inside the Snackbar.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
clickAwayListener: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
||||
children: PropTypes.element.isRequired,
|
||||
disableReactTree: PropTypes.bool,
|
||||
mouseEvent: PropTypes.oneOf(['onClick', 'onMouseDown', 'onMouseUp', 'onPointerDown', 'onPointerUp', false]),
|
||||
onClickAway: PropTypes.func,
|
||||
touchEvent: PropTypes.oneOf(['onTouchEnd', 'onTouchStart', false])
|
||||
})]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Snackbar.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
})
|
||||
} : void 0;
|
||||
export { Snackbar };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { Snackbar } from './Snackbar';
|
||||
export * from './Snackbar.types';
|
||||
export * from './snackbarClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'Snackbar';
|
||||
export function getSnackbarUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var snackbarClasses = generateUtilityClasses(COMPONENT_NAME, ['root']);
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { useSwitch } from '../useSwitch';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { getSwitchUtilityClass } from './switchClasses';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
||||
var checked = ownerState.checked,
|
||||
disabled = ownerState.disabled,
|
||||
focusVisible = ownerState.focusVisible,
|
||||
readOnly = ownerState.readOnly;
|
||||
var slots = {
|
||||
root: ['root', checked && 'checked', disabled && 'disabled', focusVisible && 'focusVisible', readOnly && 'readOnly'],
|
||||
thumb: ['thumb'],
|
||||
input: ['input'],
|
||||
track: ['track']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getSwitchUtilityClass));
|
||||
};
|
||||
|
||||
/**
|
||||
* The foundation for building custom-styled switches.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Switch](https://mui.com/base-ui/react-switch/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Switch API](https://mui.com/base-ui/react-switch/components-api/#switch)
|
||||
*/
|
||||
var Switch = /*#__PURE__*/React.forwardRef(function Switch(props, forwardedRef) {
|
||||
var _slots$root, _slots$thumb, _slots$input, _slots$track;
|
||||
var checkedProp = props.checked,
|
||||
defaultChecked = props.defaultChecked,
|
||||
disabledProp = props.disabled,
|
||||
onBlur = props.onBlur,
|
||||
onChange = props.onChange,
|
||||
onFocus = props.onFocus,
|
||||
onFocusVisible = props.onFocusVisible,
|
||||
readOnlyProp = props.readOnly,
|
||||
required = props.required,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["checked", "defaultChecked", "disabled", "onBlur", "onChange", "onFocus", "onFocusVisible", "readOnly", "required", "slotProps", "slots"]);
|
||||
var _useSwitch = useSwitch(props),
|
||||
getInputProps = _useSwitch.getInputProps,
|
||||
checked = _useSwitch.checked,
|
||||
disabled = _useSwitch.disabled,
|
||||
focusVisible = _useSwitch.focusVisible,
|
||||
readOnly = _useSwitch.readOnly;
|
||||
var ownerState = _extends({}, props, {
|
||||
checked: checked,
|
||||
disabled: disabled,
|
||||
focusVisible: focusVisible,
|
||||
readOnly: readOnly
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'span';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
var Thumb = (_slots$thumb = slots.thumb) != null ? _slots$thumb : 'span';
|
||||
var thumbProps = useSlotProps({
|
||||
elementType: Thumb,
|
||||
externalSlotProps: slotProps.thumb,
|
||||
ownerState: ownerState,
|
||||
className: classes.thumb
|
||||
});
|
||||
var Input = (_slots$input = slots.input) != null ? _slots$input : 'input';
|
||||
var inputProps = useSlotProps({
|
||||
elementType: Input,
|
||||
getSlotProps: getInputProps,
|
||||
externalSlotProps: slotProps.input,
|
||||
ownerState: ownerState,
|
||||
className: classes.input
|
||||
});
|
||||
var Track = slots.track === null ? function () {
|
||||
return null;
|
||||
} : (_slots$track = slots.track) != null ? _slots$track : 'span';
|
||||
var trackProps = useSlotProps({
|
||||
elementType: Track,
|
||||
externalSlotProps: slotProps.track,
|
||||
ownerState: ownerState,
|
||||
className: classes.track
|
||||
});
|
||||
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
|
||||
children: [/*#__PURE__*/_jsx(Track, _extends({}, trackProps)), /*#__PURE__*/_jsx(Thumb, _extends({}, thumbProps)), /*#__PURE__*/_jsx(Input, _extends({}, inputProps))]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Switch.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* If `true`, the component is checked.
|
||||
*/
|
||||
checked: PropTypes.bool,
|
||||
/**
|
||||
* Class name applied to the root element.
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The default checked state. Use when the component is not controlled.
|
||||
*/
|
||||
defaultChecked: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onBlur: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the state is changed.
|
||||
*
|
||||
* @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
|
||||
* You can pull out the new value by accessing `event.target.value` (string).
|
||||
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onFocus: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onFocusVisible: PropTypes.func,
|
||||
/**
|
||||
* If `true`, the component is read only.
|
||||
*/
|
||||
readOnly: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the `input` element is required.
|
||||
*/
|
||||
required: PropTypes.bool,
|
||||
/**
|
||||
* The props used for each slot inside the Switch.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
thumb: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
track: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Switch.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes /* @typescript-to-proptypes-ignore */.shape({
|
||||
input: PropTypes.elementType,
|
||||
root: PropTypes.elementType,
|
||||
thumb: PropTypes.elementType,
|
||||
track: PropTypes.oneOfType([PropTypes.elementType, PropTypes.oneOf([null])])
|
||||
})
|
||||
} : void 0;
|
||||
export { Switch };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { Switch } from './Switch';
|
||||
export * from './Switch.types';
|
||||
export * from './switchClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'Switch';
|
||||
export function getSwitchUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var switchClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'input', 'track', 'thumb', 'checked', 'disabled', 'focusVisible', 'readOnly']);
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getTabUtilityClass } from './tabClasses';
|
||||
import { useTab } from '../useTab';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
||||
var selected = ownerState.selected,
|
||||
disabled = ownerState.disabled;
|
||||
var slots = {
|
||||
root: ['root', selected && 'selected', disabled && 'disabled']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getTabUtilityClass));
|
||||
};
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Tabs](https://mui.com/base-ui/react-tabs/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Tab API](https://mui.com/base-ui/react-tabs/components-api/#tab)
|
||||
*/
|
||||
var Tab = /*#__PURE__*/React.forwardRef(function Tab(props, forwardedRef) {
|
||||
var _slots$root;
|
||||
var action = props.action,
|
||||
children = props.children,
|
||||
_props$disabled = props.disabled,
|
||||
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
||||
onChange = props.onChange,
|
||||
onClick = props.onClick,
|
||||
onFocus = props.onFocus,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
value = props.value,
|
||||
other = _objectWithoutProperties(props, ["action", "children", "disabled", "onChange", "onClick", "onFocus", "slotProps", "slots", "value"]);
|
||||
var tabRef = React.useRef();
|
||||
var handleRef = useForkRef(tabRef, forwardedRef);
|
||||
var _useTab = useTab(_extends({}, props, {
|
||||
rootRef: handleRef,
|
||||
value: value
|
||||
})),
|
||||
active = _useTab.active,
|
||||
highlighted = _useTab.highlighted,
|
||||
selected = _useTab.selected,
|
||||
getRootProps = _useTab.getRootProps;
|
||||
var ownerState = _extends({}, props, {
|
||||
active: active,
|
||||
disabled: disabled,
|
||||
highlighted: highlighted,
|
||||
selected: selected
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var TabRoot = (_slots$root = slots.root) != null ? _slots$root : 'button';
|
||||
var tabRootProps = useSlotProps({
|
||||
elementType: TabRoot,
|
||||
getSlotProps: getRootProps,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
return /*#__PURE__*/_jsx(TabRoot, _extends({}, tabRootProps, {
|
||||
children: children
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Tab.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* A ref for imperative actions. It currently only supports `focusVisible()` action.
|
||||
*/
|
||||
action: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
||||
current: PropTypes.shape({
|
||||
focusVisible: PropTypes.func.isRequired
|
||||
})
|
||||
})]),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* Callback invoked when new value is being set.
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* The props used for each slot inside the Tab.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Tab.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* You can provide your own value. Otherwise, it falls back to the child position index.
|
||||
*/
|
||||
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
||||
} : void 0;
|
||||
export { Tab };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { Tab } from './Tab';
|
||||
export * from './Tab.types';
|
||||
export * from './tabClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'Tab';
|
||||
export function getTabUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var tabClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'selected', 'disabled']);
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getTabPanelUtilityClass } from './tabPanelClasses';
|
||||
import { useTabPanel } from '../useTabPanel/useTabPanel';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
||||
var hidden = ownerState.hidden;
|
||||
var slots = {
|
||||
root: ['root', hidden && 'hidden']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getTabPanelUtilityClass));
|
||||
};
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Tabs](https://mui.com/base-ui/react-tabs/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [TabPanel API](https://mui.com/base-ui/react-tabs/components-api/#tab-panel)
|
||||
*/
|
||||
var TabPanel = /*#__PURE__*/React.forwardRef(function TabPanel(props, forwardedRef) {
|
||||
var _slots$root;
|
||||
var children = props.children,
|
||||
value = props.value,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["children", "value", "slotProps", "slots"]);
|
||||
var _useTabPanel = useTabPanel(props),
|
||||
hidden = _useTabPanel.hidden,
|
||||
getRootProps = _useTabPanel.getRootProps;
|
||||
var ownerState = _extends({}, props, {
|
||||
hidden: hidden
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var TabPanelRoot = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
||||
var tabPanelRootProps = useSlotProps({
|
||||
elementType: TabPanelRoot,
|
||||
getSlotProps: getRootProps,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
role: 'tabpanel',
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
return /*#__PURE__*/_jsx(TabPanelRoot, _extends({}, tabPanelRootProps, {
|
||||
children: !hidden && children
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? TabPanel.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 content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The props used for each slot inside the TabPanel.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the TabPanel.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The value of the TabPanel. It will be shown when the Tab with the corresponding value is selected.
|
||||
* If not provided, it will fall back to the index of the panel.
|
||||
* It is recommended to explicitly provide it, as it's required for the tab panel to be rendered on the server.
|
||||
*/
|
||||
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
||||
} : void 0;
|
||||
export { TabPanel };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { TabPanel } from './TabPanel';
|
||||
export * from './TabPanel.types';
|
||||
export * from './tabPanelClasses';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'TabPanel';
|
||||
export function getTabPanelUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var tabPanelClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'hidden']);
|
||||
+322
@@ -0,0 +1,322 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_useId as useId, chainPropTypes, integerPropType } from '@mui/utils';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { isHostComponent } from '../utils/isHostComponent';
|
||||
import { TablePaginationActions } from './TablePaginationActions';
|
||||
import { getTablePaginationUtilityClass } from './tablePaginationClasses';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { createElement as _createElement } from "react";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
function defaultLabelDisplayedRows(_ref) {
|
||||
var from = _ref.from,
|
||||
to = _ref.to,
|
||||
count = _ref.count;
|
||||
return "".concat(from, "\u2013").concat(to, " of ").concat(count !== -1 ? count : "more than ".concat(to));
|
||||
}
|
||||
function defaultGetAriaLabel(type) {
|
||||
return "Go to ".concat(type, " page");
|
||||
}
|
||||
var useUtilityClasses = function useUtilityClasses() {
|
||||
var slots = {
|
||||
root: ['root'],
|
||||
toolbar: ['toolbar'],
|
||||
spacer: ['spacer'],
|
||||
selectLabel: ['selectLabel'],
|
||||
select: ['select'],
|
||||
input: ['input'],
|
||||
selectIcon: ['selectIcon'],
|
||||
menuItem: ['menuItem'],
|
||||
displayedRows: ['displayedRows'],
|
||||
actions: ['actions']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getTablePaginationUtilityClass));
|
||||
};
|
||||
|
||||
/**
|
||||
* A pagination for tables.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Table Pagination](https://mui.com/base-ui/react-table-pagination/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [TablePagination API](https://mui.com/base-ui/react-table-pagination/components-api/#table-pagination)
|
||||
*/
|
||||
var TablePagination = /*#__PURE__*/React.forwardRef(function TablePagination(props, forwardedRef) {
|
||||
var _slots$root, _slots$select, _slots$actions, _slots$menuItem, _slots$selectLabel, _slots$displayedRows, _slots$toolbar, _slots$spacer;
|
||||
var colSpanProp = props.colSpan,
|
||||
count = props.count,
|
||||
_props$getItemAriaLab = props.getItemAriaLabel,
|
||||
getItemAriaLabel = _props$getItemAriaLab === void 0 ? defaultGetAriaLabel : _props$getItemAriaLab,
|
||||
_props$labelDisplayed = props.labelDisplayedRows,
|
||||
labelDisplayedRows = _props$labelDisplayed === void 0 ? defaultLabelDisplayedRows : _props$labelDisplayed,
|
||||
labelIdProp = props.labelId,
|
||||
_props$labelRowsPerPa = props.labelRowsPerPage,
|
||||
labelRowsPerPage = _props$labelRowsPerPa === void 0 ? 'Rows per page:' : _props$labelRowsPerPa,
|
||||
onPageChange = props.onPageChange,
|
||||
onRowsPerPageChange = props.onRowsPerPageChange,
|
||||
page = props.page,
|
||||
rowsPerPage = props.rowsPerPage,
|
||||
_props$rowsPerPageOpt = props.rowsPerPageOptions,
|
||||
rowsPerPageOptions = _props$rowsPerPageOpt === void 0 ? [10, 25, 50, 100] : _props$rowsPerPageOpt,
|
||||
selectIdProp = props.selectId,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["colSpan", "count", "getItemAriaLabel", "labelDisplayedRows", "labelId", "labelRowsPerPage", "onPageChange", "onRowsPerPageChange", "page", "rowsPerPage", "rowsPerPageOptions", "selectId", "slotProps", "slots"]);
|
||||
var ownerState = props;
|
||||
var classes = useUtilityClasses();
|
||||
var colSpan;
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'td';
|
||||
if (Root === 'td' || !isHostComponent(Root)) {
|
||||
colSpan = colSpanProp || 1000; // col-span over everything
|
||||
}
|
||||
var getLabelDisplayedRowsTo = function getLabelDisplayedRowsTo() {
|
||||
if (count === -1) {
|
||||
return (page + 1) * rowsPerPage;
|
||||
}
|
||||
return rowsPerPage === -1 ? count : Math.min(count, (page + 1) * rowsPerPage);
|
||||
};
|
||||
var selectId = useId(selectIdProp);
|
||||
var labelId = useId(labelIdProp);
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
colSpan: colSpan,
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
var Select = (_slots$select = slots.select) != null ? _slots$select : 'select';
|
||||
var selectProps = useSlotProps({
|
||||
elementType: Select,
|
||||
externalSlotProps: slotProps.select,
|
||||
additionalProps: {
|
||||
value: rowsPerPage,
|
||||
id: selectId,
|
||||
onChange: function onChange(event) {
|
||||
return onRowsPerPageChange && onRowsPerPageChange(event);
|
||||
},
|
||||
'aria-label': rowsPerPage.toString(),
|
||||
'aria-labelledby': [labelId, selectId].filter(Boolean).join(' ') || undefined
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.select
|
||||
});
|
||||
var Actions = (_slots$actions = slots.actions) != null ? _slots$actions : TablePaginationActions;
|
||||
var actionsProps = useSlotProps({
|
||||
elementType: Actions,
|
||||
externalSlotProps: slotProps.actions,
|
||||
additionalProps: {
|
||||
page: page,
|
||||
rowsPerPage: rowsPerPage,
|
||||
count: count,
|
||||
onPageChange: onPageChange,
|
||||
getItemAriaLabel: getItemAriaLabel
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.actions
|
||||
});
|
||||
var MenuItem = (_slots$menuItem = slots.menuItem) != null ? _slots$menuItem : 'option';
|
||||
var menuItemProps = useSlotProps({
|
||||
elementType: MenuItem,
|
||||
externalSlotProps: slotProps.menuItem,
|
||||
additionalProps: {
|
||||
value: undefined
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.menuItem
|
||||
});
|
||||
var SelectLabel = (_slots$selectLabel = slots.selectLabel) != null ? _slots$selectLabel : 'p';
|
||||
var selectLabelProps = useSlotProps({
|
||||
elementType: SelectLabel,
|
||||
externalSlotProps: slotProps.selectLabel,
|
||||
additionalProps: {
|
||||
id: labelId
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.selectLabel
|
||||
});
|
||||
var DisplayedRows = (_slots$displayedRows = slots.displayedRows) != null ? _slots$displayedRows : 'p';
|
||||
var displayedRowsProps = useSlotProps({
|
||||
elementType: DisplayedRows,
|
||||
externalSlotProps: slotProps.displayedRows,
|
||||
ownerState: ownerState,
|
||||
className: classes.displayedRows
|
||||
});
|
||||
var Toolbar = (_slots$toolbar = slots.toolbar) != null ? _slots$toolbar : 'div';
|
||||
var toolbarProps = useSlotProps({
|
||||
elementType: Toolbar,
|
||||
externalSlotProps: slotProps.toolbar,
|
||||
ownerState: ownerState,
|
||||
className: classes.toolbar
|
||||
});
|
||||
var Spacer = (_slots$spacer = slots.spacer) != null ? _slots$spacer : 'div';
|
||||
var spacerProps = useSlotProps({
|
||||
elementType: Spacer,
|
||||
externalSlotProps: slotProps.spacer,
|
||||
ownerState: ownerState,
|
||||
className: classes.spacer
|
||||
});
|
||||
return /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
|
||||
children: /*#__PURE__*/_jsxs(Toolbar, _extends({}, toolbarProps, {
|
||||
children: [/*#__PURE__*/_jsx(Spacer, _extends({}, spacerProps)), rowsPerPageOptions.length > 1 && /*#__PURE__*/_jsx(SelectLabel, _extends({}, selectLabelProps, {
|
||||
children: labelRowsPerPage
|
||||
})), rowsPerPageOptions.length > 1 && /*#__PURE__*/_jsx(Select, _extends({}, selectProps, {
|
||||
children: rowsPerPageOptions.map(function (rowsPerPageOption) {
|
||||
return /*#__PURE__*/_createElement(MenuItem, _extends({}, menuItemProps, {
|
||||
key: typeof rowsPerPageOption !== 'number' && rowsPerPageOption.label ? rowsPerPageOption.label : rowsPerPageOption,
|
||||
value: typeof rowsPerPageOption !== 'number' && rowsPerPageOption.value ? rowsPerPageOption.value : rowsPerPageOption
|
||||
}), typeof rowsPerPageOption !== 'number' && rowsPerPageOption.label ? rowsPerPageOption.label : rowsPerPageOption);
|
||||
})
|
||||
})), /*#__PURE__*/_jsx(DisplayedRows, _extends({}, displayedRowsProps, {
|
||||
children: labelDisplayedRows({
|
||||
from: count === 0 ? 0 : page * rowsPerPage + 1,
|
||||
to: getLabelDisplayedRowsTo(),
|
||||
count: count === -1 ? -1 : count,
|
||||
page: page
|
||||
})
|
||||
})), /*#__PURE__*/_jsx(Actions, _extends({}, actionsProps))]
|
||||
}))
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? TablePagination.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
|
||||
*/
|
||||
colSpan: PropTypes.number,
|
||||
/**
|
||||
* The total number of rows.
|
||||
*
|
||||
* To enable server side pagination for an unknown number of items, provide -1.
|
||||
*/
|
||||
count: PropTypes.number.isRequired,
|
||||
/**
|
||||
* Accepts a function which returns a string value that provides a user-friendly name for the current page.
|
||||
* This is important for screen reader users.
|
||||
*
|
||||
* For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
|
||||
* @param {string} type The link or button type to format ('first' | 'last' | 'next' | 'previous').
|
||||
* @returns {string}
|
||||
* @default function defaultGetAriaLabel(type: ItemAriaLabelType) {
|
||||
* return `Go to ${type} page`;
|
||||
* }
|
||||
*/
|
||||
getItemAriaLabel: PropTypes.func,
|
||||
/**
|
||||
* Customize the displayed rows label. Invoked with a `{ from, to, count, page }`
|
||||
* object.
|
||||
*
|
||||
* For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
|
||||
* @default function defaultLabelDisplayedRows({ from, to, count }: LabelDisplayedRowsArgs) {
|
||||
* return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;
|
||||
* }
|
||||
*/
|
||||
labelDisplayedRows: PropTypes.func,
|
||||
/**
|
||||
* Id of the label element within the pagination.
|
||||
*/
|
||||
labelId: PropTypes.string,
|
||||
/**
|
||||
* Customize the rows per page label.
|
||||
*
|
||||
* For localization purposes, you can use the provided [translations](/material-ui/guides/localization/).
|
||||
* @default 'Rows per page:'
|
||||
*/
|
||||
labelRowsPerPage: PropTypes.node,
|
||||
/**
|
||||
* Callback fired when the page is changed.
|
||||
*
|
||||
* @param {React.MouseEvent<HTMLButtonElement> | null} event The event source of the callback.
|
||||
* @param {number} page The page selected.
|
||||
*/
|
||||
onPageChange: PropTypes.func.isRequired,
|
||||
/**
|
||||
* Callback fired when the number of rows per page is changed.
|
||||
*
|
||||
* @param {React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>} event The event source of the callback.
|
||||
*/
|
||||
onRowsPerPageChange: PropTypes.func,
|
||||
/**
|
||||
* The zero-based index of the current page.
|
||||
*/
|
||||
page: chainPropTypes(integerPropType.isRequired, function (props) {
|
||||
var count = props.count,
|
||||
page = props.page,
|
||||
rowsPerPage = props.rowsPerPage;
|
||||
if (count === -1) {
|
||||
return null;
|
||||
}
|
||||
var newLastPage = Math.max(0, Math.ceil(count / rowsPerPage) - 1);
|
||||
if (page < 0 || page > newLastPage) {
|
||||
return new Error('MUI: The page prop of a TablePagination is out of range ' + "(0 to ".concat(newLastPage, ", but page is ").concat(page, ")."));
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
/**
|
||||
* The number of rows per page.
|
||||
*
|
||||
* Set -1 to display all the rows.
|
||||
*/
|
||||
rowsPerPage: integerPropType.isRequired,
|
||||
/**
|
||||
* Customizes the options of the rows per page select field. If less than two options are
|
||||
* available, no select field will be displayed.
|
||||
* Use -1 for the value with a custom label to show all the rows.
|
||||
* @default [10, 25, 50, 100]
|
||||
*/
|
||||
rowsPerPageOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
||||
label: PropTypes.string.isRequired,
|
||||
value: PropTypes.number.isRequired
|
||||
})]).isRequired),
|
||||
/**
|
||||
* Id of the select element within the pagination.
|
||||
*/
|
||||
selectId: PropTypes.string,
|
||||
/**
|
||||
* The props used for each slot inside the TablePagination.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes /* @typescript-to-proptypes-ignore */.shape({
|
||||
actions: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
displayedRows: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
menuItem: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
select: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
selectLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
spacer: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
toolbar: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the TablePagination.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
actions: PropTypes.elementType,
|
||||
displayedRows: PropTypes.elementType,
|
||||
menuItem: PropTypes.elementType,
|
||||
root: PropTypes.elementType,
|
||||
select: PropTypes.elementType,
|
||||
selectLabel: PropTypes.elementType,
|
||||
spacer: PropTypes.elementType,
|
||||
toolbar: PropTypes.elementType
|
||||
})
|
||||
} : void 0;
|
||||
export { TablePagination };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
var _span, _span2, _span3, _span4;
|
||||
import * as React from 'react';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
function LastPageIconDefault() {
|
||||
return _span || (_span = /*#__PURE__*/_jsx("span", {
|
||||
children: '⇾|'
|
||||
}));
|
||||
}
|
||||
function FirstPageIconDefault() {
|
||||
return _span2 || (_span2 = /*#__PURE__*/_jsx("span", {
|
||||
children: '|⇽'
|
||||
}));
|
||||
}
|
||||
function NextPageIconDefault() {
|
||||
return _span3 || (_span3 = /*#__PURE__*/_jsx("span", {
|
||||
children: '⇾'
|
||||
}));
|
||||
}
|
||||
function BackPageIconDefault() {
|
||||
return _span4 || (_span4 = /*#__PURE__*/_jsx("span", {
|
||||
children: '⇽'
|
||||
}));
|
||||
}
|
||||
function defaultGetAriaLabel(type) {
|
||||
return "Go to ".concat(type, " page");
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
var TablePaginationActions = /*#__PURE__*/React.forwardRef(function TablePaginationActions(props, forwardedRef) {
|
||||
var _slots$root, _slots$firstButton, _slots$lastButton, _slots$nextButton, _slots$backButton, _slots$lastPageIcon, _slots$firstPageIcon, _slots$nextPageIcon, _slots$backPageIcon;
|
||||
var count = props.count,
|
||||
_props$getItemAriaLab = props.getItemAriaLabel,
|
||||
getItemAriaLabel = _props$getItemAriaLab === void 0 ? defaultGetAriaLabel : _props$getItemAriaLab,
|
||||
onPageChange = props.onPageChange,
|
||||
page = props.page,
|
||||
rowsPerPage = props.rowsPerPage,
|
||||
_props$showFirstButto = props.showFirstButton,
|
||||
showFirstButton = _props$showFirstButto === void 0 ? false : _props$showFirstButto,
|
||||
_props$showLastButton = props.showLastButton,
|
||||
showLastButton = _props$showLastButton === void 0 ? false : _props$showLastButton,
|
||||
direction = props.direction,
|
||||
ownerStateProp = props.ownerState,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["count", "getItemAriaLabel", "onPageChange", "page", "rowsPerPage", "showFirstButton", "showLastButton", "direction", "ownerState", "slotProps", "slots"]);
|
||||
var ownerState = props;
|
||||
var handleFirstPageButtonClick = function handleFirstPageButtonClick(event) {
|
||||
onPageChange(event, 0);
|
||||
};
|
||||
var handleBackButtonClick = function handleBackButtonClick(event) {
|
||||
onPageChange(event, page - 1);
|
||||
};
|
||||
var handleNextButtonClick = function handleNextButtonClick(event) {
|
||||
onPageChange(event, page + 1);
|
||||
};
|
||||
var handleLastPageButtonClick = function handleLastPageButtonClick(event) {
|
||||
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
|
||||
};
|
||||
var Root = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
||||
var rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: ownerState
|
||||
});
|
||||
var FirstButton = (_slots$firstButton = slots.firstButton) != null ? _slots$firstButton : 'button';
|
||||
var firstButtonProps = useSlotProps({
|
||||
elementType: FirstButton,
|
||||
externalSlotProps: slotProps.firstButton,
|
||||
additionalProps: {
|
||||
onClick: handleFirstPageButtonClick,
|
||||
disabled: page === 0,
|
||||
'aria-label': getItemAriaLabel('first', page),
|
||||
title: getItemAriaLabel('first', page)
|
||||
},
|
||||
ownerState: ownerState
|
||||
});
|
||||
var LastButton = (_slots$lastButton = slots.lastButton) != null ? _slots$lastButton : 'button';
|
||||
var lastButtonProps = useSlotProps({
|
||||
elementType: LastButton,
|
||||
externalSlotProps: slotProps.lastButton,
|
||||
additionalProps: {
|
||||
onClick: handleLastPageButtonClick,
|
||||
disabled: page >= Math.ceil(count / rowsPerPage) - 1,
|
||||
'aria-label': getItemAriaLabel('last', page),
|
||||
title: getItemAriaLabel('last', page)
|
||||
},
|
||||
ownerState: ownerState
|
||||
});
|
||||
var NextButton = (_slots$nextButton = slots.nextButton) != null ? _slots$nextButton : 'button';
|
||||
var nextButtonProps = useSlotProps({
|
||||
elementType: NextButton,
|
||||
externalSlotProps: slotProps.nextButton,
|
||||
additionalProps: {
|
||||
onClick: handleNextButtonClick,
|
||||
disabled: count !== -1 ? page >= Math.ceil(count / rowsPerPage) - 1 : false,
|
||||
'aria-label': getItemAriaLabel('next', page),
|
||||
title: getItemAriaLabel('next', page)
|
||||
},
|
||||
ownerState: ownerState
|
||||
});
|
||||
var BackButton = (_slots$backButton = slots.backButton) != null ? _slots$backButton : 'button';
|
||||
var backButtonProps = useSlotProps({
|
||||
elementType: BackButton,
|
||||
externalSlotProps: slotProps.backButton,
|
||||
additionalProps: {
|
||||
onClick: handleBackButtonClick,
|
||||
disabled: page === 0,
|
||||
'aria-label': getItemAriaLabel('previous', page),
|
||||
title: getItemAriaLabel('previous', page)
|
||||
},
|
||||
ownerState: ownerState
|
||||
});
|
||||
var LastPageIcon = (_slots$lastPageIcon = slots.lastPageIcon) != null ? _slots$lastPageIcon : LastPageIconDefault;
|
||||
var FirstPageIcon = (_slots$firstPageIcon = slots.firstPageIcon) != null ? _slots$firstPageIcon : FirstPageIconDefault;
|
||||
var NextPageIcon = (_slots$nextPageIcon = slots.nextPageIcon) != null ? _slots$nextPageIcon : NextPageIconDefault;
|
||||
var BackPageIcon = (_slots$backPageIcon = slots.backPageIcon) != null ? _slots$backPageIcon : BackPageIconDefault;
|
||||
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
|
||||
children: [showFirstButton && /*#__PURE__*/_jsx(FirstButton, _extends({}, firstButtonProps, {
|
||||
children: direction === 'rtl' ? /*#__PURE__*/_jsx(LastPageIcon, {}) : /*#__PURE__*/_jsx(FirstPageIcon, {})
|
||||
})), /*#__PURE__*/_jsx(BackButton, _extends({}, backButtonProps, {
|
||||
children: direction === 'rtl' ? /*#__PURE__*/_jsx(NextPageIcon, {}) : /*#__PURE__*/_jsx(BackPageIcon, {})
|
||||
})), /*#__PURE__*/_jsx(NextButton, _extends({}, nextButtonProps, {
|
||||
children: direction === 'rtl' ? /*#__PURE__*/_jsx(BackPageIcon, {}) : /*#__PURE__*/_jsx(NextPageIcon, {})
|
||||
})), showLastButton && /*#__PURE__*/_jsx(LastButton, _extends({}, lastButtonProps, {
|
||||
children: direction === 'rtl' ? /*#__PURE__*/_jsx(FirstPageIcon, {}) : /*#__PURE__*/_jsx(LastPageIcon, {})
|
||||
}))]
|
||||
}));
|
||||
});
|
||||
export { TablePaginationActions };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
'use client';
|
||||
|
||||
export { TablePagination } from './TablePagination';
|
||||
export * from './TablePagination.types';
|
||||
export { TablePaginationActions } from './TablePaginationActions';
|
||||
export * from './TablePaginationActions.types';
|
||||
export * from './tablePaginationClasses';
|
||||
export * from './common.types';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'TablePagination';
|
||||
export function getTablePaginationUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var tablePaginationClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'toolbar', 'spacer', 'selectLabel', 'selectRoot', 'select', 'selectIcon', 'input', 'menuItem', 'displayedRows', 'actions']);
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getTabsUtilityClass } from './tabsClasses';
|
||||
import { useTabs } from '../useTabs';
|
||||
import { TabsProvider } from '../useTabs/TabsProvider';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
||||
var orientation = ownerState.orientation;
|
||||
var slots = {
|
||||
root: ['root', orientation]
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getTabsUtilityClass));
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Tabs](https://mui.com/base-ui/react-tabs/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Tabs API](https://mui.com/base-ui/react-tabs/components-api/#tabs)
|
||||
*/
|
||||
var Tabs = /*#__PURE__*/React.forwardRef(function Tabs(props, forwardedRef) {
|
||||
var _slots$root;
|
||||
var children = props.children,
|
||||
valueProp = props.value,
|
||||
defaultValue = props.defaultValue,
|
||||
_props$orientation = props.orientation,
|
||||
orientation = _props$orientation === void 0 ? 'horizontal' : _props$orientation,
|
||||
_props$direction = props.direction,
|
||||
direction = _props$direction === void 0 ? 'ltr' : _props$direction,
|
||||
onChange = props.onChange,
|
||||
selectionFollowsFocus = props.selectionFollowsFocus,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["children", "value", "defaultValue", "orientation", "direction", "onChange", "selectionFollowsFocus", "slotProps", "slots"]);
|
||||
var ownerState = _extends({}, props, {
|
||||
orientation: orientation,
|
||||
direction: direction
|
||||
});
|
||||
var _useTabs = useTabs(ownerState),
|
||||
contextValue = _useTabs.contextValue;
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var TabsRoot = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
||||
var tabsRootProps = useSlotProps({
|
||||
elementType: TabsRoot,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
return /*#__PURE__*/_jsx(TabsRoot, _extends({}, tabsRootProps, {
|
||||
children: /*#__PURE__*/_jsx(TabsProvider, {
|
||||
value: contextValue,
|
||||
children: children
|
||||
})
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Tabs.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 content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The default value. Use when the component is not controlled.
|
||||
*/
|
||||
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* The direction of the text.
|
||||
* @default 'ltr'
|
||||
*/
|
||||
direction: PropTypes.oneOf(['ltr', 'rtl']),
|
||||
/**
|
||||
* Callback invoked when new value is being set.
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* The component orientation (layout flow direction).
|
||||
* @default 'horizontal'
|
||||
*/
|
||||
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
||||
/**
|
||||
* If `true` the selected tab changes on focus. Otherwise it only
|
||||
* changes on activation.
|
||||
*/
|
||||
selectionFollowsFocus: PropTypes.bool,
|
||||
/**
|
||||
* The props used for each slot inside the Tabs.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Tabs.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The value of the currently selected `Tab`.
|
||||
* If you don't want any selected `Tab`, you can set this prop to `null`.
|
||||
*/
|
||||
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
||||
} : void 0;
|
||||
export { Tabs };
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import * as React from 'react';
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
var TabsContext = /*#__PURE__*/React.createContext(null);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
TabsContext.displayName = 'TabsContext';
|
||||
}
|
||||
export function useTabsContext() {
|
||||
var context = React.useContext(TabsContext);
|
||||
if (context == null) {
|
||||
throw new Error('No TabsContext provided');
|
||||
}
|
||||
return context;
|
||||
}
|
||||
export { TabsContext };
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
'use client';
|
||||
|
||||
export { Tabs } from './Tabs';
|
||||
export * from './TabsContext';
|
||||
export * from './tabsClasses';
|
||||
export * from './Tabs.types';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
var COMPONENT_NAME = 'Tabs';
|
||||
export function getTabsUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export var tabsClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'horizontal', 'vertical']);
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { getTabsListUtilityClass } from './tabsListClasses';
|
||||
import { useTabsList } from '../useTabsList';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { TabsListProvider } from '../useTabsList/TabsListProvider';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
||||
var orientation = ownerState.orientation;
|
||||
var slots = {
|
||||
root: ['root', orientation]
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getTabsListUtilityClass));
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Tabs](https://mui.com/base-ui/react-tabs/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [TabsList API](https://mui.com/base-ui/react-tabs/components-api/#tabs-list)
|
||||
*/
|
||||
var TabsList = /*#__PURE__*/React.forwardRef(function TabsList(props, forwardedRef) {
|
||||
var _slots$root;
|
||||
var children = props.children,
|
||||
_props$slotProps = props.slotProps,
|
||||
slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
||||
_props$slots = props.slots,
|
||||
slots = _props$slots === void 0 ? {} : _props$slots,
|
||||
other = _objectWithoutProperties(props, ["children", "slotProps", "slots"]);
|
||||
var _useTabsList = useTabsList({
|
||||
rootRef: forwardedRef
|
||||
}),
|
||||
isRtl = _useTabsList.isRtl,
|
||||
orientation = _useTabsList.orientation,
|
||||
getRootProps = _useTabsList.getRootProps,
|
||||
contextValue = _useTabsList.contextValue;
|
||||
var ownerState = _extends({}, props, {
|
||||
isRtl: isRtl,
|
||||
orientation: orientation
|
||||
});
|
||||
var classes = useUtilityClasses(ownerState);
|
||||
var TabsListRoot = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
||||
var tabsListRootProps = useSlotProps({
|
||||
elementType: TabsListRoot,
|
||||
getSlotProps: getRootProps,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
ownerState: ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
return /*#__PURE__*/_jsx(TabsListProvider, {
|
||||
value: contextValue,
|
||||
children: /*#__PURE__*/_jsx(TabsListRoot, _extends({}, tabsListRootProps, {
|
||||
children: children
|
||||
}))
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? TabsList.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 content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The props used for each slot inside the TabsList.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the TabsList.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
})
|
||||
} : void 0;
|
||||
export { TabsList };
|
||||
Loaded 100 of 6977 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user