cotomy 0.3.5 → 0.3.6

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
 
@@ -2218,6 +2218,10 @@ class CotomyViewRenderer {
2218
2218
  this._renderers[type] = callback;
2219
2219
  return this;
2220
2220
  }
2221
+ get renderers() {
2222
+ this.initialize();
2223
+ return this._renderers;
2224
+ }
2221
2225
  get initialized() {
2222
2226
  return this._builded;
2223
2227
  }
@@ -2257,6 +2261,15 @@ class CotomyViewRenderer {
2257
2261
  }
2258
2262
  }
2259
2263
  });
2264
+ this.renderer("date", (element, value) => {
2265
+ if (value) {
2266
+ const date = new Date(value);
2267
+ if (!isNaN(date.getTime())) {
2268
+ const format = element.attribute("data-cotomy-format") ?? "YYYY/MM/DD";
2269
+ element.text = dayjs_min_default()(date).format(format);
2270
+ }
2271
+ }
2272
+ });
2260
2273
  this._builded = true;
2261
2274
  }
2262
2275
  return this;
@@ -2267,8 +2280,8 @@ class CotomyViewRenderer {
2267
2280
  console.debug(`Binding data to element [data-cotomy-bind="${propertyName}"]:`, value);
2268
2281
  }
2269
2282
  const type = element.attribute("data-cotomy-bindtype")?.toLowerCase();
2270
- if (type && this._renderers[type]) {
2271
- this._renderers[type](element, value);
2283
+ if (type && this.renderers[type]) {
2284
+ this.renderers[type](element, value);
2272
2285
  }
2273
2286
  else {
2274
2287
  element.text = String(value ?? "");
@@ -2308,9 +2321,6 @@ class CotomyViewRenderer {
2308
2321
  }
2309
2322
  }
2310
2323
  async applyAsync(respose) {
2311
- if (!this.initialized) {
2312
- this.initialize();
2313
- }
2314
2324
  if (!respose.available) {
2315
2325
  throw new Error("Response is not available.");
2316
2326
  }
@@ -2718,7 +2728,7 @@ class CotomyEntityApiForm extends CotomyApiForm {
2718
2728
  this.attribute("data-cotomy-entity-key", addedParts[0]);
2719
2729
  }
2720
2730
  else {
2721
- const msg = `Location does not contain a single entity key segment.
2731
+ const msg = `Location does not contain a single entity key segment.
2722
2732
  action="${baseAction}", location="${locPath}", added=["${addedParts.join('","')}"]`;
2723
2733
  throw new Error(msg);
2724
2734
  }
@@ -2808,8 +2818,8 @@ class CotomyEntityFillApiForm extends CotomyEntityApiForm {
2808
2818
  }
2809
2819
  }
2810
2820
  applyValueToInputs(pname, value) {
2811
- this.find(`input[name="${pname}" i]:not([data-cotomy-fill="false"]):not([multiple]),
2812
- textarea[name="${pname}" i]:not([data-cotomy-fill="false"]),
2821
+ this.find(`input[name="${pname}" i]:not([data-cotomy-fill="false"]):not([multiple]),
2822
+ textarea[name="${pname}" i]:not([data-cotomy-fill="false"]),
2813
2823
  select[name="${pname}" i]:not([data-cotomy-fill="false"]):not([multiple])`).forEach(input => {
2814
2824
  if (CotomyDebugSettings.isEnabled(CotomyDebugFeature.Fill)) {
2815
2825
  console.debug(`Filling input[name="${pname}"] with value:`, value);