"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const rebass_1 = require("rebass");
const NotifyResize_1 = tslib_1.__importDefault(require("../NotifyResize"));
const SizedContainer = (props) => {
    const { onResize: onResizeFromProps, ...domProps } = props;
    const [size, onResize] = React.useState(null);
    const sizeFn = props.children;
    return (React.createElement(rebass_1.Box, { ...domProps, style: { flex: 1, ...domProps.style, position: 'relative' } },
        React.createElement(rebass_1.Box, { style: {
                position: 'absolute',
                left: 0,
                top: 0,
                width: '100%',
                height: '100%',
            }, "data-width": size ? size.width : null, "data-height": size ? size.height : null },
            React.createElement(NotifyResize_1.default, { onResize: (size) => {
                    onResize(size);
                    onResizeFromProps?.(size);
                } }),
            size ? sizeFn(size) : null)));
};
exports.default = SizedContainer;
