"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const components_1 = require("@bluebase/components");
const core_1 = require("@bluebase/core");
const react_1 = tslib_1.__importDefault(require("react"));
class ColumnComponent extends react_1.default.PureComponent {
    constructor(props) {
        super(props);
        this.state = {
            size: 0
        };
        // This binding is necessary to make `this` work in the callback
        this.onLayout = this.onLayout.bind(this);
    }
    onLayout(event) {
        const width = parseFloat(event.nativeEvent.layout.width);
        if (this.state.size !== width) {
            this.setState({ size: width });
        }
    }
    render() {
        const _a = this.props, { children } = _a, rest = tslib_1.__rest(_a, ["children"]);
        const size = this.state.size;
        return (react_1.default.createElement(components_1.Column, Object.assign({ onLayout: this.onLayout }, rest), children(size)));
    }
}
ColumnComponent.contextType = core_1.BlueBaseContext;
exports.ColumnComponent = ColumnComponent;
exports.Column = ColumnComponent;
