solid-tiny-utils 0.14.0 → 0.16.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/dist/color/hex-rgb.d.mts +0 -1
- package/dist/color/validation.d.mts +0 -1
- package/dist/dom/css.d.mts +0 -1
- package/dist/dom/index.d.mts +2 -1
- package/dist/index.d.mts +12 -9
- package/dist/index.mjs +2 -2
- package/dist/solidjs/assign-accessors.d.mts +3 -8
- package/dist/solidjs/assign-accessors.mjs +4 -2
- package/dist/solidjs/create-click-outside.d.mts +1 -0
- package/dist/solidjs/create-debounce-watch.d.mts +0 -1
- package/dist/solidjs/create-debounce.d.mts +1 -0
- package/dist/solidjs/create-easy-context.d.mts +12 -0
- package/dist/solidjs/create-easy-context.mjs +30 -0
- package/dist/solidjs/create-event-listener.d.mts +1 -1
- package/dist/solidjs/create-intersection-observer.d.mts +3 -1
- package/dist/solidjs/create-list.d.mts +0 -1
- package/dist/solidjs/create-loop-exec.d.mts +0 -1
- package/dist/solidjs/create-persisted-store.d.mts +1 -2
- package/dist/solidjs/create-presence.d.mts +1 -1
- package/dist/solidjs/create-static-store.d.mts +1 -0
- package/dist/solidjs/create-static-store.mjs +2 -1
- package/dist/solidjs/create-throttle.d.mts +1 -0
- package/dist/solidjs/create-visibility-observer.d.mts +1 -1
- package/dist/solidjs/create-watch.d.mts +0 -1
- package/dist/solidjs/index.d.mts +3 -2
- package/dist/solidjs/make-event-listener.d.mts +1 -0
- package/dist/solidjs/utils.d.mts +3 -3
- package/dist/types/index.d.mts +2 -1
- package/dist/types/maybe.d.mts +0 -1
- package/dist/types/solidjs.d.mts +0 -1
- package/package.json +4 -4
- package/dist/solidjs/create-context-provider.d.mts +0 -6
- package/dist/solidjs/create-context-provider.mjs +0 -20
package/dist/color/hex-rgb.d.mts
CHANGED
package/dist/dom/css.d.mts
CHANGED
package/dist/dom/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { hasAnimation } from "./animation.mjs";
|
|
2
2
|
import { dataIf } from "./attrs.mjs";
|
|
3
|
-
import { combineClass, combineStyle, mountStyle, stringStyleToObject } from "./css.mjs";
|
|
3
|
+
import { combineClass, combineStyle, mountStyle, stringStyleToObject } from "./css.mjs";
|
|
4
|
+
export { combineClass, combineStyle, dataIf, hasAnimation, mountStyle, stringStyleToObject };
|
package/dist/index.d.mts
CHANGED
|
@@ -4,16 +4,25 @@ import { isValidHex, isValidOKLCH, isValidRGB } from "./color/validation.mjs";
|
|
|
4
4
|
import { hasAnimation } from "./dom/animation.mjs";
|
|
5
5
|
import { dataIf } from "./dom/attrs.mjs";
|
|
6
6
|
import { combineClass, combineStyle, mountStyle, stringStyleToObject } from "./dom/css.mjs";
|
|
7
|
+
import "./dom/index.mjs";
|
|
7
8
|
import { assignAccessors } from "./solidjs/assign-accessors.mjs";
|
|
8
9
|
import { AnyFn, Fn } from "./types/fn.mjs";
|
|
9
10
|
import { MaybeAccessor, MaybeArray, MaybeNullableAccessor, MaybePromise } from "./types/maybe.mjs";
|
|
10
11
|
import { SetterParam } from "./types/solidjs.mjs";
|
|
12
|
+
import "./types/index.mjs";
|
|
11
13
|
import { createClickOutside } from "./solidjs/create-click-outside.mjs";
|
|
12
|
-
import { createContextProvider } from "./solidjs/create-context-provider.mjs";
|
|
13
14
|
import { createDebounce } from "./solidjs/create-debounce.mjs";
|
|
14
15
|
import { createDebouncedWatch } from "./solidjs/create-debounce-watch.mjs";
|
|
16
|
+
import { EasyContext, createEasyContext } from "./solidjs/create-easy-context.mjs";
|
|
15
17
|
import { DocumentEventName, GeneralEventListener, WindowEventName, makeEventListener } from "./solidjs/make-event-listener.mjs";
|
|
16
18
|
import { createEventListener } from "./solidjs/create-event-listener.mjs";
|
|
19
|
+
import { clearArray, iterate, list, range } from "./utils/array.mjs";
|
|
20
|
+
import { runAtNextAnimationFrame, sleep } from "./utils/async.mjs";
|
|
21
|
+
import { noop } from "./utils/constant.mjs";
|
|
22
|
+
import { isArray, isClient, isDate, isDefined, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isUndefined } from "./utils/is.mjs";
|
|
23
|
+
import { clamp, inRange, max, min, toHex } from "./utils/number.mjs";
|
|
24
|
+
import { draw, random, shuffle, uid } from "./utils/random.mjs";
|
|
25
|
+
import { camel, capitalize, dash, pascal, snake, template, title, trim } from "./utils/str.mjs";
|
|
17
26
|
import { createIntersectionObserver } from "./solidjs/create-intersection-observer.mjs";
|
|
18
27
|
import { createList } from "./solidjs/create-list.mjs";
|
|
19
28
|
import { createLoopExec } from "./solidjs/create-loop-exec.mjs";
|
|
@@ -24,11 +33,5 @@ import { createThrottle } from "./solidjs/create-throttle.mjs";
|
|
|
24
33
|
import { CreateVisibilityObserverOption, EntryCallback, UseVisibilityObserverFn, createVisibilityObserver } from "./solidjs/create-visibility-observer.mjs";
|
|
25
34
|
import { createWatch } from "./solidjs/create-watch.mjs";
|
|
26
35
|
import { MaybeCallableChild, access, accessWith, callMaybeCallableChild, runSolidEventHandler } from "./solidjs/utils.mjs";
|
|
27
|
-
import
|
|
28
|
-
|
|
29
|
-
import { noop } from "./utils/constant.mjs";
|
|
30
|
-
import { isArray, isClient, isDate, isDefined, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isUndefined } from "./utils/is.mjs";
|
|
31
|
-
import { clamp, inRange, max, min, toHex } from "./utils/number.mjs";
|
|
32
|
-
import { draw, random, shuffle, uid } from "./utils/random.mjs";
|
|
33
|
-
import { camel, capitalize, dash, pascal, snake, template, title, trim } from "./utils/str.mjs";
|
|
34
|
-
export { AnyFn, CreateVisibilityObserverOption, DocumentEventName, EntryCallback, Fn, GeneralEventListener, MakePresenceOptions, MaybeAccessor, MaybeArray, MaybeCallableChild, MaybeNullableAccessor, MaybePromise, OKLCH, PersistedStorage, PersistedStoreOption, PresencePhase, RGB, SetterParam, StaticStoreSetter, UseVisibilityObserverFn, WindowEventName, access, accessWith, assignAccessors, callMaybeCallableChild, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside, createContextProvider, createDebounce, createDebouncedWatch, createEventListener, createIntersectionObserver, createList, createLoopExec, createPersistedStore, createPresence, createStaticStore, createThrottle, createVisibilityObserver, createWatch, dash, dataIf, draw, hasAnimation, hexToRgb, inRange, isArray, isClient, isDate, isDefined, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isUndefined, 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 };
|
|
36
|
+
import "./solidjs/index.mjs";
|
|
37
|
+
export { AnyFn, CreateVisibilityObserverOption, DocumentEventName, EasyContext, EntryCallback, Fn, GeneralEventListener, MakePresenceOptions, MaybeAccessor, MaybeArray, MaybeCallableChild, MaybeNullableAccessor, MaybePromise, OKLCH, PersistedStorage, PersistedStoreOption, PresencePhase, RGB, SetterParam, StaticStoreSetter, UseVisibilityObserverFn, WindowEventName, access, accessWith, assignAccessors, callMaybeCallableChild, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside, createDebounce, createDebouncedWatch, createEasyContext, createEventListener, createIntersectionObserver, createList, createLoopExec, createPersistedStore, createPresence, createStaticStore, createThrottle, createVisibilityObserver, createWatch, dash, dataIf, draw, hasAnimation, hexToRgb, inRange, isArray, isClient, isDate, isDefined, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isUndefined, 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
|
@@ -14,10 +14,10 @@ import { assignAccessors } from "./solidjs/assign-accessors.mjs";
|
|
|
14
14
|
import { makeEventListener } from "./solidjs/make-event-listener.mjs";
|
|
15
15
|
import { access, accessWith, callMaybeCallableChild, runSolidEventHandler } from "./solidjs/utils.mjs";
|
|
16
16
|
import { createClickOutside } from "./solidjs/create-click-outside.mjs";
|
|
17
|
-
import { createContextProvider } from "./solidjs/create-context-provider.mjs";
|
|
18
17
|
import { createDebounce } from "./solidjs/create-debounce.mjs";
|
|
19
18
|
import { createWatch } from "./solidjs/create-watch.mjs";
|
|
20
19
|
import { createDebouncedWatch } from "./solidjs/create-debounce-watch.mjs";
|
|
20
|
+
import { createEasyContext } from "./solidjs/create-easy-context.mjs";
|
|
21
21
|
import { createEventListener } from "./solidjs/create-event-listener.mjs";
|
|
22
22
|
import { createIntersectionObserver } from "./solidjs/create-intersection-observer.mjs";
|
|
23
23
|
import { createList } from "./solidjs/create-list.mjs";
|
|
@@ -28,4 +28,4 @@ import { createPresence } from "./solidjs/create-presence.mjs";
|
|
|
28
28
|
import { createThrottle } from "./solidjs/create-throttle.mjs";
|
|
29
29
|
import { createVisibilityObserver } from "./solidjs/create-visibility-observer.mjs";
|
|
30
30
|
import { combineClass, combineStyle, mountStyle, stringStyleToObject } from "./dom/css.mjs";
|
|
31
|
-
export { access, accessWith, assignAccessors, callMaybeCallableChild, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside,
|
|
31
|
+
export { access, accessWith, assignAccessors, callMaybeCallableChild, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside, createDebounce, createDebouncedWatch, createEasyContext, createEventListener, createIntersectionObserver, createList, createLoopExec, createPersistedStore, createPresence, createStaticStore, createThrottle, createVisibilityObserver, createWatch, dash, dataIf, draw, hasAnimation, hexToRgb, inRange, isArray, isClient, isDate, isDefined, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isUndefined, 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 };
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { Accessor } from "solid-js";
|
|
2
|
-
|
|
3
2
|
//#region src/solidjs/assign-accessors.d.ts
|
|
4
3
|
type AccessorRecord = Record<PropertyKey, Accessor<unknown>>;
|
|
5
|
-
type AccessorValues<T extends AccessorRecord> = { readonly [K in keyof T]: ReturnType<T[K]
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* `append` keys must not already exist on `base`.
|
|
10
|
-
*/
|
|
11
|
-
declare function assignAccessors<Base extends object, Append extends AccessorRecord>(base: Base, append: Append & { [K in keyof Base]?: never }): Readonly<Base & AccessorValues<Append>>;
|
|
4
|
+
type AccessorValues<T extends AccessorRecord> = { readonly [K in keyof T]: ReturnType<T[K]>; };
|
|
5
|
+
declare function assignAccessors<Append extends AccessorRecord>(append: Append): Readonly<AccessorValues<Append>>;
|
|
6
|
+
declare function assignAccessors<Base extends object, Append extends AccessorRecord>(base: Base, append: Append): Readonly<Omit<Base, keyof AccessorValues<Append>> & AccessorValues<Append>>;
|
|
12
7
|
//#endregion
|
|
13
8
|
export { assignAccessors };
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Assigns accessor-backed getters to an object.
|
|
4
4
|
*
|
|
5
|
-
* `append` keys
|
|
5
|
+
* `append` keys override keys that already exist on `base`.
|
|
6
6
|
*/
|
|
7
7
|
function assignAccessors(base, append) {
|
|
8
|
-
|
|
8
|
+
if (!append) return assignAccessors({}, base);
|
|
9
|
+
for (const key in append) if (Object.hasOwn(append, key)) Object.defineProperty(base, key, {
|
|
9
10
|
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
10
12
|
get: append[key]
|
|
11
13
|
});
|
|
12
14
|
return base;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MaybeAccessor } from "../types/maybe.mjs";
|
|
2
|
+
import "../types/index.mjs";
|
|
2
3
|
//#region src/solidjs/create-click-outside.d.ts
|
|
3
4
|
declare function createClickOutside(target: MaybeAccessor<HTMLElement | null | undefined>, handler: (event: PointerEvent) => void, options?: {
|
|
4
5
|
ignore?: MaybeAccessor<HTMLElement | null | undefined>[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MaybeAccessor } from "../types/maybe.mjs";
|
|
2
|
+
import "../types/index.mjs";
|
|
2
3
|
//#region src/solidjs/create-debounce.d.ts
|
|
3
4
|
declare function createDebounce<Args extends unknown[]>(callback: (...args: Args) => void, delay: MaybeAccessor<number>): (...args: Args) => void;
|
|
4
5
|
//#endregion
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ParentComponent } from "solid-js";
|
|
2
|
+
//#region src/solidjs/create-easy-context.d.ts
|
|
3
|
+
interface EasyContext<V, P extends object> {
|
|
4
|
+
initial: (params: P) => {
|
|
5
|
+
value: V;
|
|
6
|
+
Provider: ParentComponent;
|
|
7
|
+
};
|
|
8
|
+
useContext: () => V;
|
|
9
|
+
}
|
|
10
|
+
declare function createEasyContext<V, P extends object>(factory: (params: P) => V): EasyContext<V, P>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { EasyContext, createEasyContext };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isUndefined } from "../utils/is.mjs";
|
|
2
|
+
import { createComponent, createContext, useContext } from "solid-js";
|
|
3
|
+
//#region src/solidjs/create-easy-context.ts
|
|
4
|
+
function createEasyContext(factory) {
|
|
5
|
+
const ctx = createContext();
|
|
6
|
+
const initial = (params) => {
|
|
7
|
+
const value = factory(params);
|
|
8
|
+
const Provider = (props) => createComponent(ctx.Provider, {
|
|
9
|
+
value,
|
|
10
|
+
get children() {
|
|
11
|
+
return props.children;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
value,
|
|
16
|
+
Provider
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const useThisContext = () => {
|
|
20
|
+
const value = useContext(ctx);
|
|
21
|
+
if (isUndefined(value)) throw new Error("createEasyContext: missing context provider");
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
initial,
|
|
26
|
+
useContext: useThisContext
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { createEasyContext };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fn } from "../types/fn.mjs";
|
|
2
2
|
import { MaybeAccessor, MaybeArray } from "../types/maybe.mjs";
|
|
3
|
+
import "../types/index.mjs";
|
|
3
4
|
import { DocumentEventName, GeneralEventListener, WindowEventName } from "./make-event-listener.mjs";
|
|
4
|
-
|
|
5
5
|
//#region src/solidjs/create-event-listener.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Overload 2: Explicitly Window target
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { MaybeAccessor } from "../types/maybe.mjs";
|
|
2
|
+
import "../types/index.mjs";
|
|
3
|
+
import { noop } from "../utils/constant.mjs";
|
|
2
4
|
//#region src/solidjs/create-intersection-observer.d.ts
|
|
3
|
-
declare function createIntersectionObserver(targets: MaybeAccessor<HTMLElement | null | undefined>[], callback: IntersectionObserverCallback, options?: IntersectionObserverInit):
|
|
5
|
+
declare function createIntersectionObserver(targets: MaybeAccessor<HTMLElement | null | undefined>[], callback: IntersectionObserverCallback, options?: IntersectionObserverInit): typeof noop;
|
|
4
6
|
//#endregion
|
|
5
7
|
export { createIntersectionObserver };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { StaticStoreSetter } from "./create-static-store.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/solidjs/create-persisted-store.d.ts
|
|
4
3
|
interface PersistedStorage {
|
|
5
4
|
getItem(key: string): string | null;
|
|
@@ -37,6 +36,6 @@ interface PersistedStoreOption {
|
|
|
37
36
|
* setSettings({ sidebarOpen: false });
|
|
38
37
|
* ```
|
|
39
38
|
*/
|
|
40
|
-
declare function createPersistedStore<T extends
|
|
39
|
+
declare function createPersistedStore<T extends object>(init: T, opts?: PersistedStoreOption): readonly [T, StaticStoreSetter<T>];
|
|
41
40
|
//#endregion
|
|
42
41
|
export { PersistedStorage, PersistedStoreOption, createPersistedStore };
|
|
@@ -33,7 +33,8 @@ function createStaticStore(init) {
|
|
|
33
33
|
};
|
|
34
34
|
for (const key in init) if (Object.hasOwn(init, key)) Object.defineProperty(store, key, {
|
|
35
35
|
get: () => getValue(key),
|
|
36
|
-
enumerable: true
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true
|
|
37
38
|
});
|
|
38
39
|
const setValue = (key, value) => {
|
|
39
40
|
const signal = cache[key];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MaybeAccessor } from "../types/maybe.mjs";
|
|
2
|
+
import "../types/index.mjs";
|
|
2
3
|
//#region src/solidjs/create-throttle.d.ts
|
|
3
4
|
declare function createThrottle<Args extends unknown[]>(callback: (...args: Args) => void, delay: MaybeAccessor<number>): (...args: Args) => void;
|
|
4
5
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MaybeNullableAccessor } from "../types/maybe.mjs";
|
|
2
|
+
import "../types/index.mjs";
|
|
2
3
|
import { Accessor } from "solid-js";
|
|
3
|
-
|
|
4
4
|
//#region src/solidjs/create-visibility-observer.d.ts
|
|
5
5
|
type UseVisibilityObserverFn = (target: MaybeNullableAccessor<HTMLElement>) => Accessor<boolean>;
|
|
6
6
|
type CreateVisibilityObserverOption = IntersectionObserverInit & {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Accessor, AccessorArray, OnEffectFunction, OnOptions } from "solid-js";
|
|
2
|
-
|
|
3
2
|
//#region src/solidjs/create-watch.d.ts
|
|
4
3
|
declare function createWatch<S, Next extends Prev, Prev = Next>(targets: AccessorArray<S> | Accessor<S>, fn: OnEffectFunction<S, undefined | NoInfer<Prev>, Next>, opt?: OnOptions): void;
|
|
5
4
|
//#endregion
|
package/dist/solidjs/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { assignAccessors } from "./assign-accessors.mjs";
|
|
2
2
|
import { createClickOutside } from "./create-click-outside.mjs";
|
|
3
|
-
import { createContextProvider } from "./create-context-provider.mjs";
|
|
4
3
|
import { createDebounce } from "./create-debounce.mjs";
|
|
5
4
|
import { createDebouncedWatch } from "./create-debounce-watch.mjs";
|
|
5
|
+
import { EasyContext, createEasyContext } from "./create-easy-context.mjs";
|
|
6
6
|
import { DocumentEventName, GeneralEventListener, WindowEventName, makeEventListener } from "./make-event-listener.mjs";
|
|
7
7
|
import { createEventListener } from "./create-event-listener.mjs";
|
|
8
8
|
import { createIntersectionObserver } from "./create-intersection-observer.mjs";
|
|
@@ -14,4 +14,5 @@ import { MakePresenceOptions, PresencePhase, createPresence } from "./create-pre
|
|
|
14
14
|
import { createThrottle } from "./create-throttle.mjs";
|
|
15
15
|
import { CreateVisibilityObserverOption, EntryCallback, UseVisibilityObserverFn, createVisibilityObserver } from "./create-visibility-observer.mjs";
|
|
16
16
|
import { createWatch } from "./create-watch.mjs";
|
|
17
|
-
import { MaybeCallableChild, access, accessWith, callMaybeCallableChild, runSolidEventHandler } from "./utils.mjs";
|
|
17
|
+
import { MaybeCallableChild, access, accessWith, callMaybeCallableChild, runSolidEventHandler } from "./utils.mjs";
|
|
18
|
+
export { CreateVisibilityObserverOption, DocumentEventName, EasyContext, EntryCallback, GeneralEventListener, MakePresenceOptions, MaybeCallableChild, PersistedStorage, PersistedStoreOption, PresencePhase, StaticStoreSetter, UseVisibilityObserverFn, WindowEventName, access, accessWith, assignAccessors, callMaybeCallableChild, createClickOutside, createDebounce, createDebouncedWatch, createEasyContext, createEventListener, createIntersectionObserver, createList, createLoopExec, createPersistedStore, createPresence, createStaticStore, createThrottle, createVisibilityObserver, createWatch, makeEventListener, runSolidEventHandler };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fn } from "../types/fn.mjs";
|
|
2
2
|
import { MaybeArray } from "../types/maybe.mjs";
|
|
3
|
+
import "../types/index.mjs";
|
|
3
4
|
//#region src/solidjs/make-event-listener.d.ts
|
|
4
5
|
interface InferEventTarget<Events> {
|
|
5
6
|
addEventListener: (event: Events, fn?: any, options?: any) => any;
|
package/dist/solidjs/utils.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AnyFn } from "../types/fn.mjs";
|
|
2
2
|
import { MaybeAccessor } from "../types/maybe.mjs";
|
|
3
|
+
import "../types/index.mjs";
|
|
3
4
|
import { JSX } from "solid-js";
|
|
4
|
-
|
|
5
5
|
//#region src/solidjs/utils.d.ts
|
|
6
6
|
declare function access<T>(value: MaybeAccessor<T>): T;
|
|
7
7
|
/** If value is a function – call it with a given arguments – otherwise get the value as is */
|
|
8
8
|
declare function accessWith<T>(valueOrFn: T, ...args: T extends AnyFn ? Parameters<T> : never): T extends AnyFn ? ReturnType<T> : T;
|
|
9
9
|
declare function runSolidEventHandler<T, E extends Event, EHandler extends JSX.EventHandler<T, any> = JSX.EventHandler<T, E>>(event: E, handler?: EHandler | JSX.BoundEventHandler<T, E, EHandler>): void;
|
|
10
|
-
type MaybeCallableChild<T extends unknown[] = []> = JSX.Element | ((...args: T) => JSX.Element);
|
|
11
|
-
declare function callMaybeCallableChild<T extends unknown[] = []>(children: MaybeCallableChild<T>, ...args: T): JSX.Element;
|
|
10
|
+
type MaybeCallableChild<T extends readonly unknown[] = []> = JSX.Element | ((...args: T) => JSX.Element);
|
|
11
|
+
declare function callMaybeCallableChild<T extends readonly unknown[] = []>(children: MaybeCallableChild<T>, ...args: T): JSX.Element;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { MaybeCallableChild, access, accessWith, callMaybeCallableChild, runSolidEventHandler };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { AnyFn, Fn } from "./fn.mjs";
|
|
2
2
|
import { MaybeAccessor, MaybeArray, MaybeNullableAccessor, MaybePromise } from "./maybe.mjs";
|
|
3
|
-
import { SetterParam } from "./solidjs.mjs";
|
|
3
|
+
import { SetterParam } from "./solidjs.mjs";
|
|
4
|
+
export { AnyFn, Fn, MaybeAccessor, MaybeArray, MaybeNullableAccessor, MaybePromise, SetterParam };
|
package/dist/types/maybe.d.mts
CHANGED
package/dist/types/solidjs.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"@testing-library/user-event": "^14.6.1",
|
|
9
9
|
"@types/culori": "^4.0.0",
|
|
10
10
|
"@types/node": "^25.0.3",
|
|
11
|
-
"@typescript/native-preview": "7.0.0-dev.20260527.2",
|
|
12
11
|
"@vitest/ui": "^4.0.16",
|
|
13
12
|
"bumpp": "^11.1.0",
|
|
14
13
|
"culori": "^4.0.2",
|
|
15
14
|
"jsdom": "^29.1.1",
|
|
16
|
-
"tsdown": "^0.22.
|
|
15
|
+
"tsdown": "^0.22.7",
|
|
16
|
+
"typescript": "^7.0.2",
|
|
17
17
|
"ultracite": "7.7.0",
|
|
18
18
|
"unocss": "^66.7.0",
|
|
19
19
|
"vite": "^8.0.14",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"solid-js": "^1.9.7"
|
|
27
27
|
},
|
|
28
28
|
"type": "module",
|
|
29
|
-
"version": "0.
|
|
29
|
+
"version": "0.16.0",
|
|
30
30
|
"description": "A collection of tiny utilities for SolidJS applications",
|
|
31
31
|
"author": "solid tiny",
|
|
32
32
|
"license": "MIT",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"test": "vitest run",
|
|
61
61
|
"clean": "rimraf dist node_modules pnpm-lock.yaml",
|
|
62
62
|
"test:ui": "vitest --ui",
|
|
63
|
-
"tc": "
|
|
63
|
+
"tc": "tsc --noEmit --skipLibCheck",
|
|
64
64
|
"bump": "pnpm bumpp --no-push",
|
|
65
65
|
"prepublish": "pnpm build",
|
|
66
66
|
"check": "ultracite check",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ParentProps } from "solid-js";
|
|
2
|
-
|
|
3
|
-
//#region src/solidjs/create-context-provider.d.ts
|
|
4
|
-
declare function createContextProvider<P extends Record<string, unknown>, V>(factory: (props: P) => V): readonly [(props: ParentProps<P>) => import("solid-js").JSX.Element, () => V | undefined];
|
|
5
|
-
//#endregion
|
|
6
|
-
export { createContextProvider };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createComponent, createContext, splitProps, useContext } from "solid-js";
|
|
2
|
-
//#region src/solidjs/create-context-provider.ts
|
|
3
|
-
function createContextProvider(factory) {
|
|
4
|
-
const Ctx = createContext();
|
|
5
|
-
const Provider = (props) => {
|
|
6
|
-
const [local, rest] = splitProps(props, ["children"]);
|
|
7
|
-
return createComponent(Ctx.Provider, {
|
|
8
|
-
value: factory(rest),
|
|
9
|
-
get children() {
|
|
10
|
-
return local.children;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
function useStateContext() {
|
|
15
|
-
return useContext(Ctx);
|
|
16
|
-
}
|
|
17
|
-
return [Provider, useStateContext];
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { createContextProvider };
|