"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileUploadStories = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const FormConfiguration_1 = require("../../FormConfiguration");
const FormRuntime_1 = require("../../FormRuntime");
const FileUploadFormControl_1 = require("../Web/FileUploadFormControl");
const ExecutionData_1 = require("@appglue/common/dist/Common/Data/ExecutionData/ExecutionData");
const StateManager_1 = require("@appglue/common/dist/Common/StateManager");
const Containers_1 = require("../../Containers");
const StoryData_1 = require("../../../CommonUI/StoryBook/StoryData");
const ObserveState_1 = require("../../../CommonUI/StateManagement/ObserveState");
// todo: fix. this is the old template.  it should NOT require to listen to the data outside of the form to work.  FIX!
// const Template: StoryBook<IUserFormParameters> = (args) => (
//
// );
function getUI() {
    let ui = new FormConfiguration_1.FormConfiguration();
    let container = new Containers_1.XStackContainer();
    let uploadField = new FileUploadFormControl_1.FileUploadFormControl();
    uploadField.valueName = "upload";
    uploadField.label = "File Upload";
    container.add(uploadField);
    ui.add(container);
    const data = new ExecutionData_1.ExecutionData();
    const result = {
        form: ui,
        onFormDataChange: (_) => {
            StateManager_1.StateManager.propertyChanged(result, "formData");
        },
        formData: data,
    };
    return result;
}
exports.FileUploadStories = [
    new StoryData_1.StoryNode(() => {
        let ui = getUI();
        return (0, jsx_runtime_1.jsx)(ObserveState_1.ObserveState, { listenTo: ui, properties: ["formData"], control: () => (0, jsx_runtime_1.jsx)(FormRuntime_1.FormRuntime, { ...ui }) });
    }, "Form Designer", "Controls", "File Upload", "Default"),
    new StoryData_1.StoryNode(() => {
        let ui = getUI();
        ui.form.getAllControls()[0].showFileName = false;
        return (0, jsx_runtime_1.jsx)(ObserveState_1.ObserveState, { listenTo: ui, properties: ["formData"], control: () => (0, jsx_runtime_1.jsx)(FormRuntime_1.FormRuntime, { ...ui }) });
    }, "Form Designer", "Controls", "File Upload", "Without File Name"),
    new StoryData_1.StoryNode(() => {
        let ui = getUI();
        ui.form.getAllControls()[0].showFileName = true;
        return (0, jsx_runtime_1.jsx)(ObserveState_1.ObserveState, { listenTo: ui, properties: ["formData"], control: () => (0, jsx_runtime_1.jsx)(FormRuntime_1.FormRuntime, { ...ui }) });
    }, "Form Designer", "Controls", "File Upload", "With File Name"),
    new StoryData_1.StoryNode(() => {
        let ui = getUI();
        ui.form.getAllControls()[0].showFileSize = false;
        return (0, jsx_runtime_1.jsx)(ObserveState_1.ObserveState, { listenTo: ui, properties: ["formData"], control: () => (0, jsx_runtime_1.jsx)(FormRuntime_1.FormRuntime, { ...ui }) });
    }, "Form Designer", "Controls", "File Upload", "Without File Size"),
    new StoryData_1.StoryNode(() => {
        let ui = getUI();
        ui.form.getAllControls()[0].showFileSize = true;
        return (0, jsx_runtime_1.jsx)(ObserveState_1.ObserveState, { listenTo: ui, properties: ["formData"], control: () => (0, jsx_runtime_1.jsx)(FormRuntime_1.FormRuntime, { ...ui }) });
    }, "Form Designer", "Controls", "File Upload", "With File Size"),
    new StoryData_1.StoryNode(() => {
        let ui = getUI();
        ui.form.getAllControls()[0].showPreview = false;
        return (0, jsx_runtime_1.jsx)(ObserveState_1.ObserveState, { listenTo: ui, properties: ["formData"], control: () => (0, jsx_runtime_1.jsx)(FormRuntime_1.FormRuntime, { ...ui }) });
    }, "Form Designer", "Controls", "File Upload", "Without Preview"),
    new StoryData_1.StoryNode(() => {
        let ui = getUI();
        ui.form.getAllControls()[0].showPreview = true;
        return (0, jsx_runtime_1.jsx)(ObserveState_1.ObserveState, { listenTo: ui, properties: ["formData"], control: () => (0, jsx_runtime_1.jsx)(FormRuntime_1.FormRuntime, { ...ui }) });
    }, "Form Designer", "Controls", "File Upload", "With Preview"),
    new StoryData_1.StoryNode(() => {
        let ui = getUI();
        ui.form.getAllControls()[0].filesLimit = 1;
        return (0, jsx_runtime_1.jsx)(ObserveState_1.ObserveState, { listenTo: ui, properties: ["formData"], control: () => (0, jsx_runtime_1.jsx)(FormRuntime_1.FormRuntime, { ...ui }) });
    }, "Form Designer", "Controls", "File Upload", "Single File"),
    new StoryData_1.StoryNode(() => {
        let ui = getUI();
        ui.form.getAllControls()[0].filesLimit = 3;
        return (0, jsx_runtime_1.jsx)(ObserveState_1.ObserveState, { listenTo: ui, properties: ["formData"], control: () => (0, jsx_runtime_1.jsx)(FormRuntime_1.FormRuntime, { ...ui }) });
    }, "Form Designer", "Controls", "File Upload", "Multiple Files"),
];
//# sourceMappingURL=XFileUpload-stories.js.map