"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValueOrExpressionStories = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const styled_components_1 = tslib_1.__importDefault(require("styled-components"));
const XValueOrExpressionEditor_1 = require("../XValueOrExpressionEditor");
const ExpressionConfiguration_1 = require("@appglue/common/dist/Expressions/ExpressionConfiguration");
const BooleanDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/BooleanDataDefinition");
const StringDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/StringDataDefinition");
const DateDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/DateDataDefinition");
const NumberDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/NumberDataDefinition");
const ExpressionValueType_1 = require("@appglue/common/dist/Expressions/ExpressionValueType");
const StoryData_1 = require("../../StoryBook/StoryData");
const Cell = styled_components_1.default.div `
    min-width: 120px;
    border: solid 1px lightblue;
    display: inline-block;
    align-items: center;
`;
const factory = (type) => {
    let expression = new ExpressionConfiguration_1.ExpressionConfiguration();
    let expectedType = type;
    expression.expressionRoot.expectedType = expectedType;
    expression.executionResult = () => {
        return expectedType;
    };
    return expression;
};
exports.ValueOrExpressionStories = [
    new StoryData_1.StoryNode(() => {
        let booleanExpression = factory(new BooleanDataDefinition_1.BooleanDataDefinition("boolean"));
        return ((0, jsx_runtime_1.jsx)(Cell, { children: (0, jsx_runtime_1.jsx)(XValueOrExpressionEditor_1.XValueOrExpressionEditor, { expression: booleanExpression, onUpdate: (newValue) => {
                    if (newValue instanceof ExpressionConfiguration_1.ExpressionConfiguration) {
                    }
                    else {
                        booleanExpression.value = newValue;
                        booleanExpression.valueType = ExpressionValueType_1.ExpressionValueType.VALUE;
                    }
                } }) }));
    }, "Data Designer", "Value or Expression", "Boolean"),
    new StoryData_1.StoryNode(() => {
        let stringExpression = factory(new StringDataDefinition_1.StringDataDefinition("string"));
        return ((0, jsx_runtime_1.jsx)(Cell, { children: (0, jsx_runtime_1.jsx)(XValueOrExpressionEditor_1.XValueOrExpressionEditor, { expression: stringExpression, onUpdate: (newValue) => {
                    if (newValue instanceof ExpressionConfiguration_1.ExpressionConfiguration) {
                    }
                    else {
                        stringExpression.value = newValue;
                        stringExpression.valueType = ExpressionValueType_1.ExpressionValueType.VALUE;
                    }
                } }) }));
    }, "Data Designer", "Value or Expression", "String"),
    new StoryData_1.StoryNode(() => {
        let dateExpression = factory(new DateDataDefinition_1.DateDataDefinition("date"));
        return ((0, jsx_runtime_1.jsx)(Cell, { children: (0, jsx_runtime_1.jsx)(XValueOrExpressionEditor_1.XValueOrExpressionEditor, { expression: dateExpression, onUpdate: (newValue) => {
                    if (newValue instanceof ExpressionConfiguration_1.ExpressionConfiguration) {
                    }
                    else {
                        dateExpression.value = newValue;
                        dateExpression.valueType = ExpressionValueType_1.ExpressionValueType.VALUE;
                    }
                } }) }));
    }, "Data Designer", "Value or Expression", "Date"),
    new StoryData_1.StoryNode(() => {
        let numberExpression = factory(new NumberDataDefinition_1.NumberDataDefinition("number"));
        return ((0, jsx_runtime_1.jsx)(Cell, { children: (0, jsx_runtime_1.jsx)(XValueOrExpressionEditor_1.XValueOrExpressionEditor, { expression: numberExpression, onUpdate: (newValue) => {
                    if (newValue instanceof ExpressionConfiguration_1.ExpressionConfiguration) {
                    }
                    else {
                        numberExpression.value = newValue;
                        numberExpression.valueType = ExpressionValueType_1.ExpressionValueType.VALUE;
                    }
                } }) }));
    }, "Data Designer", "Value or Expression", "Number"),
];
//# sourceMappingURL=XValueOrExpressionEditor-stories.js.map