"use strict";
/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Widget
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScrollableWidgetContent = void 0;
const core_react_1 = require("@itwin/core-react");
const React = require("react");
const useTransientState_1 = require("../../widget-panels/useTransientState");
require("./Content.scss");
/** Component that enables widget content scrolling.
 * @internal
 */
function ScrollableWidgetContent(props) {
    const scrollPosition = React.useRef(new core_react_1.Point());
    const ref = React.useRef(null);
    const onSave = React.useCallback(() => {
        if (!ref.current)
            return;
        scrollPosition.current = new core_react_1.Point(ref.current.scrollLeft, ref.current.scrollTop);
    }, []);
    const onRestore = React.useCallback(() => {
        if (!ref.current)
            return;
        ref.current.scrollLeft = scrollPosition.current.x;
        ref.current.scrollTop = scrollPosition.current.y;
    }, []);
    (0, useTransientState_1.useTransientState)(onSave, onRestore);
    return (React.createElement("div", { "data-item-id": props.itemId, "data-item-provider-id": props.providerId, "data-item-type": "widget-content", className: "nz-widget-content", ref: ref }, props.children));
}
exports.ScrollableWidgetContent = ScrollableWidgetContent;
//# sourceMappingURL=Content.js.map