1 | 'use client';
|
2 |
|
3 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
4 | import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
5 | import _extends from "@babel/runtime/helpers/esm/extends";
|
6 | import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
7 | import * as React from 'react';
|
8 | import clsx from 'clsx';
|
9 | import PropTypes from 'prop-types';
|
10 | import composeClasses from '@mui/utils/composeClasses';
|
11 | import capitalize from '../utils/capitalize';
|
12 | import styled from '../styles/styled';
|
13 | import useTheme from '../styles/useTheme';
|
14 | import { getHiddenCssUtilityClass } from './hiddenCssClasses';
|
15 | import { jsx as _jsx } from "react/jsx-runtime";
|
16 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
17 | var classes = ownerState.classes,
|
18 | breakpoints = ownerState.breakpoints;
|
19 | var slots = {
|
20 | root: ['root'].concat(_toConsumableArray(breakpoints.map(function (_ref) {
|
21 | var breakpoint = _ref.breakpoint,
|
22 | dir = _ref.dir;
|
23 | return dir === 'only' ? "".concat(dir).concat(capitalize(breakpoint)) : "".concat(breakpoint).concat(capitalize(dir));
|
24 | })))
|
25 | };
|
26 | return composeClasses(slots, getHiddenCssUtilityClass, classes);
|
27 | };
|
28 | var HiddenCssRoot = styled('div', {
|
29 | name: 'PrivateHiddenCss',
|
30 | slot: 'Root'
|
31 | })(function (_ref2) {
|
32 | var theme = _ref2.theme,
|
33 | ownerState = _ref2.ownerState;
|
34 | var hidden = {
|
35 | display: 'none'
|
36 | };
|
37 | return _extends({}, ownerState.breakpoints.map(function (_ref3) {
|
38 | var breakpoint = _ref3.breakpoint,
|
39 | dir = _ref3.dir;
|
40 | if (dir === 'only') {
|
41 | return _defineProperty({}, theme.breakpoints.only(breakpoint), hidden);
|
42 | }
|
43 | return dir === 'up' ? _defineProperty({}, theme.breakpoints.up(breakpoint), hidden) : _defineProperty({}, theme.breakpoints.down(breakpoint), hidden);
|
44 | }).reduce(function (r, o) {
|
45 | Object.keys(o).forEach(function (k) {
|
46 | r[k] = o[k];
|
47 | });
|
48 | return r;
|
49 | }, {}));
|
50 | });
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | function HiddenCss(props) {
|
56 | var children = props.children,
|
57 | className = props.className,
|
58 | only = props.only,
|
59 | other = _objectWithoutProperties(props, ["children", "className", "only"]);
|
60 | var theme = useTheme();
|
61 | if (process.env.NODE_ENV !== 'production') {
|
62 | var unknownProps = Object.keys(other).filter(function (propName) {
|
63 | var isUndeclaredBreakpoint = !theme.breakpoints.keys.some(function (breakpoint) {
|
64 | return "".concat(breakpoint, "Up") === propName || "".concat(breakpoint, "Down") === propName;
|
65 | });
|
66 | return !['classes', 'theme', 'isRtl', 'sx'].includes(propName) && isUndeclaredBreakpoint;
|
67 | });
|
68 | if (unknownProps.length > 0) {
|
69 | console.error("MUI: Unsupported props received by `<Hidden implementation=\"css\" />`: ".concat(unknownProps.join(', '), ". Did you forget to wrap this component in a ThemeProvider declaring these breakpoints?"));
|
70 | }
|
71 | }
|
72 | var breakpoints = [];
|
73 | for (var i = 0; i < theme.breakpoints.keys.length; i += 1) {
|
74 | var breakpoint = theme.breakpoints.keys[i];
|
75 | var breakpointUp = other["".concat(breakpoint, "Up")];
|
76 | var breakpointDown = other["".concat(breakpoint, "Down")];
|
77 | if (breakpointUp) {
|
78 | breakpoints.push({
|
79 | breakpoint: breakpoint,
|
80 | dir: 'up'
|
81 | });
|
82 | }
|
83 | if (breakpointDown) {
|
84 | breakpoints.push({
|
85 | breakpoint: breakpoint,
|
86 | dir: 'down'
|
87 | });
|
88 | }
|
89 | }
|
90 | if (only) {
|
91 | var onlyBreakpoints = Array.isArray(only) ? only : [only];
|
92 | onlyBreakpoints.forEach(function (breakpoint) {
|
93 | breakpoints.push({
|
94 | breakpoint: breakpoint,
|
95 | dir: 'only'
|
96 | });
|
97 | });
|
98 | }
|
99 | var ownerState = _extends({}, props, {
|
100 | breakpoints: breakpoints
|
101 | });
|
102 | var classes = useUtilityClasses(ownerState);
|
103 | return _jsx(HiddenCssRoot, {
|
104 | className: clsx(classes.root, className),
|
105 | ownerState: ownerState,
|
106 | children: children
|
107 | });
|
108 | }
|
109 | process.env.NODE_ENV !== "production" ? HiddenCss.propTypes = {
|
110 | |
111 |
|
112 |
|
113 | children: PropTypes.node,
|
114 | |
115 |
|
116 |
|
117 | className: PropTypes.string,
|
118 | |
119 |
|
120 |
|
121 |
|
122 | implementation: PropTypes.oneOf(['js', 'css']),
|
123 | |
124 |
|
125 |
|
126 | lgDown: PropTypes.bool,
|
127 | |
128 |
|
129 |
|
130 | lgUp: PropTypes.bool,
|
131 | |
132 |
|
133 |
|
134 | mdDown: PropTypes.bool,
|
135 | |
136 |
|
137 |
|
138 | mdUp: PropTypes.bool,
|
139 | |
140 |
|
141 |
|
142 | only: PropTypes.oneOfType([PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']), PropTypes.arrayOf(PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']))]),
|
143 | |
144 |
|
145 |
|
146 | smDown: PropTypes.bool,
|
147 | |
148 |
|
149 |
|
150 | smUp: PropTypes.bool,
|
151 | |
152 |
|
153 |
|
154 | xlDown: PropTypes.bool,
|
155 | |
156 |
|
157 |
|
158 | xlUp: PropTypes.bool,
|
159 | |
160 |
|
161 |
|
162 | xsDown: PropTypes.bool,
|
163 | |
164 |
|
165 |
|
166 | xsUp: PropTypes.bool
|
167 | } : void 0;
|
168 | export default HiddenCss; |
\ | No newline at end of file |