"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var react_1 = require("@storybook/react");
var addon_actions_1 = require("@storybook/addon-actions");
var __1 = require("../../");
var unstable_1 = require("../../unstable/");
var JellyForm = unstable_1.Async(function () {
    return Promise.resolve().then(function () { return require('../../unstable/components/JellyForm'); });
});
var schema = "\n  title: Pok\u00E8mon\n  version: 1\n  properties:\n    - Name:\n        type: string\n        minLength: 5\n    - Category:\n        type: string\n        maxLength: 20\n    - pokedex_number:\n        title: National Pok\u00E8dex Number\n        type: number\n    - caught:\n        type: boolean\n    - first_seen:\n        title: First seen\n        description: The first time you saw this pok\u00E8mon\n        type: string\n        format: date-time\n    - tags:\n        title: Tags\n        description: Add useful tags to your pok\u00E8mon\n        type: array\n        items:\n          type: string\n";
var FormDemo = (function (_super) {
    __extends(FormDemo, _super);
    function FormDemo(props) {
        var _this = _super.call(this, props) || this;
        _this.state = {
            schema: schema,
            formData: {}
        };
        _this.change = function (_a) {
            var formData = _a.formData;
            addon_actions_1.action('Form.onChange')(formData);
            _this.setState({ formData: formData });
        };
        _this.submit = function (data) {
            addon_actions_1.action('Form.onSubmit')(data);
        };
        return _this;
    }
    FormDemo.prototype.render = function () {
        return (React.createElement(__1.Flex, null,
            React.createElement(__1.Box, { flex: '1', m: 30 },
                React.createElement(JellyForm, __assign({ onFormChange: this.change, onFormSubmit: this.submit, value: this.state.formData }, this.props))),
            React.createElement(__1.Box, { flex: '1', style: { maxWidth: '50%' }, p: 30 },
                React.createElement(__1.Txt, { monospace: true },
                    React.createElement("pre", null, JSON.stringify(this.state.formData, null, 4))))));
    };
    return FormDemo;
}(React.Component));
react_1.storiesOf('Beta/JellyForm', module).add('Standard', function () {
    return (React.createElement(__1.Provider, null,
        React.createElement(__1.Box, { p: 3 },
            React.createElement(FormDemo, { schema: schema }))));
});
