solid-tiny-utils 0.7.1 → 0.9.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/LICENSE +21 -21
- package/dist/color/{hex-rgb.d.ts → hex-rgb.d.mts} +5 -3
- package/dist/color/hex-rgb.mjs +62 -0
- package/dist/color/{oklch-rgb.d.ts → oklch-rgb.d.mts} +9 -8
- package/dist/color/oklch-rgb.mjs +101 -0
- package/dist/color/{validation.d.ts → validation.d.mts} +5 -3
- package/dist/color/validation.mjs +35 -0
- package/dist/dom/{css.d.ts → css.d.mts} +5 -3
- package/dist/dom/css.mjs +51 -0
- package/dist/event/create-click-outside.d.mts +9 -0
- package/dist/event/create-click-outside.mjs +33 -0
- package/dist/event/{create-event-listener.d.ts → create-event-listener.d.mts} +7 -6
- package/dist/event/create-event-listener.mjs +34 -0
- package/dist/event/{create-intersection-observer.d.ts → create-intersection-observer.d.mts} +5 -4
- package/dist/event/create-intersection-observer.mjs +29 -0
- package/dist/event/{create-visibility-observer.d.ts → create-visibility-observer.d.mts} +7 -5
- package/dist/event/create-visibility-observer.mjs +46 -0
- package/dist/event/index.d.mts +11 -0
- package/dist/event/index.mjs +14 -0
- package/dist/event/{make-event-listener.d.ts → make-event-listener.d.mts} +8 -7
- package/dist/event/make-event-listener.mjs +35 -0
- package/dist/fn/create-debounce.d.mts +7 -0
- package/dist/fn/create-debounce.mjs +20 -0
- package/dist/fn/{create-loop-exec.d.ts → create-loop-exec.d.mts} +7 -6
- package/dist/fn/create-loop-exec.mjs +59 -0
- package/dist/fn/create-throttle.d.mts +7 -0
- package/dist/fn/create-throttle.mjs +21 -0
- package/dist/fn/index.d.mts +8 -0
- package/dist/fn/index.mjs +9 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.mjs +26 -0
- package/dist/jsx/{attrs.d.ts → attrs.d.mts} +3 -2
- package/dist/jsx/attrs.mjs +26 -0
- package/dist/reactive/access.d.mts +6 -0
- package/dist/reactive/access.mjs +9 -0
- package/dist/reactive/{create-debounce-watch.d.ts → create-debounce-watch.d.mts} +6 -4
- package/dist/reactive/create-debounce-watch.mjs +15 -0
- package/dist/reactive/{create-watch.d.ts → create-watch.d.mts} +4 -3
- package/dist/reactive/create-watch.mjs +9 -0
- package/dist/reactive/index.d.mts +3 -0
- package/dist/types/{fn.d.ts → fn.d.mts} +3 -2
- package/dist/types/index.d.mts +2 -0
- package/dist/types/{maybe.d.ts → maybe.d.mts} +4 -3
- package/dist/utils/{array.d.ts → array.d.mts} +3 -2
- package/dist/utils/array.mjs +66 -0
- package/dist/utils/async.d.mts +8 -0
- package/dist/utils/async.mjs +17 -0
- package/dist/utils/{is.d.ts → is.d.mts} +3 -2
- package/dist/utils/is.mjs +72 -0
- package/dist/utils/{number.d.ts → number.d.mts} +3 -2
- package/dist/utils/number.mjs +127 -0
- package/dist/utils/{random.d.ts → random.d.mts} +3 -2
- package/dist/utils/random.mjs +33 -0
- package/dist/utils/{str.d.ts → str.d.mts} +4 -3
- package/dist/utils/str.mjs +120 -0
- package/package.json +25 -22
- package/dist/chunk-4L6FK7MF.js +0 -9
- package/dist/chunk-6G7GFZV2.js +0 -93
- package/dist/chunk-6OVLJ45M.js +0 -51
- package/dist/chunk-ACZGS7DG.js +0 -72
- package/dist/chunk-AZAXMGEB.js +0 -0
- package/dist/chunk-BLX3XSA6.js +0 -0
- package/dist/chunk-BT47ISVC.js +0 -36
- package/dist/chunk-EZML2DEC.js +0 -0
- package/dist/chunk-FFBJP5FE.js +0 -0
- package/dist/chunk-II6INKPZ.js +0 -8
- package/dist/chunk-KFLH3AZ6.js +0 -40
- package/dist/chunk-KKFGUHFR.js +0 -8
- package/dist/chunk-KM4Q6THD.js +0 -50
- package/dist/chunk-LEWF7QAQ.js +0 -47
- package/dist/chunk-LUFOWTRW.js +0 -0
- package/dist/chunk-PD6VHMH6.js +0 -26
- package/dist/chunk-QPEF6LHH.js +0 -111
- package/dist/chunk-QQVSG76Z.js +0 -36
- package/dist/chunk-S7U3LZNS.js +0 -23
- package/dist/chunk-SK6Y2YH6.js +0 -0
- package/dist/chunk-TDJLPDJF.js +0 -66
- package/dist/chunk-TGWWPUWD.js +0 -55
- package/dist/chunk-U5LQ2AS5.js +0 -0
- package/dist/chunk-WJHRONQU.js +0 -54
- package/dist/chunk-Y4GYGFIT.js +0 -85
- package/dist/chunk-YK5QQQ43.js +0 -12
- package/dist/chunk-YXRZ2KMJ.js +0 -0
- package/dist/color/hex-rgb.js +0 -15
- package/dist/color/index.d.ts +0 -3
- package/dist/color/index.js +0 -30
- package/dist/color/oklch-rgb.js +0 -15
- package/dist/color/validation.js +0 -18
- package/dist/dom/css.js +0 -19
- package/dist/dom/index.d.ts +0 -2
- package/dist/dom/index.js +0 -20
- package/dist/event/create-click-outside.d.ts +0 -8
- package/dist/event/create-click-outside.js +0 -17
- package/dist/event/create-event-listener.js +0 -17
- package/dist/event/create-intersection-observer.js +0 -16
- package/dist/event/create-visibility-observer.js +0 -16
- package/dist/event/index.d.ts +0 -8
- package/dist/event/index.js +0 -33
- package/dist/event/make-event-listener.js +0 -16
- package/dist/fn/create-debounce.d.ts +0 -6
- package/dist/fn/create-debounce.js +0 -15
- package/dist/fn/create-loop-exec.js +0 -15
- package/dist/fn/create-throttle.d.ts +0 -6
- package/dist/fn/create-throttle.js +0 -15
- package/dist/fn/index.d.ts +0 -9
- package/dist/fn/index.js +0 -21
- package/dist/index.d.ts +0 -27
- package/dist/index.js +0 -166
- package/dist/jsx/attrs.js +0 -6
- package/dist/jsx/index.d.ts +0 -1
- package/dist/jsx/index.js +0 -7
- package/dist/reactive/access.d.ts +0 -6
- package/dist/reactive/access.js +0 -13
- package/dist/reactive/create-debounce-watch.js +0 -15
- package/dist/reactive/create-watch.js +0 -6
- package/dist/reactive/index.d.ts +0 -5
- package/dist/reactive/index.js +0 -21
- package/dist/types/fn.js +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.js +0 -3
- package/dist/types/maybe.js +0 -1
- package/dist/utils/array.js +0 -13
- package/dist/utils/async.d.ts +0 -6
- package/dist/utils/async.js +0 -6
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/index.js +0 -85
- package/dist/utils/is.js +0 -30
- package/dist/utils/number.js +0 -14
- package/dist/utils/object.d.ts +0 -10
- package/dist/utils/object.js +0 -7
- package/dist/utils/random.js +0 -14
- package/dist/utils/str.js +0 -20
package/dist/chunk-KFLH3AZ6.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isArray
|
|
3
|
-
} from "./chunk-6G7GFZV2.js";
|
|
4
|
-
import {
|
|
5
|
-
clamp,
|
|
6
|
-
toHex
|
|
7
|
-
} from "./chunk-PD6VHMH6.js";
|
|
8
|
-
|
|
9
|
-
// src/color/hex-rgb.ts
|
|
10
|
-
var HEX_PREFIX_REGEX = /^#/;
|
|
11
|
-
var HEX_VALIDATION_REGEX = /^[0-9a-fA-F]{6}$/;
|
|
12
|
-
function hexToRgb(hex) {
|
|
13
|
-
if (!hex || typeof hex !== "string") {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
let value = hex.trim().replace(HEX_PREFIX_REGEX, "");
|
|
17
|
-
if (value.length === 3) {
|
|
18
|
-
value = value.split("").map((c) => c + c).join("");
|
|
19
|
-
}
|
|
20
|
-
if (!HEX_VALIDATION_REGEX.test(value)) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const r = Number.parseInt(value.slice(0, 2), 16);
|
|
24
|
-
const g = Number.parseInt(value.slice(2, 4), 16);
|
|
25
|
-
const b = Number.parseInt(value.slice(4, 6), 16);
|
|
26
|
-
return { r, g, b };
|
|
27
|
-
}
|
|
28
|
-
function rgbToHex(rgb) {
|
|
29
|
-
const c = (v) => Math.round(clamp(v, 0, 255));
|
|
30
|
-
const rgb_ = isArray(rgb) ? rgb : [rgb.r, rgb.g, rgb.b];
|
|
31
|
-
const r = c(rgb_[0]);
|
|
32
|
-
const g = c(rgb_[1]);
|
|
33
|
-
const b = c(rgb_[2]);
|
|
34
|
-
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
hexToRgb,
|
|
39
|
-
rgbToHex
|
|
40
|
-
};
|
package/dist/chunk-KKFGUHFR.js
DELETED
package/dist/chunk-KM4Q6THD.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isClient
|
|
3
|
-
} from "./chunk-6G7GFZV2.js";
|
|
4
|
-
|
|
5
|
-
// src/dom/css.ts
|
|
6
|
-
var alreadyInjected = [];
|
|
7
|
-
function mountStyle(style, id, refresh = false) {
|
|
8
|
-
if (!isClient) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if (alreadyInjected.includes(id) && !refresh) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
let styleElement = document.querySelector(`style#${id}`);
|
|
15
|
-
if (styleElement) {
|
|
16
|
-
styleElement.innerHTML = style;
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
styleElement = document.createElement("style");
|
|
20
|
-
styleElement.id = id;
|
|
21
|
-
styleElement.innerHTML = style;
|
|
22
|
-
document.head.appendChild(styleElement);
|
|
23
|
-
alreadyInjected.push(id);
|
|
24
|
-
}
|
|
25
|
-
var extractCSSregex = /((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;
|
|
26
|
-
function stringStyleToObject(style) {
|
|
27
|
-
const object = {};
|
|
28
|
-
let match = extractCSSregex.exec(style);
|
|
29
|
-
while (match) {
|
|
30
|
-
if (match[1] && match[2]) {
|
|
31
|
-
object[match[1]] = match[2];
|
|
32
|
-
}
|
|
33
|
-
match = extractCSSregex.exec(style);
|
|
34
|
-
}
|
|
35
|
-
return object;
|
|
36
|
-
}
|
|
37
|
-
function combineStyle(a, b) {
|
|
38
|
-
const bb = typeof b === "string" ? stringStyleToObject(b) : b;
|
|
39
|
-
return { ...a, ...bb };
|
|
40
|
-
}
|
|
41
|
-
function combineClass(defaultClass, ...otherClass) {
|
|
42
|
-
return [defaultClass, ...otherClass].filter(Boolean).join(" ");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
mountStyle,
|
|
47
|
-
stringStyleToObject,
|
|
48
|
-
combineStyle,
|
|
49
|
-
combineClass
|
|
50
|
-
};
|
package/dist/chunk-LEWF7QAQ.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
noop
|
|
3
|
-
} from "./chunk-QPEF6LHH.js";
|
|
4
|
-
import {
|
|
5
|
-
access
|
|
6
|
-
} from "./chunk-YK5QQQ43.js";
|
|
7
|
-
import {
|
|
8
|
-
createWatch
|
|
9
|
-
} from "./chunk-4L6FK7MF.js";
|
|
10
|
-
import {
|
|
11
|
-
clearArray
|
|
12
|
-
} from "./chunk-BT47ISVC.js";
|
|
13
|
-
|
|
14
|
-
// src/event/create-intersection-observer.ts
|
|
15
|
-
import { onCleanup } from "solid-js";
|
|
16
|
-
import { isServer } from "solid-js/web";
|
|
17
|
-
function createIntersectionObserver(targets, callback, options = {}) {
|
|
18
|
-
if (isServer) {
|
|
19
|
-
return noop;
|
|
20
|
-
}
|
|
21
|
-
const io = new IntersectionObserver(callback, options);
|
|
22
|
-
onCleanup(() => io.disconnect());
|
|
23
|
-
const cleanups = [];
|
|
24
|
-
const cleanup = () => {
|
|
25
|
-
for (const c of cleanups) {
|
|
26
|
-
c();
|
|
27
|
-
}
|
|
28
|
-
clearArray(cleanups);
|
|
29
|
-
};
|
|
30
|
-
createWatch(
|
|
31
|
-
() => targets.map(access),
|
|
32
|
-
(elements) => {
|
|
33
|
-
cleanup();
|
|
34
|
-
for (const element of elements) {
|
|
35
|
-
if (element) {
|
|
36
|
-
io.observe(element);
|
|
37
|
-
cleanups.push(() => io.unobserve(element));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
return () => io.disconnect();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
createIntersectionObserver
|
|
47
|
-
};
|
package/dist/chunk-LUFOWTRW.js
DELETED
|
File without changes
|
package/dist/chunk-PD6VHMH6.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// src/utils/number.ts
|
|
2
|
-
function min(...numbers) {
|
|
3
|
-
return Math.min(...numbers);
|
|
4
|
-
}
|
|
5
|
-
function max(...numbers) {
|
|
6
|
-
return Math.max(...numbers);
|
|
7
|
-
}
|
|
8
|
-
function clamp(x, minimum = 0, maximum = 1) {
|
|
9
|
-
return min(maximum, max(minimum, x));
|
|
10
|
-
}
|
|
11
|
-
function inRange(x, minimum = 0, maximum = 1, inclusivity = "[]") {
|
|
12
|
-
const minCheck = inclusivity[0] === "[" ? x >= minimum : x > minimum;
|
|
13
|
-
const maxCheck = inclusivity[1] === "]" ? x <= maximum : x < maximum;
|
|
14
|
-
return minCheck && maxCheck;
|
|
15
|
-
}
|
|
16
|
-
function toHex(x, pad = 2) {
|
|
17
|
-
return x.toString(16).padStart(pad, "0");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
min,
|
|
22
|
-
max,
|
|
23
|
-
clamp,
|
|
24
|
-
inRange,
|
|
25
|
-
toHex
|
|
26
|
-
};
|
package/dist/chunk-QPEF6LHH.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
access
|
|
3
|
-
} from "./chunk-YK5QQQ43.js";
|
|
4
|
-
import {
|
|
5
|
-
createWatch
|
|
6
|
-
} from "./chunk-4L6FK7MF.js";
|
|
7
|
-
import {
|
|
8
|
-
isNumber
|
|
9
|
-
} from "./chunk-6G7GFZV2.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
|
-
};
|
package/dist/chunk-QQVSG76Z.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
iterate
|
|
3
|
-
} from "./chunk-BT47ISVC.js";
|
|
4
|
-
|
|
5
|
-
// src/utils/random.ts
|
|
6
|
-
var random = (min, max) => {
|
|
7
|
-
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
8
|
-
};
|
|
9
|
-
var draw = (array) => {
|
|
10
|
-
const max = array.length;
|
|
11
|
-
if (max === 0) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
const index = random(0, max - 1);
|
|
15
|
-
return array[index];
|
|
16
|
-
};
|
|
17
|
-
var shuffle = (array) => {
|
|
18
|
-
return array.map((a) => ({ rand: Math.random(), value: a })).sort((a, b) => a.rand - b.rand).map((a) => a.value);
|
|
19
|
-
};
|
|
20
|
-
var uid = (length, specials = "") => {
|
|
21
|
-
const characters = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789${specials}`;
|
|
22
|
-
return iterate(
|
|
23
|
-
length,
|
|
24
|
-
(acc) => {
|
|
25
|
-
return acc + characters.charAt(random(0, characters.length - 1));
|
|
26
|
-
},
|
|
27
|
-
""
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
random,
|
|
33
|
-
draw,
|
|
34
|
-
shuffle,
|
|
35
|
-
uid
|
|
36
|
-
};
|
package/dist/chunk-S7U3LZNS.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
hexToRgb
|
|
3
|
-
} from "./chunk-KFLH3AZ6.js";
|
|
4
|
-
import {
|
|
5
|
-
inRange
|
|
6
|
-
} from "./chunk-PD6VHMH6.js";
|
|
7
|
-
|
|
8
|
-
// src/color/validation.ts
|
|
9
|
-
function isValidRGB(rgb) {
|
|
10
|
-
return Object.values(rgb).every((x) => inRange(x, 0, 255));
|
|
11
|
-
}
|
|
12
|
-
function isValidOKLCH(oklch) {
|
|
13
|
-
return inRange(oklch.l) && oklch.c >= 0 && inRange(oklch.h, 0, 360);
|
|
14
|
-
}
|
|
15
|
-
function isValidHex(hex) {
|
|
16
|
-
return hexToRgb(hex) !== null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
isValidRGB,
|
|
21
|
-
isValidOKLCH,
|
|
22
|
-
isValidHex
|
|
23
|
-
};
|
package/dist/chunk-SK6Y2YH6.js
DELETED
|
File without changes
|
package/dist/chunk-TDJLPDJF.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
access
|
|
3
|
-
} from "./chunk-YK5QQQ43.js";
|
|
4
|
-
import {
|
|
5
|
-
createWatch
|
|
6
|
-
} from "./chunk-4L6FK7MF.js";
|
|
7
|
-
import {
|
|
8
|
-
isObject
|
|
9
|
-
} from "./chunk-6G7GFZV2.js";
|
|
10
|
-
|
|
11
|
-
// src/event/create-visibility-observer.ts
|
|
12
|
-
import { createSignal, onCleanup } from "solid-js";
|
|
13
|
-
function createVisibilityObserver(arg1, arg2) {
|
|
14
|
-
let target;
|
|
15
|
-
let options;
|
|
16
|
-
if (arg1 && !isObject(arg1)) {
|
|
17
|
-
target = arg1;
|
|
18
|
-
options = arg2 ?? {};
|
|
19
|
-
} else {
|
|
20
|
-
options = arg1 ?? {};
|
|
21
|
-
}
|
|
22
|
-
const callbacks = /* @__PURE__ */ new WeakMap();
|
|
23
|
-
const io = new IntersectionObserver((entries, instance) => {
|
|
24
|
-
for (const entry of entries) {
|
|
25
|
-
callbacks.get(entry.target)?.(entry, instance);
|
|
26
|
-
}
|
|
27
|
-
}, options);
|
|
28
|
-
onCleanup(() => io.disconnect());
|
|
29
|
-
const addEntry = (el, callback) => {
|
|
30
|
-
io.observe(el);
|
|
31
|
-
callbacks.set(el, callback);
|
|
32
|
-
};
|
|
33
|
-
const removeEntry = (el) => {
|
|
34
|
-
io.unobserve(el);
|
|
35
|
-
callbacks.delete(el);
|
|
36
|
-
};
|
|
37
|
-
const useVisibilityObserverFn = (element) => {
|
|
38
|
-
const [isVisible, setVisible] = createSignal(
|
|
39
|
-
options?.initialValue ?? false
|
|
40
|
-
);
|
|
41
|
-
let prevEl;
|
|
42
|
-
createWatch(
|
|
43
|
-
() => access(element),
|
|
44
|
-
(el) => {
|
|
45
|
-
if (prevEl) {
|
|
46
|
-
removeEntry(prevEl);
|
|
47
|
-
}
|
|
48
|
-
if (el) {
|
|
49
|
-
addEntry(el, (entry) => {
|
|
50
|
-
setVisible(entry.isIntersecting);
|
|
51
|
-
});
|
|
52
|
-
prevEl = el;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
return isVisible;
|
|
57
|
-
};
|
|
58
|
-
if (target) {
|
|
59
|
-
return useVisibilityObserverFn(target);
|
|
60
|
-
}
|
|
61
|
-
return useVisibilityObserverFn;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export {
|
|
65
|
-
createVisibilityObserver
|
|
66
|
-
};
|
package/dist/chunk-TGWWPUWD.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
noop
|
|
3
|
-
} from "./chunk-QPEF6LHH.js";
|
|
4
|
-
import {
|
|
5
|
-
clearArray
|
|
6
|
-
} from "./chunk-BT47ISVC.js";
|
|
7
|
-
import {
|
|
8
|
-
isArray
|
|
9
|
-
} from "./chunk-6G7GFZV2.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
|
-
};
|
package/dist/chunk-U5LQ2AS5.js
DELETED
|
File without changes
|
package/dist/chunk-WJHRONQU.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
makeEventListener
|
|
3
|
-
} from "./chunk-TGWWPUWD.js";
|
|
4
|
-
import {
|
|
5
|
-
access
|
|
6
|
-
} from "./chunk-YK5QQQ43.js";
|
|
7
|
-
|
|
8
|
-
// src/event/create-click-outside.ts
|
|
9
|
-
function createClickOutside(target, handler, options) {
|
|
10
|
-
let shouldListen = false;
|
|
11
|
-
const shouldIgnore = (event) => {
|
|
12
|
-
const ignore = (options?.ignore ? options.ignore : []).map(access);
|
|
13
|
-
return ignore.some((el) => {
|
|
14
|
-
return el && (event.target === el || event.composedPath().includes(el));
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
const listener = (e) => {
|
|
18
|
-
const el = access(target);
|
|
19
|
-
if (!el || el === e.target || e.composedPath().includes(el)) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (e.detail === 0) {
|
|
23
|
-
shouldListen = !shouldIgnore(e);
|
|
24
|
-
}
|
|
25
|
-
if (!shouldListen) {
|
|
26
|
-
shouldListen = true;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
handler(e);
|
|
30
|
-
};
|
|
31
|
-
const cleanups = [
|
|
32
|
-
makeEventListener("click", listener, { passive: true }),
|
|
33
|
-
makeEventListener(
|
|
34
|
-
"pointerdown",
|
|
35
|
-
(e) => {
|
|
36
|
-
const el = access(target);
|
|
37
|
-
if (el) {
|
|
38
|
-
shouldListen = !(e.composedPath().includes(el) || shouldIgnore(e));
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
{ passive: true }
|
|
42
|
-
)
|
|
43
|
-
];
|
|
44
|
-
const stop = () => {
|
|
45
|
-
for (const cleanup of cleanups) {
|
|
46
|
-
cleanup();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
return stop;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export {
|
|
53
|
-
createClickOutside
|
|
54
|
-
};
|
package/dist/chunk-Y4GYGFIT.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// src/utils/str.ts
|
|
2
|
-
var capitalize = (str) => {
|
|
3
|
-
if (!str || str.length === 0) {
|
|
4
|
-
return "";
|
|
5
|
-
}
|
|
6
|
-
const lower = str.toLowerCase();
|
|
7
|
-
return lower.substring(0, 1).toUpperCase() + lower.substring(1, lower.length);
|
|
8
|
-
};
|
|
9
|
-
var splitRegexp = /(?=[A-Z])|[.\-\s_]/;
|
|
10
|
-
var camel = (str) => {
|
|
11
|
-
const parts = str?.replace(/([A-Z])+/g, capitalize)?.split(splitRegexp).map((x) => x.toLowerCase()) ?? [];
|
|
12
|
-
if (parts.length === 0) {
|
|
13
|
-
return "";
|
|
14
|
-
}
|
|
15
|
-
if (parts.length === 1) {
|
|
16
|
-
return parts[0];
|
|
17
|
-
}
|
|
18
|
-
return parts.reduce((acc, part) => {
|
|
19
|
-
return `${acc}${part.charAt(0).toUpperCase()}${part.slice(1)}`;
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var splitOnNumberRegexp = /([A-Za-z]{1}[0-9]{1})/;
|
|
23
|
-
var snake = (str, options) => {
|
|
24
|
-
const parts = str?.replace(/([A-Z])+/g, capitalize).split(splitRegexp).map((x) => x.toLowerCase()) ?? [];
|
|
25
|
-
if (parts.length === 0) {
|
|
26
|
-
return "";
|
|
27
|
-
}
|
|
28
|
-
if (parts.length === 1) {
|
|
29
|
-
return parts[0];
|
|
30
|
-
}
|
|
31
|
-
const result = parts.reduce((acc, part) => {
|
|
32
|
-
return `${acc}_${part.toLowerCase()}`;
|
|
33
|
-
});
|
|
34
|
-
return options?.splitOnNumber === false ? result : result.replace(splitOnNumberRegexp, (val) => `${val[0]}_${val[1]}`);
|
|
35
|
-
};
|
|
36
|
-
var dash = (str) => {
|
|
37
|
-
const parts = str?.replace(/([A-Z])+/g, capitalize)?.split(splitRegexp).map((x) => x.toLowerCase()) ?? [];
|
|
38
|
-
if (parts.length === 0) {
|
|
39
|
-
return "";
|
|
40
|
-
}
|
|
41
|
-
if (parts.length === 1) {
|
|
42
|
-
return parts[0];
|
|
43
|
-
}
|
|
44
|
-
return parts.reduce((acc, part) => {
|
|
45
|
-
return `${acc}-${part.toLowerCase()}`;
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
var pascalSplitRegexp = /[.\-\s_]/;
|
|
49
|
-
var pascal = (str) => {
|
|
50
|
-
const parts = str?.split(pascalSplitRegexp).map((x) => x.toLowerCase()) ?? [];
|
|
51
|
-
if (parts.length === 0) {
|
|
52
|
-
return "";
|
|
53
|
-
}
|
|
54
|
-
return parts.map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("");
|
|
55
|
-
};
|
|
56
|
-
var title = (str) => {
|
|
57
|
-
if (!str) {
|
|
58
|
-
return "";
|
|
59
|
-
}
|
|
60
|
-
return str.split(splitRegexp).map((s) => s.trim()).filter((s) => !!s).map((s) => capitalize(s.toLowerCase())).join(" ");
|
|
61
|
-
};
|
|
62
|
-
var template = (str, data, regex = /\{\{(.+?)\}\}/g) => {
|
|
63
|
-
return Array.from(str.matchAll(regex)).reduce((acc, match) => {
|
|
64
|
-
return acc.replace(match[0], data[match[1]]);
|
|
65
|
-
}, str);
|
|
66
|
-
};
|
|
67
|
-
var trim = (str, charsToTrim = " ") => {
|
|
68
|
-
if (!str) {
|
|
69
|
-
return "";
|
|
70
|
-
}
|
|
71
|
-
const toTrim = charsToTrim.replace(/[\W]{1}/g, "\\$&");
|
|
72
|
-
const regex = new RegExp(`^[${toTrim}]+|[${toTrim}]+$`, "g");
|
|
73
|
-
return str.replace(regex, "");
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export {
|
|
77
|
-
capitalize,
|
|
78
|
-
camel,
|
|
79
|
-
snake,
|
|
80
|
-
dash,
|
|
81
|
-
pascal,
|
|
82
|
-
title,
|
|
83
|
-
template,
|
|
84
|
-
trim
|
|
85
|
-
};
|
package/dist/chunk-YK5QQQ43.js
DELETED
package/dist/chunk-YXRZ2KMJ.js
DELETED
|
File without changes
|
package/dist/color/hex-rgb.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
hexToRgb,
|
|
3
|
-
rgbToHex
|
|
4
|
-
} from "../chunk-KFLH3AZ6.js";
|
|
5
|
-
import "../chunk-U5LQ2AS5.js";
|
|
6
|
-
import "../chunk-QQVSG76Z.js";
|
|
7
|
-
import "../chunk-Y4GYGFIT.js";
|
|
8
|
-
import "../chunk-BT47ISVC.js";
|
|
9
|
-
import "../chunk-KKFGUHFR.js";
|
|
10
|
-
import "../chunk-6G7GFZV2.js";
|
|
11
|
-
import "../chunk-PD6VHMH6.js";
|
|
12
|
-
export {
|
|
13
|
-
hexToRgb,
|
|
14
|
-
rgbToHex
|
|
15
|
-
};
|
package/dist/color/index.d.ts
DELETED
package/dist/color/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import "../chunk-BLX3XSA6.js";
|
|
2
|
-
import {
|
|
3
|
-
oklchToRgb,
|
|
4
|
-
rgbToOklch
|
|
5
|
-
} from "../chunk-ACZGS7DG.js";
|
|
6
|
-
import {
|
|
7
|
-
isValidHex,
|
|
8
|
-
isValidOKLCH,
|
|
9
|
-
isValidRGB
|
|
10
|
-
} from "../chunk-S7U3LZNS.js";
|
|
11
|
-
import {
|
|
12
|
-
hexToRgb,
|
|
13
|
-
rgbToHex
|
|
14
|
-
} from "../chunk-KFLH3AZ6.js";
|
|
15
|
-
import "../chunk-U5LQ2AS5.js";
|
|
16
|
-
import "../chunk-QQVSG76Z.js";
|
|
17
|
-
import "../chunk-Y4GYGFIT.js";
|
|
18
|
-
import "../chunk-BT47ISVC.js";
|
|
19
|
-
import "../chunk-KKFGUHFR.js";
|
|
20
|
-
import "../chunk-6G7GFZV2.js";
|
|
21
|
-
import "../chunk-PD6VHMH6.js";
|
|
22
|
-
export {
|
|
23
|
-
hexToRgb,
|
|
24
|
-
isValidHex,
|
|
25
|
-
isValidOKLCH,
|
|
26
|
-
isValidRGB,
|
|
27
|
-
oklchToRgb,
|
|
28
|
-
rgbToHex,
|
|
29
|
-
rgbToOklch
|
|
30
|
-
};
|
package/dist/color/oklch-rgb.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
oklchToRgb,
|
|
3
|
-
rgbToOklch
|
|
4
|
-
} from "../chunk-ACZGS7DG.js";
|
|
5
|
-
import "../chunk-U5LQ2AS5.js";
|
|
6
|
-
import "../chunk-QQVSG76Z.js";
|
|
7
|
-
import "../chunk-Y4GYGFIT.js";
|
|
8
|
-
import "../chunk-BT47ISVC.js";
|
|
9
|
-
import "../chunk-KKFGUHFR.js";
|
|
10
|
-
import "../chunk-6G7GFZV2.js";
|
|
11
|
-
import "../chunk-PD6VHMH6.js";
|
|
12
|
-
export {
|
|
13
|
-
oklchToRgb,
|
|
14
|
-
rgbToOklch
|
|
15
|
-
};
|