33 lines
1.6 KiB
JavaScript
33 lines
1.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.LayerHost = void 0;
|
|
var tslib_1 = require("tslib");
|
|
var React = require("react");
|
|
var react_hooks_1 = require("@fluentui/react-hooks");
|
|
var Utilities_1 = require("../../Utilities");
|
|
var Layer_notification_1 = require("./Layer.notification");
|
|
var LayerHost = function (props) {
|
|
var className = props.className;
|
|
var layerHostId = React.useState(function () { return (0, Utilities_1.getId)(); })[0];
|
|
var _a = props.id, hostId = _a === void 0 ? layerHostId : _a;
|
|
var layerHostRef = React.useRef({
|
|
hostId: hostId,
|
|
rootRef: React.useRef(null),
|
|
notifyLayersChanged: function () {
|
|
// Nothing, since the default implementation of Layer Host does not need to react to layer changes.
|
|
},
|
|
});
|
|
React.useImperativeHandle(props.componentRef, function () { return layerHostRef.current; });
|
|
React.useEffect(function () {
|
|
(0, Layer_notification_1.registerLayerHost)(hostId, layerHostRef.current);
|
|
(0, Layer_notification_1.notifyHostChanged)(hostId);
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- should only run on first render
|
|
}, []);
|
|
(0, react_hooks_1.useUnmount)(function () {
|
|
(0, Layer_notification_1.unregisterLayerHost)(hostId, layerHostRef.current);
|
|
(0, Layer_notification_1.notifyHostChanged)(hostId);
|
|
});
|
|
return React.createElement("div", tslib_1.__assign({}, props, { className: (0, Utilities_1.css)('ms-LayerHost', className), ref: layerHostRef.current.rootRef }));
|
|
};
|
|
exports.LayerHost = LayerHost;
|
|
//# sourceMappingURL=LayerHost.js.map
|