import './demo13.css';
import Button from '../../button';
import Field from '..';
import Input from '../../input';
import React from 'react';
import ReactDOM from 'react-dom';
class App extends React.Component {
    constructor(props) {
        super(props);
        this.field = new Field(this, {
            parseName: true,
            values: {
                objWithDefaults: {
                    a: 1,
                    b: 2,
                },
            },
        });
    }
    onGetValue() {
        console.log(this.field.getValues());
    }
    onSetValue() {
        this.field.setValues({
            obj: {
                b: 'b',
                c: 'c',
            },
            arr: ['first', 'second'],
            objWithDefaults: {
                a: 100,
                b: 200,
            },
        });
    }
    render() {
        const { init, reset, resetToDefault } = this.field;
        return (React.createElement("div", { className: "demo" },
            React.createElement("h3", null, "Object transfer"),
            "obj.b: ",
            React.createElement(Input, Object.assign({}, init('obj.b', { initValue: 'test1' }))),
            ' ',
            React.createElement("span", { style: { marginRight: 20 } }),
            "obj.c: ",
            React.createElement(Input, Object.assign({}, init('obj.c', { initValue: 'test2' }))),
            React.createElement("br", null),
            React.createElement("h3", null, "Array transfer"),
            "arr.0: ",
            React.createElement(Input, Object.assign({}, init('arr.0', { initValue: '0' }))),
            ' ',
            React.createElement("span", { style: { marginRight: 20 } }),
            "arr.1: ",
            React.createElement(Input, Object.assign({}, init('arr.1', { initValue: '1' }))),
            React.createElement("br", null),
            React.createElement("br", null),
            React.createElement("h3", null, "Object with Defaults"),
            "objWithDefaults.a: ",
            React.createElement(Input, Object.assign({}, init('objWithDefaults.a'))),
            ' ',
            React.createElement("span", { style: { marginRight: 20 } }),
            "objWithDefaults.b: ",
            React.createElement(Input, Object.assign({}, init('objWithDefaults.b'))),
            React.createElement("br", null),
            React.createElement("br", null),
            "result:",
            React.createElement("pre", null, JSON.stringify(this.field.getValues(), null, 2)),
            React.createElement("br", null),
            React.createElement("br", null),
            React.createElement(Button, { type: "primary", onClick: this.onGetValue.bind(this) }, "getValues"),
            React.createElement(Button, { onClick: this.onSetValue.bind(this) }, "setValues"),
            React.createElement(Button, { onClick: () => reset() }, "reset"),
            React.createElement(Button, { onClick: () => resetToDefault() }, "resetToDefault")));
    }
}
ReactDOM.render(React.createElement(App, null), document.getElementById('field-demo-13'));
