@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,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,22 +31,19 @@ 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 = {})
|
|
35
|
+
rect(fallback : any = { left: 0, top: 0, width: 0, height: 0 })
|
|
34
36
|
{
|
|
37
|
+
if ( !this.el.getBoundingClientRect ) {
|
|
38
|
+
return fallback;
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
const rect = this.el.getBoundingClientRect();
|
|
36
42
|
|
|
37
43
|
if ( rect == null ) {
|
|
38
44
|
return fallback;
|
|
39
45
|
}
|
|
40
|
-
|
|
46
|
+
|
|
41
47
|
return rect.toJSON();
|
|
42
48
|
}
|
|
43
49
|
|
|
@@ -50,7 +56,7 @@ export class PicoDomRectangleInstance
|
|
|
50
56
|
* @param {number} [fallback] Fallback value
|
|
51
57
|
* @returns {any} Margin values
|
|
52
58
|
*/
|
|
53
|
-
margin(key = null, fallback = 0)
|
|
59
|
+
margin(key : string = null, fallback : number = 0) : any
|
|
54
60
|
{
|
|
55
61
|
let computed = this.computed();
|
|
56
62
|
|
|
@@ -77,7 +83,7 @@ export class PicoDomRectangleInstance
|
|
|
77
83
|
* @param {number} [fallback] Fallback value
|
|
78
84
|
* @returns {any} Padding values
|
|
79
85
|
*/
|
|
80
|
-
padding(key = null, fallback = 0)
|
|
86
|
+
padding(key : string = null, fallback : number = 0) : any
|
|
81
87
|
{
|
|
82
88
|
let computed = this.computed();
|
|
83
89
|
|
|
@@ -102,7 +108,7 @@ export class PicoDomRectangleInstance
|
|
|
102
108
|
*
|
|
103
109
|
* @returns {number} Height value
|
|
104
110
|
*/
|
|
105
|
-
height()
|
|
111
|
+
height() : number
|
|
106
112
|
{
|
|
107
113
|
if ( this.el == null ) {
|
|
108
114
|
return 0;
|
|
@@ -122,7 +128,7 @@ export class PicoDomRectangleInstance
|
|
|
122
128
|
*
|
|
123
129
|
* @returns {number} Height value
|
|
124
130
|
*/
|
|
125
|
-
clientHeight()
|
|
131
|
+
clientHeight() : number
|
|
126
132
|
{
|
|
127
133
|
if ( this.el == null ) {
|
|
128
134
|
return 0;
|
|
@@ -138,7 +144,7 @@ export class PicoDomRectangleInstance
|
|
|
138
144
|
*
|
|
139
145
|
* @returns {number} Height value
|
|
140
146
|
*/
|
|
141
|
-
scrollHeight()
|
|
147
|
+
scrollHeight() : number
|
|
142
148
|
{
|
|
143
149
|
if ( this.el == null ) {
|
|
144
150
|
return 0;
|
|
@@ -154,7 +160,7 @@ export class PicoDomRectangleInstance
|
|
|
154
160
|
*
|
|
155
161
|
* @returns {number} Height value
|
|
156
162
|
*/
|
|
157
|
-
innerHeight()
|
|
163
|
+
innerHeight() : number
|
|
158
164
|
{
|
|
159
165
|
if ( this.el == null ) {
|
|
160
166
|
return 0;
|
|
@@ -175,11 +181,11 @@ export class PicoDomRectangleInstance
|
|
|
175
181
|
* @example Dom.find("div").realHeight({ display: "block" })
|
|
176
182
|
*
|
|
177
183
|
* @param {any} [style] Temp style
|
|
178
|
-
* @returns {
|
|
184
|
+
* @returns {any} Height value
|
|
179
185
|
*/
|
|
180
|
-
realHeight(style = {})
|
|
186
|
+
realHeight(style : any = {}) : any
|
|
181
187
|
{
|
|
182
|
-
let height = 'auto';
|
|
188
|
+
let height : number | string = 'auto';
|
|
183
189
|
|
|
184
190
|
this.actual(() => {
|
|
185
191
|
return height = this.height();
|
|
@@ -195,9 +201,9 @@ export class PicoDomRectangleInstance
|
|
|
195
201
|
*
|
|
196
202
|
* @param {any} [target] Target element
|
|
197
203
|
* @param {boolean} [apply] Apply style
|
|
198
|
-
* @returns {
|
|
204
|
+
* @returns {any} Height value
|
|
199
205
|
*/
|
|
200
|
-
evaluateHeight(target = null, apply = true)
|
|
206
|
+
evaluateHeight(target : any = null, apply : boolean = true) : any
|
|
201
207
|
{
|
|
202
208
|
target = Dom.find(target);
|
|
203
209
|
|
|
@@ -205,7 +211,7 @@ export class PicoDomRectangleInstance
|
|
|
205
211
|
target = this.parent();
|
|
206
212
|
}
|
|
207
213
|
|
|
208
|
-
let height = 'auto';
|
|
214
|
+
let height : number | string = 'auto';
|
|
209
215
|
|
|
210
216
|
this.actual(() => {
|
|
211
217
|
height = target.innerHeight();
|
|
@@ -225,7 +231,7 @@ export class PicoDomRectangleInstance
|
|
|
225
231
|
*
|
|
226
232
|
* @returns {number} Width value
|
|
227
233
|
*/
|
|
228
|
-
width()
|
|
234
|
+
width() : number
|
|
229
235
|
{
|
|
230
236
|
if ( this.el == null ) {
|
|
231
237
|
return 0;
|
|
@@ -245,7 +251,7 @@ export class PicoDomRectangleInstance
|
|
|
245
251
|
*
|
|
246
252
|
* @returns {number} Width value
|
|
247
253
|
*/
|
|
248
|
-
clientWidth()
|
|
254
|
+
clientWidth() : number
|
|
249
255
|
{
|
|
250
256
|
if ( this.el == null ) {
|
|
251
257
|
return 0;
|
|
@@ -261,7 +267,7 @@ export class PicoDomRectangleInstance
|
|
|
261
267
|
*
|
|
262
268
|
* @returns {number} Width value
|
|
263
269
|
*/
|
|
264
|
-
scrollWidth()
|
|
270
|
+
scrollWidth() : number
|
|
265
271
|
{
|
|
266
272
|
if ( this.el == null ) {
|
|
267
273
|
return 0;
|
|
@@ -277,7 +283,7 @@ export class PicoDomRectangleInstance
|
|
|
277
283
|
*
|
|
278
284
|
* @returns {number} Width value
|
|
279
285
|
*/
|
|
280
|
-
innerWidth()
|
|
286
|
+
innerWidth() : number
|
|
281
287
|
{
|
|
282
288
|
if ( this.el == null ) {
|
|
283
289
|
return 0;
|
|
@@ -298,11 +304,11 @@ export class PicoDomRectangleInstance
|
|
|
298
304
|
* @example Dom.find("div").realWidth({ display: "block" })
|
|
299
305
|
*
|
|
300
306
|
* @param {any} [style] Temp style
|
|
301
|
-
* @returns {
|
|
307
|
+
* @returns {any} Width value
|
|
302
308
|
*/
|
|
303
|
-
realWidth(style = {})
|
|
309
|
+
realWidth(style = {}) : any
|
|
304
310
|
{
|
|
305
|
-
let width = 'auto';
|
|
311
|
+
let width : number | string = 'auto';
|
|
306
312
|
|
|
307
313
|
this.actual(() => {
|
|
308
314
|
return width = this.width();
|
|
@@ -318,9 +324,9 @@ export class PicoDomRectangleInstance
|
|
|
318
324
|
*
|
|
319
325
|
* @param {any} [target] Target element
|
|
320
326
|
* @param {boolean} [apply] Apply style
|
|
321
|
-
* @returns {
|
|
327
|
+
* @returns {any} Width value
|
|
322
328
|
*/
|
|
323
|
-
evaluateWidth(target = null, apply = true)
|
|
329
|
+
evaluateWidth(target : any = null, apply : boolean = true) : any
|
|
324
330
|
{
|
|
325
331
|
target = Dom.find(target);
|
|
326
332
|
|
|
@@ -328,7 +334,7 @@ export class PicoDomRectangleInstance
|
|
|
328
334
|
target = this.parent();
|
|
329
335
|
}
|
|
330
336
|
|
|
331
|
-
let width = 'auto';
|
|
337
|
+
let width : number | string = 'auto';
|
|
332
338
|
|
|
333
339
|
this.actual(() => {
|
|
334
340
|
width = target.innerWidth();
|
|
@@ -350,7 +356,7 @@ export class PicoDomRectangleInstance
|
|
|
350
356
|
* @param {any} [boundry] View boundry
|
|
351
357
|
* @returns {any} Offset values
|
|
352
358
|
*/
|
|
353
|
-
offset(key = null, boundry = null)
|
|
359
|
+
offset(key : string = null, boundry : any = null) : any
|
|
354
360
|
{
|
|
355
361
|
let offset = this.getOffset(boundry);
|
|
356
362
|
|
|
@@ -369,7 +375,7 @@ export class PicoDomRectangleInstance
|
|
|
369
375
|
* @param {any} [boundry] View boundry
|
|
370
376
|
* @returns {number} Top offset
|
|
371
377
|
*/
|
|
372
|
-
offsetTop(boundry = null)
|
|
378
|
+
offsetTop(boundry : any = null) : number
|
|
373
379
|
{
|
|
374
380
|
return this.offset('top', boundry);
|
|
375
381
|
}
|
|
@@ -382,7 +388,7 @@ export class PicoDomRectangleInstance
|
|
|
382
388
|
* @param {any} [boundry] View boundry
|
|
383
389
|
* @returns {number} Bottom offset
|
|
384
390
|
*/
|
|
385
|
-
offsetBottom(boundry = null)
|
|
391
|
+
offsetBottom(boundry : any = null) : number
|
|
386
392
|
{
|
|
387
393
|
return this.offset('bottom', boundry);
|
|
388
394
|
}
|
|
@@ -395,7 +401,7 @@ export class PicoDomRectangleInstance
|
|
|
395
401
|
* @param {any} [boundry] View boundry
|
|
396
402
|
* @returns {number} Left offset
|
|
397
403
|
*/
|
|
398
|
-
offsetLeft(boundry = null)
|
|
404
|
+
offsetLeft(boundry : any = null) : number
|
|
399
405
|
{
|
|
400
406
|
return this.offset('left', boundry);
|
|
401
407
|
}
|
|
@@ -408,7 +414,7 @@ export class PicoDomRectangleInstance
|
|
|
408
414
|
* @param {any} [boundry] View boundry
|
|
409
415
|
* @returns {number} Right offset
|
|
410
416
|
*/
|
|
411
|
-
offsetRight(boundry = null)
|
|
417
|
+
offsetRight(boundry : any = null) : number
|
|
412
418
|
{
|
|
413
419
|
return this.offset('right', boundry);
|
|
414
420
|
}
|
|
@@ -418,11 +424,11 @@ export class PicoDomRectangleInstance
|
|
|
418
424
|
*
|
|
419
425
|
* @example Dom.find("div").loopOffset((el) => console.log(el))
|
|
420
426
|
*
|
|
421
|
-
* @param {
|
|
427
|
+
* @param {Function} cb Callback fn
|
|
422
428
|
* @param {any} [boundry] Loop limit
|
|
423
429
|
* @returns {PicoDom} Current instance
|
|
424
430
|
*/
|
|
425
|
-
loopOffset(cb, boundry = null)
|
|
431
|
+
loopOffset(cb : Function, boundry : any = null) : PicoDom
|
|
426
432
|
{
|
|
427
433
|
if ( boundry == null ) {
|
|
428
434
|
boundry = Dom.body();
|
|
@@ -432,7 +438,7 @@ export class PicoDomRectangleInstance
|
|
|
432
438
|
cb.call({}, el);
|
|
433
439
|
}
|
|
434
440
|
|
|
435
|
-
return this;
|
|
441
|
+
return <PicoDom> <unknown> this;
|
|
436
442
|
}
|
|
437
443
|
|
|
438
444
|
/**
|
|
@@ -445,7 +451,7 @@ export class PicoDomRectangleInstance
|
|
|
445
451
|
* @param {number} height Element height
|
|
446
452
|
* @returns {any} Calculated offset
|
|
447
453
|
*/
|
|
448
|
-
calcOffset(offset, width, height)
|
|
454
|
+
calcOffset(offset : any, width : number, height : number) : any
|
|
449
455
|
{
|
|
450
456
|
let size = {
|
|
451
457
|
right: Dom.body().scrollWidth - offset.left - width,
|
|
@@ -463,7 +469,7 @@ export class PicoDomRectangleInstance
|
|
|
463
469
|
* @param {any} [boundry] View boundry
|
|
464
470
|
* @returns {any} Offset values
|
|
465
471
|
*/
|
|
466
|
-
getOffset(boundry = null)
|
|
472
|
+
getOffset(boundry : any = null) : any
|
|
467
473
|
{
|
|
468
474
|
if ( boundry == null ) {
|
|
469
475
|
boundry = Dom.body();
|
|
@@ -477,7 +483,7 @@ export class PicoDomRectangleInstance
|
|
|
477
483
|
return source;
|
|
478
484
|
}
|
|
479
485
|
|
|
480
|
-
cb = (el) => {
|
|
486
|
+
cb = (el : any) => {
|
|
481
487
|
source.top += Dom.num(el.offsetTop, 0);
|
|
482
488
|
source.left += Dom.num(el.offsetLeft, 0);
|
|
483
489
|
};
|
|
@@ -494,7 +500,7 @@ export class PicoDomRectangleInstance
|
|
|
494
500
|
top: 0, left: 0, bottom: 0, right: 0
|
|
495
501
|
};
|
|
496
502
|
|
|
497
|
-
cb = (el) => {
|
|
503
|
+
cb = (el : any) => {
|
|
498
504
|
target.top += Dom.num(el.offsetTop, 0);
|
|
499
505
|
target.left += Dom.num(el.offsetLeft, 0);
|
|
500
506
|
};
|
|
@@ -522,7 +528,7 @@ export class PicoDomRectangleInstance
|
|
|
522
528
|
* @param {any} [boundry] View boundry
|
|
523
529
|
* @returns {any} Scroll values
|
|
524
530
|
*/
|
|
525
|
-
scroll(key = null, boundry = null)
|
|
531
|
+
scroll(key : any = null, boundry : any = null) : any
|
|
526
532
|
{
|
|
527
533
|
let scroll = this.getScroll(boundry);
|
|
528
534
|
|
|
@@ -540,15 +546,15 @@ export class PicoDomRectangleInstance
|
|
|
540
546
|
*
|
|
541
547
|
* @param {any} [value] Scroll value
|
|
542
548
|
* @param {any} [boundry] View boundry
|
|
543
|
-
* @returns {
|
|
549
|
+
* @returns {any} Value or instance
|
|
544
550
|
*/
|
|
545
|
-
scrollTop(value = null, boundry = null)
|
|
551
|
+
scrollTop(value : any = null, boundry : any = null) : any
|
|
546
552
|
{
|
|
547
553
|
if ( value == null ) {
|
|
548
554
|
return this.scroll('top', boundry);
|
|
549
555
|
}
|
|
550
556
|
|
|
551
|
-
this.each((el) => {
|
|
557
|
+
this.each((el : any) => {
|
|
552
558
|
el.scrollTop = value;
|
|
553
559
|
});
|
|
554
560
|
|
|
@@ -562,15 +568,15 @@ export class PicoDomRectangleInstance
|
|
|
562
568
|
*
|
|
563
569
|
* @param {any} [value] Scroll value
|
|
564
570
|
* @param {any} [boundry] View boundry
|
|
565
|
-
* @returns {
|
|
571
|
+
* @returns {any} Value or instance
|
|
566
572
|
*/
|
|
567
|
-
scrollLeft(value = null, boundry = null)
|
|
573
|
+
scrollLeft(value : any = null, boundry : any = null) : any
|
|
568
574
|
{
|
|
569
575
|
if ( value == null ) {
|
|
570
576
|
return this.scroll('left', boundry);
|
|
571
577
|
}
|
|
572
578
|
|
|
573
|
-
this.each((el) => {
|
|
579
|
+
this.each((el : any) => {
|
|
574
580
|
el.scrollLeft = value;
|
|
575
581
|
});
|
|
576
582
|
|
|
@@ -585,7 +591,7 @@ export class PicoDomRectangleInstance
|
|
|
585
591
|
* @param {any} [boundry] View boundry
|
|
586
592
|
* @returns {any} Scroll values
|
|
587
593
|
*/
|
|
588
|
-
getScroll(boundry = null)
|
|
594
|
+
getScroll(boundry : any = null) : any
|
|
589
595
|
{
|
|
590
596
|
if ( boundry == null ) {
|
|
591
597
|
boundry = Dom.win();
|
|
@@ -599,7 +605,7 @@ export class PicoDomRectangleInstance
|
|
|
599
605
|
return source;
|
|
600
606
|
}
|
|
601
607
|
|
|
602
|
-
cb = (el) => {
|
|
608
|
+
cb = (el : any) => {
|
|
603
609
|
source.top += Dom.num(el.scrollTop || el.pageYOffset || 0);
|
|
604
610
|
source.left += Dom.num(el.scrollLeft || el.pageXOffset || 0);
|
|
605
611
|
}
|
|
@@ -610,7 +616,7 @@ export class PicoDomRectangleInstance
|
|
|
610
616
|
top: 0, left: 0
|
|
611
617
|
};
|
|
612
618
|
|
|
613
|
-
cb = (el) => {
|
|
619
|
+
cb = (el : any) => {
|
|
614
620
|
target.top += Dom.num(el.scrollTop || el.pageYOffset || 0);
|
|
615
621
|
target.left += Dom.num(el.scrollLeft || el.pageXOffset || 0);
|
|
616
622
|
};
|
|
@@ -625,45 +631,22 @@ export class PicoDomRectangleInstance
|
|
|
625
631
|
|
|
626
632
|
}
|
|
627
633
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
*/
|
|
631
|
-
PicoDomRectangleInstance.prototype.loopOffsetParent = function (...args) {
|
|
634
|
+
// @ts-ignore
|
|
635
|
+
PicoDomRectangle.prototype.loopOffsetParent = function (...args : Parameters<typeof PicoDomRectangle.prototype.loopOffset>) {
|
|
632
636
|
console.warn('Dom.loopOffsetParent() is deprecated, use Dom.loopOffset() instead.');
|
|
633
637
|
return this.loopOffset(...args);
|
|
634
638
|
};
|
|
635
639
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
*/
|
|
639
|
-
PicoDomRectangleInstance.prototype.scrollTopGlobal = function () {
|
|
640
|
+
// @ts-ignore
|
|
641
|
+
PicoDomRectangle.prototype.scrollTopGlobal = function () {
|
|
640
642
|
console.warn('Dom.scrollTopGlobal() is deprecated, use Dom.scroll(\'top\') instead.');
|
|
641
643
|
return this.scroll('top', null);
|
|
642
644
|
};
|
|
643
645
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
*/
|
|
647
|
-
PicoDomRectangleInstance.prototype.scrollLeftGlobal = function () {
|
|
646
|
+
// @ts-ignore
|
|
647
|
+
PicoDomRectangle.prototype.scrollLeftGlobal = function () {
|
|
648
648
|
console.warn('Dom.scrollLeftGlobal() is deprecated, use Dom.scroll(\'left\') instead.');
|
|
649
649
|
return this.scroll('left', null);
|
|
650
650
|
};
|
|
651
651
|
|
|
652
|
-
|
|
653
|
-
* @param {typeof PicoDom} self
|
|
654
|
-
* @returns {typeof PicoDom}
|
|
655
|
-
*/
|
|
656
|
-
export const PicoDomRectanglePlugin = function (self) {
|
|
657
|
-
|
|
658
|
-
Obj.each(Mix.class(PicoDomRectangleStatic), (fn, id) => {
|
|
659
|
-
self[id] = fn;
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
Obj.each(Mix.proto(PicoDomRectangleInstance), (fn, id) => {
|
|
663
|
-
self.prototype[id] = fn;
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
// self.init.push(PicoDomRectangleInstance.constructor);
|
|
667
|
-
|
|
668
|
-
return self;
|
|
669
|
-
}
|
|
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;
|