@kizmann/pico-js 2.0.8 → 2.0.10
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} +74 -78
- package/src/dom/{DomFinder.js → DomFinder.ts} +89 -129
- 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} +67 -88
- 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} +146 -160
- 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} +22 -22
- package/src/utils/{Mixed.js → Mixed.ts} +70 -58
- 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} +65 -47
- 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} +131 -101
- package/types/dom/DomAttribute.d.ts +16 -27
- package/types/dom/DomBuilder.d.ts +6 -9
- package/types/dom/DomEvent.d.ts +19 -25
- package/types/dom/DomFinder.d.ts +35 -58
- 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 -40
- 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 -104
- 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 +10 -10
- package/types/utils/Mixed.d.ts +18 -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 +41 -24
- 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,10 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PicoDom } from "../utils/Dom.
|
|
1
|
+
import { Dom, Mix, Obj } from "../index.esm.ts";
|
|
2
|
+
import { PicoDom, PicoDomInterface } from "../utils/Dom.ts";
|
|
3
|
+
import PicoDomFinder from "./DomFinder.js";
|
|
4
|
+
import PicoDomAttribute from "./DomAttribute.js";
|
|
5
|
+
|
|
6
|
+
export interface PicoDomRectangle extends PicoDomInterface,
|
|
7
|
+
PicoDomFinder,
|
|
8
|
+
PicoDomAttribute
|
|
9
|
+
{
|
|
10
|
+
//
|
|
11
|
+
}
|
|
3
12
|
|
|
4
13
|
/**
|
|
5
14
|
* @memberof PicoDom
|
|
6
15
|
*/
|
|
7
|
-
export class
|
|
16
|
+
export class PicoDomRectangle
|
|
8
17
|
{
|
|
9
18
|
/**
|
|
10
19
|
* Cast value to number
|
|
@@ -14,7 +23,7 @@ export class PicoDomRectangleStatic
|
|
|
14
23
|
* @param {any} value Input value
|
|
15
24
|
* @returns {number} Number value
|
|
16
25
|
*/
|
|
17
|
-
static num(value)
|
|
26
|
+
static num(value : any) : number
|
|
18
27
|
{
|
|
19
28
|
if ( typeof value === 'string' ) {
|
|
20
29
|
value = value.replace(/(^\s+|\s$|px)/g, '');
|
|
@@ -22,17 +31,10 @@ export class PicoDomRectangleStatic
|
|
|
22
31
|
|
|
23
32
|
return Mix.num(value, 0);
|
|
24
33
|
}
|
|
25
|
-
}
|
|
26
34
|
|
|
27
|
-
|
|
28
|
-
* @memberof PicoDom
|
|
29
|
-
* @extends {PicoDom}
|
|
30
|
-
*/
|
|
31
|
-
export class PicoDomRectangleInstance
|
|
32
|
-
{
|
|
33
|
-
rect(fallback = { left: 0, top: 0, width: 0, height: 0 })
|
|
35
|
+
rect(fallback : any = { left: 0, top: 0, width: 0, height: 0 })
|
|
34
36
|
{
|
|
35
|
-
if ( !
|
|
37
|
+
if ( !this.el.getBoundingClientRect ) {
|
|
36
38
|
return fallback;
|
|
37
39
|
}
|
|
38
40
|
|
|
@@ -41,7 +43,7 @@ export class PicoDomRectangleInstance
|
|
|
41
43
|
if ( rect == null ) {
|
|
42
44
|
return fallback;
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
|
|
45
47
|
return rect.toJSON();
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -54,7 +56,7 @@ export class PicoDomRectangleInstance
|
|
|
54
56
|
* @param {number} [fallback] Fallback value
|
|
55
57
|
* @returns {any} Margin values
|
|
56
58
|
*/
|
|
57
|
-
margin(key = null, fallback = 0)
|
|
59
|
+
margin(key : string = null, fallback : number = 0) : any
|
|
58
60
|
{
|
|
59
61
|
let computed = this.computed();
|
|
60
62
|
|
|
@@ -81,7 +83,7 @@ export class PicoDomRectangleInstance
|
|
|
81
83
|
* @param {number} [fallback] Fallback value
|
|
82
84
|
* @returns {any} Padding values
|
|
83
85
|
*/
|
|
84
|
-
padding(key = null, fallback = 0)
|
|
86
|
+
padding(key : string = null, fallback : number = 0) : any
|
|
85
87
|
{
|
|
86
88
|
let computed = this.computed();
|
|
87
89
|
|
|
@@ -106,7 +108,7 @@ export class PicoDomRectangleInstance
|
|
|
106
108
|
*
|
|
107
109
|
* @returns {number} Height value
|
|
108
110
|
*/
|
|
109
|
-
height()
|
|
111
|
+
height() : number
|
|
110
112
|
{
|
|
111
113
|
if ( this.el == null ) {
|
|
112
114
|
return 0;
|
|
@@ -126,7 +128,7 @@ export class PicoDomRectangleInstance
|
|
|
126
128
|
*
|
|
127
129
|
* @returns {number} Height value
|
|
128
130
|
*/
|
|
129
|
-
clientHeight()
|
|
131
|
+
clientHeight() : number
|
|
130
132
|
{
|
|
131
133
|
if ( this.el == null ) {
|
|
132
134
|
return 0;
|
|
@@ -142,7 +144,7 @@ export class PicoDomRectangleInstance
|
|
|
142
144
|
*
|
|
143
145
|
* @returns {number} Height value
|
|
144
146
|
*/
|
|
145
|
-
scrollHeight()
|
|
147
|
+
scrollHeight() : number
|
|
146
148
|
{
|
|
147
149
|
if ( this.el == null ) {
|
|
148
150
|
return 0;
|
|
@@ -158,7 +160,7 @@ export class PicoDomRectangleInstance
|
|
|
158
160
|
*
|
|
159
161
|
* @returns {number} Height value
|
|
160
162
|
*/
|
|
161
|
-
innerHeight()
|
|
163
|
+
innerHeight() : number
|
|
162
164
|
{
|
|
163
165
|
if ( this.el == null ) {
|
|
164
166
|
return 0;
|
|
@@ -179,11 +181,11 @@ export class PicoDomRectangleInstance
|
|
|
179
181
|
* @example Dom.find("div").realHeight({ display: "block" })
|
|
180
182
|
*
|
|
181
183
|
* @param {any} [style] Temp style
|
|
182
|
-
* @returns {
|
|
184
|
+
* @returns {any} Height value
|
|
183
185
|
*/
|
|
184
|
-
realHeight(style = {})
|
|
186
|
+
realHeight(style : any = {}) : any
|
|
185
187
|
{
|
|
186
|
-
let height = 'auto';
|
|
188
|
+
let height : number | string = 'auto';
|
|
187
189
|
|
|
188
190
|
this.actual(() => {
|
|
189
191
|
return height = this.height();
|
|
@@ -199,9 +201,9 @@ export class PicoDomRectangleInstance
|
|
|
199
201
|
*
|
|
200
202
|
* @param {any} [target] Target element
|
|
201
203
|
* @param {boolean} [apply] Apply style
|
|
202
|
-
* @returns {
|
|
204
|
+
* @returns {any} Height value
|
|
203
205
|
*/
|
|
204
|
-
evaluateHeight(target = null, apply = true)
|
|
206
|
+
evaluateHeight(target : any = null, apply : boolean = true) : any
|
|
205
207
|
{
|
|
206
208
|
target = Dom.find(target);
|
|
207
209
|
|
|
@@ -209,7 +211,7 @@ export class PicoDomRectangleInstance
|
|
|
209
211
|
target = this.parent();
|
|
210
212
|
}
|
|
211
213
|
|
|
212
|
-
let height = 'auto';
|
|
214
|
+
let height : number | string = 'auto';
|
|
213
215
|
|
|
214
216
|
this.actual(() => {
|
|
215
217
|
height = target.innerHeight();
|
|
@@ -229,7 +231,7 @@ export class PicoDomRectangleInstance
|
|
|
229
231
|
*
|
|
230
232
|
* @returns {number} Width value
|
|
231
233
|
*/
|
|
232
|
-
width()
|
|
234
|
+
width() : number
|
|
233
235
|
{
|
|
234
236
|
if ( this.el == null ) {
|
|
235
237
|
return 0;
|
|
@@ -249,7 +251,7 @@ export class PicoDomRectangleInstance
|
|
|
249
251
|
*
|
|
250
252
|
* @returns {number} Width value
|
|
251
253
|
*/
|
|
252
|
-
clientWidth()
|
|
254
|
+
clientWidth() : number
|
|
253
255
|
{
|
|
254
256
|
if ( this.el == null ) {
|
|
255
257
|
return 0;
|
|
@@ -265,7 +267,7 @@ export class PicoDomRectangleInstance
|
|
|
265
267
|
*
|
|
266
268
|
* @returns {number} Width value
|
|
267
269
|
*/
|
|
268
|
-
scrollWidth()
|
|
270
|
+
scrollWidth() : number
|
|
269
271
|
{
|
|
270
272
|
if ( this.el == null ) {
|
|
271
273
|
return 0;
|
|
@@ -281,7 +283,7 @@ export class PicoDomRectangleInstance
|
|
|
281
283
|
*
|
|
282
284
|
* @returns {number} Width value
|
|
283
285
|
*/
|
|
284
|
-
innerWidth()
|
|
286
|
+
innerWidth() : number
|
|
285
287
|
{
|
|
286
288
|
if ( this.el == null ) {
|
|
287
289
|
return 0;
|
|
@@ -302,11 +304,11 @@ export class PicoDomRectangleInstance
|
|
|
302
304
|
* @example Dom.find("div").realWidth({ display: "block" })
|
|
303
305
|
*
|
|
304
306
|
* @param {any} [style] Temp style
|
|
305
|
-
* @returns {
|
|
307
|
+
* @returns {any} Width value
|
|
306
308
|
*/
|
|
307
|
-
realWidth(style = {})
|
|
309
|
+
realWidth(style = {}) : any
|
|
308
310
|
{
|
|
309
|
-
let width = 'auto';
|
|
311
|
+
let width : number | string = 'auto';
|
|
310
312
|
|
|
311
313
|
this.actual(() => {
|
|
312
314
|
return width = this.width();
|
|
@@ -322,9 +324,9 @@ export class PicoDomRectangleInstance
|
|
|
322
324
|
*
|
|
323
325
|
* @param {any} [target] Target element
|
|
324
326
|
* @param {boolean} [apply] Apply style
|
|
325
|
-
* @returns {
|
|
327
|
+
* @returns {any} Width value
|
|
326
328
|
*/
|
|
327
|
-
evaluateWidth(target = null, apply = true)
|
|
329
|
+
evaluateWidth(target : any = null, apply : boolean = true) : any
|
|
328
330
|
{
|
|
329
331
|
target = Dom.find(target);
|
|
330
332
|
|
|
@@ -332,7 +334,7 @@ export class PicoDomRectangleInstance
|
|
|
332
334
|
target = this.parent();
|
|
333
335
|
}
|
|
334
336
|
|
|
335
|
-
let width = 'auto';
|
|
337
|
+
let width : number | string = 'auto';
|
|
336
338
|
|
|
337
339
|
this.actual(() => {
|
|
338
340
|
width = target.innerWidth();
|
|
@@ -354,7 +356,7 @@ export class PicoDomRectangleInstance
|
|
|
354
356
|
* @param {any} [boundry] View boundry
|
|
355
357
|
* @returns {any} Offset values
|
|
356
358
|
*/
|
|
357
|
-
offset(key = null, boundry = null)
|
|
359
|
+
offset(key : string = null, boundry : any = null) : any
|
|
358
360
|
{
|
|
359
361
|
let offset = this.getOffset(boundry);
|
|
360
362
|
|
|
@@ -373,7 +375,7 @@ export class PicoDomRectangleInstance
|
|
|
373
375
|
* @param {any} [boundry] View boundry
|
|
374
376
|
* @returns {number} Top offset
|
|
375
377
|
*/
|
|
376
|
-
offsetTop(boundry = null)
|
|
378
|
+
offsetTop(boundry : any = null) : number
|
|
377
379
|
{
|
|
378
380
|
return this.offset('top', boundry);
|
|
379
381
|
}
|
|
@@ -386,7 +388,7 @@ export class PicoDomRectangleInstance
|
|
|
386
388
|
* @param {any} [boundry] View boundry
|
|
387
389
|
* @returns {number} Bottom offset
|
|
388
390
|
*/
|
|
389
|
-
offsetBottom(boundry = null)
|
|
391
|
+
offsetBottom(boundry : any = null) : number
|
|
390
392
|
{
|
|
391
393
|
return this.offset('bottom', boundry);
|
|
392
394
|
}
|
|
@@ -399,7 +401,7 @@ export class PicoDomRectangleInstance
|
|
|
399
401
|
* @param {any} [boundry] View boundry
|
|
400
402
|
* @returns {number} Left offset
|
|
401
403
|
*/
|
|
402
|
-
offsetLeft(boundry = null)
|
|
404
|
+
offsetLeft(boundry : any = null) : number
|
|
403
405
|
{
|
|
404
406
|
return this.offset('left', boundry);
|
|
405
407
|
}
|
|
@@ -412,7 +414,7 @@ export class PicoDomRectangleInstance
|
|
|
412
414
|
* @param {any} [boundry] View boundry
|
|
413
415
|
* @returns {number} Right offset
|
|
414
416
|
*/
|
|
415
|
-
offsetRight(boundry = null)
|
|
417
|
+
offsetRight(boundry : any = null) : number
|
|
416
418
|
{
|
|
417
419
|
return this.offset('right', boundry);
|
|
418
420
|
}
|
|
@@ -422,11 +424,11 @@ export class PicoDomRectangleInstance
|
|
|
422
424
|
*
|
|
423
425
|
* @example Dom.find("div").loopOffset((el) => console.log(el))
|
|
424
426
|
*
|
|
425
|
-
* @param {
|
|
427
|
+
* @param {Function} cb Callback fn
|
|
426
428
|
* @param {any} [boundry] Loop limit
|
|
427
429
|
* @returns {PicoDom} Current instance
|
|
428
430
|
*/
|
|
429
|
-
loopOffset(cb, boundry = null)
|
|
431
|
+
loopOffset(cb : Function, boundry : any = null) : PicoDom
|
|
430
432
|
{
|
|
431
433
|
if ( boundry == null ) {
|
|
432
434
|
boundry = Dom.body();
|
|
@@ -436,7 +438,7 @@ export class PicoDomRectangleInstance
|
|
|
436
438
|
cb.call({}, el);
|
|
437
439
|
}
|
|
438
440
|
|
|
439
|
-
return this;
|
|
441
|
+
return <PicoDom> <unknown> this;
|
|
440
442
|
}
|
|
441
443
|
|
|
442
444
|
/**
|
|
@@ -449,7 +451,7 @@ export class PicoDomRectangleInstance
|
|
|
449
451
|
* @param {number} height Element height
|
|
450
452
|
* @returns {any} Calculated offset
|
|
451
453
|
*/
|
|
452
|
-
calcOffset(offset, width, height)
|
|
454
|
+
calcOffset(offset : any, width : number, height : number) : any
|
|
453
455
|
{
|
|
454
456
|
let size = {
|
|
455
457
|
right: Dom.body().scrollWidth - offset.left - width,
|
|
@@ -467,7 +469,7 @@ export class PicoDomRectangleInstance
|
|
|
467
469
|
* @param {any} [boundry] View boundry
|
|
468
470
|
* @returns {any} Offset values
|
|
469
471
|
*/
|
|
470
|
-
getOffset(boundry = null)
|
|
472
|
+
getOffset(boundry : any = null) : any
|
|
471
473
|
{
|
|
472
474
|
if ( boundry == null ) {
|
|
473
475
|
boundry = Dom.body();
|
|
@@ -481,7 +483,7 @@ export class PicoDomRectangleInstance
|
|
|
481
483
|
return source;
|
|
482
484
|
}
|
|
483
485
|
|
|
484
|
-
cb = (el) => {
|
|
486
|
+
cb = (el : any) => {
|
|
485
487
|
source.top += Dom.num(el.offsetTop, 0);
|
|
486
488
|
source.left += Dom.num(el.offsetLeft, 0);
|
|
487
489
|
};
|
|
@@ -498,7 +500,7 @@ export class PicoDomRectangleInstance
|
|
|
498
500
|
top: 0, left: 0, bottom: 0, right: 0
|
|
499
501
|
};
|
|
500
502
|
|
|
501
|
-
cb = (el) => {
|
|
503
|
+
cb = (el : any) => {
|
|
502
504
|
target.top += Dom.num(el.offsetTop, 0);
|
|
503
505
|
target.left += Dom.num(el.offsetLeft, 0);
|
|
504
506
|
};
|
|
@@ -526,7 +528,7 @@ export class PicoDomRectangleInstance
|
|
|
526
528
|
* @param {any} [boundry] View boundry
|
|
527
529
|
* @returns {any} Scroll values
|
|
528
530
|
*/
|
|
529
|
-
scroll(key = null, boundry = null)
|
|
531
|
+
scroll(key : any = null, boundry : any = null) : any
|
|
530
532
|
{
|
|
531
533
|
let scroll = this.getScroll(boundry);
|
|
532
534
|
|
|
@@ -544,15 +546,15 @@ export class PicoDomRectangleInstance
|
|
|
544
546
|
*
|
|
545
547
|
* @param {any} [value] Scroll value
|
|
546
548
|
* @param {any} [boundry] View boundry
|
|
547
|
-
* @returns {
|
|
549
|
+
* @returns {any} Value or instance
|
|
548
550
|
*/
|
|
549
|
-
scrollTop(value = null, boundry = null)
|
|
551
|
+
scrollTop(value : any = null, boundry : any = null) : any
|
|
550
552
|
{
|
|
551
553
|
if ( value == null ) {
|
|
552
554
|
return this.scroll('top', boundry);
|
|
553
555
|
}
|
|
554
556
|
|
|
555
|
-
this.each((el) => {
|
|
557
|
+
this.each((el : any) => {
|
|
556
558
|
el.scrollTop = value;
|
|
557
559
|
});
|
|
558
560
|
|
|
@@ -566,15 +568,15 @@ export class PicoDomRectangleInstance
|
|
|
566
568
|
*
|
|
567
569
|
* @param {any} [value] Scroll value
|
|
568
570
|
* @param {any} [boundry] View boundry
|
|
569
|
-
* @returns {
|
|
571
|
+
* @returns {any} Value or instance
|
|
570
572
|
*/
|
|
571
|
-
scrollLeft(value = null, boundry = null)
|
|
573
|
+
scrollLeft(value : any = null, boundry : any = null) : any
|
|
572
574
|
{
|
|
573
575
|
if ( value == null ) {
|
|
574
576
|
return this.scroll('left', boundry);
|
|
575
577
|
}
|
|
576
578
|
|
|
577
|
-
this.each((el) => {
|
|
579
|
+
this.each((el : any) => {
|
|
578
580
|
el.scrollLeft = value;
|
|
579
581
|
});
|
|
580
582
|
|
|
@@ -589,7 +591,7 @@ export class PicoDomRectangleInstance
|
|
|
589
591
|
* @param {any} [boundry] View boundry
|
|
590
592
|
* @returns {any} Scroll values
|
|
591
593
|
*/
|
|
592
|
-
getScroll(boundry = null)
|
|
594
|
+
getScroll(boundry : any = null) : any
|
|
593
595
|
{
|
|
594
596
|
if ( boundry == null ) {
|
|
595
597
|
boundry = Dom.win();
|
|
@@ -603,7 +605,7 @@ export class PicoDomRectangleInstance
|
|
|
603
605
|
return source;
|
|
604
606
|
}
|
|
605
607
|
|
|
606
|
-
cb = (el) => {
|
|
608
|
+
cb = (el : any) => {
|
|
607
609
|
source.top += Dom.num(el.scrollTop || el.pageYOffset || 0);
|
|
608
610
|
source.left += Dom.num(el.scrollLeft || el.pageXOffset || 0);
|
|
609
611
|
}
|
|
@@ -614,7 +616,7 @@ export class PicoDomRectangleInstance
|
|
|
614
616
|
top: 0, left: 0
|
|
615
617
|
};
|
|
616
618
|
|
|
617
|
-
cb = (el) => {
|
|
619
|
+
cb = (el : any) => {
|
|
618
620
|
target.top += Dom.num(el.scrollTop || el.pageYOffset || 0);
|
|
619
621
|
target.left += Dom.num(el.scrollLeft || el.pageXOffset || 0);
|
|
620
622
|
};
|
|
@@ -629,45 +631,22 @@ export class PicoDomRectangleInstance
|
|
|
629
631
|
|
|
630
632
|
}
|
|
631
633
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
*/
|
|
635
|
-
PicoDomRectangleInstance.prototype.loopOffsetParent = function (...args) {
|
|
634
|
+
// @ts-ignore
|
|
635
|
+
PicoDomRectangle.prototype.loopOffsetParent = function (...args : Parameters<typeof PicoDomRectangle.prototype.loopOffset>) {
|
|
636
636
|
console.warn('Dom.loopOffsetParent() is deprecated, use Dom.loopOffset() instead.');
|
|
637
637
|
return this.loopOffset(...args);
|
|
638
638
|
};
|
|
639
639
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
*/
|
|
643
|
-
PicoDomRectangleInstance.prototype.scrollTopGlobal = function () {
|
|
640
|
+
// @ts-ignore
|
|
641
|
+
PicoDomRectangle.prototype.scrollTopGlobal = function () {
|
|
644
642
|
console.warn('Dom.scrollTopGlobal() is deprecated, use Dom.scroll(\'top\') instead.');
|
|
645
643
|
return this.scroll('top', null);
|
|
646
644
|
};
|
|
647
645
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
*/
|
|
651
|
-
PicoDomRectangleInstance.prototype.scrollLeftGlobal = function () {
|
|
646
|
+
// @ts-ignore
|
|
647
|
+
PicoDomRectangle.prototype.scrollLeftGlobal = function () {
|
|
652
648
|
console.warn('Dom.scrollLeftGlobal() is deprecated, use Dom.scroll(\'left\') instead.');
|
|
653
649
|
return this.scroll('left', null);
|
|
654
650
|
};
|
|
655
651
|
|
|
656
|
-
|
|
657
|
-
* @param {typeof PicoDom} self
|
|
658
|
-
* @returns {typeof PicoDom}
|
|
659
|
-
*/
|
|
660
|
-
export const PicoDomRectanglePlugin = function (self) {
|
|
661
|
-
|
|
662
|
-
Obj.each(Mix.class(PicoDomRectangleStatic), (fn, id) => {
|
|
663
|
-
self[id] = fn;
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
Obj.each(Mix.proto(PicoDomRectangleInstance), (fn, id) => {
|
|
667
|
-
self.prototype[id] = fn;
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
// self.init.push(PicoDomRectangleInstance.constructor);
|
|
671
|
-
|
|
672
|
-
return self;
|
|
673
|
-
}
|
|
652
|
+
export default PicoDomRectangle;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Mix, Obj, Num } from "../index.esm.
|
|
2
|
-
import { PicoFormat } from "../utils/Format.
|
|
1
|
+
import { Mix, Obj, Num } from "../index.esm.ts";
|
|
2
|
+
import { PicoFormat } from "../utils/Format.ts";
|
|
3
3
|
|
|
4
4
|
export const FILE_UNITS = [
|
|
5
5
|
'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'
|
|
6
6
|
];
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* @memberof PicoFormat
|
|
10
|
-
* @extends {PicoFormat}
|
|
11
|
-
*/
|
|
12
|
-
export class PicoFormatFileStatic
|
|
8
|
+
export interface PicoFormatFile
|
|
13
9
|
{
|
|
10
|
+
//
|
|
11
|
+
}
|
|
14
12
|
|
|
13
|
+
export class PicoFormatFile
|
|
14
|
+
{
|
|
15
15
|
/**
|
|
16
16
|
* Format file size
|
|
17
17
|
*
|
|
@@ -21,18 +21,18 @@ export class PicoFormatFileStatic
|
|
|
21
21
|
* @param {number} [decimals] Decimal points
|
|
22
22
|
* @returns {string} Formatted size
|
|
23
23
|
*/
|
|
24
|
-
static filesize(value, decimals = 1)
|
|
24
|
+
static filesize(value : any, decimals : number = 1) : string
|
|
25
25
|
{
|
|
26
|
-
if ( !
|
|
26
|
+
if ( !Mix.isNum(value) ) {
|
|
27
27
|
value = Mix.num(value, 0);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
let fn = (i) => {
|
|
30
|
+
let fn = (i : any) => {
|
|
31
31
|
return Num.fixed(value / Math.pow(1000, i), decimals);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
for ( let i = 0; i < FILE_UNITS.length; i++ ) {
|
|
35
|
-
if ( value <= Math.pow(1000, i+1) ) {
|
|
35
|
+
if ( value <= Math.pow(1000, i + 1) ) {
|
|
36
36
|
return fn(i) + ' ' + FILE_UNITS[i]
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -42,15 +42,4 @@ export class PicoFormatFileStatic
|
|
|
42
42
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
* @param {typeof PicoFormat} self
|
|
47
|
-
* @returns {typeof PicoFormat}
|
|
48
|
-
*/
|
|
49
|
-
export const PicoFormatFilePlugin = function (self) {
|
|
50
|
-
|
|
51
|
-
Obj.each(Mix.class(PicoFormatFileStatic), (fn, id) => {
|
|
52
|
-
self[id] = fn;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
return self;
|
|
56
|
-
}
|
|
45
|
+
export default PicoFormatFile;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { Arr, For, Mix, Obj } from "../index.esm.
|
|
2
|
-
import { PicoFormat } from "../utils/Format.
|
|
1
|
+
import { Arr, For, Mix, Obj } from "../index.esm.ts";
|
|
2
|
+
import { PicoFormat } from "../utils/Format.ts";
|
|
3
3
|
|
|
4
4
|
export const OPTION_REGEX = {
|
|
5
5
|
entry: /(^|;)(\s*(?<key>.*?)\s*:\s*(?<val>".*?"|'.*?'|.*?)\s*)(?=;|$)/g
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export interface PicoFormatOption
|
|
9
|
+
{
|
|
10
|
+
//
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class PicoFormatOption
|
|
12
14
|
{
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -20,13 +22,13 @@ export class PicoFormatOptionStatic
|
|
|
20
22
|
* @param {boolean} [space] Add space
|
|
21
23
|
* @returns {string} Options string
|
|
22
24
|
*/
|
|
23
|
-
static castOptions(options = {}, space = true)
|
|
25
|
+
static castOptions(options : any = {}, space : boolean = true) : string
|
|
24
26
|
{
|
|
25
27
|
if ( Mix.isEmpty(options) ) {
|
|
26
28
|
return '';
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
let result = Arr.each(options, (val, key) => {
|
|
31
|
+
let result = Arr.each(options, (val : any, key : any) => {
|
|
30
32
|
return this.castOption(key, val, null, space);
|
|
31
33
|
});
|
|
32
34
|
|
|
@@ -44,7 +46,7 @@ export class PicoFormatOptionStatic
|
|
|
44
46
|
* @param {boolean} [space] Add space
|
|
45
47
|
* @returns {string} Option string
|
|
46
48
|
*/
|
|
47
|
-
static castOption(key, value, path = null, space = true)
|
|
49
|
+
static castOption(key : string, value : any, path : string = null, space : boolean = true) : string
|
|
48
50
|
{
|
|
49
51
|
if ( path != null ) {
|
|
50
52
|
key = path + '.' + key;
|
|
@@ -56,7 +58,7 @@ export class PicoFormatOptionStatic
|
|
|
56
58
|
return Mix.str(key) + div + For.casted(value, false);
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
let result = Arr.map(value, (v, k) => {
|
|
61
|
+
let result = Arr.map(value, (v : any, k : any) => {
|
|
60
62
|
return this.castOption(k, v, key, space);
|
|
61
63
|
});
|
|
62
64
|
|
|
@@ -71,7 +73,7 @@ export class PicoFormatOptionStatic
|
|
|
71
73
|
* @param {string} value Options string
|
|
72
74
|
* @returns {any} Options object
|
|
73
75
|
*/
|
|
74
|
-
static parseOptions(value)
|
|
76
|
+
static parseOptions(value : string) : any
|
|
75
77
|
{
|
|
76
78
|
if ( Mix.isEmpty(value) ) {
|
|
77
79
|
return {};
|
|
@@ -89,22 +91,11 @@ export class PicoFormatOptionStatic
|
|
|
89
91
|
For.keyed, For.parsed
|
|
90
92
|
];
|
|
91
93
|
|
|
92
|
-
return Arr.reduce(Array.from(matches), (result, { groups }) => {
|
|
94
|
+
return Arr.reduce(Array.from(matches), (result : any, { groups }) => {
|
|
93
95
|
return Obj.set(result, key(groups.key), val(groups.val));
|
|
94
96
|
}, {});
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
|
|
100
|
-
* @param {typeof PicoFormat} self
|
|
101
|
-
* @returns {typeof PicoFormat}
|
|
102
|
-
*/
|
|
103
|
-
export const PicoFormatOptionPlugin = function (self) {
|
|
104
|
-
|
|
105
|
-
Obj.each(Mix.class(PicoFormatOptionStatic), (fn, id) => {
|
|
106
|
-
self[id] = fn;
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
return self;
|
|
110
|
-
}
|
|
101
|
+
export default PicoFormatOption;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Arr, Mix, Obj, For } from "../index.esm.
|
|
2
|
-
import { PicoFormat } from "../utils/Format.
|
|
1
|
+
import { Arr, Mix, Obj, For } from "../index.esm.ts";
|
|
2
|
+
import { PicoFormat } from "../utils/Format.ts";
|
|
3
3
|
|
|
4
4
|
export const PARAM_REGEX = {
|
|
5
5
|
entry: /(?<=^|&|\?)(\s*(?<key>.*?)\s*=\s*(?<val>".*?"|'.*?'|.*?)\s*)(?=&|$)/g
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* @memberof PicoFormat
|
|
10
|
-
* @extends {PicoFormat}
|
|
11
|
-
*/
|
|
12
|
-
export class PicoFormatParamStatic
|
|
8
|
+
export interface PicoFormatParam
|
|
13
9
|
{
|
|
10
|
+
//
|
|
11
|
+
}
|
|
14
12
|
|
|
13
|
+
export class PicoFormatParam
|
|
14
|
+
{
|
|
15
15
|
/**
|
|
16
16
|
* Cast object to params string
|
|
17
17
|
*
|
|
@@ -20,13 +20,13 @@ export class PicoFormatParamStatic
|
|
|
20
20
|
* @param {any} [params] Input params
|
|
21
21
|
* @returns {string} Params string
|
|
22
22
|
*/
|
|
23
|
-
static castParams(params = {})
|
|
23
|
+
static castParams(params : any = {}) : string
|
|
24
24
|
{
|
|
25
25
|
if ( Mix.isEmpty(params) ) {
|
|
26
26
|
return '';
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
let result = Arr.each(params, (val, key) => {
|
|
29
|
+
let result = Arr.each(params, (val : any, key : any) => {
|
|
30
30
|
return this.castParam(key, val);
|
|
31
31
|
});
|
|
32
32
|
|
|
@@ -43,7 +43,7 @@ export class PicoFormatParamStatic
|
|
|
43
43
|
* @param {string} [path] Key path
|
|
44
44
|
* @returns {string} Param string
|
|
45
45
|
*/
|
|
46
|
-
static castParam(key, value, path = null)
|
|
46
|
+
static castParam(key : string, value : any, path : string = null) : string
|
|
47
47
|
{
|
|
48
48
|
if ( path != null ) {
|
|
49
49
|
key = path + '[' + key + ']';
|
|
@@ -53,7 +53,7 @@ export class PicoFormatParamStatic
|
|
|
53
53
|
return Mix.str(key) + '=' + For.casted(value, true);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
let result = Arr.each(value, (v, k) => {
|
|
56
|
+
let result = Arr.each(value, (v : any, k : any) => {
|
|
57
57
|
return this.castParam(Mix.isArr(value) ? '' : k, v, key);
|
|
58
58
|
});
|
|
59
59
|
|
|
@@ -68,7 +68,7 @@ export class PicoFormatParamStatic
|
|
|
68
68
|
* @param {string} value Params string
|
|
69
69
|
* @returns {any} Params object
|
|
70
70
|
*/
|
|
71
|
-
static parseParams(value)
|
|
71
|
+
static parseParams(value : string) : any
|
|
72
72
|
{
|
|
73
73
|
if ( Mix.isEmpty(value) ) {
|
|
74
74
|
return {};
|
|
@@ -88,22 +88,11 @@ export class PicoFormatParamStatic
|
|
|
88
88
|
For.keyed, For.parsed
|
|
89
89
|
];
|
|
90
90
|
|
|
91
|
-
return Arr.reduce(Array.from(matches), (result, { groups }) => {
|
|
91
|
+
return Arr.reduce(Array.from(matches), (result : any, { groups }) => {
|
|
92
92
|
return Obj.set(result, key(groups.key), val(groups.val));
|
|
93
93
|
}, {});
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
* @param {typeof PicoFormat} self
|
|
100
|
-
* @returns {typeof PicoFormat}
|
|
101
|
-
*/
|
|
102
|
-
export const PicoFormatParamPlugin = function (self) {
|
|
103
|
-
|
|
104
|
-
Obj.each(Mix.class(PicoFormatParamStatic), (fn, id) => {
|
|
105
|
-
self[id] = fn;
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
return self;
|
|
109
|
-
}
|
|
98
|
+
export default PicoFormatParam;
|