1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports.default = void 0;
|
8 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9 | var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
10 | var React = _interopRequireWildcard(require("react"));
|
11 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
12 | var _ClickAwayListener = _interopRequireDefault(require("../ClickAwayListener"));
|
13 | var _composeClasses = _interopRequireDefault(require("../composeClasses"));
|
14 | var _snackbarClasses = require("./snackbarClasses");
|
15 | var _useSnackbar = _interopRequireDefault(require("../useSnackbar"));
|
16 | var _utils = require("../utils");
|
17 | var _ClassNameConfigurator = require("../utils/ClassNameConfigurator");
|
18 | var _jsxRuntime = require("react/jsx-runtime");
|
19 | const _excluded = ["autoHideDuration", "children", "disableWindowBlurListener", "exited", "onBlur", "onClose", "onFocus", "onMouseEnter", "onMouseLeave", "open", "resumeHideDuration", "slotProps", "slots"];
|
20 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
21 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
22 | const useUtilityClasses = () => {
|
23 | const slots = {
|
24 | root: ['root']
|
25 | };
|
26 | return (0, _composeClasses.default)(slots, (0, _ClassNameConfigurator.useClassNamesOverride)(_snackbarClasses.getSnackbarUtilityClass));
|
27 | };
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | const Snackbar = React.forwardRef(function Snackbar(props, forwardedRef) {
|
40 | const {
|
41 | autoHideDuration = null,
|
42 | children,
|
43 | disableWindowBlurListener = false,
|
44 | exited = true,
|
45 | onClose,
|
46 | open,
|
47 | resumeHideDuration,
|
48 | slotProps = {},
|
49 | slots = {}
|
50 | } = props,
|
51 | other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
52 | const classes = useUtilityClasses();
|
53 | const {
|
54 | getRootProps,
|
55 | onClickAway
|
56 | } = (0, _useSnackbar.default)((0, _extends2.default)({}, props, {
|
57 | autoHideDuration,
|
58 | disableWindowBlurListener,
|
59 | onClose,
|
60 | open,
|
61 | resumeHideDuration
|
62 | }));
|
63 | const ownerState = props;
|
64 | const Root = slots.root || 'div';
|
65 | const rootProps = (0, _utils.useSlotProps)({
|
66 | elementType: Root,
|
67 | getSlotProps: getRootProps,
|
68 | externalForwardedProps: other,
|
69 | externalSlotProps: slotProps.root,
|
70 | additionalProps: {
|
71 | ref: forwardedRef
|
72 | },
|
73 | ownerState,
|
74 | className: classes.root
|
75 | });
|
76 | const clickAwayListenerProps = (0, _utils.useSlotProps)({
|
77 | elementType: _ClickAwayListener.default,
|
78 | externalSlotProps: slotProps.clickAwayListener,
|
79 | additionalProps: {
|
80 | onClickAway
|
81 | },
|
82 | ownerState
|
83 | });
|
84 |
|
85 |
|
86 | delete clickAwayListenerProps.ownerState;
|
87 |
|
88 |
|
89 | if (!open && exited) {
|
90 | return null;
|
91 | }
|
92 | return (0, _jsxRuntime.jsx)(_ClickAwayListener.default, (0, _extends2.default)({}, clickAwayListenerProps, {
|
93 | children: (0, _jsxRuntime.jsx)(Root, (0, _extends2.default)({}, rootProps, {
|
94 | children: children
|
95 | }))
|
96 | }));
|
97 | });
|
98 | process.env.NODE_ENV !== "production" ? Snackbar.propTypes = {
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | |
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 | autoHideDuration: _propTypes.default.number,
|
111 | |
112 |
|
113 |
|
114 | children: _propTypes.default.node,
|
115 | |
116 |
|
117 |
|
118 |
|
119 | disableWindowBlurListener: _propTypes.default.bool,
|
120 | |
121 |
|
122 |
|
123 |
|
124 | exited: _propTypes.default.bool,
|
125 | |
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | onClose: _propTypes.default.func,
|
136 | |
137 |
|
138 |
|
139 | open: _propTypes.default.bool,
|
140 | |
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 | resumeHideDuration: _propTypes.default.number,
|
147 | |
148 |
|
149 |
|
150 |
|
151 | slotProps: _propTypes.default.shape({
|
152 | clickAwayListener: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
153 | children: _propTypes.default.element.isRequired,
|
154 | disableReactTree: _propTypes.default.bool,
|
155 | mouseEvent: _propTypes.default.oneOf(['onClick', 'onMouseDown', 'onMouseUp', 'onPointerDown', 'onPointerUp', false]),
|
156 | onClickAway: _propTypes.default.func,
|
157 | touchEvent: _propTypes.default.oneOf(['onTouchEnd', 'onTouchStart', false])
|
158 | })]),
|
159 | root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
|
160 | }),
|
161 | |
162 |
|
163 |
|
164 |
|
165 |
|
166 | slots: _propTypes.default.shape({
|
167 | root: _propTypes.default.elementType
|
168 | })
|
169 | } : void 0;
|
170 | var _default = Snackbar;
|
171 | exports.default = _default; |
\ | No newline at end of file |