"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormDesignerRuleStories = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const FormTestData_1 = require("../Testing/FormTestData");
const FormRule_1 = require("../Structure/FormRule");
const LogicData_1 = require("../../Expressions/Testing/LogicData");
const StoryData_1 = require("../../CommonUI/StoryBook/StoryData");
const FormBuilder_1 = require("../FormBuilder");
exports.FormDesignerRuleStories = [
    new StoryData_1.StoryNode(() => {
        let ui = (0, FormTestData_1.getFormConfig)();
        let datadef = (0, FormTestData_1.getDataDefinitionForRulePage)();
        ui.inputData = datadef;
        let expression1 = (0, LogicData_1.getLogicExpressionResultElseIfAtEnd)();
        let rule1 = new FormRule_1.FormRule(expression1, ["isEmployee", "income"]);
        Reflect.set(rule1.data, "validationMessage", "It's not valid.");
        ui.rules = [rule1];
        return (0, jsx_runtime_1.jsx)(FormBuilder_1.FormBuilder, { form: ui });
    }, "Form Designer", "Rules", "Invalid Expression"),
    new StoryData_1.StoryNode(() => {
        let ui = (0, FormTestData_1.getFormConfig)();
        let datadef = (0, FormTestData_1.getDataDefinitionForRulePage)();
        ui.inputData = datadef;
        let expression1 = (0, LogicData_1.getIfSimpleRule)();
        let changeFocus = new FormRule_1.FormRule(expression1, []);
        changeFocus.ruleType = FormRule_1.FormRuleType.CHANGE_FOCUS;
        Reflect.set(changeFocus.data, "controlId", ui.getAllControls()[0].id);
        let changeValue = new FormRule_1.FormRule(expression1, []);
        changeValue.ruleType = FormRule_1.FormRuleType.CHANGE_VALUE;
        Reflect.set(changeValue.data, "value", (0, LogicData_1.getIfSimpleRule)());
        Reflect.set(changeValue.data, "dataPath", "isEmployee");
        let controlEnabled = new FormRule_1.FormRule(expression1, []);
        controlEnabled.ruleType = FormRule_1.FormRuleType.CONTROL_ENABLED;
        Reflect.set(controlEnabled.data, "controlId", [ui.getAllControls()[0].id]);
        let controlVisibility = new FormRule_1.FormRule(expression1, []);
        controlVisibility.ruleType = FormRule_1.FormRuleType.CONTROL_VISIBILITY;
        Reflect.set(controlVisibility.data, "controlId", [ui.getAllControls()[0].id]);
        let exitForm = new FormRule_1.FormRule(expression1, []);
        exitForm.ruleType = FormRule_1.FormRuleType.EXIT_FORM;
        Reflect.set(exitForm.data, "exitOnPath", ui.getOutcomes()[0]?.name);
        let validationRule = new FormRule_1.FormRule(expression1, []);
        validationRule.ruleType = FormRule_1.FormRuleType.VALIDATION;
        Reflect.set(validationRule.data, "validationMessage", "It's invalid.");
        ui.rules = [changeFocus, changeValue, controlEnabled, controlVisibility, exitForm, validationRule];
        return (0, jsx_runtime_1.jsx)(FormBuilder_1.FormBuilder, { form: ui });
    }, "Form Designer", "Rules", "All Rules"),
    new StoryData_1.StoryNode(() => {
        let ui = (0, FormTestData_1.getFormConfig)();
        let datadef = (0, FormTestData_1.getDataDefinitionForRulePage)();
        ui.inputData = datadef;
        let expression1 = (0, LogicData_1.getIfSimpleRule)();
        let changeFocus = new FormRule_1.FormRule(expression1, []);
        changeFocus.ruleType = FormRule_1.FormRuleType.CHANGE_FOCUS;
        let changeValue = new FormRule_1.FormRule(expression1, []);
        changeValue.ruleType = FormRule_1.FormRuleType.CHANGE_VALUE;
        let controlEnabled = new FormRule_1.FormRule(expression1, []);
        controlEnabled.ruleType = FormRule_1.FormRuleType.CONTROL_ENABLED;
        let controlVisibility = new FormRule_1.FormRule(expression1, []);
        controlVisibility.ruleType = FormRule_1.FormRuleType.CONTROL_VISIBILITY;
        let exitForm = new FormRule_1.FormRule(expression1, []);
        exitForm.ruleType = FormRule_1.FormRuleType.EXIT_FORM;
        let validationRule = new FormRule_1.FormRule(expression1, []);
        validationRule.ruleType = FormRule_1.FormRuleType.VALIDATION;
        ui.rules = [changeFocus, changeValue, controlEnabled, controlVisibility, exitForm, validationRule];
        return (0, jsx_runtime_1.jsx)(FormBuilder_1.FormBuilder, { form: ui });
    }, "Form Designer", "Rules", "Invalid Other Parameters"),
    new StoryData_1.StoryNode(() => {
        let ui = (0, FormTestData_1.getFormConfig)();
        return (0, jsx_runtime_1.jsx)(FormBuilder_1.FormBuilder, { form: ui });
    }, "Form Designer", "Rules", "Empty"),
];
//# sourceMappingURL=XFormRule-stories.js.map