"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var storybook_1 = require("../../../test/storybook");
var __1 = require("..");
var STORY = {
    title: 'Code editor.',
    width: '100%',
    height: '100%',
    padding: 30,
    hr: false,
    flex: true,
};
var CODE = "\n/**\n * Comments.\n */\nconst FOO = 123;\nconst func = (arg) => true;\n\n".substr(1);
var PKG = require('../../../../package.json');
var CODE_JSON = JSON.stringify(PKG, null, '  ');
storybook_1.describe('CodeEditor/options', STORY)
    .add('fontSize: (default)', function () { return storybook_1.React.createElement(Test, null); })
    .add('fontSize: large', function () { return storybook_1.React.createElement(Test, { options: { fontSize: 32 } }); })
    .add('fontSize: small', function () { return storybook_1.React.createElement(Test, { options: { fontSize: 10 } }); })
    .add('tabSize: 2 (default)', function () { return storybook_1.React.createElement(Test, { options: { tabSize: 2 } }); })
    .add('tabSize: 4', function () { return storybook_1.React.createElement(Test, { options: { tabSize: 4 } }); })
    .add('readOnly', function () { return storybook_1.React.createElement(Test, { options: { readOnly: true } }); });
storybook_1.describe('CodeEditor/options (theme)', STORY)
    .add('DARK (default)', function () { return storybook_1.React.createElement(Test, null); })
    .add('LIGHT', function () { return storybook_1.React.createElement(Test, { options: { theme: 'LIGHT' } }); });
storybook_1.describe('CodeEditor/options (language)', STORY)
    .add('json', function () {
    return storybook_1.React.createElement(Test, { options: { language: 'json' }, code: CODE_JSON });
})
    .add('typescript (default)', function () {
    return storybook_1.React.createElement(Test, { options: { language: 'typescript' } });
})
    .add('javascript', function () {
    return storybook_1.React.createElement(Test, { options: { language: 'javascript' } });
})
    .add('types (string)', function () {
    var types = [
        "\n      /**\n       * My kind of Type.\n       */\n      declare type MyThing = {\n        count: number;\n        text?: string;\n      }\n    ",
        "\n      /**\n       * A Foo that foo's the next foo.\n       */\n      class Foo {\n        static next(): string;\n      }\n    ",
    ];
    var code = "\nFoo.next();\nconst foo:MyThing = { count:123 };\n".substr(1);
    return storybook_1.React.createElement(Test, { options: { typescriptDefaults: { types: types } }, code: code });
})
    .add('types (".d.ts" file)', function () {
    var def = require('./test.types-1.d.ts');
    var code = "\nasync function go() {\n  await MyClass.doSomething();\n  const foo: MySuperFoo = {\n    counter: 123,\n    async magic() { return 'hello'; }\n  }\n}\n".substr(1);
    return (storybook_1.React.createElement(Test, { options: { typescriptDefaults: { types: [def] } }, code: code }));
})
    .add('different sets of types', function () {
    var def1 = require('./test.types-1.d.ts');
    var def2 = require('./test.types-2.d.ts');
    var code1 = 'MyClass.doSomething();';
    var styles = {
        base: storybook_1.css({
            Flex: 'vertical-stretch-stretch',
            flex: 1,
        }),
        outer: storybook_1.css({
            position: 'relative',
            flex: 1,
            marginTop: 5,
            ':first-child': { marginTop: 0 },
        }),
    };
    return (storybook_1.React.createElement("div", tslib_1.__assign({}, styles.base),
        storybook_1.React.createElement("div", tslib_1.__assign({}, styles.outer),
            storybook_1.React.createElement(Test, { options: { typescriptDefaults: { types: [def1] } }, code: code1 })),
        storybook_1.React.createElement("div", tslib_1.__assign({}, styles.outer),
            storybook_1.React.createElement(Test, { options: { typescriptDefaults: { types: [def2] } }, code: code1 }))));
});
var DIFF_AFTER = "\nconst FOO = 123;\n\n";
var DIFF_BEFORE = "\nconst FOO = 456;\nconsole.log(FOO);\n\n";
storybook_1.describe('CodeEditor/diff', STORY)
    .add('side-by-side (default)', function () {
    return storybook_1.React.createElement(Test, { code: DIFF_AFTER, diff: { code: DIFF_BEFORE } });
})
    .add('inline', function () {
    return (storybook_1.React.createElement(Test, { code: DIFF_AFTER, diff: { code: DIFF_BEFORE, inline: true } }));
});
var Test = (function (_super) {
    tslib_1.__extends(Test, _super);
    function Test() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.state = { code: _this.props.code || CODE };
        _this.handleChange = function (e) {
            storybook_1.log.info('!! onChange', e);
            _this.setState({ code: e.code });
        };
        return _this;
    }
    Test.prototype.render = function () {
        return (storybook_1.React.createElement(__1.CodeEditor, tslib_1.__assign({}, this.props, { code: this.state.code, onChange: this.handleChange, style: { Absolute: 0 } })));
    };
    return Test;
}(storybook_1.React.PureComponent));
//# sourceMappingURL=stories.js.map