solid-tiny-utils 0.8.0 → 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 CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 g-mero
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 g-mero
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # solid-tiny-utils
2
-
3
- Tiny utilities for SolidJS applications.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- pnpm add solid-tiny-utils
9
- ```
1
+ # solid-tiny-utils
2
+
3
+ Tiny utilities for SolidJS applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add solid-tiny-utils
9
+ ```
@@ -3,7 +3,6 @@ import { DocumentEventName, GeneralEventListener, WindowEventName, makeEventList
3
3
  import { createEventListener } from "./create-event-listener.mjs";
4
4
  import { createIntersectionObserver } from "./create-intersection-observer.mjs";
5
5
  import { CreateVisibilityObserverOption, EntryCallback, UseVisibilityObserverFn, createVisibilityObserver } from "./create-visibility-observer.mjs";
6
- import { OnMotionEndOptions, OnMotionEndType, createOnMotionEnd, makeOnMotionEnd } from "./on-motion-end.mjs";
7
6
  import { JSX } from "solid-js/jsx-runtime";
8
7
 
9
8
  //#region src/event/index.d.ts
@@ -3,7 +3,6 @@ import { createClickOutside } from "./create-click-outside.mjs";
3
3
  import { createEventListener } from "./create-event-listener.mjs";
4
4
  import { createIntersectionObserver } from "./create-intersection-observer.mjs";
5
5
  import { createVisibilityObserver } from "./create-visibility-observer.mjs";
6
- import { createOnMotionEnd, makeOnMotionEnd } from "./on-motion-end.mjs";
7
6
 
8
7
  //#region src/event/index.ts
9
8
  function runSolidEventHandler(event, handler) {
package/dist/index.d.mts CHANGED
@@ -10,7 +10,6 @@ import { DocumentEventName, GeneralEventListener, WindowEventName, makeEventList
10
10
  import { createEventListener } from "./event/create-event-listener.mjs";
11
11
  import { createIntersectionObserver } from "./event/create-intersection-observer.mjs";
12
12
  import { CreateVisibilityObserverOption, EntryCallback, UseVisibilityObserverFn, createVisibilityObserver } from "./event/create-visibility-observer.mjs";
13
- import { OnMotionEndOptions, OnMotionEndType, createOnMotionEnd, makeOnMotionEnd } from "./event/on-motion-end.mjs";
14
13
  import { runSolidEventHandler } from "./event/index.mjs";
15
14
  import { createDebounce } from "./fn/create-debounce.mjs";
16
15
  import { createLoopExec } from "./fn/create-loop-exec.mjs";
@@ -27,4 +26,4 @@ import { isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isO
27
26
  import { clamp, inRange, max, min, toHex } from "./utils/number.mjs";
28
27
  import { draw, random, shuffle, uid } from "./utils/random.mjs";
29
28
  import { camel, capitalize, dash, pascal, snake, template, title, trim } from "./utils/str.mjs";
30
- export { AnyFn, CreateVisibilityObserverOption, DocumentEventName, EntryCallback, Fn, GeneralEventListener, MaybeAccessor, MaybeArray, MaybeNullableAccessor, MaybePromise, OKLCH, OnMotionEndOptions, OnMotionEndType, RGB, UseVisibilityObserverFn, WindowEventName, access, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside, createDebounce, createDebouncedWatch, createEventListener, createIntersectionObserver, createLoopExec, createOnMotionEnd, createThrottle, createVisibilityObserver, createWatch, dash, dataIf, draw, hexToRgb, inRange, isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isValidHex, isValidOKLCH, isValidRGB, iterate, list, makeEventListener, makeOnMotionEnd, max, min, mountStyle, noop, oklchToRgb, pascal, random, range, rgbToHex, rgbToOklch, runAtNextAnimationFrame, runSolidEventHandler, shuffle, sleep, snake, stringStyleToObject, template, title, toHex, trim, uid };
29
+ export { AnyFn, CreateVisibilityObserverOption, DocumentEventName, EntryCallback, Fn, GeneralEventListener, MaybeAccessor, MaybeArray, MaybeNullableAccessor, MaybePromise, OKLCH, RGB, UseVisibilityObserverFn, WindowEventName, access, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside, createDebounce, createDebouncedWatch, createEventListener, createIntersectionObserver, createLoopExec, createThrottle, createVisibilityObserver, createWatch, dash, dataIf, draw, hexToRgb, inRange, isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isValidHex, isValidOKLCH, isValidRGB, iterate, list, makeEventListener, max, min, mountStyle, noop, oklchToRgb, pascal, random, range, rgbToHex, rgbToOklch, runAtNextAnimationFrame, runSolidEventHandler, shuffle, sleep, snake, stringStyleToObject, template, title, toHex, trim, uid };
package/dist/index.mjs CHANGED
@@ -20,8 +20,7 @@ import { createClickOutside } from "./event/create-click-outside.mjs";
20
20
  import { createEventListener } from "./event/create-event-listener.mjs";
21
21
  import { createIntersectionObserver } from "./event/create-intersection-observer.mjs";
22
22
  import { createVisibilityObserver } from "./event/create-visibility-observer.mjs";
23
- import { createOnMotionEnd, makeOnMotionEnd } from "./event/on-motion-end.mjs";
24
23
  import { runSolidEventHandler } from "./event/index.mjs";
25
24
  import { dataIf } from "./jsx/attrs.mjs";
26
25
 
27
- export { access, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside, createDebounce, createDebouncedWatch, createEventListener, createIntersectionObserver, createLoopExec, createOnMotionEnd, createThrottle, createVisibilityObserver, createWatch, dash, dataIf, draw, hexToRgb, inRange, isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isValidHex, isValidOKLCH, isValidRGB, iterate, list, makeEventListener, makeOnMotionEnd, max, min, mountStyle, noop, oklchToRgb, pascal, random, range, rgbToHex, rgbToOklch, runAtNextAnimationFrame, runSolidEventHandler, shuffle, sleep, snake, stringStyleToObject, template, title, toHex, trim, uid };
26
+ export { access, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside, createDebounce, createDebouncedWatch, createEventListener, createIntersectionObserver, createLoopExec, createThrottle, createVisibilityObserver, createWatch, dash, dataIf, draw, hexToRgb, inRange, isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isValidHex, isValidOKLCH, isValidRGB, iterate, list, makeEventListener, max, min, mountStyle, noop, oklchToRgb, pascal, random, range, rgbToHex, rgbToOklch, runAtNextAnimationFrame, runSolidEventHandler, shuffle, sleep, snake, stringStyleToObject, template, title, toHex, trim, uid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-tiny-utils",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "A collection of tiny utilities for SolidJS applications",
5
5
  "main": "./dist/index.mjs",
6
6
  "type": "module",
@@ -19,19 +19,19 @@
19
19
  "@testing-library/user-event": "^14.6.1",
20
20
  "@types/culori": "^4.0.0",
21
21
  "@types/node": "^25.0.3",
22
+ "@typescript/native-preview": "7.0.0-dev.20251226.1",
22
23
  "@vitest/ui": "^4.0.16",
23
24
  "bumpp": "^10.2.3",
24
25
  "culori": "^4.0.2",
25
26
  "jsdom": "^27.3.0",
27
+ "solid-tiny-context": "0.2.3",
26
28
  "tsdown": "^0.18.3",
27
- "typescript": "^5.8.3",
28
29
  "ultracite": "6.5.0",
29
30
  "unocss": "^66.3.3",
30
31
  "vite": "^7.3.0",
31
32
  "vite-plugin-solid": "^2.11.0",
32
- "vite-plugin-solid-pages": "^0.3.4",
33
- "vitest": "^4.0.16",
34
- "solid-tiny-context": "0.2.3"
33
+ "vite-plugin-solid-pages": "^0.3.5",
34
+ "vitest": "^4.0.16"
35
35
  },
36
36
  "keywords": [
37
37
  "solidjs",
@@ -57,7 +57,7 @@
57
57
  "lint": "pnpm dlx ultracite@latest check",
58
58
  "lint:error": "pnpm dlx ultracite@latest check --diagnostic-level error",
59
59
  "lint:fix": "pnpm dlx ultracite@latest fix",
60
- "type-check": "tsc --noEmit --skipLibCheck",
60
+ "type-check": "tsgo --noEmit --skipLibCheck",
61
61
  "bump": "pnpm type-check && pnpm lint:fix && pnpm test && pnpm bumpp --no-push",
62
62
  "prepublish": "pnpm build"
63
63
  }
@@ -1,63 +0,0 @@
1
- //#region src/event/on-motion-end.d.ts
2
- type Accessor<T> = () => T;
3
- type OnMotionEndType = "animationend" | "transitionend" | "transitioncancel" | "no-motion";
4
- interface OnMotionEndOptions {
5
- /**
6
- * Specifies which type of motion to listen for.
7
- *
8
- * @default "auto"
9
- */
10
- motionType?: "animation" | "transition" | "auto";
11
- /**
12
- * If true, the callback will be executed immediately if there are no motions on the element.
13
- *
14
- * @default true
15
- */
16
- execWhenNoMotion?: boolean;
17
- /**
18
- * If true, 'transitioncancel' events will also be detected and treated as motion end.
19
- *
20
- * @default false
21
- */
22
- detectCancelled?: boolean;
23
- }
24
- /**
25
- * Calls the callback when all CSS motions (animations and transitions) on the element have ended.
26
- *
27
- * if opt.motionType is set to "auto" (default), both animations and transitions are considered,
28
- * but animation takes precedence if both are present.
29
- *
30
- *
31
- * @example
32
- * ```ts
33
- * import { makeOnMotionEnd } from "solid-tiny-utils/event";
34
- *
35
- * const el = document.getElementById("my-element");
36
- *
37
- * makeOnMotionEnd(el, () => {
38
- * console.log("All motions ended!");
39
- * });
40
- * ```
41
- */
42
- declare function makeOnMotionEnd(el: HTMLElement, cb: (params: {
43
- type: OnMotionEndType;
44
- }) => void, opt?: OnMotionEndOptions): () => void;
45
- /** * Reactive version of `makeOnMotionEnd`.
46
- *
47
- * @example
48
- * ```ts
49
- * import { createOnMotionEnd } from "solid-tiny-utils/event";
50
- * import { createSignal } from "solid-js";
51
- *
52
- * const [el, setEl] = createSignal<HTMLElement | undefined>(undefined);
53
- *
54
- * createOnMotionEnd(el, () => {
55
- * console.log("All motions ended!");
56
- * });
57
- * ```
58
- */
59
- declare function createOnMotionEnd(el: Accessor<HTMLElement | undefined>, cb: (params: {
60
- type: OnMotionEndType;
61
- }) => void, opt?: OnMotionEndOptions): void;
62
- //#endregion
63
- export { OnMotionEndOptions, OnMotionEndType, createOnMotionEnd, makeOnMotionEnd };
@@ -1,96 +0,0 @@
1
- import { noop } from "../fn/index.mjs";
2
- import { createWatch } from "../reactive/create-watch.mjs";
3
- import { makeEventListener } from "./make-event-listener.mjs";
4
- import { onCleanup } from "solid-js";
5
-
6
- //#region src/event/on-motion-end.ts
7
- /**
8
- * Calls the callback when all CSS motions (animations and transitions) on the element have ended.
9
- *
10
- * if opt.motionType is set to "auto" (default), both animations and transitions are considered,
11
- * but animation takes precedence if both are present.
12
- *
13
- *
14
- * @example
15
- * ```ts
16
- * import { makeOnMotionEnd } from "solid-tiny-utils/event";
17
- *
18
- * const el = document.getElementById("my-element");
19
- *
20
- * makeOnMotionEnd(el, () => {
21
- * console.log("All motions ended!");
22
- * });
23
- * ```
24
- */
25
- function makeOnMotionEnd(el, cb, opt = {}) {
26
- const node = el;
27
- const style = getComputedStyle(node);
28
- const { motionType = "auto", execWhenNoMotion = true, detectCancelled = false } = opt;
29
- const allowAnimation = motionType === "animation" || motionType === "auto";
30
- const allowTransition = motionType === "transition" || motionType === "auto";
31
- const cleanups = [];
32
- const cleanup = () => {
33
- for (const c of cleanups) c();
34
- };
35
- const resolve = (params) => {
36
- cb(params);
37
- };
38
- if (allowAnimation) {
39
- const animNames = style.animationName.split(",").map((s) => s.trim());
40
- const animationIterationCounts = style.animationIterationCount.split(",").map((s) => s.trim());
41
- function onAnimEnd(e) {
42
- if (e.target !== node) return;
43
- resolve({ type: "animationend" });
44
- }
45
- if (style.animationName && style.animationName !== "none" && animNames.length > 0 && animationIterationCounts.some((count) => count !== "infinite")) {
46
- cleanups.push(makeEventListener(node, ["animationend"], onAnimEnd));
47
- onCleanup(cleanup);
48
- return cleanup;
49
- }
50
- }
51
- if (allowTransition) {
52
- const transProps = style.transitionProperty.split(",").map((s) => s.trim());
53
- const transPending = /* @__PURE__ */ new Set();
54
- function onTransEnd(e) {
55
- if (e.target !== node) return;
56
- transPending.delete(e.propertyName);
57
- if (transPending.size === 0) resolve({ type: e.type });
58
- }
59
- function onTransRun(e) {
60
- if (e.target !== node) return;
61
- transPending.add(e.propertyName);
62
- }
63
- if (transProps.length > 0) {
64
- const events = detectCancelled ? ["transitionend", "transitioncancel"] : ["transitionend"];
65
- cleanups.push(makeEventListener(node, events, onTransEnd), makeEventListener(node, "transitionrun", onTransRun));
66
- onCleanup(cleanup);
67
- return cleanup;
68
- }
69
- }
70
- if (execWhenNoMotion) cb({ type: "no-motion" });
71
- return cleanup;
72
- }
73
- /** * Reactive version of `makeOnMotionEnd`.
74
- *
75
- * @example
76
- * ```ts
77
- * import { createOnMotionEnd } from "solid-tiny-utils/event";
78
- * import { createSignal } from "solid-js";
79
- *
80
- * const [el, setEl] = createSignal<HTMLElement | undefined>(undefined);
81
- *
82
- * createOnMotionEnd(el, () => {
83
- * console.log("All motions ended!");
84
- * });
85
- * ```
86
- */
87
- function createOnMotionEnd(el, cb, opt) {
88
- let cleanup = noop;
89
- createWatch(el, (node) => {
90
- cleanup();
91
- if (node) cleanup = makeOnMotionEnd(node, cb, opt);
92
- });
93
- }
94
-
95
- //#endregion
96
- export { createOnMotionEnd, makeOnMotionEnd };