@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,27 +1,31 @@
|
|
|
1
|
-
import { Arr, Hash, Mix, Obj, Dom, Run } from "../index.esm.
|
|
2
|
-
import { PicoDom } from "../utils/Dom.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Arr, Hash, Mix, Obj, Dom, Run } from "../index.esm.ts";
|
|
2
|
+
import { PicoDom, PicoDomInterface } from "../utils/Dom.ts";
|
|
3
|
+
import PicoDomFinder from "./DomFinder.js";
|
|
4
|
+
import PicoDomRectangle from "./DomRectangle.js";
|
|
5
|
+
|
|
6
|
+
export interface PicoDomEvent extends PicoDomInterface,
|
|
7
|
+
PicoDomFinder,
|
|
8
|
+
PicoDomRectangle
|
|
8
9
|
{
|
|
9
|
-
|
|
10
|
+
//
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @memberof PicoDom
|
|
14
|
-
* @extends {PicoDom}
|
|
15
15
|
*/
|
|
16
|
-
export class
|
|
16
|
+
export class PicoDomEvent
|
|
17
17
|
{
|
|
18
|
+
/**
|
|
19
|
+
* @type {any[]}
|
|
20
|
+
*/
|
|
21
|
+
static $events : any[] = [];
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* Bind event listener
|
|
21
25
|
*
|
|
22
26
|
* @example Dom.bind(el, "click", cb)
|
|
23
27
|
*
|
|
24
|
-
* @param {
|
|
28
|
+
* @param {any} el Target element
|
|
25
29
|
* @param {string} event Event name
|
|
26
30
|
* @param {function} cb Callback fn
|
|
27
31
|
* @param {string} [selector] Event selector
|
|
@@ -29,7 +33,7 @@ export class PicoDomEventInstance
|
|
|
29
33
|
* @param {any} [options] Listener options
|
|
30
34
|
* @returns {PicoDom} Current instance
|
|
31
35
|
*/
|
|
32
|
-
bind(el, event, cb, selector = null, pause = false, options = {})
|
|
36
|
+
bind(el : any, event : string, cb : Function, selector : string = null, pause : boolean = false, options : any = {}) : PicoDom
|
|
33
37
|
{
|
|
34
38
|
if ( Mix.isPrim(options) ) {
|
|
35
39
|
options = { id: options };
|
|
@@ -41,7 +45,7 @@ export class PicoDomEventInstance
|
|
|
41
45
|
|
|
42
46
|
el.addEventListener(event, cb, options);
|
|
43
47
|
|
|
44
|
-
return this;
|
|
48
|
+
return <PicoDom> <unknown> this;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
/**
|
|
@@ -49,13 +53,13 @@ export class PicoDomEventInstance
|
|
|
49
53
|
*
|
|
50
54
|
* @example Dom.unbind(el, "click")
|
|
51
55
|
*
|
|
52
|
-
* @param {
|
|
56
|
+
* @param {any} el Target element
|
|
53
57
|
* @param {string} event Event name
|
|
54
58
|
* @param {string} [selector] Event selector
|
|
55
59
|
* @param {any} [options] Listener options
|
|
56
60
|
* @returns {PicoDom} Current instance
|
|
57
61
|
*/
|
|
58
|
-
unbind(el, event, selector = null, options = {})
|
|
62
|
+
unbind(el : any, event : string, selector : string = null, options : any = {}) : PicoDom
|
|
59
63
|
{
|
|
60
64
|
if ( Mix.isPrim(options) ) {
|
|
61
65
|
options = { id: options };
|
|
@@ -66,20 +70,20 @@ export class PicoDomEventInstance
|
|
|
66
70
|
});
|
|
67
71
|
|
|
68
72
|
if ( indexes.length === 0 ) {
|
|
69
|
-
return;
|
|
73
|
+
return <PicoDom> <unknown> this;
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
let args = (val) => {
|
|
76
|
+
let args = (val : any) => {
|
|
73
77
|
return [event, val.cb, val.options];
|
|
74
78
|
};
|
|
75
79
|
|
|
76
|
-
Arr.each(indexes.reverse(), (index) => {
|
|
80
|
+
Arr.each(indexes.reverse(), (index : any) => {
|
|
77
81
|
el.removeEventListener(...args(Dom.$events[index]));
|
|
78
82
|
});
|
|
79
83
|
|
|
80
84
|
Arr.splices(Dom.$events, indexes);
|
|
81
85
|
|
|
82
|
-
return this;
|
|
86
|
+
return <PicoDom> <unknown> this;
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
/**
|
|
@@ -88,32 +92,36 @@ export class PicoDomEventInstance
|
|
|
88
92
|
* @example Dom.find("div").on("click", cb)
|
|
89
93
|
*
|
|
90
94
|
* @param {any} event Event name
|
|
91
|
-
* @param {
|
|
95
|
+
* @param {Function} cb Callback fn
|
|
92
96
|
* @param {any} [options] Listener options
|
|
93
97
|
* @param {boolean} [pause] Pause listener
|
|
94
98
|
* @param {string} [selector] Event selector
|
|
95
99
|
* @returns {PicoDom} Current instance
|
|
96
100
|
*/
|
|
97
|
-
on(event, cb, options = {}, pause = false, selector = null)
|
|
101
|
+
on(event : any, cb : Function, options : any = {}, pause : boolean = false, selector : string = null) : PicoDom
|
|
98
102
|
{
|
|
99
103
|
if ( Mix.isPrim(options) ) {
|
|
100
104
|
options = { id: options };
|
|
101
105
|
}
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
const args = [
|
|
108
|
+
cb, options, pause, selector
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
if ( Mix.isArr(event) ) {
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
return (Arr.each(event, (e : any) => this.on(e, ...args)), this);
|
|
114
|
+
}
|
|
107
115
|
|
|
108
|
-
let fn = (e) => {
|
|
116
|
+
let fn = (e : any) => {
|
|
109
117
|
cb.call(e.target, e, e.target);
|
|
110
118
|
};
|
|
111
119
|
|
|
112
|
-
this.each((el) => {
|
|
120
|
+
this.each((el : any) => {
|
|
113
121
|
this.bind(el, event, fn, selector, pause, options);
|
|
114
122
|
});
|
|
115
123
|
|
|
116
|
-
return this;
|
|
124
|
+
return <PicoDom> <unknown> this;
|
|
117
125
|
}
|
|
118
126
|
|
|
119
127
|
/**
|
|
@@ -122,30 +130,34 @@ export class PicoDomEventInstance
|
|
|
122
130
|
* @example Dom.find("div").off("click")
|
|
123
131
|
*
|
|
124
132
|
* @param {any} event Event name
|
|
125
|
-
* @param {
|
|
133
|
+
* @param {any} [selector] Event selector
|
|
126
134
|
* @param {any} [options] Listener options
|
|
127
135
|
* @returns {PicoDom} Current instance
|
|
128
136
|
*/
|
|
129
|
-
off(event, selector = null, options = {})
|
|
137
|
+
off(event : any, selector : string = null, options : any = {}) : PicoDom
|
|
130
138
|
{
|
|
131
139
|
if ( Mix.isPrim(options) ) {
|
|
132
140
|
options = { id: options };
|
|
133
141
|
}
|
|
134
142
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
143
|
+
const args = [
|
|
144
|
+
selector, options
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
if ( Mix.isArr(event) ) {
|
|
148
|
+
// @ts-ignore
|
|
149
|
+
return (Arr.each(event, (e : any) => this.off(e, ...args)), this);
|
|
150
|
+
}
|
|
139
151
|
|
|
140
152
|
if ( Mix.isObj(selector) ) {
|
|
141
153
|
(options = selector, selector = null);
|
|
142
154
|
}
|
|
143
155
|
|
|
144
|
-
this.each((el) => {
|
|
156
|
+
this.each((el : any) => {
|
|
145
157
|
this.unbind(el, event, selector, options);
|
|
146
158
|
});
|
|
147
159
|
|
|
148
|
-
return this;
|
|
160
|
+
return <PicoDom> <unknown> this;
|
|
149
161
|
}
|
|
150
162
|
|
|
151
163
|
/**
|
|
@@ -156,17 +168,17 @@ export class PicoDomEventInstance
|
|
|
156
168
|
* @param {any} [options] Listener options
|
|
157
169
|
* @returns {PicoDom} Current instance
|
|
158
170
|
*/
|
|
159
|
-
optoff(options = {})
|
|
171
|
+
optoff(options : any = {}) : PicoDom
|
|
160
172
|
{
|
|
161
173
|
Run.async(() => {
|
|
162
174
|
Arr.filterRemove(Dom.$events, { options });
|
|
163
175
|
});
|
|
164
176
|
|
|
165
|
-
this.each((el) => {
|
|
177
|
+
this.each((el : any) => {
|
|
166
178
|
el && el.removeAllListeners();
|
|
167
179
|
});
|
|
168
180
|
|
|
169
|
-
return this;
|
|
181
|
+
return <PicoDom> <unknown> this;
|
|
170
182
|
}
|
|
171
183
|
|
|
172
184
|
/**
|
|
@@ -175,19 +187,20 @@ export class PicoDomEventInstance
|
|
|
175
187
|
* @example Dom.find("div").once("click", cb)
|
|
176
188
|
*
|
|
177
189
|
* @param {any} event Event name
|
|
178
|
-
* @param {
|
|
190
|
+
* @param {Function} cb Callback fn
|
|
179
191
|
* @param {any} [options] Listener options
|
|
180
192
|
* @returns {PicoDom} Current instance
|
|
181
193
|
*/
|
|
182
|
-
once(event, cb, options = {})
|
|
194
|
+
once(event : any, cb : Function, options : any = {}) : PicoDom
|
|
183
195
|
{
|
|
184
196
|
options.id = Hash.make(24);
|
|
185
197
|
|
|
186
198
|
this.on(event, (e) => {
|
|
187
|
-
cb(e);
|
|
199
|
+
cb(e);
|
|
200
|
+
this.off(event, options);
|
|
188
201
|
}, options);
|
|
189
202
|
|
|
190
|
-
return this;
|
|
203
|
+
return <PicoDom> <unknown> this;
|
|
191
204
|
}
|
|
192
205
|
|
|
193
206
|
/**
|
|
@@ -197,14 +210,14 @@ export class PicoDomEventInstance
|
|
|
197
210
|
*
|
|
198
211
|
* @param {any} event Event name
|
|
199
212
|
* @param {string} selector Event selector
|
|
200
|
-
* @param {
|
|
213
|
+
* @param {Function} cb Callback fn
|
|
201
214
|
* @param {any} [options] Listener options
|
|
202
215
|
* @param {boolean} [pause] Pause listener
|
|
203
216
|
* @returns {PicoDom} Current instance
|
|
204
217
|
*/
|
|
205
|
-
live(event, selector, cb, options = {}, pause = false)
|
|
218
|
+
live(event : any, selector : string, cb : Function, options : any = {}, pause : boolean = false) : PicoDom
|
|
206
219
|
{
|
|
207
|
-
let fn = function (event) {
|
|
220
|
+
let fn = function (event : any) {
|
|
208
221
|
|
|
209
222
|
let target = Dom.getNodeEvent(selector, event);
|
|
210
223
|
|
|
@@ -217,7 +230,7 @@ export class PicoDomEventInstance
|
|
|
217
230
|
|
|
218
231
|
this.on(event, fn, options, pause, selector);
|
|
219
232
|
|
|
220
|
-
return this;
|
|
233
|
+
return <PicoDom> <unknown> this;
|
|
221
234
|
}
|
|
222
235
|
|
|
223
236
|
/**
|
|
@@ -229,18 +242,18 @@ export class PicoDomEventInstance
|
|
|
229
242
|
* @param {object} [detail] Event detail
|
|
230
243
|
* @returns {PicoDom} Current instance
|
|
231
244
|
*/
|
|
232
|
-
fire(event, detail = {})
|
|
245
|
+
fire(event : string, detail : any = {}) : PicoDom
|
|
233
246
|
{
|
|
234
247
|
let callback = new CustomEvent(event, { detail });
|
|
235
248
|
|
|
236
|
-
this.each((el) => {
|
|
249
|
+
this.each((el : any) => {
|
|
237
250
|
el.dispatchEvent(callback);
|
|
238
251
|
});
|
|
239
252
|
|
|
240
|
-
return this;
|
|
253
|
+
return <PicoDom> <unknown> this;
|
|
241
254
|
}
|
|
242
255
|
|
|
243
|
-
pointerdown(button = 1)
|
|
256
|
+
pointerdown(button : number = 1)
|
|
244
257
|
{
|
|
245
258
|
const rect = this.rect();
|
|
246
259
|
|
|
@@ -257,7 +270,7 @@ export class PicoDomEventInstance
|
|
|
257
270
|
clientX: x, clientY: y
|
|
258
271
|
});
|
|
259
272
|
|
|
260
|
-
this.each((el) => {
|
|
273
|
+
this.each((el : any) => {
|
|
261
274
|
el.dispatchEvent(event);
|
|
262
275
|
});
|
|
263
276
|
|
|
@@ -266,42 +279,25 @@ export class PicoDomEventInstance
|
|
|
266
279
|
|
|
267
280
|
}
|
|
268
281
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
*/
|
|
272
|
-
PicoDomEventInstance.prototype.one = function (...args) {
|
|
282
|
+
// @ts-ignore
|
|
283
|
+
PicoDomEvent.prototype.one = function (...args : Parameters<typeof PicoDomEvent.prototype.once>) {
|
|
273
284
|
console.warn('Dom.one() is deprecated, use Dom.once() instead.');
|
|
274
285
|
return this.once(...args);
|
|
275
286
|
};
|
|
276
287
|
|
|
277
|
-
|
|
278
|
-
|
|
288
|
+
// @ts-ignore
|
|
289
|
+
PicoDomEvent.prototype.delayed = function () {
|
|
279
290
|
console.error('Dom.delayed() is not implemented anymore.');
|
|
280
291
|
};
|
|
281
292
|
|
|
282
|
-
|
|
293
|
+
// @ts-ignore
|
|
294
|
+
PicoDomEvent.prototype.pause = function () {
|
|
283
295
|
console.error('Dom.pause() is not implemented anymore.');
|
|
284
296
|
};
|
|
285
297
|
|
|
286
|
-
|
|
298
|
+
// @ts-ignore
|
|
299
|
+
PicoDomEvent.prototype.unpause = function () {
|
|
287
300
|
console.error('Dom.unpause() is not implemented anymore.');
|
|
288
301
|
};
|
|
289
302
|
|
|
290
|
-
|
|
291
|
-
* @param {typeof PicoDom} self
|
|
292
|
-
* @returns {typeof PicoDom}
|
|
293
|
-
*/
|
|
294
|
-
export const PicoDomEventPlugin = function (self) {
|
|
295
|
-
|
|
296
|
-
Obj.each(Mix.class(PicoDomEventStatic), (fn, id) => {
|
|
297
|
-
self[id] = fn;
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
Obj.each(Mix.proto(PicoDomEventInstance), (fn, id) => {
|
|
301
|
-
self.prototype[id] = fn;
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
// self.init.push(PicoDomEventInstance.constructor);
|
|
305
|
-
|
|
306
|
-
return self;
|
|
307
|
-
}
|
|
303
|
+
export default PicoDomEvent;
|