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 _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
13 |
|
14 | var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
15 |
|
16 | var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
17 |
|
18 | var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
19 |
|
20 | var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
21 |
|
22 | var React = _interopRequireWildcard(require("react"));
|
23 |
|
24 | var ReactDOM = _interopRequireWildcard(require("react-dom"));
|
25 |
|
26 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
27 |
|
28 | var _utils = require("@material-ui/utils");
|
29 |
|
30 | var _setRef = _interopRequireDefault(require("../utils/setRef"));
|
31 |
|
32 | function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
33 |
|
34 | function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
35 |
|
36 | var warnedOnce = false;
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | var RootRef = function (_React$Component) {
|
73 | (0, _inherits2.default)(RootRef, _React$Component);
|
74 |
|
75 | var _super = _createSuper(RootRef);
|
76 |
|
77 | function RootRef() {
|
78 | (0, _classCallCheck2.default)(this, RootRef);
|
79 | return _super.apply(this, arguments);
|
80 | }
|
81 |
|
82 | (0, _createClass2.default)(RootRef, [{
|
83 | key: "componentDidMount",
|
84 | value: function componentDidMount() {
|
85 | this.ref = ReactDOM.findDOMNode(this);
|
86 | (0, _setRef.default)(this.props.rootRef, this.ref);
|
87 | }
|
88 | }, {
|
89 | key: "componentDidUpdate",
|
90 | value: function componentDidUpdate(prevProps) {
|
91 | var ref = ReactDOM.findDOMNode(this);
|
92 |
|
93 | if (prevProps.rootRef !== this.props.rootRef || this.ref !== ref) {
|
94 | if (prevProps.rootRef !== this.props.rootRef) {
|
95 | (0, _setRef.default)(prevProps.rootRef, null);
|
96 | }
|
97 |
|
98 | this.ref = ref;
|
99 | (0, _setRef.default)(this.props.rootRef, this.ref);
|
100 | }
|
101 | }
|
102 | }, {
|
103 | key: "componentWillUnmount",
|
104 | value: function componentWillUnmount() {
|
105 | this.ref = null;
|
106 | (0, _setRef.default)(this.props.rootRef, null);
|
107 | }
|
108 | }, {
|
109 | key: "render",
|
110 | value: function render() {
|
111 | if (process.env.NODE_ENV !== 'production') {
|
112 | if (!warnedOnce) {
|
113 | warnedOnce = true;
|
114 | console.warn(['Material-UI: The RootRef component is deprecated.', 'The component relies on the ReactDOM.findDOMNode API which is deprecated in React.StrictMode.', 'Instead, you can get a reference to the underlying DOM node of the components via the `ref` prop.'].join('/n'));
|
115 | }
|
116 | }
|
117 |
|
118 | return this.props.children;
|
119 | }
|
120 | }]);
|
121 | return RootRef;
|
122 | }(React.Component);
|
123 |
|
124 | process.env.NODE_ENV !== "production" ? RootRef.propTypes = {
|
125 | |
126 |
|
127 |
|
128 | children: _propTypes.default.element.isRequired,
|
129 |
|
130 | |
131 |
|
132 |
|
133 | rootRef: _utils.refType.isRequired
|
134 | } : void 0;
|
135 |
|
136 | if (process.env.NODE_ENV !== 'production') {
|
137 | process.env.NODE_ENV !== "production" ? RootRef.propTypes = (0, _utils.exactProp)(RootRef.propTypes) : void 0;
|
138 | }
|
139 |
|
140 | var _default = RootRef;
|
141 | exports.default = _default; |
\ | No newline at end of file |