@mui/material 7.0.0-alpha.1 → 7.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Accordion/Accordion.d.ts +12 -6
- package/Backdrop/Backdrop.d.ts +12 -6
- package/Button/Button.js +3 -3
- package/CHANGELOG.md +31 -0
- package/Dialog/Dialog.d.ts +2 -2
- package/IconButton/IconButton.js +3 -3
- package/InputBase/inputBaseClasses.d.ts +15 -6
- package/InputLabel/InputLabel.d.ts +2 -2
- package/InputLabel/InputLabel.js +3 -3
- package/Popover/Popover.d.ts +1 -1
- package/Snackbar/Snackbar.d.ts +2 -2
- package/SpeedDial/SpeedDial.d.ts +8 -6
- package/StepContent/StepContent.d.ts +2 -2
- package/Tooltip/Tooltip.d.ts +19 -3
- package/esm/Accordion/Accordion.d.ts +12 -6
- package/esm/Backdrop/Backdrop.d.ts +12 -6
- package/esm/Button/Button.js +3 -3
- package/esm/Dialog/Dialog.d.ts +2 -2
- package/esm/IconButton/IconButton.js +3 -3
- package/esm/InputBase/inputBaseClasses.d.ts +15 -6
- package/esm/InputLabel/InputLabel.d.ts +2 -2
- package/esm/InputLabel/InputLabel.js +3 -3
- package/esm/Popover/Popover.d.ts +1 -1
- package/esm/Snackbar/Snackbar.d.ts +2 -2
- package/esm/SpeedDial/SpeedDial.d.ts +8 -6
- package/esm/StepContent/StepContent.d.ts +2 -2
- package/esm/Tooltip/Tooltip.d.ts +19 -3
- package/esm/index.d.ts +0 -2
- package/esm/index.js +1 -3
- package/esm/useAutocomplete/useAutocomplete.js +0 -1
- package/esm/utils/mergeSlotProps.d.ts +1 -1
- package/esm/version/index.js +2 -2
- package/index.d.ts +0 -2
- package/index.js +1 -20
- package/modern/Accordion/Accordion.d.ts +12 -6
- package/modern/Backdrop/Backdrop.d.ts +12 -6
- package/modern/Button/Button.js +3 -3
- package/modern/Dialog/Dialog.d.ts +2 -2
- package/modern/IconButton/IconButton.js +3 -3
- package/modern/InputBase/inputBaseClasses.d.ts +15 -6
- package/modern/InputLabel/InputLabel.d.ts +2 -2
- package/modern/InputLabel/InputLabel.js +3 -3
- package/modern/Popover/Popover.d.ts +1 -1
- package/modern/Snackbar/Snackbar.d.ts +2 -2
- package/modern/SpeedDial/SpeedDial.d.ts +8 -6
- package/modern/StepContent/StepContent.d.ts +2 -2
- package/modern/Tooltip/Tooltip.d.ts +19 -3
- package/modern/index.d.ts +0 -2
- package/modern/index.js +1 -3
- package/modern/useAutocomplete/useAutocomplete.js +0 -1
- package/modern/utils/mergeSlotProps.d.ts +1 -1
- package/modern/version/index.js +2 -2
- package/package.json +9 -7
- package/tsconfig.build.tsbuildinfo +1 -1
- package/useAutocomplete/useAutocomplete.js +0 -1
- package/utils/mergeSlotProps.d.ts +1 -1
- package/version/index.js +2 -2
- package/Hidden/Hidden.d.ts +0 -96
- package/Hidden/Hidden.js +0 -145
- package/Hidden/HiddenCss.d.ts +0 -17
- package/Hidden/HiddenCss.js +0 -189
- package/Hidden/HiddenJs.d.ts +0 -18
- package/Hidden/HiddenJs.js +0 -127
- package/Hidden/hiddenCssClasses.d.ts +0 -3
- package/Hidden/hiddenCssClasses.js +0 -15
- package/Hidden/index.d.ts +0 -2
- package/Hidden/index.js +0 -13
- package/Hidden/withWidth.d.ts +0 -17
- package/Hidden/withWidth.js +0 -118
- package/PigmentHidden/PigmentHidden.d.ts +0 -100
- package/PigmentHidden/PigmentHidden.js +0 -287
- package/PigmentHidden/index.d.ts +0 -2
- package/PigmentHidden/index.js +0 -25
- package/esm/Hidden/Hidden.d.ts +0 -96
- package/esm/Hidden/Hidden.js +0 -140
- package/esm/Hidden/HiddenCss.d.ts +0 -17
- package/esm/Hidden/HiddenCss.js +0 -182
- package/esm/Hidden/HiddenJs.d.ts +0 -18
- package/esm/Hidden/HiddenJs.js +0 -121
- package/esm/Hidden/hiddenCssClasses.d.ts +0 -3
- package/esm/Hidden/hiddenCssClasses.js +0 -7
- package/esm/Hidden/index.d.ts +0 -2
- package/esm/Hidden/index.js +0 -1
- package/esm/Hidden/withWidth.d.ts +0 -17
- package/esm/Hidden/withWidth.js +0 -109
- package/esm/PigmentHidden/PigmentHidden.d.ts +0 -100
- package/esm/PigmentHidden/PigmentHidden.js +0 -279
- package/esm/PigmentHidden/index.d.ts +0 -2
- package/esm/PigmentHidden/index.js +0 -2
- package/modern/Hidden/Hidden.d.ts +0 -96
- package/modern/Hidden/Hidden.js +0 -140
- package/modern/Hidden/HiddenCss.d.ts +0 -17
- package/modern/Hidden/HiddenCss.js +0 -182
- package/modern/Hidden/HiddenJs.d.ts +0 -18
- package/modern/Hidden/HiddenJs.js +0 -121
- package/modern/Hidden/hiddenCssClasses.d.ts +0 -3
- package/modern/Hidden/hiddenCssClasses.js +0 -7
- package/modern/Hidden/index.d.ts +0 -2
- package/modern/Hidden/index.js +0 -1
- package/modern/Hidden/withWidth.d.ts +0 -17
- package/modern/Hidden/withWidth.js +0 -109
- package/modern/PigmentHidden/PigmentHidden.d.ts +0 -100
- package/modern/PigmentHidden/PigmentHidden.js +0 -279
- package/modern/PigmentHidden/index.d.ts +0 -2
- package/modern/PigmentHidden/index.js +0 -2
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
-
import capitalize from "../utils/capitalize.js";
|
|
8
|
-
import styled from "../styles/styled.js";
|
|
9
|
-
import useTheme from "../styles/useTheme.js";
|
|
10
|
-
import { getHiddenCssUtilityClass } from "./hiddenCssClasses.js";
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
const useUtilityClasses = ownerState => {
|
|
13
|
-
const {
|
|
14
|
-
classes,
|
|
15
|
-
breakpoints
|
|
16
|
-
} = ownerState;
|
|
17
|
-
const slots = {
|
|
18
|
-
root: ['root', ...breakpoints.map(({
|
|
19
|
-
breakpoint,
|
|
20
|
-
dir
|
|
21
|
-
}) => {
|
|
22
|
-
return dir === 'only' ? `${dir}${capitalize(breakpoint)}` : `${breakpoint}${capitalize(dir)}`;
|
|
23
|
-
})]
|
|
24
|
-
};
|
|
25
|
-
return composeClasses(slots, getHiddenCssUtilityClass, classes);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// FIXME(romgrk): Can't use memoTheme here, should we memo also on ownerState?
|
|
29
|
-
const HiddenCssRoot = styled('div', {
|
|
30
|
-
name: 'PrivateHiddenCss',
|
|
31
|
-
slot: 'Root'
|
|
32
|
-
})(({
|
|
33
|
-
theme,
|
|
34
|
-
ownerState
|
|
35
|
-
}) => {
|
|
36
|
-
const hidden = {
|
|
37
|
-
display: 'none'
|
|
38
|
-
};
|
|
39
|
-
return {
|
|
40
|
-
...ownerState.breakpoints.map(({
|
|
41
|
-
breakpoint,
|
|
42
|
-
dir
|
|
43
|
-
}) => {
|
|
44
|
-
if (dir === 'only') {
|
|
45
|
-
return {
|
|
46
|
-
[theme.breakpoints.only(breakpoint)]: hidden
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return dir === 'up' ? {
|
|
50
|
-
[theme.breakpoints.up(breakpoint)]: hidden
|
|
51
|
-
} : {
|
|
52
|
-
[theme.breakpoints.down(breakpoint)]: hidden
|
|
53
|
-
};
|
|
54
|
-
}).reduce((r, o) => {
|
|
55
|
-
Object.keys(o).forEach(k => {
|
|
56
|
-
r[k] = o[k];
|
|
57
|
-
});
|
|
58
|
-
return r;
|
|
59
|
-
}, {})
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @ignore - internal component.
|
|
65
|
-
*/
|
|
66
|
-
function HiddenCss(props) {
|
|
67
|
-
const {
|
|
68
|
-
children,
|
|
69
|
-
className,
|
|
70
|
-
only,
|
|
71
|
-
...other
|
|
72
|
-
} = props;
|
|
73
|
-
const theme = useTheme();
|
|
74
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
75
|
-
const unknownProps = Object.keys(other).filter(propName => {
|
|
76
|
-
const isUndeclaredBreakpoint = !theme.breakpoints.keys.some(breakpoint => {
|
|
77
|
-
return `${breakpoint}Up` === propName || `${breakpoint}Down` === propName;
|
|
78
|
-
});
|
|
79
|
-
return !['classes', 'theme', 'isRtl', 'sx'].includes(propName) && isUndeclaredBreakpoint;
|
|
80
|
-
});
|
|
81
|
-
if (unknownProps.length > 0) {
|
|
82
|
-
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?`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const breakpoints = [];
|
|
86
|
-
for (let i = 0; i < theme.breakpoints.keys.length; i += 1) {
|
|
87
|
-
const breakpoint = theme.breakpoints.keys[i];
|
|
88
|
-
const breakpointUp = other[`${breakpoint}Up`];
|
|
89
|
-
const breakpointDown = other[`${breakpoint}Down`];
|
|
90
|
-
if (breakpointUp) {
|
|
91
|
-
breakpoints.push({
|
|
92
|
-
breakpoint,
|
|
93
|
-
dir: 'up'
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
if (breakpointDown) {
|
|
97
|
-
breakpoints.push({
|
|
98
|
-
breakpoint,
|
|
99
|
-
dir: 'down'
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (only) {
|
|
104
|
-
const onlyBreakpoints = Array.isArray(only) ? only : [only];
|
|
105
|
-
onlyBreakpoints.forEach(breakpoint => {
|
|
106
|
-
breakpoints.push({
|
|
107
|
-
breakpoint,
|
|
108
|
-
dir: 'only'
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
const ownerState = {
|
|
113
|
-
...props,
|
|
114
|
-
breakpoints
|
|
115
|
-
};
|
|
116
|
-
const classes = useUtilityClasses(ownerState);
|
|
117
|
-
return /*#__PURE__*/_jsx(HiddenCssRoot, {
|
|
118
|
-
className: clsx(classes.root, className),
|
|
119
|
-
ownerState: ownerState,
|
|
120
|
-
children: children
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
process.env.NODE_ENV !== "production" ? HiddenCss.propTypes = {
|
|
124
|
-
/**
|
|
125
|
-
* The content of the component.
|
|
126
|
-
*/
|
|
127
|
-
children: PropTypes.node,
|
|
128
|
-
/**
|
|
129
|
-
* @ignore
|
|
130
|
-
*/
|
|
131
|
-
className: PropTypes.string,
|
|
132
|
-
/**
|
|
133
|
-
* Specify which implementation to use. 'js' is the default, 'css' works better for
|
|
134
|
-
* server-side rendering.
|
|
135
|
-
*/
|
|
136
|
-
implementation: PropTypes.oneOf(['js', 'css']),
|
|
137
|
-
/**
|
|
138
|
-
* If `true`, screens this size and down are hidden.
|
|
139
|
-
*/
|
|
140
|
-
lgDown: PropTypes.bool,
|
|
141
|
-
/**
|
|
142
|
-
* If `true`, screens this size and up are hidden.
|
|
143
|
-
*/
|
|
144
|
-
lgUp: PropTypes.bool,
|
|
145
|
-
/**
|
|
146
|
-
* If `true`, screens this size and down are hidden.
|
|
147
|
-
*/
|
|
148
|
-
mdDown: PropTypes.bool,
|
|
149
|
-
/**
|
|
150
|
-
* If `true`, screens this size and up are hidden.
|
|
151
|
-
*/
|
|
152
|
-
mdUp: PropTypes.bool,
|
|
153
|
-
/**
|
|
154
|
-
* Hide the given breakpoint(s).
|
|
155
|
-
*/
|
|
156
|
-
only: PropTypes.oneOfType([PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']), PropTypes.arrayOf(PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']))]),
|
|
157
|
-
/**
|
|
158
|
-
* If `true`, screens this size and down are hidden.
|
|
159
|
-
*/
|
|
160
|
-
smDown: PropTypes.bool,
|
|
161
|
-
/**
|
|
162
|
-
* If `true`, screens this size and up are hidden.
|
|
163
|
-
*/
|
|
164
|
-
smUp: PropTypes.bool,
|
|
165
|
-
/**
|
|
166
|
-
* If `true`, screens this size and down are hidden.
|
|
167
|
-
*/
|
|
168
|
-
xlDown: PropTypes.bool,
|
|
169
|
-
/**
|
|
170
|
-
* If `true`, screens this size and up are hidden.
|
|
171
|
-
*/
|
|
172
|
-
xlUp: PropTypes.bool,
|
|
173
|
-
/**
|
|
174
|
-
* If `true`, screens this size and down are hidden.
|
|
175
|
-
*/
|
|
176
|
-
xsDown: PropTypes.bool,
|
|
177
|
-
/**
|
|
178
|
-
* If `true`, screens this size and up are hidden.
|
|
179
|
-
*/
|
|
180
|
-
xsUp: PropTypes.bool
|
|
181
|
-
} : void 0;
|
|
182
|
-
export default HiddenCss;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Breakpoint } from '@mui/system';
|
|
3
|
-
export interface HiddenJsProps {
|
|
4
|
-
width?: Breakpoint;
|
|
5
|
-
lgDown?: boolean;
|
|
6
|
-
lgUp?: boolean;
|
|
7
|
-
mdDown?: boolean;
|
|
8
|
-
mdUp?: boolean;
|
|
9
|
-
only?: Breakpoint | Breakpoint[];
|
|
10
|
-
smDown?: boolean;
|
|
11
|
-
smUp?: boolean;
|
|
12
|
-
xlDown?: boolean;
|
|
13
|
-
xlUp?: boolean;
|
|
14
|
-
xsDown?: boolean;
|
|
15
|
-
xsUp?: boolean;
|
|
16
|
-
}
|
|
17
|
-
declare const HiddenJs: React.JSXElementConstructor<HiddenJsProps>;
|
|
18
|
-
export default HiddenJs;
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import exactProp from '@mui/utils/exactProp';
|
|
5
|
-
import withWidth, { isWidthDown, isWidthUp } from "./withWidth.js";
|
|
6
|
-
import useTheme from "../styles/useTheme.js";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @ignore - internal component.
|
|
10
|
-
*/
|
|
11
|
-
function HiddenJs(props) {
|
|
12
|
-
const {
|
|
13
|
-
children,
|
|
14
|
-
only,
|
|
15
|
-
width
|
|
16
|
-
} = props;
|
|
17
|
-
const theme = useTheme();
|
|
18
|
-
let visible = true;
|
|
19
|
-
|
|
20
|
-
// `only` check is faster to get out sooner if used.
|
|
21
|
-
if (only) {
|
|
22
|
-
if (Array.isArray(only)) {
|
|
23
|
-
for (let i = 0; i < only.length; i += 1) {
|
|
24
|
-
const breakpoint = only[i];
|
|
25
|
-
if (width === breakpoint) {
|
|
26
|
-
visible = false;
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
} else if (only && width === only) {
|
|
31
|
-
visible = false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Allow `only` to be combined with other props. If already hidden, no need to check others.
|
|
36
|
-
if (visible) {
|
|
37
|
-
// determine visibility based on the smallest size up
|
|
38
|
-
for (let i = 0; i < theme.breakpoints.keys.length; i += 1) {
|
|
39
|
-
const breakpoint = theme.breakpoints.keys[i];
|
|
40
|
-
const breakpointUp = props[`${breakpoint}Up`];
|
|
41
|
-
const breakpointDown = props[`${breakpoint}Down`];
|
|
42
|
-
if (breakpointUp && isWidthUp(breakpoint, width) || breakpointDown && isWidthDown(breakpoint, width)) {
|
|
43
|
-
visible = false;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (!visible) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
return children;
|
|
52
|
-
}
|
|
53
|
-
HiddenJs.propTypes = {
|
|
54
|
-
/**
|
|
55
|
-
* The content of the component.
|
|
56
|
-
*/
|
|
57
|
-
children: PropTypes.node,
|
|
58
|
-
/**
|
|
59
|
-
* If `true`, screens this size and down are hidden.
|
|
60
|
-
*/
|
|
61
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
62
|
-
lgDown: PropTypes.bool,
|
|
63
|
-
/**
|
|
64
|
-
* If `true`, screens this size and up are hidden.
|
|
65
|
-
*/
|
|
66
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
67
|
-
lgUp: PropTypes.bool,
|
|
68
|
-
/**
|
|
69
|
-
* If `true`, screens this size and down are hidden.
|
|
70
|
-
*/
|
|
71
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
72
|
-
mdDown: PropTypes.bool,
|
|
73
|
-
/**
|
|
74
|
-
* If `true`, screens this size and up are hidden.
|
|
75
|
-
*/
|
|
76
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
77
|
-
mdUp: PropTypes.bool,
|
|
78
|
-
/**
|
|
79
|
-
* Hide the given breakpoint(s).
|
|
80
|
-
*/
|
|
81
|
-
only: PropTypes.oneOfType([PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']), PropTypes.arrayOf(PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']))]),
|
|
82
|
-
/**
|
|
83
|
-
* If `true`, screens this size and down are hidden.
|
|
84
|
-
*/
|
|
85
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
86
|
-
smDown: PropTypes.bool,
|
|
87
|
-
/**
|
|
88
|
-
* If `true`, screens this size and up are hidden.
|
|
89
|
-
*/
|
|
90
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
91
|
-
smUp: PropTypes.bool,
|
|
92
|
-
/**
|
|
93
|
-
* @ignore
|
|
94
|
-
* width prop provided by withWidth decorator.
|
|
95
|
-
*/
|
|
96
|
-
width: PropTypes.string.isRequired,
|
|
97
|
-
/**
|
|
98
|
-
* If `true`, screens this size and down are hidden.
|
|
99
|
-
*/
|
|
100
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
101
|
-
xlDown: PropTypes.bool,
|
|
102
|
-
/**
|
|
103
|
-
* If `true`, screens this size and up are hidden.
|
|
104
|
-
*/
|
|
105
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
106
|
-
xlUp: PropTypes.bool,
|
|
107
|
-
/**
|
|
108
|
-
* If `true`, screens this size and down are hidden.
|
|
109
|
-
*/
|
|
110
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
111
|
-
xsDown: PropTypes.bool,
|
|
112
|
-
/**
|
|
113
|
-
* If `true`, screens this size and up are hidden.
|
|
114
|
-
*/
|
|
115
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
116
|
-
xsUp: PropTypes.bool
|
|
117
|
-
};
|
|
118
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
119
|
-
HiddenJs.propTypes = exactProp(HiddenJs.propTypes);
|
|
120
|
-
}
|
|
121
|
-
export default withWidth()(HiddenJs);
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare function getHiddenCssUtilityClass(slot: string): string;
|
|
2
|
-
declare const hiddenCssClasses: Record<"root" | "xlDown" | "xlUp" | "onlyXl" | "lgDown" | "lgUp" | "onlyLg" | "mdDown" | "mdUp" | "onlyMd" | "smDown" | "smUp" | "onlySm" | "xsDown" | "xsUp" | "onlyXs", string>;
|
|
3
|
-
export default hiddenCssClasses;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
|
-
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
3
|
-
export function getHiddenCssUtilityClass(slot) {
|
|
4
|
-
return generateUtilityClass('PrivateHiddenCss', slot);
|
|
5
|
-
}
|
|
6
|
-
const hiddenCssClasses = generateUtilityClasses('PrivateHiddenCss', ['root', 'xlDown', 'xlUp', 'onlyXl', 'lgDown', 'lgUp', 'onlyLg', 'mdDown', 'mdUp', 'onlyMd', 'smDown', 'smUp', 'onlySm', 'xsDown', 'xsUp', 'onlyXs']);
|
|
7
|
-
export default hiddenCssClasses;
|
package/modern/Hidden/index.d.ts
DELETED
package/modern/Hidden/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./Hidden.js";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Breakpoint } from '@mui/system';
|
|
2
|
-
import { PropInjector } from '@mui/types';
|
|
3
|
-
export interface WithWidthOptions {
|
|
4
|
-
withTheme?: boolean;
|
|
5
|
-
noSSR?: boolean;
|
|
6
|
-
initialWidth?: Breakpoint;
|
|
7
|
-
resizeInterval?: number;
|
|
8
|
-
}
|
|
9
|
-
export interface WithWidth {
|
|
10
|
-
width: Breakpoint;
|
|
11
|
-
}
|
|
12
|
-
export interface WithWidthProps extends Partial<WithWidth> {
|
|
13
|
-
innerRef?: React.Ref<any>;
|
|
14
|
-
}
|
|
15
|
-
export function isWidthDown(breakpoint: Breakpoint, screenWidth: Breakpoint, inclusive?: boolean): boolean;
|
|
16
|
-
export function isWidthUp(breakpoint: Breakpoint, screenWidth: Breakpoint, inclusive?: boolean): boolean;
|
|
17
|
-
export default function withWidth(options?: WithWidthOptions): PropInjector<WithWidth, WithWidthProps>;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import getDisplayName from '@mui/utils/getDisplayName';
|
|
6
|
-
import { getThemeProps } from '@mui/system/useThemeProps';
|
|
7
|
-
import useTheme from "../styles/useTheme.js";
|
|
8
|
-
import useEnhancedEffect from "../utils/useEnhancedEffect.js";
|
|
9
|
-
import useMediaQuery from "../useMediaQuery/index.js";
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
const breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
12
|
-
|
|
13
|
-
// By default, returns true if screen width is the same or greater than the given breakpoint.
|
|
14
|
-
export const isWidthUp = (breakpoint, width, inclusive = true) => {
|
|
15
|
-
if (inclusive) {
|
|
16
|
-
return breakpointKeys.indexOf(breakpoint) <= breakpointKeys.indexOf(width);
|
|
17
|
-
}
|
|
18
|
-
return breakpointKeys.indexOf(breakpoint) < breakpointKeys.indexOf(width);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// By default, returns true if screen width is less than the given breakpoint.
|
|
22
|
-
export const isWidthDown = (breakpoint, width, inclusive = false) => {
|
|
23
|
-
if (inclusive) {
|
|
24
|
-
return breakpointKeys.indexOf(width) <= breakpointKeys.indexOf(breakpoint);
|
|
25
|
-
}
|
|
26
|
-
return breakpointKeys.indexOf(width) < breakpointKeys.indexOf(breakpoint);
|
|
27
|
-
};
|
|
28
|
-
const withWidth = (options = {}) => Component => {
|
|
29
|
-
const {
|
|
30
|
-
withTheme: withThemeOption = false,
|
|
31
|
-
noSSR = false,
|
|
32
|
-
initialWidth: initialWidthOption
|
|
33
|
-
} = options;
|
|
34
|
-
function WithWidth(props) {
|
|
35
|
-
const contextTheme = useTheme();
|
|
36
|
-
const theme = props.theme || contextTheme;
|
|
37
|
-
const {
|
|
38
|
-
initialWidth,
|
|
39
|
-
width,
|
|
40
|
-
...other
|
|
41
|
-
} = getThemeProps({
|
|
42
|
-
theme,
|
|
43
|
-
name: 'MuiWithWidth',
|
|
44
|
-
props
|
|
45
|
-
});
|
|
46
|
-
const [mountedState, setMountedState] = React.useState(false);
|
|
47
|
-
useEnhancedEffect(() => {
|
|
48
|
-
setMountedState(true);
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* innerWidth |xs sm md lg xl
|
|
53
|
-
* |-------|-------|-------|-------|------>
|
|
54
|
-
* width | xs | sm | md | lg | xl
|
|
55
|
-
*/
|
|
56
|
-
const keys = theme.breakpoints.keys.slice().reverse();
|
|
57
|
-
const widthComputed = keys.reduce((output, key) => {
|
|
58
|
-
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
|
|
59
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
60
|
-
const matches = useMediaQuery(theme.breakpoints.up(key));
|
|
61
|
-
return !output && matches ? key : output;
|
|
62
|
-
}, null);
|
|
63
|
-
const more = {
|
|
64
|
-
width: width || (mountedState || noSSR ? widthComputed : undefined) || initialWidth || initialWidthOption,
|
|
65
|
-
...(withThemeOption ? {
|
|
66
|
-
theme
|
|
67
|
-
} : {}),
|
|
68
|
-
...other
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// When rendering the component on the server,
|
|
72
|
-
// we have no idea about the client browser screen width.
|
|
73
|
-
// In order to prevent blinks and help the reconciliation of the React tree
|
|
74
|
-
// we are not rendering the child component.
|
|
75
|
-
//
|
|
76
|
-
// An alternative is to use the `initialWidth` property.
|
|
77
|
-
if (more.width === undefined) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
return /*#__PURE__*/_jsx(Component, {
|
|
81
|
-
...more
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
process.env.NODE_ENV !== "production" ? WithWidth.propTypes = {
|
|
85
|
-
/**
|
|
86
|
-
* As `window.innerWidth` is unavailable on the server,
|
|
87
|
-
* we default to rendering an empty component during the first mount.
|
|
88
|
-
* You might want to use a heuristic to approximate
|
|
89
|
-
* the screen width of the client browser screen width.
|
|
90
|
-
*
|
|
91
|
-
* For instance, you could be using the user-agent or the client-hints.
|
|
92
|
-
* https://caniuse.com/#search=client%20hint
|
|
93
|
-
*/
|
|
94
|
-
initialWidth: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
|
|
95
|
-
/**
|
|
96
|
-
* @ignore
|
|
97
|
-
*/
|
|
98
|
-
theme: PropTypes.object,
|
|
99
|
-
/**
|
|
100
|
-
* Bypass the width calculation logic.
|
|
101
|
-
*/
|
|
102
|
-
width: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl'])
|
|
103
|
-
} : void 0;
|
|
104
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
105
|
-
WithWidth.displayName = `WithWidth(${getDisplayName(Component)})`;
|
|
106
|
-
}
|
|
107
|
-
return WithWidth;
|
|
108
|
-
};
|
|
109
|
-
export default withWidth;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Breakpoint } from '@mui/system';
|
|
3
|
-
export interface HiddenProps {
|
|
4
|
-
/**
|
|
5
|
-
* The content of the component.
|
|
6
|
-
*/
|
|
7
|
-
children?: React.ReactNode;
|
|
8
|
-
/**
|
|
9
|
-
* Specify which implementation to use. 'js' is the default, 'css' works better for
|
|
10
|
-
* server-side rendering.
|
|
11
|
-
* @default 'js'
|
|
12
|
-
*/
|
|
13
|
-
implementation?: 'js' | 'css';
|
|
14
|
-
/**
|
|
15
|
-
* You can use this prop when choosing the `js` implementation with server-side rendering.
|
|
16
|
-
*
|
|
17
|
-
* As `window.innerWidth` is unavailable on the server,
|
|
18
|
-
* we default to rendering an empty component during the first mount.
|
|
19
|
-
* You might want to use a heuristic to approximate
|
|
20
|
-
* the screen width of the client browser screen width.
|
|
21
|
-
*
|
|
22
|
-
* For instance, you could be using the user-agent or the client-hints.
|
|
23
|
-
* https://caniuse.com/#search=client%20hint
|
|
24
|
-
*/
|
|
25
|
-
initialWidth?: Breakpoint;
|
|
26
|
-
/**
|
|
27
|
-
* If `true`, component is hidden on screens below (but not including) this size.
|
|
28
|
-
* @default false
|
|
29
|
-
*/
|
|
30
|
-
lgDown?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* If `true`, component is hidden on screens this size and above.
|
|
33
|
-
* @default false
|
|
34
|
-
*/
|
|
35
|
-
lgUp?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* If `true`, component is hidden on screens below (but not including) this size.
|
|
38
|
-
* @default false
|
|
39
|
-
*/
|
|
40
|
-
mdDown?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* If `true`, component is hidden on screens this size and above.
|
|
43
|
-
* @default false
|
|
44
|
-
*/
|
|
45
|
-
mdUp?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Hide the given breakpoint(s).
|
|
48
|
-
*/
|
|
49
|
-
only?: Breakpoint | Breakpoint[];
|
|
50
|
-
/**
|
|
51
|
-
* If `true`, component is hidden on screens below (but not including) this size.
|
|
52
|
-
* @default false
|
|
53
|
-
*/
|
|
54
|
-
smDown?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* If `true`, component is hidden on screens this size and above.
|
|
57
|
-
* @default false
|
|
58
|
-
*/
|
|
59
|
-
smUp?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* If `true`, component is hidden on screens below (but not including) this size.
|
|
62
|
-
* @default false
|
|
63
|
-
*/
|
|
64
|
-
xlDown?: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* If `true`, component is hidden on screens this size and above.
|
|
67
|
-
* @default false
|
|
68
|
-
*/
|
|
69
|
-
xlUp?: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* If `true`, component is hidden on screens below (but not including) this size.
|
|
72
|
-
* @default false
|
|
73
|
-
*/
|
|
74
|
-
xsDown?: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* If `true`, component is hidden on screens this size and above.
|
|
77
|
-
* @default false
|
|
78
|
-
*/
|
|
79
|
-
xsUp?: boolean;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
* Demos:
|
|
84
|
-
*
|
|
85
|
-
* - [Hidden](https://next.mui.com/material-ui/react-hidden/)
|
|
86
|
-
*
|
|
87
|
-
* API:
|
|
88
|
-
*
|
|
89
|
-
* - [PigmentHidden API](https://next.mui.com/material-ui/api/pigment-hidden/)
|
|
90
|
-
*/
|
|
91
|
-
declare function PigmentHidden({
|
|
92
|
-
implementation,
|
|
93
|
-
...props
|
|
94
|
-
}: HiddenProps & {
|
|
95
|
-
className?: string;
|
|
96
|
-
}): React.JSX.Element;
|
|
97
|
-
declare namespace PigmentHidden {
|
|
98
|
-
var propTypes: any;
|
|
99
|
-
}
|
|
100
|
-
export default PigmentHidden;
|