cotomy 0.2.2 → 0.3.2

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 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)}}}));
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)}}}));
178
178
 
179
179
  /***/ })
180
180
 
@@ -892,6 +892,10 @@ class CotomyElement {
892
892
  const ctor = (type ?? CotomyElement);
893
893
  return new ctor(element);
894
894
  }
895
+ static last(selector, type) {
896
+ const elements = this.find(selector, type);
897
+ return elements.pop();
898
+ }
895
899
  static find(selector, type) {
896
900
  const elements = document.querySelectorAll(selector);
897
901
  const ctor = (type ?? CotomyElement);
@@ -1389,6 +1393,10 @@ class CotomyElement {
1389
1393
  const elements = this.find(selector, type);
1390
1394
  return elements.shift() ?? undefined;
1391
1395
  }
1396
+ last(selector = "*", type) {
1397
+ const elements = this.find(selector, type);
1398
+ return elements.pop() ?? undefined;
1399
+ }
1392
1400
  contains(selector) {
1393
1401
  return this.find(selector).length > 0;
1394
1402
  }
@@ -1421,7 +1429,7 @@ class CotomyElement {
1421
1429
  return this;
1422
1430
  }
1423
1431
  trigger(event, e) {
1424
- this.element.dispatchEvent(e ?? new Event(event));
1432
+ this.element.dispatchEvent(e ?? new Event(event, { bubbles: true }));
1425
1433
  return this;
1426
1434
  }
1427
1435
  on(event, handle, options) {
@@ -1853,8 +1861,8 @@ class CotomyWindow {
1853
1861
  focusableElements[nextIndex].setFocus();
1854
1862
  }
1855
1863
  }
1856
- trigger(event) {
1857
- window.dispatchEvent(new Event(event));
1864
+ trigger(event, e) {
1865
+ window.dispatchEvent(e ?? new Event(event, { bubbles: true }));
1858
1866
  }
1859
1867
  on(event, handle) {
1860
1868
  if (!this._eventHandlers[event])
@@ -2651,7 +2659,7 @@ class CotomyEntityApiForm extends CotomyApiForm {
2651
2659
  this.attribute("data-cotomy-entity-key", addedParts[0]);
2652
2660
  }
2653
2661
  else {
2654
- const msg = `Location does not contain a single entity key segment.
2662
+ const msg = `Location does not contain a single entity key segment.
2655
2663
  action="${baseAction}", location="${locPath}", added=["${addedParts.join('","')}"]`;
2656
2664
  throw new Error(msg);
2657
2665
  }
@@ -2741,8 +2749,8 @@ class CotomyEntityFillApiForm extends CotomyEntityApiForm {
2741
2749
  }
2742
2750
  }
2743
2751
  applyValueToInputs(pname, value) {
2744
- this.find(`input[name="${pname}" i]:not([data-cotomy-fill="false"]):not([multiple]),
2745
- textarea[name="${pname}" i]:not([data-cotomy-fill="false"]),
2752
+ this.find(`input[name="${pname}" i]:not([data-cotomy-fill="false"]):not([multiple]),
2753
+ textarea[name="${pname}" i]:not([data-cotomy-fill="false"]),
2746
2754
  select[name="${pname}" i]:not([data-cotomy-fill="false"]):not([multiple])`).forEach(input => {
2747
2755
  if (CotomyDebugSettings.isEnabled(CotomyDebugFeature.Fill)) {
2748
2756
  console.debug(`Filling input[name="${pname}"] with value:`, value);