@kizmann/pico-js 1.0.13 → 2.0.0
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/README.md +27 -7
- package/dist/pico-js.browser.js +2 -0
- package/dist/pico-js.browser.js.map +1 -0
- package/dist/pico-js.esm.js +2 -0
- package/dist/pico-js.esm.js.map +1 -0
- package/package.json +20 -7
- package/src/dom/DomAttribute.js +374 -0
- package/src/dom/DomBuilder.js +152 -0
- package/src/dom/DomEvent.js +253 -0
- package/src/dom/DomFinder.js +669 -0
- package/src/dom/DomForm.js +57 -0
- package/src/dom/DomGlobal.js +193 -0
- package/src/dom/DomInview.js +332 -0
- package/src/dom/DomMeta.js +66 -0
- package/src/dom/DomObserver.js +57 -0
- package/src/dom/DomRectangle.js +657 -0
- package/src/format/FormatFile.js +54 -0
- package/src/format/FormatOption.js +108 -0
- package/src/format/FormatParam.js +107 -0
- package/src/format/FormatParser.js +156 -0
- package/src/format/FormatUrl.js +75 -0
- package/src/index.browser.js +10 -0
- package/src/index.esm.js +138 -0
- package/src/now/NowDefault.js +533 -0
- package/src/now/NowFormat.js +196 -0
- package/src/now/NowGrid.js +251 -0
- package/src/now/NowHuman.js +118 -0
- package/src/now/NowMatch.js +175 -0
- package/src/now/NowRange.js +70 -0
- package/src/now/NowWalker.js +544 -0
- package/src/tool/scope.js +103 -0
- package/src/utils/Array.js +986 -0
- package/src/utils/Cookie.js +184 -0
- package/src/utils/Data.js +200 -0
- package/src/utils/Dom.js +208 -0
- package/src/utils/Event.js +140 -0
- package/src/utils/Format.js +62 -0
- package/src/utils/Hash.js +164 -0
- package/src/utils/Locale.js +229 -0
- package/src/utils/Mixed.js +887 -0
- package/src/utils/Now.js +234 -0
- package/src/utils/Number.js +238 -0
- package/src/utils/Object.js +655 -0
- package/src/utils/Route.js +67 -0
- package/src/utils/Runner.js +327 -0
- package/src/utils/String.js +618 -0
- package/src/{library/element.js → wip/Element.js} +90 -16
- package/src/{library/map.js → wip/Map.js} +256 -40
- package/types/dom/DomAttribute.d.ts +137 -0
- package/types/dom/DomBuilder.d.ts +67 -0
- package/types/dom/DomEvent.d.ts +103 -0
- package/types/dom/DomFinder.d.ts +321 -0
- package/types/dom/DomForm.d.ts +21 -0
- package/types/dom/DomGlobal.d.ts +79 -0
- package/types/dom/DomInview.d.ts +114 -0
- package/types/dom/DomMeta.d.ts +29 -0
- package/types/dom/DomObserver.d.ts +21 -0
- package/types/dom/DomRectangle.d.ts +270 -0
- package/types/format/FormatFile.d.ts +18 -0
- package/types/format/FormatOption.d.ts +40 -0
- package/types/format/FormatParam.d.ts +39 -0
- package/types/format/FormatParser.d.ts +46 -0
- package/types/format/FormatUrl.d.ts +17 -0
- package/types/index.browser.d.ts +1 -0
- package/types/index.esm.d.ts +52 -0
- package/types/now/NowDefault.d.ts +183 -0
- package/types/now/NowFormat.d.ts +70 -0
- package/types/now/NowGrid.d.ts +107 -0
- package/types/now/NowHuman.d.ts +37 -0
- package/types/now/NowMatch.d.ts +108 -0
- package/types/now/NowRange.d.ts +21 -0
- package/types/now/NowWalker.d.ts +301 -0
- package/types/tool/scope.d.ts +24 -0
- package/types/utils/Array.d.ts +480 -0
- package/types/utils/Cookie.d.ts +60 -0
- package/types/utils/Data.d.ts +91 -0
- package/types/utils/Dom.d.ts +138 -0
- package/types/utils/Event.d.ts +58 -0
- package/types/utils/Format.d.ts +37 -0
- package/types/utils/Hash.d.ts +81 -0
- package/types/utils/Locale.d.ts +115 -0
- package/types/utils/Mixed.d.ts +469 -0
- package/types/utils/Now.d.ts +125 -0
- package/types/utils/Number.d.ts +127 -0
- package/types/utils/Object.d.ts +255 -0
- package/types/utils/Route.d.ts +37 -0
- package/types/utils/Runner.d.ts +139 -0
- package/types/utils/String.d.ts +330 -0
- package/types/wip/Element.d.ts +119 -0
- package/types/wip/Map.d.ts +254 -0
- package/dist/.ignore.js +0 -0
- package/dist/pico-js.js +0 -2
- package/dist/pico-js.js.map +0 -1
- package/src/element/default.js +0 -46
- package/src/element/example.js +0 -58
- package/src/index.js +0 -90
- package/src/library/cookie.js +0 -123
- package/src/library/data.js +0 -111
- package/src/library/event.js +0 -91
- package/src/library/locale.js +0 -84
- package/src/library/queue.js +0 -64
- package/src/library/route.js +0 -28
- package/src/utility/any.js +0 -369
- package/src/utility/array.js +0 -410
- package/src/utility/dom.js +0 -1425
- package/src/utility/now.js +0 -544
- package/src/utility/number.js +0 -128
- package/src/utility/object.js +0 -429
- package/src/utility/string.js +0 -328
- package/types/index.d.ts +0 -77
- package/types/library/cookie.d.ts +0 -10
- package/types/library/data.d.ts +0 -15
- package/types/library/element.d.ts +0 -22
- package/types/library/event.d.ts +0 -13
- package/types/library/locale.d.ts +0 -14
- package/types/library/map.d.ts +0 -43
- package/types/library/queue.d.ts +0 -18
- package/types/library/route.d.ts +0 -11
- package/types/utility/any.d.ts +0 -35
- package/types/utility/array.d.ts +0 -46
- package/types/utility/dom.d.ts +0 -101
- package/types/utility/now.d.ts +0 -79
- package/types/utility/number.d.ts +0 -17
- package/types/utility/object.d.ts +0 -29
- package/types/utility/string.d.ts +0 -26
package/src/element/example.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Dom } from "../index.js";
|
|
2
|
-
import DefaultElement from "./default.js";
|
|
3
|
-
|
|
4
|
-
export default class Example extends DefaultElement
|
|
5
|
-
{
|
|
6
|
-
options = {
|
|
7
|
-
duration: 500,
|
|
8
|
-
delay: 1000,
|
|
9
|
-
baseName: 'ready',
|
|
10
|
-
doneModifier: 'done'
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
constructor(el, options) {
|
|
14
|
-
super(); this.apply(el, options);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
bind()
|
|
18
|
-
{
|
|
19
|
-
if ( window.$ === undefined ) {
|
|
20
|
-
return console.error('Element ready function requires jquery.')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
Dom.ready(this.bindAnimation.bind(this), this.options.delay);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
bindAnimation()
|
|
27
|
-
{
|
|
28
|
-
Dom.find(this.el).addClass(this.options.baseName);
|
|
29
|
-
|
|
30
|
-
let options = {
|
|
31
|
-
duration: this.options.duration
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
options.complete = () => {
|
|
35
|
-
|
|
36
|
-
Dom.find(this.el).css({
|
|
37
|
-
display: 'none'
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
Dom.find(this.el).addClass(
|
|
41
|
-
this.getReadyClass()
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
Dom.find(this.el).css({
|
|
47
|
-
opacity: 1
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
window.$(this.el).animate({ opacity: 0 }, options);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
getReadyClass()
|
|
54
|
-
{
|
|
55
|
-
return this.options.baseName + '--' + this.options.doneModifier;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import Arr from "./utility/array.js";
|
|
3
|
-
export { Arr };
|
|
4
|
-
|
|
5
|
-
import Obj from "./utility/object.js";
|
|
6
|
-
export { Obj };
|
|
7
|
-
|
|
8
|
-
import Num from "./utility/number.js";
|
|
9
|
-
export { Num };
|
|
10
|
-
|
|
11
|
-
import Str from "./utility/string.js";
|
|
12
|
-
export { Str };
|
|
13
|
-
|
|
14
|
-
import Now from "./utility/now.js";
|
|
15
|
-
export { Now };
|
|
16
|
-
|
|
17
|
-
import Any from "./utility/any.js";
|
|
18
|
-
export { Any };
|
|
19
|
-
|
|
20
|
-
import Dom from "./utility/dom.js";
|
|
21
|
-
export { Dom };
|
|
22
|
-
|
|
23
|
-
import Cookie from "./library/cookie.js";
|
|
24
|
-
export { Cookie };
|
|
25
|
-
|
|
26
|
-
import Data from "./library/data.js";
|
|
27
|
-
export { Data };
|
|
28
|
-
|
|
29
|
-
import Element from "./library/element.js";
|
|
30
|
-
export { Element };
|
|
31
|
-
|
|
32
|
-
import Event from "./library/event.js";
|
|
33
|
-
export { Event };
|
|
34
|
-
|
|
35
|
-
import Locale from "./library/locale.js";
|
|
36
|
-
export { Locale };
|
|
37
|
-
|
|
38
|
-
import Map from "./library/map.js";
|
|
39
|
-
export { Map };
|
|
40
|
-
|
|
41
|
-
import Queue from "./library/queue.js";
|
|
42
|
-
export { Queue };
|
|
43
|
-
|
|
44
|
-
import Route from "./library/route.js";
|
|
45
|
-
export { Route };
|
|
46
|
-
|
|
47
|
-
import { v4 as UUID } from "uuid"
|
|
48
|
-
export { UUID };
|
|
49
|
-
|
|
50
|
-
export const Pico = {
|
|
51
|
-
|
|
52
|
-
UUID: UUID,
|
|
53
|
-
|
|
54
|
-
Arr: Arr,
|
|
55
|
-
Obj: Obj,
|
|
56
|
-
Num: Num,
|
|
57
|
-
Str: Str,
|
|
58
|
-
Now: Now,
|
|
59
|
-
Any: Any,
|
|
60
|
-
Dom: Dom,
|
|
61
|
-
|
|
62
|
-
Cookie: Cookie,
|
|
63
|
-
Data: Data,
|
|
64
|
-
Element: Element,
|
|
65
|
-
Event: Event,
|
|
66
|
-
Locale: Locale,
|
|
67
|
-
Map: Map,
|
|
68
|
-
Queue: Queue,
|
|
69
|
-
Route: Route,
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let win = Any.global();
|
|
73
|
-
|
|
74
|
-
if ( typeof win.IE === 'undefined' && win.navigator ) {
|
|
75
|
-
win.IE = !! win.navigator.userAgent.match(/Edge\/|Trident\/|MSIE /);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if ( typeof win.WIN === 'undefined' && win.navigator ) {
|
|
79
|
-
win.WIN = !! win.navigator.userAgent.match(/Windows/);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if ( typeof win.pi === 'undefined' && win.navigator ) {
|
|
83
|
-
win.pi = Pico;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if ( typeof win.pi !== 'undefined' && win.document ) {
|
|
87
|
-
win.pi.Dom.ready(win.pi.Element.listen);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export default Pico;
|
package/src/library/cookie.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { Str, Arr, Obj, Num, Any, Event } from "../index.js";
|
|
2
|
-
|
|
3
|
-
export class Cookie
|
|
4
|
-
{
|
|
5
|
-
/**
|
|
6
|
-
* Pattern to get the cookie desired
|
|
7
|
-
*
|
|
8
|
-
* @type {string}
|
|
9
|
-
*/
|
|
10
|
-
static pattern = '(^|;)\\s*{key}\\s*=\\s*([^;]+)';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Get cookie from current session
|
|
14
|
-
*
|
|
15
|
-
* @param {string} key
|
|
16
|
-
* @param {*} fallback
|
|
17
|
-
* @param {'string','boolean','float','integer','object','array'} decode
|
|
18
|
-
* @returns {*}
|
|
19
|
-
*/
|
|
20
|
-
static get(key, fallback = null, decode = 'string')
|
|
21
|
-
{
|
|
22
|
-
let pattern = this.pattern
|
|
23
|
-
.replace('{key}', key);
|
|
24
|
-
|
|
25
|
-
let result = document.cookie
|
|
26
|
-
.match(pattern);
|
|
27
|
-
|
|
28
|
-
if ( ! result ) {
|
|
29
|
-
return fallback;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let plain = result[2].replace(/\{:\}/g, ';');
|
|
33
|
-
|
|
34
|
-
if ( decode === 'boolean' ) {
|
|
35
|
-
return Any.boolean(plain);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if ( decode === 'float' ) {
|
|
39
|
-
return Any.float(plain);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if ( decode === 'integer' ) {
|
|
43
|
-
return Any.integer(plain);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if ( decode === 'object' ) {
|
|
47
|
-
return Str.objectify(plain, 'params', false);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if ( decode === 'array' ) {
|
|
51
|
-
return Str.objectify(plain, 'params', true);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return plain;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Set cookie in current session
|
|
59
|
-
*
|
|
60
|
-
* @param {string} key
|
|
61
|
-
* @param {*} value
|
|
62
|
-
* @param {integer} expire
|
|
63
|
-
* @param {object} options
|
|
64
|
-
*/
|
|
65
|
-
static set(key, value, expire = null, options = {})
|
|
66
|
-
{
|
|
67
|
-
let date = new Date;
|
|
68
|
-
|
|
69
|
-
if ( expire !== null ) {
|
|
70
|
-
date.setTime(Date.now() + (expire || 0));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if ( Date.now() !== date.getTime() ) {
|
|
74
|
-
options.expires = date.toUTCString();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if ( ! options.path ) {
|
|
78
|
-
options.path = '/';
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if ( Any.isObject(value) ) {
|
|
82
|
-
value = Str.stringify(value, 'params');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if ( Any.isString(value) ) {
|
|
86
|
-
value = value.replace(/;/g, '{:}');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
let plain = `${key}=${value};`;
|
|
90
|
-
|
|
91
|
-
Obj.each(options, (value, key) => {
|
|
92
|
-
plain += `${key}=${value};`;
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
document.cookie = plain;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Forget cookie from current session
|
|
100
|
-
*
|
|
101
|
-
* @param {string} key
|
|
102
|
-
* @param {object} options
|
|
103
|
-
*/
|
|
104
|
-
static forget(key, options = {})
|
|
105
|
-
{
|
|
106
|
-
if ( ! options.path ) {
|
|
107
|
-
options.path = '/';
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
options.expires = 'Thu, 01 Jan 1970 00:00:01 GMT';
|
|
111
|
-
|
|
112
|
-
let plain = `${key}=null;`;
|
|
113
|
-
|
|
114
|
-
Obj.each(options, (value, key) => {
|
|
115
|
-
plain += `${key}=${value};`;
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
document.cookie = plain;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export default Cookie;
|
package/src/library/data.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { Arr, Obj, Num, Any, Event } from "../index.js";
|
|
2
|
-
|
|
3
|
-
export class Data
|
|
4
|
-
{
|
|
5
|
-
static data = Obj.get(Any.global(), '_data', {});
|
|
6
|
-
|
|
7
|
-
static has(input)
|
|
8
|
-
{
|
|
9
|
-
return Obj.has(this.data, Arr.first(input));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static set(input, value)
|
|
13
|
-
{
|
|
14
|
-
let clone = value, key = Arr.first(input);
|
|
15
|
-
|
|
16
|
-
if ( Any.isEqual(Obj.get(this.data, key), clone) ) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
Obj.set(this.data, key, clone);
|
|
21
|
-
|
|
22
|
-
Event.fire('store:' + key, clone, key);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static unset(input)
|
|
26
|
-
{
|
|
27
|
-
let key = Arr.first(input);
|
|
28
|
-
|
|
29
|
-
Obj.unset(this.data, key);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static get (input, fallback = null, forceSet = false)
|
|
33
|
-
{
|
|
34
|
-
let key = Arr.first(input);
|
|
35
|
-
|
|
36
|
-
if ( ! Obj.has(this.data, key) && ! forceSet ) {
|
|
37
|
-
return fallback;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if ( Obj.has(this.data, key) && forceSet ) {
|
|
41
|
-
Obj.set(this.data, key, fallback);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let value = Obj.get(this.data, key, fallback);
|
|
45
|
-
|
|
46
|
-
if ( ! Any.isPlain(value) ) {
|
|
47
|
-
return value;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return Obj.clone(value);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
static find (input, value, fallback = null)
|
|
54
|
-
{
|
|
55
|
-
let key = Arr.first(input);
|
|
56
|
-
|
|
57
|
-
if ( Obj.has(this.data, key) === false ) {
|
|
58
|
-
return fallback;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if ( Obj.has(value, 'id') === false ) {
|
|
62
|
-
return fallback;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
let index = Arr.findIndex(this.get(key), {
|
|
66
|
-
id: value.id
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
if ( index === -1 ) {
|
|
70
|
-
return fallback;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return this.get(key + '.' + index);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static replace (input, value)
|
|
77
|
-
{
|
|
78
|
-
let key = Arr.first(input);
|
|
79
|
-
|
|
80
|
-
if ( Obj.has(this.data, key) === false ) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if ( Obj.has(value, 'id') === false ) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let index = Arr.findIndex(this.get(key), {
|
|
89
|
-
id: Num.int(value.id)
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
if ( index === -1 ) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this.set(key + '.' + index, value);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static add (input, ...args)
|
|
100
|
-
{
|
|
101
|
-
this.set(input, Arr.concat(this.get(input, []), args));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
static remove (input, ...args)
|
|
105
|
-
{
|
|
106
|
-
this.set(input, Arr.diff(this.get(input, []), args));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export default Data;
|
package/src/library/event.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Arr, Any } from "../index.js";
|
|
2
|
-
|
|
3
|
-
export class Event
|
|
4
|
-
{
|
|
5
|
-
static events = [];
|
|
6
|
-
|
|
7
|
-
static bind(name, callback, options = {}, paused = false)
|
|
8
|
-
{
|
|
9
|
-
if ( Any.isArray(name) ) {
|
|
10
|
-
return Arr.each(name, (val) =>
|
|
11
|
-
this.bind(val, callback, options, paused));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if ( ! Any.isPlain(options) ) {
|
|
15
|
-
options = { value: options }
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
this.events = Arr.push(this.events, {
|
|
19
|
-
name, callback, options, paused
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static unbind(name, options = {})
|
|
26
|
-
{
|
|
27
|
-
if ( Any.isArray(name) ) {
|
|
28
|
-
return Arr.each(name, (val) => this.unbind(val, options));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if ( ! Any.isPlain(options) ) {
|
|
32
|
-
options = { value: options }
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
Arr.remove(this.events, { name, options });
|
|
36
|
-
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static fire(name, ...args)
|
|
41
|
-
{
|
|
42
|
-
let events = this.events.filter((item) => {
|
|
43
|
-
return item.name === name;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
Arr.each(events, (event) => {
|
|
47
|
-
if ( event.paused === false ) {
|
|
48
|
-
event.callback.call({}, ...args);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static pause(name, options = {})
|
|
56
|
-
{
|
|
57
|
-
if ( Any.isArray(name) ) {
|
|
58
|
-
return Arr.each(name, (val) => this.pause(val, options));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let val = Arr.find(this.events, { name, options });
|
|
62
|
-
|
|
63
|
-
if ( val === null ) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
val.paused = true;
|
|
68
|
-
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
static unpause(name, options = {})
|
|
73
|
-
{
|
|
74
|
-
if ( Any.isArray(name) ) {
|
|
75
|
-
return Arr.each(name, (val) => this.unpause(val, options));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let val = Arr.find(this.events, { name, options });
|
|
79
|
-
|
|
80
|
-
if ( val === null ) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
val.paused = false;
|
|
85
|
-
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export default Event;
|
package/src/library/locale.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Obj, Any } from "../index.js";
|
|
2
|
-
|
|
3
|
-
export class Locale
|
|
4
|
-
{
|
|
5
|
-
/**
|
|
6
|
-
* Get locales from window if present.
|
|
7
|
-
*/
|
|
8
|
-
static locales = Obj.get(Any.global(), '_locales', {});
|
|
9
|
-
|
|
10
|
-
static pickByCount(splits, count)
|
|
11
|
-
{
|
|
12
|
-
let splitLength = splits.length;
|
|
13
|
-
|
|
14
|
-
if ( splitLength === 3 && count === 0 ) {
|
|
15
|
-
return splits[0];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if ( splitLength === 3 && count === 1 ) {
|
|
19
|
-
return splits[1];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if ( splitLength === 3 && count >= 2 ) {
|
|
23
|
-
return splits[2];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if ( splitLength === 2 && count === 1 ) {
|
|
27
|
-
return splits[0];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if ( splitLength === 2 && count !== 1 ) {
|
|
31
|
-
return splits[1];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return splits[0];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static has(key)
|
|
38
|
-
{
|
|
39
|
-
return Obj.has(Locale.locales, key);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static get(key, fallback = null)
|
|
43
|
-
{
|
|
44
|
-
return Obj.get(Locale.locales, key, fallback || key);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static set(key, value)
|
|
48
|
-
{
|
|
49
|
-
Obj.set(Locale.locales, key, value);
|
|
50
|
-
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static trans(key, values = {})
|
|
55
|
-
{
|
|
56
|
-
let message = Obj.get(Locale.locales, key, key);
|
|
57
|
-
|
|
58
|
-
Obj.each(values, (value, key) => {
|
|
59
|
-
message = message.replace(new RegExp(':' + key, 'g'), value);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return message;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static choice(key, count = 0, values = {})
|
|
66
|
-
{
|
|
67
|
-
let splits = Obj.get(Locale.locales, key, key).split('|');
|
|
68
|
-
|
|
69
|
-
if ( typeof values.count === 'undefined' ) {
|
|
70
|
-
values = Obj.assign({ count: count }, values);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
let message = Locale.pickByCount(splits, count);
|
|
74
|
-
|
|
75
|
-
Obj.each(values, (value, key) => {
|
|
76
|
-
message = message.replace(new RegExp(':' + key, 'g'), value);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
return message;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export default Locale;
|
package/src/library/queue.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Arr } from "../index.js";
|
|
2
|
-
|
|
3
|
-
export default class Queue
|
|
4
|
-
{
|
|
5
|
-
queue = [];
|
|
6
|
-
stopQueue = false;
|
|
7
|
-
activeQueue = false;
|
|
8
|
-
|
|
9
|
-
constructor(queue = [])
|
|
10
|
-
{
|
|
11
|
-
this.queue = queue;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
handler(queue, index)
|
|
15
|
-
{
|
|
16
|
-
return () => queue.length - 1 > index ++ && this.stopQueue === false ?
|
|
17
|
-
queue[index](this.handler(queue, index)) : () => {};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
stop()
|
|
21
|
-
{
|
|
22
|
-
this.stopQueue = true;
|
|
23
|
-
this.activeQueue = false;
|
|
24
|
-
|
|
25
|
-
this.queue = [];
|
|
26
|
-
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
clear()
|
|
31
|
-
{
|
|
32
|
-
this.queue = [];
|
|
33
|
-
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
add(cb)
|
|
38
|
-
{
|
|
39
|
-
this.queue.push(cb);
|
|
40
|
-
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
run()
|
|
45
|
-
{
|
|
46
|
-
let instance = new Queue(this.queue);
|
|
47
|
-
|
|
48
|
-
instance.add(() => {
|
|
49
|
-
instance.activeQueue = false;
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
if ( instance.queue.length !== 0 ) {
|
|
53
|
-
Arr.first(instance.queue)(instance.handler(instance.queue.slice(0), 0));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return instance;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
active()
|
|
60
|
-
{
|
|
61
|
-
return this.activeQueue;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
}
|
package/src/library/route.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Obj, Str, Any } from "../index.js";
|
|
2
|
-
|
|
3
|
-
export default class Route
|
|
4
|
-
{
|
|
5
|
-
static routes = Obj.get(Any.global(), '_routes', {});
|
|
6
|
-
|
|
7
|
-
static set (key, value)
|
|
8
|
-
{
|
|
9
|
-
this.routes[key] = value;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static get (key, values = null, params = null)
|
|
13
|
-
{
|
|
14
|
-
let route = key.match(/^https?:\/\//) ? key : this.routes[key] || key;
|
|
15
|
-
|
|
16
|
-
Obj.each(values || {}, (value, key) => {
|
|
17
|
-
route = route.replace(new RegExp('{' + key + '\\?*}', 'g'), value);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
return route + (! Any.isEmpty(params) ? ('?' + Str.params(params)) : '');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static goto (key, values = null, params = null)
|
|
24
|
-
{
|
|
25
|
-
window.location.href = this.get(key, values, params);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
}
|