import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { InlineRichTextEdit } from "../../CommonUI/InlineRichTextEdit";
import { PropertyEditorText } from "../../CommonUI/PropertyEditing/PropertyEditorText";
import { StyledFormHelperText, StyledInputLabel } from "./XCommonStyled";
import { BaseTextEntryControl } from "./BaseTextEntryControl";
import { StringDataDefinition } from "../../Common/Data/Definitions/StringDataDefinition";
import { PropertyEditorBoolean } from "../../CommonUI/PropertyEditing/PropertyEditorBoolean";
export class XInlineRichTextEditor extends BaseTextEntryControl {
    constructor() {
        super(...arguments);
        this.showToolsOnFocus = false;
        this.exportFileName = "output";
    }
    render() {
        const issueData = this.getFormContext()
            .getControlContext(this)
            .getRuntimeIssueData();
        const issueText = (issueData === null || issueData === void 0 ? void 0 : issueData.text) || "";
        return (_jsxs("div", Object.assign({ style: {
                width: this.fullWidth ? "100%" : `${this.width || 200}px`,
            } }, { children: [this.label && (_jsx(StyledInputLabel, { children: this.label }, void 0)),
                _jsx(InlineRichTextEdit, { value: this.valueName && this.getFormDataValue(this.valueName), updateCallback: (val) => this.valueName &&
                        val !== "" &&
                        this.setFormDataValue(this.valueName, val), placeholder: this.placeholderText || "Label", showToolsOnFocus: this.showToolsOnFocus, exportFileName: this.exportFileName, ref: this.ref }, void 0),
                (issueText || this.hintText) && (_jsx(StyledFormHelperText, Object.assign({ error: Boolean(issueText), "data-testid": "issueOrHintText" }, { children: issueText ? issueText : this.hintText }), void 0))] }), void 0));
    }
    getAddedData() {
        if (!this.valueName)
            return;
        let dd = new StringDataDefinition();
        dd.name = this.valueName;
        return dd;
    }
    renderEditUI() {
        return _jsx(XInlineRichTextEditorUI, { editMe: this }, void 0);
    }
}
function XInlineRichTextEditorUI(props) {
    return (_jsxs(_Fragment, { children: [props.editMe.renderBaseDataControlEditor(['requiredOnAllOutcomes']), _jsx(PropertyEditorBoolean, { editObject: props.editMe, label: "Show Tools On Focus", propertyName: "showToolsOnFocus", updateCallback: props.editMe.controlUpdate }, void 0), props.editMe.renderTextControlBasePropertyEditor(), _jsx(PropertyEditorText, { editObject: props.editMe, label: "Export File Name", propertyName: "exportFileName", updateCallback: props.editMe.controlUpdate }, void 0)] }, void 0));
}
//# sourceMappingURL=XInlineRichTextEditor.js.map