"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileDownloadStories = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const FormConfiguration_1 = require("../../FormConfiguration");
const FormRuntime_1 = require("../../FormRuntime");
const FileDownloadFormControl_1 = require("../Web/FileDownloadFormControl");
const ObserveState_1 = require("../../../CommonUI/StateManagement/ObserveState");
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");
// 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) => (
//     <ObserveState listenTo={args} properties={["formData"]} control={() => <XUserForm {...args} />} />
// );
function getUI() {
    let ui = new FormConfiguration_1.FormConfiguration();
    let container = new Containers_1.XStackContainer();
    let uploadField = new FileDownloadFormControl_1.FileDownloadFormControl();
    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.FileDownloadStories = [
    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 Download", "Default"),
    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 Download", "Without File Name"),
    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 Download", "With File Name"),
    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 Download", "With Preview"),
    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 Download", "Without 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 Download", "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 Download", "Multiple File"),
];
//# sourceMappingURL=XFileDownload-stories.js.map