FrontPastel/node_modules/@mui/material/node/TabScrollButton/TabScrollButton.js

163 lines
7.2 KiB
JavaScript
Raw Normal View History

2024-04-17 13:55:11 +00:00
"use strict";
'use client';
/* eslint-disable jsx-a11y/aria-role */
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _clsx = _interopRequireDefault(require("clsx"));
var _utils = require("@mui/base/utils");
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
var _RtlProvider = require("@mui/system/RtlProvider");
var _KeyboardArrowLeft = _interopRequireDefault(require("../internal/svg-icons/KeyboardArrowLeft"));
var _KeyboardArrowRight = _interopRequireDefault(require("../internal/svg-icons/KeyboardArrowRight"));
var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
var _useThemeProps = _interopRequireDefault(require("../styles/useThemeProps"));
var _styled = _interopRequireDefault(require("../styles/styled"));
var _tabScrollButtonClasses = _interopRequireWildcard(require("./tabScrollButtonClasses"));
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["className", "slots", "slotProps", "direction", "orientation", "disabled"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const useUtilityClasses = ownerState => {
const {
classes,
orientation,
disabled
} = ownerState;
const slots = {
root: ['root', orientation, disabled && 'disabled']
};
return (0, _composeClasses.default)(slots, _tabScrollButtonClasses.getTabScrollButtonUtilityClass, classes);
};
const TabScrollButtonRoot = (0, _styled.default)(_ButtonBase.default, {
name: 'MuiTabScrollButton',
slot: 'Root',
overridesResolver: (props, styles) => {
const {
ownerState
} = props;
return [styles.root, ownerState.orientation && styles[ownerState.orientation]];
}
})(({
ownerState
}) => (0, _extends2.default)({
width: 40,
flexShrink: 0,
opacity: 0.8,
[`&.${_tabScrollButtonClasses.default.disabled}`]: {
opacity: 0
}
}, ownerState.orientation === 'vertical' && {
width: '100%',
height: 40,
'& svg': {
transform: `rotate(${ownerState.isRtl ? -90 : 90}deg)`
}
}));
const TabScrollButton = /*#__PURE__*/React.forwardRef(function TabScrollButton(inProps, ref) {
var _slots$StartScrollBut, _slots$EndScrollButto;
const props = (0, _useThemeProps.default)({
props: inProps,
name: 'MuiTabScrollButton'
});
const {
className,
slots = {},
slotProps = {},
direction
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const isRtl = (0, _RtlProvider.useRtl)();
const ownerState = (0, _extends2.default)({
isRtl
}, props);
const classes = useUtilityClasses(ownerState);
const StartButtonIcon = (_slots$StartScrollBut = slots.StartScrollButtonIcon) != null ? _slots$StartScrollBut : _KeyboardArrowLeft.default;
const EndButtonIcon = (_slots$EndScrollButto = slots.EndScrollButtonIcon) != null ? _slots$EndScrollButto : _KeyboardArrowRight.default;
const startButtonIconProps = (0, _utils.useSlotProps)({
elementType: StartButtonIcon,
externalSlotProps: slotProps.startScrollButtonIcon,
additionalProps: {
fontSize: 'small'
},
ownerState
});
const endButtonIconProps = (0, _utils.useSlotProps)({
elementType: EndButtonIcon,
externalSlotProps: slotProps.endScrollButtonIcon,
additionalProps: {
fontSize: 'small'
},
ownerState
});
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TabScrollButtonRoot, (0, _extends2.default)({
component: "div",
className: (0, _clsx.default)(classes.root, className),
ref: ref,
role: null,
ownerState: ownerState,
tabIndex: null
}, other, {
children: direction === 'left' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(StartButtonIcon, (0, _extends2.default)({}, startButtonIconProps)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(EndButtonIcon, (0, _extends2.default)({}, endButtonIconProps))
}));
});
process.env.NODE_ENV !== "production" ? TabScrollButton.propTypes /* remove-proptypes */ = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* The content of the component.
*/
children: _propTypes.default.node,
/**
* Override or extend the styles applied to the component.
*/
classes: _propTypes.default.object,
/**
* @ignore
*/
className: _propTypes.default.string,
/**
* The direction the button should indicate.
*/
direction: _propTypes.default.oneOf(['left', 'right']).isRequired,
/**
* If `true`, the component is disabled.
* @default false
*/
disabled: _propTypes.default.bool,
/**
* The component orientation (layout flow direction).
*/
orientation: _propTypes.default.oneOf(['horizontal', 'vertical']).isRequired,
/**
* The extra props for the slot components.
* You can override the existing props or add new ones.
* @default {}
*/
slotProps: _propTypes.default.shape({
endScrollButtonIcon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
startScrollButtonIcon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
}),
/**
* The components used for each slot inside.
* @default {}
*/
slots: _propTypes.default.shape({
EndScrollButtonIcon: _propTypes.default.elementType,
StartScrollButtonIcon: _propTypes.default.elementType
}),
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
} : void 0;
var _default = exports.default = TabScrollButton;