@zayne-labs/toolkit-react 0.12.23 → 0.12.24
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/esm/createReactStoreContext-Bb2sfy36.js.map +1 -1
- package/dist/esm/hooks/index.d.ts +1 -1
- package/dist/esm/{index-DzWZRj-h.d.ts → index-SvhMOnGq.d.ts} +9 -9
- package/dist/esm/{types-D3tTGVfK.d.ts → types-DZQaxhCz.d.ts} +3 -3
- package/dist/esm/zustand/compatible/index.d.ts +2 -2
- package/dist/esm/zustand/index.d.ts +2 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createReactStoreContext-Bb2sfy36.js","names":[],"sources":["../../src/zustand/createReactStoreContext.ts"],"sourcesContent":["import type { StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createElement } from \"react\";\nimport { createCustomContext, useStore, type CustomContextOptions } from \"../hooks\";\n\nconst createReactStoreContext = <\n\tTState extends Record<string, unknown>,\n\tTStore extends StoreApi<TState> = StoreApi<TState>,\n>(\n\toptions?: CustomContextOptions<TStore, true>\n) => {\n\tconst [Provider, useCustomContext] = createCustomContext(options);\n\n\ttype ZustandStoreContextProviderProps = {\n\t\tchildren: React.ReactNode;\n\t\tstore: TStore;\n\t};\n\n\tfunction ZustandStoreContextProvider(props: ZustandStoreContextProviderProps) {\n\t\tconst { children, store } = props;\n\n\t\treturn createElement(Provider, { value: store }, children);\n\t}\n\n\tconst useZustandStoreContext = <
|
|
1
|
+
{"version":3,"file":"createReactStoreContext-Bb2sfy36.js","names":[],"sources":["../../src/zustand/createReactStoreContext.ts"],"sourcesContent":["import type { StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createElement } from \"react\";\nimport { createCustomContext, useStore, type CustomContextOptions } from \"../hooks\";\n\nconst createReactStoreContext = <\n\tTState extends Record<string, unknown>,\n\tTStore extends StoreApi<TState> = StoreApi<TState>,\n>(\n\toptions?: CustomContextOptions<TStore, true>\n) => {\n\tconst [Provider, useCustomContext] = createCustomContext(options);\n\n\ttype ZustandStoreContextProviderProps = {\n\t\tchildren: React.ReactNode;\n\t\tstore: TStore;\n\t};\n\n\tfunction ZustandStoreContextProvider(props: ZustandStoreContextProviderProps) {\n\t\tconst { children, store } = props;\n\n\t\treturn createElement(Provider, { value: store }, children);\n\t}\n\n\tconst useZustandStoreContext = <TResult = TState>(selector?: SelectorFn<TState, TResult>): TResult => {\n\t\tconst zustandStore = useCustomContext();\n\n\t\treturn useStore(zustandStore, selector as never);\n\t};\n\n\treturn [ZustandStoreContextProvider, useZustandStoreContext] as [\n\t\tZustandStoreContextProvider: typeof ZustandStoreContextProvider,\n\t\tuseZustandStoreContext: typeof useZustandStoreContext,\n\t];\n};\n\nexport { createReactStoreContext };\n"],"mappings":";;;;AAKA,MAAM,2BAIL,YACI;CACJ,MAAM,CAAC,UAAU,oBAAoB,oBAAoB,QAAQ;CAOjE,SAAS,4BAA4B,OAAyC;EAC7E,MAAM,EAAE,UAAU,UAAU;AAE5B,SAAO,cAAc,UAAU,EAAE,OAAO,OAAO,EAAE,SAAS;;CAG3D,MAAM,0BAA4C,aAAoD;AAGrG,SAAO,SAFc,kBAAkB,EAET,SAAkB;;AAGjD,QAAO,CAAC,6BAA6B,uBAAuB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as useUnmountEffect, B as getErrorMessage, C as useConstant, D as useCallbackRef, E as useClickOutside, F as useAfterMountEffect, I as ContextError, L as CustomContextOptions, M as useLifeCycle, N as useEffectOnce, O as useAnimationInterval, P as useAsyncEffect, R as UseCustomContext, S as useControllableState, T as useComposeRefs, _ as useDisclosure, a as useStore, b as useCopyToClipboard, c as useCompareSelector, d as useSearchParamsObject, f as useSearch, g as useIsHydrated, h as useLocationState, i as useThrottleByTimer, j as useMountEffect, k as useAnimateElementRefs, l as useCompareValue, m as createUseLocationState, n as useThrottleByFrame, o as createUseStorageState, p as useScrollObserver, r as useThrottleBySetTimeout, s as useStorageState, t as useToggle, u as useSearchParams, v as useDebouncedFn, w as useLazyRef, x as useControllableProp, y as useDebouncedState, z as createCustomContext } from "../index-
|
|
1
|
+
import { A as useUnmountEffect, B as getErrorMessage, C as useConstant, D as useCallbackRef, E as useClickOutside, F as useAfterMountEffect, I as ContextError, L as CustomContextOptions, M as useLifeCycle, N as useEffectOnce, O as useAnimationInterval, P as useAsyncEffect, R as UseCustomContext, S as useControllableState, T as useComposeRefs, _ as useDisclosure, a as useStore, b as useCopyToClipboard, c as useCompareSelector, d as useSearchParamsObject, f as useSearch, g as useIsHydrated, h as useLocationState, i as useThrottleByTimer, j as useMountEffect, k as useAnimateElementRefs, l as useCompareValue, m as createUseLocationState, n as useThrottleByFrame, o as createUseStorageState, p as useScrollObserver, r as useThrottleBySetTimeout, s as useStorageState, t as useToggle, u as useSearchParams, v as useDebouncedFn, w as useLazyRef, x as useControllableProp, y as useDebouncedState, z as createCustomContext } from "../index-SvhMOnGq.js";
|
|
2
2
|
import "../index-6fIqihyt.js";
|
|
3
3
|
export { ContextError, CustomContextOptions, UseCustomContext, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useCompareSelector, useCompareValue, useComposeRefs, useConstant, useControllableProp, useControllableState, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { D as PossibleRef, f as StateSetter } from "./index-6fIqihyt.js";
|
|
2
2
|
import * as react1 from "react";
|
|
3
3
|
import { RefCallback, useEffect } from "react";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _zayne_labs_toolkit_core1 from "@zayne-labs/toolkit-core";
|
|
5
5
|
import { AllowedClipboardItems, AnimationIntervalOptions, CompareFnOptions, CopyToClipboardOptions, LocationInfo, LocationStoreApi, LocationStoreOptions, ScrollObserverOptions, StorageOptions, StorageStoreApi, StoreApi, URLSearchParamsInit } from "@zayne-labs/toolkit-core";
|
|
6
6
|
import { AnyFunction, CallbackFn, NonEmptyArray, Prettify, SelectorFn } from "@zayne-labs/toolkit-type-helpers";
|
|
7
7
|
|
|
@@ -212,14 +212,14 @@ declare const useIsHydrated: () => boolean;
|
|
|
212
212
|
//#endregion
|
|
213
213
|
//#region src/hooks/useLocationState.d.ts
|
|
214
214
|
type UseLocationResult<TSlice> = [state: TSlice, actions: LocationStoreApi];
|
|
215
|
-
declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<
|
|
216
|
-
push: (url: string |
|
|
215
|
+
declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<_zayne_labs_toolkit_core1.StoreApi<_zayne_labs_toolkit_core1.URLInfoObject>, "resetState" | "setState"> & {
|
|
216
|
+
push: (url: string | _zayne_labs_toolkit_core1.PartialURLInfo, options?: {
|
|
217
217
|
shouldNotifySync?: boolean;
|
|
218
|
-
state?:
|
|
218
|
+
state?: _zayne_labs_toolkit_core1.PartialURLInfo["state"];
|
|
219
219
|
}) => void;
|
|
220
220
|
replace: LocationStoreApi["push"];
|
|
221
221
|
triggerPopstateEvent: (nextLocationState?: LocationInfo["state"]) => void;
|
|
222
|
-
} & (<TSlice =
|
|
222
|
+
} & (<TSlice = _zayne_labs_toolkit_core1.URLInfoObject>(selector?: SelectorFn<LocationInfo, TSlice>) => UseLocationResult<TSlice>);
|
|
223
223
|
declare const useLocationState: <TSlice = LocationInfo>(selector?: SelectorFn<LocationInfo, TSlice>, options?: LocationStoreOptions) => UseLocationResult<TSlice>;
|
|
224
224
|
//#endregion
|
|
225
225
|
//#region src/hooks/useScrollObserver.d.ts
|
|
@@ -242,8 +242,8 @@ type UseSearchParamsOptions<TSearchParams extends URLSearchParamsInit> = Omit<Lo
|
|
|
242
242
|
action?: "push" | "replace";
|
|
243
243
|
defaultValues?: TSearchParams;
|
|
244
244
|
};
|
|
245
|
-
declare const useSearchParams: <TSearchParams extends URLSearchParamsInit>(options?: UseSearchParamsOptions<TSearchParams>) => [searchParams: URLSearchParams, setSearchParams: (newQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?:
|
|
246
|
-
declare const useSearchParamsObject: <TSearchParams extends Extract<URLSearchParamsInit, Record<string, string | string[]>>>(options?: UseSearchParamsOptions<TSearchParams>) => [searchParamsObject: TSearchParams, setSearchParamsObject: (newQueryParams: TSearchParams | ((prev: TSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?:
|
|
245
|
+
declare const useSearchParams: <TSearchParams extends URLSearchParamsInit>(options?: UseSearchParamsOptions<TSearchParams>) => [searchParams: URLSearchParams, setSearchParams: (newQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core1.LocationInfo["state"]) => void];
|
|
246
|
+
declare const useSearchParamsObject: <TSearchParams extends Extract<URLSearchParamsInit, Record<string, string | string[]>>>(options?: UseSearchParamsOptions<TSearchParams>) => [searchParamsObject: TSearchParams, setSearchParamsObject: (newQueryParams: TSearchParams | ((prev: TSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core1.LocationInfo["state"]) => void];
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/hooks/useCompare.d.ts
|
|
249
249
|
type UseCompareSelectorOptions = {
|
|
@@ -259,7 +259,7 @@ type UseStorageResult<TState, TSlice = TState> = [state: TSlice, actions: Storag
|
|
|
259
259
|
* @description Creates a custom hook that returns a storage state and actions to modify it. You can use this if you need shared options.
|
|
260
260
|
* @note You must use this if you want to be able to prevent syncing state across tabs.
|
|
261
261
|
*/
|
|
262
|
-
declare const createUseStorageState: <TState>(baseOptions: StorageOptions<TState>) =>
|
|
262
|
+
declare const createUseStorageState: <TState>(baseOptions: StorageOptions<TState>) => _zayne_labs_toolkit_core1.StoreApi<TState> & {
|
|
263
263
|
removeState: () => void;
|
|
264
264
|
} & (<TSlice = TState>(selector?: SelectorFn<TState, TSlice>) => UseStorageResult<TState, TSlice>);
|
|
265
265
|
type UseStorageStateOptions<TValue> = Omit<StorageOptions<TValue>, "initialValue" | "key">;
|
|
@@ -286,4 +286,4 @@ type InitialState = boolean | (() => boolean);
|
|
|
286
286
|
declare const useToggle: (initialValue?: InitialState) => [value: boolean, toggleValue: <TValue>(newValue?: TValue) => void];
|
|
287
287
|
//#endregion
|
|
288
288
|
export { useUnmountEffect as A, getErrorMessage as B, useConstant as C, useCallbackRef as D, useClickOutside as E, useAfterMountEffect as F, ContextError as I, CustomContextOptions as L, useLifeCycle as M, useEffectOnce as N, useAnimationInterval as O, useAsyncEffect as P, UseCustomContext as R, useControllableState as S, useComposeRefs as T, useDisclosure as _, useStore as a, useCopyToClipboard as b, useCompareSelector as c, useSearchParamsObject as d, useSearch as f, useIsHydrated as g, useLocationState as h, useThrottleByTimer as i, useMountEffect as j, useAnimateElementRefs as k, useCompareValue as l, createUseLocationState as m, useThrottleByFrame as n, createUseStorageState as o, useScrollObserver as p, useThrottleBySetTimeout as r, useStorageState as s, useToggle as t, useSearchParams as u, useDebouncedFn as v, useLazyRef as w, useControllableProp as x, useDebouncedState as y, createCustomContext as z };
|
|
289
|
-
//# sourceMappingURL=index-
|
|
289
|
+
//# sourceMappingURL=index-SvhMOnGq.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as CustomContextOptions } from "./index-
|
|
1
|
+
import { L as CustomContextOptions } from "./index-SvhMOnGq.js";
|
|
2
2
|
import * as react0 from "react";
|
|
3
3
|
import { StoreApi } from "@zayne-labs/toolkit-core";
|
|
4
4
|
import { SelectorFn } from "@zayne-labs/toolkit-type-helpers";
|
|
@@ -7,7 +7,7 @@ import { SelectorFn } from "@zayne-labs/toolkit-type-helpers";
|
|
|
7
7
|
declare const createReactStoreContext: <TState extends Record<string, unknown>, TStore extends StoreApi<TState> = StoreApi<TState>>(options?: CustomContextOptions<TStore, true>) => [ZustandStoreContextProvider: (props: {
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
store: TStore;
|
|
10
|
-
}) => react0.FunctionComponentElement<react0.ProviderProps<TStore>>, useZustandStoreContext: <
|
|
10
|
+
}) => react0.FunctionComponentElement<react0.ProviderProps<TStore>>, useZustandStoreContext: <TResult = TState>(selector?: SelectorFn<TState, TResult>) => TResult];
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/zustand/types.d.ts
|
|
13
13
|
type Get<T, K, F> = K extends keyof T ? T[K] : F;
|
|
@@ -24,4 +24,4 @@ interface StoreMutators<S, A> {}
|
|
|
24
24
|
type StoreMutatorIdentifier = keyof StoreMutators<unknown, unknown>;
|
|
25
25
|
//#endregion
|
|
26
26
|
export { createReactStoreContext as a, UseBoundStore as i, Mutate as n, StoreMutatorIdentifier as r, Get as t };
|
|
27
|
-
//# sourceMappingURL=types-
|
|
27
|
+
//# sourceMappingURL=types-DZQaxhCz.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../../index-
|
|
1
|
+
import "../../index-SvhMOnGq.js";
|
|
2
2
|
import "../../index-6fIqihyt.js";
|
|
3
|
-
import { a as createReactStoreContext, i as UseBoundStore, t as Get } from "../../types-
|
|
3
|
+
import { a as createReactStoreContext, i as UseBoundStore, t as Get } from "../../types-DZQaxhCz.js";
|
|
4
4
|
import { StoreApi } from "@zayne-labs/toolkit-core";
|
|
5
5
|
import { Mutate, StoreMutatorIdentifier } from "zustand";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../index-
|
|
1
|
+
import "../index-SvhMOnGq.js";
|
|
2
2
|
import "../index-6fIqihyt.js";
|
|
3
|
-
import { a as createReactStoreContext, i as UseBoundStore, n as Mutate, r as StoreMutatorIdentifier, t as Get } from "../types-
|
|
3
|
+
import { a as createReactStoreContext, i as UseBoundStore, n as Mutate, r as StoreMutatorIdentifier, t as Get } from "../types-DZQaxhCz.js";
|
|
4
4
|
import { StoreApi } from "@zayne-labs/toolkit-core";
|
|
5
5
|
|
|
6
6
|
//#region src/zustand/createReactStore.d.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zayne-labs/toolkit-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.12.
|
|
4
|
+
"version": "0.12.24",
|
|
5
5
|
"description": "A collection of utility functions, types and composables used by my other projects. Nothing too fancy but can be useful.",
|
|
6
6
|
"author": "Ryan Zayne",
|
|
7
7
|
"license": "MIT",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@zayne-labs/toolkit-
|
|
53
|
-
"@zayne-labs/toolkit-
|
|
52
|
+
"@zayne-labs/toolkit-type-helpers": "0.12.24",
|
|
53
|
+
"@zayne-labs/toolkit-core": "0.12.24"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@arethetypeswrong/cli": "^0.18.2",
|