1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = void 0;
|
11 |
|
12 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
13 |
|
14 | var _utils = require("@material-ui/utils");
|
15 |
|
16 | var _withWidth = _interopRequireWildcard(require("../withWidth"));
|
17 |
|
18 | var _useTheme = _interopRequireDefault(require("../styles/useTheme"));
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | function HiddenJs(props) {
|
24 | var children = props.children,
|
25 | only = props.only,
|
26 | width = props.width;
|
27 | var theme = (0, _useTheme.default)();
|
28 | var visible = true;
|
29 |
|
30 | if (only) {
|
31 | if (Array.isArray(only)) {
|
32 | for (var i = 0; i < only.length; i += 1) {
|
33 | var breakpoint = only[i];
|
34 |
|
35 | if (width === breakpoint) {
|
36 | visible = false;
|
37 | break;
|
38 | }
|
39 | }
|
40 | } else if (only && width === only) {
|
41 | visible = false;
|
42 | }
|
43 | }
|
44 |
|
45 |
|
46 | if (visible) {
|
47 |
|
48 | for (var _i = 0; _i < theme.breakpoints.keys.length; _i += 1) {
|
49 | var _breakpoint = theme.breakpoints.keys[_i];
|
50 | var breakpointUp = props["".concat(_breakpoint, "Up")];
|
51 | var breakpointDown = props["".concat(_breakpoint, "Down")];
|
52 |
|
53 | if (breakpointUp && (0, _withWidth.isWidthUp)(_breakpoint, width) || breakpointDown && (0, _withWidth.isWidthDown)(_breakpoint, width)) {
|
54 | visible = false;
|
55 | break;
|
56 | }
|
57 | }
|
58 | }
|
59 |
|
60 | if (!visible) {
|
61 | return null;
|
62 | }
|
63 |
|
64 | return children;
|
65 | }
|
66 |
|
67 | HiddenJs.propTypes = {
|
68 | |
69 |
|
70 |
|
71 | children: _propTypes.default.node,
|
72 |
|
73 | |
74 |
|
75 |
|
76 | className: _propTypes.default.string,
|
77 |
|
78 | |
79 |
|
80 |
|
81 |
|
82 | implementation: _propTypes.default.oneOf(['js', 'css']),
|
83 |
|
84 | |
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 | initialWidth: _propTypes.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
|
96 |
|
97 | |
98 |
|
99 |
|
100 | lgDown: _propTypes.default.bool,
|
101 |
|
102 | |
103 |
|
104 |
|
105 | lgUp: _propTypes.default.bool,
|
106 |
|
107 | |
108 |
|
109 |
|
110 | mdDown: _propTypes.default.bool,
|
111 |
|
112 | |
113 |
|
114 |
|
115 | mdUp: _propTypes.default.bool,
|
116 |
|
117 | |
118 |
|
119 |
|
120 | only: _propTypes.default.oneOfType([_propTypes.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']), _propTypes.default.arrayOf(_propTypes.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']))]),
|
121 |
|
122 | |
123 |
|
124 |
|
125 | smDown: _propTypes.default.bool,
|
126 |
|
127 | |
128 |
|
129 |
|
130 | smUp: _propTypes.default.bool,
|
131 |
|
132 | |
133 |
|
134 |
|
135 |
|
136 | width: _propTypes.default.string.isRequired,
|
137 |
|
138 | |
139 |
|
140 |
|
141 | xlDown: _propTypes.default.bool,
|
142 |
|
143 | |
144 |
|
145 |
|
146 | xlUp: _propTypes.default.bool,
|
147 |
|
148 | |
149 |
|
150 |
|
151 | xsDown: _propTypes.default.bool,
|
152 |
|
153 | |
154 |
|
155 |
|
156 | xsUp: _propTypes.default.bool
|
157 | };
|
158 |
|
159 | if (process.env.NODE_ENV !== 'production') {
|
160 | HiddenJs.propTypes = (0, _utils.exactProp)(HiddenJs.propTypes);
|
161 | }
|
162 |
|
163 | var _default = (0, _withWidth.default)()(HiddenJs);
|
164 |
|
165 | exports.default = _default; |
\ | No newline at end of file |