solid-tiny-utils 0.13.0 → 0.14.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/index.d.mts +3 -1
- package/dist/index.mjs +3 -1
- package/dist/solidjs/assign-accessors.d.mts +13 -0
- package/dist/solidjs/assign-accessors.mjs +15 -0
- package/dist/solidjs/create-context-provider.d.mts +6 -0
- package/dist/solidjs/create-context-provider.mjs +20 -0
- package/dist/solidjs/index.d.mts +2 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4,10 +4,12 @@ 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 { assignAccessors } from "./solidjs/assign-accessors.mjs";
|
|
7
8
|
import { AnyFn, Fn } from "./types/fn.mjs";
|
|
8
9
|
import { MaybeAccessor, MaybeArray, MaybeNullableAccessor, MaybePromise } from "./types/maybe.mjs";
|
|
9
10
|
import { SetterParam } from "./types/solidjs.mjs";
|
|
10
11
|
import { createClickOutside } from "./solidjs/create-click-outside.mjs";
|
|
12
|
+
import { createContextProvider } from "./solidjs/create-context-provider.mjs";
|
|
11
13
|
import { createDebounce } from "./solidjs/create-debounce.mjs";
|
|
12
14
|
import { createDebouncedWatch } from "./solidjs/create-debounce-watch.mjs";
|
|
13
15
|
import { DocumentEventName, GeneralEventListener, WindowEventName, makeEventListener } from "./solidjs/make-event-listener.mjs";
|
|
@@ -29,4 +31,4 @@ import { isArray, isClient, isDate, isDefined, isEmpty, isFloat, isFn, isInt, is
|
|
|
29
31
|
import { clamp, inRange, max, min, toHex } from "./utils/number.mjs";
|
|
30
32
|
import { draw, random, shuffle, uid } from "./utils/random.mjs";
|
|
31
33
|
import { camel, capitalize, dash, pascal, snake, template, title, trim } from "./utils/str.mjs";
|
|
32
|
-
export { AnyFn, CreateVisibilityObserverOption, DocumentEventName, EntryCallback, Fn, GeneralEventListener, MakePresenceOptions, MaybeAccessor, MaybeArray, MaybeCallableChild, MaybeNullableAccessor, MaybePromise, OKLCH, PersistedStorage, PersistedStoreOption, PresencePhase, RGB, SetterParam, StaticStoreSetter, UseVisibilityObserverFn, WindowEventName, access, accessWith, callMaybeCallableChild, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside, 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 };
|
|
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -10,9 +10,11 @@ import { oklchToRgb, rgbToOklch } from "./color/oklch-rgb.mjs";
|
|
|
10
10
|
import { isValidHex, isValidOKLCH, isValidRGB } from "./color/validation.mjs";
|
|
11
11
|
import { hasAnimation } from "./dom/animation.mjs";
|
|
12
12
|
import { dataIf } from "./dom/attrs.mjs";
|
|
13
|
+
import { assignAccessors } from "./solidjs/assign-accessors.mjs";
|
|
13
14
|
import { makeEventListener } from "./solidjs/make-event-listener.mjs";
|
|
14
15
|
import { access, accessWith, callMaybeCallableChild, runSolidEventHandler } from "./solidjs/utils.mjs";
|
|
15
16
|
import { createClickOutside } from "./solidjs/create-click-outside.mjs";
|
|
17
|
+
import { createContextProvider } from "./solidjs/create-context-provider.mjs";
|
|
16
18
|
import { createDebounce } from "./solidjs/create-debounce.mjs";
|
|
17
19
|
import { createWatch } from "./solidjs/create-watch.mjs";
|
|
18
20
|
import { createDebouncedWatch } from "./solidjs/create-debounce-watch.mjs";
|
|
@@ -26,4 +28,4 @@ import { createPresence } from "./solidjs/create-presence.mjs";
|
|
|
26
28
|
import { createThrottle } from "./solidjs/create-throttle.mjs";
|
|
27
29
|
import { createVisibilityObserver } from "./solidjs/create-visibility-observer.mjs";
|
|
28
30
|
import { combineClass, combineStyle, mountStyle, stringStyleToObject } from "./dom/css.mjs";
|
|
29
|
-
export { access, accessWith, callMaybeCallableChild, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside, 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 };
|
|
31
|
+
export { 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 };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Accessor } from "solid-js";
|
|
2
|
+
|
|
3
|
+
//#region src/solidjs/assign-accessors.d.ts
|
|
4
|
+
type AccessorRecord = Record<PropertyKey, Accessor<unknown>>;
|
|
5
|
+
type AccessorValues<T extends AccessorRecord> = { readonly [K in keyof T]: ReturnType<T[K]> };
|
|
6
|
+
/**
|
|
7
|
+
* Assigns accessor-backed getters to an object.
|
|
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>>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { assignAccessors };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/solidjs/assign-accessors.ts
|
|
2
|
+
/**
|
|
3
|
+
* Assigns accessor-backed getters to an object.
|
|
4
|
+
*
|
|
5
|
+
* `append` keys must not already exist on `base`.
|
|
6
|
+
*/
|
|
7
|
+
function assignAccessors(base, append) {
|
|
8
|
+
for (const key in append) if (Object.hasOwn(append, key) && !Object.hasOwn(base, key)) Object.defineProperty(base, key, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: append[key]
|
|
11
|
+
});
|
|
12
|
+
return base;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { assignAccessors };
|
|
@@ -0,0 +1,6 @@
|
|
|
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 };
|
|
@@ -0,0 +1,20 @@
|
|
|
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 };
|
package/dist/solidjs/index.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { assignAccessors } from "./assign-accessors.mjs";
|
|
1
2
|
import { createClickOutside } from "./create-click-outside.mjs";
|
|
3
|
+
import { createContextProvider } from "./create-context-provider.mjs";
|
|
2
4
|
import { createDebounce } from "./create-debounce.mjs";
|
|
3
5
|
import { createDebouncedWatch } from "./create-debounce-watch.mjs";
|
|
4
6
|
import { DocumentEventName, GeneralEventListener, WindowEventName, makeEventListener } from "./make-event-listener.mjs";
|