@kizmann/pico-js 2.0.7 → 2.0.9
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/dist/pico-js.browser.js +1 -1
- package/dist/pico-js.browser.js.map +1 -1
- package/dist/pico-js.esm.js +1 -1
- package/dist/pico-js.esm.js.map +1 -1
- package/package.json +4 -6
- package/src/dom/{DomAttribute.js → DomAttribute.ts} +40 -63
- package/src/dom/{DomBuilder.js → DomBuilder.ts} +27 -44
- package/src/dom/{DomEvent.js → DomEvent.ts} +101 -76
- package/src/dom/{DomFinder.js → DomFinder.ts} +103 -139
- package/src/dom/DomForm.ts +38 -0
- package/src/dom/{DomGlobal.js → DomGlobal.ts} +34 -51
- package/src/dom/{DomInview.js → DomInview.ts} +37 -57
- package/src/dom/DomMeta.ts +48 -0
- package/src/dom/DomObserver.ts +17 -0
- package/src/dom/{DomPopover.js → DomPopover.ts} +20 -39
- package/src/dom/{DomRectangle.js → DomRectangle.ts} +70 -87
- package/src/format/{FormatFile.js → FormatFile.ts} +12 -23
- package/src/format/{FormatOption.js → FormatOption.ts} +15 -24
- package/src/format/{FormatParam.js → FormatParam.ts} +14 -25
- package/src/format/{FormatParser.js → FormatParser.ts} +29 -39
- package/src/format/{FormatUrl.js → FormatUrl.ts} +9 -21
- package/src/index.browser.ts +32 -0
- package/src/index.esm.ts +64 -0
- package/src/now/{NowDefault.js → NowDefault.ts} +86 -121
- package/src/now/{NowFormat.js → NowFormat.ts} +23 -28
- package/src/now/{NowGrid.js → NowGrid.ts} +41 -58
- package/src/now/{NowHuman.js → NowHuman.ts} +18 -27
- package/src/now/{NowMatch.js → NowMatch.ts} +22 -28
- package/src/now/{NowRange.js → NowRange.ts} +13 -22
- package/src/now/{NowWalker.js → NowWalker.ts} +65 -71
- package/src/tool/{scope.js → scope.ts} +41 -11
- package/src/utils/{Array.js → Array.ts} +187 -152
- package/src/utils/{Cookie.js → Cookie.ts} +15 -12
- package/src/utils/{Data.js → Data.ts} +17 -17
- package/src/utils/Dom.ts +204 -0
- package/src/utils/Format.ts +48 -0
- package/src/utils/{Hash.js → Hash.ts} +20 -20
- package/src/utils/{Locale.js → Locale.ts} +21 -21
- package/src/utils/{Mixed.js → Mixed.ts} +104 -61
- package/src/utils/{Now.js → Now.ts} +68 -69
- package/src/utils/{Number.js → Number.ts} +34 -36
- package/src/utils/{Object.js → Object.ts} +68 -122
- package/src/utils/{Route.js → Route.ts} +11 -9
- package/src/utils/{Runner.js → Runner.ts} +89 -77
- package/src/utils/{Signal.js → Signal.ts} +35 -22
- package/src/utils/{String.js → String.ts} +79 -69
- package/src/wip/{Element.js → Element.ts} +2 -2
- package/src/wip/{Map.js → Map.ts} +1 -1
- package/types/dom/DomAttribute.d.ts +16 -27
- package/types/dom/DomBuilder.d.ts +6 -9
- package/types/dom/DomEvent.d.ts +19 -24
- package/types/dom/DomFinder.d.ts +38 -61
- package/types/dom/DomForm.d.ts +7 -10
- package/types/dom/DomGlobal.d.ts +8 -15
- package/types/dom/DomInview.d.ts +9 -19
- package/types/dom/DomMeta.d.ts +9 -16
- package/types/dom/DomObserver.d.ts +4 -8
- package/types/dom/DomPopover.d.ts +8 -11
- package/types/dom/DomRectangle.d.ts +21 -35
- package/types/format/FormatFile.d.ts +5 -8
- package/types/format/FormatOption.d.ts +6 -8
- package/types/format/FormatParam.d.ts +6 -9
- package/types/format/FormatParser.d.ts +10 -18
- package/types/format/FormatUrl.d.ts +5 -8
- package/types/index.esm.d.ts +25 -37
- package/types/now/NowDefault.d.ts +30 -99
- package/types/now/NowFormat.d.ts +8 -21
- package/types/now/NowGrid.d.ts +24 -46
- package/types/now/NowHuman.d.ts +10 -11
- package/types/now/NowMatch.d.ts +6 -4
- package/types/now/NowRange.d.ts +5 -8
- package/types/now/NowWalker.d.ts +6 -4
- package/types/tool/scope.d.ts +11 -3
- package/types/utils/Array.d.ts +83 -101
- package/types/utils/Cookie.d.ts +11 -8
- package/types/utils/Data.d.ts +7 -7
- package/types/utils/Dom.d.ts +63 -96
- package/types/utils/Format.d.ts +15 -28
- package/types/utils/Hash.d.ts +21 -21
- package/types/utils/Locale.d.ts +9 -9
- package/types/utils/Mixed.d.ts +19 -32
- package/types/utils/Now.d.ts +51 -56
- package/types/utils/Number.d.ts +9 -20
- package/types/utils/Object.d.ts +21 -36
- package/types/utils/Route.d.ts +5 -2
- package/types/utils/Runner.d.ts +45 -38
- package/types/utils/Signal.d.ts +16 -16
- package/types/utils/String.d.ts +40 -76
- package/src/dom/DomForm.js +0 -59
- package/src/dom/DomMeta.js +0 -68
- package/src/dom/DomObserver.js +0 -38
- package/src/index.browser.js +0 -36
- package/src/index.esm.js +0 -80
- package/src/utils/Dom.js +0 -214
- package/src/utils/Format.js +0 -62
- package/types/wip/Element.d.ts +0 -119
- package/types/wip/Map.d.ts +0 -254
|
@@ -1,64 +1,65 @@
|
|
|
1
|
-
import { Mix
|
|
2
|
-
import { PicoFormat } from "../utils/Format.js";
|
|
1
|
+
import { Mix } from "../index.esm.ts";
|
|
3
2
|
|
|
4
|
-
export const TYPE_PARSERS = [
|
|
3
|
+
export const TYPE_PARSERS : any[] = [
|
|
5
4
|
{ // null
|
|
6
|
-
match: (val) => {
|
|
5
|
+
match: (val : any) => {
|
|
7
6
|
return /^(null|undefined)$/i.test(val);
|
|
8
7
|
},
|
|
9
|
-
parse: (val) => {
|
|
8
|
+
parse: (val : any) => {
|
|
10
9
|
return Mix.null(val);
|
|
11
10
|
}
|
|
12
11
|
},
|
|
13
12
|
{ // boolean
|
|
14
|
-
match: (val) => {
|
|
13
|
+
match: (val : any) => {
|
|
15
14
|
return /^(true|false|yes|no)$/i.test(val);
|
|
16
15
|
},
|
|
17
|
-
parse: (val) => {
|
|
16
|
+
parse: (val : any) => {
|
|
18
17
|
return Mix.bool(val);
|
|
19
18
|
}
|
|
20
19
|
},
|
|
21
20
|
{ // integer
|
|
22
|
-
match: (val) => {
|
|
21
|
+
match: (val : any) => {
|
|
23
22
|
return /^-?[0-9]+$/.test(val);
|
|
24
23
|
},
|
|
25
|
-
parse: (val) => {
|
|
24
|
+
parse: (val : any) => {
|
|
26
25
|
return Mix.int(val);
|
|
27
26
|
}
|
|
28
27
|
},
|
|
29
28
|
{ // number
|
|
30
|
-
match: (val) => {
|
|
29
|
+
match: (val : any) => {
|
|
31
30
|
return /^-?[0-9]+\.[0-9]+$/.test(val);
|
|
32
31
|
},
|
|
33
|
-
parse: (val) => {
|
|
32
|
+
parse: (val : any) => {
|
|
34
33
|
return Mix.num(val);
|
|
35
34
|
}
|
|
36
35
|
},
|
|
37
36
|
{ // array
|
|
38
|
-
match: (val) => {
|
|
37
|
+
match: (val : any) => {
|
|
39
38
|
return /^[{\[].*?[}\]]$/.test(val);
|
|
40
39
|
},
|
|
41
|
-
parse: (val) => {
|
|
40
|
+
parse: (val : any) => {
|
|
42
41
|
return JSON.parse(val);
|
|
43
42
|
}
|
|
44
43
|
},
|
|
45
44
|
];
|
|
46
45
|
|
|
47
|
-
export const TYPE_CASTERS = [
|
|
46
|
+
export const TYPE_CASTERS : any[] = [
|
|
48
47
|
{ // array
|
|
49
|
-
match: (val) => {
|
|
48
|
+
match: (val : any) => {
|
|
50
49
|
return Mix.isArr(val);
|
|
51
50
|
},
|
|
52
|
-
parse: (val) => {
|
|
51
|
+
parse: (val : any) => {
|
|
53
52
|
return JSON.stringify(val);
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
];
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
export interface PicoFormatParser
|
|
58
|
+
{
|
|
59
|
+
//
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class PicoFormatParser
|
|
62
63
|
{
|
|
63
64
|
|
|
64
65
|
/**
|
|
@@ -70,9 +71,9 @@ export class PicoFormatParserStatic
|
|
|
70
71
|
* @param {any} [fallback] Fallback value
|
|
71
72
|
* @returns {string} Keyed string
|
|
72
73
|
*/
|
|
73
|
-
static keyed(value, fallback = null)
|
|
74
|
+
static keyed(value : any, fallback : any = null) : string
|
|
74
75
|
{
|
|
75
|
-
if ( !
|
|
76
|
+
if ( !Mix.isStr(value) ) {
|
|
76
77
|
return fallback;
|
|
77
78
|
}
|
|
78
79
|
|
|
@@ -90,12 +91,12 @@ export class PicoFormatParserStatic
|
|
|
90
91
|
*
|
|
91
92
|
* @param {any} value Input value
|
|
92
93
|
* @param {any} [fallback] Fallback value
|
|
93
|
-
* @param {
|
|
94
|
+
* @param {any[]} [parsers] Custom parsers
|
|
94
95
|
* @returns {any} Parsed value
|
|
95
96
|
*/
|
|
96
|
-
static parsed(value, fallback = null, parsers = [])
|
|
97
|
+
static parsed(value : any, fallback : any = null, parsers : any[] = []) : any
|
|
97
98
|
{
|
|
98
|
-
if ( !
|
|
99
|
+
if ( !Mix.isStr(value) ) {
|
|
99
100
|
return fallback;
|
|
100
101
|
}
|
|
101
102
|
|
|
@@ -119,10 +120,10 @@ export class PicoFormatParserStatic
|
|
|
119
120
|
*
|
|
120
121
|
* @param {any} value Input value
|
|
121
122
|
* @param {boolean} [encode] Encode value
|
|
122
|
-
* @param {
|
|
123
|
+
* @param {any[]} [casters] Custom casters
|
|
123
124
|
* @returns {string} Casted string
|
|
124
125
|
*/
|
|
125
|
-
static casted(value, encode = false, casters = [])
|
|
126
|
+
static casted(value : any, encode : boolean = false, casters : any[] = []) : string
|
|
126
127
|
{
|
|
127
128
|
if ( encode ) {
|
|
128
129
|
value = encodeURI(value);
|
|
@@ -144,15 +145,4 @@ export class PicoFormatParserStatic
|
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
|
|
147
|
-
|
|
148
|
-
* @param {typeof PicoFormat} self
|
|
149
|
-
* @returns {typeof PicoFormat}
|
|
150
|
-
*/
|
|
151
|
-
export const PicoFormatParserPlugin = function (self) {
|
|
152
|
-
|
|
153
|
-
Obj.each(Mix.class(PicoFormatParserStatic), (fn, id) => {
|
|
154
|
-
self[id] = fn;
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
return self;
|
|
158
|
-
}
|
|
148
|
+
export default PicoFormatParser;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Arr
|
|
2
|
-
import { PicoFormat } from "../utils/Format.js";
|
|
1
|
+
import { Arr } from "../index.esm.ts";
|
|
3
2
|
|
|
4
|
-
export const SLUG_CONVERT = [
|
|
3
|
+
export const SLUG_CONVERT : any[] = [
|
|
5
4
|
['à', 'a'],
|
|
6
5
|
['á', 'a'],
|
|
7
6
|
['â', 'a'],
|
|
@@ -33,13 +32,13 @@ export const SLUG_CONVERT = [
|
|
|
33
32
|
['ß', 'ss'],
|
|
34
33
|
];
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
* @memberof PicoFormat
|
|
38
|
-
* @extends {PicoFormat}
|
|
39
|
-
*/
|
|
40
|
-
export class PicoFormatUrlStatic
|
|
35
|
+
export interface PicoFormatUrl
|
|
41
36
|
{
|
|
37
|
+
//
|
|
38
|
+
}
|
|
42
39
|
|
|
40
|
+
export class PicoFormatUrl
|
|
41
|
+
{
|
|
43
42
|
/**
|
|
44
43
|
* Create slug from string
|
|
45
44
|
*
|
|
@@ -48,7 +47,7 @@ export class PicoFormatUrlStatic
|
|
|
48
47
|
* @param {any} value Input string
|
|
49
48
|
* @returns {string} Slug string
|
|
50
49
|
*/
|
|
51
|
-
static slugify(value)
|
|
50
|
+
static slugify(value : any) : string
|
|
52
51
|
{
|
|
53
52
|
value = String(value).replace(/(^\s+|\s+$)/g, '')
|
|
54
53
|
.toLowerCase();
|
|
@@ -63,15 +62,4 @@ export class PicoFormatUrlStatic
|
|
|
63
62
|
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
* @param {typeof PicoFormat} self
|
|
68
|
-
* @returns {typeof PicoFormat}
|
|
69
|
-
*/
|
|
70
|
-
export const PicoFormatUrlPlugin = function (self) {
|
|
71
|
-
|
|
72
|
-
Obj.each(Mix.class(PicoFormatUrlStatic), (fn, id) => {
|
|
73
|
-
self[id] = fn;
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return self;
|
|
77
|
-
}
|
|
65
|
+
export default PicoFormatUrl;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as pi from "./index.esm.ts";
|
|
2
|
+
|
|
3
|
+
type Pico = {
|
|
4
|
+
// Active
|
|
5
|
+
Dom: typeof pi.Dom,
|
|
6
|
+
Now: typeof pi.Now,
|
|
7
|
+
For: typeof pi.For,
|
|
8
|
+
Run: typeof pi.Run,
|
|
9
|
+
Str: typeof pi.Str,
|
|
10
|
+
Num: typeof pi.Num,
|
|
11
|
+
Arr: typeof pi.Arr,
|
|
12
|
+
Obj: typeof pi.Obj,
|
|
13
|
+
Mix: typeof pi.Mix,
|
|
14
|
+
Hash: typeof pi.Hash,
|
|
15
|
+
Signal: typeof pi.Signal,
|
|
16
|
+
Locale: typeof pi.Locale,
|
|
17
|
+
Cookie: typeof pi.Cookie,
|
|
18
|
+
// Legacy
|
|
19
|
+
Route: typeof pi.Route,
|
|
20
|
+
Data: typeof pi.Data,
|
|
21
|
+
// Polyfill
|
|
22
|
+
Any: typeof pi.Any,
|
|
23
|
+
Event: typeof pi.Event,
|
|
24
|
+
UUID: typeof pi.UUID,
|
|
25
|
+
}
|
|
26
|
+
globalThis.pi = pi;
|
|
27
|
+
|
|
28
|
+
globalThis.addEventListener && globalThis.addEventListener('beforeunload', () => {
|
|
29
|
+
pi.Arr.map(pi.Dom.$events, ({ el, cb, event }) => {
|
|
30
|
+
return (el.removeEventListener(event, cb), null);
|
|
31
|
+
});
|
|
32
|
+
});
|
package/src/index.esm.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { default as Run } from "./utils/Runner.ts";
|
|
2
|
+
import { default as Str } from "./utils/String.ts";
|
|
3
|
+
import { default as Num } from "./utils/Number.ts";
|
|
4
|
+
import { default as Arr } from "./utils/Array.ts";
|
|
5
|
+
import { default as Obj } from "./utils/Object.ts";
|
|
6
|
+
import { default as Mix } from "./utils/Mixed.ts";
|
|
7
|
+
import { default as Hash } from "./utils/Hash.ts";
|
|
8
|
+
import { default as Signal } from "./utils/Signal.ts";
|
|
9
|
+
import { default as Locale } from "./utils/Locale.ts";
|
|
10
|
+
import { default as Cookie } from "./utils/Cookie.ts";
|
|
11
|
+
import { default as Now } from "./utils/Now.ts";
|
|
12
|
+
import { default as Dom } from "./utils/Dom.ts";
|
|
13
|
+
import { default as For } from "./utils/Format.ts";
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
Dom, Now, For, Run, Str, Num, Arr, Obj, Mix, Hash, Signal, Locale, Cookie
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
import { go, browser, device, trait } from "./tool/scope.ts";
|
|
20
|
+
export { go, browser, device, trait };
|
|
21
|
+
|
|
22
|
+
// You will be removed soon
|
|
23
|
+
import { default as Data } from "./utils/Data.ts";
|
|
24
|
+
import { default as Route } from "./utils/Route.ts";
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
Route, Data
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Work in progress (not started yet)
|
|
31
|
+
// import { default as Map } from "./wip/Map.ts";
|
|
32
|
+
// import { default as Element } from "./wip/Element.ts";
|
|
33
|
+
|
|
34
|
+
// export {
|
|
35
|
+
// Map, Element
|
|
36
|
+
// }
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @type {Mix}
|
|
40
|
+
*/
|
|
41
|
+
export const Any : Mix = new Proxy({}, {
|
|
42
|
+
get: function (target : any, prop : string) {
|
|
43
|
+
console.warn(`Any.${prop} is deprecated, use Mix.${prop}() instead.`);
|
|
44
|
+
return (...args : any[]) => Mix[prop](...args);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @type {Signal}
|
|
50
|
+
*/
|
|
51
|
+
export const Event : Signal = new Proxy({}, {
|
|
52
|
+
get: function (target : any, prop : string) {
|
|
53
|
+
console.warn(`Event.${prop} is deprecated, use Signal.${prop}() instead.`);
|
|
54
|
+
return (...args : any[]) => Signal[prop](...args);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*/
|
|
61
|
+
export const UUID = function () : string {
|
|
62
|
+
console.warn('UUID() is deprecated, use Hash.make() instead.');
|
|
63
|
+
return Hash.make();
|
|
64
|
+
};
|