pome-ui 2.0.0-preview4 → 2.0.0-preview40
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 +1 -674
- package/package.json +1 -1
- package/pome-cache-query.js +29 -0
- package/pome-cache-query.min.js +1 -1
- package/pome-commonjs.js +44 -3
- package/pome-commonjs.min.js +1 -1
- package/pome-localization.js +27 -1
- package/pome-localization.min.js +1 -1
- package/pome-ui.dev.js +18523 -15740
- package/pome-ui.dev.min.js +30 -1
- package/pome-ui.js +735 -113
- package/pome-ui.min.js +5 -1
package/pome-cache-query.js
CHANGED
|
@@ -223,6 +223,34 @@
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
function getSync(endpoint, params, dataType = 'json') {
|
|
227
|
+
var names = Object.getOwnPropertyNames(params || {});
|
|
228
|
+
if (names.length) {
|
|
229
|
+
if (endpoint.indexOf('?') >= 0) {
|
|
230
|
+
endpoint += '&';
|
|
231
|
+
} else {
|
|
232
|
+
endpoint += '?';
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
for (var i = 0; i < names.length; ++i) {
|
|
237
|
+
var name = names[i];
|
|
238
|
+
endpoint += encodeURIComponent(name) + '=' + encodeURIComponent(params[name] || '') + '&';
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (names.length) {
|
|
242
|
+
endpoint = endpoint.substr(0, endpoint.length - 1);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
var xhr = new XMLHttpRequest();
|
|
246
|
+
xhr.open('get', endpoint, false);
|
|
247
|
+
if (_options.beforeSend) {
|
|
248
|
+
_options.beforeSend(xhr);
|
|
249
|
+
}
|
|
250
|
+
xhr.send();
|
|
251
|
+
return dataType == 'json' ? JSON.parse(xhr.responseText) : xhr.responseText;
|
|
252
|
+
};
|
|
253
|
+
|
|
226
254
|
function get(endpoint, params, dataType, contentType) {
|
|
227
255
|
var names = Object.getOwnPropertyNames(params || {});
|
|
228
256
|
if (names.length) {
|
|
@@ -312,6 +340,7 @@
|
|
|
312
340
|
exports.xhrRequest = _xhrRequest;
|
|
313
341
|
exports.request = request;
|
|
314
342
|
exports.get = get;
|
|
343
|
+
exports.getSync = getSync;
|
|
315
344
|
exports.post = post;
|
|
316
345
|
exports.put = put;
|
|
317
346
|
exports.patch = patch;
|
package/pome-cache-query.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e){if(typeof e!="undefined"&&e.get){return e}function n(e,n){if(!e){return}var t=Object.getOwnPropertyNames(e);for(var r=0;r<t.length;++r){n[t[r]]=e[t[r]]}}var f={isPagedResult(e){if(e.totalRecords==undefined||e.totalPages===undefined||e.currentPage===undefined||e.pageSize===undefined)return false;else return true},beforeSend:function(e){},onError:function(e,n){return Promise.resolve(e)},onSucceeded:function(e,n){return Promise.resolve(e)},baseUrl:null,batch:null,batchInterval:null,batchTimeout:10};var t=[];var r=function(e){var n=[];for(var t=0;t<e.length;++t){n.push(e[t])}return n};if(f.batch){setInterval(function(){if(!t.length){return}f.batch(t,h,f);t=[]},f.batchInterval||50)}function o(e){var n=JSON.stringify(e);return JSON.parse(n)}function a(e){var n=[];if(!e||typeof e!=="object")return n;for(var t in e){if(e[t])n.push(t)}return n}var
|
|
1
|
+
(function(e){if(typeof e!="undefined"&&e.get){return e}function n(e,n){if(!e){return}var t=Object.getOwnPropertyNames(e);for(var r=0;r<t.length;++r){n[t[r]]=e[t[r]]}}var f={isPagedResult(e){if(e.totalRecords==undefined||e.totalPages===undefined||e.currentPage===undefined||e.pageSize===undefined)return false;else return true},beforeSend:function(e){},onError:function(e,n){return Promise.resolve(e)},onSucceeded:function(e,n){return Promise.resolve(e)},baseUrl:null,batch:null,batchInterval:null,batchTimeout:10};var t=[];var r=function(e){var n=[];for(var t=0;t<e.length;++t){n.push(e[t])}return n};if(f.batch){setInterval(function(){if(!t.length){return}f.batch(t,h,f);t=[]},f.batchInterval||50)}function o(e){var n=JSON.stringify(e);return JSON.parse(n)}function a(e){var n=[];if(!e||typeof e!=="object")return n;for(var t in e){if(e[t])n.push(t)}return n}var i={};var u={};var s={};function c(e,n=null){n=n||"1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";var t="";for(var r=e;r>0;--r){t+=n[Math.floor(Math.random()*n.length)]}return t}function l(e){n(e,f)}function d(e,n=true,t=null){var r=Object.keys(e).sort();if(!r.length)return"";var o=n?"?":"";for(var a=0;a<r.length;a++){if(t){if(t.some(e=>e==r[a])){continue}}o+=r[a]+"="+encodeURI(e[r[a]])+"&"}return o.substr(0,o.length-1)}function p(e){e=e.substr(e.indexOf("?")+1);var n=e.split("&");var t={};for(var r=0;r<n.length;r++){var o=n[r].split("=");t[o[0]]=decodeURI(o[1])}return t}function g(e,n,t){var r=o(n);if(t&&r.page)delete r.page;return e+d(r)}function v(e){return f.isPagedResult(e)}function h(n){var t=new XMLHttpRequest;t.open(n.type,n.url);t.setRequestHeader("Content-Type",n.contentType);if(n.beforeSend){n.beforeSend(t)}if(typeof n.data!=="string"){if(n.contentType.toLocaleLowerCase()=="application/json"){n.data=JSON.stringify(n.data)}else if(n.contentType.toLocaleLowerCase()=="application/octet-stream"){}else{n.data=d(n.data,false)}}t.send(n.data);t.onreadystatechange=function(){if(t.readyState==4){var e=n.dataType=="json"?JSON.parse(t.responseText):t.responseText;if(t.status>=200&&t.status<300){n.success(e,t)}else{n.error(e,t)}}};return t}function b(e){if(e.indexOf("//")>=0){return e}else if(f.baseUrl){return f.baseUrl+e}else{return e}}function y(o,a,i,e,u){e=e||"json";u=u||"application/json";i=a=="GET"?null:i;o=b(o);if(!f.batch||e!="json"||u!="application/json"){var n=this;return new Promise(function(n,t){var r=h({url:o,type:a,dataType:e,contentType:u||"application/json",data:a=="GET"?null:i,success:function(e){f.onSucceeded(e,r).then(function(e){n(e)})},error:function(e){return f.onError(e,r).then(function(e){t(e)})},beforeSend:function(e){f.beforeSend(e)}})})}else{return new Promise(function(e,n){t.push({resolve:e,reject:n,request:{requestId:c(32),url:o,method:a,body:i?JSON.stringify(i):null,contentType:"application/json",timeout:f.batchTimeout}})})}}function m(e,n,t="json"){var r=Object.getOwnPropertyNames(n||{});if(r.length){if(e.indexOf("?")>=0){e+="&"}else{e+="?"}}for(var o=0;o<r.length;++o){var a=r[o];e+=encodeURIComponent(a)+"="+encodeURIComponent(n[a]||"")+"&"}if(r.length){e=e.substr(0,e.length-1)}var i=new XMLHttpRequest;i.open("get",e,false);if(f.beforeSend){f.beforeSend(i)}i.send();return t=="json"?JSON.parse(i.responseText):i.responseText}function O(e,n,t,r){var o=Object.getOwnPropertyNames(n||{});if(o.length){if(e.indexOf("?")>=0){e+="&"}else{e+="?"}}for(var a=0;a<o.length;++a){var i=o[a];e+=encodeURIComponent(i)+"="+encodeURIComponent(n[i]||"")+"&"}if(o.length){e=e.substr(0,e.length-1)}return y(e,"GET",n,t,r)}function T(e,n,t,r){return y(e,"POST",n,t,r)}function S(e,n,t,r){return y(e,"PATCH",n,t,r)}function j(e,n,t,r){return y(e,"PUT",n,t,r)}function P(e,n,t){var r=Object.getOwnPropertyNames(n||{});if(r.length){if(e.indexOf("?")>=0){e+="&"}else{e+="?"}}for(var o=0;o<r.length;++o){var a=r[o];e+=encodeURIComponent(a)+"="+encodeURIComponent(n[a]||"")+"&"}if(r.length){e=e.substr(0,e.length-1)}return y(e,"DELETE",n,t)}function w(e,n){var t=a(n);var r=g(e,n,t.some(e=>e==="page"));if(i[r]){delete i[r]}}function R(e,n,t,r){var o;if(!u[e])u[e]=[];var a=v(t);if(!a){o=g(e,n);i[o]=t}else{o=g(e,n,true);if(!i[o])i[o]={isPaged:true};i[o][t.data.current]=t}if(!u[e].some(e=>e==o))u[e].push(o);if(r)s[o]=(new Date).getTime()+r}e.generateQueryStringFromObject=d;e.generateObjectFromQueryString=p;e.xhrRequest=h;e.request=y;e.get=O;e.getSync=m;e.post=T;e.put=j;e.patch=S;e.delete=P;e.useConfig=l;return e})(typeof exports==="object"&&typeof module!=="undefined"?exports:function(){window.cq={};return window.cq}());
|
package/pome-commonjs.js
CHANGED
|
@@ -5,6 +5,14 @@ if (window.Pomelo) {
|
|
|
5
5
|
Pomelo.Module = {};
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
if (!window.PomeloCommonJsConfig) {
|
|
9
|
+
window.PomeloCommonJsConfig = {};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function SetPomeloCommonJsConfig(options) {
|
|
13
|
+
window.PomeloCommonJsConfig = options;
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
var PomeloModule = (function (exports) {
|
|
9
17
|
if (exports.module) {
|
|
10
18
|
return;
|
|
@@ -21,6 +29,15 @@ var PomeloModule = (function (exports) {
|
|
|
21
29
|
url = url.substr(1);
|
|
22
30
|
}
|
|
23
31
|
}
|
|
32
|
+
|
|
33
|
+
if (window.PomeloCommonJsConfig.version) {
|
|
34
|
+
if (url.indexOf('?') > 0) {
|
|
35
|
+
url += '&v=' + window.PomeloCommonJsConfig.version;
|
|
36
|
+
} else {
|
|
37
|
+
url += '?v=' + window.PomeloCommonJsConfig.version;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
24
41
|
var xhr = new XMLHttpRequest();
|
|
25
42
|
xhr.open('get', url, false);
|
|
26
43
|
xhr.send();
|
|
@@ -90,6 +107,25 @@ var PomeloModule = (function (exports) {
|
|
|
90
107
|
}
|
|
91
108
|
}
|
|
92
109
|
|
|
110
|
+
var supportedExtensions = ['.js', '.json', '.cjs'];
|
|
111
|
+
|
|
112
|
+
function ensureRequiredJsPath(path) {
|
|
113
|
+
var slashIdx = path.lastIndexOf('/');
|
|
114
|
+
var subPath = slashIdx < 0 ? path : path.substr(slashIdx + 1);
|
|
115
|
+
|
|
116
|
+
var dotIdx = subPath.lastIndexOf('.');
|
|
117
|
+
var ext = subPath.substr(dotIdx);
|
|
118
|
+
if (dotIdx < 0) {
|
|
119
|
+
return path + '.js';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (supportedExtensions.some(x => x == ext.toLowerCase())) {
|
|
123
|
+
return path;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return path + '.js';
|
|
127
|
+
}
|
|
128
|
+
|
|
93
129
|
var module = {
|
|
94
130
|
require(script, workingDirectory, mode) {
|
|
95
131
|
mode = mode || 'singleton';
|
|
@@ -100,9 +136,7 @@ var PomeloModule = (function (exports) {
|
|
|
100
136
|
}
|
|
101
137
|
|
|
102
138
|
var url = resolveRelativePath(script, workingDirectory);
|
|
103
|
-
|
|
104
|
-
url = url + '.js';
|
|
105
|
-
}
|
|
139
|
+
var url = ensureRequiredJsPath(url);
|
|
106
140
|
if (_alias[url]) {
|
|
107
141
|
url = _alias[url];
|
|
108
142
|
}
|
|
@@ -113,6 +147,13 @@ var PomeloModule = (function (exports) {
|
|
|
113
147
|
|
|
114
148
|
var js = _cache[url];
|
|
115
149
|
|
|
150
|
+
if (url.length >= '.json'.length) {
|
|
151
|
+
var jsonExt = url.substr(url.length - '.json'.length);
|
|
152
|
+
if (jsonExt == '.json') {
|
|
153
|
+
return JSON.parse(js);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
116
157
|
if (mode == 'singleton' && _singleton[url]) {
|
|
117
158
|
return _singleton[url];
|
|
118
159
|
}
|
package/pome-commonjs.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
if(window.Pomelo){Pomelo.Module={}}var PomeloModule=function(exports){if(exports.module){return}var _cache={};var _alias={};var _singleton={};var useRelativePath=window.location.protocol!="http:"&&window.location.protocol!="https:";function _httpGetSync(e){if(useRelativePath){if(e.length&&e[0]=="/"){e=e.substr(1)}}var r=new XMLHttpRequest;r.open("get",e,false);r.send();return r.responseText}var validModes=["singleton","transient"];function getContainingFolder(e){if(!e){console.warn("getContainingFolder: absolutePath is invalid")}var r=e.lastIndexOf("/");if(r<0){return useRelativePath?"":"/"}var
|
|
1
|
+
if(window.Pomelo){Pomelo.Module={}}if(!window.PomeloCommonJsConfig){window.PomeloCommonJsConfig={}}function SetPomeloCommonJsConfig(e){window.PomeloCommonJsConfig=e}var PomeloModule=function(exports){if(exports.module){return}var _cache={};var _alias={};var _singleton={};var useRelativePath=window.location.protocol!="http:"&&window.location.protocol!="https:";function _httpGetSync(e){if(useRelativePath){if(e.length&&e[0]=="/"){e=e.substr(1)}}if(window.PomeloCommonJsConfig.version){if(e.indexOf("?")>0){e+="&v="+window.PomeloCommonJsConfig.version}else{e+="?v="+window.PomeloCommonJsConfig.version}}var r=new XMLHttpRequest;r.open("get",e,false);r.send();return r.responseText}var validModes=["singleton","transient"];function getContainingFolder(e){if(!e){console.warn("getContainingFolder: absolutePath is invalid")}var r=e.lastIndexOf("/");if(r<0){return useRelativePath?"":"/"}var o=e.substr(0,r)+"/";if(useRelativePath&&o.length&&o[0]=="/"){o=o.substr(1)}return o}function resolveRelativePathPlain(e){if(e.indexOf("./")==-1&&e.indexOf("../")==-1){return e}var r=e.lastIndexOf("../");if(r==0){return e}e=e.replaceAll("/./","/");if(e.indexOf("./")==0){e=e.substr(2)}if(r){var o=e.substr(0,r);var t=e.substr(r);return resolveRelativePath(t,o)}}function resolveRelativePath(e,r){if(e.length&&e[0]=="/"||e.indexOf("http")==0){return resolveRelativePathPlain(e)}if(e.length&&e[0]!="."){return resolveRelativePathPlain(r+e)}if(e.indexOf("./")==0){return resolveRelativePath(e.substr(2),r)}if(e.indexOf("../")==0){e=e.substr(3);r=getContainingFolder(r.substr(0,r.length-1));return resolveRelativePath(e,r)}}var supportedExtensions=[".js",".json",".cjs"];function ensureRequiredJsPath(e){var r=e.lastIndexOf("/");var o=r<0?e:e.substr(r+1);var t=o.lastIndexOf(".");var n=o.substr(t);if(t<0){return e+".js"}if(supportedExtensions.some(e=>e==n.toLowerCase())){return e}return e+".js"}var module={require(script,workingDirectory,mode){mode=mode||"singleton";workingDirectory=workingDirectory||"/";if(validModes.indexOf(mode)==-1){throw"Invalid require mode"}var url=resolveRelativePath(script,workingDirectory);var url=ensureRequiredJsPath(url);if(_alias[url]){url=_alias[url]}if(!_cache[url]){_cache[url]=_httpGetSync(url)}var js=_cache[url];if(url.length>=".json".length){var jsonExt=url.substr(url.length-".json".length);if(jsonExt==".json"){return JSON.parse(js)}}if(mode=="singleton"&&_singleton[url]){return _singleton[url]}var module={exports:{}};var self=this;with(module){var require=function(e,r,o){r=r||getContainingFolder(url);return self.require(e,r,o)};js=js.replaceAll("export default","exports.default =");eval(js+"\r\n//# sourceURL="+url);if(mode=="singleton"){_singleton[url]=exports}return exports}return module.exports},alias(e,r){_alias[r]=e}};exports.require=module.require;exports.alias=module.alias;exports.getContainingFolder=getContainingFolder;return exports}(window);
|
package/pome-localization.js
CHANGED
|
@@ -4,11 +4,16 @@
|
|
|
4
4
|
function create() {
|
|
5
5
|
var currentLocale = null;
|
|
6
6
|
return {
|
|
7
|
+
localesGroups: [],
|
|
7
8
|
locales: {},
|
|
8
9
|
texts: {},
|
|
10
|
+
overrides: {},
|
|
9
11
|
getCurrentLocale() {
|
|
10
12
|
return currentLocale;
|
|
11
13
|
},
|
|
14
|
+
getLocalesGroups() {
|
|
15
|
+
return this.localesGroups;
|
|
16
|
+
},
|
|
12
17
|
addLocale(path, locales, isFallback) {
|
|
13
18
|
if (!locales) {
|
|
14
19
|
var index = path.lastIndexOf('/');
|
|
@@ -20,6 +25,8 @@ function create() {
|
|
|
20
25
|
locales = locales.split('.')[0];
|
|
21
26
|
}
|
|
22
27
|
|
|
28
|
+
this.localesGroups.push(locales);
|
|
29
|
+
|
|
23
30
|
if (typeof locales == 'string') {
|
|
24
31
|
this.locales[locales] = path;
|
|
25
32
|
} else if (locales instanceof Array) {
|
|
@@ -67,15 +74,34 @@ function create() {
|
|
|
67
74
|
if (arguments.length == 0) {
|
|
68
75
|
return null;
|
|
69
76
|
}
|
|
77
|
+
|
|
70
78
|
var key = arguments[0];
|
|
71
79
|
var val = key;
|
|
72
|
-
|
|
80
|
+
var foundInOverrides = false;
|
|
81
|
+
if (this.overrides[this.getCurrentLocale()] && this.overrides[this.getCurrentLocale()][key]) {
|
|
82
|
+
val = this.overrides[this.getCurrentLocale()][key];
|
|
83
|
+
foundInOverrides = true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!foundInOverrides && this.texts[key]) {
|
|
73
87
|
val = this.texts[key];
|
|
74
88
|
}
|
|
89
|
+
|
|
75
90
|
for (var i = 1; i < arguments.length; ++i) {
|
|
76
91
|
val = val.replaceAll(`{${i - 1}}`, arguments[i]);
|
|
77
92
|
}
|
|
93
|
+
|
|
78
94
|
return val;
|
|
95
|
+
},
|
|
96
|
+
setLocalizedString(locales, key, val) {
|
|
97
|
+
var self = this;
|
|
98
|
+
locales.forEach(function (locale) {
|
|
99
|
+
if (!self.overrides[locale]) {
|
|
100
|
+
self.overrides[locale] = {};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
self.overrides[locale][key] = val;
|
|
104
|
+
});
|
|
79
105
|
}
|
|
80
106
|
};
|
|
81
107
|
}
|
package/pome-localization.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function create(){var s=null;return{locales:{},texts:{},getCurrentLocale(){return s},addLocale(e,l
|
|
1
|
+
function create(){var s=null;return{localesGroups:[],locales:{},texts:{},overrides:{},getCurrentLocale(){return s},getLocalesGroups(){return this.localesGroups},addLocale(e,t,l){if(!t){var r=e.lastIndexOf("/");if(r<0){t=e}else{t=e.substr(e,r+1)}t=t.split(".")[0]}this.localesGroups.push(t);if(typeof t=="string"){this.locales[t]=e}else if(t instanceof Array){for(var s=0;s<t.length;++s){this.locales[t[s]]=e}}if(l){this.locales["fallback"]=e}},setLocale(e){if(!e){e=!window.localStorage.locale?window.navigator.language:window.localStorage.locale}if(!this.locales[e]){e="fallback"}if(!this.locales[e]){throw"No available translations for the locale"}s=e;this.texts=require(this.locales[e]).texts;if(this.locales["fallback"]){if(this.locales[e]!=this.locales["fallback"]){var t=require(this.locales["fallback"]).texts;var l=Object.getOwnPropertyNames(t);var r=this;l.forEach(function(e){if(!r.texts[e]){r.texts[e]=t[e]}})}}},sr(){if(arguments.length==0){return null}var e=arguments[0];var t=e;var l=false;if(this.overrides[this.getCurrentLocale()]&&this.overrides[this.getCurrentLocale()][e]){t=this.overrides[this.getCurrentLocale()][e];l=true}if(!l&&this.texts[e]){t=this.texts[e]}for(var r=1;r<arguments.length;++r){t=t.replaceAll(`{${r-1}}`,arguments[r])}return t},setLocalizedString(e,t,l){var r=this;e.forEach(function(e){if(!r.overrides[e]){r.overrides[e]={}}r.overrides[e][t]=l})}}}exports.create=create;
|