UNPKG

10.1 kBJavaScriptView Raw
1"use strict";
2'use client';
3
4var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6Object.defineProperty(exports, "__esModule", {
7 value: true
8});
9exports.default = void 0;
10var React = _interopRequireWildcard(require("react"));
11var _propTypes = _interopRequireDefault(require("prop-types"));
12var _clsx = _interopRequireDefault(require("clsx"));
13var _Hidden = _interopRequireDefault(require("@mui/material-pigment-css/Hidden"));
14var _capitalize = _interopRequireDefault(require("@mui/utils/capitalize"));
15var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
16var _HiddenJs = _interopRequireDefault(require("../Hidden/HiddenJs"));
17var _hiddenCssClasses = require("../Hidden/hiddenCssClasses");
18var _zeroStyled = require("../zero-styled");
19var _jsxRuntime = require("react/jsx-runtime");
20// @ts-ignore
21
22const useUtilityClasses = ownerState => {
23 const {
24 classes,
25 breakpoints
26 } = ownerState;
27 const slots = {
28 root: ['root', ...breakpoints.map(({
29 breakpoint,
30 dir
31 }) => {
32 return dir === 'only' ? `${dir}${(0, _capitalize.default)(breakpoint)}` : `${breakpoint}${(0, _capitalize.default)(dir)}`;
33 })]
34 };
35 return (0, _composeClasses.default)(slots, _hiddenCssClasses.getHiddenCssUtilityClass, classes);
36};
37function HiddenCss(props) {
38 const theme = (0, _zeroStyled.useTheme)();
39 const {
40 children,
41 className,
42 only,
43 ...other
44 } = props;
45 if (process.env.NODE_ENV !== 'production') {
46 const unknownProps = Object.keys(other).filter(propName => {
47 const isUndeclaredBreakpoint = !theme.breakpoints.keys.some(breakpoint => {
48 return `${breakpoint}Up` === propName || `${breakpoint}Down` === propName;
49 });
50 return !['classes', 'theme', 'isRtl', 'sx'].includes(propName) && isUndeclaredBreakpoint;
51 });
52 if (unknownProps.length > 0) {
53 console.error(`MUI: Unsupported props received by \`<Hidden implementation="css" />\`: ${unknownProps.join(', ')}. Did you forget to wrap this component in a ThemeProvider declaring these breakpoints?`);
54 }
55 }
56 const breakpoints = [];
57 for (let i = 0; i < theme.breakpoints.keys.length; i += 1) {
58 const breakpoint = theme.breakpoints.keys[i];
59 const breakpointUp = other[`${breakpoint}Up`];
60 const breakpointDown = other[`${breakpoint}Down`];
61 if (breakpointUp) {
62 breakpoints.push({
63 breakpoint,
64 dir: 'up'
65 });
66 }
67 if (breakpointDown) {
68 breakpoints.push({
69 breakpoint,
70 dir: 'down'
71 });
72 }
73 }
74 if (only) {
75 const onlyBreakpoints = Array.isArray(only) ? only : [only];
76 onlyBreakpoints.forEach(breakpoint => {
77 breakpoints.push({
78 breakpoint,
79 dir: 'only'
80 });
81 });
82 }
83 const ownerState = {
84 ...props,
85 classes: {},
86 breakpoints
87 };
88 const classes = useUtilityClasses(ownerState);
89 return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Hidden.default, {
90 className: (0, _clsx.default)(classes.root, className),
91 ...props
92 });
93}
94process.env.NODE_ENV !== "production" ? HiddenCss.propTypes /* remove-proptypes */ = {
95 // ┌────────────────────────────── Warning ──────────────────────────────┐
96 // │ These PropTypes are generated from the TypeScript type definitions. │
97 // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
98 // └─────────────────────────────────────────────────────────────────────┘
99 /**
100 * The content of the component.
101 */
102 children: _propTypes.default.node,
103 className: _propTypes.default.string,
104 /**
105 * Specify which implementation to use. 'js' is the default, 'css' works better for
106 * server-side rendering.
107 * @default 'js'
108 */
109 implementation: _propTypes.default.oneOf(['css', 'js']),
110 /**
111 * You can use this prop when choosing the `js` implementation with server-side rendering.
112 *
113 * As `window.innerWidth` is unavailable on the server,
114 * we default to rendering an empty component during the first mount.
115 * You might want to use a heuristic to approximate
116 * the screen width of the client browser screen width.
117 *
118 * For instance, you could be using the user-agent or the client-hints.
119 * https://caniuse.com/#search=client%20hint
120 */
121 initialWidth: _propTypes.default.oneOf(['lg', 'md', 'sm', 'xl', 'xs']),
122 /**
123 * If `true`, component is hidden on screens below (but not including) this size.
124 * @default false
125 */
126 lgDown: _propTypes.default.bool,
127 /**
128 * If `true`, component is hidden on screens this size and above.
129 * @default false
130 */
131 lgUp: _propTypes.default.bool,
132 /**
133 * If `true`, component is hidden on screens below (but not including) this size.
134 * @default false
135 */
136 mdDown: _propTypes.default.bool,
137 /**
138 * If `true`, component is hidden on screens this size and above.
139 * @default false
140 */
141 mdUp: _propTypes.default.bool,
142 /**
143 * Hide the given breakpoint(s).
144 */
145 only: _propTypes.default.oneOfType([_propTypes.default.oneOf(['lg', 'md', 'sm', 'xl', 'xs']), _propTypes.default.arrayOf(_propTypes.default.oneOf(['lg', 'md', 'sm', 'xl', 'xs']).isRequired)]),
146 /**
147 * If `true`, component is hidden on screens below (but not including) this size.
148 * @default false
149 */
150 smDown: _propTypes.default.bool,
151 /**
152 * If `true`, component is hidden on screens this size and above.
153 * @default false
154 */
155 smUp: _propTypes.default.bool,
156 /**
157 * If `true`, component is hidden on screens below (but not including) this size.
158 * @default false
159 */
160 xlDown: _propTypes.default.bool,
161 /**
162 * If `true`, component is hidden on screens this size and above.
163 * @default false
164 */
165 xlUp: _propTypes.default.bool,
166 /**
167 * If `true`, component is hidden on screens below (but not including) this size.
168 * @default false
169 */
170 xsDown: _propTypes.default.bool,
171 /**
172 * If `true`, component is hidden on screens this size and above.
173 * @default false
174 */
175 xsUp: _propTypes.default.bool
176} : void 0;
177
178/**
179 *
180 * Demos:
181 *
182 * - [Hidden](https://mui.com/material-ui/react-hidden/)
183 *
184 * API:
185 *
186 * - [PigmentHidden API](https://mui.com/material-ui/api/pigment-hidden/)
187 */
188function PigmentHidden({
189 implementation = 'js',
190 ...props
191}) {
192 if (implementation === 'js') {
193 return /*#__PURE__*/(0, _jsxRuntime.jsx)(_HiddenJs.default, {
194 ...props
195 });
196 }
197 return /*#__PURE__*/(0, _jsxRuntime.jsx)(HiddenCss, {
198 ...props
199 });
200}
201process.env.NODE_ENV !== "production" ? PigmentHidden.propTypes /* remove-proptypes */ = {
202 // ┌────────────────────────────── Warning ──────────────────────────────┐
203 // │ These PropTypes are generated from the TypeScript type definitions. │
204 // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
205 // └─────────────────────────────────────────────────────────────────────┘
206 /**
207 * The content of the component.
208 */
209 children: _propTypes.default.node,
210 /**
211 * @ignore
212 */
213 className: _propTypes.default.string,
214 /**
215 * Specify which implementation to use. 'js' is the default, 'css' works better for
216 * server-side rendering.
217 * @default 'js'
218 */
219 implementation: _propTypes.default.oneOf(['css', 'js']),
220 /**
221 * You can use this prop when choosing the `js` implementation with server-side rendering.
222 *
223 * As `window.innerWidth` is unavailable on the server,
224 * we default to rendering an empty component during the first mount.
225 * You might want to use a heuristic to approximate
226 * the screen width of the client browser screen width.
227 *
228 * For instance, you could be using the user-agent or the client-hints.
229 * https://caniuse.com/#search=client%20hint
230 */
231 initialWidth: _propTypes.default.oneOf(['lg', 'md', 'sm', 'xl', 'xs']),
232 /**
233 * If `true`, component is hidden on screens below (but not including) this size.
234 * @default false
235 */
236 lgDown: _propTypes.default.bool,
237 /**
238 * If `true`, component is hidden on screens this size and above.
239 * @default false
240 */
241 lgUp: _propTypes.default.bool,
242 /**
243 * If `true`, component is hidden on screens below (but not including) this size.
244 * @default false
245 */
246 mdDown: _propTypes.default.bool,
247 /**
248 * If `true`, component is hidden on screens this size and above.
249 * @default false
250 */
251 mdUp: _propTypes.default.bool,
252 /**
253 * Hide the given breakpoint(s).
254 */
255 only: _propTypes.default.oneOfType([_propTypes.default.oneOf(['lg', 'md', 'sm', 'xl', 'xs']), _propTypes.default.arrayOf(_propTypes.default.oneOf(['lg', 'md', 'sm', 'xl', 'xs']).isRequired)]),
256 /**
257 * If `true`, component is hidden on screens below (but not including) this size.
258 * @default false
259 */
260 smDown: _propTypes.default.bool,
261 /**
262 * If `true`, component is hidden on screens this size and above.
263 * @default false
264 */
265 smUp: _propTypes.default.bool,
266 /**
267 * If `true`, component is hidden on screens below (but not including) this size.
268 * @default false
269 */
270 xlDown: _propTypes.default.bool,
271 /**
272 * If `true`, component is hidden on screens this size and above.
273 * @default false
274 */
275 xlUp: _propTypes.default.bool,
276 /**
277 * If `true`, component is hidden on screens below (but not including) this size.
278 * @default false
279 */
280 xsDown: _propTypes.default.bool,
281 /**
282 * If `true`, component is hidden on screens this size and above.
283 * @default false
284 */
285 xsUp: _propTypes.default.bool
286} : void 0;
287var _default = exports.default = PigmentHidden;
\No newline at end of file