import { UserFormData } from "../UserFormData";
import { XTextField } from "../Controls/XTextField";
import { XMultiLineTextEdit } from "../Controls/XMultiLineTextEdit";
import { XCheckboxField } from "../Controls/XCheckboxField";
import { XSelectbox } from "../Controls/XSelectbox";
import { XHeading } from "../Controls/XHeading";
import { XLabel } from "../Controls/XLabel";
import { XButton } from "../Controls/XButton";
import { XLink } from "../Controls/XLink";
import { XSwitch } from "../Controls/XSwitch";
import { XCheckboxList } from "../Controls/XCheckboxList";
import { XRating } from "../Controls/XRating";
import { XInlineTextEdit } from "../Controls/XInlineTextEdit";
import { XMultiInlineTextEdit } from "../Controls/XMultiInlineTextEdit";
import { XColumnContainer, XColumnContainerColumn, XStackContainer, XHStackContainer } from "../Containers";
import { XRadioGroup } from "../Controls/XRadioGroup";
import { XFormConfiguration } from "../XFormConfiguration";
import { XDatePicker } from "../Controls/XDatePicker";
import { XTimePicker } from "../Controls/XTimePicker";
import { XNumberBox } from "../Controls/XNumberBox";
import { XSlider } from "../Controls/XSlider";
import { XButtonGroup } from "../Controls/XButtonGroup";
import { XTagGroup } from "../Controls/XTagGroup";
import { WidthUnitInterface, ButtonControlSize } from "../FormDesignConstants";
import { DefaultOnOff } from "../Utilities/DefaultOnOff";
import { XListEntry } from "../Controls/XListEntry";
import { XValueSlider } from "../Controls/XValueSlider";
import { XImageControl } from "../Controls/XImageControl";
import { XDataDefinition } from "../../Common/Data/XDataDefinition";
import { BooleanDataDefinition } from "../../Common/Data/Definitions/BooleanDataDefinition";
import { NumberDataDefinition } from "../../Common/Data/Definitions/NumberDataDefinition";
import { ObjectDataDefinition } from "../../Common/Data/Definitions/ObjectDataDefinition";
import { StringDataDefinition } from "../../Common/Data/Definitions/StringDataDefinition";
import { XTimeline } from "../Controls/XTimeline";
import { XDataGrid } from "../Controls/XDataGrid";
import { XExpressionDefinition } from "../../Expressions/XExpressionDefinition";
import { FormRule, FormRuleValidationData, FormRuleChangeFocusData, FormRuleChangeValueData, FormRuleControlEnabledData, FormRuleControlVisibilityData, FormRuleType, FormRuleExitFormData } from "../FormRule";
import { getEqualSimpleRule } from "../../Expressions/Test/StringData";
import { getCombineSimpleRule } from "../../Expressions/Test/StringData";
// this is temporary code to create form definition.
// eventually, this form will be read in from JSON and written to JSON... even though I think that
// this might be useful pattern to create test scripts.
export function getFormData() {
    let formData = new UserFormData();
    formData["firstName"] = "Carl";
    formData["lastName"] = "Hewitt";
    formData["testdata"] = "";
    formData["age"] = 28;
    return formData;
}
export function getFormConfig() {
    let heading = new XHeading();
    heading.text = "Person Information";
    heading.type = "h3";
    let label = new XLabel();
    label.text = " Enter Information Below";
    let composite2 = new XTextField();
    composite2.label = "first name";
    composite2.valueName = "firstName";
    let composite3 = new XTextField();
    composite3.label = "last name";
    composite3.valueName = "lastName";
    let composite4 = new XTextField();
    composite4.label = "full name";
    composite4.valueName = "fullName";
    let compositeCheckbox = new XCheckboxField();
    compositeCheckbox.label = "Is Male";
    compositeCheckbox.valueName = "isMale";
    let numberBox = new XNumberBox();
    numberBox.label = "Age";
    numberBox.valueName = "age";
    let compositeCheckList = new XCheckboxList();
    compositeCheckList.label = "Software Used";
    compositeCheckList.list = ["Upwork", "Hubstaff", "Google Sites"];
    let selectBox = new XSelectbox();
    selectBox.valueName = "selectLabel";
    selectBox.list = ["Pizza", "Cake", "Beer", "Candy"];
    let textbox = new XMultiLineTextEdit();
    textbox.valueName = "personDescription";
    textbox.rowMax = 20;
    textbox.rowMin = 7;
    textbox.placeholderText = "enter description of person";
    let radioButtonGroup = new XRadioGroup();
    radioButtonGroup.valueName = "tester";
    radioButtonGroup.label = "Happy to be tester";
    radioButtonGroup.list = ["Yes", "No", "Indifferent"];
    let tagGroup = new XTagGroup();
    tagGroup.label = "Categories";
    tagGroup.valueName = "Categories";
    tagGroup.list = ["Upwork", "Hubstaff", "Appglue"];
    let button = new XButton();
    button.label = "Submit";
    let button2 = new XButton();
    button.label = "Cancel";
    let link = new XLink();
    link.label = "Test Link";
    link.size = ButtonControlSize.STANDARD;
    let switchMe = new XSwitch();
    switchMe.label = "isAlive";
    switchMe.valueName = "isAlive";
    let datePicker = new XDatePicker();
    datePicker.label = "Birthday";
    datePicker.valueName = "birthday";
    let timePicker = new XTimePicker();
    timePicker.label = "Favorite Time Of Day";
    timePicker.valueName = "favoriteTime";
    let slider = new XSlider();
    slider.step = 10;
    slider.min = 0;
    slider.max = 100;
    slider.label = "Skill Level";
    slider.valueName = "skillLevel";
    let rating = new XRating();
    rating.label = "Please rate";
    rating.valueName = "rating";
    let buttonGroup = new XButtonGroup();
    buttonGroup.label = "Skills";
    buttonGroup.valueName = "skills";
    buttonGroup.list = ["React", "Typescript", "NodeJS"];
    let listEntry = new XListEntry();
    listEntry.label = "List";
    listEntry.valueName = "list";
    let inlineTextEdit = new XInlineTextEdit();
    inlineTextEdit.label = "Label";
    inlineTextEdit.valueName = "label";
    let multiInlineTextEdit = new XMultiInlineTextEdit();
    let valueSlider = new XValueSlider();
    let timeline = new XTimeline();
    let imageControl = new XImageControl();
    let dataGrid = new XDataGrid();
    let colContainer = new XColumnContainer();
    colContainer.lineBetweenColumns = false;
    let container1 = new XColumnContainerColumn();
    container1.targetWidth = 20;
    container1.widthUnit = WidthUnitInterface.PERCENTAGE;
    colContainer.add(container1);
    [1, 2, 3].map((value) => {
        let composite = new XTextField();
        composite.label = "Facts " + value;
        composite.valueName = "otherdata_" + value;
        container1.add(composite);
        return value;
    });
    let container2 = new XColumnContainerColumn();
    container2.targetWidth = 70;
    container2.widthUnit = WidthUnitInterface.PERCENTAGE;
    colContainer.add(container2);
    [1, 2, 3].map((value) => {
        let composite = new XTextField();
        composite.label = "Other Facts " + value;
        composite.valueName = "otherdata2_" + value;
        container2.add(composite);
        return value;
    });
    let container3 = new XColumnContainerColumn();
    container3.targetWidth = 20;
    container3.overrideFormBorderSettings = DefaultOnOff.On;
    container3.showColumnBorder = true;
    container3.widthUnit = WidthUnitInterface.PERCENTAGE;
    colContainer.add(container3);
    [1, 2, 3].map((value) => {
        let composite = new XTextField();
        composite.label = "More Facts " + value;
        composite.valueName = "otherdata3_" + value;
        container3.add(composite);
        return value;
    });
    let container = new XStackContainer();
    container.add(label);
    container.add(composite2);
    container.add(composite3);
    container.add(composite4);
    container.add(switchMe);
    container.add(numberBox);
    container.add(compositeCheckbox);
    container.add(selectBox);
    container.add(textbox);
    container.add(radioButtonGroup);
    container.add(compositeCheckList);
    container.add(datePicker);
    container.add(timePicker);
    container.add(slider);
    container.add(rating);
    container.add(buttonGroup);
    container.add(listEntry);
    container.add(tagGroup);
    container.add(inlineTextEdit);
    container.add(multiInlineTextEdit);
    container.add(valueSlider);
    container.add(timeline);
    container.add(imageControl);
    container.add(dataGrid);
    let headingContainer = new XStackContainer();
    headingContainer.add(heading);
    let hstack1 = new XHStackContainer();
    hstack1.add(button);
    hstack1.add(button2);
    let hstack2 = new XHStackContainer();
    hstack2.add(link);
    let ui = new XFormConfiguration([headingContainer, container, colContainer, hstack1, hstack2]);
    // todo: come back here
    //ui.setFormData(formData);
    // test code to start the process of writing out a json representation of the form
    try {
        let s = JSON.stringify(ui.getStorageData(), null, 2);
        // console.log('************ Written Out *************');
        // console.log( s);
        // console.log('************ Written Out *************');
        let sasobj = JSON.parse(s);
        let newUI = new XFormConfiguration();
        newUI.setStorageData(sasobj);
        // console.log(newUI);
        //        let news =
        JSON.stringify(newUI.getStorageData(), null, 2);
        // console.log('************ READ IN - Written Out *************');
        // console.log( news);
        // console.log('************ READ IN -  Written Out *************');
        //   return newUI;
    }
    catch (_a) {
        console.log(ui.getStorageData());
    }
    return ui;
}
export const getDataDefinitionForRulePage = () => {
    let data = new XDataDefinition();
    data.fields.push(new BooleanDataDefinition("isEmployee"));
    data.fields.push(new NumberDataDefinition("income"));
    data.fields.push(new NumberDataDefinition("divideValue"));
    data.fields.push(new NumberDataDefinition("divideBy"));
    let person = new ObjectDataDefinition("person");
    person.fields.push(new StringDataDefinition("name"));
    data.fields.push(person);
    return data;
};
export const getFormRules = () => {
    const validationRule = new FormRule(new XExpressionDefinition());
    validationRule.expression = getEqualSimpleRule();
    validationRule.data = new FormRuleValidationData('Test Validation Message', 'lastName');
    const changeFocusRule = new FormRule(new XExpressionDefinition());
    changeFocusRule.expression = getEqualSimpleRule();
    changeFocusRule.ruleType = FormRuleType.CHANGE_FOCUS;
    changeFocusRule.data = new FormRuleChangeFocusData('age');
    const changeValueRule = new FormRule(new XExpressionDefinition());
    changeValueRule.expression = getEqualSimpleRule();
    changeValueRule.ruleType = FormRuleType.CHANGE_VALUE;
    changeValueRule.data = new FormRuleChangeValueData('personDescription', getCombineSimpleRule());
    const controlEnabledRule = new FormRule(new XExpressionDefinition());
    controlEnabledRule.expression = getEqualSimpleRule();
    controlEnabledRule.ruleType = FormRuleType.CONTROL_ENABLED;
    controlEnabledRule.data = new FormRuleControlEnabledData('isMale');
    const controlVisibilityRule = new FormRule(new XExpressionDefinition());
    controlVisibilityRule.expression = getEqualSimpleRule();
    controlVisibilityRule.ruleType = FormRuleType.CONTROL_VISIBILITY;
    controlVisibilityRule.data = new FormRuleControlVisibilityData('isMale');
    const exitFormRule = new FormRule(new XExpressionDefinition());
    exitFormRule.expression = getEqualSimpleRule();
    exitFormRule.ruleType = FormRuleType.EXIT_FORM;
    exitFormRule.data = new FormRuleExitFormData('person');
    return [validationRule, changeFocusRule, changeValueRule, controlEnabledRule, controlVisibilityRule, exitFormRule];
};
//# sourceMappingURL=FormTestData.js.map