@websy/websy-designs 1.9.14 → 1.10.1

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.
@@ -84,6 +84,12 @@ var APIService = /*#__PURE__*/function () {
84
84
  var url = this.buildUrl(entity, id);
85
85
  return this.run('DELETE', url);
86
86
  }
87
+ }, {
88
+ key: "deleteMany",
89
+ value: function deleteMany(entity, query) {
90
+ var url = this.buildUrl(entity, null, query);
91
+ return this.run('DELETE', url);
92
+ }
87
93
  }, {
88
94
  key: "get",
89
95
  value: function get(entity, id, query, offset, limit) {
@@ -95,11 +101,11 @@ var APIService = /*#__PURE__*/function () {
95
101
  url += "?offset=".concat(offset);
96
102
  }
97
103
  }
98
- if (limit) {
104
+ if (limit || this.options.rowLimit) {
99
105
  if (url.indexOf('?') !== -1) {
100
- url += "&limit=".concat(limit);
106
+ url += "&limit=".concat(limit || this.options.rowLimit);
101
107
  } else {
102
- url += "?limit=".concat(limit);
108
+ url += "?limit=".concat(limit || this.options.rowLimit);
103
109
  }
104
110
  }
105
111
  return this.run('GET', url);
@@ -232,16 +238,52 @@ var ButtonGroup = /*#__PURE__*/function () {
232
238
  }
233
239
  }
234
240
  _createClass(ButtonGroup, [{
241
+ key: "value",
242
+ get: function get() {
243
+ if (this.options.activeItem > -1) {
244
+ return [this.options.items[this.options.activeItem]];
245
+ } else if (this.options.multiSelect === true) {
246
+ return this.options.items.filter(function (d) {
247
+ return d.selected;
248
+ });
249
+ }
250
+ return [];
251
+ },
252
+ set: function set(value) {
253
+ var activeIndex = -1;
254
+ if (this.options.multiSelect === true) {
255
+ if (Array.isArray(value)) {
256
+ this.options.items.forEach(function (d) {
257
+ if (value.indexOf(d.value) !== -1) {
258
+ d.selected = true;
259
+ } else {
260
+ d.selected = false;
261
+ }
262
+ });
263
+ }
264
+ } else {
265
+ for (var i = 0; i < this.options.items.length; i++) {
266
+ if ((this.options.items[i].value || this.options.items[i].label) === value) {
267
+ activeIndex = i;
268
+ }
269
+ }
270
+ this.options.activeItem = activeIndex;
271
+ }
272
+ this.render();
273
+ }
274
+ }, {
235
275
  key: "handleClick",
236
276
  value: function handleClick(event) {
237
277
  if (event.target.classList.contains('websy-button-group-item')) {
238
278
  var index = +event.target.getAttribute('data-index');
239
279
  if (this.options.multiSelect === true) {
240
280
  if (event.target.classList.contains('active')) {
281
+ this.options.items[index].selected = false;
241
282
  this.options.onDeactivate(this.options.items[index], index, event);
242
283
  event.target.classList.remove('active');
243
284
  event.target.classList.add('inactive');
244
285
  } else {
286
+ this.options.items[index].selected = true;
245
287
  this.options.onActivate(this.options.items[index], index, event);
246
288
  event.target.classList.add('active');
247
289
  event.target.classList.remove('inactive');
@@ -297,6 +339,8 @@ var ButtonGroup = /*#__PURE__*/function () {
297
339
  var activeClass = '';
298
340
  if (_this.options.activeItem !== -1) {
299
341
  activeClass = i === _this.options.activeItem ? 'active' : 'inactive';
342
+ } else if (_this.options.multiSelect === true) {
343
+ activeClass = t.selected === true ? 'active' : 'inactive';
300
344
  }
301
345
  return "\n <".concat(_this.options.tag, " ").concat((t.attributes || []).join(' '), " data-id=\"").concat(t.id || t.label, "\" data-index=\"").concat(i, "\" class=\"websy-button-group-item ").concat((t.classes || []).join(' '), " ").concat(_this.options.style, "-style ").concat(activeClass, "\">").concat(t.label, "</").concat(_this.options.tag, ">\n ");
302
346
  }).join('');
@@ -1829,6 +1873,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1829
1873
  var contentPos = WebsyUtils.getElementPos(contentEl);
1830
1874
  if (this.options.style === 'plain' && headerPos.width > 0 && headerPos.height > 0) {
1831
1875
  contentEl.style.right = "calc(100vw - ".concat(headerPos.right, "px)");
1876
+ contentEl.style.width = "".concat(headerEl.clientWidth, "px");
1832
1877
  if (headerPos.bottom + contentPos.height > window.innerHeight) {
1833
1878
  // contentEl.classList.add('on-top')
1834
1879
  contentEl.style.bottom = "calc(100vh - ".concat(headerPos.top, "px)");
@@ -1838,6 +1883,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1838
1883
  } else if (this.options.style === 'plain' && headerPos.width === 0 && headerPos.height === 0) {
1839
1884
  var targetPos = WebsyUtils.getElementPos(event.target);
1840
1885
  contentEl.style.right = "calc(100vw - ".concat(targetPos.right, "px)");
1886
+ contentEl.style.width = "".concat(targetPos.width, "px");
1841
1887
  }
1842
1888
  if (this.options.disableSearch !== true) {
1843
1889
  var searchEl = document.getElementById("".concat(this.elementId, "_search"));
@@ -1849,6 +1895,21 @@ var WebsyDropdown = /*#__PURE__*/function () {
1849
1895
  this.options.onOpen(this.elementId);
1850
1896
  }
1851
1897
  }
1898
+ }, {
1899
+ key: "items",
1900
+ set: function set(items) {
1901
+ this.options.items = _toConsumableArray(items);
1902
+ if (this.options.items.length > 0) {
1903
+ this.options.items = this.options.items.map(function (d, i) {
1904
+ if (typeof d.index === 'undefined') {
1905
+ d.index = i;
1906
+ }
1907
+ return d;
1908
+ });
1909
+ }
1910
+ this._originalData = _toConsumableArray(this.options.items);
1911
+ this.render();
1912
+ }
1852
1913
  }, {
1853
1914
  key: "render",
1854
1915
  value: function render() {
@@ -2067,9 +2128,7 @@ var WebsyForm = /*#__PURE__*/function () {
2067
2128
  };
2068
2129
  GlobalPubSub.subscribe('recaptchaready', this.recaptchaReady.bind(this));
2069
2130
  this.recaptchaResult = null;
2070
- this.options = _extends(defaults, {}, {
2071
- // defaults go here
2072
- }, options);
2131
+ this.options = _extends({}, defaults, options);
2073
2132
  if (!elementId) {
2074
2133
  console.log('No element Id provided');
2075
2134
  return;
@@ -2143,23 +2202,41 @@ var WebsyForm = /*#__PURE__*/function () {
2143
2202
  }, {
2144
2203
  key: "data",
2145
2204
  get: function get() {
2205
+ var _this14 = this;
2146
2206
  var formEl = document.getElementById("".concat(this.elementId, "Form"));
2147
2207
  var data = {};
2148
2208
  var temp = new FormData(formEl);
2149
2209
  temp.forEach(function (value, key) {
2150
- data[key] = value;
2210
+ if (_this14.fieldMap[key] && _this14.fieldMap[key].type === 'checkbox') {
2211
+ data[key] = true;
2212
+ }
2213
+ if (_this14.fieldMap[key] && _this14.fieldMap[key].instance && _this14.fieldMap[key].instance.value) {
2214
+ data[key] = _this14.fieldMap[key].instance.value;
2215
+ } else {
2216
+ data[key] = value;
2217
+ }
2151
2218
  });
2219
+ var keys = Object.keys(data);
2220
+ for (var key in this.fieldMap) {
2221
+ if (keys.indexOf(key) === -1) {
2222
+ if (this.fieldMap[key] && this.fieldMap[key].type === 'checkbox') {
2223
+ data[key] = false;
2224
+ } else if (this.fieldMap[key] && this.fieldMap[key].instance && this.fieldMap[key].instance.value) {
2225
+ data[key] = this.fieldMap[key].instance.value;
2226
+ }
2227
+ }
2228
+ }
2152
2229
  return data;
2153
2230
  },
2154
2231
  set: function set(d) {
2155
- var _this14 = this;
2232
+ var _this15 = this;
2156
2233
  if (!this.options.fields) {
2157
2234
  this.options.fields = [];
2158
2235
  }
2159
2236
  var _loop = function _loop(key) {
2160
- _this14.options.fields.forEach(function (f) {
2237
+ _this15.options.fields.forEach(function (f) {
2161
2238
  if (f.field === key) {
2162
- _this14.setValue(key, d[key]);
2239
+ _this15.setValue(key, d[key]);
2163
2240
  // f.value = d[key]
2164
2241
  // const el = document.getElementById(`${this.elementId}_input_${f.field}`)
2165
2242
  // if (el) {
@@ -2218,6 +2295,7 @@ var WebsyForm = /*#__PURE__*/function () {
2218
2295
  value: function handleClick(event) {
2219
2296
  if (event.target.classList.contains('submit')) {
2220
2297
  event.preventDefault();
2298
+ event.stopPropagation();
2221
2299
  this.submitForm();
2222
2300
  } else if (event.target.classList.contains('cancel')) {
2223
2301
  event.preventDefault();
@@ -2359,7 +2437,7 @@ var WebsyForm = /*#__PURE__*/function () {
2359
2437
  }, {
2360
2438
  key: "processComponents",
2361
2439
  value: function processComponents(components, callbackFn) {
2362
- var _this15 = this;
2440
+ var _this16 = this;
2363
2441
  if (components.length === 0) {
2364
2442
  callbackFn();
2365
2443
  } else {
@@ -2368,11 +2446,11 @@ var WebsyForm = /*#__PURE__*/function () {
2368
2446
  if (!c.options.onChange) {
2369
2447
  c.options.onChange = function () {
2370
2448
  if (c.required || c.validate) {
2371
- _this15.validateField(c, c.instance.value);
2449
+ _this16.validateField(c, c.instance.value);
2372
2450
  }
2373
2451
  };
2374
2452
  }
2375
- c.instance = new WebsyDesigns[c.component]("".concat(_this15.elementId, "_input_").concat(c.field, "_component"), c.options);
2453
+ c.instance = new WebsyDesigns[c.component]("".concat(_this16.elementId, "_input_").concat(c.field, "_component"), c.options);
2376
2454
  } else {
2377
2455
  // some user feedback here
2378
2456
  }
@@ -2382,13 +2460,13 @@ var WebsyForm = /*#__PURE__*/function () {
2382
2460
  }, {
2383
2461
  key: "recaptchaReady",
2384
2462
  value: function recaptchaReady() {
2385
- var _this16 = this;
2463
+ var _this17 = this;
2386
2464
  var el = document.getElementById("".concat(this.elementId, "_recaptcha"));
2387
2465
  if (el) {
2388
2466
  grecaptcha.ready(function () {
2389
- grecaptcha.render("".concat(_this16.elementId, "_recaptcha"), {
2467
+ grecaptcha.render("".concat(_this17.elementId, "_recaptcha"), {
2390
2468
  sitekey: ENVIRONMENT.RECAPTCHA_KEY,
2391
- callback: _this16.validateRecaptcha.bind(_this16)
2469
+ callback: _this17.validateRecaptcha.bind(_this17)
2392
2470
  });
2393
2471
  });
2394
2472
  }
@@ -2396,20 +2474,21 @@ var WebsyForm = /*#__PURE__*/function () {
2396
2474
  }, {
2397
2475
  key: "render",
2398
2476
  value: function render(update, data) {
2399
- var _this17 = this;
2477
+ var _this18 = this;
2400
2478
  var el = document.getElementById(this.elementId);
2401
2479
  var componentsToProcess = [];
2402
2480
  if (el) {
2403
2481
  var html = "\n <form id=\"".concat(this.elementId, "Form\" class=\"websy-form ").concat((this.options.classes || []).join(' '), "\">\n ");
2404
2482
  this.options.fields.forEach(function (f, i) {
2405
- _this17.fieldMap[f.field] = f;
2483
+ _this18.fieldMap[f.field] = f;
2484
+ f.owningElement = _this18.elementId;
2406
2485
  if (f.component) {
2407
2486
  componentsToProcess.push(f);
2408
- html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this17.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <div id='").concat(_this17.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n <span id='").concat(_this17.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
2487
+ html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <div id='").concat(_this18.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n <span id='").concat(_this18.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
2409
2488
  } else if (f.type === 'longtext') {
2410
- html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this17.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <textarea\n id=\"").concat(_this17.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n name=\"").concat(f.field, "\" \n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea\"\n ></textarea>\n <span id='").concat(_this17.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
2489
+ html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <textarea\n id=\"").concat(_this18.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n name=\"").concat(f.field, "\" \n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea\"\n ></textarea>\n <span id='").concat(_this18.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
2411
2490
  } else {
2412
- html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this17.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <input \n id=\"").concat(_this17.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat((f.type === 'expiry' ? 'text' : f.type === 'cvv' ? 'number' : f.type) || 'text', "\" \n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n class=\"websy-input\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? f.value : '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n <span id='").concat(_this17.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
2491
+ html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <input \n id=\"").concat(_this18.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat((f.type === 'expiry' ? 'text' : f.type === 'cvv' ? 'number' : f.type) || 'text', "\" \n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n class=\"websy-input\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? f.value : '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n <span id='").concat(_this18.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
2413
2492
  }
2414
2493
  });
2415
2494
  if (this.options.useRecaptcha === true) {
@@ -2422,8 +2501,8 @@ var WebsyForm = /*#__PURE__*/function () {
2422
2501
  html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n ");
2423
2502
  el.innerHTML = html;
2424
2503
  this.processComponents(componentsToProcess, function () {
2425
- if (_this17.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
2426
- _this17.recaptchaReady();
2504
+ if (_this18.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
2505
+ _this18.recaptchaReady();
2427
2506
  }
2428
2507
  });
2429
2508
  }
@@ -2438,6 +2517,10 @@ var WebsyForm = /*#__PURE__*/function () {
2438
2517
  var el = document.getElementById("".concat(this.elementId, "_input_").concat(field));
2439
2518
  if (el) {
2440
2519
  el.value = value;
2520
+ el.setAttribute('value', value);
2521
+ if (this.fieldMap[field].type === 'checkbox') {
2522
+ el.checked = value;
2523
+ }
2441
2524
  } else {
2442
2525
  console.error("Input for ".concat(field, " does not exist in form."));
2443
2526
  }
@@ -2449,7 +2532,7 @@ var WebsyForm = /*#__PURE__*/function () {
2449
2532
  }, {
2450
2533
  key: "submitForm",
2451
2534
  value: function submitForm() {
2452
- var _this18 = this;
2535
+ var _this19 = this;
2453
2536
  var formEl = document.getElementById("".concat(this.elementId, "Form"));
2454
2537
  var buttonEl = formEl.querySelector('button.websy-btn.submit');
2455
2538
  var recaptchErrEl = document.getElementById("".concat(this.elementId, "_recaptchaError"));
@@ -2474,27 +2557,27 @@ var WebsyForm = /*#__PURE__*/function () {
2474
2557
  temp.forEach(function (value, key) {
2475
2558
  data[key] = value;
2476
2559
  });
2477
- if (_this18.options.url) {
2478
- var _this18$apiService;
2479
- var params = [_this18.options.url];
2480
- if (_this18.options.mode === 'update') {
2481
- params.push(_this18.options.id);
2560
+ if (_this19.options.url) {
2561
+ var _this19$apiService;
2562
+ var params = [_this19.options.url];
2563
+ if (_this19.options.mode === 'update') {
2564
+ params.push(_this19.options.id);
2482
2565
  }
2483
2566
  params.push(data);
2484
- (_this18$apiService = _this18.apiService)[_this18.options.mode].apply(_this18$apiService, params).then(function (result) {
2485
- if (_this18.options.clearAfterSave === true) {
2567
+ (_this19$apiService = _this19.apiService)[_this19.options.mode].apply(_this19$apiService, params).then(function (result) {
2568
+ if (_this19.options.clearAfterSave === true) {
2486
2569
  // this.render()
2487
2570
  formEl.reset();
2488
2571
  }
2489
2572
  buttonEl.removeAttribute('disabled');
2490
- _this18.options.onSuccess.call(_this18, result);
2573
+ _this19.options.onSuccess.call(_this19, result);
2491
2574
  }, function (err) {
2492
2575
  console.log('Error submitting form data:', err);
2493
- _this18.options.onError.call(_this18, err);
2576
+ _this19.options.onError.call(_this19, err);
2494
2577
  });
2495
- } else if (_this18.options.submitFn) {
2496
- _this18.options.submitFn(data, function () {
2497
- if (_this18.options.clearAfterSave === true) {
2578
+ } else if (_this19.options.submitFn) {
2579
+ _this19.options.submitFn(data, function () {
2580
+ if (_this19.options.clearAfterSave === true) {
2498
2581
  // this.render()
2499
2582
  formEl.reset();
2500
2583
  }
@@ -2601,6 +2684,12 @@ var MultiForm = /*#__PURE__*/function () {
2601
2684
  this.render();
2602
2685
  }
2603
2686
  _createClass(MultiForm, [{
2687
+ key: "addData",
2688
+ value: function addData(data) {
2689
+ this.formData = this.formData.concat(data);
2690
+ this.render();
2691
+ }
2692
+ }, {
2604
2693
  key: "addEntry",
2605
2694
  value: function addEntry() {
2606
2695
  var el = document.getElementById("".concat(this.elementId, "_container"));
@@ -2610,7 +2699,11 @@ var MultiForm = /*#__PURE__*/function () {
2610
2699
  newFormEl.classList.add('websy-multi-form-form-container');
2611
2700
  newFormEl.innerHTML = "\n <div id='".concat(this.elementId, "_").concat(newId, "_form' class='websy-multi-form-form'>\n </div>\n <button id='").concat(this.elementId, "_").concat(newId, "_deleteButton' data-formid='").concat(newId, "' class='hidden websy-multi-form-delete'>\n ").concat(this.options.deleteButton, "\n </button> \n <button id='").concat(this.elementId, "_").concat(newId, "_addButton' data-formid='").concat(newId, "' class='websy-multi-form-add'>\n ").concat(this.options.addButton, "\n </button> \n ");
2612
2701
  el.appendChild(newFormEl);
2613
- var formOptions = _extends({}, this.options);
2702
+ var formOptions = _extends({}, this.options, {
2703
+ fields: _toConsumableArray(this.options.fields.map(function (f) {
2704
+ return _extends({}, f);
2705
+ }))
2706
+ });
2614
2707
  this.forms.push(new WebsyDesigns.Form("".concat(this.elementId, "_").concat(newId, "_form"), formOptions));
2615
2708
  }
2616
2709
  }, {
@@ -2630,14 +2723,25 @@ var MultiForm = /*#__PURE__*/function () {
2630
2723
  var d = this.forms.map(function (f) {
2631
2724
  return f.data;
2632
2725
  });
2633
- // we don't return the last form
2634
- d.pop();
2726
+ console.log('forms data', d);
2727
+ if (this.options.allowAdd !== false) {
2728
+ // we don't return the last form
2729
+ d.pop();
2730
+ }
2635
2731
  return d;
2636
2732
  },
2637
2733
  set: function set(d) {
2638
2734
  this.formData = d;
2639
2735
  this.render();
2640
2736
  }
2737
+ }, {
2738
+ key: "deleted",
2739
+ get: function get() {
2740
+ var _this20 = this;
2741
+ return this.formData.filter(function (d) {
2742
+ return _this20.recordsToDelete.includes("".concat(d.id));
2743
+ });
2744
+ }
2641
2745
  }, {
2642
2746
  key: "handleClick",
2643
2747
  value: function handleClick(event) {
@@ -2682,7 +2786,7 @@ var MultiForm = /*#__PURE__*/function () {
2682
2786
  }, {
2683
2787
  key: "render",
2684
2788
  value: function render() {
2685
- var _this19 = this;
2789
+ var _this21 = this;
2686
2790
  this.forms = [];
2687
2791
  this.recordsToDelete = [];
2688
2792
  var el = document.getElementById("".concat(this.elementId, "_container"));
@@ -2690,9 +2794,9 @@ var MultiForm = /*#__PURE__*/function () {
2690
2794
  var html = '';
2691
2795
  this.formData.forEach(function (d) {
2692
2796
  d.formId = WebsyDesigns.Utils.createIdentity();
2693
- html += "\n <div id='".concat(_this19.elementId, "_").concat(d.formId, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(_this19.elementId, "_").concat(d.formId, "_form' class='websy-multi-form-form'>\n </div>\n ");
2694
- if (_this19.options.allowDelete === true) {
2695
- html += "\n <button id='".concat(_this19.elementId, "_").concat(d.formId, "_deleteButton' data-formid='").concat(d.formId, "' data-rowid='").concat(d.id, "' class='websy-multi-form-delete'>\n ").concat(_this19.options.deleteButton, "\n </button>\n ");
2797
+ html += "\n <div id='".concat(_this21.elementId, "_").concat(d.formId, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(_this21.elementId, "_").concat(d.formId, "_form' class='websy-multi-form-form'>\n </div>\n ");
2798
+ if (_this21.options.allowDelete === true) {
2799
+ html += "\n <button id='".concat(_this21.elementId, "_").concat(d.formId, "_deleteButton' data-formid='").concat(d.formId, "' data-rowid='").concat(d.id, "' class='websy-multi-form-delete'>\n ").concat(_this21.options.deleteButton, "\n </button>\n ");
2696
2800
  }
2697
2801
  html += "\n </div>\n ";
2698
2802
  });
@@ -2701,15 +2805,25 @@ var MultiForm = /*#__PURE__*/function () {
2701
2805
  html += "\n <div id='".concat(this.elementId, "_").concat(id, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(this.elementId, "_").concat(id, "_form' class='websy-multi-form-form'>\n </div>\n <button id='").concat(this.elementId, "_").concat(id, "_deleteButton' data-formid='").concat(id, "' class='hidden websy-multi-form-delete'>\n ").concat(this.options.deleteButton, "\n </button> \n <button id='").concat(this.elementId, "_").concat(id, "_addButton' data-formid='").concat(id, "' class='websy-multi-form-add'>\n ").concat(this.options.addButton, "\n </button> \n </div>\n ");
2702
2806
  }
2703
2807
  el.innerHTML = html;
2704
- this.formData.forEach(function (d) {
2705
- var formOptions = _extends({}, _this19.options);
2706
- var formObject = new WebsyDesigns.Form("".concat(_this19.elementId, "_").concat(d.formId, "_form"), formOptions);
2808
+ this.forms = new Array(this.formData.length);
2809
+ this.formData.forEach(function (d, i) {
2810
+ var formOptions = _extends({}, _this21.options, {
2811
+ fields: _toConsumableArray(_this21.options.fields.map(function (f) {
2812
+ return _extends({}, f);
2813
+ }))
2814
+ });
2815
+ var formObject = new WebsyDesigns.Form("".concat(_this21.elementId, "_").concat(d.formId, "_form"), formOptions);
2707
2816
  formObject.data = d;
2708
- _this19.forms.push(formObject);
2817
+ _this21.forms[i] = formObject;
2709
2818
  });
2710
2819
  if (this.options.allowAdd === true) {
2711
- var formOptions = _extends({}, this.options);
2712
- this.forms.push(new WebsyDesigns.Form("".concat(this.elementId, "_").concat(id, "_form"), formOptions));
2820
+ var formOptions = _extends({}, this.options, {
2821
+ fields: _toConsumableArray(this.options.fields.map(function (f) {
2822
+ return _extends({}, f);
2823
+ }))
2824
+ });
2825
+ var formObject = new WebsyDesigns.Form("".concat(this.elementId, "_").concat(id, "_form"), formOptions);
2826
+ this.forms.push(formObject);
2713
2827
  }
2714
2828
  }
2715
2829
  }
@@ -2934,7 +3048,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2934
3048
  }, {
2935
3049
  key: "handleSearch",
2936
3050
  value: function handleSearch(searchText) {
2937
- var _this20 = this;
3051
+ var _this22 = this;
2938
3052
  var el = document.getElementById(this.elementId);
2939
3053
  // let lowestItems = this.flatItems.filter(d => d.level === this.maxLevel)
2940
3054
  var lowestItems = this.flatItems.filter(function (d) {
@@ -2945,7 +3059,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2945
3059
  if (searchText && searchText.length > 1) {
2946
3060
  defaultMethod = 'add';
2947
3061
  visibleItems = lowestItems.filter(function (d) {
2948
- return d[_this20.options.searchProp].toLowerCase().indexOf(searchText.toLowerCase()) !== -1;
3062
+ return d[_this22.options.searchProp].toLowerCase().indexOf(searchText.toLowerCase()) !== -1;
2949
3063
  });
2950
3064
  }
2951
3065
  // hide everything
@@ -3127,7 +3241,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
3127
3241
  /* global WebsyDesigns */
3128
3242
  var Pager = /*#__PURE__*/function () {
3129
3243
  function Pager(elementId, options) {
3130
- var _this21 = this;
3244
+ var _this23 = this;
3131
3245
  _classCallCheck(this, Pager);
3132
3246
  this.elementId = elementId;
3133
3247
  var DEFAULTS = {
@@ -3174,8 +3288,8 @@ var Pager = /*#__PURE__*/function () {
3174
3288
  allowClear: false,
3175
3289
  disableSearch: true,
3176
3290
  onItemSelected: function onItemSelected(selectedItem) {
3177
- if (_this21.options.onChangePageSize) {
3178
- _this21.options.onChangePageSize(selectedItem.value);
3291
+ if (_this23.options.onChangePageSize) {
3292
+ _this23.options.onChangePageSize(selectedItem.value);
3179
3293
  }
3180
3294
  }
3181
3295
  });
@@ -3196,11 +3310,11 @@ var Pager = /*#__PURE__*/function () {
3196
3310
  }, {
3197
3311
  key: "render",
3198
3312
  value: function render() {
3199
- var _this22 = this;
3313
+ var _this24 = this;
3200
3314
  var el = document.getElementById("".concat(this.elementId, "_pageList"));
3201
3315
  if (el) {
3202
3316
  var pages = this.options.pages.map(function (item, index) {
3203
- return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(_this22.options.activePage === index ? 'active' : '', "\">").concat(index + 1, "</li>");
3317
+ return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(_this24.options.activePage === index ? 'active' : '', "\">").concat(index + 1, "</li>");
3204
3318
  });
3205
3319
  var startIndex = 0;
3206
3320
  if (this.options.pages.length > 8) {
@@ -3230,7 +3344,11 @@ var WebsyPDFButton = /*#__PURE__*/function () {
3230
3344
  classes: [],
3231
3345
  wait: 0,
3232
3346
  buttonText: 'Download',
3233
- directDownload: false
3347
+ directDownload: false,
3348
+ preProcess: function preProcess(callbackFn) {
3349
+ return callbackFn(true);
3350
+ },
3351
+ onError: function onError() {}
3234
3352
  };
3235
3353
  this.elementId = elementId;
3236
3354
  this.options = _extends({}, DEFAULTS, options);
@@ -3258,83 +3376,90 @@ var WebsyPDFButton = /*#__PURE__*/function () {
3258
3376
  _createClass(WebsyPDFButton, [{
3259
3377
  key: "handleClick",
3260
3378
  value: function handleClick(event) {
3261
- var _this23 = this;
3379
+ var _this25 = this;
3262
3380
  if (event.target.classList.contains('websy-pdf-button')) {
3263
3381
  this.loader.show();
3264
- setTimeout(function () {
3265
- if (_this23.options.targetId) {
3266
- var el = document.getElementById(_this23.options.targetId);
3267
- if (el) {
3268
- var pdfData = {
3269
- options: {}
3270
- };
3271
- if (_this23.options.pdfOptions) {
3272
- pdfData.options = _extends({}, _this23.options.pdfOptions);
3273
- }
3274
- if (_this23.options.header) {
3275
- if (_this23.options.header.elementId) {
3276
- var headerEl = document.getElementById(_this23.options.header.elementId);
3277
- if (headerEl) {
3278
- pdfData.header = headerEl.outerHTML;
3279
- if (_this23.options.header.css) {
3280
- pdfData.options.headerCSS = _this23.options.header.css;
3281
- }
3382
+ this.options.preProcess(function (proceed) {
3383
+ if (proceed === true) {
3384
+ setTimeout(function () {
3385
+ if (_this25.options.targetId) {
3386
+ var el = document.getElementById(_this25.options.targetId);
3387
+ if (el) {
3388
+ var pdfData = {
3389
+ options: {}
3390
+ };
3391
+ if (_this25.options.pdfOptions) {
3392
+ pdfData.options = _extends({}, _this25.options.pdfOptions);
3282
3393
  }
3283
- } else if (_this23.options.header.html) {
3284
- pdfData.header = _this23.options.header.html;
3285
- if (_this23.options.header.css) {
3286
- pdfData.options.headerCSS = _this23.options.header.css;
3394
+ if (_this25.options.header) {
3395
+ if (_this25.options.header.elementId) {
3396
+ var headerEl = document.getElementById(_this25.options.header.elementId);
3397
+ if (headerEl) {
3398
+ pdfData.header = headerEl.outerHTML;
3399
+ if (_this25.options.header.css) {
3400
+ pdfData.options.headerCSS = _this25.options.header.css;
3401
+ }
3402
+ }
3403
+ } else if (_this25.options.header.html) {
3404
+ pdfData.header = _this25.options.header.html;
3405
+ if (_this25.options.header.css) {
3406
+ pdfData.options.headerCSS = _this25.options.header.css;
3407
+ }
3408
+ } else {
3409
+ pdfData.header = _this25.options.header;
3410
+ }
3287
3411
  }
3288
- } else {
3289
- pdfData.header = _this23.options.header;
3290
- }
3291
- }
3292
- if (_this23.options.footer) {
3293
- if (_this23.options.footer.elementId) {
3294
- var footerEl = document.getElementById(_this23.options.footer.elementId);
3295
- if (footerEl) {
3296
- pdfData.footer = footerEl.outerHTML;
3297
- if (_this23.options.footer.css) {
3298
- pdfData.options.footerCSS = _this23.options.footer.css;
3412
+ if (_this25.options.footer) {
3413
+ if (_this25.options.footer.elementId) {
3414
+ var footerEl = document.getElementById(_this25.options.footer.elementId);
3415
+ if (footerEl) {
3416
+ pdfData.footer = footerEl.outerHTML;
3417
+ if (_this25.options.footer.css) {
3418
+ pdfData.options.footerCSS = _this25.options.footer.css;
3419
+ }
3420
+ }
3421
+ } else {
3422
+ pdfData.footer = _this25.options.footer;
3299
3423
  }
3300
3424
  }
3301
- } else {
3302
- pdfData.footer = _this23.options.footer;
3425
+ pdfData.html = el.outerHTML;
3426
+ // document.getElementById(`${this.elementId}_pdfHeader`).value = pdfData.header
3427
+ // document.getElementById(`${this.elementId}_pdfHTML`).value = pdfData.html
3428
+ // document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
3429
+ // document.getElementById(`${this.elementId}_form`).submit()
3430
+ _this25.service.add('', pdfData, {
3431
+ responseType: 'blob'
3432
+ }).then(function (response) {
3433
+ _this25.loader.hide();
3434
+ var blob = new Blob([response], {
3435
+ type: 'application/pdf'
3436
+ });
3437
+ var msg = "\n <div class='text-center websy-pdf-download'>\n <div>Your file is ready to download</div>\n <a href='".concat(URL.createObjectURL(blob), "' target='_blank'\n ");
3438
+ if (_this25.options.directDownload === true) {
3439
+ var fileName;
3440
+ if (typeof _this25.options.fileName === 'function') {
3441
+ fileName = _this25.options.fileName() || 'Export';
3442
+ } else {
3443
+ fileName = _this25.options.fileName || 'Export';
3444
+ }
3445
+ msg += "download='".concat(fileName, ".pdf'");
3446
+ }
3447
+ msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this25.options.buttonText, "</button>\n </a>\n </div>\n ");
3448
+ _this25.popup.show({
3449
+ message: msg,
3450
+ mask: true
3451
+ });
3452
+ }, function (err) {
3453
+ console.error(err);
3454
+ });
3303
3455
  }
3304
3456
  }
3305
- pdfData.html = el.outerHTML;
3306
- // document.getElementById(`${this.elementId}_pdfHeader`).value = pdfData.header
3307
- // document.getElementById(`${this.elementId}_pdfHTML`).value = pdfData.html
3308
- // document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
3309
- // document.getElementById(`${this.elementId}_form`).submit()
3310
- _this23.service.add('', pdfData, {
3311
- responseType: 'blob'
3312
- }).then(function (response) {
3313
- _this23.loader.hide();
3314
- var blob = new Blob([response], {
3315
- type: 'application/pdf'
3316
- });
3317
- var msg = "\n <div class='text-center websy-pdf-download'>\n <div>Your file is ready to download</div>\n <a href='".concat(URL.createObjectURL(blob), "' target='_blank'\n ");
3318
- if (_this23.options.directDownload === true) {
3319
- var fileName;
3320
- if (typeof _this23.options.fileName === 'function') {
3321
- fileName = _this23.options.fileName() || 'Export';
3322
- } else {
3323
- fileName = _this23.options.fileName || 'Export';
3324
- }
3325
- msg += "download='".concat(fileName, ".pdf'");
3326
- }
3327
- msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this23.options.buttonText, "</button>\n </a>\n </div>\n ");
3328
- _this23.popup.show({
3329
- message: msg,
3330
- mask: true
3331
- });
3332
- }, function (err) {
3333
- console.error(err);
3334
- });
3335
- }
3457
+ }, _this25.options.wait);
3458
+ } else {
3459
+ _this25.loader.hide();
3460
+ _this25.options.onError();
3336
3461
  }
3337
- }, this.options.wait);
3462
+ });
3338
3463
  } else if (event.target.classList.contains('download-pdf')) {
3339
3464
  this.popup.hide();
3340
3465
  if (this.options.onClose) {
@@ -3474,6 +3599,9 @@ var WebsyPubSub = /*#__PURE__*/function () {
3474
3599
  }, {
3475
3600
  key: "subscribe",
3476
3601
  value: function subscribe(id, method, fn) {
3602
+ if (!this.subscriptions) {
3603
+ this.subscriptions = {};
3604
+ }
3477
3605
  if (arguments.length === 3) {
3478
3606
  if (!this.subscriptions[id]) {
3479
3607
  this.subscriptions[id] = {};
@@ -3493,7 +3621,7 @@ var WebsyPubSub = /*#__PURE__*/function () {
3493
3621
  }();
3494
3622
  var ResponsiveText = /*#__PURE__*/function () {
3495
3623
  function ResponsiveText(elementId, options) {
3496
- var _this24 = this;
3624
+ var _this26 = this;
3497
3625
  _classCallCheck(this, ResponsiveText);
3498
3626
  var DEFAULTS = {
3499
3627
  textAlign: 'center',
@@ -3504,7 +3632,7 @@ var ResponsiveText = /*#__PURE__*/function () {
3504
3632
  this.elementId = elementId;
3505
3633
  this.canvas = document.createElement('canvas');
3506
3634
  window.addEventListener('resize', function () {
3507
- return _this24.render();
3635
+ return _this26.render();
3508
3636
  });
3509
3637
  var el = document.getElementById(this.elementId);
3510
3638
  if (el) {
@@ -3694,7 +3822,7 @@ var ResponsiveText = /*#__PURE__*/function () {
3694
3822
  /* global WebsyDesigns */
3695
3823
  var WebsyResultList = /*#__PURE__*/function () {
3696
3824
  function WebsyResultList(elementId, options) {
3697
- var _this25 = this;
3825
+ var _this27 = this;
3698
3826
  _classCallCheck(this, WebsyResultList);
3699
3827
  var DEFAULTS = {
3700
3828
  listeners: {
@@ -3720,8 +3848,8 @@ var WebsyResultList = /*#__PURE__*/function () {
3720
3848
  }
3721
3849
  if (_typeof(options.template) === 'object' && options.template.url) {
3722
3850
  this.templateService.get(options.template.url).then(function (templateString) {
3723
- _this25.options.template = templateString;
3724
- _this25.render();
3851
+ _this27.options.template = templateString;
3852
+ _this27.render();
3725
3853
  });
3726
3854
  } else {
3727
3855
  this.render();
@@ -3740,7 +3868,7 @@ var WebsyResultList = /*#__PURE__*/function () {
3740
3868
  }, {
3741
3869
  key: "buildHTML",
3742
3870
  value: function buildHTML(d) {
3743
- var _this26 = this;
3871
+ var _this28 = this;
3744
3872
  var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
3745
3873
  var inputTemplate = arguments.length > 2 ? arguments[2] : undefined;
3746
3874
  var locator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
@@ -3748,7 +3876,7 @@ var WebsyResultList = /*#__PURE__*/function () {
3748
3876
  if (this.options.template) {
3749
3877
  if (d.length > 0) {
3750
3878
  d.forEach(function (row, ix) {
3751
- var template = "".concat(ix > 0 ? '-->' : '').concat(inputTemplate || _this26.options.template).concat(ix < d.length - 1 ? '<!--' : '');
3879
+ var template = "".concat(ix > 0 ? '-->' : '').concat(inputTemplate || _this28.options.template).concat(ix < d.length - 1 ? '<!--' : '');
3752
3880
  // find conditional elements
3753
3881
  var ifMatches = _toConsumableArray(template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g));
3754
3882
  ifMatches.forEach(function (m) {
@@ -3836,7 +3964,7 @@ var WebsyResultList = /*#__PURE__*/function () {
3836
3964
  parts.forEach(function (p) {
3837
3965
  items = items[p];
3838
3966
  });
3839
- template = template.replace(m[0], _this26.buildHTML(items, 0, withoutFor, [].concat(_toConsumableArray(locator), ["".concat(startIndex + ix, ":").concat(c)])));
3967
+ template = template.replace(m[0], _this28.buildHTML(items, 0, withoutFor, [].concat(_toConsumableArray(locator), ["".concat(startIndex + ix, ":").concat(c)])));
3840
3968
  }
3841
3969
  });
3842
3970
  var tagMatches = _toConsumableArray(template.matchAll(/(\sdata-event=["|']\w.+)["|']/g));
@@ -3845,7 +3973,7 @@ var WebsyResultList = /*#__PURE__*/function () {
3845
3973
  template = template.replace(m[0], "".concat(m[0], " data-id=").concat(startIndex + ix, " data-locator='").concat(locator.join(';'), "'"));
3846
3974
  }
3847
3975
  });
3848
- var flatRow = _this26.flattenObject(row);
3976
+ var flatRow = _this28.flattenObject(row);
3849
3977
  for (var key in flatRow) {
3850
3978
  var rg = new RegExp("{".concat(key, "}"), 'gm');
3851
3979
  template = template.replace(rg, flatRow[key] || '');
@@ -3970,15 +4098,15 @@ var WebsyResultList = /*#__PURE__*/function () {
3970
4098
  }, {
3971
4099
  key: "render",
3972
4100
  value: function render() {
3973
- var _this27 = this;
4101
+ var _this29 = this;
3974
4102
  if (this.options.entity) {
3975
4103
  var url = this.options.entity;
3976
4104
  if (this.options.sortField) {
3977
4105
  url += (url.indexOf('?') === -1 ? '?' : '&') + "by=".concat(this.options.sortField, "&order=").concat(this.options.sortOrder || 'ASC');
3978
4106
  }
3979
4107
  this.apiService.get(url).then(function (results) {
3980
- _this27.rows = results.rows;
3981
- _this27.resize();
4108
+ _this29.rows = results.rows;
4109
+ _this29.resize();
3982
4110
  });
3983
4111
  } else {
3984
4112
  this.resize();
@@ -4048,12 +4176,12 @@ var WebsyRouter = /*#__PURE__*/function () {
4048
4176
  _createClass(WebsyRouter, [{
4049
4177
  key: "addGroup",
4050
4178
  value: function addGroup(group) {
4051
- var _this28 = this;
4179
+ var _this30 = this;
4052
4180
  if (!this.groups[group]) {
4053
4181
  var els = document.querySelectorAll(".websy-view[data-group=\"".concat(group, "\"]"));
4054
4182
  if (els) {
4055
4183
  this.getClosestParent(els[0], function (parent) {
4056
- _this28.groups[group] = {
4184
+ _this30.groups[group] = {
4057
4185
  activeView: '',
4058
4186
  views: [],
4059
4187
  parent: parent.getAttribute('data-view')
@@ -4117,7 +4245,7 @@ var WebsyRouter = /*#__PURE__*/function () {
4117
4245
  }, {
4118
4246
  key: "removeUrlParams",
4119
4247
  value: function removeUrlParams() {
4120
- var _this29 = this;
4248
+ var _this31 = this;
4121
4249
  var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
4122
4250
  var reloadView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4123
4251
  var noHistory = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
@@ -4125,7 +4253,7 @@ var WebsyRouter = /*#__PURE__*/function () {
4125
4253
  var path = '';
4126
4254
  if (this.currentParams && this.currentParams.items) {
4127
4255
  params.forEach(function (p) {
4128
- delete _this29.currentParams.items[p];
4256
+ delete _this31.currentParams.items[p];
4129
4257
  });
4130
4258
  path = this.buildUrlPath(this.currentParams.items);
4131
4259
  }
@@ -4456,11 +4584,11 @@ var WebsyRouter = /*#__PURE__*/function () {
4456
4584
  }, {
4457
4585
  key: "showComponents",
4458
4586
  value: function showComponents(view) {
4459
- var _this30 = this;
4587
+ var _this32 = this;
4460
4588
  if (this.options.views && this.options.views[view] && this.options.views[view].components) {
4461
4589
  this.options.views[view].components.forEach(function (c) {
4462
4590
  if (typeof c.instance === 'undefined') {
4463
- _this30.prepComponent(c.elementId, c.options);
4591
+ _this32.prepComponent(c.elementId, c.options);
4464
4592
  c.instance = new c.Component(c.elementId, c.options);
4465
4593
  } else if (c.instance.render) {
4466
4594
  c.instance.render();
@@ -4804,7 +4932,7 @@ var Switch = /*#__PURE__*/function () {
4804
4932
  /* global WebsyDesigns */
4805
4933
  var WebsyTemplate = /*#__PURE__*/function () {
4806
4934
  function WebsyTemplate(elementId, options) {
4807
- var _this31 = this;
4935
+ var _this33 = this;
4808
4936
  _classCallCheck(this, WebsyTemplate);
4809
4937
  var DEFAULTS = {
4810
4938
  listeners: {
@@ -4824,8 +4952,8 @@ var WebsyTemplate = /*#__PURE__*/function () {
4824
4952
  }
4825
4953
  if (_typeof(options.template) === 'object' && options.template.url) {
4826
4954
  this.templateService.get(options.template.url).then(function (templateString) {
4827
- _this31.options.template = templateString;
4828
- _this31.render();
4955
+ _this33.options.template = templateString;
4956
+ _this33.render();
4829
4957
  });
4830
4958
  } else {
4831
4959
  this.render();
@@ -4834,7 +4962,7 @@ var WebsyTemplate = /*#__PURE__*/function () {
4834
4962
  _createClass(WebsyTemplate, [{
4835
4963
  key: "buildHTML",
4836
4964
  value: function buildHTML() {
4837
- var _this32 = this;
4965
+ var _this34 = this;
4838
4966
  var html = "";
4839
4967
  if (this.options.template) {
4840
4968
  var template = this.options.template;
@@ -4883,14 +5011,14 @@ var WebsyTemplate = /*#__PURE__*/function () {
4883
5011
  }
4884
5012
  }
4885
5013
  if (polarity === true) {
4886
- if (typeof _this32.options.data[parts[0]] !== 'undefined' && _this32.options.data[parts[0]] === parts[1]) {
5014
+ if (typeof _this34.options.data[parts[0]] !== 'undefined' && _this34.options.data[parts[0]] === parts[1]) {
4887
5015
  // remove the <if> tags
4888
5016
  removeAll = false;
4889
5017
  } else if (parts[0] === parts[1]) {
4890
5018
  removeAll = false;
4891
5019
  }
4892
5020
  } else if (polarity === false) {
4893
- if (typeof _this32.options.data[parts[0]] !== 'undefined' && _this32.options.data[parts[0]] !== parts[1]) {
5021
+ if (typeof _this34.options.data[parts[0]] !== 'undefined' && _this34.options.data[parts[0]] !== parts[1]) {
4894
5022
  // remove the <if> tags
4895
5023
  removeAll = false;
4896
5024
  }
@@ -4927,7 +5055,55 @@ var WebsyTemplate = /*#__PURE__*/function () {
4927
5055
  }, {
4928
5056
  key: "handleClick",
4929
5057
  value: function handleClick(event) {
4930
- //
5058
+ if (event.target.classList.contains('clickable')) {
5059
+ this.handleEvent(event, 'clickable', 'click');
5060
+ }
5061
+ }
5062
+ }, {
5063
+ key: "handleEvent",
5064
+ value: function handleEvent(event, eventType, action) {
5065
+ var l = event.target.getAttribute('data-event');
5066
+ if (l) {
5067
+ l = l.split('(');
5068
+ var params = [];
5069
+ var id = event.target.getAttribute('data-id');
5070
+ // const locator = event.target.getAttribute('data-locator')
5071
+ // if (l[1]) {
5072
+ // l[1] = l[1].replace(')', '')
5073
+ // params = l[1].split(',')
5074
+ // }
5075
+ // l = l[0]
5076
+ var data = this.options.data;
5077
+ // if (locator !== '') {
5078
+ // let locatorItems = locator.split(';')
5079
+ // locatorItems.forEach(loc => {
5080
+ // let locatorParts = loc.split(':')
5081
+ // if (data[locatorParts[0]]) {
5082
+ // data = data[locatorParts[0]]
5083
+ // let parts = locatorParts[1].split('.')
5084
+ // parts.forEach(p => {
5085
+ // data = data[p]
5086
+ // })
5087
+ // }
5088
+ // })
5089
+ // }
5090
+ // params = params.map(p => {
5091
+ // if (typeof p !== 'string' && typeof p !== 'number') {
5092
+ // if (data[+id]) {
5093
+ // p = data[+id][p]
5094
+ // }
5095
+ // }
5096
+ // else if (typeof p === 'string') {
5097
+ // p = p.replace(/"/g, '').replace(/'/g, '')
5098
+ // }
5099
+ // return p
5100
+ // })
5101
+ if (event.target.classList.contains(eventType) && this.options.listeners[action] && this.options.listeners[action][l]) {
5102
+ var _this$options$listene2;
5103
+ event.stopPropagation();
5104
+ (_this$options$listene2 = this.options.listeners[action][l]).call.apply(_this$options$listene2, [this, event, data[+id]].concat(params));
5105
+ }
5106
+ }
4931
5107
  }
4932
5108
  }, {
4933
5109
  key: "render",
@@ -5151,7 +5327,7 @@ var WebsyUtils = {
5151
5327
  /* global WebsyDesigns */
5152
5328
  var WebsyTable = /*#__PURE__*/function () {
5153
5329
  function WebsyTable(elementId, options) {
5154
- var _this33 = this;
5330
+ var _this35 = this;
5155
5331
  _classCallCheck(this, WebsyTable);
5156
5332
  var DEFAULTS = {
5157
5333
  pageSize: 20,
@@ -5183,8 +5359,8 @@ var WebsyTable = /*#__PURE__*/function () {
5183
5359
  allowClear: false,
5184
5360
  disableSearch: true,
5185
5361
  onItemSelected: function onItemSelected(selectedItem) {
5186
- if (_this33.options.onChangePageSize) {
5187
- _this33.options.onChangePageSize(selectedItem.value);
5362
+ if (_this35.options.onChangePageSize) {
5363
+ _this35.options.onChangePageSize(selectedItem.value);
5188
5364
  }
5189
5365
  }
5190
5366
  });
@@ -5203,19 +5379,19 @@ var WebsyTable = /*#__PURE__*/function () {
5203
5379
  _createClass(WebsyTable, [{
5204
5380
  key: "appendRows",
5205
5381
  value: function appendRows(data) {
5206
- var _this34 = this;
5382
+ var _this36 = this;
5207
5383
  this.hideError();
5208
5384
  var bodyHTML = '';
5209
5385
  if (data) {
5210
5386
  bodyHTML += data.map(function (r, rowIndex) {
5211
5387
  return '<tr>' + r.map(function (c, i) {
5212
- if (_this34.options.columns[i].show !== false) {
5388
+ if (_this36.options.columns[i].show !== false) {
5213
5389
  var style = '';
5214
5390
  if (c.style) {
5215
5391
  style += c.style;
5216
5392
  }
5217
- if (_this34.options.columns[i].width) {
5218
- style += "width: ".concat(_this34.options.columns[i].width, "; ");
5393
+ if (_this36.options.columns[i].width) {
5394
+ style += "width: ".concat(_this36.options.columns[i].width, "; ");
5219
5395
  }
5220
5396
  if (c.backgroundColor) {
5221
5397
  style += "background-color: ".concat(c.backgroundColor, "; ");
@@ -5226,16 +5402,16 @@ var WebsyTable = /*#__PURE__*/function () {
5226
5402
  if (c.color) {
5227
5403
  style += "color: ".concat(c.color, "; ");
5228
5404
  }
5229
- if (_this34.options.columns[i].showAsLink === true && c.value.trim() !== '') {
5230
- return "\n <td \n data-row-index='".concat(_this34.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this34.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this34.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this34.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
5231
- } else if ((_this34.options.columns[i].showAsNavigatorLink === true || _this34.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
5232
- return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this34.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this34.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this34.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this34.options.columns[i].linkText || c.value, "</td>\n ");
5405
+ if (_this36.options.columns[i].showAsLink === true && c.value.trim() !== '') {
5406
+ return "\n <td \n data-row-index='".concat(_this36.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this36.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this36.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this36.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
5407
+ } else if ((_this36.options.columns[i].showAsNavigatorLink === true || _this36.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
5408
+ return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this36.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this36.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this36.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this36.options.columns[i].linkText || c.value, "</td>\n ");
5233
5409
  } else {
5234
5410
  var info = c.value;
5235
- if (_this34.options.columns[i].showAsImage === true) {
5411
+ if (_this36.options.columns[i].showAsImage === true) {
5236
5412
  c.value = "\n <img src='".concat(c.value, "'>\n ");
5237
5413
  }
5238
- return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this34.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this34.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
5414
+ return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this36.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this36.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
5239
5415
  }
5240
5416
  }
5241
5417
  }).join('') + '</tr>';
@@ -5394,7 +5570,7 @@ var WebsyTable = /*#__PURE__*/function () {
5394
5570
  }, {
5395
5571
  key: "render",
5396
5572
  value: function render(data) {
5397
- var _this35 = this;
5573
+ var _this37 = this;
5398
5574
  if (!this.options.columns) {
5399
5575
  return;
5400
5576
  }
@@ -5421,7 +5597,7 @@ var WebsyTable = /*#__PURE__*/function () {
5421
5597
  if (c.width) {
5422
5598
  style += "width: ".concat(c.width || 'auto', ";");
5423
5599
  }
5424
- return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n <!--").concat(c.searchable === true ? _this35.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
5600
+ return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n <!--").concat(c.searchable === true ? _this37.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
5425
5601
  }
5426
5602
  }).join('') + '</tr>';
5427
5603
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
@@ -5439,7 +5615,7 @@ var WebsyTable = /*#__PURE__*/function () {
5439
5615
  var pagingEl = document.getElementById("".concat(this.elementId, "_pageList"));
5440
5616
  if (pagingEl) {
5441
5617
  var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
5442
- return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this35.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
5618
+ return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this37.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
5443
5619
  });
5444
5620
  var startIndex = 0;
5445
5621
  if (this.options.pageCount > 8) {
@@ -5494,7 +5670,7 @@ var WebsyTable = /*#__PURE__*/function () {
5494
5670
  /* global WebsyDesigns */
5495
5671
  var WebsyTable2 = /*#__PURE__*/function () {
5496
5672
  function WebsyTable2(elementId, options) {
5497
- var _this36 = this;
5673
+ var _this38 = this;
5498
5674
  _classCallCheck(this, WebsyTable2);
5499
5675
  var DEFAULTS = {
5500
5676
  pageSize: 20,
@@ -5529,8 +5705,8 @@ var WebsyTable2 = /*#__PURE__*/function () {
5529
5705
  allowClear: false,
5530
5706
  disableSearch: true,
5531
5707
  onItemSelected: function onItemSelected(selectedItem) {
5532
- if (_this36.options.onChangePageSize) {
5533
- _this36.options.onChangePageSize(selectedItem.value);
5708
+ if (_this38.options.onChangePageSize) {
5709
+ _this38.options.onChangePageSize(selectedItem.value);
5534
5710
  }
5535
5711
  }
5536
5712
  });
@@ -5552,20 +5728,20 @@ var WebsyTable2 = /*#__PURE__*/function () {
5552
5728
  _createClass(WebsyTable2, [{
5553
5729
  key: "appendRows",
5554
5730
  value: function appendRows(data) {
5555
- var _this37 = this;
5731
+ var _this39 = this;
5556
5732
  this.hideError();
5557
5733
  var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
5558
5734
  var bodyHTML = '';
5559
5735
  if (data) {
5560
5736
  bodyHTML += data.map(function (r, rowIndex) {
5561
5737
  return '<tr>' + r.map(function (c, i) {
5562
- if (_this37.options.columns[i].show !== false) {
5563
- var style = "height: ".concat(_this37.options.cellSize, "px; line-height: ").concat(_this37.options.cellSize, "px;");
5738
+ if (_this39.options.columns[i].show !== false) {
5739
+ var style = "height: ".concat(_this39.options.cellSize, "px; line-height: ").concat(_this39.options.cellSize, "px;");
5564
5740
  if (c.style) {
5565
5741
  style += c.style;
5566
5742
  }
5567
- if (_this37.options.columns[i].width) {
5568
- style += "width: ".concat(_this37.options.columns[i].width, "; ");
5743
+ if (_this39.options.columns[i].width) {
5744
+ style += "width: ".concat(_this39.options.columns[i].width, "; ");
5569
5745
  }
5570
5746
  if (c.backgroundColor) {
5571
5747
  style += "background-color: ".concat(c.backgroundColor, "; ");
@@ -5576,16 +5752,16 @@ var WebsyTable2 = /*#__PURE__*/function () {
5576
5752
  if (c.color) {
5577
5753
  style += "color: ".concat(c.color, "; ");
5578
5754
  }
5579
- if (_this37.options.columns[i].showAsLink === true && c.value.trim() !== '') {
5580
- return "\n <td \n data-row-index='".concat(_this37.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this37.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this37.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this37.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
5581
- } else if ((_this37.options.columns[i].showAsNavigatorLink === true || _this37.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
5582
- return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this37.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this37.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this37.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this37.options.columns[i].linkText || c.value, "</td>\n ");
5755
+ if (_this39.options.columns[i].showAsLink === true && c.value.trim() !== '') {
5756
+ return "\n <td \n data-row-index='".concat(_this39.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this39.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this39.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this39.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
5757
+ } else if ((_this39.options.columns[i].showAsNavigatorLink === true || _this39.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
5758
+ return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this39.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this39.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this39.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this39.options.columns[i].linkText || c.value, "</td>\n ");
5583
5759
  } else {
5584
5760
  var info = c.value;
5585
- if (_this37.options.columns[i].showAsImage === true) {
5761
+ if (_this39.options.columns[i].showAsImage === true) {
5586
5762
  c.value = "\n <img src='".concat(c.value, "'>\n ");
5587
5763
  }
5588
- return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this37.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this37.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
5764
+ return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this39.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this39.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
5589
5765
  }
5590
5766
  }
5591
5767
  }).join('') + '</tr>';
@@ -5819,7 +5995,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
5819
5995
  }, {
5820
5996
  key: "render",
5821
5997
  value: function render(data) {
5822
- var _this38 = this;
5998
+ var _this40 = this;
5823
5999
  if (!this.options.columns) {
5824
6000
  return;
5825
6001
  }
@@ -5847,7 +6023,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
5847
6023
  if (c.width) {
5848
6024
  style += "width: ".concat(c.width || 'auto', "; ");
5849
6025
  }
5850
- return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-sort-index=\"").concat(c.sortIndex || i, "\"\n data-index=\"").concat(i, "\"\n data-sort=\"").concat(c.sort, "\"\n style=\"").concat(c.style || '', "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n ").concat(c.searchable === true ? _this38.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
6026
+ return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-sort-index=\"").concat(c.sortIndex || i, "\"\n data-index=\"").concat(i, "\"\n data-sort=\"").concat(c.sort, "\"\n style=\"").concat(c.style || '', "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n ").concat(c.searchable === true ? _this40.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
5851
6027
  }
5852
6028
  }).join('') + '</tr>';
5853
6029
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
@@ -5857,7 +6033,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
5857
6033
  var dropdownHTML = "";
5858
6034
  this.options.columns.forEach(function (c, i) {
5859
6035
  if (c.searchable && c.searchField) {
5860
- dropdownHTML += "\n <div id=\"".concat(_this38.elementId, "_columnSearch_").concat(i, "\" class=\"websy-modal-dropdown\"></div>\n ");
6036
+ dropdownHTML += "\n <div id=\"".concat(_this40.elementId, "_columnSearch_").concat(i, "\" class=\"websy-modal-dropdown\"></div>\n ");
5861
6037
  }
5862
6038
  });
5863
6039
  dropdownEl.innerHTML = dropdownHTML;
@@ -5877,7 +6053,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
5877
6053
  var pagingEl = document.getElementById("".concat(this.elementId, "_pageList"));
5878
6054
  if (pagingEl) {
5879
6055
  var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
5880
- return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this38.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
6056
+ return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this40.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
5881
6057
  });
5882
6058
  var startIndex = 0;
5883
6059
  if (this.options.pageCount > 8) {
@@ -5954,17 +6130,17 @@ var WebsyTable2 = /*#__PURE__*/function () {
5954
6130
  }, {
5955
6131
  key: "getColumnParameters",
5956
6132
  value: function getColumnParameters(values) {
5957
- var _this39 = this;
6133
+ var _this41 = this;
5958
6134
  var tableEl = document.getElementById("".concat(this.elementId, "_table"));
5959
6135
  tableEl.style.tableLayout = 'auto';
5960
6136
  tableEl.style.width = 'auto';
5961
6137
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
5962
6138
  var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
5963
6139
  headEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c, i) {
5964
- return "\n <th>\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField\" \n >\n ".concat(c.value || 'nbsp;', "\n </div>\n </div> \n ").concat(c.searchable === true ? _this39.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
6140
+ return "\n <th>\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField\" \n >\n ".concat(c.value || 'nbsp;', "\n </div>\n </div> \n ").concat(c.searchable === true ? _this41.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
5965
6141
  }).join('') + '</tr>';
5966
6142
  bodyEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c) {
5967
- return "\n <td \n style='height: ".concat(_this39.options.cellSize, "px; line-height: ").concat(_this39.options.cellSize, "px; padding: 10px 5px;'\n >").concat(c.value || '&nbsp;', "</td>\n ");
6143
+ return "\n <td \n style='height: ".concat(_this41.options.cellSize, "px; line-height: ").concat(_this41.options.cellSize, "px; padding: 10px 5px;'\n >").concat(c.value || '&nbsp;', "</td>\n ");
5968
6144
  }).join('') + '</tr>';
5969
6145
  // get height of the first data cell
5970
6146
  var cells = bodyEl.querySelectorAll("tr:first-of-type td");
@@ -6025,6 +6201,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6025
6201
  autoFitColumns: true
6026
6202
  };
6027
6203
  this.options = _extends({}, DEFAULTS, options);
6204
+ this._isRendered = false;
6028
6205
  this.isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
6029
6206
  if (this.options.disableTouch === true) {
6030
6207
  this.isTouchDevice = false;
@@ -6085,6 +6262,11 @@ var WebsyTable3 = /*#__PURE__*/function () {
6085
6262
  }
6086
6263
  }
6087
6264
  _createClass(WebsyTable3, [{
6265
+ key: "isRendered",
6266
+ get: function get() {
6267
+ return this._isRendered;
6268
+ }
6269
+ }, {
6088
6270
  key: "columns",
6089
6271
  set: function set(columns) {
6090
6272
  this.options.columns = columns;
@@ -6099,6 +6281,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6099
6281
  }, {
6100
6282
  key: "appendRows",
6101
6283
  value: function appendRows(data) {
6284
+ this._isRendered = false;
6102
6285
  this.hideError();
6103
6286
  var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody"));
6104
6287
  if (bodyEl) {
@@ -6110,6 +6293,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6110
6293
  bodyEl.querySelector('tbody').innerHTML += this.buildBodyHtml(data, true, true);
6111
6294
  } else {
6112
6295
  bodyEl.innerHTML += this.buildBodyHtml(data, true);
6296
+ this._isRendered = true;
6113
6297
  }
6114
6298
  this.currentData = this.currentData.concat(data);
6115
6299
  }
@@ -6120,7 +6304,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6120
6304
  }, {
6121
6305
  key: "buildBodyHtml",
6122
6306
  value: function buildBodyHtml() {
6123
- var _this40 = this;
6307
+ var _this42 = this;
6124
6308
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6125
6309
  var useWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6126
6310
  if (!this.options.columns) {
@@ -6145,7 +6329,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6145
6329
  row.forEach(function (cell, cellIndex) {
6146
6330
  var sizeIndex = cell.level || cellIndex;
6147
6331
  var colIndex = cell.index || cellIndex;
6148
- if (typeof sizingColumns[sizeIndex] === 'undefined' || _this40.options.columns[_this40.options.columns.length - 1][colIndex].show === false) {
6332
+ if (typeof sizingColumns[sizeIndex] === 'undefined' || _this42.options.columns[_this42.options.columns.length - 1][colIndex].show === false) {
6149
6333
  return; // need to revisit this logic
6150
6334
  }
6151
6335
 
@@ -6172,7 +6356,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6172
6356
  style += "color: ".concat(cell.color, "; ");
6173
6357
  }
6174
6358
  // console.log('rowspan', cell.rowspan)
6175
- bodyHtml += "<td \n class='websy-table-cell ".concat(sizeIndex < _this40.pinnedColumns ? 'pinned' : 'unpinned', " ").concat((cell.classes || []).join(' '), " ").concat((sizingColumns[sizeIndex].classes || []).join(' '), "'\n style='").concat(style, "'\n data-info='").concat(cell.value.replace ? cell.value.replace(/'/g, '`') : cell.value, "'\n colspan='").concat(cell.colspan || 1, "'\n rowspan='").concat(cell.rowspan || 1, "'\n data-row-index='").concat(rowIndex, "'\n data-cell-index='").concat(cellIndex, "'\n data-col-index='").concat(colIndex, "'\n ");
6359
+ bodyHtml += "<td \n class='websy-table-cell ".concat(sizeIndex < _this42.pinnedColumns ? 'pinned' : 'unpinned', " ").concat((cell.classes || []).join(' '), " ").concat((sizingColumns[sizeIndex].classes || []).join(' '), "'\n style='").concat(style, "'\n data-info='").concat(cell.value.replace ? cell.value.replace(/'/g, '`') : cell.value, "'\n colspan='").concat(cell.colspan || 1, "'\n rowspan='").concat(cell.rowspan || 1, "'\n data-row-index='").concat(rowIndex, "'\n data-cell-index='").concat(cellIndex, "'\n data-col-index='").concat(colIndex, "'\n ");
6176
6360
  // if (useWidths === true) {
6177
6361
  // bodyHtml += `
6178
6362
  // style='width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important'
@@ -6181,10 +6365,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
6181
6365
  // }
6182
6366
  bodyHtml += "\n ><div \n style='".concat(divStyle, "' \n class='websy-table-cell-content'\n data-row-index='").concat(rowIndex, "'\n data-cell-index='").concat(cellIndex, "'\n data-col-index='").concat(colIndex, "'\n >");
6183
6367
  if (cell.expandable === true) {
6184
- bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-expand'\n >").concat(_this40.options.plusIcon, "</i>");
6368
+ bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-expand'\n >").concat(_this42.options.plusIcon, "</i>");
6185
6369
  }
6186
6370
  if (cell.collapsable === true) {
6187
- bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-collapse'\n >").concat(_this40.options.minusIcon, "</i>");
6371
+ bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-collapse'\n >").concat(_this42.options.minusIcon, "</i>");
6188
6372
  }
6189
6373
  if (sizingColumns[sizeIndex].showAsLink === true && cell.value.trim() !== '') {
6190
6374
  cell.value = "\n <a href=\"".concat(encodeURI(cell.value), "\" target='").concat(sizingColumns[sizeIndex].openInNewTab === true ? '_blank' : '_self', "'>").concat(cell.displayText || sizingColumns[sizeIndex].linkText || cell.value, "</a>\n ");
@@ -6205,7 +6389,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6205
6389
  }, {
6206
6390
  key: "buildHeaderHtml",
6207
6391
  value: function buildHeaderHtml() {
6208
- var _this41 = this;
6392
+ var _this43 = this;
6209
6393
  var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
6210
6394
  if (!this.options.columns) {
6211
6395
  return '';
@@ -6222,7 +6406,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6222
6406
  headerHtml += '</colgroup>';
6223
6407
  }
6224
6408
  this.options.columns.forEach(function (row, rowIndex) {
6225
- if (useWidths === false && rowIndex !== _this41.options.columns.length - 1) {
6409
+ if (useWidths === false && rowIndex !== _this43.options.columns.length - 1) {
6226
6410
  // if we're calculating the size we only want to render the last row of column headers
6227
6411
  return;
6228
6412
  }
@@ -6246,24 +6430,24 @@ var WebsyTable3 = /*#__PURE__*/function () {
6246
6430
  if (col.style) {
6247
6431
  style += col.style;
6248
6432
  }
6249
- headerHtml += "<td \n class='websy-table-cell ".concat(colIndex < _this41.pinnedColumns ? 'pinned' : 'unpinned', " ").concat((col.classes || []).join(' '), "' \n style='").concat(style, "' \n colspan='").concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n ");
6433
+ headerHtml += "<td \n class='websy-table-cell ".concat(colIndex < _this43.pinnedColumns ? 'pinned' : 'unpinned', " ").concat((col.classes || []).join(' '), "' \n style='").concat(style, "' \n colspan='").concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n ");
6250
6434
  // if (useWidths === true && rowIndex === this.options.columns.length - 1) {
6251
6435
  // headerHtml += `
6252
6436
  // style='width: ${col.width || col.actualWidth}px'
6253
6437
  // width='${col.width || col.actualWidth}'
6254
6438
  // `
6255
6439
  // }
6256
- headerHtml += ">\n <div \n style='".concat(divStyle, "'\n data-col-index=\"").concat(colIndex, "\"\n class='").concat(['asc', 'desc'].indexOf(col.sort) !== -1 ? 'sortable-column' : '', "'\n >\n ").concat(col.name).concat(col.activeSort ? _this41.buildSortIcon(col.sort, colIndex) : '').concat(col.searchable === true ? _this41.buildSearchIcon(col, colIndex) : '', "\n </div>\n </td>");
6440
+ headerHtml += ">\n <div \n style='".concat(divStyle, "'\n data-col-index=\"").concat(colIndex, "\"\n class='").concat(['asc', 'desc'].indexOf(col.sort) !== -1 ? 'sortable-column' : '', "'\n >\n ").concat(col.name).concat(col.activeSort ? _this43.buildSortIcon(col.sort, colIndex) : '').concat(col.searchable === true ? _this43.buildSearchIcon(col, colIndex) : '', "\n </div>\n </td>");
6257
6441
  });
6258
6442
  headerHtml += "</tr>";
6259
6443
  });
6260
6444
  var dropdownEl = document.getElementById("".concat(this.elementId, "_dropdownContainer"));
6261
6445
  this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
6262
6446
  if (c.searchable && c.isExternalSearch === true) {
6263
- var testEl = document.getElementById("".concat(_this41.elementId, "_columnSearch_").concat(c.dimId || i));
6447
+ var testEl = document.getElementById("".concat(_this43.elementId, "_columnSearch_").concat(c.dimId || i));
6264
6448
  if (!testEl) {
6265
6449
  var newE = document.createElement('div');
6266
- newE.id = "".concat(_this41.elementId, "_columnSearch_").concat(c.dimId || i);
6450
+ newE.id = "".concat(_this43.elementId, "_columnSearch_").concat(c.dimId || i);
6267
6451
  newE.className = 'websy-modal-dropdown';
6268
6452
  dropdownEl.appendChild(newE);
6269
6453
  }
@@ -6286,7 +6470,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6286
6470
  }, {
6287
6471
  key: "buildTotalHtml",
6288
6472
  value: function buildTotalHtml() {
6289
- var _this42 = this;
6473
+ var _this44 = this;
6290
6474
  var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
6291
6475
  if (!this.options.totals) {
6292
6476
  return '';
@@ -6302,7 +6486,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6302
6486
 
6303
6487
  totalHtml += "<td \n class='websy-table-cell ".concat((col.classes || []).join(' '), "'\n colspan='").concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n ");
6304
6488
  if (useWidths === true) {
6305
- totalHtml += "\n style='width: ".concat(_this42.options.columns[_this42.options.columns.length - 1][colIndex].width || _this42.options.columns[_this42.options.columns.length - 1][colIndex].actualWidth, "px'\n width='").concat(col.width || col.actualWidth, "'\n ");
6489
+ totalHtml += "\n style='width: ".concat(_this44.options.columns[_this44.options.columns.length - 1][colIndex].width || _this44.options.columns[_this44.options.columns.length - 1][colIndex].actualWidth, "px'\n width='").concat(col.width || col.actualWidth, "'\n ");
6306
6490
  }
6307
6491
  totalHtml += " \n >\n ".concat(col.value, "\n </td>");
6308
6492
  });
@@ -6312,7 +6496,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6312
6496
  }, {
6313
6497
  key: "calculateSizes",
6314
6498
  value: function calculateSizes() {
6315
- var _this43 = this;
6499
+ var _this45 = this;
6316
6500
  var sample = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6317
6501
  var totalRowCount = arguments.length > 1 ? arguments[1] : undefined;
6318
6502
  var totalColumnCount = arguments.length > 2 ? arguments[2] : undefined;
@@ -6356,7 +6540,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6356
6540
  rows.forEach(function (row, rowIndex) {
6357
6541
  Array.from(row.children).forEach(function (col, colIndex) {
6358
6542
  var colSize = col.getBoundingClientRect();
6359
- _this43.sizes.cellHeight = colSize.height;
6543
+ _this45.sizes.cellHeight = colSize.height;
6360
6544
  if (columnsForSizing[colIndex]) {
6361
6545
  if (!columnsForSizing[colIndex].actualWidth) {
6362
6546
  columnsForSizing[colIndex].potentialWidth = 0;
@@ -6368,7 +6552,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6368
6552
  // columnsForSizing[colIndex].actualWidth = columnsForSizing[colIndex].width
6369
6553
  // }
6370
6554
  columnsForSizing[colIndex].cellHeight = colSize.height;
6371
- if (colIndex >= _this43.pinnedColumns) {
6555
+ if (colIndex >= _this45.pinnedColumns) {
6372
6556
  firstNonPinnedColumnWidth = columnsForSizing[colIndex].actualWidth;
6373
6557
  }
6374
6558
  }
@@ -6383,7 +6567,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6383
6567
  return a + (b.width || b.actualWidth);
6384
6568
  }, 0);
6385
6569
  this.sizes.totalNonPinnedWidth = columnsForSizing.filter(function (c, i) {
6386
- return i >= _this43.pinnedColumns;
6570
+ return i >= _this45.pinnedColumns;
6387
6571
  }).reduce(function (a, b) {
6388
6572
  return a + (b.width || b.actualWidth);
6389
6573
  }, 0);
@@ -6394,7 +6578,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6394
6578
  var availableSpace = this.sizes.table.width - this.sizes.totalWidth;
6395
6579
  columnsForSizing.forEach(function (c) {
6396
6580
  c.shouldGrow = true;
6397
- if (_this43.options.autoFitColumns === false) {
6581
+ if (_this45.options.autoFitColumns === false) {
6398
6582
  c.shouldGrow = false;
6399
6583
  if (c.potentialWidth > c.actualWidth) {
6400
6584
  c.shouldGrow = true;
@@ -6413,7 +6597,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6413
6597
  // if (!c.width) {
6414
6598
  // if (c.actualWidth < equalWidth) {
6415
6599
  // adjust the width
6416
- if (_this43.options.autoFitColumns === true) {
6600
+ if (_this45.options.autoFitColumns === true) {
6417
6601
  if (c.width) {
6418
6602
  c.width += equalWidth;
6419
6603
  }
@@ -6437,9 +6621,9 @@ var WebsyTable3 = /*#__PURE__*/function () {
6437
6621
  }
6438
6622
  // }
6439
6623
  // }
6440
- _this43.sizes.totalWidth += c.width || c.actualWidth;
6441
- if (i > _this43.pinnedColumns) {
6442
- _this43.sizes.totalNonPinnedWidth += c.width || c.actualWidth;
6624
+ _this45.sizes.totalWidth += c.width || c.actualWidth;
6625
+ if (i > _this45.pinnedColumns) {
6626
+ _this45.sizes.totalNonPinnedWidth += c.width || c.actualWidth;
6443
6627
  }
6444
6628
  // equalWidth = (outerSize.width - this.sizes.totalWidth) / (this.options.columns[this.options.columns.length - 1].length - (i + 1))
6445
6629
  });
@@ -6498,7 +6682,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6498
6682
  }, {
6499
6683
  key: "createSample",
6500
6684
  value: function createSample(data) {
6501
- var _this44 = this;
6685
+ var _this46 = this;
6502
6686
  var output = [];
6503
6687
  this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
6504
6688
  if (col.maxLength) {
@@ -6508,7 +6692,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6508
6692
  } else if (data) {
6509
6693
  var longest = '';
6510
6694
  for (var i = 0; i < Math.min(data.length, 1000); i++) {
6511
- if (data[i].length === _this44.options.columns[_this44.options.columns.length - 1].length) {
6695
+ if (data[i].length === _this46.options.columns[_this46.options.columns.length - 1].length) {
6512
6696
  if (longest.length < data[i][colIndex].value.length) {
6513
6697
  longest = data[i][colIndex].value;
6514
6698
  }
@@ -6780,7 +6964,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6780
6964
  }, {
6781
6965
  key: "perpetualScroll",
6782
6966
  value: function perpetualScroll() {
6783
- var _this45 = this;
6967
+ var _this47 = this;
6784
6968
  // if the currentTouchtime and touchEndTime are more than 300ms apart then we abort the perpetual scroll
6785
6969
  if (this.touchEndTime - this.currentTouchtime > 300) {
6786
6970
  return;
@@ -6799,17 +6983,17 @@ var WebsyTable3 = /*#__PURE__*/function () {
6799
6983
  var direction = touchDistance > 0 ? -1 : 1;
6800
6984
  var _loop2 = function _loop2(i) {
6801
6985
  setTimeout(function () {
6802
- var delta = _this45.mouseYStart - _this45.currentClientY + _this45.sizes.cellHeight * (i + 1) * direction;
6986
+ var delta = _this47.mouseYStart - _this47.currentClientY + _this47.sizes.cellHeight * (i + 1) * direction;
6803
6987
  delta = Math.min(10, delta);
6804
6988
  delta = Math.max(-10, delta);
6805
6989
  // only run this if isPerpetual === true
6806
6990
  // this value is reset to false on touchStart
6807
- if (_this45.isPerpetual === true) {
6991
+ if (_this47.isPerpetual === true) {
6808
6992
  // this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 250)))
6809
6993
  // this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 200)))
6810
- _this45.scrollY(Math.max(-5, Math.min(5, delta)));
6811
- if (_this45.scrollTimeout) {
6812
- clearTimeout(_this45.scrollTimeout);
6994
+ _this47.scrollY(Math.max(-5, Math.min(5, delta)));
6995
+ if (_this47.scrollTimeout) {
6996
+ clearTimeout(_this47.scrollTimeout);
6813
6997
  }
6814
6998
  }
6815
6999
  }, 1000 / fps * i);
@@ -7077,7 +7261,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
7077
7261
  /* global d3 include WebsyDesigns */
7078
7262
  var WebsyChart = /*#__PURE__*/function () {
7079
7263
  function WebsyChart(elementId, options) {
7080
- var _this46 = this;
7264
+ var _this48 = this;
7081
7265
  _classCallCheck(this, WebsyChart);
7082
7266
  var DEFAULTS = {
7083
7267
  margin: {
@@ -7115,10 +7299,12 @@ var WebsyChart = /*#__PURE__*/function () {
7115
7299
  maxBandWidth: 100,
7116
7300
  allowUnevenBands: true,
7117
7301
  allowBrushing: true,
7118
- balancedMinMax: false
7302
+ balancedMinMax: false,
7303
+ onRendered: function onRendered() {}
7119
7304
  };
7120
7305
  this.elementId = elementId;
7121
7306
  this.options = _extends({}, DEFAULTS, options);
7307
+ this._isRendered = false;
7122
7308
  this.leftAxis = null;
7123
7309
  this.rightAxis = null;
7124
7310
  this.topAxis = null;
@@ -7134,7 +7320,7 @@ var WebsyChart = /*#__PURE__*/function () {
7134
7320
  this.invertOverride = function (input, input2) {
7135
7321
  var forBrush = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
7136
7322
  var xAxis = 'bottom';
7137
- if (_this46.options.orientation === 'horizontal') {
7323
+ if (_this48.options.orientation === 'horizontal') {
7138
7324
  xAxis = 'left';
7139
7325
  }
7140
7326
  if (forBrush === true) {
@@ -7142,12 +7328,12 @@ var WebsyChart = /*#__PURE__*/function () {
7142
7328
  }
7143
7329
  xAxis += 'Axis';
7144
7330
  var output;
7145
- var width = _this46.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth;
7331
+ var width = _this48.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth;
7146
7332
  // if (this.customBottomRange) {
7147
- for (var index = 0; index < _this46.customBottomRange.length; index++) {
7148
- if (input > _this46.customBottomRange[index]) {
7149
- if (_this46.customBottomRange[index + 1]) {
7150
- if (input < _this46.customBottomRange[index + 1]) {
7333
+ for (var index = 0; index < _this48.customBottomRange.length; index++) {
7334
+ if (input > _this48.customBottomRange[index]) {
7335
+ if (_this48.customBottomRange[index + 1]) {
7336
+ if (input < _this48.customBottomRange[index + 1]) {
7151
7337
  output = index;
7152
7338
  break;
7153
7339
  }
@@ -7157,21 +7343,6 @@ var WebsyChart = /*#__PURE__*/function () {
7157
7343
  }
7158
7344
  }
7159
7345
  }
7160
- // }
7161
- // else {
7162
- // let domain = [...this[xAxis].domain()]
7163
- // if (this.options.orientation === 'horizontal') {
7164
- // domain = domain.reverse()
7165
- // }
7166
- // for (let j = 0; j < domain.length; j++) {
7167
- // let breakA = this[xAxis](domain[j]) - (width / 2)
7168
- // let breakB = breakA + width
7169
- // if (input > breakA && input <= breakB) {
7170
- // output = j
7171
- // break
7172
- // }
7173
- // }
7174
- // }
7175
7346
  return output;
7176
7347
  };
7177
7348
  var that = this;
@@ -7246,6 +7417,11 @@ var WebsyChart = /*#__PURE__*/function () {
7246
7417
  this.options.data = d;
7247
7418
  this.render();
7248
7419
  }
7420
+ }, {
7421
+ key: "isRendered",
7422
+ get: function get() {
7423
+ return this._isRendered;
7424
+ }
7249
7425
  }, {
7250
7426
  key: "close",
7251
7427
  value: function close() {
@@ -7322,9 +7498,9 @@ var WebsyChart = /*#__PURE__*/function () {
7322
7498
  }, {
7323
7499
  key: "handleEventMouseMove",
7324
7500
  value: function handleEventMouseMove(event, d) {
7325
- var _this47 = this;
7501
+ var _this49 = this;
7326
7502
  var bisectDate = d3.bisector(function (d) {
7327
- return _this47.parseX(d.x.value);
7503
+ return _this49.parseX(d.x.value);
7328
7504
  }).left;
7329
7505
  if (this.options.showTrackingLine === true && d3.pointer(event)) {
7330
7506
  var xAxis = 'bottomAxis';
@@ -7357,9 +7533,9 @@ var WebsyChart = /*#__PURE__*/function () {
7357
7533
  xLabel = _toConsumableArray(this[xAxis].domain().reverse())[x0];
7358
7534
  }
7359
7535
  this.options.data.series.forEach(function (s) {
7360
- if (_this47.options.data[xData].scale !== 'Time') {
7536
+ if (_this49.options.data[xData].scale !== 'Time') {
7361
7537
  // if (this.customBottomRange && this.customBottomRange.length > 0) {
7362
- xPoint = _this47.customBottomRange[x0] + (_this47.customBottomRange[x0 + 1] - _this47.customBottomRange[x0]) / 2;
7538
+ xPoint = _this49.customBottomRange[x0] + (_this49.customBottomRange[x0 + 1] - _this49.customBottomRange[x0]) / 2;
7363
7539
  // }
7364
7540
  // else {
7365
7541
  // xPoint = this[xAxis](this.parseX(xLabel))
@@ -7379,41 +7555,41 @@ var WebsyChart = /*#__PURE__*/function () {
7379
7555
  var index = bisectDate(s.data, x0, 1);
7380
7556
  var pointA = s.data[index - 1];
7381
7557
  var pointB = s.data[index];
7382
- if (_this47.options.orientation === 'horizontal') {
7558
+ if (_this49.options.orientation === 'horizontal') {
7383
7559
  pointA = _toConsumableArray(s.data).reverse()[index - 1];
7384
7560
  pointB = _toConsumableArray(s.data).reverse()[index];
7385
7561
  }
7386
7562
  if (pointA && !pointB) {
7387
- xPoint = _this47[xAxis](_this47.parseX(pointA.x.value));
7563
+ xPoint = _this49[xAxis](_this49.parseX(pointA.x.value));
7388
7564
  tooltipTitle = pointA.x.value;
7389
7565
  if (!pointA.y.color) {
7390
7566
  pointA.y.color = s.color;
7391
7567
  }
7392
7568
  tooltipData.push(pointA);
7393
7569
  if (typeof pointA.x.value.getTime !== 'undefined') {
7394
- tooltipTitle = d3.timeFormat(_this47.options.dateFormat || _this47.options.calculatedTimeFormatPattern)(pointA.x.value);
7570
+ tooltipTitle = d3.timeFormat(_this49.options.dateFormat || _this49.options.calculatedTimeFormatPattern)(pointA.x.value);
7395
7571
  }
7396
7572
  }
7397
7573
  if (pointB && !pointA) {
7398
- xPoint = _this47[xAxis](_this47.parseX(pointB.x.value));
7574
+ xPoint = _this49[xAxis](_this49.parseX(pointB.x.value));
7399
7575
  tooltipTitle = pointB.x.value;
7400
7576
  if (!pointB.y.color) {
7401
7577
  pointB.y.color = s.color;
7402
7578
  }
7403
7579
  tooltipData.push(pointB);
7404
7580
  if (typeof pointB.x.value.getTime !== 'undefined') {
7405
- tooltipTitle = d3.timeFormat(_this47.options.dateFormat || _this47.options.calculatedTimeFormatPattern)(pointB.x.value);
7581
+ tooltipTitle = d3.timeFormat(_this49.options.dateFormat || _this49.options.calculatedTimeFormatPattern)(pointB.x.value);
7406
7582
  }
7407
7583
  }
7408
7584
  if (pointA && pointB) {
7409
- var d0 = _this47[xAxis](_this47.parseX(pointA.x.value));
7410
- var d1 = _this47[xAxis](_this47.parseX(pointB.x.value));
7585
+ var d0 = _this49[xAxis](_this49.parseX(pointA.x.value));
7586
+ var d1 = _this49[xAxis](_this49.parseX(pointB.x.value));
7411
7587
  var mid = Math.abs(d0 - d1) / 2;
7412
7588
  if (d3.pointer(event)[0] - d0 >= mid) {
7413
7589
  xPoint = d1;
7414
7590
  tooltipTitle = pointB.x.value;
7415
7591
  if (typeof pointB.x.value.getTime !== 'undefined') {
7416
- tooltipTitle = d3.timeFormat(_this47.options.dateFormat || _this47.options.calculatedTimeFormatPattern)(pointB.x.value);
7592
+ tooltipTitle = d3.timeFormat(_this49.options.dateFormat || _this49.options.calculatedTimeFormatPattern)(pointB.x.value);
7417
7593
  }
7418
7594
  if (!pointB.y.color) {
7419
7595
  pointB.y.color = s.color;
@@ -7423,7 +7599,7 @@ var WebsyChart = /*#__PURE__*/function () {
7423
7599
  xPoint = d0;
7424
7600
  tooltipTitle = pointA.x.value;
7425
7601
  if (typeof pointB.x.value.getTime !== 'undefined') {
7426
- tooltipTitle = d3.timeFormat(_this47.options.dateFormat || _this47.options.calculatedTimeFormatPattern)(pointB.x.value);
7602
+ tooltipTitle = d3.timeFormat(_this49.options.dateFormat || _this49.options.calculatedTimeFormatPattern)(pointB.x.value);
7427
7603
  }
7428
7604
  if (!pointA.y.color) {
7429
7605
  pointA.y.color = s.color;
@@ -7549,8 +7725,9 @@ var WebsyChart = /*#__PURE__*/function () {
7549
7725
  }, {
7550
7726
  key: "render",
7551
7727
  value: function render(options) {
7552
- var _this48 = this;
7728
+ var _this50 = this;
7553
7729
  /* global d3 options WebsyUtils */
7730
+ this._isRendered = false;
7554
7731
  if (typeof options !== 'undefined') {
7555
7732
  this.options = _extends({}, this.options, options);
7556
7733
  if (this.options.legendOptions) {
@@ -7617,7 +7794,7 @@ var WebsyChart = /*#__PURE__*/function () {
7617
7794
  this.options.data.series.map(function (s, i) {
7618
7795
  return {
7619
7796
  value: s.label || s.key,
7620
- color: s.color || _this48.options.colors[i % _this48.options.colors.length]
7797
+ color: s.color || _this50.options.colors[i % _this50.options.colors.length]
7621
7798
  };
7622
7799
  });
7623
7800
  }
@@ -7974,25 +8151,25 @@ var WebsyChart = /*#__PURE__*/function () {
7974
8151
  if (this.options.data[customRangeSideLC].data && this.options.data[customRangeSideLC].data[0] && (this.options.data[customRangeSideLC].data[0].valueCount || 1) && this.options.data[customRangeSideLC].scale === 'Ordinal') {
7975
8152
  var acc = 0;
7976
8153
  this["custom".concat(customRangeSide, "Range")] = [0].concat(_toConsumableArray(this.options.data[customRangeSideLC].data.map(function (d, index, arr) {
7977
- var adjustment = _this48.bandPadding * index + _this48.bandPadding;
8154
+ var adjustment = _this50.bandPadding * index + _this50.bandPadding;
7978
8155
  // if (this.options.data.bottom.padding) {
7979
8156
  // adjustment = (this.widthForCalc * this.options.data.bottom.padding) / (arr.length * 2)
7980
8157
  // }
7981
- var start = _this48.widthForCalc / noOfPoints * acc;
8158
+ var start = _this50.widthForCalc / noOfPoints * acc;
7982
8159
  for (var i = 0; i < (d.valueCount || 1); i++) {
7983
8160
  var pos = i * proposedBandWidth;
7984
- _this48["custom".concat(customRangeSide, "DetailRange")].push(start + adjustment + pos);
8161
+ _this50["custom".concat(customRangeSide, "DetailRange")].push(start + adjustment + pos);
7985
8162
  }
7986
- acc += _this48.options.grouping !== 'stacked' && _this48.options.allowUnevenBands === true ? d.valueCount || 1 : 1;
7987
- var end = _this48.widthForCalc / noOfPoints * acc;
8163
+ acc += _this50.options.grouping !== 'stacked' && _this50.options.allowUnevenBands === true ? d.valueCount || 1 : 1;
8164
+ var end = _this50.widthForCalc / noOfPoints * acc;
7988
8165
  // this.customBottomBrushRange.push((end + adjustment) * (this.plotWidth / this.widthForCalc))
7989
8166
  return end + adjustment;
7990
8167
  })));
7991
8168
  acc = 0;
7992
8169
  this["custom".concat(customRangeSide, "BrushRange")] = [0].concat(_toConsumableArray(this.options.data[customRangeSideLC].data.map(function (d, index, arr) {
7993
- var adjustment = _this48.brushBandPadding * index + _this48.brushBandPadding;
7994
- acc += _this48.options.grouping !== 'stacked' && _this48.options.allowUnevenBands === true ? d.valueCount || 1 : 1;
7995
- return (_this48.options.orientation === 'vertical' ? _this48.plotWidth : _this48.plotHeight) / noOfPoints * acc;
8170
+ var adjustment = _this50.brushBandPadding * index + _this50.brushBandPadding;
8171
+ acc += _this50.options.grouping !== 'stacked' && _this50.options.allowUnevenBands === true ? d.valueCount || 1 : 1;
8172
+ return (_this50.options.orientation === 'vertical' ? _this50.plotWidth : _this50.plotHeight) / noOfPoints * acc;
7996
8173
  })));
7997
8174
  }
7998
8175
  // }
@@ -8165,7 +8342,7 @@ var WebsyChart = /*#__PURE__*/function () {
8165
8342
  this.bAxisFunc = d3.axisBottom(this.bottomAxis).ticks(tickDefinition);
8166
8343
  if (this.options.data.bottom.formatter) {
8167
8344
  this.bAxisFunc.tickFormat(function (d) {
8168
- return _this48.options.data.bottom.formatter(d);
8345
+ return _this50.options.data.bottom.formatter(d);
8169
8346
  });
8170
8347
  }
8171
8348
  this.bottomAxisLayer.call(this.bAxisFunc);
@@ -8175,7 +8352,7 @@ var WebsyChart = /*#__PURE__*/function () {
8175
8352
  }
8176
8353
  if (this.customBottomRange.length > 0) {
8177
8354
  this.bottomAxisLayer.selectAll('g').attr('transform', function (d, i) {
8178
- return "translate(".concat(_this48.customBottomRange[i] + (_this48.customBottomRange[i + 1] - _this48.customBottomRange[i]) / 2, ", 0)");
8355
+ return "translate(".concat(_this50.customBottomRange[i] + (_this50.customBottomRange[i + 1] - _this50.customBottomRange[i]) / 2, ", 0)");
8179
8356
  });
8180
8357
  }
8181
8358
  }
@@ -8194,14 +8371,14 @@ var WebsyChart = /*#__PURE__*/function () {
8194
8371
  }
8195
8372
  if (this.options.margin.axisLeft > 0) {
8196
8373
  this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
8197
- if (_this48.options.data.left.formatter) {
8198
- d = _this48.options.data.left.formatter(d);
8374
+ if (_this50.options.data.left.formatter) {
8375
+ d = _this50.options.data.left.formatter(d);
8199
8376
  }
8200
8377
  return d;
8201
8378
  }));
8202
8379
  if (this.customLeftRange.length > 0) {
8203
8380
  this.leftAxisLayer.selectAll('g').attr('transform', function (d, i) {
8204
- return "translate(0, ".concat(_this48.customLeftRange[i] + (_this48.customLeftRange[i + 1] - _this48.customLeftRange[i]) / 2, ")");
8381
+ return "translate(0, ".concat(_this50.customLeftRange[i] + (_this50.customLeftRange[i + 1] - _this50.customLeftRange[i]) / 2, ")");
8205
8382
  });
8206
8383
  }
8207
8384
  }
@@ -8229,8 +8406,8 @@ var WebsyChart = /*#__PURE__*/function () {
8229
8406
  }
8230
8407
  if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
8231
8408
  this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.right.ticks || 5).tickFormat(function (d) {
8232
- if (_this48.options.data.right.formatter) {
8233
- d = _this48.options.data.right.formatter(d);
8409
+ if (_this50.options.data.right.formatter) {
8410
+ d = _this50.options.data.right.formatter(d);
8234
8411
  }
8235
8412
  return d;
8236
8413
  }));
@@ -8270,50 +8447,51 @@ var WebsyChart = /*#__PURE__*/function () {
8270
8447
  }, {
8271
8448
  key: "renderComponents",
8272
8449
  value: function renderComponents() {
8273
- var _this49 = this;
8450
+ var _this51 = this;
8274
8451
  // Draw the series data
8275
8452
  this.renderedKeys = {};
8276
8453
  this.options.data.series.forEach(function (series, index) {
8277
8454
  if (!series.key) {
8278
- series.key = _this49.createIdentity();
8455
+ series.key = _this51.createIdentity();
8279
8456
  }
8280
8457
  if (!series.color) {
8281
- series.color = _this49.options.colors[index % _this49.options.colors.length];
8458
+ series.color = _this51.options.colors[index % _this51.options.colors.length];
8282
8459
  }
8283
- _this49["render".concat(series.type || 'bar')](series, index);
8284
- _this49.renderLabels(series, index);
8285
- _this49.renderedKeys[series.key] = series.type;
8460
+ _this51["render".concat(series.type || 'bar')](series, index);
8461
+ _this51.renderLabels(series, index);
8462
+ _this51.renderedKeys[series.key] = series.type;
8286
8463
  });
8287
8464
  this.refLineLayer.selectAll('.reference-line').remove();
8288
8465
  this.refLineLayer.selectAll('.reference-line-label').remove();
8289
8466
  if (this.options.refLines && this.options.refLines.length > 0) {
8290
8467
  this.options.refLines.forEach(function (l) {
8291
- return _this49.renderRefLine(l);
8468
+ return _this51.renderRefLine(l);
8292
8469
  });
8293
8470
  }
8471
+ this._isRendered = true;
8294
8472
  }
8295
8473
  }, {
8296
8474
  key: "renderarea",
8297
8475
  value: function renderarea(series, index) {
8298
- var _this50 = this;
8476
+ var _this52 = this;
8299
8477
  /* global d3 series index */
8300
8478
  var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
8301
8479
  return d3.area().x(function (d) {
8302
- if (_this50.options.data[xAxis].scale === 'Time') {
8303
- return _this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value));
8480
+ if (_this52.options.data[xAxis].scale === 'Time') {
8481
+ return _this52["".concat(xAxis, "Axis")](_this52.parseX(d.x.value));
8304
8482
  } else {
8305
- var xIndex = _this50[xAxis + 'Axis'].domain().indexOf(d.x.value);
8306
- var xPos = _this50["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
8307
- if (_this50["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
8308
- xPos = xPos + (_this50["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
8483
+ var xIndex = _this52[xAxis + 'Axis'].domain().indexOf(d.x.value);
8484
+ var xPos = _this52["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
8485
+ if (_this52["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
8486
+ xPos = xPos + (_this52["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
8309
8487
  }
8310
8488
  return xPos;
8311
8489
  }
8312
8490
  }).y0(function (d) {
8313
- return _this50["".concat(yAxis, "Axis")](0);
8491
+ return _this52["".concat(yAxis, "Axis")](0);
8314
8492
  }).y1(function (d) {
8315
- return _this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8316
- }).curve(d3[curveStyle || _this50.options.curveStyle]);
8493
+ return _this52["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8494
+ }).curve(d3[curveStyle || _this52.options.curveStyle]);
8317
8495
  };
8318
8496
  var xAxis = 'bottom';
8319
8497
  var yAxis = series.axis === 'secondary' ? 'right' : 'left';
@@ -8353,7 +8531,7 @@ var WebsyChart = /*#__PURE__*/function () {
8353
8531
  }, {
8354
8532
  key: "renderbar",
8355
8533
  value: function renderbar(series, index) {
8356
- var _this51 = this;
8534
+ var _this53 = this;
8357
8535
  /* global series index d3 */
8358
8536
  var xAxis = 'bottom';
8359
8537
  var yAxis = 'left';
@@ -8520,26 +8698,26 @@ var WebsyChart = /*#__PURE__*/function () {
8520
8698
  }
8521
8699
  bars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8522
8700
  bars.attr('width', function (d, i) {
8523
- return Math.abs(getBarWidth.call(_this51, d, i, yAxis, xAxis));
8701
+ return Math.abs(getBarWidth.call(_this53, d, i, yAxis, xAxis));
8524
8702
  }).attr('height', function (d, i) {
8525
- return getBarHeight.call(_this51, d, i, yAxis, xAxis);
8703
+ return getBarHeight.call(_this53, d, i, yAxis, xAxis);
8526
8704
  }).attr('x', function (d, i) {
8527
- return getBarX.call(_this51, d, i, yAxis, xAxis);
8705
+ return getBarX.call(_this53, d, i, yAxis, xAxis);
8528
8706
  }).attr('y', function (d, i) {
8529
- return getBarY.call(_this51, d, i, yAxis, xAxis);
8707
+ return getBarY.call(_this53, d, i, yAxis, xAxis);
8530
8708
  })
8531
8709
  // .transition(this.transition)
8532
8710
  .attr('fill', function (d) {
8533
8711
  return d.y.color || d.color || series.color;
8534
8712
  });
8535
8713
  bars.enter().append('rect').attr('width', function (d, i) {
8536
- return Math.abs(getBarWidth.call(_this51, d, i, yAxis, xAxis));
8714
+ return Math.abs(getBarWidth.call(_this53, d, i, yAxis, xAxis));
8537
8715
  }).attr('height', function (d, i) {
8538
- return getBarHeight.call(_this51, d, i, yAxis, xAxis);
8716
+ return getBarHeight.call(_this53, d, i, yAxis, xAxis);
8539
8717
  }).attr('x', function (d, i) {
8540
- return getBarX.call(_this51, d, i, yAxis, xAxis);
8718
+ return getBarX.call(_this53, d, i, yAxis, xAxis);
8541
8719
  }).attr('y', function (d, i) {
8542
- return getBarY.call(_this51, d, i, yAxis, xAxis);
8720
+ return getBarY.call(_this53, d, i, yAxis, xAxis);
8543
8721
  })
8544
8722
  // .transition(this.transition)
8545
8723
  .attr('fill', function (d) {
@@ -8551,26 +8729,26 @@ var WebsyChart = /*#__PURE__*/function () {
8551
8729
  this.brushBarsInitialized[series.key] = true;
8552
8730
  brushBars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8553
8731
  brushBars.attr('width', function (d, i) {
8554
- return Math.abs(getBarWidth.call(_this51, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush")));
8732
+ return Math.abs(getBarWidth.call(_this53, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush")));
8555
8733
  }).attr('height', function (d, i) {
8556
- return getBarHeight.call(_this51, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8734
+ return getBarHeight.call(_this53, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8557
8735
  }).attr('x', function (d, i) {
8558
- return getBarX.call(_this51, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8736
+ return getBarX.call(_this53, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8559
8737
  }).attr('y', function (d, i) {
8560
- return getBarY.call(_this51, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8738
+ return getBarY.call(_this53, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8561
8739
  })
8562
8740
  // .transition(this.transition)
8563
8741
  .attr('fill', function (d) {
8564
8742
  return d.y.color || d.color || series.color;
8565
8743
  });
8566
8744
  brushBars.enter().append('rect').attr('width', function (d, i) {
8567
- return Math.abs(getBarWidth.call(_this51, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush")));
8745
+ return Math.abs(getBarWidth.call(_this53, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush")));
8568
8746
  }).attr('height', function (d, i) {
8569
- return getBarHeight.call(_this51, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8747
+ return getBarHeight.call(_this53, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8570
8748
  }).attr('x', function (d, i) {
8571
- return getBarX.call(_this51, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8749
+ return getBarX.call(_this53, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8572
8750
  }).attr('y', function (d, i) {
8573
- return getBarY.call(_this51, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8751
+ return getBarY.call(_this53, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8574
8752
  })
8575
8753
  // .transition(this.transition)
8576
8754
  .attr('fill', function (d) {
@@ -8591,7 +8769,7 @@ var WebsyChart = /*#__PURE__*/function () {
8591
8769
  }, {
8592
8770
  key: "renderLabels",
8593
8771
  value: function renderLabels(series, index) {
8594
- var _this52 = this;
8772
+ var _this54 = this;
8595
8773
  /* global series index d3 WebsyDesigns */
8596
8774
  var xAxis = 'bottom';
8597
8775
  var yAxis = 'left';
@@ -8607,14 +8785,14 @@ var WebsyChart = /*#__PURE__*/function () {
8607
8785
  var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
8608
8786
  labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
8609
8787
  labels.attr('x', function (d) {
8610
- return getLabelX.call(_this52, d, series.labelPosition);
8788
+ return getLabelX.call(_this54, d, series.labelPosition);
8611
8789
  }).attr('y', function (d) {
8612
- return getLabelY.call(_this52, d, series.labelPosition);
8790
+ return getLabelY.call(_this54, d, series.labelPosition);
8613
8791
  }).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
8614
- if (_this52.options.grouping === 'stacked' && d.y.value === 0) {
8792
+ if (_this54.options.grouping === 'stacked' && d.y.value === 0) {
8615
8793
  return 'transparent';
8616
8794
  }
8617
- return _this52.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8795
+ return _this54.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8618
8796
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
8619
8797
  return d.y.label || d.y.value;
8620
8798
  }).each(function (d, i) {
@@ -8648,14 +8826,14 @@ var WebsyChart = /*#__PURE__*/function () {
8648
8826
  }
8649
8827
  });
8650
8828
  labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', function (d) {
8651
- return getLabelX.call(_this52, d, series.labelPosition);
8829
+ return getLabelX.call(_this54, d, series.labelPosition);
8652
8830
  }).attr('y', function (d) {
8653
- return getLabelY.call(_this52, d, series.labelPosition);
8831
+ return getLabelY.call(_this54, d, series.labelPosition);
8654
8832
  }).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
8655
- if (_this52.options.grouping === 'stacked' && d.y.value === 0) {
8833
+ if (_this54.options.grouping === 'stacked' && d.y.value === 0) {
8656
8834
  return 'transparent';
8657
8835
  }
8658
- return _this52.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8836
+ return _this54.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8659
8837
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
8660
8838
  return d.y.label || d.y.value;
8661
8839
  }).each(function (d, i) {
@@ -8733,32 +8911,32 @@ var WebsyChart = /*#__PURE__*/function () {
8733
8911
  }, {
8734
8912
  key: "renderline",
8735
8913
  value: function renderline(series, index) {
8736
- var _this53 = this;
8914
+ var _this55 = this;
8737
8915
  /* global series index d3 */
8738
8916
  var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
8739
8917
  return d3.line().x(function (d) {
8740
- if (_this53.options.orientation === 'horizontal') {
8741
- return _this53["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8918
+ if (_this55.options.orientation === 'horizontal') {
8919
+ return _this55["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8742
8920
  } else {
8743
- if (_this53.options.data[xAxis].scale === 'Time') {
8744
- return _this53["".concat(xAxis, "Axis")](_this53.parseX(d.x.value));
8921
+ if (_this55.options.data[xAxis].scale === 'Time') {
8922
+ return _this55["".concat(xAxis, "Axis")](_this55.parseX(d.x.value));
8745
8923
  } else {
8746
- var xIndex = _this53[xAxis + 'Axis'].domain().indexOf(d.x.value);
8747
- var xPos = _this53["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
8748
- if (_this53["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
8749
- xPos = xPos + (_this53["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
8924
+ var xIndex = _this55[xAxis + 'Axis'].domain().indexOf(d.x.value);
8925
+ var xPos = _this55["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
8926
+ if (_this55["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
8927
+ xPos = xPos + (_this55["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
8750
8928
  }
8751
8929
  return xPos;
8752
8930
  }
8753
8931
  }
8754
8932
  }).y(function (d) {
8755
- if (_this53.options.orientation === 'horizontal') {
8756
- var adjustment = _this53.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this53.options.data[xAxis].bandWidth / 2;
8757
- return _this53["".concat(xAxis, "Axis")](_this53.parseX(d.x.value)) + adjustment;
8933
+ if (_this55.options.orientation === 'horizontal') {
8934
+ var adjustment = _this55.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this55.options.data[xAxis].bandWidth / 2;
8935
+ return _this55["".concat(xAxis, "Axis")](_this55.parseX(d.x.value)) + adjustment;
8758
8936
  } else {
8759
- return _this53["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8937
+ return _this55["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8760
8938
  }
8761
- }).curve(d3[curveStyle || _this53.options.curveStyle]);
8939
+ }).curve(d3[curveStyle || _this55.options.curveStyle]);
8762
8940
  };
8763
8941
  var xAxis = 'bottom';
8764
8942
  var yAxis = series.axis === 'secondary' ? 'right' : 'left';
@@ -8867,14 +9045,14 @@ var WebsyChart = /*#__PURE__*/function () {
8867
9045
  }, {
8868
9046
  key: "rendersymbol",
8869
9047
  value: function rendersymbol(series, index) {
8870
- var _this54 = this;
9048
+ var _this56 = this;
8871
9049
  /* global d3 series index series.key */
8872
9050
  var drawSymbol = function drawSymbol(size) {
8873
9051
  return d3.symbol()
8874
9052
  // .type(d => {
8875
9053
  // return d3.symbols[0]
8876
9054
  // })
8877
- .size(size || _this54.options.symbolSize);
9055
+ .size(size || _this56.options.symbolSize);
8878
9056
  };
8879
9057
  var xAxis = 'bottom';
8880
9058
  var yAxis = series.axis === 'secondary' ? 'right' : 'left';
@@ -8900,27 +9078,27 @@ var WebsyChart = /*#__PURE__*/function () {
8900
9078
  // else {
8901
9079
  // return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
8902
9080
  // }
8903
- var xIndex = _this54[xAxis + 'Axis'].domain().indexOf(d.x.value);
8904
- var xPos = _this54["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
8905
- if (_this54["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
8906
- xPos = xPos + (_this54["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
8907
- }
8908
- var adjustment = _this54.options.data[xAxis].scale === 'Time' || _this54.options.data[xAxis].scale === 'Linear' ? 0 : _this54.options.data[xAxis].bandWidth / 2;
8909
- if (_this54.options.orientation === 'horizontal') {
8910
- return "translate(".concat(_this54["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(xPos, ")");
9081
+ var xIndex = _this56[xAxis + 'Axis'].domain().indexOf(d.x.value);
9082
+ var xPos = _this56["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
9083
+ if (_this56["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
9084
+ xPos = xPos + (_this56["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
9085
+ }
9086
+ var adjustment = _this56.options.data[xAxis].scale === 'Time' || _this56.options.data[xAxis].scale === 'Linear' ? 0 : _this56.options.data[xAxis].bandWidth / 2;
9087
+ if (_this56.options.orientation === 'horizontal') {
9088
+ return "translate(".concat(_this56["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(xPos, ")");
8911
9089
  } else {
8912
- if (_this54.options.data[xAxis].scale === 'Time') {
8913
- xPos = _this54["".concat(xAxis, "Axis")](_this54.parseX(d.x.value));
9090
+ if (_this56.options.data[xAxis].scale === 'Time') {
9091
+ xPos = _this56["".concat(xAxis, "Axis")](_this56.parseX(d.x.value));
8914
9092
  } else {
8915
- var _xIndex = _this54[xAxis + 'Axis'].domain().indexOf(d.x.value);
8916
- var _xPos = _this54["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex];
8917
- if (_this54["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex + 1]) {
8918
- _xPos = _xPos + (_this54["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex + 1] - _xPos) / 2;
9093
+ var _xIndex = _this56[xAxis + 'Axis'].domain().indexOf(d.x.value);
9094
+ var _xPos = _this56["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex];
9095
+ if (_this56["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex + 1]) {
9096
+ _xPos = _xPos + (_this56["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex + 1] - _xPos) / 2;
8919
9097
  }
8920
9098
  // return xPos
8921
9099
  }
8922
9100
  // return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
8923
- return "translate(".concat(xPos, ", ").concat(_this54["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
9101
+ return "translate(".concat(xPos, ", ").concat(_this56["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
8924
9102
  }
8925
9103
  });
8926
9104
  // Enter
@@ -8935,27 +9113,27 @@ var WebsyChart = /*#__PURE__*/function () {
8935
9113
  }).attr('class', function (d) {
8936
9114
  return "symbol symbol_".concat(series.key);
8937
9115
  }).attr('transform', function (d) {
8938
- var xIndex = _this54[xAxis + 'Axis'].domain().indexOf(d.x.value);
8939
- var xPos = _this54["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
8940
- if (_this54["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
8941
- xPos = xPos + (_this54["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
8942
- }
8943
- var adjustment = _this54.options.data[xAxis].scale === 'Time' || _this54.options.data[xAxis].scale === 'Linear' ? 0 : _this54.options.data[xAxis].bandWidth / 2;
8944
- if (_this54.options.orientation === 'horizontal') {
8945
- return "translate(".concat(_this54["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(xPos, ")");
9116
+ var xIndex = _this56[xAxis + 'Axis'].domain().indexOf(d.x.value);
9117
+ var xPos = _this56["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
9118
+ if (_this56["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
9119
+ xPos = xPos + (_this56["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
9120
+ }
9121
+ var adjustment = _this56.options.data[xAxis].scale === 'Time' || _this56.options.data[xAxis].scale === 'Linear' ? 0 : _this56.options.data[xAxis].bandWidth / 2;
9122
+ if (_this56.options.orientation === 'horizontal') {
9123
+ return "translate(".concat(_this56["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(xPos, ")");
8946
9124
  } else {
8947
- if (_this54.options.data[xAxis].scale === 'Time') {
8948
- xPos = _this54["".concat(xAxis, "Axis")](_this54.parseX(d.x.value));
9125
+ if (_this56.options.data[xAxis].scale === 'Time') {
9126
+ xPos = _this56["".concat(xAxis, "Axis")](_this56.parseX(d.x.value));
8949
9127
  } else {
8950
- var _xIndex2 = _this54[xAxis + 'Axis'].domain().indexOf(d.x.value);
8951
- var _xPos2 = _this54["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex2];
8952
- if (_this54["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex2 + 1]) {
8953
- _xPos2 = _xPos2 + (_this54["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex2 + 1] - _xPos2) / 2;
9128
+ var _xIndex2 = _this56[xAxis + 'Axis'].domain().indexOf(d.x.value);
9129
+ var _xPos2 = _this56["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex2];
9130
+ if (_this56["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex2 + 1]) {
9131
+ _xPos2 = _xPos2 + (_this56["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex2 + 1] - _xPos2) / 2;
8954
9132
  }
8955
9133
  // return xPos
8956
9134
  }
8957
9135
  // return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
8958
- return "translate(".concat(xPos, ", ").concat(_this54["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
9136
+ return "translate(".concat(xPos, ", ").concat(_this56["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
8959
9137
  }
8960
9138
  });
8961
9139
  }
@@ -9151,7 +9329,7 @@ var WebsyLegend = /*#__PURE__*/function () {
9151
9329
  }, {
9152
9330
  key: "resize",
9153
9331
  value: function resize() {
9154
- var _this55 = this;
9332
+ var _this57 = this;
9155
9333
  var el = document.getElementById(this.elementId);
9156
9334
  if (el) {
9157
9335
  // if (this.options.width) {
@@ -9162,7 +9340,7 @@ var WebsyLegend = /*#__PURE__*/function () {
9162
9340
  // }
9163
9341
  var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
9164
9342
  html += this._data.map(function (d, i) {
9165
- return _this55.getLegendItemHTML(d);
9343
+ return _this57.getLegendItemHTML(d);
9166
9344
  }).join('');
9167
9345
  html += "\n <div>\n ";
9168
9346
  el.innerHTML = html;
@@ -9207,11 +9385,18 @@ var WebsyKPI = /*#__PURE__*/function () {
9207
9385
  };
9208
9386
  this.elementId = elementId;
9209
9387
  this.options = _extends({}, DEFAULTS, options);
9388
+ this._isRendered = false;
9210
9389
  this.render();
9211
9390
  }
9212
9391
  _createClass(WebsyKPI, [{
9392
+ key: "isRendered",
9393
+ get: function get() {
9394
+ return this._isRendered;
9395
+ }
9396
+ }, {
9213
9397
  key: "render",
9214
9398
  value: function render(options) {
9399
+ this._isRendered = false;
9215
9400
  this.options = _extends({}, this.options, options);
9216
9401
  if (!this.options.label.classes) {
9217
9402
  this.options.label.classes = [];
@@ -9246,6 +9431,7 @@ var WebsyKPI = /*#__PURE__*/function () {
9246
9431
  }
9247
9432
  html += " \n </div>\n </div>\n ";
9248
9433
  el.innerHTML = html;
9434
+ this._isRendered = true;
9249
9435
  }
9250
9436
  }
9251
9437
  }]);
@@ -9269,6 +9455,7 @@ var WebsyMap = /*#__PURE__*/function () {
9269
9455
  };
9270
9456
  this.elementId = elementId;
9271
9457
  this.options = _extends({}, DEFAULTS, options);
9458
+ this._isRendered = false;
9272
9459
  if (!elementId) {
9273
9460
  console.log('No element Id provided for Websy Map');
9274
9461
  return;
@@ -9298,6 +9485,11 @@ var WebsyMap = /*#__PURE__*/function () {
9298
9485
  }
9299
9486
  }
9300
9487
  _createClass(WebsyMap, [{
9488
+ key: "isRendered",
9489
+ get: function get() {
9490
+ return this._isRendered;
9491
+ }
9492
+ }, {
9301
9493
  key: "handleClick",
9302
9494
  value: function handleClick(event) {}
9303
9495
  }, {
@@ -9306,14 +9498,15 @@ var WebsyMap = /*#__PURE__*/function () {
9306
9498
  }, {
9307
9499
  key: "render",
9308
9500
  value: function render() {
9309
- var _this56 = this;
9501
+ var _this58 = this;
9502
+ this._isRendered = false;
9310
9503
  var mapEl = document.getElementById("".concat(this.elementId, "_map"));
9311
9504
  var legendEl = document.getElementById("".concat(this.elementId, "_map"));
9312
9505
  if (this.options.showLegend === true && this.options.data.polygons) {
9313
9506
  var legendData = this.options.data.polygons.map(function (s, i) {
9314
9507
  return {
9315
9508
  value: s.label || s.key,
9316
- color: s.color || _this56.options.colors[i % _this56.options.colors.length]
9509
+ color: s.color || _this58.options.colors[i % _this58.options.colors.length]
9317
9510
  };
9318
9511
  });
9319
9512
  var longestValue = legendData.map(function (s) {
@@ -9367,7 +9560,7 @@ var WebsyMap = /*#__PURE__*/function () {
9367
9560
  }
9368
9561
  if (this.polygons) {
9369
9562
  this.polygons.forEach(function (p) {
9370
- return _this56.map.removeLayer(p);
9563
+ return _this58.map.removeLayer(p);
9371
9564
  });
9372
9565
  }
9373
9566
  this.polygons = [];
@@ -9421,15 +9614,15 @@ var WebsyMap = /*#__PURE__*/function () {
9421
9614
  p.options = {};
9422
9615
  }
9423
9616
  if (!p.options.color) {
9424
- p.options.color = _this56.options.colors[i % _this56.options.colors.length];
9617
+ p.options.color = _this58.options.colors[i % _this58.options.colors.length];
9425
9618
  }
9426
9619
  var pol = L.polygon(p.data.map(function (c) {
9427
9620
  return c.map(function (d) {
9428
9621
  return [d.Latitude, d.Longitude];
9429
9622
  });
9430
- }), p.options).addTo(_this56.map);
9431
- _this56.polygons.push(pol);
9432
- _this56.map.fitBounds(pol.getBounds());
9623
+ }), p.options).addTo(_this58.map);
9624
+ _this58.polygons.push(pol);
9625
+ _this58.map.fitBounds(pol.getBounds());
9433
9626
  });
9434
9627
  }
9435
9628
  // if (this.data.markers.length > 0) {
@@ -9448,6 +9641,7 @@ var WebsyMap = /*#__PURE__*/function () {
9448
9641
  } else if (this.options.center) {
9449
9642
  this.map.setView(this.options.center, this.options.zoom || null);
9450
9643
  }
9644
+ this._isRendered = true;
9451
9645
  }
9452
9646
  }]);
9453
9647
  return WebsyMap;