@luftborn/custom-elements 2.15.7 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/demo/index.min.js CHANGED
@@ -3285,8 +3285,9 @@ var ArrayUtil_1 = require("./framework/Utilities/ArrayUtil");
3285
3285
  var MakeRequest_1 = require("./framework/Utilities/MakeRequest");
3286
3286
  var Elements_1 = require("./elements/Elements");
3287
3287
  var CustomForm = /** @class */ (function () {
3288
- function CustomForm(form) {
3288
+ function CustomForm(form, previewContainerSelector) {
3289
3289
  this.form = form;
3290
+ this.previewContainerSelector = previewContainerSelector;
3290
3291
  this.action = form.action || '';
3291
3292
  this.method = form.method || 'get';
3292
3293
  this.attachForm();
@@ -3381,8 +3382,12 @@ var CustomForm = /** @class */ (function () {
3381
3382
  dependentValues = [dependentValue];
3382
3383
  }
3383
3384
  var customElement = document.forms[0].querySelector("[name=\"" + dependentField + "\"]");
3385
+ if (_this.previewContainerSelector) {
3386
+ var previewContainer = document.querySelector(_this.previewContainerSelector);
3387
+ customElement = previewContainer === null || previewContainer === void 0 ? void 0 : previewContainer.querySelector("[name=\"" + dependentField + "\"]");
3388
+ }
3384
3389
  element.setAttribute("hidden", "");
3385
- customElement.onChange.on(function (event) {
3390
+ customElement === null || customElement === void 0 ? void 0 : customElement.onChange.on(function (event) {
3386
3391
  if (_this.groupShouldBeVisible(event.value, dependentValues)) {
3387
3392
  _this.showGroupAndItsDependencies(element);
3388
3393
  }
@@ -3390,7 +3395,7 @@ var CustomForm = /** @class */ (function () {
3390
3395
  _this.hideGroupAndItsDependencies(element);
3391
3396
  }
3392
3397
  });
3393
- customElement.onVisibilityChanged.on(function (event) {
3398
+ customElement === null || customElement === void 0 ? void 0 : customElement.onVisibilityChanged.on(function (event) {
3394
3399
  var elmentIsHidden = customElement.hasAttribute('hidden');
3395
3400
  if (_this.groupShouldBeVisible(customElement.value, dependentValues) && !elmentIsHidden) {
3396
3401
  _this.showGroupAndItsDependencies(element);
@@ -4059,12 +4064,12 @@ var CheckBoxElement = /** @class */ (function (_super) {
4059
4064
  fieldset = document.createElement('fieldset');
4060
4065
  wrapper.appendChild(fieldset);
4061
4066
  }
4062
- this.options.forEach(function (element, index) {
4063
- var existingCheckbox = fieldset.querySelector("input[value='" + element + "']");
4064
- if (!existingCheckbox) {
4067
+ var optionsAlreadyAdded = fieldset.querySelectorAll('input[type="checkbox"]').length;
4068
+ if (!optionsAlreadyAdded) {
4069
+ this.options.forEach(function (element, index) {
4065
4070
  fieldset.insertAdjacentHTML('beforeend', StringUtil_1.StringUtil.StringFormat(_this.checkboxTemplate, _this.name, element, _this.name + "-" + index));
4066
- }
4067
- });
4071
+ });
4072
+ }
4068
4073
  };
4069
4074
  CheckBoxElement.prototype.addLegend = function () {
4070
4075
  var fieldset = this.shadowRoot.querySelector('fieldset');
@@ -6279,12 +6284,10 @@ var RadioButtonGroupElement = /** @class */ (function (_super) {
6279
6284
  fieldset = document.createElement('fieldset');
6280
6285
  wrapper.appendChild(fieldset);
6281
6286
  }
6282
- if (fieldset.children.length === 0) {
6287
+ var optionsAlreadyAdded = fieldset.querySelectorAll('input[type="radio"]').length;
6288
+ if (!optionsAlreadyAdded) {
6283
6289
  this.options.forEach(function (element, index) {
6284
- var existingRadio = fieldset.querySelector("input[value='" + element + "']");
6285
- if (!existingRadio) {
6286
- fieldset.insertAdjacentHTML('beforeend', StringUtil_1.StringUtil.StringFormat(_this.radioButtonTemplate, _this.name, element, _this.name + "-" + index, "" + (_this.required ? 'required' : '')));
6287
- }
6290
+ fieldset.insertAdjacentHTML('beforeend', StringUtil_1.StringUtil.StringFormat(_this.radioButtonTemplate, _this.name, element, _this.name + "-" + index, "" + (_this.required ? 'required' : '')));
6288
6291
  });
6289
6292
  }
6290
6293
  };
@@ -7159,6 +7162,7 @@ var CustomInputElement = /** @class */ (function (_super) {
7159
7162
  _this.allDependenciesMustBeMet = false;
7160
7163
  _this.multi = false;
7161
7164
  _this.hideLabel = false;
7165
+ _this.designerMode = false;
7162
7166
  _this.compareValues = [];
7163
7167
  return _this;
7164
7168
  }
@@ -7192,6 +7196,11 @@ var CustomInputElement = /** @class */ (function (_super) {
7192
7196
  window.addEventListener("load", function () {
7193
7197
  _this.bindDependencies();
7194
7198
  });
7199
+ if (!this.designerMode) {
7200
+ window.addEventListener("preview-rendered", function () {
7201
+ _this.bindDependencies();
7202
+ });
7203
+ }
7195
7204
  };
7196
7205
  CustomInputElement.prototype.parseData = function () {
7197
7206
  try {
@@ -7246,8 +7255,11 @@ var CustomInputElement = /** @class */ (function (_super) {
7246
7255
  };
7247
7256
  CustomInputElement.prototype.setAttributes = function () {
7248
7257
  this.setAttribute("custom-input", "");
7249
- this.setAttribute("name", this.name);
7250
7258
  this.hideLabel = this.hasAttribute('hide-label') || this.hasAttribute('hideLabel');
7259
+ this.designerMode = this.hasAttribute('designer-mode') || this.hasAttribute('designerMode');
7260
+ if (!this.designerMode) {
7261
+ this.setAttribute("name", this.name);
7262
+ }
7251
7263
  };
7252
7264
  CustomInputElement.prototype.bindDependencies = function () {
7253
7265
  if (this.hasValueDependency && this.hasValueDependency.items.length) {
@@ -7391,9 +7403,12 @@ var CustomInputElement = /** @class */ (function (_super) {
7391
7403
  newLabel.setAttribute('for', inputField.id);
7392
7404
  newLabel.classList.add('field-label');
7393
7405
  newLabel.textContent = this.label + ": ";
7394
- var fieldLabel = this.shadowRoot.querySelector('.field-label');
7395
- if (fieldLabel) {
7396
- fieldLabel.appendChild(newLabel);
7406
+ var fieldLabelDiv = this.shadowRoot.querySelector('.field-label');
7407
+ if (fieldLabelDiv) {
7408
+ var existingLabel = fieldLabelDiv.querySelector('label.field-label');
7409
+ if (!existingLabel) {
7410
+ fieldLabelDiv.appendChild(newLabel);
7411
+ }
7397
7412
  }
7398
7413
  if (this.required) {
7399
7414
  newLabel.innerHTML += '<span style="color: #e00040">*</span>';