UNPKG

gd-sprest-bs

Version:

SharePoint JavaScript, TypeScript and Web Components designed using the Bootstrap framework.

87 lines (86 loc) 3.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BasePropertyPane = void 0; var core_1 = require("../components/core"); /** * Base Property Pane */ var BasePropertyPane = /** @class */ (function () { // Constructor function BasePropertyPane(targetProperty, config, context) { var _this = this; // Set the type (Custom = 1) this.type = 1; // Save the configuration this._config = config; // Save the key this.targetProperty = targetProperty; // Set the properties this.properties = { key: this.targetProperty, context: context, onDispose: function (el, context) { // Call the events _this.dispose(el, context); _this.onDispose ? _this.onDispose(el, context) : null; }, onRender: function (el, context, onChange) { _this.render(el, context, onChange); _this.onRender ? _this.onRender(el, context, onChange) : null; } }; } Object.defineProperty(BasePropertyPane.prototype, "config", { get: function () { return this._config; }, enumerable: false, configurable: true }); // Applies the tooltip to an element BasePropertyPane.prototype.applyTooltip = function (el) { // Apply the tooltip var content = this._config.tooltip; if (content) { core_1.Components.Tooltip({ target: el, content: content }); } }; Object.defineProperty(BasePropertyPane.prototype, "currentValue", { // Returns the current value as a string get: function () { var properties = this._config.properties; return properties ? properties[this.targetProperty] : undefined; }, enumerable: false, configurable: true }); // Returns the current value as an object BasePropertyPane.prototype.currentValueAsObject = function () { // Ensure a value exists if (this.currentValue) { try { return JSON.parse(this.currentValue); } catch (_a) { } } // Return nothing return undefined; }; // Dispose of the component BasePropertyPane.prototype.onDispose = function (el, context) { }; BasePropertyPane.prototype.dispose = function (el, context) { // Clear the element while (el.firstChild) { el.removeChild(el.firstChild); } }; // Renders the component BasePropertyPane.prototype.onRender = function (el, context, onChange) { }; BasePropertyPane.prototype.render = function (el, context, onChange) { // Clear the component this.dispose(el, context); }; return BasePropertyPane; }()); exports.BasePropertyPane = BasePropertyPane;