cotomy 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +339 -317
- package/dist/browser/cotomy.js +35 -19
- package/dist/browser/cotomy.js.map +1 -1
- package/dist/browser/cotomy.min.js +1 -1
- package/dist/browser/cotomy.min.js.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/api.js +15 -5
- package/dist/esm/api.js.map +1 -1
- package/dist/esm/form.js +3 -3
- package/dist/esm/view.js +16 -10
- package/dist/esm/view.js.map +1 -1
- package/dist/types/api.d.ts +4 -1
- package/dist/types/view.d.ts +17 -17
- package/package.json +61 -61
package/dist/browser/cotomy.js
CHANGED
|
@@ -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
|
|
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
|
|
|
@@ -1115,6 +1115,7 @@ class CotomyElement {
|
|
|
1115
1115
|
}
|
|
1116
1116
|
setFocus() {
|
|
1117
1117
|
this.element.focus();
|
|
1118
|
+
return this;
|
|
1118
1119
|
}
|
|
1119
1120
|
get visible() {
|
|
1120
1121
|
if (!this.attached) {
|
|
@@ -1877,6 +1878,7 @@ class CotomyWindow {
|
|
|
1877
1878
|
});
|
|
1878
1879
|
this._mutationObserver.observe(this.body.element, { childList: true, subtree: true });
|
|
1879
1880
|
}
|
|
1881
|
+
return this;
|
|
1880
1882
|
}
|
|
1881
1883
|
get reloading() {
|
|
1882
1884
|
return this._reloading;
|
|
@@ -1890,6 +1892,7 @@ class CotomyWindow {
|
|
|
1890
1892
|
}
|
|
1891
1893
|
append(e) {
|
|
1892
1894
|
this._body.append(e);
|
|
1895
|
+
return this;
|
|
1893
1896
|
}
|
|
1894
1897
|
moveNext(focused, shift = false) {
|
|
1895
1898
|
const selector = "input, a, select, button, textarea";
|
|
@@ -1910,6 +1913,7 @@ class CotomyWindow {
|
|
|
1910
1913
|
}
|
|
1911
1914
|
trigger(event, e) {
|
|
1912
1915
|
window.dispatchEvent(e ?? new Event(event, { bubbles: true }));
|
|
1916
|
+
return this;
|
|
1913
1917
|
}
|
|
1914
1918
|
on(event, handle) {
|
|
1915
1919
|
const events = Array.isArray(event) ? event : [event];
|
|
@@ -1919,6 +1923,7 @@ class CotomyWindow {
|
|
|
1919
1923
|
this._eventHandlers[eventName].push(handle);
|
|
1920
1924
|
window.addEventListener(eventName, handle);
|
|
1921
1925
|
});
|
|
1926
|
+
return this;
|
|
1922
1927
|
}
|
|
1923
1928
|
off(event, handle) {
|
|
1924
1929
|
const events = Array.isArray(event) ? event : [event];
|
|
@@ -1940,43 +1945,44 @@ class CotomyWindow {
|
|
|
1940
1945
|
delete this._eventHandlers[eventName];
|
|
1941
1946
|
}
|
|
1942
1947
|
});
|
|
1948
|
+
return this;
|
|
1943
1949
|
}
|
|
1944
1950
|
load(handle) {
|
|
1945
|
-
this.on("load", handle);
|
|
1951
|
+
return this.on("load", handle);
|
|
1946
1952
|
}
|
|
1947
1953
|
ready(handle) {
|
|
1948
|
-
this.on("cotomy:ready", handle);
|
|
1954
|
+
return this.on("cotomy:ready", handle);
|
|
1949
1955
|
}
|
|
1950
1956
|
resize(handle) {
|
|
1951
1957
|
if (handle) {
|
|
1952
|
-
this.on("resize", handle);
|
|
1958
|
+
return this.on("resize", handle);
|
|
1953
1959
|
}
|
|
1954
1960
|
else {
|
|
1955
|
-
this.trigger("resize");
|
|
1961
|
+
return this.trigger("resize");
|
|
1956
1962
|
}
|
|
1957
1963
|
}
|
|
1958
1964
|
scroll(handle) {
|
|
1959
1965
|
if (handle) {
|
|
1960
|
-
this.on("scroll", handle);
|
|
1966
|
+
return this.on("scroll", handle);
|
|
1961
1967
|
}
|
|
1962
1968
|
else {
|
|
1963
|
-
this.trigger("scroll");
|
|
1969
|
+
return this.trigger("scroll");
|
|
1964
1970
|
}
|
|
1965
1971
|
}
|
|
1966
1972
|
changeLayout(handle) {
|
|
1967
1973
|
if (handle) {
|
|
1968
|
-
this.on("cotomy:changelayout", handle);
|
|
1974
|
+
return this.on("cotomy:changelayout", handle);
|
|
1969
1975
|
}
|
|
1970
1976
|
else {
|
|
1971
|
-
this.trigger("cotomy:changelayout");
|
|
1977
|
+
return this.trigger("cotomy:changelayout");
|
|
1972
1978
|
}
|
|
1973
1979
|
}
|
|
1974
1980
|
pageshow(handle) {
|
|
1975
1981
|
if (handle) {
|
|
1976
|
-
this.on("pageshow", handle);
|
|
1982
|
+
return this.on("pageshow", handle);
|
|
1977
1983
|
}
|
|
1978
1984
|
else {
|
|
1979
|
-
this.trigger("pageshow");
|
|
1985
|
+
return this.trigger("pageshow");
|
|
1980
1986
|
}
|
|
1981
1987
|
}
|
|
1982
1988
|
get scrollTop() {
|
|
@@ -2218,6 +2224,10 @@ class CotomyViewRenderer {
|
|
|
2218
2224
|
this._renderers[type] = callback;
|
|
2219
2225
|
return this;
|
|
2220
2226
|
}
|
|
2227
|
+
get renderers() {
|
|
2228
|
+
this.initialize();
|
|
2229
|
+
return this._renderers;
|
|
2230
|
+
}
|
|
2221
2231
|
get initialized() {
|
|
2222
2232
|
return this._builded;
|
|
2223
2233
|
}
|
|
@@ -2257,6 +2267,15 @@ class CotomyViewRenderer {
|
|
|
2257
2267
|
}
|
|
2258
2268
|
}
|
|
2259
2269
|
});
|
|
2270
|
+
this.renderer("date", (element, value) => {
|
|
2271
|
+
if (value) {
|
|
2272
|
+
const date = new Date(value);
|
|
2273
|
+
if (!isNaN(date.getTime())) {
|
|
2274
|
+
const format = element.attribute("data-cotomy-format") ?? "YYYY/MM/DD";
|
|
2275
|
+
element.text = dayjs_min_default()(date).format(format);
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
});
|
|
2260
2279
|
this._builded = true;
|
|
2261
2280
|
}
|
|
2262
2281
|
return this;
|
|
@@ -2267,8 +2286,8 @@ class CotomyViewRenderer {
|
|
|
2267
2286
|
console.debug(`Binding data to element [data-cotomy-bind="${propertyName}"]:`, value);
|
|
2268
2287
|
}
|
|
2269
2288
|
const type = element.attribute("data-cotomy-bindtype")?.toLowerCase();
|
|
2270
|
-
if (type && this.
|
|
2271
|
-
this.
|
|
2289
|
+
if (type && this.renderers[type]) {
|
|
2290
|
+
this.renderers[type](element, value);
|
|
2272
2291
|
}
|
|
2273
2292
|
else {
|
|
2274
2293
|
element.text = String(value ?? "");
|
|
@@ -2308,9 +2327,6 @@ class CotomyViewRenderer {
|
|
|
2308
2327
|
}
|
|
2309
2328
|
}
|
|
2310
2329
|
async applyAsync(respose) {
|
|
2311
|
-
if (!this.initialized) {
|
|
2312
|
-
this.initialize();
|
|
2313
|
-
}
|
|
2314
2330
|
if (!respose.available) {
|
|
2315
2331
|
throw new Error("Response is not available.");
|
|
2316
2332
|
}
|
|
@@ -2718,7 +2734,7 @@ class CotomyEntityApiForm extends CotomyApiForm {
|
|
|
2718
2734
|
this.attribute("data-cotomy-entity-key", addedParts[0]);
|
|
2719
2735
|
}
|
|
2720
2736
|
else {
|
|
2721
|
-
const msg = `Location does not contain a single entity key segment.
|
|
2737
|
+
const msg = `Location does not contain a single entity key segment.
|
|
2722
2738
|
action="${baseAction}", location="${locPath}", added=["${addedParts.join('","')}"]`;
|
|
2723
2739
|
throw new Error(msg);
|
|
2724
2740
|
}
|
|
@@ -2808,8 +2824,8 @@ class CotomyEntityFillApiForm extends CotomyEntityApiForm {
|
|
|
2808
2824
|
}
|
|
2809
2825
|
}
|
|
2810
2826
|
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"]),
|
|
2827
|
+
this.find(`input[name="${pname}" i]:not([data-cotomy-fill="false"]):not([multiple]),
|
|
2828
|
+
textarea[name="${pname}" i]:not([data-cotomy-fill="false"]),
|
|
2813
2829
|
select[name="${pname}" i]:not([data-cotomy-fill="false"]):not([multiple])`).forEach(input => {
|
|
2814
2830
|
if (CotomyDebugSettings.isEnabled(CotomyDebugFeature.Fill)) {
|
|
2815
2831
|
console.debug(`Filling input[name="${pname}"] with value:`, value);
|