cotomy 0.3.2 → 0.3.3

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.
@@ -174,7 +174,7 @@ module.exports = cuid;
174
174
  /***/ 826:
175
175
  /***/ (function(module) {
176
176
 
177
- !function(t,i){ true?module.exports=i():0}(this,(function(){"use strict";var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var r=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),r.call(this,t)};var o=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else o.call(this)};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s;if(0===u)return this.utc(f);var r=this.clone();if(f)return r.$offset=u,r.$u=!1,r;var o=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(r=this.local().add(u+o,t)).$offset=u,r.$x.$localOffset=o,r};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return!!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return"s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)}}}));
177
+ !function(t,i){ true?module.exports=i():0}(this,(function(){"use strict";var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var o=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t)};var r=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else r.call(this)};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s,o=this;if(f)return o.$offset=u,o.$u=0===s,o;if(0!==s){var r=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(u+r,t)).$offset=u,o.$x.$localOffset=r}else o=this.utc();return o};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return!!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return"s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)}}}));
178
178
 
179
179
  /***/ })
180
180
 
@@ -943,10 +943,24 @@ class CotomyElement {
943
943
  }
944
944
  }
945
945
  }
946
- this.removed(() => {
947
- this._element = CotomyElement.createHTMLElement(`<div data-cotomy-invalidated style="display: none;"></div>`);
948
- EventRegistry.instance.clear(this);
949
- });
946
+ if (!this.instanceId) {
947
+ this.attribute("data-cotomy-instance", `__cotomy_instance_${cuid_default()()}`);
948
+ this.removed(() => {
949
+ this._element = CotomyElement.createHTMLElement(`<div data-cotomy-invalidated style="display: none;"></div>`);
950
+ EventRegistry.instance.clear(this);
951
+ });
952
+ this.on("cotomy:transitstart", () => {
953
+ this.attribute("data-cotomy-moving", "");
954
+ this.find("[data-cotomy-instance]").forEach(e => e.attribute("data-cotomy-moving", ""));
955
+ });
956
+ this.on("cotomy:transitend", () => {
957
+ this.attribute("data-cotomy-moving", null);
958
+ this.find("[data-cotomy-instance]").forEach(e => e.attribute("data-cotomy-moving", null));
959
+ });
960
+ }
961
+ }
962
+ get instanceId() {
963
+ return this.attribute("data-cotomy-instance");
950
964
  }
951
965
  get scopeId() {
952
966
  if (!this._scopeId) {
@@ -1400,12 +1414,25 @@ class CotomyElement {
1400
1414
  contains(selector) {
1401
1415
  return this.find(selector).length > 0;
1402
1416
  }
1417
+ static runWithMoveEvents(target, operation) {
1418
+ target.trigger("cotomy:transitstart");
1419
+ try {
1420
+ operation();
1421
+ }
1422
+ finally {
1423
+ target.trigger("cotomy:transitend");
1424
+ }
1425
+ }
1403
1426
  prepend(prepend) {
1404
- this._element.prepend(prepend.element);
1427
+ CotomyElement.runWithMoveEvents(prepend, () => {
1428
+ this.element.prepend(prepend.element);
1429
+ });
1405
1430
  return this;
1406
1431
  }
1407
1432
  append(target) {
1408
- this.element.append(target.element);
1433
+ CotomyElement.runWithMoveEvents(target, () => {
1434
+ this.element.append(target.element);
1435
+ });
1409
1436
  return this;
1410
1437
  }
1411
1438
  appendAll(targets) {
@@ -1413,19 +1440,27 @@ class CotomyElement {
1413
1440
  return this;
1414
1441
  }
1415
1442
  insertBefore(append) {
1416
- this.element.before(append.element);
1443
+ CotomyElement.runWithMoveEvents(append, () => {
1444
+ this.element.before(append.element);
1445
+ });
1417
1446
  return this;
1418
1447
  }
1419
1448
  insertAfter(append) {
1420
- this.element.after(append.element);
1449
+ CotomyElement.runWithMoveEvents(append, () => {
1450
+ this.element.after(append.element);
1451
+ });
1421
1452
  return this;
1422
1453
  }
1423
1454
  appendTo(target) {
1424
- target.element.append(this.element);
1455
+ CotomyElement.runWithMoveEvents(this, () => {
1456
+ target.element.append(this.element);
1457
+ });
1425
1458
  return this;
1426
1459
  }
1427
1460
  prependTo(target) {
1428
- target.element.prepend(this.element);
1461
+ CotomyElement.runWithMoveEvents(this, () => {
1462
+ target.element.prepend(this.element);
1463
+ });
1429
1464
  return this;
1430
1465
  }
1431
1466
  trigger(event, e) {
@@ -1823,7 +1858,9 @@ class CotomyWindow {
1823
1858
  mutation.removedNodes.forEach(node => {
1824
1859
  if (typeof HTMLElement !== "undefined" && node instanceof HTMLElement) {
1825
1860
  const element = new CotomyElement(node);
1826
- element.trigger("removed");
1861
+ if (!element.hasAttribute("data-cotomy-moving") && !element.attached) {
1862
+ element.trigger("removed");
1863
+ }
1827
1864
  }
1828
1865
  });
1829
1866
  });
@@ -2659,7 +2696,7 @@ class CotomyEntityApiForm extends CotomyApiForm {
2659
2696
  this.attribute("data-cotomy-entity-key", addedParts[0]);
2660
2697
  }
2661
2698
  else {
2662
- const msg = `Location does not contain a single entity key segment.
2699
+ const msg = `Location does not contain a single entity key segment.
2663
2700
  action="${baseAction}", location="${locPath}", added=["${addedParts.join('","')}"]`;
2664
2701
  throw new Error(msg);
2665
2702
  }
@@ -2749,8 +2786,8 @@ class CotomyEntityFillApiForm extends CotomyEntityApiForm {
2749
2786
  }
2750
2787
  }
2751
2788
  applyValueToInputs(pname, value) {
2752
- this.find(`input[name="${pname}" i]:not([data-cotomy-fill="false"]):not([multiple]),
2753
- textarea[name="${pname}" i]:not([data-cotomy-fill="false"]),
2789
+ this.find(`input[name="${pname}" i]:not([data-cotomy-fill="false"]):not([multiple]),
2790
+ textarea[name="${pname}" i]:not([data-cotomy-fill="false"]),
2754
2791
  select[name="${pname}" i]:not([data-cotomy-fill="false"]):not([multiple])`).forEach(input => {
2755
2792
  if (CotomyDebugSettings.isEnabled(CotomyDebugFeature.Fill)) {
2756
2793
  console.debug(`Filling input[name="${pname}"] with value:`, value);