solid-tiny-utils 0.3.0 → 0.4.0
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/README.md +0 -68
- package/dist/chunk-BGLY6NJK.js +111 -0
- package/dist/{chunk-WLQ64SAO.js → chunk-CSAKXWF3.js} +5 -1
- package/dist/{chunk-YJB637I2.js → chunk-HPKVQC7S.js} +4 -3
- package/dist/chunk-II6INKPZ.js +8 -0
- package/dist/chunk-KLRTXD4R.js +53 -0
- package/dist/chunk-OUAI75QC.js +55 -0
- package/dist/{chunk-RRYFZNKE.js → chunk-PBALVUKK.js} +1 -1
- package/dist/chunk-YXRZ2KMJ.js +0 -0
- package/dist/dom/css.js +4 -4
- package/dist/dom/index.js +4 -4
- package/dist/event/create-click-outside.js +7 -6
- package/dist/event/create-event-listener.d.ts +23 -0
- package/dist/event/create-event-listener.js +16 -0
- package/dist/event/index.d.ts +3 -0
- package/dist/event/index.js +16 -8
- package/dist/event/make-event-listener.d.ts +49 -0
- package/dist/event/make-event-listener.js +15 -0
- package/dist/fn/create-debounce.js +5 -6
- package/dist/fn/create-loop-exec.js +5 -6
- package/dist/fn/create-throttle.d.ts +6 -0
- package/dist/fn/create-throttle.js +14 -0
- package/dist/fn/index.d.ts +1 -0
- package/dist/fn/index.js +9 -12
- package/dist/index.d.ts +7 -1
- package/dist/index.js +39 -24
- package/dist/jsx/attrs.d.ts +22 -0
- package/dist/jsx/attrs.js +6 -0
- package/dist/jsx/index.d.ts +1 -0
- package/dist/jsx/index.js +7 -0
- package/dist/lodash/array.d.ts +5 -1
- package/dist/lodash/array.js +3 -1
- package/dist/lodash/index.d.ts +1 -1
- package/dist/lodash/index.js +16 -14
- package/dist/lodash/random.js +2 -2
- package/dist/reactive/access.js +4 -4
- package/dist/reactive/create-debounce-watch.d.ts +12 -0
- package/dist/reactive/create-debounce-watch.js +14 -0
- package/dist/reactive/index.d.ts +1 -0
- package/dist/reactive/index.js +8 -5
- package/dist/types/fn.d.ts +2 -1
- package/dist/types/fn.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -1
- package/package.json +1 -2
- package/dist/chunk-2BGAGVTR.js +0 -7
- package/dist/chunk-H6VUVMSF.js +0 -23
- package/dist/chunk-WY5G2PJM.js +0 -60
- /package/dist/{chunk-2BUPSB7O.js → chunk-AZAXMGEB.js} +0 -0
- /package/dist/{chunk-M53KPXWR.js → chunk-B6TZK2S5.js} +0 -0
- /package/dist/{chunk-ZZNAXGNU.js → chunk-SK6Y2YH6.js} +0 -0
package/README.md
CHANGED
|
@@ -7,71 +7,3 @@ Tiny utilities for SolidJS applications.
|
|
|
7
7
|
```bash
|
|
8
8
|
pnpm add solid-tiny-utils
|
|
9
9
|
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
import { access, createWatch, CreateLoopExec, isFn, isArray } from 'solid-tiny-utils';
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## API
|
|
18
|
-
|
|
19
|
-
### Reactive
|
|
20
|
-
|
|
21
|
-
#### `access(value)`
|
|
22
|
-
Safely access a value that might be an accessor function.
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
const value = access(maybeAccessor); // Returns the value directly or calls the accessor
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
#### `createWatch(targets, fn, options?)`
|
|
29
|
-
Create a watcher that runs when dependencies change.
|
|
30
|
-
|
|
31
|
-
```typescript
|
|
32
|
-
createWatch(() => signal(), (value) => {
|
|
33
|
-
console.log('Value changed:', value);
|
|
34
|
-
});
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### Functions
|
|
38
|
-
|
|
39
|
-
#### `CreateLoopExec(fn, delay)`
|
|
40
|
-
Execute a function in a loop with cleanup support.
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
CreateLoopExec(
|
|
44
|
-
async () => {
|
|
45
|
-
// Your async work here
|
|
46
|
-
},
|
|
47
|
-
1000 // Delay in milliseconds
|
|
48
|
-
);
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Type Guards
|
|
52
|
-
|
|
53
|
-
#### `isFn(value)`
|
|
54
|
-
Check if a value is a function.
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
if (isFn(value)) {
|
|
58
|
-
value(); // TypeScript knows it's a function
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
#### `isArray(value)`
|
|
63
|
-
Check if a value is an array.
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
if (isArray(value)) {
|
|
67
|
-
value.forEach(...); // TypeScript knows it's an array
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Types
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
type MaybeArray<T> = T | T[];
|
|
75
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
76
|
-
type MaybeAccessor<T> = T | Accessor<T>;
|
|
77
|
-
```
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
access
|
|
3
|
+
} from "./chunk-M5A3VVYI.js";
|
|
4
|
+
import {
|
|
5
|
+
createWatch
|
|
6
|
+
} from "./chunk-4L6FK7MF.js";
|
|
7
|
+
import {
|
|
8
|
+
isNumber
|
|
9
|
+
} from "./chunk-ZGYORUAX.js";
|
|
10
|
+
|
|
11
|
+
// src/fn/create-debounce.ts
|
|
12
|
+
import { onCleanup as onCleanup3 } from "solid-js";
|
|
13
|
+
|
|
14
|
+
// src/fn/create-loop-exec.ts
|
|
15
|
+
import { onCleanup } from "solid-js";
|
|
16
|
+
function createLoopExec(fn, delay) {
|
|
17
|
+
let shouldStop = false;
|
|
18
|
+
let isCleanedUp = false;
|
|
19
|
+
let timer;
|
|
20
|
+
const execFn = async () => {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
const d = access(delay);
|
|
23
|
+
if (shouldStop || !isNumber(d) || d < 0) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
await fn();
|
|
28
|
+
} finally {
|
|
29
|
+
timer = setTimeout(() => {
|
|
30
|
+
execFn();
|
|
31
|
+
}, d);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
createWatch(
|
|
35
|
+
() => access(delay),
|
|
36
|
+
() => {
|
|
37
|
+
execFn();
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
const stop = () => {
|
|
41
|
+
shouldStop = true;
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
};
|
|
44
|
+
const start = () => {
|
|
45
|
+
if (isCleanedUp) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
shouldStop = false;
|
|
49
|
+
execFn();
|
|
50
|
+
};
|
|
51
|
+
onCleanup(() => {
|
|
52
|
+
isCleanedUp = true;
|
|
53
|
+
stop();
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
stop,
|
|
57
|
+
start
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/fn/create-throttle.ts
|
|
62
|
+
import { onCleanup as onCleanup2 } from "solid-js";
|
|
63
|
+
function createThrottle(callback, delay) {
|
|
64
|
+
let timeoutId;
|
|
65
|
+
onCleanup2(() => {
|
|
66
|
+
clearTimeout(timeoutId);
|
|
67
|
+
});
|
|
68
|
+
const run = (...args) => {
|
|
69
|
+
if (timeoutId) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
timeoutId = setTimeout(() => {
|
|
73
|
+
callback(...args);
|
|
74
|
+
timeoutId = void 0;
|
|
75
|
+
}, access(delay));
|
|
76
|
+
};
|
|
77
|
+
return run;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/fn/index.ts
|
|
81
|
+
var noop = () => {
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/reactive/create-debounce-watch.ts
|
|
85
|
+
function createDebouncedWatch(targets, fn, opt) {
|
|
86
|
+
const debounceFn = createDebounce(fn, opt?.delay ?? 10);
|
|
87
|
+
createWatch(targets, debounceFn, opt);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/fn/create-debounce.ts
|
|
91
|
+
function createDebounce(callback, delay) {
|
|
92
|
+
let timeoutId;
|
|
93
|
+
onCleanup3(() => {
|
|
94
|
+
clearTimeout(timeoutId);
|
|
95
|
+
});
|
|
96
|
+
const run = (...args) => {
|
|
97
|
+
clearTimeout(timeoutId);
|
|
98
|
+
timeoutId = setTimeout(() => {
|
|
99
|
+
callback(...args);
|
|
100
|
+
}, access(delay));
|
|
101
|
+
};
|
|
102
|
+
return run;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
createDebounce,
|
|
107
|
+
createLoopExec,
|
|
108
|
+
createThrottle,
|
|
109
|
+
noop,
|
|
110
|
+
createDebouncedWatch
|
|
111
|
+
};
|
|
@@ -24,9 +24,13 @@ function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
|
|
|
24
24
|
var list = (startOrLength, end, valueOrMapper, step) => {
|
|
25
25
|
return Array.from(range(startOrLength, end, valueOrMapper, step));
|
|
26
26
|
};
|
|
27
|
+
function clearArray(arr) {
|
|
28
|
+
arr.length = 0;
|
|
29
|
+
}
|
|
27
30
|
|
|
28
31
|
export {
|
|
29
32
|
iterate,
|
|
30
33
|
range,
|
|
31
|
-
list
|
|
34
|
+
list,
|
|
35
|
+
clearArray
|
|
32
36
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
makeEventListener
|
|
3
|
+
} from "./chunk-OUAI75QC.js";
|
|
1
4
|
import {
|
|
2
5
|
access
|
|
3
6
|
} from "./chunk-M5A3VVYI.js";
|
|
4
7
|
|
|
5
8
|
// src/event/create-click-outside.ts
|
|
6
|
-
import { makeEventListener } from "@solid-primitives/event-listener";
|
|
7
9
|
function createClickOutside(target, handler, options) {
|
|
8
10
|
const listener = (e) => {
|
|
9
11
|
const el = access(target);
|
|
@@ -20,8 +22,7 @@ function createClickOutside(target, handler, options) {
|
|
|
20
22
|
}
|
|
21
23
|
handler(e);
|
|
22
24
|
};
|
|
23
|
-
makeEventListener(document, "click", listener);
|
|
24
|
-
makeEventListener(document, "touchstart", listener);
|
|
25
|
+
makeEventListener(document, ["click", "touchstart"], listener);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
makeEventListener
|
|
3
|
+
} from "./chunk-OUAI75QC.js";
|
|
4
|
+
import {
|
|
5
|
+
noop
|
|
6
|
+
} from "./chunk-BGLY6NJK.js";
|
|
7
|
+
import {
|
|
8
|
+
access
|
|
9
|
+
} from "./chunk-M5A3VVYI.js";
|
|
10
|
+
import {
|
|
11
|
+
createWatch
|
|
12
|
+
} from "./chunk-4L6FK7MF.js";
|
|
13
|
+
import {
|
|
14
|
+
clearArray
|
|
15
|
+
} from "./chunk-CSAKXWF3.js";
|
|
16
|
+
import {
|
|
17
|
+
isArray
|
|
18
|
+
} from "./chunk-ZGYORUAX.js";
|
|
19
|
+
|
|
20
|
+
// src/event/create-event-listener.ts
|
|
21
|
+
import { onCleanup } from "solid-js";
|
|
22
|
+
function createEventListener(...args) {
|
|
23
|
+
const target = args[0];
|
|
24
|
+
const events = args[1];
|
|
25
|
+
let listeners = args[2];
|
|
26
|
+
const options = args[3] ?? noop;
|
|
27
|
+
if (!isArray(listeners)) {
|
|
28
|
+
listeners = [listeners];
|
|
29
|
+
}
|
|
30
|
+
const cleanups = [];
|
|
31
|
+
const cleanup = () => {
|
|
32
|
+
for (const c of cleanups) {
|
|
33
|
+
c();
|
|
34
|
+
}
|
|
35
|
+
clearArray(cleanups);
|
|
36
|
+
};
|
|
37
|
+
createWatch(
|
|
38
|
+
() => [access(target), access(events), access(options)],
|
|
39
|
+
([tars, evs, opts]) => {
|
|
40
|
+
cleanup();
|
|
41
|
+
if (!(tars && evs)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
cleanups.push(makeEventListener(tars, evs, listeners, opts));
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
onCleanup(cleanup);
|
|
48
|
+
return cleanup;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
createEventListener
|
|
53
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
noop
|
|
3
|
+
} from "./chunk-BGLY6NJK.js";
|
|
4
|
+
import {
|
|
5
|
+
clearArray
|
|
6
|
+
} from "./chunk-CSAKXWF3.js";
|
|
7
|
+
import {
|
|
8
|
+
isArray
|
|
9
|
+
} from "./chunk-ZGYORUAX.js";
|
|
10
|
+
|
|
11
|
+
// src/event/make-event-listener.ts
|
|
12
|
+
import { onCleanup } from "solid-js";
|
|
13
|
+
function makeEventListener(...args) {
|
|
14
|
+
let target;
|
|
15
|
+
let events;
|
|
16
|
+
let listeners;
|
|
17
|
+
let options;
|
|
18
|
+
if (typeof args[0] === "string" || isArray(args[0])) {
|
|
19
|
+
[events, listeners, options] = args;
|
|
20
|
+
target = window;
|
|
21
|
+
} else {
|
|
22
|
+
[target, events, listeners, options] = args;
|
|
23
|
+
}
|
|
24
|
+
if (!target) {
|
|
25
|
+
return noop;
|
|
26
|
+
}
|
|
27
|
+
if (!isArray(events)) {
|
|
28
|
+
events = [events];
|
|
29
|
+
}
|
|
30
|
+
if (!isArray(listeners)) {
|
|
31
|
+
listeners = [listeners];
|
|
32
|
+
}
|
|
33
|
+
const cleanups = [];
|
|
34
|
+
const cleanup = () => {
|
|
35
|
+
for (const c of cleanups) {
|
|
36
|
+
c();
|
|
37
|
+
}
|
|
38
|
+
clearArray(cleanups);
|
|
39
|
+
};
|
|
40
|
+
const register = (el, event, listener, opts) => {
|
|
41
|
+
el.addEventListener(event, listener, opts);
|
|
42
|
+
return () => el.removeEventListener(event, listener, opts);
|
|
43
|
+
};
|
|
44
|
+
cleanups.push(
|
|
45
|
+
...events.flatMap(
|
|
46
|
+
(event) => listeners.map((listener) => register(target, event, listener, options))
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
onCleanup(cleanup);
|
|
50
|
+
return cleanup;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
makeEventListener
|
|
55
|
+
};
|
|
File without changes
|
package/dist/dom/css.js
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
mountStyle
|
|
3
3
|
} from "../chunk-KVG6TCSE.js";
|
|
4
4
|
import "../chunk-OECLQ3OT.js";
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-RRYFZNKE.js";
|
|
7
|
-
import "../chunk-WLQ64SAO.js";
|
|
8
|
-
import "../chunk-ZGYORUAX.js";
|
|
5
|
+
import "../chunk-PBALVUKK.js";
|
|
9
6
|
import "../chunk-PNR5G432.js";
|
|
7
|
+
import "../chunk-CSAKXWF3.js";
|
|
8
|
+
import "../chunk-ZGYORUAX.js";
|
|
9
|
+
import "../chunk-KFWZFQMB.js";
|
|
10
10
|
export {
|
|
11
11
|
mountStyle
|
|
12
12
|
};
|
package/dist/dom/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
mountStyle
|
|
4
4
|
} from "../chunk-KVG6TCSE.js";
|
|
5
5
|
import "../chunk-OECLQ3OT.js";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-RRYFZNKE.js";
|
|
8
|
-
import "../chunk-WLQ64SAO.js";
|
|
9
|
-
import "../chunk-ZGYORUAX.js";
|
|
6
|
+
import "../chunk-PBALVUKK.js";
|
|
10
7
|
import "../chunk-PNR5G432.js";
|
|
8
|
+
import "../chunk-CSAKXWF3.js";
|
|
9
|
+
import "../chunk-ZGYORUAX.js";
|
|
10
|
+
import "../chunk-KFWZFQMB.js";
|
|
11
11
|
export {
|
|
12
12
|
mountStyle
|
|
13
13
|
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createClickOutside
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-HPKVQC7S.js";
|
|
4
|
+
import "../chunk-OUAI75QC.js";
|
|
5
|
+
import "../chunk-BGLY6NJK.js";
|
|
5
6
|
import "../chunk-M5A3VVYI.js";
|
|
6
7
|
import "../chunk-4L6FK7MF.js";
|
|
7
8
|
import "../chunk-OECLQ3OT.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-RRYFZNKE.js";
|
|
10
|
-
import "../chunk-WLQ64SAO.js";
|
|
11
|
-
import "../chunk-ZGYORUAX.js";
|
|
9
|
+
import "../chunk-PBALVUKK.js";
|
|
12
10
|
import "../chunk-PNR5G432.js";
|
|
11
|
+
import "../chunk-CSAKXWF3.js";
|
|
12
|
+
import "../chunk-ZGYORUAX.js";
|
|
13
|
+
import "../chunk-KFWZFQMB.js";
|
|
13
14
|
export {
|
|
14
15
|
createClickOutside
|
|
15
16
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Fn } from '../types/fn.js';
|
|
2
|
+
import { MaybeAccessor, MaybeArray } from '../types/maybe.js';
|
|
3
|
+
import { WindowEventName, DocumentEventName, GeneralEventListener } from './make-event-listener.js';
|
|
4
|
+
import 'solid-js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Overload 2: Explicitly Window target
|
|
8
|
+
*/
|
|
9
|
+
declare function createEventListener<E extends WindowEventName>(target: MaybeAccessor<Window | undefined | null>, event: MaybeAccessor<MaybeArray<E>>, listener: MaybeArray<(this: Window, ev: WindowEventMap[E]) => void>, options?: MaybeAccessor<boolean | AddEventListenerOptions | undefined>): Fn;
|
|
10
|
+
/**
|
|
11
|
+
* Overload 3: Explicitly Document target
|
|
12
|
+
*/
|
|
13
|
+
declare function createEventListener<E extends DocumentEventName>(target: MaybeAccessor<DocumentOrShadowRoot | undefined | null>, event: MaybeAccessor<MaybeArray<E>>, listener: MaybeArray<(this: Document, ev: DocumentEventMap[E]) => void>, options?: MaybeAccessor<boolean | AddEventListenerOptions | undefined>): Fn;
|
|
14
|
+
/**
|
|
15
|
+
* Overload 4: Explicitly HTMLElement target
|
|
16
|
+
*/
|
|
17
|
+
declare function createEventListener<T extends HTMLElement, E extends keyof HTMLElementEventMap>(target: MaybeAccessor<T | undefined | null>, event: MaybeAccessor<MaybeArray<E>>, listener: MaybeArray<(this: T, ev: HTMLElementEventMap[E]) => void>, options?: MaybeAccessor<boolean | AddEventListenerOptions | undefined>): Fn;
|
|
18
|
+
/**
|
|
19
|
+
* Overload 6: Custom event target fallback
|
|
20
|
+
*/
|
|
21
|
+
declare function createEventListener<EventType = Event>(target: MaybeAccessor<EventTarget | undefined | null>, event: MaybeAccessor<MaybeArray<string>>, listener: MaybeArray<GeneralEventListener<EventType>>, options?: MaybeAccessor<boolean | AddEventListenerOptions | undefined>): Fn;
|
|
22
|
+
|
|
23
|
+
export { createEventListener };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createEventListener
|
|
3
|
+
} from "../chunk-KLRTXD4R.js";
|
|
4
|
+
import "../chunk-OUAI75QC.js";
|
|
5
|
+
import "../chunk-BGLY6NJK.js";
|
|
6
|
+
import "../chunk-M5A3VVYI.js";
|
|
7
|
+
import "../chunk-4L6FK7MF.js";
|
|
8
|
+
import "../chunk-OECLQ3OT.js";
|
|
9
|
+
import "../chunk-PBALVUKK.js";
|
|
10
|
+
import "../chunk-PNR5G432.js";
|
|
11
|
+
import "../chunk-CSAKXWF3.js";
|
|
12
|
+
import "../chunk-ZGYORUAX.js";
|
|
13
|
+
import "../chunk-KFWZFQMB.js";
|
|
14
|
+
export {
|
|
15
|
+
createEventListener
|
|
16
|
+
};
|
package/dist/event/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { createClickOutside } from './create-click-outside.js';
|
|
2
|
+
export { createEventListener } from './create-event-listener.js';
|
|
3
|
+
export { DocumentEventName, GeneralEventListener, WindowEventName, makeEventListener } from './make-event-listener.js';
|
|
2
4
|
import '../types/maybe.js';
|
|
3
5
|
import 'solid-js';
|
|
6
|
+
import '../types/fn.js';
|
package/dist/event/index.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-B6TZK2S5.js";
|
|
2
2
|
import {
|
|
3
3
|
createClickOutside
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import
|
|
4
|
+
} from "../chunk-HPKVQC7S.js";
|
|
5
|
+
import {
|
|
6
|
+
createEventListener
|
|
7
|
+
} from "../chunk-KLRTXD4R.js";
|
|
8
|
+
import {
|
|
9
|
+
makeEventListener
|
|
10
|
+
} from "../chunk-OUAI75QC.js";
|
|
11
|
+
import "../chunk-BGLY6NJK.js";
|
|
6
12
|
import "../chunk-M5A3VVYI.js";
|
|
7
13
|
import "../chunk-4L6FK7MF.js";
|
|
8
14
|
import "../chunk-OECLQ3OT.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-RRYFZNKE.js";
|
|
11
|
-
import "../chunk-WLQ64SAO.js";
|
|
12
|
-
import "../chunk-ZGYORUAX.js";
|
|
15
|
+
import "../chunk-PBALVUKK.js";
|
|
13
16
|
import "../chunk-PNR5G432.js";
|
|
17
|
+
import "../chunk-CSAKXWF3.js";
|
|
18
|
+
import "../chunk-ZGYORUAX.js";
|
|
19
|
+
import "../chunk-KFWZFQMB.js";
|
|
14
20
|
export {
|
|
15
|
-
createClickOutside
|
|
21
|
+
createClickOutside,
|
|
22
|
+
createEventListener,
|
|
23
|
+
makeEventListener
|
|
16
24
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Fn } from '../types/fn.js';
|
|
2
|
+
import { MaybeArray } from '../types/maybe.js';
|
|
3
|
+
import 'solid-js';
|
|
4
|
+
|
|
5
|
+
interface InferEventTarget<Events> {
|
|
6
|
+
addEventListener: (event: Events, fn?: any, options?: any) => any;
|
|
7
|
+
removeEventListener: (event: Events, fn?: any, options?: any) => any;
|
|
8
|
+
}
|
|
9
|
+
type WindowEventName = keyof WindowEventMap;
|
|
10
|
+
type DocumentEventName = keyof DocumentEventMap;
|
|
11
|
+
type GeneralEventListener<E = Event> = (evt: E) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Overload 1: Omitted Window target
|
|
14
|
+
*/
|
|
15
|
+
declare function makeEventListener<E extends WindowEventName>(event: MaybeArray<E>, listener: MaybeArray<(this: Window, ev: WindowEventMap[E]) => void>, options?: boolean | AddEventListenerOptions): Fn;
|
|
16
|
+
/**
|
|
17
|
+
* Overload 2: Explicitly Window target
|
|
18
|
+
*/
|
|
19
|
+
declare function makeEventListener<E extends WindowEventName>(target: Window, event: E, listener: MaybeArray<(this: Window, ev: WindowEventMap[E]) => void>, options?: boolean | AddEventListenerOptions): Fn;
|
|
20
|
+
/**
|
|
21
|
+
* Overload 2.1: Explicitly Window target
|
|
22
|
+
*/
|
|
23
|
+
declare function makeEventListener<EventType = Event>(target: Window, event: WindowEventName[], listener: MaybeArray<(this: Window, ev: EventType) => void>, options?: boolean | AddEventListenerOptions): Fn;
|
|
24
|
+
/**
|
|
25
|
+
* Overload 3: Explicitly Document target
|
|
26
|
+
*/
|
|
27
|
+
declare function makeEventListener<E extends DocumentEventName>(target: DocumentOrShadowRoot, event: E, listener: MaybeArray<(this: Document, ev: DocumentEventMap[E]) => void>, options?: boolean | AddEventListenerOptions): Fn;
|
|
28
|
+
/**
|
|
29
|
+
* Overload 3.1: Explicitly Document target
|
|
30
|
+
*/
|
|
31
|
+
declare function makeEventListener<EventType = Event>(target: DocumentOrShadowRoot, event: DocumentEventName[], listener: MaybeArray<(this: Document, ev: EventType) => void>, options?: boolean | AddEventListenerOptions): Fn;
|
|
32
|
+
/**
|
|
33
|
+
* Overload 4: Explicitly HTMLElement target
|
|
34
|
+
*/
|
|
35
|
+
declare function makeEventListener<T extends HTMLElement, E extends keyof HTMLElementEventMap>(target: T, event: E | (keyof HTMLElementEventMap)[], listener: MaybeArray<(this: T, ev: HTMLElementEventMap[E]) => void>, options?: boolean | AddEventListenerOptions): Fn;
|
|
36
|
+
/**
|
|
37
|
+
* Overload 4.1: Explicitly HTMLElement target
|
|
38
|
+
*/
|
|
39
|
+
declare function makeEventListener<T extends HTMLElement, EventType = Event>(target: T, event: (keyof HTMLElementEventMap)[], listener: MaybeArray<(this: T, ev: EventType) => void>, options?: boolean | AddEventListenerOptions): Fn;
|
|
40
|
+
/**
|
|
41
|
+
* Overload 5: Custom event target with event type infer
|
|
42
|
+
*/
|
|
43
|
+
declare function makeEventListener<Names extends string, EventType = Event>(target: InferEventTarget<Names>, event: MaybeArray<Names>, listener: MaybeArray<GeneralEventListener<EventType>>, options?: boolean | AddEventListenerOptions): Fn;
|
|
44
|
+
/**
|
|
45
|
+
* Overload 6: Custom event target fallback
|
|
46
|
+
*/
|
|
47
|
+
declare function makeEventListener<EventType = Event>(target: EventTarget, event: MaybeArray<string>, listener: MaybeArray<GeneralEventListener<EventType>>, options?: boolean | AddEventListenerOptions): Fn;
|
|
48
|
+
|
|
49
|
+
export { type DocumentEventName, type GeneralEventListener, type WindowEventName, makeEventListener };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
makeEventListener
|
|
3
|
+
} from "../chunk-OUAI75QC.js";
|
|
4
|
+
import "../chunk-BGLY6NJK.js";
|
|
5
|
+
import "../chunk-M5A3VVYI.js";
|
|
6
|
+
import "../chunk-4L6FK7MF.js";
|
|
7
|
+
import "../chunk-OECLQ3OT.js";
|
|
8
|
+
import "../chunk-PBALVUKK.js";
|
|
9
|
+
import "../chunk-PNR5G432.js";
|
|
10
|
+
import "../chunk-CSAKXWF3.js";
|
|
11
|
+
import "../chunk-ZGYORUAX.js";
|
|
12
|
+
import "../chunk-KFWZFQMB.js";
|
|
13
|
+
export {
|
|
14
|
+
makeEventListener
|
|
15
|
+
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDebounce
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-ZZNAXGNU.js";
|
|
3
|
+
} from "../chunk-BGLY6NJK.js";
|
|
5
4
|
import "../chunk-M5A3VVYI.js";
|
|
6
5
|
import "../chunk-4L6FK7MF.js";
|
|
7
6
|
import "../chunk-OECLQ3OT.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-RRYFZNKE.js";
|
|
10
|
-
import "../chunk-WLQ64SAO.js";
|
|
11
|
-
import "../chunk-ZGYORUAX.js";
|
|
7
|
+
import "../chunk-PBALVUKK.js";
|
|
12
8
|
import "../chunk-PNR5G432.js";
|
|
9
|
+
import "../chunk-CSAKXWF3.js";
|
|
10
|
+
import "../chunk-ZGYORUAX.js";
|
|
11
|
+
import "../chunk-KFWZFQMB.js";
|
|
13
12
|
export {
|
|
14
13
|
createDebounce
|
|
15
14
|
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLoopExec
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-ZZNAXGNU.js";
|
|
3
|
+
} from "../chunk-BGLY6NJK.js";
|
|
5
4
|
import "../chunk-M5A3VVYI.js";
|
|
6
5
|
import "../chunk-4L6FK7MF.js";
|
|
7
6
|
import "../chunk-OECLQ3OT.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-RRYFZNKE.js";
|
|
10
|
-
import "../chunk-WLQ64SAO.js";
|
|
11
|
-
import "../chunk-ZGYORUAX.js";
|
|
7
|
+
import "../chunk-PBALVUKK.js";
|
|
12
8
|
import "../chunk-PNR5G432.js";
|
|
9
|
+
import "../chunk-CSAKXWF3.js";
|
|
10
|
+
import "../chunk-ZGYORUAX.js";
|
|
11
|
+
import "../chunk-KFWZFQMB.js";
|
|
13
12
|
export {
|
|
14
13
|
createLoopExec
|
|
15
14
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createThrottle
|
|
3
|
+
} from "../chunk-BGLY6NJK.js";
|
|
4
|
+
import "../chunk-M5A3VVYI.js";
|
|
5
|
+
import "../chunk-4L6FK7MF.js";
|
|
6
|
+
import "../chunk-OECLQ3OT.js";
|
|
7
|
+
import "../chunk-PBALVUKK.js";
|
|
8
|
+
import "../chunk-PNR5G432.js";
|
|
9
|
+
import "../chunk-CSAKXWF3.js";
|
|
10
|
+
import "../chunk-ZGYORUAX.js";
|
|
11
|
+
import "../chunk-KFWZFQMB.js";
|
|
12
|
+
export {
|
|
13
|
+
createThrottle
|
|
14
|
+
};
|
package/dist/fn/index.d.ts
CHANGED
package/dist/fn/index.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
+
createDebounce,
|
|
3
|
+
createLoopExec,
|
|
4
|
+
createThrottle,
|
|
2
5
|
noop
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import {
|
|
5
|
-
createDebounce
|
|
6
|
-
} from "../chunk-H6VUVMSF.js";
|
|
7
|
-
import {
|
|
8
|
-
createLoopExec
|
|
9
|
-
} from "../chunk-WY5G2PJM.js";
|
|
10
|
-
import "../chunk-ZZNAXGNU.js";
|
|
6
|
+
} from "../chunk-BGLY6NJK.js";
|
|
11
7
|
import "../chunk-M5A3VVYI.js";
|
|
12
8
|
import "../chunk-4L6FK7MF.js";
|
|
13
9
|
import "../chunk-OECLQ3OT.js";
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-RRYFZNKE.js";
|
|
16
|
-
import "../chunk-WLQ64SAO.js";
|
|
17
|
-
import "../chunk-ZGYORUAX.js";
|
|
10
|
+
import "../chunk-PBALVUKK.js";
|
|
18
11
|
import "../chunk-PNR5G432.js";
|
|
12
|
+
import "../chunk-CSAKXWF3.js";
|
|
13
|
+
import "../chunk-ZGYORUAX.js";
|
|
14
|
+
import "../chunk-KFWZFQMB.js";
|
|
19
15
|
export {
|
|
20
16
|
createDebounce,
|
|
21
17
|
createLoopExec,
|
|
18
|
+
createThrottle,
|
|
22
19
|
noop
|
|
23
20
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
export { mountStyle } from './dom/css.js';
|
|
2
2
|
export { createClickOutside } from './event/create-click-outside.js';
|
|
3
|
+
export { createEventListener } from './event/create-event-listener.js';
|
|
4
|
+
export { DocumentEventName, GeneralEventListener, WindowEventName, makeEventListener } from './event/make-event-listener.js';
|
|
3
5
|
export { noop } from './fn/index.js';
|
|
4
|
-
export {
|
|
6
|
+
export { dataIf } from './jsx/attrs.js';
|
|
7
|
+
export { clearArray, iterate, list, range } from './lodash/array.js';
|
|
5
8
|
export { sleep } from './lodash/async.js';
|
|
6
9
|
export { isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol } from './lodash/is.js';
|
|
7
10
|
export { draw, random, shuffle, uid } from './lodash/random.js';
|
|
8
11
|
export { camel, capitalize, dash, pascal, snake, template, title, trim } from './lodash/str.js';
|
|
9
12
|
export { access } from './reactive/access.js';
|
|
13
|
+
export { createDebouncedWatch } from './reactive/create-debounce-watch.js';
|
|
10
14
|
export { createWatch } from './reactive/create-watch.js';
|
|
15
|
+
export { AnyFn, Fn } from './types/fn.js';
|
|
11
16
|
export { MaybeAccessor, MaybeArray, MaybePromise } from './types/maybe.js';
|
|
12
17
|
export { createDebounce } from './fn/create-debounce.js';
|
|
13
18
|
export { createLoopExec } from './fn/create-loop-exec.js';
|
|
19
|
+
export { createThrottle } from './fn/create-throttle.js';
|
|
14
20
|
import 'solid-js';
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-SK6Y2YH6.js";
|
|
2
2
|
import "./chunk-EZML2DEC.js";
|
|
3
|
+
import "./chunk-AZAXMGEB.js";
|
|
4
|
+
import "./chunk-YXRZ2KMJ.js";
|
|
5
|
+
import {
|
|
6
|
+
dataIf
|
|
7
|
+
} from "./chunk-II6INKPZ.js";
|
|
3
8
|
import "./chunk-FFBJP5FE.js";
|
|
4
9
|
import {
|
|
5
10
|
mountStyle
|
|
6
11
|
} from "./chunk-KVG6TCSE.js";
|
|
7
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-B6TZK2S5.js";
|
|
8
13
|
import {
|
|
9
14
|
createClickOutside
|
|
10
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-HPKVQC7S.js";
|
|
11
16
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
17
|
+
createEventListener
|
|
18
|
+
} from "./chunk-KLRTXD4R.js";
|
|
14
19
|
import {
|
|
15
|
-
|
|
16
|
-
} from "./chunk-
|
|
20
|
+
makeEventListener
|
|
21
|
+
} from "./chunk-OUAI75QC.js";
|
|
17
22
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
createDebounce,
|
|
24
|
+
createDebouncedWatch,
|
|
25
|
+
createLoopExec,
|
|
26
|
+
createThrottle,
|
|
27
|
+
noop
|
|
28
|
+
} from "./chunk-BGLY6NJK.js";
|
|
21
29
|
import {
|
|
22
30
|
access
|
|
23
31
|
} from "./chunk-M5A3VVYI.js";
|
|
@@ -25,20 +33,28 @@ import {
|
|
|
25
33
|
createWatch
|
|
26
34
|
} from "./chunk-4L6FK7MF.js";
|
|
27
35
|
import "./chunk-OECLQ3OT.js";
|
|
28
|
-
import {
|
|
29
|
-
sleep
|
|
30
|
-
} from "./chunk-KFWZFQMB.js";
|
|
31
36
|
import {
|
|
32
37
|
draw,
|
|
33
38
|
random,
|
|
34
39
|
shuffle,
|
|
35
40
|
uid
|
|
36
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-PBALVUKK.js";
|
|
37
42
|
import {
|
|
43
|
+
camel,
|
|
44
|
+
capitalize,
|
|
45
|
+
dash,
|
|
46
|
+
pascal,
|
|
47
|
+
snake,
|
|
48
|
+
template,
|
|
49
|
+
title,
|
|
50
|
+
trim
|
|
51
|
+
} from "./chunk-PNR5G432.js";
|
|
52
|
+
import {
|
|
53
|
+
clearArray,
|
|
38
54
|
iterate,
|
|
39
55
|
list,
|
|
40
56
|
range
|
|
41
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-CSAKXWF3.js";
|
|
42
58
|
import {
|
|
43
59
|
isArray,
|
|
44
60
|
isClient,
|
|
@@ -55,24 +71,22 @@ import {
|
|
|
55
71
|
isSymbol
|
|
56
72
|
} from "./chunk-ZGYORUAX.js";
|
|
57
73
|
import {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
dash,
|
|
61
|
-
pascal,
|
|
62
|
-
snake,
|
|
63
|
-
template,
|
|
64
|
-
title,
|
|
65
|
-
trim
|
|
66
|
-
} from "./chunk-PNR5G432.js";
|
|
74
|
+
sleep
|
|
75
|
+
} from "./chunk-KFWZFQMB.js";
|
|
67
76
|
export {
|
|
68
77
|
access,
|
|
69
78
|
camel,
|
|
70
79
|
capitalize,
|
|
80
|
+
clearArray,
|
|
71
81
|
createClickOutside,
|
|
72
82
|
createDebounce,
|
|
83
|
+
createDebouncedWatch,
|
|
84
|
+
createEventListener,
|
|
73
85
|
createLoopExec,
|
|
86
|
+
createThrottle,
|
|
74
87
|
createWatch,
|
|
75
88
|
dash,
|
|
89
|
+
dataIf,
|
|
76
90
|
draw,
|
|
77
91
|
isArray,
|
|
78
92
|
isClient,
|
|
@@ -89,6 +103,7 @@ export {
|
|
|
89
103
|
isSymbol,
|
|
90
104
|
iterate,
|
|
91
105
|
list,
|
|
106
|
+
makeEventListener,
|
|
92
107
|
mountStyle,
|
|
93
108
|
noop,
|
|
94
109
|
pascal,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* return '' if show is true
|
|
3
|
+
*
|
|
4
|
+
* suitable when you want to conditionally apply data attributes
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
*
|
|
10
|
+
* function MyComponent(props:{size:'small'|'medium'|'large'}) {
|
|
11
|
+
* return <div
|
|
12
|
+
* data-size-small={dataIf(props.size === 'small')}
|
|
13
|
+
* data-size-medium={dataIf(props.size === 'medium')}
|
|
14
|
+
* data-size-large={dataIf(props.size === 'large')}
|
|
15
|
+
* >Hello</div>;
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function dataIf(show: boolean): "" | undefined;
|
|
21
|
+
|
|
22
|
+
export { dataIf };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { dataIf } from './attrs.js';
|
package/dist/lodash/array.d.ts
CHANGED
|
@@ -38,5 +38,9 @@ declare function range<T = number>(startOrLength: number, end?: number, valueOrM
|
|
|
38
38
|
* list(0, 6, i => i, 2) // 0, 2, 4, 6
|
|
39
39
|
*/
|
|
40
40
|
declare const list: <T = number>(startOrLength: number, end?: number, valueOrMapper?: T | ((i: number) => T), step?: number) => T[];
|
|
41
|
+
/**
|
|
42
|
+
* set arr.length to 0
|
|
43
|
+
*/
|
|
44
|
+
declare function clearArray<T>(arr: T[]): void;
|
|
41
45
|
|
|
42
|
-
export { iterate, list, range };
|
|
46
|
+
export { clearArray, iterate, list, range };
|
package/dist/lodash/array.js
CHANGED
package/dist/lodash/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { iterate, list, range } from './array.js';
|
|
1
|
+
export { clearArray, iterate, list, range } from './array.js';
|
|
2
2
|
export { sleep } from './async.js';
|
|
3
3
|
export { isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol } from './is.js';
|
|
4
4
|
export { draw, random, shuffle, uid } from './random.js';
|
package/dist/lodash/index.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import "../chunk-OECLQ3OT.js";
|
|
2
|
-
import {
|
|
3
|
-
sleep
|
|
4
|
-
} from "../chunk-KFWZFQMB.js";
|
|
5
2
|
import {
|
|
6
3
|
draw,
|
|
7
4
|
random,
|
|
8
5
|
shuffle,
|
|
9
6
|
uid
|
|
10
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-PBALVUKK.js";
|
|
8
|
+
import {
|
|
9
|
+
camel,
|
|
10
|
+
capitalize,
|
|
11
|
+
dash,
|
|
12
|
+
pascal,
|
|
13
|
+
snake,
|
|
14
|
+
template,
|
|
15
|
+
title,
|
|
16
|
+
trim
|
|
17
|
+
} from "../chunk-PNR5G432.js";
|
|
11
18
|
import {
|
|
19
|
+
clearArray,
|
|
12
20
|
iterate,
|
|
13
21
|
list,
|
|
14
22
|
range
|
|
15
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-CSAKXWF3.js";
|
|
16
24
|
import {
|
|
17
25
|
isArray,
|
|
18
26
|
isClient,
|
|
@@ -29,18 +37,12 @@ import {
|
|
|
29
37
|
isSymbol
|
|
30
38
|
} from "../chunk-ZGYORUAX.js";
|
|
31
39
|
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
dash,
|
|
35
|
-
pascal,
|
|
36
|
-
snake,
|
|
37
|
-
template,
|
|
38
|
-
title,
|
|
39
|
-
trim
|
|
40
|
-
} from "../chunk-PNR5G432.js";
|
|
40
|
+
sleep
|
|
41
|
+
} from "../chunk-KFWZFQMB.js";
|
|
41
42
|
export {
|
|
42
43
|
camel,
|
|
43
44
|
capitalize,
|
|
45
|
+
clearArray,
|
|
44
46
|
dash,
|
|
45
47
|
draw,
|
|
46
48
|
isArray,
|
package/dist/lodash/random.js
CHANGED
package/dist/reactive/access.js
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
access
|
|
3
3
|
} from "../chunk-M5A3VVYI.js";
|
|
4
4
|
import "../chunk-OECLQ3OT.js";
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-RRYFZNKE.js";
|
|
7
|
-
import "../chunk-WLQ64SAO.js";
|
|
8
|
-
import "../chunk-ZGYORUAX.js";
|
|
5
|
+
import "../chunk-PBALVUKK.js";
|
|
9
6
|
import "../chunk-PNR5G432.js";
|
|
7
|
+
import "../chunk-CSAKXWF3.js";
|
|
8
|
+
import "../chunk-ZGYORUAX.js";
|
|
9
|
+
import "../chunk-KFWZFQMB.js";
|
|
10
10
|
export {
|
|
11
11
|
access
|
|
12
12
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AccessorArray, Accessor, OnOptions } from 'solid-js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a debounced watch effect.
|
|
5
|
+
*
|
|
6
|
+
* opt.delay - The debounce delay in milliseconds. Default is 10ms.
|
|
7
|
+
*/
|
|
8
|
+
declare function createDebouncedWatch<S, Next extends Prev, Prev = Next>(targets: AccessorArray<S> | Accessor<S>, fn: (input: S, prevInput?: S) => void, opt?: OnOptions & {
|
|
9
|
+
delay?: number;
|
|
10
|
+
}): void;
|
|
11
|
+
|
|
12
|
+
export { createDebouncedWatch };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDebouncedWatch
|
|
3
|
+
} from "../chunk-BGLY6NJK.js";
|
|
4
|
+
import "../chunk-M5A3VVYI.js";
|
|
5
|
+
import "../chunk-4L6FK7MF.js";
|
|
6
|
+
import "../chunk-OECLQ3OT.js";
|
|
7
|
+
import "../chunk-PBALVUKK.js";
|
|
8
|
+
import "../chunk-PNR5G432.js";
|
|
9
|
+
import "../chunk-CSAKXWF3.js";
|
|
10
|
+
import "../chunk-ZGYORUAX.js";
|
|
11
|
+
import "../chunk-KFWZFQMB.js";
|
|
12
|
+
export {
|
|
13
|
+
createDebouncedWatch
|
|
14
|
+
};
|
package/dist/reactive/index.d.ts
CHANGED
package/dist/reactive/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
createDebouncedWatch
|
|
3
|
+
} from "../chunk-BGLY6NJK.js";
|
|
2
4
|
import {
|
|
3
5
|
access
|
|
4
6
|
} from "../chunk-M5A3VVYI.js";
|
|
@@ -6,12 +8,13 @@ import {
|
|
|
6
8
|
createWatch
|
|
7
9
|
} from "../chunk-4L6FK7MF.js";
|
|
8
10
|
import "../chunk-OECLQ3OT.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-RRYFZNKE.js";
|
|
11
|
-
import "../chunk-WLQ64SAO.js";
|
|
12
|
-
import "../chunk-ZGYORUAX.js";
|
|
11
|
+
import "../chunk-PBALVUKK.js";
|
|
13
12
|
import "../chunk-PNR5G432.js";
|
|
13
|
+
import "../chunk-CSAKXWF3.js";
|
|
14
|
+
import "../chunk-ZGYORUAX.js";
|
|
15
|
+
import "../chunk-KFWZFQMB.js";
|
|
14
16
|
export {
|
|
15
17
|
access,
|
|
18
|
+
createDebouncedWatch,
|
|
16
19
|
createWatch
|
|
17
20
|
};
|
package/dist/types/fn.d.ts
CHANGED
package/dist/types/fn.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../chunk-AZAXMGEB.js";
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-tiny-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A collection of tiny utilities for SolidJS applications",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"author": "",
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@solid-primitives/event-listener": "^2.4.3",
|
|
44
43
|
"solid-tiny-context": "0.1.2"
|
|
45
44
|
},
|
|
46
45
|
"scripts": {
|
package/dist/chunk-2BGAGVTR.js
DELETED
package/dist/chunk-H6VUVMSF.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
access
|
|
3
|
-
} from "./chunk-M5A3VVYI.js";
|
|
4
|
-
|
|
5
|
-
// src/fn/create-debounce.ts
|
|
6
|
-
import { onCleanup } from "solid-js";
|
|
7
|
-
function createDebounce(callback, delay) {
|
|
8
|
-
let timeoutId;
|
|
9
|
-
onCleanup(() => {
|
|
10
|
-
clearTimeout(timeoutId);
|
|
11
|
-
});
|
|
12
|
-
const run = (...args) => {
|
|
13
|
-
clearTimeout(timeoutId);
|
|
14
|
-
timeoutId = setTimeout(() => {
|
|
15
|
-
callback(...args);
|
|
16
|
-
}, access(delay));
|
|
17
|
-
};
|
|
18
|
-
return run;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
createDebounce
|
|
23
|
-
};
|
package/dist/chunk-WY5G2PJM.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
access
|
|
3
|
-
} from "./chunk-M5A3VVYI.js";
|
|
4
|
-
import {
|
|
5
|
-
createWatch
|
|
6
|
-
} from "./chunk-4L6FK7MF.js";
|
|
7
|
-
import {
|
|
8
|
-
isNumber
|
|
9
|
-
} from "./chunk-ZGYORUAX.js";
|
|
10
|
-
|
|
11
|
-
// src/fn/create-loop-exec.ts
|
|
12
|
-
import { onCleanup } from "solid-js";
|
|
13
|
-
function createLoopExec(fn, delay) {
|
|
14
|
-
let shouldStop = false;
|
|
15
|
-
let isCleanedUp = false;
|
|
16
|
-
let timer;
|
|
17
|
-
const execFn = async () => {
|
|
18
|
-
clearTimeout(timer);
|
|
19
|
-
const d = access(delay);
|
|
20
|
-
if (shouldStop || !isNumber(d) || d < 0) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
await fn();
|
|
25
|
-
} finally {
|
|
26
|
-
timer = setTimeout(() => {
|
|
27
|
-
execFn();
|
|
28
|
-
}, d);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
createWatch(
|
|
32
|
-
() => access(delay),
|
|
33
|
-
() => {
|
|
34
|
-
execFn();
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
const stop = () => {
|
|
38
|
-
shouldStop = true;
|
|
39
|
-
clearTimeout(timer);
|
|
40
|
-
};
|
|
41
|
-
const start = () => {
|
|
42
|
-
if (isCleanedUp) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
shouldStop = false;
|
|
46
|
-
execFn();
|
|
47
|
-
};
|
|
48
|
-
onCleanup(() => {
|
|
49
|
-
isCleanedUp = true;
|
|
50
|
-
stop();
|
|
51
|
-
});
|
|
52
|
-
return {
|
|
53
|
-
stop,
|
|
54
|
-
start
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export {
|
|
59
|
-
createLoopExec
|
|
60
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|