@zayne-labs/toolkit-react 0.10.7 → 0.10.9
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ContextError, CustomContextOptions, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect } from "../index-
|
|
1
|
+
import { ContextError, CustomContextOptions, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect } from "../index-WGdWu8BB.js";
|
|
2
2
|
export { ContextError, CustomContextOptions, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyFunction, CallbackFn, NonEmptyArray, Prettify, SelectorFn } from "@zayne-labs/toolkit-type-helpers";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react6 from "react";
|
|
3
3
|
import { RefCallback, useEffect } from "react";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _zayne_labs_toolkit_core0 from "@zayne-labs/toolkit-core";
|
|
5
5
|
import { AnimationIntervalOptions, LocationInfo, LocationStoreApi, LocationStoreOptions, ScrollObserverOptions, StorageOptions, StorageStoreApi, StoreApi, URLSearchParamsInit } from "@zayne-labs/toolkit-core";
|
|
6
6
|
|
|
7
7
|
//#region src/hooks/createCustomContext.d.ts
|
|
@@ -19,8 +19,8 @@ type CustomContextOptions<TContextValue, TStrict extends boolean> = {
|
|
|
19
19
|
strict?: TStrict;
|
|
20
20
|
};
|
|
21
21
|
type UseCustomContextResult<TContextValue, TStrict extends boolean> = TStrict extends true ? TContextValue : TContextValue | null;
|
|
22
|
-
declare const createCustomContext: <TContextValue, TStrict extends boolean = true>(options?: CustomContextOptions<TContextValue, TStrict>) => [
|
|
23
|
-
$inferUnion:
|
|
22
|
+
declare const createCustomContext: <TContextValue, TStrict extends boolean = true>(options?: CustomContextOptions<TContextValue, TStrict>) => [react6.Context<TContextValue | null>, () => UseCustomContextResult<TContextValue, TStrict>] & {
|
|
23
|
+
$inferUnion: react6.Context<TContextValue | null> | (() => UseCustomContextResult<TContextValue, TStrict>);
|
|
24
24
|
};
|
|
25
25
|
//#endregion
|
|
26
26
|
//#region src/hooks/effects/useAfterMountEffect.d.ts
|
|
@@ -108,13 +108,13 @@ declare const useDebouncedFn: <TParams>(callBackFn: CallbackFn<TParams>, delay:
|
|
|
108
108
|
cancelMaxWait(): void;
|
|
109
109
|
};
|
|
110
110
|
declare const useDebouncedState: <TValue>(defaultValue: TValue, delay: number | undefined) => readonly [TValue, {
|
|
111
|
-
(...params:
|
|
112
|
-
(params:
|
|
111
|
+
(...params: react6.SetStateAction<TValue>[]): void;
|
|
112
|
+
(params: react6.SetStateAction<TValue> | react6.SetStateAction<TValue>[], overrideOptions: {
|
|
113
113
|
$delay: number;
|
|
114
114
|
}): void;
|
|
115
115
|
cancel: () => void;
|
|
116
116
|
cancelMaxWait(): void;
|
|
117
|
-
},
|
|
117
|
+
}, react6.Dispatch<react6.SetStateAction<TValue>>];
|
|
118
118
|
//#endregion
|
|
119
119
|
//#region src/hooks/useDisclosure.d.ts
|
|
120
120
|
type DisclosureOptions = {
|
|
@@ -138,13 +138,13 @@ declare const useIsServer: () => boolean;
|
|
|
138
138
|
//#endregion
|
|
139
139
|
//#region src/hooks/useLocationState.d.ts
|
|
140
140
|
type UseLocationResult<TSlice> = [state: TSlice, actions: LocationStoreApi];
|
|
141
|
-
declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<
|
|
142
|
-
push: (url: string |
|
|
143
|
-
state?:
|
|
141
|
+
declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<_zayne_labs_toolkit_core0.StoreApi<_zayne_labs_toolkit_core0.URLInfoObject>, "setState" | "resetState"> & {
|
|
142
|
+
push: (url: string | _zayne_labs_toolkit_core0.PartialURLInfo, options?: {
|
|
143
|
+
state?: _zayne_labs_toolkit_core0.PartialURLInfo["state"];
|
|
144
144
|
}) => void;
|
|
145
145
|
replace: LocationStoreApi["push"];
|
|
146
146
|
triggerPopstateEvent: (nextLocationState?: LocationInfo["state"]) => void;
|
|
147
|
-
} & (<TSlice =
|
|
147
|
+
} & (<TSlice = _zayne_labs_toolkit_core0.URLInfoObject>(selector?: SelectorFn<LocationInfo, TSlice>) => UseLocationResult<TSlice>);
|
|
148
148
|
declare const useLocationState: <TSlice = LocationInfo>(selector?: SelectorFn<LocationInfo, TSlice>, options?: LocationStoreOptions) => UseLocationResult<TSlice>;
|
|
149
149
|
//#endregion
|
|
150
150
|
//#region src/hooks/useToggle.d.ts
|
|
@@ -199,7 +199,7 @@ declare const useSearch: <TData>(initialData: TData[], delay?: number) => {
|
|
|
199
199
|
data: TData[];
|
|
200
200
|
isLoading: boolean;
|
|
201
201
|
query: string;
|
|
202
|
-
setQuery:
|
|
202
|
+
setQuery: react6.Dispatch<react6.SetStateAction<string>>;
|
|
203
203
|
};
|
|
204
204
|
//#endregion
|
|
205
205
|
//#region src/hooks/useSearchParams.d.ts
|
|
@@ -208,11 +208,11 @@ type UseSearchParamsOptions = LocationStoreOptions & {
|
|
|
208
208
|
};
|
|
209
209
|
declare const useSearchParams: <TSearchParams extends URLSearchParamsInit>(options?: UseSearchParamsOptions) => readonly [URLSearchParams, {
|
|
210
210
|
(newQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)): void;
|
|
211
|
-
triggerPopstateEvent: (nextLocationState?:
|
|
211
|
+
triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core0.LocationInfo["state"]) => void;
|
|
212
212
|
}];
|
|
213
213
|
declare const useSearchParamsObject: <TSearchParams extends Record<string, string>>(options?: UseSearchParamsOptions) => readonly [TSearchParams, {
|
|
214
214
|
(newQueryParams: TSearchParams | ((prev: TSearchParams) => TSearchParams)): void;
|
|
215
|
-
triggerPopstateEvent: (nextLocationState?:
|
|
215
|
+
triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core0.LocationInfo["state"]) => void;
|
|
216
216
|
}];
|
|
217
217
|
//#endregion
|
|
218
218
|
//#region src/hooks/useShallowCompare.d.ts
|
|
@@ -225,7 +225,7 @@ type UseStorageResult<TState, TSlice = TState> = [state: TSlice, actions: Storag
|
|
|
225
225
|
* @description Creates a custom hook that returns a storage state and actions to modify it. You can use this if you need shared options.
|
|
226
226
|
* @note You must use this if you want to be able to prevent syncing state across tabs.
|
|
227
227
|
*/
|
|
228
|
-
declare const createUseStorageState: <TState>(baseOptions: StorageOptions<TState>) =>
|
|
228
|
+
declare const createUseStorageState: <TState>(baseOptions: StorageOptions<TState>) => _zayne_labs_toolkit_core0.StoreApi<TState> & {
|
|
229
229
|
removeState: () => void;
|
|
230
230
|
} & (<TSlice = TState>(selector?: SelectorFn<TState, TSlice>) => UseStorageResult<TState, TSlice>);
|
|
231
231
|
type UseStorageStateOptions<TValue> = Omit<StorageOptions<TValue>, "initialValue" | "key">;
|
|
@@ -248,4 +248,4 @@ declare const useThrottleByFrame: <TParams>(callbackFn: CallbackFn<TParams>) =>
|
|
|
248
248
|
};
|
|
249
249
|
//#endregion
|
|
250
250
|
export { ContextError, CustomContextOptions, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
|
|
251
|
-
//# sourceMappingURL=index-
|
|
251
|
+
//# sourceMappingURL=index-WGdWu8BB.d.ts.map
|
|
@@ -45,10 +45,25 @@ type ForwardedRefType<TComponent extends HTMLElement | React.ElementType> = TCom
|
|
|
45
45
|
type InferProps<TComponent extends HTMLElement | React.ElementType> = TComponent extends React.ElementType ? React.ComponentPropsWithRef<TComponent> : React.HTMLAttributes<TComponent>;
|
|
46
46
|
type StateSetter<TSetter = unknown> = React.Dispatch<React.SetStateAction<TSetter>>;
|
|
47
47
|
type CssWithCustomProperties<TExtra extends Record<string, string> = NonNullable<unknown>> = React.CSSProperties & Record<`--${string}`, string> & TExtra;
|
|
48
|
-
type
|
|
48
|
+
type DefaultRenderItemErrorMessages = {
|
|
49
49
|
children: "Hey, Sorry but the children prop is redundant since you're currently using the render prop to do the same thing";
|
|
50
50
|
renderItem: "Hey, Sorry but the renderItem prop is redundant since you're currently using the children prop to do the same thing";
|
|
51
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* @description Represents a set of props that can be used to render a component conditionally based on a discriminated union type.
|
|
54
|
+
* This type allows for the use of either a render prop or children prop, but not both at the same time.
|
|
55
|
+
* If both are provided, a TypeScript error will be thrown.
|
|
56
|
+
* @template TErrorMessages An object of custom messages to display on the disallowed property.
|
|
57
|
+
*/
|
|
58
|
+
type DiscriminatedRenderItemProps<TRenderItemPropType, TErrorMessages extends Record<keyof DefaultRenderItemErrorMessages, string> = DefaultRenderItemErrorMessages> = UnionDiscriminator<[{
|
|
59
|
+
children: TRenderItemPropType;
|
|
60
|
+
}, {
|
|
61
|
+
renderItem: TRenderItemPropType;
|
|
62
|
+
}], TErrorMessages>;
|
|
63
|
+
type DefaultRenderErrorMessages = {
|
|
64
|
+
children: "Hey, Sorry but the children prop is redundant since you're currently using the render prop to do the same thing";
|
|
65
|
+
render: "Hey, Sorry but the render prop is redundant since you're currently using the children prop to do the same thing";
|
|
66
|
+
};
|
|
52
67
|
/**
|
|
53
68
|
* @description Represents a set of props that can be used to render a component conditionally based on a discriminated union type.
|
|
54
69
|
* This type allows for the use of either a render prop or children prop, but not both at the same time.
|
|
@@ -58,7 +73,7 @@ type DefaultRenderErrorMessages = {
|
|
|
58
73
|
type DiscriminatedRenderProps<TRenderPropType, TErrorMessages extends Record<keyof DefaultRenderErrorMessages, string> = DefaultRenderErrorMessages> = UnionDiscriminator<[{
|
|
59
74
|
children: TRenderPropType;
|
|
60
75
|
}, {
|
|
61
|
-
|
|
76
|
+
render: TRenderPropType;
|
|
62
77
|
}], TErrorMessages>;
|
|
63
78
|
//#endregion
|
|
64
79
|
//#region src/utils/types/polymorphism.d.ts
|
|
@@ -69,5 +84,5 @@ type InferRemainingProps<TElement extends React.ElementType, TProps> = Omit<Infe
|
|
|
69
84
|
type MergedGivenPropsWithAs<TElement extends React.ElementType, TProps> = Prettify<Omit<AsProp<TElement>, keyof TProps> & TProps>;
|
|
70
85
|
type PolymorphicProps<TElement extends React.ElementType, TProps extends AnyObject = NonNullable<unknown>> = MergedGivenPropsWithAs<TElement, TProps> & InferRemainingProps<TElement, TProps>;
|
|
71
86
|
//#endregion
|
|
72
|
-
export { AsProp, CssWithCustomProperties, DefaultRenderErrorMessages, DiscriminatedRenderProps, ForwardedRefType, InferProps, PolymorphicProps, StateSetter, composeEventHandlers, composeRefs, composeTwoEventHandlers, mergeProps, mergeTwoProps, setRef, useComposeRefs };
|
|
87
|
+
export { AsProp, CssWithCustomProperties, DefaultRenderErrorMessages, DefaultRenderItemErrorMessages, DiscriminatedRenderItemProps, DiscriminatedRenderProps, ForwardedRefType, InferProps, PolymorphicProps, StateSetter, composeEventHandlers, composeRefs, composeTwoEventHandlers, mergeProps, mergeTwoProps, setRef, useComposeRefs };
|
|
73
88
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomContextOptions } from "../index-
|
|
1
|
+
import { CustomContextOptions } from "../index-WGdWu8BB.js";
|
|
2
2
|
import { AnyObject, Prettify, SelectorFn } from "@zayne-labs/toolkit-type-helpers";
|
|
3
3
|
import * as react8 from "react";
|
|
4
4
|
import { StoreApi } from "@zayne-labs/toolkit-core";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zayne-labs/toolkit-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.9",
|
|
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",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@zayne-labs/toolkit-
|
|
51
|
-
"@zayne-labs/toolkit-
|
|
50
|
+
"@zayne-labs/toolkit-type-helpers": "0.10.9",
|
|
51
|
+
"@zayne-labs/toolkit-core": "0.10.9"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@arethetypeswrong/cli": "^0.18.2",
|