1 | 'use client';
|
2 |
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import exactProp from '@mui/utils/exactProp';
|
6 | import withWidth, { isWidthDown, isWidthUp } from "./withWidth.js";
|
7 | import useTheme from "../styles/useTheme.js";
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | import { jsx as _jsx } from "react/jsx-runtime";
|
13 | function HiddenJs(props) {
|
14 | const {
|
15 | children,
|
16 | only,
|
17 | width
|
18 | } = props;
|
19 | const theme = useTheme();
|
20 | let visible = true;
|
21 |
|
22 |
|
23 | if (only) {
|
24 | if (Array.isArray(only)) {
|
25 | for (let i = 0; i < only.length; i += 1) {
|
26 | const breakpoint = only[i];
|
27 | if (width === breakpoint) {
|
28 | visible = false;
|
29 | break;
|
30 | }
|
31 | }
|
32 | } else if (only && width === only) {
|
33 | visible = false;
|
34 | }
|
35 | }
|
36 |
|
37 |
|
38 | if (visible) {
|
39 |
|
40 | for (let i = 0; i < theme.breakpoints.keys.length; i += 1) {
|
41 | const breakpoint = theme.breakpoints.keys[i];
|
42 | const breakpointUp = props[`${breakpoint}Up`];
|
43 | const breakpointDown = props[`${breakpoint}Down`];
|
44 | if (breakpointUp && isWidthUp(breakpoint, width) || breakpointDown && isWidthDown(breakpoint, width)) {
|
45 | visible = false;
|
46 | break;
|
47 | }
|
48 | }
|
49 | }
|
50 | if (!visible) {
|
51 | return null;
|
52 | }
|
53 | return _jsx(React.Fragment, {
|
54 | children: children
|
55 | });
|
56 | }
|
57 | process.env.NODE_ENV !== "production" ? HiddenJs.propTypes = {
|
58 | |
59 |
|
60 |
|
61 | children: PropTypes.node,
|
62 | |
63 |
|
64 |
|
65 |
|
66 | lgDown: PropTypes.bool,
|
67 | |
68 |
|
69 |
|
70 |
|
71 | lgUp: PropTypes.bool,
|
72 | |
73 |
|
74 |
|
75 |
|
76 | mdDown: PropTypes.bool,
|
77 | |
78 |
|
79 |
|
80 |
|
81 | mdUp: PropTypes.bool,
|
82 | |
83 |
|
84 |
|
85 | only: PropTypes.oneOfType([PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']), PropTypes.arrayOf(PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']))]),
|
86 | |
87 |
|
88 |
|
89 |
|
90 | smDown: PropTypes.bool,
|
91 | |
92 |
|
93 |
|
94 |
|
95 | smUp: PropTypes.bool,
|
96 | |
97 |
|
98 |
|
99 |
|
100 | width: PropTypes.string.isRequired,
|
101 | |
102 |
|
103 |
|
104 |
|
105 | xlDown: PropTypes.bool,
|
106 | |
107 |
|
108 |
|
109 |
|
110 | xlUp: PropTypes.bool,
|
111 | |
112 |
|
113 |
|
114 |
|
115 | xsDown: PropTypes.bool,
|
116 | |
117 |
|
118 |
|
119 |
|
120 | xsUp: PropTypes.bool
|
121 | } : void 0;
|
122 | if (process.env.NODE_ENV !== 'production') {
|
123 | process.env.NODE_ENV !== "production" ? HiddenJs.propTypes = exactProp(HiddenJs.propTypes) : void 0;
|
124 | }
|
125 | export default withWidth()(HiddenJs); |
\ | No newline at end of file |