survey-creator-react
Version:
A white-label drag-and-drop form builder for React that lets you design complex, interactive forms and surveys without writing code. It generates JSON schemas used by the SurveyJS Form Library to render dynamic forms in your React app.
926 lines (902 loc) • 225 kB
JavaScript
/*!
* SurveyJS Creator v2.5.27
* (c) 2015-2026 Devsoft Baltic OÜ - http://surveyjs.io/
* Github: https://github.com/surveyjs/survey-creator
* License: https://surveyjs.io/Licenses#SurveyCreator
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('survey-react-ui'), require('survey-creator-core'), require('react-dom'), require('survey-core')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', 'survey-react-ui', 'survey-creator-core', 'react-dom', 'survey-core'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SurveyCreator = {}, global.React, global.SurveyReact, global.SurveyCreatorCore, global.ReactDOM, global.Survey));
})(this, (function (exports, React, surveyReactUi, surveyCreatorCore, ReactDOM, surveyCore) { 'use strict';
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
var TabbedMenuComponent = /** @class */ (function (_super) {
__extends(TabbedMenuComponent, _super);
function TabbedMenuComponent(props) {
var _this = _super.call(this, props) || this;
_this.rootRef = React__namespace.createRef();
return _this;
}
Object.defineProperty(TabbedMenuComponent.prototype, "model", {
get: function () {
return this.props.model;
},
enumerable: false,
configurable: true
});
TabbedMenuComponent.prototype.getStateElement = function () {
return this.model;
};
TabbedMenuComponent.prototype.renderElement = function () {
var items = this.model.renderedActions.map(function (item) { return React__namespace.createElement(TabbedMenuItemWrapper, { item: item, key: item.renderedId }); });
return (React__namespace.createElement("div", { ref: this.rootRef, className: "svc-tabbed-menu", role: "tablist", style: this.model.getRootStyle() }, items));
};
TabbedMenuComponent.prototype.componentDidUpdate = function (prevProps, prevState) {
_super.prototype.componentDidUpdate.call(this, prevProps, prevState);
var container = this.rootRef.current;
if (!container)
return;
this.model.initResponsivityManager(container);
};
TabbedMenuComponent.prototype.componentDidMount = function () {
_super.prototype.componentDidMount.call(this);
var container = this.rootRef.current;
if (!container)
return;
this.model.initResponsivityManager(container);
};
TabbedMenuComponent.prototype.componentWillUnmount = function () {
this.model.resetResponsivityManager();
_super.prototype.componentWillUnmount.call(this);
};
return TabbedMenuComponent;
}(surveyReactUi.SurveyElementBase));
var TabbedMenuItemWrapper = /** @class */ (function (_super) {
__extends(TabbedMenuItemWrapper, _super);
function TabbedMenuItemWrapper(props) {
var _this = _super.call(this, props) || this;
_this.ref = React__namespace.createRef();
_this.state = { changed: 0 };
return _this;
}
Object.defineProperty(TabbedMenuItemWrapper.prototype, "item", {
get: function () {
return this.props.item;
},
enumerable: false,
configurable: true
});
TabbedMenuItemWrapper.prototype.getStateElement = function () {
return this.item;
};
TabbedMenuItemWrapper.prototype.renderElement = function () {
var css = "svc-tabbed-menu-item-container";
if (this.item.css) {
css += " " + this.item.css;
}
css += (!this.item.isVisible ? " sv-action--hidden" : "");
var component = surveyReactUi.ReactElementFactory.Instance.createElement(this.item.component || "svc-tabbed-menu-item", { item: this.item });
return (React__namespace.createElement("span", { key: this.item.id, className: css, ref: this.ref },
React__namespace.createElement("div", { className: "sv-action__content" }, component)));
};
TabbedMenuItemWrapper.prototype.componentDidMount = function () {
var _this = this;
_super.prototype.componentDidMount.call(this);
this.item.updateModeCallback = function (mode, callback) {
var update = function () {
if (_this.item.mode == mode) {
_this.setState({ changed: _this.state.changed + 1 });
}
else {
_this.item.mode = mode;
}
};
queueMicrotask(function () {
if (ReactDOM__namespace["flushSync"]) {
ReactDOM__namespace["flushSync"](function () {
update();
});
}
else {
update();
}
queueMicrotask(function () {
callback(mode, _this.ref.current);
});
});
};
this.item.afterRender();
};
TabbedMenuItemWrapper.prototype.componentWillUnmount = function () {
_super.prototype.componentWillUnmount.call(this);
this.item.updateModeCallback = undefined;
};
return TabbedMenuItemWrapper;
}(surveyReactUi.SurveyElementBase));
var TabbedMenuItemComponent = /** @class */ (function (_super) {
__extends(TabbedMenuItemComponent, _super);
function TabbedMenuItemComponent() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(TabbedMenuItemComponent.prototype, "item", {
get: function () {
return this.props.item;
},
enumerable: false,
configurable: true
});
TabbedMenuItemComponent.prototype.getStateElement = function () {
return this.item;
};
TabbedMenuItemComponent.prototype.render = function () {
var item = this.item;
return (surveyReactUi.attachKey2click(React__namespace.createElement("div", { role: "tab", id: "tab-" + item.id, "aria-selected": item.active, "aria-controls": "scrollableDiv-" + item.id, className: item.getRootCss(), onClick: function () { return item.doAction(); } },
item.hasTitle ? React__namespace.createElement("span", { className: item.getTitleCss() }, item.title) : null,
item.hasIcon ? React__namespace.createElement(surveyReactUi.SvgIcon, { iconName: item.iconName, className: item.getIconCss(), size: "auto", title: item.tooltip || item.title }) : null)));
};
return TabbedMenuItemComponent;
}(surveyReactUi.SurveyElementBase));
surveyReactUi.ReactElementFactory.Instance.registerElement("svc-tabbed-menu-item", function (props) {
return React__namespace.createElement(TabbedMenuItemComponent, props);
});
var SurveyCreatorComponent = /** @class */ (function (_super) {
__extends(SurveyCreatorComponent, _super);
function SurveyCreatorComponent(props) {
var _this = _super.call(this, props) || this;
_this.rootNode = React__namespace.createRef();
return _this;
}
Object.defineProperty(SurveyCreatorComponent.prototype, "creator", {
get: function () {
return this.props.creator;
},
enumerable: false,
configurable: true
});
SurveyCreatorComponent.prototype.getStateElement = function () {
return this.creator;
};
Object.defineProperty(SurveyCreatorComponent.prototype, "style", {
get: function () {
return this.props.style;
},
enumerable: false,
configurable: true
});
SurveyCreatorComponent.prototype.componentDidUpdate = function (prevProps, prevState) {
_super.prototype.componentDidUpdate.call(this, prevProps, prevState);
if (this.creator !== prevProps.creator) {
if (prevProps.creator) {
prevProps.creator.unsubscribeRootElement();
}
if (this.creator && this.rootNode.current) {
this.creator.setRootElement(this.rootNode.current);
}
}
};
SurveyCreatorComponent.prototype.componentDidMount = function () {
_super.prototype.componentDidMount.call(this);
this.creator.setRootElement(this.rootNode.current);
};
SurveyCreatorComponent.prototype.componentWillUnmount = function () {
_super.prototype.componentWillUnmount.call(this);
this.creator.unsubscribeRootElement();
};
SurveyCreatorComponent.prototype.renderElement = function () {
var creator = this.props.creator;
if (creator.isCreatorDisposed)
return null;
var areaClassName = "svc-full-container svc-creator__area svc-flex-column" + (this.props.creator.haveCommercialLicense ? "" : " svc-creator__area--with-banner");
var contentWrapperClassName = "svc-creator__content-wrapper svc-flex-row" + (this.props.creator.isMobileView ? " svc-creator__content-wrapper--footer-toolbar" : "");
var fullContainerClassName = "svc-flex-row svc-full-container" + (" svc-creator__side-bar--" + this.creator.sidebarLocation);
var creatorStyles = {};
surveyCreatorCore.assign(creatorStyles, this.style, this.props.creator.themeVariables);
var licenseBanner = null;
if (!this.props.creator.haveCommercialLicense) {
var htmlValue = { __html: this.props.creator.licenseText };
licenseBanner = (React__namespace.createElement("div", { className: "svc-creator__banner" },
React__namespace.createElement("span", { className: "svc-creator__non-commercial-text", dangerouslySetInnerHTML: htmlValue })));
}
//AM: width unrecognized by react
return (React__namespace.createElement("div", { className: this.creator.getRootCss(), ref: this.rootNode, style: creatorStyles },
React__namespace.createElement(surveyReactUi.SvgBundleComponent, null),
React__namespace.createElement(surveyReactUi.PopupModal, null),
React__namespace.createElement("div", { className: areaClassName },
React__namespace.createElement("div", { className: fullContainerClassName },
React__namespace.createElement("div", { className: "svc-flex-column svc-flex-row__element svc-flex-row__element--growing" },
React__namespace.createElement("div", { className: "svc-top-bar" },
(creator.showTabs ?
React__namespace.createElement("div", { className: "svc-tabbed-menu-wrapper" },
React__namespace.createElement(TabbedMenuComponent, { model: creator.tabbedMenu })) : null),
(creator.showToolbar ?
React__namespace.createElement("div", { className: "svc-toolbar-wrapper" },
React__namespace.createElement(surveyReactUi.SurveyActionBar, { model: creator.toolbar }))
: null)),
React__namespace.createElement("div", { className: contentWrapperClassName },
React__namespace.createElement("div", { className: "svc-creator__content-holder svc-flex-column" }, this.renderActiveTab())),
React__namespace.createElement("div", { className: "svc-footer-bar" }, (creator.isMobileView ?
React__namespace.createElement("div", { className: "svc-toolbar-wrapper" },
React__namespace.createElement(surveyReactUi.SurveyActionBar, { model: creator.footerToolbar }))
: null))),
this.renderSidebar()),
licenseBanner,
React__namespace.createElement(surveyReactUi.NotifierComponent, { notifier: creator.notifier }))));
};
SurveyCreatorComponent.prototype.renderActiveTab = function () {
var creator = this.props.creator;
return this.renderCreatorTab(creator.activeTabMenuItem);
};
SurveyCreatorComponent.prototype.renderCreatorTab = function (tab) {
if (!tab)
return null;
var creator = this.props.creator;
var component = !!tab.renderTab
? tab.renderTab()
: surveyReactUi.ReactElementFactory.Instance.createElement(tab.componentContent, {
creator: creator,
survey: creator.survey,
data: tab.data.model
});
var className = "svc-creator-tab" + (creator.toolboxLocation == "right" ? " svc-creator__toolbox--right" : "");
return (React__namespace.createElement("div", { role: "tabpanel", key: tab.id, id: "scrollableDiv-" + tab.id, "aria-labelledby": "tab-" + tab.id, className: className }, component));
};
SurveyCreatorComponent.prototype.renderSidebar = function () {
if (!!this.creator.isSidebarVisible) {
return surveyReactUi.ReactElementFactory.Instance.createElement("svc-side-bar", { model: this.creator.sidebar });
}
else {
return null;
}
};
return SurveyCreatorComponent;
}(surveyReactUi.SurveyElementBase));
var SurveyCreator = /** @class */ (function (_super) {
__extends(SurveyCreator, _super);
function SurveyCreator(options, options2) {
if (options === void 0) { options = {}; }
return _super.call(this, options, options2) || this;
}
SurveyCreator.prototype.render = function (target) {
// eslint-disable-next-line no-console
console.error("The render method is deprecated. Use SurveyCreatorComponent instead.");
};
//ISurveyCreator
SurveyCreator.prototype.createQuestionElement = function (question) {
return surveyReactUi.ReactQuestionFactory.Instance.createQuestion(question.isDefaultRendering()
? question.getTemplate()
: question.getComponentName(), {
question: question,
isDisplayMode: question.isReadOnly,
creator: this
});
};
SurveyCreator.prototype.renderError = function (key, error, cssClasses) {
return (React__namespace.createElement("div", { key: key },
React__namespace.createElement("span", { className: cssClasses.error.icon, "aria-hidden": "true" }),
React__namespace.createElement("span", { className: cssClasses.error.item },
React__namespace.createElement(surveyReactUi.SurveyLocStringViewer, { model: error.locText }))));
};
SurveyCreator.prototype.questionTitleLocation = function () {
return this.survey.questionTitleLocation;
};
SurveyCreator.prototype.questionErrorLocation = function () {
return this.survey.questionErrorLocation;
};
return SurveyCreator;
}(surveyCreatorCore.SurveyCreatorModel));
surveyReactUi.ReactElementFactory.Instance.registerElement("survey-widget", function (props) {
return React__namespace.createElement(surveyReactUi.Survey, props);
});
var CreatorModelElement = /** @class */ (function (_super) {
__extends(CreatorModelElement, _super);
function CreatorModelElement(props) {
var _this = _super.call(this, props) || this;
_this.createModel(props);
return _this;
}
CreatorModelElement.prototype.shouldComponentUpdate = function (nextProps, nextState) {
var result = _super.prototype.shouldComponentUpdate.call(this, nextProps, nextState);
if (result) {
if (this.needUpdateModel(nextProps)) {
this.createModel(nextProps);
}
}
return result;
};
CreatorModelElement.prototype.createModel = function (props) { };
CreatorModelElement.prototype.needUpdateModel = function (nextProps) {
var names = this.getUpdatedModelProps();
if (!Array.isArray(names))
return true;
var _loop_1 = function () {
var key = names[i];
if (typeof key === "object") {
var currentProp_1 = this_1.props[key.name];
var nextProp_1 = nextProps[key.name];
if (key.deepEqual) {
if (this_1.props[key.name] === nextProps[key.name])
return { value: false };
var currentPropKeys = Object.keys(currentProp_1 || {});
if (currentPropKeys.length !== Object.keys(nextProp_1 || {}).length)
return { value: true };
return { value: currentPropKeys.some(function (key) { return currentProp_1[key] != nextProp_1[key]; }) };
}
else {
return { value: currentProp_1 !== nextProp_1 };
}
}
else {
if (this_1.props[key] !== nextProps[key])
return { value: true };
}
};
var this_1 = this;
for (var i = 0; i < names.length; i++) {
var state_1 = _loop_1();
if (typeof state_1 === "object")
return state_1.value;
}
return false;
};
CreatorModelElement.prototype.getUpdatedModelProps = function () {
return undefined;
};
return CreatorModelElement;
}(surveyReactUi.SurveyElementBase));
var RowWrapper = /** @class */ (function (_super) {
__extends(RowWrapper, _super);
function RowWrapper(props) {
return _super.call(this, props) || this;
}
RowWrapper.prototype.createModel = function (props) {
if (!!this.model) {
this.model.dispose();
}
this.model = new surveyCreatorCore.RowViewModel(props.componentData.creator, props.row, null);
};
RowWrapper.prototype.getUpdatedModelProps = function () {
return ["row", { name: "componentData", deepEqual: true }];
};
RowWrapper.prototype.getStateElement = function () {
return this.model;
};
RowWrapper.prototype.componentDidMount = function () {
_super.prototype.componentDidMount.call(this);
this.model.subscribeElementChanges();
};
RowWrapper.prototype.componentWillUnmount = function () {
this.model.unsubscribeElementChanges();
_super.prototype.componentWillUnmount.call(this);
};
RowWrapper.prototype.render = function () {
return (React__namespace.createElement("div", { key: "svc-row-" + this.props.row.id, className: this.model.cssClasses },
React__namespace.createElement("div", { className: "svc-row__drop-indicator svc-row__drop-indicator--top" }),
React__namespace.createElement("div", { className: "svc-row__drop-indicator svc-row__drop-indicator--bottom" }),
this.props.element));
};
return RowWrapper;
}(CreatorModelElement));
surveyReactUi.ReactElementFactory.Instance.registerElement("svc-row", function (props) {
return React__namespace.createElement(RowWrapper, props);
});
var ReactMouseEvent = /** @class */ (function () {
function ReactMouseEvent(event) {
this.event = event;
}
ReactMouseEvent.prototype.stopPropagation = function () {
this.event.stopPropagation();
//this.event.nativeEvent.stopPropagation();
//this.event.nativeEvent.stopImmediatePropagation();
};
ReactMouseEvent.prototype.preventDefault = function () {
this.event.preventDefault();
//this.event.nativeEvent.preventDefault();
};
Object.defineProperty(ReactMouseEvent.prototype, "cancelBubble", {
get: function () {
//return this.event.cancelBubble;
return false;
},
set: function (value) {
//this.event.cancelBubble = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ReactMouseEvent.prototype, "target", {
get: function () {
return this.event.target;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ReactMouseEvent.prototype, "currentTarget", {
get: function () {
return this.event.currentTarget;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ReactMouseEvent.prototype, "clientX", {
get: function () {
return this.event.clientX;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ReactMouseEvent.prototype, "clientY", {
get: function () {
return this.event.clientY;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ReactMouseEvent.prototype, "offsetX", {
get: function () {
return this.event.nativeEvent.offsetX;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ReactMouseEvent.prototype, "offsetY", {
get: function () {
return this.event.nativeEvent.offsetY;
},
enumerable: false,
configurable: true
});
return ReactMouseEvent;
}());
var ReactDragEvent = /** @class */ (function (_super) {
__extends(ReactDragEvent, _super);
function ReactDragEvent(event) {
var _this = _super.call(this, event) || this;
_this.event = event;
return _this;
}
Object.defineProperty(ReactDragEvent.prototype, "dataTransfer", {
get: function () {
return this.event.dataTransfer;
},
enumerable: false,
configurable: true
});
return ReactDragEvent;
}(ReactMouseEvent));
function QuestionElementContentFunc(props) {
return props.element;
}
var QuestionElementContent = React__namespace.memo(QuestionElementContentFunc);
QuestionElementContent.displayName = "QuestionElementContent";
var QuestionAdornerComponent = /** @class */ (function (_super) {
__extends(QuestionAdornerComponent, _super);
function QuestionAdornerComponent(props) {
var _this = _super.call(this, props) || this;
_this.rootRef = React__namespace.createRef();
return _this;
}
QuestionAdornerComponent.prototype.createModel = function (props) {
if (this.model) {
this.model.attachToUI(props.question, this.rootRef.current);
}
else {
this.modelValue = this.createQuestionViewModel(props);
}
};
QuestionAdornerComponent.prototype.createQuestionViewModel = function (props) {
return new surveyCreatorCore.QuestionAdornerViewModel(props.componentData, props.question, null);
};
QuestionAdornerComponent.prototype.getUpdatedModelProps = function () {
return ["question", "componentData"];
};
Object.defineProperty(QuestionAdornerComponent.prototype, "model", {
get: function () {
return this.modelValue;
},
enumerable: false,
configurable: true
});
QuestionAdornerComponent.prototype.getStateElement = function () {
return this.model;
};
QuestionAdornerComponent.prototype.renderElement = function () {
var _this = this;
var allowInteractions = this.model.element
.isInteractiveDesignElement;
var titleForCollapsedState = this.renderQuestionTitle();
var content = this.renderContent(allowInteractions);
return (React__namespace.createElement("div", { ref: this.rootRef, "data-sv-drop-target-survey-element": this.model.element.name || null, className: this.model.rootCss(), onDoubleClick: function (e) { allowInteractions && _this.model.dblclick(e.nativeEvent); e.stopPropagation(); }, onMouseLeave: function (e) { return allowInteractions && _this.model.hover(e.nativeEvent, e.currentTarget); }, onMouseOver: function (e) { return allowInteractions && _this.model.hover(e.nativeEvent, e.currentTarget); } },
titleForCollapsedState,
content));
};
QuestionAdornerComponent.prototype.disableTabStop = function () {
return true;
};
QuestionAdornerComponent.prototype.renderContent = function (allowInteractions) {
var _this = this;
var content = this.model.needToRenderContent ? this.renderElementContent() : null;
//if (!allowInteractions) return <>{content}{this.renderFooter()}</>;
return surveyReactUi.attachKey2click(React__namespace.createElement("div", { className: this.model.css(), onClick: function (e) { return _this.model.select(_this.model, new ReactMouseEvent(e)); } },
React__namespace.createElement("div", { className: "svc-question__drop-indicator svc-question__drop-indicator--left" }),
React__namespace.createElement("div", { className: "svc-question__drop-indicator svc-question__drop-indicator--right" }),
React__namespace.createElement("div", { className: "svc-question__drop-indicator svc-question__drop-indicator--top" }),
React__namespace.createElement("div", { className: "svc-question__drop-indicator svc-question__drop-indicator--bottom" }),
allowInteractions ? this.renderHeader() : null,
content,
this.model.needToRenderContent ? this.renderFooter() : null), undefined, { disableTabStop: this.disableTabStop() });
};
QuestionAdornerComponent.prototype.renderHeader = function () {
return surveyReactUi.ReactElementFactory.Instance.createElement("svc-question-header", { model: this.model });
};
QuestionAdornerComponent.prototype.renderFooter = function () {
var allowInteractions = this.model.element
.isInteractiveDesignElement;
return allowInteractions ? surveyReactUi.ReactElementFactory.Instance.createElement("svc-question-footer", { className: "svc-question__content-actions", model: this.model }) : null;
};
QuestionAdornerComponent.prototype.renderCarryForwardBanner = function () {
if (!this.model.isBannerShowing)
return null;
return surveyReactUi.ReactElementFactory.Instance.createElement("svc-question-banner", this.model.createBannerParams());
};
QuestionAdornerComponent.prototype.renderQuestionTitle = function () {
var _this = this;
if (!this.model.showHiddenTitle)
return null;
var element = this.model.element;
return (React__namespace.createElement("div", { ref: function (node) { return node && (!_this.model.renderedCollapsed ?
node.setAttribute("inert", "") : node.removeAttribute("inert")); }, className: this.model.cssCollapsedHiddenHeader }, (element.hasTitle ?
React__namespace.createElement(surveyReactUi.TitleElement, { element: element, renderActions: false }) :
React__namespace.createElement("div", { className: this.model.cssCollapsedHiddenTitle },
React__namespace.createElement("span", { className: "svc-fake-title" }, element.name)))));
};
QuestionAdornerComponent.prototype.renderElementContent = function () {
return (React__namespace.createElement(React__namespace.Fragment, null,
React__namespace.createElement(QuestionElementContent, { element: this.props.element }),
this.renderElementPlaceholder(),
this.renderCarryForwardBanner()));
};
QuestionAdornerComponent.prototype.componentDidMount = function () {
_super.prototype.componentDidMount.call(this);
this.model.attachToUI(this.props.question, this.rootRef.current);
};
QuestionAdornerComponent.prototype.renderElementPlaceholder = function () {
if (!this.model.isEmptyElement) {
return null;
}
return (React__namespace.createElement("div", { className: "svc-panel__placeholder_frame-wrapper" },
React__namespace.createElement("div", { className: "svc-panel__placeholder_frame" },
React__namespace.createElement("div", { className: "svc-panel__placeholder" }, this.model.placeholderText))));
};
QuestionAdornerComponent.prototype.componentWillUnmount = function () {
_super.prototype.componentWillUnmount.call(this);
this.model.detachFromUI();
};
return QuestionAdornerComponent;
}(CreatorModelElement));
surveyReactUi.ReactElementFactory.Instance.registerElement("svc-question", function (props) {
return React__namespace.createElement(QuestionAdornerComponent, props);
});
var QuestionWrapperHeader = /** @class */ (function (_super) {
__extends(QuestionWrapperHeader, _super);
function QuestionWrapperHeader() {
return _super !== null && _super.apply(this, arguments) || this;
}
QuestionWrapperHeader.prototype.render = function () {
var _this = this;
if (!this.props.model.allowDragging)
return null;
return (React__namespace.createElement("div", { className: "svc-question__drag-area", onPointerDown: function (event) {
return _this.props.model.onPointerDown(event);
} },
React__namespace.createElement(surveyReactUi.SvgIcon, { className: "svc-question__drag-element", size: "auto", iconName: "icon-drag-area-indicator_24x16" }),
React__namespace.createElement("div", { className: "svc-question__top-actions" },
React__namespace.createElement(surveyReactUi.SurveyActionBar, { model: this.props.model.topActionContainer, handleClick: false }))));
};
return QuestionWrapperHeader;
}(React__namespace.Component));
surveyReactUi.ReactElementFactory.Instance.registerElement("svc-question-header", function (props) {
return React__namespace.createElement(QuestionWrapperHeader, props);
});
var QuestionWrapperFooter = /** @class */ (function (_super) {
__extends(QuestionWrapperFooter, _super);
function QuestionWrapperFooter() {
return _super !== null && _super.apply(this, arguments) || this;
}
QuestionWrapperFooter.prototype.render = function () {
var _this = this;
return (React__namespace.createElement("div", { className: this.props.className, onFocus: function (e) { return _this.props.model.select(_this.props.model, new ReactMouseEvent(e)); } },
React__namespace.createElement(surveyReactUi.SurveyActionBar, { model: this.props.model.actionContainer, handleClick: false })));
};
return QuestionWrapperFooter;
}(React__namespace.Component));
surveyReactUi.ReactElementFactory.Instance.registerElement("svc-question-footer", function (props) {
return React__namespace.createElement(QuestionWrapperFooter, props);
});
var ActionButton = /** @class */ (function (_super) {
__extends(ActionButton, _super);
function ActionButton() {
return _super !== null && _super.apply(this, arguments) || this;
}
ActionButton.prototype.renderElement = function () {
var classes = new surveyCore.CssClassBuilder()
.append(this.props.classes)
.append("svc-action-button")
.append("svc-action-button--selected", !!this.props.selected)
.append("svc-action-button--disabled", !!this.props.disabled)
.toString();
if (this.props.iconName) {
return this.renderIcon(classes);
}
return this.renderButtonText(classes);
};
ActionButton.prototype.renderButtonText = function (classes) {
var _this = this;
if (this.props.disabled) {
return React__namespace.createElement("span", { className: classes }, this.props.text);
}
return (React__namespace.createElement(React__namespace.Fragment, null, surveyReactUi.attachKey2click(React__namespace.createElement("span", { role: "button", className: classes, onClick: function (e) {
if (!_this.props.allowBubble) {
e.stopPropagation();
}
_this.props.click();
}, title: this.props.title }, this.props.text))));
};
ActionButton.prototype.renderIcon = function (classes) {
var _this = this;
classes += " svc-action-button--icon";
if (this.props.disabled) {
return React__namespace.createElement("span", { className: classes },
React__namespace.createElement(surveyReactUi.SvgIcon, { size: "auto", iconName: this.props.iconName }));
}
return (React__namespace.createElement(React__namespace.Fragment, null, surveyReactUi.attachKey2click(React__namespace.createElement("span", { className: classes, onClick: function (e) {
if (!_this.props.allowBubble) {
e.stopPropagation();
}
_this.props.click();
}, title: this.props.title },
React__namespace.createElement(surveyReactUi.SvgIcon, { size: "auto", iconName: this.props.iconName })))));
};
return ActionButton;
}(surveyReactUi.SurveyElementBase));
surveyReactUi.ReactElementFactory.Instance.registerElement("svc-action-button", function (props) { return React__namespace.createElement(ActionButton, props); });
var QuestionBanner = /** @class */ (function (_super) {
__extends(QuestionBanner, _super);
function QuestionBanner() {
return _super !== null && _super.apply(this, arguments) || this;
}
QuestionBanner.prototype.render = function () {
var _this = this;
return (React__namespace.createElement("div", { className: "svc-carry-forward-panel-wrapper" },
React__namespace.createElement("div", { className: "svc-carry-forward-panel" },
React__namespace.createElement("span", null,
this.props.text,
" "),
React__namespace.createElement("span", { className: "svc-carry-forward-panel__link" },
React__namespace.createElement(ActionButton, { click: function () { return _this.props.onClick(); }, text: this.props.actionText })))));
};
return QuestionBanner;
}(React__namespace.Component));
surveyReactUi.ReactElementFactory.Instance.registerElement("svc-question-banner", function (props) {
return React__namespace.createElement(QuestionBanner, props);
});
var QuestionDropdownAdornerComponent = /** @class */ (function (_super) {
__extends(QuestionDropdownAdornerComponent, _super);
function QuestionDropdownAdornerComponent(props) {
return _super.call(this, props) || this;
}
QuestionDropdownAdornerComponent.prototype.createQuestionViewModel = function (props) {
return new surveyCreatorCore.QuestionDropdownAdornerViewModel(props.componentData, props.question, null);
};
Object.defineProperty(QuestionDropdownAdornerComponent.prototype, "dropdownModel", {
get: function () {
return this.model;
},
enumerable: false,
configurable: true
});
Object.defineProperty(QuestionDropdownAdornerComponent.prototype, "question", {
get: function () {
return this.dropdownModel.question;
},
enumerable: false,
configurable: true
});
QuestionDropdownAdornerComponent.prototype.renderElementPlaceholder = function () {
var _this = this;
var textStyle = this.question.textStyle;
return (React__namespace.createElement("div", { className: "svc-question__dropdown-choices--wrapper" },
React__namespace.createElement("div", null,
React__namespace.createElement("div", { className: "svc-question__dropdown-choices" }, (this.dropdownModel.getRenderedItems() || []).map(function (item, index) { return (React__namespace.createElement("div", { className: _this.dropdownModel.getChoiceCss(), key: "editable_choice_".concat(index) }, surveyReactUi.ReactSurveyElementsWrapper.wrapItemValue(_this.question.survey, surveyReactUi.ReactElementFactory.Instance.createElement(_this.dropdownModel.itemComponent, {
key: item.value,
question: _this.question,
cssClasses: _this.question.cssClasses,
isDisplayMode: true,
item: item,
textStyle: textStyle,
index: index,
isChecked: _this.question.value === item.value
}), _this.question, item))); })),
this.dropdownModel.needToCollapse ?
React__namespace.createElement(ActionButton, { click: this.dropdownModel.switchCollapse, text: this.dropdownModel.getButtonText(), allowBubble: true }) :
null)));
};
return QuestionDropdownAdornerComponent;
}(QuestionAdornerComponent));
surveyReactUi.ReactElementFactory.Instance.registerElement("svc-dropdown-question", function (props) {
return React__namespace.createElement(QuestionDropdownAdornerComponent, props);
});
var QuestionImageAdornerComponent = /** @class */ (function (_super) {
__extends(QuestionImageAdornerComponent, _super);
function QuestionImageAdornerComponent() {
return _super !== null && _super.apply(this, arguments) || this;
}
QuestionImageAdornerComponent.prototype.createQuestionViewModel = function (props) {
return new surveyCreatorCore.QuestionImageAdornerViewModel(props.componentData, props.question, null);
};
Object.defineProperty(QuestionImageAdornerComponent.prototype, "imageModel", {
get: function () {
return this.model;
},
enumerable: false,
configurable: true
});
QuestionImageAdornerComponent.prototype.renderHeader = function () {
return (React__namespace.createElement(React__namespace.Fragment, null,
React__namespace.createElement("input", { type: "file", "aria-hidden": "true", tabIndex: -1, accept: this.imageModel.acceptedTypes, className: "svc-choose-file-input", style: {
position: "absolute",
opacity: 0,
width: "1px",
height: "1px",
overflow: "hidden"
} }),
_super.prototype.renderHeader.call(this)));
};
QuestionImageAdornerComponent.prototype.renderLoadingPlaceholder = function () {
return (React__namespace.createElement("div", { className: "svc-image-question__loading-placeholder" },
React__namespace.createElement("div", { className: "svc-image-question__loading" },
React__namespace.createElement(surveyReactUi.LoadingIndicatorComponent, null))));
};
QuestionImageAdornerComponent.prototype.renderChooseButton = function () {
var _this = this;
return (React__namespace.createElement("div", { className: "svc-image-question-controls" }, this.model.allowEdit ? surveyReactUi.attachKey2click(React__namespace.createElement("span", { className: "svc-context-button", onClick: function () { return _this.imageModel.chooseFile(_this.imageModel); } },
React__namespace.createElement(surveyReactUi.SvgIcon, { size: "auto", iconName: "icon-choosefile" }))) : null));
};
QuestionImageAdornerComponent.prototype.renderElementPlaceholder = function () {
return this.imageModel.isUploading ? this.renderLoadingPlaceholder() : this.renderChooseButton();
};
QuestionImageAdornerComponent.prototype.getStateElements = function () {
return [this.model, this.imageModel.filePresentationModel];
};
QuestionImageAdornerComponent.prototype.renderElementContent = function () {
if (this.imageModel.isEmptyElement) {
var fileQuestion = surveyReactUi.ReactQuestionFactory.Instance.createQuestion("file", {
creator: this.imageModel.question.survey,
isDisplayMode: false,
question: this.imageModel.filePresentationModel
});
return (React__namespace.createElement(React__namespace.Fragment, null, fileQuestion));
}
else {
return (React__namespace.createElement(React__namespace.Fragment, null,
this.props.element,
this.renderElementPlaceholder()));
}
};
return QuestionImageAdornerComponent;
}(QuestionAdornerComponent));
surveyReactUi.ReactElementFactory.Instance.registerElement("svc-image-question", function (props) {
return React__namespace.createElement(QuestionImageAdornerComponent, props);
});
var QuestionRatingAdornerComponent = /** @class */ (function (_super) {
__extends(QuestionRatingAdornerComponent, _super);
function QuestionRatingAdornerComponent() {
return _super !== null && _super.apply(this, arguments) || this;
}
QuestionRatingAdornerComponent.prototype.createModel = function (props) {
this.modelValue = this.createQuestionViewModel(props);
};
QuestionRatingAdornerComponent.prototype.createQuestionViewModel = function (props) {
return new surveyCreatorCore.QuestionRatingAdornerViewModel(props.componentData, props.question, null);
};
QuestionRatingAdornerComponent.prototype.getUpdatedModelProps = function () {
return ["question", "componentData"];
};
Object.defineProperty(QuestionRatingAdornerComponent.prototype, "ratingModel", {
get: function () {
return this.model;
},
enumerable: false,
configurable: true
});
Object.defineProperty(QuestionRatingAdornerComponent.prototype, "model", {
get: function () {
return this.modelValue;
},
enumerable: false,
configurable: true
});
QuestionRatingAdornerComponent.prototype.getStateElement = function () {
return this.model;
};
QuestionRatingAdornerComponent.prototype.renderElement = function () {
var model = this.ratingModel;
return (React__namespace.createElement(React__namespace.Fragment, null,
React__namespace.createElement("div", { className: "svc-rating-question-content" },
React__namespace.createElement("div", { className: model.controlsClassNames },
model.allowRemove ? surveyReactUi.attachKey2click(React__namespace.createElement("span", { role: "button", className: model.removeClassNames, "aria-label": model.removeTooltip, onClick: function () { return model.removeItem(model); } },
React__namespace.createElement(surveyReactUi.SvgIcon, { size: "auto", iconName: "icon-remove_16x16", title: model.removeTooltip }))) : null,
model.allowAdd ? surveyReactUi.attachKey2click(React__namespace.createElement("span", { role: "button", className: model.addClassNames, "aria-label": model.addTooltip, onClick: function () { return model.addItem(model); } },
React__namespace.createElement(surveyReactUi.SvgIcon, { size: "auto", iconName: "icon-add_16x16", title: model.addTooltip }))) : null),
this.props.element)));
};
return QuestionRatingAdornerComponent;
}(CreatorModelElement));
surveyReactUi.ReactElementFactory.Instance.registerElement("svc-rating-question", function (props) {
return React__namespace.createElement(QuestionRatingAdornerComponent, props);
});
surveyReactUi.ReactElementFactory.Instance.registerElement("svc-rating-question-content", function (props) {
return React__namespace.createElement(QuestionRatingAdornerComponent, props);
});
var QuestionWidgetAdornerComponent = /** @class */ (function (_super) {
__extends(QuestionWidgetAdornerComponent, _super);
function QuestionWidgetAdornerComponent() {
return _super !== null && _super.apply(this, arguments) || this;
}
QuestionWidgetAdornerComponent.prototype.createQuestionViewMod