@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,12 +1,16 @@
|
|
|
1
|
-
import { Arr, Mix, Obj, Dom } from "../index.esm.
|
|
2
|
-
import { PicoDom } from "../utils/Dom.
|
|
1
|
+
import { Arr, Mix, Obj, Dom } from "../index.esm.ts";
|
|
2
|
+
import { PicoDomInterface, PicoDom } from "../utils/Dom.ts";
|
|
3
|
+
|
|
4
|
+
export interface PicoDomFinder extends PicoDomInterface
|
|
5
|
+
{
|
|
6
|
+
//
|
|
7
|
+
}
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* @memberof PicoDom
|
|
6
11
|
*/
|
|
7
|
-
export class
|
|
12
|
+
export class PicoDomFinder
|
|
8
13
|
{
|
|
9
|
-
|
|
10
14
|
/**
|
|
11
15
|
* Filter nodes by type
|
|
12
16
|
*
|
|
@@ -14,11 +18,11 @@ export class PicoDomFinderStatic
|
|
|
14
18
|
*
|
|
15
19
|
* @param {any} nodes Source nodes
|
|
16
20
|
* @param {number} [filter] Node type
|
|
17
|
-
* @returns {Array<
|
|
21
|
+
* @returns {Array<any>} Filtered nodes
|
|
18
22
|
*/
|
|
19
|
-
static filterNodes(nodes, filter = 1)
|
|
23
|
+
static filterNodes(nodes : any, filter : number = 1) : Array<any>
|
|
20
24
|
{
|
|
21
|
-
return Arr.filter(Mix.nodes(nodes), (el) => {
|
|
25
|
+
return Arr.filter(Mix.nodes(nodes), (el : any) => {
|
|
22
26
|
return el.nodeType === filter;
|
|
23
27
|
});
|
|
24
28
|
}
|
|
@@ -28,20 +32,26 @@ export class PicoDomFinderStatic
|
|
|
28
32
|
*
|
|
29
33
|
* @example Dom.getNodePoint(100, 100)
|
|
30
34
|
*
|
|
31
|
-
* @param {
|
|
32
|
-
* @
|
|
33
|
-
* @returns {Array<Element>} Nodes at point
|
|
35
|
+
* @param {any} event Event data
|
|
36
|
+
* @returns {Array<any>} Nodes at point
|
|
34
37
|
*/
|
|
35
|
-
static getNodePoint(
|
|
38
|
+
static getNodePoint(event : any) : Array<any>
|
|
36
39
|
{
|
|
37
|
-
|
|
40
|
+
if ( event.touches?.[0] ) {
|
|
41
|
+
event = event.touches[0];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let [el, src] = [
|
|
45
|
+
null, [event.clientX, event.clientY]
|
|
46
|
+
];
|
|
38
47
|
|
|
39
48
|
if ( Dom.doc().elementsFromPoint != null ) {
|
|
40
|
-
el = document.elementsFromPoint(
|
|
49
|
+
el = document.elementsFromPoint(src[0], src[1]);
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
if ( Dom.doc().msElementsFromPoint != null ) {
|
|
44
|
-
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
el = document.msElementsFromPoint(src[0], src[1]);
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
return el;
|
|
@@ -54,9 +64,9 @@ export class PicoDomFinderStatic
|
|
|
54
64
|
*
|
|
55
65
|
* @param {string} selector Node selector
|
|
56
66
|
* @param {any} [event] Event object
|
|
57
|
-
* @returns {
|
|
67
|
+
* @returns {any} Found element
|
|
58
68
|
*/
|
|
59
|
-
static getNodeEvent(selector, event = {})
|
|
69
|
+
static getNodeEvent(selector : string, event : any = {}) : any
|
|
60
70
|
{
|
|
61
71
|
let target = event.srcElement;
|
|
62
72
|
|
|
@@ -64,10 +74,10 @@ export class PicoDomFinderStatic
|
|
|
64
74
|
target = event.target;
|
|
65
75
|
}
|
|
66
76
|
|
|
67
|
-
let { type
|
|
77
|
+
let { type } = event;
|
|
68
78
|
|
|
69
79
|
if ( /^(drag[a-z]*|drop$)/.test(type) ) {
|
|
70
|
-
target = Dom.getNodePoint(
|
|
80
|
+
target = Dom.getNodePoint(event);
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
if ( Mix.isArr(target) ) {
|
|
@@ -81,35 +91,6 @@ export class PicoDomFinderStatic
|
|
|
81
91
|
return target.closest(selector);
|
|
82
92
|
}
|
|
83
93
|
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @memberof PicoDom
|
|
88
|
-
* @extends {PicoDom}
|
|
89
|
-
*/
|
|
90
|
-
export class PicoDomFinderInstance
|
|
91
|
-
{
|
|
92
|
-
/**
|
|
93
|
-
* Resolve input elements
|
|
94
|
-
*
|
|
95
|
-
* @example Dom._constructFinder(".item")
|
|
96
|
-
*
|
|
97
|
-
* @param {any} el Input value
|
|
98
|
-
* @returns {any} Resolved elements
|
|
99
|
-
*/
|
|
100
|
-
static _constructFinder(el)
|
|
101
|
-
{
|
|
102
|
-
if ( typeof el === 'string' ) {
|
|
103
|
-
el = document.querySelectorAll(el);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if ( el instanceof NodeList ) {
|
|
107
|
-
el = Mix.nodes(el);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return el;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
94
|
/**
|
|
114
95
|
* Get node type
|
|
115
96
|
*
|
|
@@ -118,9 +99,9 @@ export class PicoDomFinderInstance
|
|
|
118
99
|
* @param {number} [fallback] Fallback value
|
|
119
100
|
* @returns {number} Node type
|
|
120
101
|
*/
|
|
121
|
-
getNodeType(fallback = -1)
|
|
102
|
+
getNodeType(fallback : number = -1) : number
|
|
122
103
|
{
|
|
123
|
-
if ( !
|
|
104
|
+
if ( !this.el ) {
|
|
124
105
|
return fallback;
|
|
125
106
|
}
|
|
126
107
|
|
|
@@ -135,9 +116,9 @@ export class PicoDomFinderInstance
|
|
|
135
116
|
* @param {any} [fallback] Fallback value
|
|
136
117
|
* @returns {PicoDom} Parent instance
|
|
137
118
|
*/
|
|
138
|
-
getNodeParent(fallback = null)
|
|
119
|
+
getNodeParent(fallback : any = null) : PicoDom
|
|
139
120
|
{
|
|
140
|
-
if ( !
|
|
121
|
+
if ( !this.el ) {
|
|
141
122
|
return fallback;
|
|
142
123
|
}
|
|
143
124
|
|
|
@@ -152,9 +133,9 @@ export class PicoDomFinderInstance
|
|
|
152
133
|
* @param {any} [fallback] Fallback value
|
|
153
134
|
* @returns {PicoDom} Prev instance
|
|
154
135
|
*/
|
|
155
|
-
getNodePrev(fallback = null)
|
|
136
|
+
getNodePrev(fallback : any = null) : PicoDom
|
|
156
137
|
{
|
|
157
|
-
if ( !
|
|
138
|
+
if ( !this.el ) {
|
|
158
139
|
return fallback;
|
|
159
140
|
}
|
|
160
141
|
|
|
@@ -169,9 +150,9 @@ export class PicoDomFinderInstance
|
|
|
169
150
|
* @param {any} [fallback] Fallback value
|
|
170
151
|
* @returns {PicoDom} Next instance
|
|
171
152
|
*/
|
|
172
|
-
getNodeNext(fallback = null)
|
|
153
|
+
getNodeNext(fallback : any = null) : PicoDom
|
|
173
154
|
{
|
|
174
|
-
if ( !
|
|
155
|
+
if ( !this.el ) {
|
|
175
156
|
return fallback;
|
|
176
157
|
}
|
|
177
158
|
|
|
@@ -185,11 +166,11 @@ export class PicoDomFinderInstance
|
|
|
185
166
|
*
|
|
186
167
|
* @param {number} [type] Node type
|
|
187
168
|
* @param {any} [fallback] Fallback value
|
|
188
|
-
* @returns {Array<
|
|
169
|
+
* @returns {Array<any>} Child nodes
|
|
189
170
|
*/
|
|
190
|
-
getNodeChilds(type = -1, fallback = [])
|
|
171
|
+
getNodeChilds(type : number = -1, fallback : any = []) : Array<any>
|
|
191
172
|
{
|
|
192
|
-
if ( !
|
|
173
|
+
if ( !this.el ) {
|
|
193
174
|
return fallback;
|
|
194
175
|
}
|
|
195
176
|
|
|
@@ -199,7 +180,7 @@ export class PicoDomFinderInstance
|
|
|
199
180
|
return childs;
|
|
200
181
|
}
|
|
201
182
|
|
|
202
|
-
return Arr.filter(childs, (el) => {
|
|
183
|
+
return Arr.filter(childs, (el : any) => {
|
|
203
184
|
return el.nodeType === type;
|
|
204
185
|
});
|
|
205
186
|
}
|
|
@@ -212,11 +193,11 @@ export class PicoDomFinderInstance
|
|
|
212
193
|
* @param {number} [filter] Node type
|
|
213
194
|
* @returns {PicoDom} Current instance
|
|
214
195
|
*/
|
|
215
|
-
sanatize(filter = 1)
|
|
196
|
+
sanatize(filter : number = 1) : PicoDom
|
|
216
197
|
{
|
|
217
198
|
this.els = Dom.filterNodes(this.els, filter);
|
|
218
199
|
|
|
219
|
-
return this;
|
|
200
|
+
return <PicoDom> <unknown> this;
|
|
220
201
|
}
|
|
221
202
|
|
|
222
203
|
/**
|
|
@@ -225,12 +206,12 @@ export class PicoDomFinderInstance
|
|
|
225
206
|
* @example Dom.find("div").filter(".active")
|
|
226
207
|
*
|
|
227
208
|
* @param {any} selector Filter selector
|
|
228
|
-
* @returns {Array<
|
|
209
|
+
* @returns {Array<any>} Filtered nodes
|
|
229
210
|
*/
|
|
230
|
-
filter(selector)
|
|
211
|
+
filter(selector : any) : Array<any>
|
|
231
212
|
{
|
|
232
213
|
if ( typeof selector !== 'function' ) {
|
|
233
|
-
selector = (el) => Dom.find(el).is(selector);
|
|
214
|
+
selector = (el : any) => Dom.find(el).is(selector);
|
|
234
215
|
}
|
|
235
216
|
|
|
236
217
|
return Arr.filter(this.els, selector);
|
|
@@ -242,12 +223,12 @@ export class PicoDomFinderInstance
|
|
|
242
223
|
* @example Dom.find("div").except(".active")
|
|
243
224
|
*
|
|
244
225
|
* @param {any} selector Exclude selector
|
|
245
|
-
* @returns {Array<
|
|
226
|
+
* @returns {Array<any>} Filtered nodes
|
|
246
227
|
*/
|
|
247
|
-
except(selector)
|
|
228
|
+
except(selector : any) : Array<any>
|
|
248
229
|
{
|
|
249
230
|
if ( typeof selector !== 'function' ) {
|
|
250
|
-
selector = (el) => !
|
|
231
|
+
selector = (el : any) => !Dom.find(el).is(selector);
|
|
251
232
|
}
|
|
252
233
|
|
|
253
234
|
return Arr.filter(this.els, selector);
|
|
@@ -261,7 +242,7 @@ export class PicoDomFinderInstance
|
|
|
261
242
|
* @param {any} selector Search selector
|
|
262
243
|
* @returns {PicoDom} Dom instance
|
|
263
244
|
*/
|
|
264
|
-
find(selector)
|
|
245
|
+
find(selector : any) : PicoDom
|
|
265
246
|
{
|
|
266
247
|
if ( this.el == null ) {
|
|
267
248
|
return Dom.find(null);
|
|
@@ -285,16 +266,16 @@ export class PicoDomFinderInstance
|
|
|
285
266
|
/**
|
|
286
267
|
* Get element by index
|
|
287
268
|
*
|
|
288
|
-
* @example Dom.find("div").get(0) // =>
|
|
269
|
+
* @example Dom.find("div").get(0) // => HTMLElement
|
|
289
270
|
*
|
|
290
271
|
* @param {number} [index] Node index
|
|
291
272
|
* @returns {any} Found element
|
|
292
273
|
*/
|
|
293
|
-
get(index = -
|
|
274
|
+
get(index : number = -1) : any
|
|
294
275
|
{
|
|
295
276
|
let nodes = this.els;
|
|
296
277
|
|
|
297
|
-
if ( index === -
|
|
278
|
+
if ( index === -1 ) {
|
|
298
279
|
return nodes;
|
|
299
280
|
}
|
|
300
281
|
|
|
@@ -304,12 +285,12 @@ export class PicoDomFinderInstance
|
|
|
304
285
|
/**
|
|
305
286
|
* Get first element
|
|
306
287
|
*
|
|
307
|
-
* @example Dom.find("div").first() // =>
|
|
288
|
+
* @example Dom.find("div").first() // => HTMLElement
|
|
308
289
|
*
|
|
309
290
|
* @param {number} [offset] Node offset
|
|
310
291
|
* @returns {any} Found element
|
|
311
292
|
*/
|
|
312
|
-
first(offset = 0)
|
|
293
|
+
first(offset : number = 0) : any
|
|
313
294
|
{
|
|
314
295
|
return this.get(offset);
|
|
315
296
|
}
|
|
@@ -317,12 +298,12 @@ export class PicoDomFinderInstance
|
|
|
317
298
|
/**
|
|
318
299
|
* Get last element
|
|
319
300
|
*
|
|
320
|
-
* @example Dom.find("div").last() // =>
|
|
301
|
+
* @example Dom.find("div").last() // => HTMLElement
|
|
321
302
|
*
|
|
322
303
|
* @param {number} [offset] Node offset
|
|
323
304
|
* @returns {any} Found element
|
|
324
305
|
*/
|
|
325
|
-
last(offset = 1)
|
|
306
|
+
last(offset : number = 1) : any
|
|
326
307
|
{
|
|
327
308
|
return Arr.get(this.els, this.els.length - offset);
|
|
328
309
|
}
|
|
@@ -332,10 +313,10 @@ export class PicoDomFinderInstance
|
|
|
332
313
|
*
|
|
333
314
|
* @example Dom.find("div").each((el) => console.log(el))
|
|
334
315
|
*
|
|
335
|
-
* @param {
|
|
316
|
+
* @param {Function} cb Callback fn
|
|
336
317
|
* @returns {PicoDom} Current instance
|
|
337
318
|
*/
|
|
338
|
-
each(cb)
|
|
319
|
+
each(cb : Function) : PicoDom
|
|
339
320
|
{
|
|
340
321
|
return (this, Arr.each(this.els, cb));
|
|
341
322
|
}
|
|
@@ -345,21 +326,21 @@ export class PicoDomFinderInstance
|
|
|
345
326
|
*
|
|
346
327
|
* @example Dom.find("div").loopParent((el) => console.log(el))
|
|
347
328
|
*
|
|
348
|
-
* @param {
|
|
329
|
+
* @param {Function} cb Callback fn
|
|
349
330
|
* @param {any} [boundry] Loop limit
|
|
350
331
|
* @returns {PicoDom} Current instance
|
|
351
332
|
*/
|
|
352
|
-
loopParent(cb, boundry = null)
|
|
333
|
+
loopParent(cb : Function, boundry : any = null) : PicoDom
|
|
353
334
|
{
|
|
354
335
|
if ( boundry == null ) {
|
|
355
336
|
boundry = Dom.win();
|
|
356
337
|
}
|
|
357
338
|
|
|
358
|
-
for ( let el = this.el; el && el !== boundry; el = el.parentNode ) {
|
|
339
|
+
for ( let el : any = this.el; el && el !== boundry; el = el.parentNode ) {
|
|
359
340
|
cb.call({}, el);
|
|
360
341
|
}
|
|
361
342
|
|
|
362
|
-
return this;
|
|
343
|
+
return <PicoDom> <unknown> this;
|
|
363
344
|
}
|
|
364
345
|
|
|
365
346
|
/**
|
|
@@ -369,7 +350,7 @@ export class PicoDomFinderInstance
|
|
|
369
350
|
*
|
|
370
351
|
* @returns {PicoDom} Parent instance
|
|
371
352
|
*/
|
|
372
|
-
parent()
|
|
353
|
+
parent() : PicoDom
|
|
373
354
|
{
|
|
374
355
|
let parent = this.getNodeParent();
|
|
375
356
|
|
|
@@ -389,12 +370,10 @@ export class PicoDomFinderInstance
|
|
|
389
370
|
* @param {number} [filter] Node type
|
|
390
371
|
* @returns {PicoDom} Child instance
|
|
391
372
|
*/
|
|
392
|
-
child(selector, filter = 1)
|
|
373
|
+
child(selector : any = null, filter : number = 1) : PicoDom
|
|
393
374
|
{
|
|
394
|
-
for ( let el of this.
|
|
395
|
-
|
|
396
|
-
return Dom.find(el);
|
|
397
|
-
}
|
|
375
|
+
for ( let el of this.childs(selector, filter) ) {
|
|
376
|
+
return Dom.find(el);
|
|
398
377
|
}
|
|
399
378
|
|
|
400
379
|
return Dom.find(null);
|
|
@@ -407,9 +386,9 @@ export class PicoDomFinderInstance
|
|
|
407
386
|
*
|
|
408
387
|
* @param {any} [selector] Child selector
|
|
409
388
|
* @param {number} [filter] Node type
|
|
410
|
-
* @returns {Array<
|
|
389
|
+
* @returns {Array<any>} Child elements
|
|
411
390
|
*/
|
|
412
|
-
childs(selector = null, filter = 1)
|
|
391
|
+
childs(selector : any = null, filter : number = 1) : Array<any>
|
|
413
392
|
{
|
|
414
393
|
let childs = this.getNodeChilds(filter);
|
|
415
394
|
|
|
@@ -428,22 +407,30 @@ export class PicoDomFinderInstance
|
|
|
428
407
|
* @example Dom.find("div").closest(".container")
|
|
429
408
|
*
|
|
430
409
|
* @param {any} selector Target selector
|
|
431
|
-
* @returns {
|
|
410
|
+
* @returns {any} Found element
|
|
432
411
|
*/
|
|
433
|
-
closest(selector)
|
|
412
|
+
closest(selector : any) : any
|
|
434
413
|
{
|
|
435
414
|
if ( this.el === selector ) {
|
|
436
415
|
return this.el;
|
|
437
416
|
}
|
|
438
417
|
|
|
439
|
-
for ( let el = this; el.el != null; el = el.getNodeParent() ) {
|
|
418
|
+
for ( let el : any = this; el.el != null; el = el.getNodeParent() ) {
|
|
440
419
|
if ( el.is(selector) ) return el.el;
|
|
441
420
|
}
|
|
442
421
|
|
|
443
422
|
return null;
|
|
444
423
|
}
|
|
445
424
|
|
|
446
|
-
|
|
425
|
+
/**
|
|
426
|
+
* Get closest instance
|
|
427
|
+
*
|
|
428
|
+
* @example Dom.find("div").upnode(".container")
|
|
429
|
+
*
|
|
430
|
+
* @param {any} selector
|
|
431
|
+
* @returns {PicoDom}
|
|
432
|
+
*/
|
|
433
|
+
upnode(selector : any) : PicoDom
|
|
447
434
|
{
|
|
448
435
|
return Dom.find(...[
|
|
449
436
|
this.closest(selector)
|
|
@@ -458,7 +445,7 @@ export class PicoDomFinderInstance
|
|
|
458
445
|
* @param {number} [type] Node type
|
|
459
446
|
* @returns {PicoDom} Prev instance
|
|
460
447
|
*/
|
|
461
|
-
prev(type = 1)
|
|
448
|
+
prev(type : number = 1) : PicoDom
|
|
462
449
|
{
|
|
463
450
|
let el = this.getNodePrev();
|
|
464
451
|
|
|
@@ -477,7 +464,7 @@ export class PicoDomFinderInstance
|
|
|
477
464
|
* @param {number} [type] Node type
|
|
478
465
|
* @returns {PicoDom} Next instance
|
|
479
466
|
*/
|
|
480
|
-
next(type = 1)
|
|
467
|
+
next(type : number = 1) : PicoDom
|
|
481
468
|
{
|
|
482
469
|
let el = this.getNodeNext();
|
|
483
470
|
|
|
@@ -495,7 +482,7 @@ export class PicoDomFinderInstance
|
|
|
495
482
|
*
|
|
496
483
|
* @returns {number} Count value
|
|
497
484
|
*/
|
|
498
|
-
length()
|
|
485
|
+
length() : number
|
|
499
486
|
{
|
|
500
487
|
return this.els.length;
|
|
501
488
|
}
|
|
@@ -506,16 +493,17 @@ export class PicoDomFinderInstance
|
|
|
506
493
|
* @example Dom.find("div").is(".active") // => true
|
|
507
494
|
*
|
|
508
495
|
* @param {any} selector Test selector
|
|
496
|
+
* @param {boolean} [empty] Test selector
|
|
509
497
|
* @returns {boolean} True if matches
|
|
510
498
|
*/
|
|
511
|
-
is(selector)
|
|
499
|
+
is(selector : any, empty : boolean = false) : boolean
|
|
512
500
|
{
|
|
513
501
|
if ( this.el === selector ) {
|
|
514
502
|
return true;
|
|
515
503
|
}
|
|
516
504
|
|
|
517
505
|
if ( this.el == null ) {
|
|
518
|
-
return
|
|
506
|
+
return empty;
|
|
519
507
|
}
|
|
520
508
|
|
|
521
509
|
for ( let el of this.parent().find(selector).get() ) {
|
|
@@ -533,7 +521,7 @@ export class PicoDomFinderInstance
|
|
|
533
521
|
* @param {any} selector Test selector
|
|
534
522
|
* @returns {boolean} True if matches
|
|
535
523
|
*/
|
|
536
|
-
matches(selector)
|
|
524
|
+
matches(selector : any) : boolean
|
|
537
525
|
{
|
|
538
526
|
if ( this.el === selector ) {
|
|
539
527
|
return true;
|
|
@@ -557,7 +545,7 @@ export class PicoDomFinderInstance
|
|
|
557
545
|
*
|
|
558
546
|
* @returns {boolean} True if empty
|
|
559
547
|
*/
|
|
560
|
-
empty()
|
|
548
|
+
empty() : boolean
|
|
561
549
|
{
|
|
562
550
|
return this.length() < 1 || this.el == null;
|
|
563
551
|
}
|
|
@@ -569,7 +557,7 @@ export class PicoDomFinderInstance
|
|
|
569
557
|
*
|
|
570
558
|
* @returns {boolean} True if visible
|
|
571
559
|
*/
|
|
572
|
-
visible()
|
|
560
|
+
visible() : boolean
|
|
573
561
|
{
|
|
574
562
|
if ( this.el == null ) {
|
|
575
563
|
return false;
|
|
@@ -586,7 +574,7 @@ export class PicoDomFinderInstance
|
|
|
586
574
|
* @param {any} selector Parent selector
|
|
587
575
|
* @returns {boolean} True if matches
|
|
588
576
|
*/
|
|
589
|
-
above(selector)
|
|
577
|
+
above(selector : any) : boolean
|
|
590
578
|
{
|
|
591
579
|
// Parent is exacly selector
|
|
592
580
|
return this.parent().is(selector);
|
|
@@ -600,7 +588,7 @@ export class PicoDomFinderInstance
|
|
|
600
588
|
* @param {any} selector Target selector
|
|
601
589
|
* @returns {boolean} True if inside
|
|
602
590
|
*/
|
|
603
|
-
inside(selector)
|
|
591
|
+
inside(selector : any) : boolean
|
|
604
592
|
{
|
|
605
593
|
// Has parent of selector
|
|
606
594
|
return this.closest(selector) != null;
|
|
@@ -614,7 +602,7 @@ export class PicoDomFinderInstance
|
|
|
614
602
|
* @param {any} selector Target selector
|
|
615
603
|
* @returns {boolean} True if contains
|
|
616
604
|
*/
|
|
617
|
-
contains(selector)
|
|
605
|
+
contains(selector : any) : boolean
|
|
618
606
|
{
|
|
619
607
|
// Has child of selector
|
|
620
608
|
return this.el.contains(selector);
|
|
@@ -622,57 +610,33 @@ export class PicoDomFinderInstance
|
|
|
622
610
|
|
|
623
611
|
}
|
|
624
612
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
*/
|
|
628
|
-
PicoDomFinderInstance.prototype.isParent = function (...args) {
|
|
613
|
+
// @ts-ignore
|
|
614
|
+
PicoDomFinder.prototype.isParent = function (...args : Parameters<typeof PicoDomFinder.prototype.above>) {
|
|
629
615
|
console.warn('Dom.isParent() is deprecated, use Dom.above() instead.');
|
|
630
616
|
return this.above(...args);
|
|
631
617
|
};
|
|
632
618
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
*/
|
|
636
|
-
PicoDomFinderInstance.prototype.previous = function () {
|
|
619
|
+
// @ts-ignore
|
|
620
|
+
PicoDomFinder.prototype.previous = function () {
|
|
637
621
|
console.warn('Dom.previous() is deprecated, use Dom.prev() instead.');
|
|
638
622
|
return this.prev();
|
|
639
623
|
};
|
|
640
624
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
*/
|
|
644
|
-
PicoDomFinderInstance.prototype.where = function (...args) {
|
|
625
|
+
// @ts-ignore
|
|
626
|
+
PicoDomFinder.prototype.where = function (...args : Parameters<typeof PicoDomFinder.prototype.filter>) {
|
|
645
627
|
console.warn('Dom.where() is deprecated, use Dom.filter() instead.');
|
|
646
628
|
return this.filter(...args);
|
|
647
629
|
};
|
|
648
630
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
*/
|
|
652
|
-
PicoDomFinderInstance.prototype.not = function (...args) {
|
|
631
|
+
// @ts-ignore
|
|
632
|
+
PicoDomFinder.prototype.not = function (...args : Parameters<typeof PicoDomFinder.prototype.except>) {
|
|
653
633
|
console.warn('Dom.not() is deprecated, use Dom.except() instead.');
|
|
654
634
|
return this.except(...args);
|
|
655
635
|
};
|
|
656
636
|
|
|
657
|
-
|
|
637
|
+
// @ts-ignore
|
|
638
|
+
PicoDomFinder.prototype.getNot = () => {
|
|
658
639
|
console.error('Dom.getNot() is not implemented anymore.');
|
|
659
640
|
};
|
|
660
641
|
|
|
661
|
-
|
|
662
|
-
* @param {typeof PicoDom} self
|
|
663
|
-
* @returns {typeof PicoDom}
|
|
664
|
-
*/
|
|
665
|
-
export const PicoDomFinderPlugin = function (self) {
|
|
666
|
-
|
|
667
|
-
Obj.each(Mix.class(PicoDomFinderStatic), (fn, id) => {
|
|
668
|
-
self[id] = fn;
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
Obj.each(Mix.proto(PicoDomFinderInstance), (fn, id) => {
|
|
672
|
-
self.prototype[id] = fn;
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
self.init.push(PicoDomFinderInstance._constructFinder);
|
|
676
|
-
|
|
677
|
-
return self;
|
|
678
|
-
}
|
|
642
|
+
export default PicoDomFinder;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { PicoDomInterface } from "../utils/Dom.ts";
|
|
2
|
+
import PicoDomFinder from "./DomFinder.js";
|
|
3
|
+
|
|
4
|
+
export interface PicoDomForm extends PicoDomInterface,
|
|
5
|
+
PicoDomFinder
|
|
6
|
+
{
|
|
7
|
+
//
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @memberof PicoDom
|
|
12
|
+
*/
|
|
13
|
+
export class PicoDomForm
|
|
14
|
+
{
|
|
15
|
+
/**
|
|
16
|
+
* Get or set input value
|
|
17
|
+
*
|
|
18
|
+
* @example Dom.find("input").value("hello")
|
|
19
|
+
*
|
|
20
|
+
* @param {any} [value] Input value
|
|
21
|
+
* @returns {any} Value or instance
|
|
22
|
+
*/
|
|
23
|
+
value(value : any = undefined) : any
|
|
24
|
+
{
|
|
25
|
+
if ( value === undefined ) {
|
|
26
|
+
return this.el.value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.each((el : any) => {
|
|
30
|
+
el.value = value;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default PicoDomForm;
|