@zayne-labs/toolkit-react 0.12.16 → 0.12.18
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-Su6UuhCL.js → createReactStoreContext-BwiNZqMl.js} +2 -2
- package/dist/esm/{createReactStoreContext-Su6UuhCL.js.map → createReactStoreContext-BwiNZqMl.js.map} +1 -1
- package/dist/esm/hooks/index.d.ts +2 -2
- package/dist/esm/hooks/index.js +1 -1
- package/dist/esm/{hooks-DkhL0ElE.js → hooks-ByaT0fZg.js} +43 -43
- package/dist/esm/hooks-ByaT0fZg.js.map +1 -0
- package/dist/esm/{index-qDirhuAy.d.ts → index-6fIqihyt.d.ts} +3 -3
- package/dist/esm/{index-DDEEcoRa.d.ts → index-B0Wqh8dy.d.ts} +35 -40
- package/dist/esm/{types-jWYPkLEC.d.ts → types-Cl9wVD2w.d.ts} +2 -2
- package/dist/esm/utils/index.d.ts +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/{utils-BJUZGTbU.js → utils-DAG-7fTH.js} +19 -17
- package/dist/esm/utils-DAG-7fTH.js.map +1 -0
- package/dist/esm/zustand/compatible/index.d.ts +3 -3
- package/dist/esm/zustand/compatible/index.js +2 -2
- package/dist/esm/zustand/index.d.ts +3 -3
- package/dist/esm/zustand/index.js +2 -2
- package/package.json +8 -8
- package/dist/esm/hooks-DkhL0ElE.js.map +0 -1
- package/dist/esm/utils-BJUZGTbU.js.map +0 -1
package/dist/esm/{createReactStoreContext-Su6UuhCL.js → createReactStoreContext-BwiNZqMl.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as createCustomContext, m as useStore } from "./hooks-
|
|
1
|
+
import { L as createCustomContext, m as useStore } from "./hooks-ByaT0fZg.js";
|
|
2
2
|
import { createElement } from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/zustand/createReactStoreContext.ts
|
|
@@ -16,4 +16,4 @@ const createReactStoreContext = (options) => {
|
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
18
|
export { createReactStoreContext as t };
|
|
19
|
-
//# sourceMappingURL=createReactStoreContext-
|
|
19
|
+
//# sourceMappingURL=createReactStoreContext-BwiNZqMl.js.map
|
package/dist/esm/{createReactStoreContext-Su6UuhCL.js.map → createReactStoreContext-BwiNZqMl.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createReactStoreContext-
|
|
1
|
+
{"version":3,"file":"createReactStoreContext-BwiNZqMl.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);\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,SAAS;;AAGxC,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 useShallowCompSelector, d as useSearchParamsObject, f as useSearch, g as useIsHydrated, h as useLocationState, i as useThrottleByTimer, j as useMountEffect, k as useAnimateElementRefs, l as useShallowCompValue, 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-
|
|
2
|
-
import "../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 useShallowCompSelector, d as useSearchParamsObject, f as useSearch, g as useIsHydrated, h as useLocationState, i as useThrottleByTimer, j as useMountEffect, k as useAnimateElementRefs, l as useShallowCompValue, 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-B0Wqh8dy.js";
|
|
2
|
+
import "../index-6fIqihyt.js";
|
|
3
3
|
export { ContextError, CustomContextOptions, UseCustomContext, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useComposeRefs, useConstant, useControllableProp, useControllableState, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowCompSelector, useShallowCompValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as useMountEffect, C as useConstant, D as useAnimationInterval, E as useClickOutside, F as useCallbackRef, I as ContextError, L as createCustomContext, M as useEffectOnce, N as useAsyncEffect, O as useAnimateElementRefs, P as useAfterMountEffect, R as getErrorMessage, S as useControllableState, T as useComposeRefs, _ as useDebouncedFn, a as useStorageState, b as useToggle, c as useSearchParams, d as useScrollObserver, f as createUseLocationState, g as useDisclosure, h as useIsHydrated, i as createUseStorageState, j as useLifeCycle, k as useUnmountEffect, l as useSearchParamsObject, m as useStore, n as useThrottleBySetTimeout, o as useShallowCompSelector, p as useLocationState, r as useThrottleByTimer, s as useShallowCompValue, t as useThrottleByFrame, u as useSearch, v as useDebouncedState, w as useLazyRef, x as useControllableProp, y as useCopyToClipboard } from "../hooks-
|
|
1
|
+
import { A as useMountEffect, C as useConstant, D as useAnimationInterval, E as useClickOutside, F as useCallbackRef, I as ContextError, L as createCustomContext, M as useEffectOnce, N as useAsyncEffect, O as useAnimateElementRefs, P as useAfterMountEffect, R as getErrorMessage, S as useControllableState, T as useComposeRefs, _ as useDebouncedFn, a as useStorageState, b as useToggle, c as useSearchParams, d as useScrollObserver, f as createUseLocationState, g as useDisclosure, h as useIsHydrated, i as createUseStorageState, j as useLifeCycle, k as useUnmountEffect, l as useSearchParamsObject, m as useStore, n as useThrottleBySetTimeout, o as useShallowCompSelector, p as useLocationState, r as useThrottleByTimer, s as useShallowCompValue, t as useThrottleByFrame, u as useSearch, v as useDebouncedState, w as useLazyRef, x as useControllableProp, y as useCopyToClipboard } from "../hooks-ByaT0fZg.js";
|
|
2
2
|
|
|
3
3
|
export { ContextError, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useComposeRefs, useConstant, useControllableProp, useControllableState, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowCompSelector, useShallowCompValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as composeRefs } from "./utils-
|
|
1
|
+
import { f as composeRefs } from "./utils-DAG-7fTH.js";
|
|
2
2
|
import { createContext, use, useCallback, useDebugValue, useDeferredValue, useEffect, useInsertionEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { copyToClipboard, createExternalStorageStore, createLocationStore, createScrollObserver, createSearchParams, debounce, lockScroll, on, onClickOutside, setAnimationInterval, shallowCompare, throttleByFrame, throttleBySetTimeout, throttleByTime, toArray } from "@zayne-labs/toolkit-core";
|
|
4
4
|
import { isArray, isBoolean, isFunction, isPlainObject } from "@zayne-labs/toolkit-type-helpers";
|
|
@@ -42,15 +42,15 @@ const useCallbackRef = (callbackFn) => {
|
|
|
42
42
|
//#endregion
|
|
43
43
|
//#region src/hooks/effects/useAfterMountEffect.ts
|
|
44
44
|
const useAfterMountEffect = (callBackFn, deps) => {
|
|
45
|
-
const
|
|
45
|
+
const isFirstMountRef = useRef(true);
|
|
46
46
|
const stableCallback = useCallbackRef(callBackFn);
|
|
47
47
|
useEffect(() => {
|
|
48
|
-
if (
|
|
49
|
-
|
|
48
|
+
if (isFirstMountRef.current) {
|
|
49
|
+
isFirstMountRef.current = false;
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
stableCallback();
|
|
53
|
-
}, deps);
|
|
53
|
+
}, [stableCallback, ...deps ?? []]);
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
@@ -59,13 +59,17 @@ function useAsyncEffect(effect, deps) {
|
|
|
59
59
|
const stableEffectCallback = useCallbackRef(effect);
|
|
60
60
|
const [destroy, setDestroy] = useState();
|
|
61
61
|
useEffect(() => {
|
|
62
|
-
const
|
|
62
|
+
const effectResult = stableEffectCallback();
|
|
63
63
|
async function execute() {
|
|
64
|
-
setDestroy(await
|
|
64
|
+
setDestroy(await effectResult);
|
|
65
65
|
}
|
|
66
66
|
execute();
|
|
67
67
|
return () => void destroy?.();
|
|
68
|
-
},
|
|
68
|
+
}, [
|
|
69
|
+
destroy,
|
|
70
|
+
stableEffectCallback,
|
|
71
|
+
...deps ?? []
|
|
72
|
+
]);
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
//#endregion
|
|
@@ -152,17 +156,21 @@ const useAnimateElementRefs = (elementsInfoArray) => {
|
|
|
152
156
|
//#region src/hooks/useAnimationInterval.ts
|
|
153
157
|
const useAnimationInterval = (options) => {
|
|
154
158
|
const { intervalDuration, onAnimation, once } = options;
|
|
155
|
-
const
|
|
156
|
-
const { start, stop } = useMemo(() => setAnimationInterval(
|
|
159
|
+
const stableCallback = useCallbackRef(onAnimation);
|
|
160
|
+
const { start, stop } = useMemo(() => setAnimationInterval(stableCallback, intervalDuration, { once }), [
|
|
157
161
|
intervalDuration,
|
|
158
|
-
|
|
162
|
+
stableCallback,
|
|
159
163
|
once
|
|
160
164
|
]);
|
|
161
165
|
useEffect(() => {
|
|
162
166
|
if (intervalDuration === null) return;
|
|
163
167
|
start();
|
|
164
168
|
return stop;
|
|
165
|
-
}, [
|
|
169
|
+
}, [
|
|
170
|
+
intervalDuration,
|
|
171
|
+
start,
|
|
172
|
+
stop
|
|
173
|
+
]);
|
|
166
174
|
return {
|
|
167
175
|
start,
|
|
168
176
|
stop
|
|
@@ -219,56 +227,48 @@ const useControllableProp = (options) => {
|
|
|
219
227
|
};
|
|
220
228
|
/**
|
|
221
229
|
* @description React hook to manage state that can be either controlled or uncontrolled.
|
|
222
|
-
* - When `options.
|
|
223
|
-
* In this mode, `value` always equals `options.
|
|
230
|
+
* - When `options.prop` is provided, the hook operates in controlled mode.
|
|
231
|
+
* In this mode, `value` always equals `options.prop` and `setState` will
|
|
224
232
|
* invoke `options.onChange(next)` without mutating internal state.
|
|
225
|
-
* - When `options.
|
|
226
|
-
* mode, initializing internal state from `options.
|
|
227
|
-
* it via `
|
|
228
|
-
* - All updates are gated by `options.equalityFn(prev, next)` which defaults
|
|
229
|
-
* to `Object.is`.
|
|
233
|
+
* - When `options.prop` is not provided, the hook operates in uncontrolled
|
|
234
|
+
* mode, initializing internal state from `options.defaultProp` and updating
|
|
235
|
+
* it via `setState`.
|
|
230
236
|
*
|
|
231
237
|
* @param options - Configuration options for the hook.
|
|
232
|
-
* @param options.
|
|
233
|
-
* @param options.
|
|
238
|
+
* @param options.prop - Controlled value. If defined, the state is controlled.
|
|
239
|
+
* @param options.defaultProp - Initial value for the uncontrolled state. Can be a
|
|
234
240
|
* function for lazy initialization or a direct value.
|
|
235
241
|
* @param options.onChange - Callback fired when a new value is requested. In
|
|
236
242
|
* controlled mode, this is invoked instead of updating internal state. In
|
|
237
243
|
* uncontrolled mode, it is called after the internal state updates.
|
|
238
|
-
* @
|
|
239
|
-
* update given `prevState` and `nextValue`. If the values are equal, the update
|
|
240
|
-
* is skipped. Defaults to `Object.is`.
|
|
241
|
-
* @returns A tuple `[value, setValue]` just like React.useState.
|
|
244
|
+
* @returns A tuple `[state, setState]` just like React.useState.
|
|
242
245
|
*
|
|
243
246
|
* @example
|
|
244
247
|
* // Uncontrolled usage
|
|
245
|
-
* const [
|
|
248
|
+
* const [state, setState] = useControllableState({ defaultProp: 0 });
|
|
246
249
|
*
|
|
247
250
|
* @example
|
|
248
251
|
* // Controlled usage
|
|
249
|
-
* const [
|
|
250
|
-
*
|
|
252
|
+
* const [state, setState] = useControllableState({
|
|
253
|
+
* prop: props.value,
|
|
251
254
|
* onChange: props.onChange,
|
|
252
255
|
* });
|
|
253
256
|
*/
|
|
254
257
|
const useControllableState = (options) => {
|
|
255
|
-
const {
|
|
256
|
-
const
|
|
257
|
-
const
|
|
258
|
-
const [unControlledState, setUncontrolledState] = useState(
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (stableEqualityFn(currentValue, nextValue)) return;
|
|
264
|
-
stableOnchangeProp?.(nextValue);
|
|
265
|
-
if (isControlled) return;
|
|
258
|
+
const { defaultProp, onChange, prop } = options;
|
|
259
|
+
const isControlled = options.isControlled ?? prop !== void 0;
|
|
260
|
+
const stableOnchange = useCallbackRef(onChange);
|
|
261
|
+
const [unControlledState, setUncontrolledState] = useState(defaultProp);
|
|
262
|
+
const state = isControlled ? prop : unControlledState;
|
|
263
|
+
return [state, useCallback((newValue) => {
|
|
264
|
+
const nextValue = isFunction(newValue) ? newValue(state) : newValue;
|
|
265
|
+
if (isControlled) return stableOnchange?.(nextValue);
|
|
266
266
|
setUncontrolledState(nextValue);
|
|
267
|
+
return stableOnchange?.(nextValue);
|
|
267
268
|
}, [
|
|
269
|
+
state,
|
|
268
270
|
isControlled,
|
|
269
|
-
|
|
270
|
-
stableEqualityFn,
|
|
271
|
-
currentValue
|
|
271
|
+
stableOnchange
|
|
272
272
|
])];
|
|
273
273
|
};
|
|
274
274
|
|
|
@@ -636,4 +636,4 @@ const useThrottleByFrame = (callbackFn) => {
|
|
|
636
636
|
|
|
637
637
|
//#endregion
|
|
638
638
|
export { useMountEffect as A, useConstant as C, useAnimationInterval as D, useClickOutside as E, useCallbackRef as F, ContextError as I, createCustomContext as L, useEffectOnce as M, useAsyncEffect as N, useAnimateElementRefs as O, useAfterMountEffect as P, getErrorMessage as R, useControllableState as S, useComposeRefs as T, useDebouncedFn as _, useStorageState as a, useToggle as b, useSearchParams as c, useScrollObserver as d, createUseLocationState as f, useDisclosure as g, useIsHydrated as h, createUseStorageState as i, useLifeCycle as j, useUnmountEffect as k, useSearchParamsObject as l, useStore as m, useThrottleBySetTimeout as n, useShallowCompSelector as o, useLocationState as p, useThrottleByTimer as r, useShallowCompValue as s, useThrottleByFrame as t, useSearch as u, useDebouncedState as v, useLazyRef as w, useControllableProp as x, useCopyToClipboard as y };
|
|
639
|
-
//# sourceMappingURL=hooks-
|
|
639
|
+
//# sourceMappingURL=hooks-ByaT0fZg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks-ByaT0fZg.js","names":["useLocationState","useStorageState"],"sources":["../../src/hooks/createCustomContext.ts","../../src/hooks/useCallbackRef.ts","../../src/hooks/effects/useAfterMountEffect.ts","../../src/hooks/effects/useAsyncEffect.ts","../../src/hooks/effects/useEffectOnce.ts","../../src/hooks/effects/useLifeCycle.ts","../../src/hooks/effects/useMountEffect.ts","../../src/hooks/effects/useUnMountEffect.ts","../../src/hooks/useAnimateElementRefs.ts","../../src/hooks/useAnimationInterval.ts","../../src/hooks/useClickOutside.ts","../../src/hooks/useComposeRefs.ts","../../src/hooks/useConstant.ts","../../src/hooks/useControllable.ts","../../src/hooks/useToggle.ts","../../src/hooks/useCopyToClipboard.ts","../../src/hooks/useDebounce.ts","../../src/hooks/useDisclosure.ts","../../src/hooks/useIsHydrated.ts","../../src/hooks/useStore.ts","../../src/hooks/useLocationState.ts","../../src/hooks/useScrollObserver.ts","../../src/hooks/useSearch.ts","../../src/hooks/useSearchParams.ts","../../src/hooks/useShallowCompare.ts","../../src/hooks/useStorageState.ts","../../src/hooks/useThrottle.ts"],"sourcesContent":["import { createContext, use } from \"react\";\n\nexport type CustomContextOptions<TContextValue, TStrict extends boolean> = {\n\tdefaultValue?: TContextValue | null;\n\terrorMessage?: string;\n\textendValue?: (contextValue: NoInfer<TContextValue> | null) => TContextValue | null;\n\thookName?: string;\n\tname?: string;\n\tproviderName?: string;\n\tstrict?: TStrict;\n};\n\nexport type UseCustomContext<TContextValue, TStrict extends boolean> = () => TStrict extends true ?\n\tTContextValue\n:\tTContextValue | null;\n\nexport const createCustomContext = <TContextValue = null, TStrict extends boolean = true>(\n\toptions: CustomContextOptions<TContextValue, TStrict> = {}\n) => {\n\tconst {\n\t\tdefaultValue = null,\n\t\terrorMessage,\n\t\textendValue,\n\t\thookName = \"useUnnamedContext\",\n\t\tproviderName = \"UnnamedContextProvider\",\n\t\tname = providerName.endsWith(\"Provider\") ? providerName.slice(0, -8) : \"UnnamedContext\",\n\t\tstrict = true,\n\t} = options;\n\n\tconst Context = createContext<TContextValue>(defaultValue as TContextValue);\n\n\tContext.displayName = name;\n\n\tconst useCustomContext: UseCustomContext<TContextValue, TStrict> = () => {\n\t\tconst contextValue = use(Context);\n\n\t\tconst extendedContextValue = extendValue?.(contextValue) ?? contextValue;\n\n\t\tif (strict && extendedContextValue === null) {\n\t\t\tthrow new ContextError(errorMessage ?? getErrorMessage(hookName, providerName));\n\t\t}\n\n\t\treturn extendedContextValue as NonNullable<typeof extendedContextValue>;\n\t};\n\n\treturn [Context, useCustomContext] as [\n\t\tProvider: typeof Context,\n\t\tuseCustomContext: typeof useCustomContext,\n\t];\n};\n\nexport class ContextError extends Error {\n\toverride name = \"ContextError\";\n}\n\nexport const getErrorMessage = (hook: string, provider: string) => {\n\treturn `${hook} returned \"null\". Did you forget to wrap the necessary components within ${provider}?`;\n};\n","import type { AnyFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useInsertionEffect, useRef } from \"react\";\n\n/**\n * @description\n * - Returns a stable function that always points to the latest version of the callback function.\n * - This is only is the callback passed is not null or undefined.\n */\n\n// eslint-disable-next-line ts-eslint/no-invalid-void-type -- Ignore\nconst useCallbackRef = <TCallback extends AnyFunction | null | undefined | void = AnyFunction>(\n\tcallbackFn: TCallback\n): TCallback => {\n\tconst callbackRef = useRef(callbackFn);\n\n\tuseInsertionEffect(() => {\n\t\t// == Doing this instead updating it during render cuz according to Dan Abramov, render should be pure\n\t\tcallbackRef.current = callbackFn;\n\t}, [callbackFn]);\n\n\tconst savedCallback = useCallback(\n\t\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- callbackRef.current can be null in some cases\n\t\t(...params: unknown[]) => (callbackRef.current as AnyFunction)?.(...params) as unknown,\n\t\t[]\n\t);\n\n\tconst callbackOrSavedCallback = callbackFn ? (savedCallback as TCallback) : callbackFn;\n\n\treturn callbackOrSavedCallback;\n};\n\nexport { useCallbackRef };\n","import { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nconst useAfterMountEffect: typeof useEffect = (callBackFn, deps) => {\n\tconst isFirstMountRef = useRef(true);\n\tconst stableCallback = useCallbackRef(callBackFn);\n\n\tuseEffect(() => {\n\t\tif (isFirstMountRef.current) {\n\t\t\tisFirstMountRef.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\tstableCallback();\n\t\t// eslint-disable-next-line react-hooks/rule-suppression -- Ignore\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- Ignore\n\t}, [stableCallback, ...(deps ?? [])]);\n};\nexport { useAfterMountEffect };\n","import { useEffect, useState } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nexport function useAsyncEffect(\n\teffect: () => Promise<ReturnType<React.EffectCallback>>,\n\tdeps?: React.DependencyList\n) {\n\tconst stableEffectCallback = useCallbackRef(effect);\n\tconst [destroy, setDestroy] = useState<ReturnType<React.EffectCallback>>();\n\n\tuseEffect(() => {\n\t\tconst effectResult = stableEffectCallback();\n\n\t\tasync function execute() {\n\t\t\tsetDestroy(await effectResult);\n\t\t}\n\n\t\tvoid execute();\n\n\t\treturn () => void destroy?.();\n\t\t// eslint-disable-next-line react-hooks/rule-suppression -- Ignore\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- Ignore\n\t}, [destroy, stableEffectCallback, ...(deps ?? [])]);\n}\n","import { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nconst useEffectOnce = (callBackFn: React.EffectCallback) => {\n\tconst stableCallback = useCallbackRef(callBackFn);\n\n\tconst effectGuardRef = useRef(false);\n\n\tuseEffect(() => {\n\t\tif (effectGuardRef.current) return;\n\n\t\teffectGuardRef.current = true;\n\n\t\treturn stableCallback();\n\t}, [stableCallback]);\n};\n\nexport { useEffectOnce };\n","import { useEffect } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nexport type Destructor = ReturnType<React.EffectCallback>;\n\ntype LifeCycleOptions = {\n\tonMount?: () => void;\n\tonUnmount?: Destructor;\n};\n\nconst useLifeCycle = ({ onMount, onUnmount }: LifeCycleOptions) => {\n\tconst stableOnMount = useCallbackRef(onMount);\n\tconst stableOnUnmount = useCallbackRef(onUnmount);\n\n\tuseEffect(() => {\n\t\tstableOnMount?.();\n\n\t\treturn stableOnUnmount;\n\t}, [stableOnMount, stableOnUnmount]);\n};\n\nexport { useLifeCycle };\n","import { useLifeCycle } from \"./useLifeCycle\";\n\nconst useMountEffect = (callBackFn: () => void) => {\n\tuseLifeCycle({ onMount: callBackFn });\n};\n\nexport { useMountEffect };\n","import { useLifeCycle, type Destructor } from \"./useLifeCycle\";\n\nconst useUnmountEffect = (cleanUpFn: Destructor) => useLifeCycle({ onUnmount: cleanUpFn });\n\nexport { useUnmountEffect };\n","import { on } from \"@zayne-labs/toolkit-core\";\nimport { isArray, type NonEmptyArray } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useRef } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype ElementsInfoArray<TTargetElement extends string> = NonEmptyArray<{\n\tanimationClass: string;\n\ttargetElement: TTargetElement;\n}>;\n\nconst removeClass = (target: HTMLElement, className: string) => () => target.classList.remove(className);\n\n/**\n * This is a custom React hook that adds and removes animation classes to specified HTML elements.\n * @param elementsInfoArray - An array of objects that contain information about the animation class and the target HTML element.\n * @returns - An object containing the refs of the animated elements and a function to handle the initiation and removal animation.\n */\n\nconst useAnimateElementRefs = <TTargetElement extends string>(\n\telementsInfoArray: ElementsInfoArray<TTargetElement>\n) => {\n\tconst elementsRef = useRef<Record<TTargetElement, HTMLElement | null>>({} as never);\n\n\tconst addAnimationClasses = useCallbackRef(() => {\n\t\tif (!isArray(elementsInfoArray)) {\n\t\t\tconsole.error(\"elementsInfo is not an Array\");\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const { animationClass, targetElement } of elementsInfoArray) {\n\t\t\tif (!elementsRef.current[targetElement]) {\n\t\t\t\tconsole.error(\"ElementError\", `\"${targetElement}\" element does not exist`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\telementsRef.current[targetElement].classList.add(animationClass);\n\t\t}\n\t});\n\n\tconst removeAnimationClasses = useCallbackRef(() => {\n\t\tif (!isArray(elementsInfoArray)) {\n\t\t\tconsole.error(\"elementsInfo is not an Array\");\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const { animationClass, targetElement } of elementsInfoArray) {\n\t\t\tif (!elementsRef.current[targetElement]) {\n\t\t\t\tconsole.error(\"ElementError\", `\"${targetElement}\" element does not exist`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ton(\n\t\t\t\t\"transitionend\",\n\t\t\t\telementsRef.current[targetElement],\n\t\t\t\tremoveClass(elementsRef.current[targetElement], animationClass)\n\t\t\t);\n\n\t\t\ton(\n\t\t\t\t\"animationend\",\n\t\t\t\telementsRef.current[targetElement],\n\t\t\t\tremoveClass(elementsRef.current[targetElement], animationClass)\n\t\t\t);\n\t\t}\n\t});\n\n\t// Add animation classes to elements and remove them after the animation ends\n\tconst handleElementsAnimation = useCallback(() => {\n\t\taddAnimationClasses();\n\n\t\tremoveAnimationClasses();\n\t}, [addAnimationClasses, removeAnimationClasses]);\n\n\t// eslint-disable-next-line react-hooks/refs -- Allow this for convenience\n\treturn { animatedElements: elementsRef.current, handleElementsAnimation };\n};\n\nexport { useAnimateElementRefs };\n","import { setAnimationInterval, type AnimationIntervalOptions } from \"@zayne-labs/toolkit-core\";\nimport type { Prettify } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useEffect, useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype AnimationOptions = Prettify<\n\tAnimationIntervalOptions & {\n\t\tintervalDuration: number | null;\n\t\tonAnimation: () => void;\n\t}\n>;\n\nconst useAnimationInterval = (options: AnimationOptions) => {\n\tconst { intervalDuration, onAnimation, once } = options;\n\n\tconst stableCallback = useCallbackRef(onAnimation);\n\n\tconst { start, stop } = useMemo(\n\t\t() => setAnimationInterval(stableCallback, intervalDuration, { once }),\n\t\t[intervalDuration, stableCallback, once]\n\t);\n\n\tuseEffect(() => {\n\t\tif (intervalDuration === null) return;\n\n\t\tstart();\n\n\t\treturn stop;\n\t}, [intervalDuration, start, stop]);\n\n\treturn { start, stop };\n};\n\nexport { useAnimationInterval };\n","import { onClickOutside, toArray } from \"@zayne-labs/toolkit-core\";\nimport { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype UseClickOutsideOptions<TElement extends HTMLElement> = {\n\tenabled?: boolean;\n\tonClick: (event: MouseEvent | TouchEvent) => void;\n\tref?: Array<React.RefObject<TElement>> | React.RefObject<TElement>;\n};\n\nconst useClickOutside = <TElement extends HTMLElement>(options: UseClickOutsideOptions<TElement>) => {\n\tconst innerRef = useRef<TElement>(null);\n\n\tconst { enabled = true, onClick, ref: refOrRefArray = innerRef } = options;\n\n\tconst savedOnClick = useCallbackRef(onClick);\n\n\tuseEffect(() => {\n\t\tif (!enabled) return;\n\n\t\tconst elementArray = toArray(refOrRefArray).map((ref) => ref.current);\n\n\t\tconst cleanup = onClickOutside(elementArray, savedOnClick);\n\n\t\treturn () => cleanup();\n\t}, [enabled, refOrRefArray, savedOnClick]);\n\n\treturn {\n\t\tref: innerRef,\n\t};\n};\n\nexport { useClickOutside };\n","import { useMemo } from \"react\";\nimport { composeRefs, type PossibleRef } from \"@/utils\";\n\nconst useComposeRefs = <TRef extends HTMLElement>(...refs: Array<PossibleRef<TRef>>) => {\n\t// eslint-disable-next-line react-hooks/rule-suppression -- Allow\n\t// eslint-disable-next-line react-hooks/exhaustive-deps -- Allow\n\tconst mergedRef = useMemo(() => composeRefs(...refs), refs);\n\n\treturn mergedRef;\n};\n\nexport { useComposeRefs };\n","import { useRef } from \"react\";\n\nexport const useConstant = <TResult>(initFn: () => TResult): TResult => {\n\tconst resultRef = useRef<TResult | null>(null);\n\n\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- The current case is justified since it's optimizable by the react compiler\n\tif (resultRef.current === null) {\n\t\tresultRef.current = initFn();\n\t}\n\n\t// eslint-disable-next-line react-hooks/refs -- Allow this for convenience\n\treturn resultRef.current;\n};\n\nexport const useLazyRef = <TResult>(initFn: () => TResult): React.RefObject<TResult> => {\n\tconst resultRef = useRef<TResult>(null as never);\n\n\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- The current case is justified since it's optimizable by the react compiler\n\tif (resultRef.current === null) {\n\t\tresultRef.current = initFn();\n\t}\n\n\treturn resultRef;\n};\n","\"use client\";\n\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport type { StateSetter } from \"@/utils\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype UseControllablePropOptions<TProp> = {\n\tprop: TProp | undefined;\n\tstate: TProp;\n};\n\n/**\n * @description Given a prop value and state value, the useControllableProp hook is used to determine whether a component is controlled or uncontrolled, and also returns the computed value.\n */\nexport const useControllableProp = <TProp>(options: UseControllablePropOptions<TProp>) => {\n\tconst { prop, state } = options;\n\n\tconst isControlled = prop !== undefined;\n\n\tconst value = isControlled ? prop : state;\n\n\tconst result = useMemo<[isControlled: typeof isControlled, value: typeof value]>(\n\t\t() => [isControlled, value],\n\t\t[isControlled, value]\n\t);\n\n\treturn result;\n};\n\ntype UseControllableStateOptions<TValue> = {\n\tdefaultProp?: TValue | (() => TValue);\n\tisControlled?: boolean;\n\tonChange?: (value: TValue) => void;\n\tprop?: TValue;\n};\n\n/**\n * @description React hook to manage state that can be either controlled or uncontrolled.\n * - When `options.prop` is provided, the hook operates in controlled mode.\n * In this mode, `value` always equals `options.prop` and `setState` will\n * invoke `options.onChange(next)` without mutating internal state.\n * - When `options.prop` is not provided, the hook operates in uncontrolled\n * mode, initializing internal state from `options.defaultProp` and updating\n * it via `setState`.\n *\n * @param options - Configuration options for the hook.\n * @param options.prop - Controlled value. If defined, the state is controlled.\n * @param options.defaultProp - Initial value for the uncontrolled state. Can be a\n * function for lazy initialization or a direct value.\n * @param options.onChange - Callback fired when a new value is requested. In\n * controlled mode, this is invoked instead of updating internal state. In\n * uncontrolled mode, it is called after the internal state updates.\n * @returns A tuple `[state, setState]` just like React.useState.\n *\n * @example\n * // Uncontrolled usage\n * const [state, setState] = useControllableState({ defaultProp: 0 });\n *\n * @example\n * // Controlled usage\n * const [state, setState] = useControllableState({\n * prop: props.value,\n * onChange: props.onChange,\n * });\n */\nexport const useControllableState = <TProp>(options: UseControllableStateOptions<TProp>) => {\n\tconst { defaultProp, onChange, prop } = options;\n\n\tconst isControlled = options.isControlled ?? prop !== undefined;\n\n\tconst stableOnchange = useCallbackRef(onChange);\n\n\tconst [unControlledState, setUncontrolledState] = useState(defaultProp as TProp);\n\n\tconst state = isControlled ? prop : unControlledState;\n\n\tconst setState: StateSetter<TProp> = useCallback(\n\t\t(newValue) => {\n\t\t\tconst nextValue = isFunction(newValue) ? newValue(state as TProp) : newValue;\n\n\t\t\tif (isControlled) {\n\t\t\t\treturn stableOnchange?.(nextValue);\n\t\t\t}\n\n\t\t\tsetUncontrolledState(nextValue);\n\t\t\treturn stableOnchange?.(nextValue);\n\t\t},\n\t\t[state, isControlled, stableOnchange]\n\t);\n\n\treturn [state, setState] as [state: typeof state, setState: typeof setState];\n};\n","import { useCallback, useState } from \"react\";\n\ntype InitialState = boolean | (() => boolean);\n\nconst useToggle = (initialValue: InitialState = false) => {\n\tconst [value, setValue] = useState(initialValue);\n\n\tconst toggleValue = useCallback(<TValue>(newValue?: TValue) => {\n\t\tif (typeof newValue === \"boolean\") {\n\t\t\tsetValue(newValue);\n\t\t\treturn;\n\t\t}\n\n\t\tsetValue((prev) => !prev);\n\t}, []);\n\n\treturn [value, toggleValue] as [value: typeof value, toggleValue: typeof toggleValue];\n};\n\nexport { useToggle };\n","import {\n\tcopyToClipboard,\n\ttype AllowedClipboardItems,\n\ttype CopyToClipboardOptions,\n} from \"@zayne-labs/toolkit-core\";\nimport { useCallback, useRef, useState } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useToggle } from \"./useToggle\";\n\nconst useCopyToClipboard = (options: CopyToClipboardOptions & { timeout?: number } = {}) => {\n\tconst { mimeType, onCopied, onError, onSuccess, timeout = 1500 } = options;\n\n\tconst [value, setValue] = useState<AllowedClipboardItems>(\"\");\n\n\tconst [hasCopied, toggleHasCopied] = useToggle(false);\n\tconst timeoutRef = useRef<number | null>(null);\n\n\tconst savedOnError = useCallbackRef(onError);\n\tconst savedOnSuccess = useCallbackRef(onSuccess);\n\tconst savedOnCopied = useCallbackRef(onCopied);\n\n\tconst handleHasCopied = useCallback(() => {\n\t\ttoggleHasCopied(true);\n\n\t\ttimeoutRef.current && clearTimeout(timeoutRef.current);\n\n\t\ttimeoutRef.current = setTimeout(() => {\n\t\t\ttoggleHasCopied(false);\n\t\t}, timeout) as never;\n\t}, [toggleHasCopied, timeout]);\n\n\tconst handleCopy = useCallback(\n\t\t(valueToCopy: AllowedClipboardItems) => {\n\t\t\tsetValue(valueToCopy);\n\n\t\t\tvoid copyToClipboard(valueToCopy, {\n\t\t\t\tmimeType,\n\t\t\t\tonCopied: () => {\n\t\t\t\t\tsavedOnCopied?.();\n\t\t\t\t\thandleHasCopied();\n\t\t\t\t},\n\t\t\t\tonError: savedOnError,\n\t\t\t\tonSuccess: savedOnSuccess,\n\t\t\t});\n\t\t},\n\t\t[handleHasCopied, mimeType, savedOnCopied, savedOnError, savedOnSuccess]\n\t);\n\n\treturn { handleCopy, hasCopied, setValue, value };\n};\n\nexport { useCopyToClipboard };\n","import { debounce } from \"@zayne-labs/toolkit-core\";\nimport type { CallbackFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo, useState } from \"react\";\nimport { useUnmountEffect } from \"./effects/useUnMountEffect\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nexport const useDebouncedFn = <TParams>(callBackFn: CallbackFn<TParams>, delay: number | undefined) => {\n\tconst latestCallback = useCallbackRef(callBackFn);\n\n\tconst debouncedFn = useMemo(() => debounce(latestCallback, delay), [delay, latestCallback]);\n\n\tuseUnmountEffect(() => {\n\t\tdebouncedFn.cancel();\n\t\tdebouncedFn.cancelMaxWait();\n\t});\n\n\treturn debouncedFn;\n};\n\nexport const useDebouncedState = <TValue>(defaultValue: TValue, delay: number | undefined) => {\n\tconst [value, setValue] = useState(defaultValue);\n\n\tconst setDebouncedValue = useMemo(() => debounce(setValue, delay), [delay]);\n\n\tuseUnmountEffect(() => {\n\t\tsetDebouncedValue.cancel();\n\t\tsetDebouncedValue.cancelMaxWait();\n\t});\n\n\treturn [value, setDebouncedValue, setValue] as const;\n};\n","import { lockScroll } from \"@zayne-labs/toolkit-core\";\nimport { isBoolean } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useToggle } from \"./useToggle\";\n\ntype DisclosureOptions = {\n\thasScrollControl?: boolean;\n\tinitialState?: boolean | (() => boolean);\n};\n\nconst useDisclosure = (options: DisclosureOptions = {}) => {\n\tconst { hasScrollControl = false, initialState = false } = options;\n\tconst [isOpen, toggleIsOpen] = useToggle(initialState);\n\n\tconst onOpen = useCallbackRef(() => {\n\t\ttoggleIsOpen(true);\n\t\thasScrollControl && lockScroll({ lock: true });\n\t});\n\n\tconst onClose = useCallbackRef(() => {\n\t\ttoggleIsOpen(false);\n\t\thasScrollControl && lockScroll({ lock: false });\n\t});\n\n\tconst onToggle = useCallbackRef(<TValue>(value?: TValue) => {\n\t\tif (isBoolean(value)) {\n\t\t\ttoggleIsOpen(value);\n\t\t\thasScrollControl && lockScroll({ lock: value });\n\t\t\treturn;\n\t\t}\n\n\t\tisOpen ? onClose() : onOpen();\n\t});\n\n\tconst api = useMemo(() => ({ isOpen, onClose, onOpen, onToggle }), [isOpen, onClose, onOpen, onToggle]);\n\n\treturn api;\n};\nexport { useDisclosure };\n","import { useDeferredValue, useSyncExternalStore } from \"react\";\n\nconst noop = () => {};\n\nconst noopStore = {\n\tgetServerSnapshot: () => true,\n\tgetSnapshot: () => false,\n\tsubscribe: () => noop,\n};\n\n/**\n * @description Return a boolean indicating if the JS has been hydrated already.\n * When doing Server-Side Rendering, the result will always be false.\n * When doing Client-Side Rendering, the result will always be false on the\n * first render and true from then on. Even if a new component renders it will\n * always start with true.\n *\n * @see https://github.com/sergiodxa/remix-utils/blob/main/src/react/use-hydrated.ts\n *\n * @see https://github.com/sergiodxa/remix-utils/blob/main/src/react/use-hydrated.ts\n *\n * @example\n * **Example: Disable a button that needs JS to work.**\n * ```tsx\n * const isHydrated = useIsHydrated();\n *\n * return (\n * <button type=\"button\" disabled={!isHydrated} onClick={doSomethingCustom}>\n * Click me\n * </button>\n * );\n * ```\n */\nconst useIsHydrated = () => {\n\tconst isHydrated = useSyncExternalStore(\n\t\tnoopStore.subscribe,\n\t\tnoopStore.getSnapshot,\n\t\tnoopStore.getServerSnapshot\n\t);\n\n\t// == Using useDeferredValue to make the returned value for uSES play nicely with React's concurrent mode.\n\t// LINK - https://kurtextrem.de/posts/react-uses-hydration#-concurrent-usesyncexternalstore\n\t// TODO - Switch concurrent react stores once it's officially released - https://react.dev/blog/2025/04/23/react-labs-view-transitions-activity-and-more#concurrent-stores\n\tconst deferredIsHydrated = useDeferredValue(isHydrated);\n\n\treturn deferredIsHydrated;\n};\n\nexport { useIsHydrated };\n","import type { StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useDebugValue, useDeferredValue, useSyncExternalStore } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nconst identity = <TState>(value: TState) => value;\n\nconst useStore = <TState, TSlice = TState>(\n\tstore: StoreApi<TState>,\n\tselector: SelectorFn<TState, TSlice> = identity as never\n) => {\n\tconst stableSelector = useCallbackRef(selector);\n\n\tconst stableGetState = useCallback(() => stableSelector(store.getState()), [stableSelector, store]);\n\n\tconst stableGetInitialState = useCallback(\n\t\t() => stableSelector(store.getInitialState()),\n\t\t[stableSelector, store]\n\t);\n\n\tconst slice = useSyncExternalStore(store.subscribe, stableGetState, stableGetInitialState);\n\n\tuseDebugValue(slice);\n\n\t// == Using useDeferredValue to make the returned value for uSES play nicely with React's concurrent mode.\n\t// LINK - https://kurtextrem.de/posts/react-uses-hydration#-concurrent-usesyncexternalstore\n\t// TODO - Switch concurrent react stores once it's officially released - https://react.dev/blog/2025/04/23/react-labs-view-transitions-activity-and-more#concurrent-stores\n\tconst deferredSlice = useDeferredValue(slice);\n\n\treturn deferredSlice;\n};\n\nexport { useStore };\n","import {\n\tcreateLocationStore,\n\ttype LocationInfo,\n\ttype LocationStoreApi,\n\ttype LocationStoreOptions,\n} from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useStore } from \"./useStore\";\n\ntype UseLocationResult<TSlice> = [state: TSlice, actions: LocationStoreApi];\n\nexport const createUseLocationState = (options?: LocationStoreOptions) => {\n\tconst locationStore = createLocationStore(options);\n\n\ttype UseBoundLocationState = LocationStoreApi\n\t\t& (<TSlice = LocationInfo>(\n\t\t\tselector?: SelectorFn<LocationInfo, TSlice>\n\t\t) => UseLocationResult<TSlice>);\n\n\tconst useLocationState = <TSlice = LocationInfo>(\n\t\tselector?: SelectorFn<LocationInfo, TSlice>\n\t): UseLocationResult<TSlice> => {\n\t\tconst stateSlice = useStore(locationStore as never, selector);\n\n\t\treturn [stateSlice, locationStore];\n\t};\n\n\tObject.assign(useLocationState, locationStore);\n\n\treturn useLocationState as UseBoundLocationState;\n};\n\nexport const useLocationState = <TSlice = LocationInfo>(\n\tselector?: SelectorFn<LocationInfo, TSlice>,\n\toptions: LocationStoreOptions = {}\n): UseLocationResult<TSlice> => {\n\tconst { equalityFn } = options;\n\n\tconst savedEqualityFn = useCallbackRef(equalityFn);\n\n\tconst locationStore = useMemo(\n\t\t() => createLocationStore({ equalityFn: savedEqualityFn }),\n\t\t[savedEqualityFn]\n\t);\n\n\tconst stateSlice = useStore(locationStore as never, selector);\n\n\treturn [stateSlice, locationStore];\n};\n","import { createScrollObserver, type ScrollObserverOptions } from \"@zayne-labs/toolkit-core\";\nimport { useMemo, useState, type RefCallback } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nconst useScrollObserver = <TElement extends HTMLElement>(options: ScrollObserverOptions = {}) => {\n\tconst { onIntersectionChange, root, rootMargin = \"10px 0px 0px 0px\", threshold } = options;\n\n\tconst [isScrolled, setIsScrolled] = useState(false);\n\n\tconst savedOnIntersectionChange = useCallbackRef(onIntersectionChange);\n\n\tconst { elementObserver, handleElementObservation } = useMemo(() => {\n\t\treturn createScrollObserver({\n\t\t\tonIntersectionChange: (entry, observer) => {\n\t\t\t\tconst newIsScrolledState = !entry.isIntersecting;\n\n\t\t\t\tsetIsScrolled(newIsScrolledState);\n\n\t\t\t\t// eslint-disable-next-line no-param-reassign -- Mutation is fine here\n\t\t\t\t(entry.target as HTMLElement).dataset.scrolled = String(newIsScrolledState);\n\n\t\t\t\tsavedOnIntersectionChange?.(entry, observer);\n\t\t\t},\n\t\t\troot,\n\t\t\trootMargin,\n\t\t\tthreshold,\n\t\t});\n\t}, [root, rootMargin, savedOnIntersectionChange, threshold]);\n\n\tconst observedElementRef: RefCallback<TElement> = useCallbackRef((element) => {\n\t\tconst cleanupFn = handleElementObservation(element);\n\n\t\t// == React 18 may not call the cleanup function so we need to call it manually on element unmount\n\t\tif (!element) {\n\t\t\tcleanupFn?.();\n\t\t\treturn;\n\t\t}\n\n\t\treturn cleanupFn;\n\t});\n\n\treturn { elementObserver, isScrolled, observedElementRef };\n};\n\nexport { useScrollObserver };\n","import { isPlainObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useState } from \"react\";\nimport { useAfterMountEffect } from \"./effects/useAfterMountEffect\";\nimport { useDebouncedFn } from \"./useDebounce\";\n\nconst isSerializable = (item: unknown): item is boolean | number | string =>\n\ttypeof item === \"string\" || typeof item === \"number\" || typeof item === \"boolean\";\n\nconst checkObjectPropsForQuery = (item: Record<string, unknown>, query: string): boolean => {\n\tfor (const value of Object.values(item)) {\n\t\tif (isSerializable(value) && value.toString().toLowerCase().includes(query)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n};\n\nconst useSearch = <TData>(initialData: TData[], delay?: number) => {\n\tconst [searchQuery, setSearchQuery] = useState(\"\");\n\tconst [filteredData, setFilteredData] = useState(initialData);\n\tconst [isLoading, setIsLoading] = useState(false);\n\n\tconst handleDebouncedSearch = useDebouncedFn(() => {\n\t\tconst query = searchQuery.toLowerCase();\n\n\t\tconst filteredResults = initialData.filter((item) => {\n\t\t\tif (isSerializable(item)) {\n\t\t\t\treturn item.toString().toLowerCase().includes(query);\n\t\t\t}\n\n\t\t\tif (isPlainObject(item)) {\n\t\t\t\treturn checkObjectPropsForQuery(item, query);\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\n\t\tsetFilteredData(filteredResults);\n\t\tsetIsLoading(false);\n\t}, delay);\n\n\tuseAfterMountEffect(() => {\n\t\tsetIsLoading(true);\n\t\thandleDebouncedSearch();\n\t}, [searchQuery]);\n\n\treturn { data: filteredData, isLoading, query: searchQuery, setQuery: setSearchQuery };\n};\n\nexport { useSearch };\n","import {\n\tcreateSearchParams,\n\ttype LocationStoreOptions,\n\ttype URLSearchParamsInit,\n} from \"@zayne-labs/toolkit-core\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useLocationState } from \"./useLocationState\";\n\ntype UseSearchParamsOptions = LocationStoreOptions & {\n\taction?: \"push\" | \"replace\";\n};\n\nexport const useSearchParams = <TSearchParams extends URLSearchParamsInit>(\n\toptions?: UseSearchParamsOptions\n) => {\n\tconst { action = \"push\", ...restOfOptions } = options ?? {};\n\n\tconst [searchParams, actions] = useLocationState((state) => state.search, restOfOptions);\n\n\tconst setSearchParams = (\n\t\tnewQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)\n\t) => {\n\t\tconst params = isFunction(newQueryParams) ? newQueryParams(searchParams) : newQueryParams;\n\n\t\tconst nextSearchParams = createSearchParams(params);\n\n\t\tactions[action]({ search: nextSearchParams });\n\t};\n\n\treturn [searchParams, setSearchParams, actions.triggerPopstateEvent] as [\n\t\tsearchParams: typeof searchParams,\n\t\tsetSearchParams: typeof setSearchParams,\n\t\ttriggerPopstateEvent: typeof actions.triggerPopstateEvent,\n\t];\n};\n\nexport const useSearchParamsObject = <TSearchParams extends Record<string, string>>(\n\toptions?: UseSearchParamsOptions\n) => {\n\tconst [searchParams, setSearchParams, triggerPopstateEvent] = useSearchParams(options);\n\n\tconst searchParamsObject = Object.fromEntries(searchParams) as TSearchParams;\n\n\tconst setSearchParamsObject = (\n\t\tnewQueryParams: TSearchParams | ((prev: TSearchParams) => TSearchParams)\n\t) => {\n\t\tconst params = isFunction(newQueryParams) ? newQueryParams(searchParamsObject) : newQueryParams;\n\n\t\tsetSearchParams(params);\n\t};\n\n\treturn [searchParamsObject, setSearchParamsObject, triggerPopstateEvent] as [\n\t\tsearchParamsObject: typeof searchParamsObject,\n\t\tsetSearchParamsObject: typeof setSearchParamsObject,\n\t\ttriggerPopstateEvent: typeof triggerPopstateEvent,\n\t];\n};\n","import { shallowCompare } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useInsertionEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nexport const useShallowCompSelector = <TState, TResult>(\n\tselector: SelectorFn<TState, TResult> | undefined\n) => {\n\tconst prevStateRef = useRef<TResult>(undefined as never);\n\n\tconst shallowSelector = useCallbackRef((state: TState) => {\n\t\tconst nextState = selector?.(state);\n\n\t\tif (!nextState) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\tif (shallowCompare(prevStateRef.current, nextState)) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\treturn (prevStateRef.current = nextState);\n\t});\n\n\treturn shallowSelector;\n};\n\nexport const useShallowCompValue = <TValue>(value: TValue) => {\n\tconst prevValueRef = useRef<TValue>(value);\n\n\tuseInsertionEffect(() => {\n\t\tif (shallowCompare(prevValueRef.current, value)) return;\n\n\t\tprevValueRef.current = value;\n\t});\n\n\t// eslint-disable-next-line react-hooks/refs -- Allow this for convenience\n\treturn prevValueRef.current;\n};\n","import {\n\tcreateExternalStorageStore,\n\ttype StorageOptions,\n\ttype StorageStoreApi,\n} from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useStore } from \"./useStore\";\n\ntype UseStorageResult<TState, TSlice = TState> = [state: TSlice, actions: StorageStoreApi<TState>];\n\n/**\n * @description Creates a custom hook that returns a storage state and actions to modify it. You can use this if you need shared options.\n * @note You must use this if you want to be able to prevent syncing state across tabs.\n */\nexport const createUseStorageState = <TState>(baseOptions: StorageOptions<TState>) => {\n\tconst externalStore = createExternalStorageStore(baseOptions);\n\n\ttype UseBoundStorageState = StorageStoreApi<TState>\n\t\t& (<TSlice = TState>(selector?: SelectorFn<TState, TSlice>) => UseStorageResult<TState, TSlice>);\n\n\tconst useStorageState = <TSlice = TState>(\n\t\tselector?: SelectorFn<TState, TSlice>\n\t): UseStorageResult<TState, TSlice> => {\n\t\tconst stateInStorage = useStore(externalStore, selector);\n\n\t\treturn [stateInStorage, externalStore];\n\t};\n\n\tObject.assign(useStorageState, externalStore);\n\n\treturn useStorageState as UseBoundStorageState;\n};\n\ntype UseStorageStateOptions<TValue> = Omit<StorageOptions<TValue>, \"initialValue\" | \"key\">;\n\nexport const useStorageState = <TValue, TSlice = TValue>(\n\tkey: string,\n\tinitialValue?: TValue,\n\toptions: UseStorageStateOptions<TValue> & { select?: SelectorFn<TValue, TSlice> } = {}\n): UseStorageResult<TValue, TSlice> => {\n\tconst { equalityFn, logger, parser, partialize, select, serializer, storageArea, syncStateAcrossTabs } =\n\t\toptions;\n\n\tconst savedEquality = useCallbackRef(equalityFn);\n\tconst savedLogger = useCallbackRef(logger);\n\tconst savedParser = useCallbackRef(parser);\n\tconst savedPartialize = useCallbackRef(partialize);\n\tconst savedSerializer = useCallbackRef(serializer);\n\n\tconst externalStore = useMemo(() => {\n\t\treturn createExternalStorageStore({\n\t\t\tequalityFn: savedEquality,\n\t\t\tinitialValue,\n\t\t\tkey,\n\t\t\tlogger: savedLogger,\n\t\t\tparser: savedParser,\n\t\t\tpartialize: savedPartialize,\n\t\t\tserializer: savedSerializer,\n\t\t\tstorageArea,\n\t\t\tsyncStateAcrossTabs,\n\t\t});\n\t}, [\n\t\tinitialValue,\n\t\tkey,\n\t\tsavedEquality,\n\t\tsavedLogger,\n\t\tsavedParser,\n\t\tsavedPartialize,\n\t\tsavedSerializer,\n\t\tstorageArea,\n\t\tsyncStateAcrossTabs,\n\t]);\n\n\tconst stateInStorage = useStore(externalStore as never, select as never);\n\n\treturn [stateInStorage as never, externalStore];\n};\n","import { throttleByFrame, throttleBySetTimeout, throttleByTime } from \"@zayne-labs/toolkit-core\";\nimport type { CallbackFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { useUnmountEffect } from \"./effects\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useConstant } from \"./useConstant\";\n\nexport const useThrottleBySetTimeout = <TParams>(callbackFn: CallbackFn<TParams>, delay: number) => {\n\tconst latestCallback = useCallbackRef(callbackFn);\n\n\tconst throttledCallback = useMemo(\n\t\t() => throttleBySetTimeout(latestCallback, delay),\n\t\t[delay, latestCallback]\n\t);\n\n\tuseUnmountEffect(() => throttledCallback.cancelTimeout());\n\n\treturn throttledCallback;\n};\n\nexport const useThrottleByTimer = <TParams>(callbackFn: CallbackFn<TParams>, delay: number) => {\n\tconst latestCallback = useCallbackRef(callbackFn);\n\n\tconst throttledCallback = useMemo(() => throttleByTime(latestCallback, delay), [delay, latestCallback]);\n\n\treturn throttledCallback;\n};\n\nexport const useThrottleByFrame = <TParams>(callbackFn: CallbackFn<TParams>) => {\n\tconst latestCallback = useCallbackRef(callbackFn);\n\n\tconst throttledCallback = useConstant(() => throttleByFrame(latestCallback));\n\n\tuseUnmountEffect(() => throttledCallback.cancelAnimation());\n\n\treturn throttledCallback;\n};\n"],"mappings":";;;;;;AAgBA,MAAa,uBACZ,UAAwD,EAAE,KACtD;CACJ,MAAM,EACL,eAAe,MACf,cACA,aACA,WAAW,qBACX,eAAe,0BACf,OAAO,aAAa,SAAS,WAAW,GAAG,aAAa,MAAM,GAAG,GAAG,GAAG,kBACvE,SAAS,SACN;CAEJ,MAAM,UAAU,cAA6B,aAA8B;AAE3E,SAAQ,cAAc;CAEtB,MAAM,yBAAmE;EACxE,MAAM,eAAe,IAAI,QAAQ;EAEjC,MAAM,uBAAuB,cAAc,aAAa,IAAI;AAE5D,MAAI,UAAU,yBAAyB,KACtC,OAAM,IAAI,aAAa,gBAAgB,gBAAgB,UAAU,aAAa,CAAC;AAGhF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
156
|
*/
|
|
157
157
|
declare const withSlotNameAndSymbol: <TSlotComponentProps extends GetSlotComponentProps, TOtherProps extends UnknownObject = EmptyObject>(name: TSlotComponentProps["name"], SlotComponent?: SlotWithNameAndSymbol<TSlotComponentProps, TOtherProps>) => SlotWithNameAndSymbol<TSlotComponentProps, TOtherProps>;
|
|
158
158
|
//#endregion
|
|
159
|
-
//#region src/utils/mergeProps.d.ts
|
|
159
|
+
//#region src/utils/mergeProps/mergeProps.d.ts
|
|
160
160
|
type UnionToIntersection$1<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : "") extends ((param: infer TParam) => void) ? TParam : "";
|
|
161
161
|
/**
|
|
162
162
|
* Merges multiple sets of React props.
|
|
@@ -174,7 +174,7 @@ type UnionToIntersection$1<TUnion> = (TUnion extends unknown ? (param: TUnion) =
|
|
|
174
174
|
*/
|
|
175
175
|
declare const mergeProps: <TProps extends Record<never, never>>(...propsObjectArray: Array<TProps | undefined>) => UnionToIntersection$1<TProps>;
|
|
176
176
|
//#endregion
|
|
177
|
-
//#region src/utils/mergeTwoProps.d.ts
|
|
177
|
+
//#region src/utils/mergeProps/mergeTwoProps.d.ts
|
|
178
178
|
declare const mergeTwoProps: <TProps extends Record<never, never>>(formerProps: TProps | undefined, latterProps: TProps | undefined) => TProps;
|
|
179
179
|
//#endregion
|
|
180
180
|
//#region src/utils/types/common.d.ts
|
|
@@ -225,4 +225,4 @@ type PolymorphicProps<TElement extends React.ElementType, TProps extends AnyObje
|
|
|
225
225
|
type PolymorphicPropsStrict<TElement extends React.ElementType, TProps extends AnyObject = NonNullable<unknown>> = MergedGivenPropsWithAs<TElement, TProps> & Omit<InferPropsStrict<TElement>, keyof TProps>;
|
|
226
226
|
//#endregion
|
|
227
227
|
export { composeEventHandlers as A, getRegularChildren as C, PossibleRef as D, matchesSlotComponent as E, composeRefs as O, getMultipleSlots as S, matchesAnySlotComponent as T, createSlotComponent as _, DefaultRenderErrorMessages as a, withSlotNameAndSymbol as b, DiscriminatedRenderProps as c, InferPropsStrict as d, StateSetter as f, GetSlotMapResult as g, GetSlotComponentProps as h, CssWithCustomProperties as i, composeTwoEventHandlers as j, setRef as k, ForwardedRefType as l, mergeProps as m, PolymorphicProps as n, DefaultRenderItemErrorMessages as o, mergeTwoProps as p, PolymorphicPropsStrict as r, DiscriminatedRenderItemProps as s, AsProp as t, InferProps as u, getSlotMap as v, getSingleSlot as w, FunctionalComponent as x, slotComponentSymbol as y };
|
|
228
|
-
//# sourceMappingURL=index-
|
|
228
|
+
//# sourceMappingURL=index-6fIqihyt.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { D as PossibleRef, f as StateSetter } from "./index-
|
|
2
|
-
import * as
|
|
1
|
+
import { D as PossibleRef, f as StateSetter } from "./index-6fIqihyt.js";
|
|
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, 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
|
|
|
@@ -16,7 +16,7 @@ type CustomContextOptions<TContextValue, TStrict extends boolean> = {
|
|
|
16
16
|
strict?: TStrict;
|
|
17
17
|
};
|
|
18
18
|
type UseCustomContext<TContextValue, TStrict extends boolean> = () => TStrict extends true ? TContextValue : TContextValue | null;
|
|
19
|
-
declare const createCustomContext: <TContextValue = null, TStrict extends boolean = true>(options?: CustomContextOptions<TContextValue, TStrict>) => [Provider:
|
|
19
|
+
declare const createCustomContext: <TContextValue = null, TStrict extends boolean = true>(options?: CustomContextOptions<TContextValue, TStrict>) => [Provider: react1.Context<TContextValue>, useCustomContext: UseCustomContext<TContextValue, TStrict>];
|
|
20
20
|
declare class ContextError extends Error {
|
|
21
21
|
name: string;
|
|
22
22
|
}
|
|
@@ -79,7 +79,7 @@ declare const useAnimationInterval: (options: AnimationOptions) => {
|
|
|
79
79
|
* - Returns a stable function that always points to the latest version of the callback function.
|
|
80
80
|
* - This is only is the callback passed is not null or undefined.
|
|
81
81
|
*/
|
|
82
|
-
declare const useCallbackRef: <TCallback = AnyFunction>(callbackFn: TCallback) => TCallback;
|
|
82
|
+
declare const useCallbackRef: <TCallback extends AnyFunction | null | undefined | void = AnyFunction>(callbackFn: TCallback) => TCallback;
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/hooks/useClickOutside.d.ts
|
|
85
85
|
type UseClickOutsideOptions<TElement extends HTMLElement> = {
|
|
@@ -88,11 +88,11 @@ type UseClickOutsideOptions<TElement extends HTMLElement> = {
|
|
|
88
88
|
ref?: Array<React.RefObject<TElement>> | React.RefObject<TElement>;
|
|
89
89
|
};
|
|
90
90
|
declare const useClickOutside: <TElement extends HTMLElement>(options: UseClickOutsideOptions<TElement>) => {
|
|
91
|
-
ref:
|
|
91
|
+
ref: react1.RefObject<TElement | null>;
|
|
92
92
|
};
|
|
93
93
|
//#endregion
|
|
94
94
|
//#region src/hooks/useComposeRefs.d.ts
|
|
95
|
-
declare const useComposeRefs: <TRef extends HTMLElement>(...refs: Array<PossibleRef<TRef>>) =>
|
|
95
|
+
declare const useComposeRefs: <TRef extends HTMLElement>(...refs: Array<PossibleRef<TRef>>) => react1.RefCallback<TRef>;
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/hooks/useConstant.d.ts
|
|
98
98
|
declare const useConstant: <TResult>(initFn: () => TResult) => TResult;
|
|
@@ -108,46 +108,41 @@ type UseControllablePropOptions<TProp> = {
|
|
|
108
108
|
*/
|
|
109
109
|
declare const useControllableProp: <TProp>(options: UseControllablePropOptions<TProp>) => [isControlled: boolean, value: TProp];
|
|
110
110
|
type UseControllableStateOptions<TValue> = {
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
defaultProp?: TValue | (() => TValue);
|
|
112
|
+
isControlled?: boolean;
|
|
113
113
|
onChange?: (value: TValue) => void;
|
|
114
|
-
|
|
114
|
+
prop?: TValue;
|
|
115
115
|
};
|
|
116
116
|
/**
|
|
117
117
|
* @description React hook to manage state that can be either controlled or uncontrolled.
|
|
118
|
-
* - When `options.
|
|
119
|
-
* In this mode, `value` always equals `options.
|
|
118
|
+
* - When `options.prop` is provided, the hook operates in controlled mode.
|
|
119
|
+
* In this mode, `value` always equals `options.prop` and `setState` will
|
|
120
120
|
* invoke `options.onChange(next)` without mutating internal state.
|
|
121
|
-
* - When `options.
|
|
122
|
-
* mode, initializing internal state from `options.
|
|
123
|
-
* it via `
|
|
124
|
-
* - All updates are gated by `options.equalityFn(prev, next)` which defaults
|
|
125
|
-
* to `Object.is`.
|
|
121
|
+
* - When `options.prop` is not provided, the hook operates in uncontrolled
|
|
122
|
+
* mode, initializing internal state from `options.defaultProp` and updating
|
|
123
|
+
* it via `setState`.
|
|
126
124
|
*
|
|
127
125
|
* @param options - Configuration options for the hook.
|
|
128
|
-
* @param options.
|
|
129
|
-
* @param options.
|
|
126
|
+
* @param options.prop - Controlled value. If defined, the state is controlled.
|
|
127
|
+
* @param options.defaultProp - Initial value for the uncontrolled state. Can be a
|
|
130
128
|
* function for lazy initialization or a direct value.
|
|
131
129
|
* @param options.onChange - Callback fired when a new value is requested. In
|
|
132
130
|
* controlled mode, this is invoked instead of updating internal state. In
|
|
133
131
|
* uncontrolled mode, it is called after the internal state updates.
|
|
134
|
-
* @
|
|
135
|
-
* update given `prevState` and `nextValue`. If the values are equal, the update
|
|
136
|
-
* is skipped. Defaults to `Object.is`.
|
|
137
|
-
* @returns A tuple `[value, setValue]` just like React.useState.
|
|
132
|
+
* @returns A tuple `[state, setState]` just like React.useState.
|
|
138
133
|
*
|
|
139
134
|
* @example
|
|
140
135
|
* // Uncontrolled usage
|
|
141
|
-
* const [
|
|
136
|
+
* const [state, setState] = useControllableState({ defaultProp: 0 });
|
|
142
137
|
*
|
|
143
138
|
* @example
|
|
144
139
|
* // Controlled usage
|
|
145
|
-
* const [
|
|
146
|
-
*
|
|
140
|
+
* const [state, setState] = useControllableState({
|
|
141
|
+
* prop: props.value,
|
|
147
142
|
* onChange: props.onChange,
|
|
148
143
|
* });
|
|
149
144
|
*/
|
|
150
|
-
declare const useControllableState: <
|
|
145
|
+
declare const useControllableState: <TProp>(options: UseControllableStateOptions<TProp>) => [state: TProp | undefined, setState: StateSetter<TProp>];
|
|
151
146
|
//#endregion
|
|
152
147
|
//#region src/hooks/useCopyToClipboard.d.ts
|
|
153
148
|
declare const useCopyToClipboard: (options?: CopyToClipboardOptions & {
|
|
@@ -155,7 +150,7 @@ declare const useCopyToClipboard: (options?: CopyToClipboardOptions & {
|
|
|
155
150
|
}) => {
|
|
156
151
|
handleCopy: (valueToCopy: AllowedClipboardItems) => void;
|
|
157
152
|
hasCopied: boolean;
|
|
158
|
-
setValue:
|
|
153
|
+
setValue: react1.Dispatch<react1.SetStateAction<AllowedClipboardItems>>;
|
|
159
154
|
value: AllowedClipboardItems;
|
|
160
155
|
};
|
|
161
156
|
//#endregion
|
|
@@ -169,13 +164,13 @@ declare const useDebouncedFn: <TParams>(callBackFn: CallbackFn<TParams>, delay:
|
|
|
169
164
|
cancelMaxWait(): void;
|
|
170
165
|
};
|
|
171
166
|
declare const useDebouncedState: <TValue>(defaultValue: TValue, delay: number | undefined) => readonly [TValue, {
|
|
172
|
-
(...params:
|
|
173
|
-
(params:
|
|
167
|
+
(...params: react1.SetStateAction<TValue>[]): void;
|
|
168
|
+
(params: react1.SetStateAction<TValue> | react1.SetStateAction<TValue>[], overrideOptions: {
|
|
174
169
|
$delay: number;
|
|
175
170
|
}): void;
|
|
176
171
|
cancel: () => void;
|
|
177
172
|
cancelMaxWait(): void;
|
|
178
|
-
},
|
|
173
|
+
}, react1.Dispatch<react1.SetStateAction<TValue>>];
|
|
179
174
|
//#endregion
|
|
180
175
|
//#region src/hooks/useDisclosure.d.ts
|
|
181
176
|
type DisclosureOptions = {
|
|
@@ -217,14 +212,14 @@ declare const useIsHydrated: () => boolean;
|
|
|
217
212
|
//#endregion
|
|
218
213
|
//#region src/hooks/useLocationState.d.ts
|
|
219
214
|
type UseLocationResult<TSlice> = [state: TSlice, actions: LocationStoreApi];
|
|
220
|
-
declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<
|
|
221
|
-
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?: {
|
|
222
217
|
shouldNotifySync?: boolean;
|
|
223
|
-
state?:
|
|
218
|
+
state?: _zayne_labs_toolkit_core1.PartialURLInfo["state"];
|
|
224
219
|
}) => void;
|
|
225
220
|
replace: LocationStoreApi["push"];
|
|
226
221
|
triggerPopstateEvent: (nextLocationState?: LocationInfo["state"]) => void;
|
|
227
|
-
} & (<TSlice =
|
|
222
|
+
} & (<TSlice = _zayne_labs_toolkit_core1.URLInfoObject>(selector?: SelectorFn<LocationInfo, TSlice>) => UseLocationResult<TSlice>);
|
|
228
223
|
declare const useLocationState: <TSlice = LocationInfo>(selector?: SelectorFn<LocationInfo, TSlice>, options?: LocationStoreOptions) => UseLocationResult<TSlice>;
|
|
229
224
|
//#endregion
|
|
230
225
|
//#region src/hooks/useScrollObserver.d.ts
|
|
@@ -239,15 +234,15 @@ declare const useSearch: <TData>(initialData: TData[], delay?: number) => {
|
|
|
239
234
|
data: TData[];
|
|
240
235
|
isLoading: boolean;
|
|
241
236
|
query: string;
|
|
242
|
-
setQuery:
|
|
237
|
+
setQuery: react1.Dispatch<react1.SetStateAction<string>>;
|
|
243
238
|
};
|
|
244
239
|
//#endregion
|
|
245
240
|
//#region src/hooks/useSearchParams.d.ts
|
|
246
241
|
type UseSearchParamsOptions = LocationStoreOptions & {
|
|
247
242
|
action?: "push" | "replace";
|
|
248
243
|
};
|
|
249
|
-
declare const useSearchParams: <TSearchParams extends URLSearchParamsInit>(options?: UseSearchParamsOptions) => [searchParams: URLSearchParams, setSearchParams: (newQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?:
|
|
250
|
-
declare const useSearchParamsObject: <TSearchParams extends Record<string, string>>(options?: UseSearchParamsOptions) => [searchParamsObject: TSearchParams, setSearchParamsObject: (newQueryParams: TSearchParams | ((prev: TSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?:
|
|
244
|
+
declare const useSearchParams: <TSearchParams extends URLSearchParamsInit>(options?: UseSearchParamsOptions) => [searchParams: URLSearchParams, setSearchParams: (newQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core1.LocationInfo["state"]) => void];
|
|
245
|
+
declare const useSearchParamsObject: <TSearchParams extends Record<string, string>>(options?: UseSearchParamsOptions) => [searchParamsObject: TSearchParams, setSearchParamsObject: (newQueryParams: TSearchParams | ((prev: TSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core1.LocationInfo["state"]) => void];
|
|
251
246
|
//#endregion
|
|
252
247
|
//#region src/hooks/useShallowCompare.d.ts
|
|
253
248
|
declare const useShallowCompSelector: <TState, TResult>(selector: SelectorFn<TState, TResult> | undefined) => (state: TState) => TResult;
|
|
@@ -259,7 +254,7 @@ type UseStorageResult<TState, TSlice = TState> = [state: TSlice, actions: Storag
|
|
|
259
254
|
* @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
255
|
* @note You must use this if you want to be able to prevent syncing state across tabs.
|
|
261
256
|
*/
|
|
262
|
-
declare const createUseStorageState: <TState>(baseOptions: StorageOptions<TState>) =>
|
|
257
|
+
declare const createUseStorageState: <TState>(baseOptions: StorageOptions<TState>) => _zayne_labs_toolkit_core1.StoreApi<TState> & {
|
|
263
258
|
removeState: () => void;
|
|
264
259
|
} & (<TSlice = TState>(selector?: SelectorFn<TState, TSlice>) => UseStorageResult<TState, TSlice>);
|
|
265
260
|
type UseStorageStateOptions<TValue> = Omit<StorageOptions<TValue>, "initialValue" | "key">;
|
|
@@ -286,4 +281,4 @@ type InitialState = boolean | (() => boolean);
|
|
|
286
281
|
declare const useToggle: (initialValue?: InitialState) => [value: boolean, toggleValue: <TValue>(newValue?: TValue) => void];
|
|
287
282
|
//#endregion
|
|
288
283
|
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, useShallowCompSelector as c, useSearchParamsObject as d, useSearch as f, useIsHydrated as g, useLocationState as h, useThrottleByTimer as i, useMountEffect as j, useAnimateElementRefs as k, useShallowCompValue 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-
|
|
284
|
+
//# sourceMappingURL=index-B0Wqh8dy.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as CustomContextOptions } from "./index-
|
|
1
|
+
import { L as CustomContextOptions } from "./index-B0Wqh8dy.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";
|
|
@@ -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-Cl9wVD2w.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as composeEventHandlers, C as getRegularChildren, D as PossibleRef, E as matchesSlotComponent, O as composeRefs, S as getMultipleSlots, T as matchesAnySlotComponent, _ as createSlotComponent, a as DefaultRenderErrorMessages, b as withSlotNameAndSymbol, c as DiscriminatedRenderProps, d as InferPropsStrict, f as StateSetter, g as GetSlotMapResult, h as GetSlotComponentProps, i as CssWithCustomProperties, j as composeTwoEventHandlers, k as setRef, l as ForwardedRefType, m as mergeProps, n as PolymorphicProps, o as DefaultRenderItemErrorMessages, p as mergeTwoProps, r as PolymorphicPropsStrict, s as DiscriminatedRenderItemProps, t as AsProp, u as InferProps, v as getSlotMap, w as getSingleSlot, x as FunctionalComponent, y as slotComponentSymbol } from "../index-
|
|
1
|
+
import { A as composeEventHandlers, C as getRegularChildren, D as PossibleRef, E as matchesSlotComponent, O as composeRefs, S as getMultipleSlots, T as matchesAnySlotComponent, _ as createSlotComponent, a as DefaultRenderErrorMessages, b as withSlotNameAndSymbol, c as DiscriminatedRenderProps, d as InferPropsStrict, f as StateSetter, g as GetSlotMapResult, h as GetSlotComponentProps, i as CssWithCustomProperties, j as composeTwoEventHandlers, k as setRef, l as ForwardedRefType, m as mergeProps, n as PolymorphicProps, o as DefaultRenderItemErrorMessages, p as mergeTwoProps, r as PolymorphicPropsStrict, s as DiscriminatedRenderItemProps, t as AsProp, u as InferProps, v as getSlotMap, w as getSingleSlot, x as FunctionalComponent, y as slotComponentSymbol } from "../index-6fIqihyt.js";
|
|
2
2
|
export { AsProp, CssWithCustomProperties, DefaultRenderErrorMessages, DefaultRenderItemErrorMessages, DiscriminatedRenderItemProps, DiscriminatedRenderProps, ForwardedRefType, FunctionalComponent, GetSlotComponentProps, GetSlotMapResult, InferProps, InferPropsStrict, PolymorphicProps, PolymorphicPropsStrict, PossibleRef, StateSetter, composeEventHandlers, composeRefs, composeTwoEventHandlers, createSlotComponent, getMultipleSlots, getRegularChildren, getSingleSlot, getSlotMap, matchesAnySlotComponent, matchesSlotComponent, mergeProps, mergeTwoProps, setRef, slotComponentSymbol, withSlotNameAndSymbol };
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as slotComponentSymbol, c as getRegularChildren, d as matchesSlotComponent, f as composeRefs, h as composeTwoEventHandlers, i as getSlotMap, l as getSingleSlot, m as composeEventHandlers, n as mergeTwoProps, o as withSlotNameAndSymbol, p as setRef, r as createSlotComponent, s as getMultipleSlots, t as mergeProps, u as matchesAnySlotComponent } from "../utils-
|
|
1
|
+
import { a as slotComponentSymbol, c as getRegularChildren, d as matchesSlotComponent, f as composeRefs, h as composeTwoEventHandlers, i as getSlotMap, l as getSingleSlot, m as composeEventHandlers, n as mergeTwoProps, o as withSlotNameAndSymbol, p as setRef, r as createSlotComponent, s as getMultipleSlots, t as mergeProps, u as matchesAnySlotComponent } from "../utils-DAG-7fTH.js";
|
|
2
2
|
|
|
3
3
|
export { composeEventHandlers, composeRefs, composeTwoEventHandlers, createSlotComponent, getMultipleSlots, getRegularChildren, getSingleSlot, getSlotMap, matchesAnySlotComponent, matchesSlotComponent, mergeProps, mergeTwoProps, setRef, slotComponentSymbol, withSlotNameAndSymbol };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, isValidElement } from "react";
|
|
2
2
|
import { toArray } from "@zayne-labs/toolkit-core";
|
|
3
|
-
import { AssertionError, isArray, isFunction, isObject } from "@zayne-labs/toolkit-type-helpers";
|
|
3
|
+
import { AssertionError, isArray, isFunction, isObject, isString } from "@zayne-labs/toolkit-type-helpers";
|
|
4
4
|
import { twMerge } from "tailwind-merge";
|
|
5
5
|
|
|
6
6
|
//#region src/utils/composeEventHandlers.ts
|
|
@@ -213,40 +213,42 @@ const withSlotNameAndSymbol = (name, SlotComponent = DefaultSlotComponent) => {
|
|
|
213
213
|
const cnMerge = (...classNames) => twMerge(classNames);
|
|
214
214
|
|
|
215
215
|
//#endregion
|
|
216
|
-
//#region src/utils/
|
|
217
|
-
const isEventHandler = (key
|
|
216
|
+
//#region src/utils/mergeProps/utils.ts
|
|
217
|
+
const isEventHandler = (key) => {
|
|
218
218
|
const thirdCharCode = key.codePointAt(2);
|
|
219
|
-
if (
|
|
220
|
-
return key
|
|
219
|
+
if (thirdCharCode === void 0) return false;
|
|
220
|
+
return key[0] === "o" && key[1] === "n" && thirdCharCode >= 65 && thirdCharCode <= 90;
|
|
221
221
|
};
|
|
222
|
+
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/utils/mergeProps/mergeTwoProps.ts
|
|
222
225
|
const mergeTwoProps = (formerProps, latterProps) => {
|
|
223
226
|
if (!latterProps || !formerProps) return latterProps ?? formerProps ?? {};
|
|
224
227
|
const propsAccumulator = { ...formerProps };
|
|
225
|
-
for (const latterPropName of Object.
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
propsAccumulator[latterPropName] = cnMerge(formerPropValue, latterPropValue);
|
|
228
|
+
for (const [latterPropName, latterPropValue] of Object.entries(latterProps)) {
|
|
229
|
+
const accumulatedPropValue = propsAccumulator[latterPropName];
|
|
230
|
+
if ((latterPropName === "className" || latterPropName === "class") && isString(latterPropValue) && isString(accumulatedPropValue)) {
|
|
231
|
+
propsAccumulator[latterPropName] = cnMerge(accumulatedPropValue, latterPropValue);
|
|
230
232
|
continue;
|
|
231
233
|
}
|
|
232
|
-
if (latterPropName === "style") {
|
|
234
|
+
if (latterPropName === "style" && isObject(latterPropValue) && isObject(accumulatedPropValue)) {
|
|
233
235
|
propsAccumulator[latterPropName] = {
|
|
234
|
-
...
|
|
236
|
+
...accumulatedPropValue,
|
|
235
237
|
...latterPropValue
|
|
236
238
|
};
|
|
237
239
|
continue;
|
|
238
240
|
}
|
|
239
|
-
if (isEventHandler(latterPropName
|
|
240
|
-
propsAccumulator[latterPropName] = composeTwoEventHandlers(
|
|
241
|
+
if (isFunction(latterPropValue) && isFunction(accumulatedPropValue) && isEventHandler(latterPropName)) {
|
|
242
|
+
propsAccumulator[latterPropName] = composeTwoEventHandlers(accumulatedPropValue, latterPropValue);
|
|
241
243
|
continue;
|
|
242
244
|
}
|
|
243
|
-
propsAccumulator[latterPropName] = latterPropValue;
|
|
245
|
+
propsAccumulator[latterPropName] = latterPropValue !== void 0 ? latterPropValue : accumulatedPropValue;
|
|
244
246
|
}
|
|
245
247
|
return propsAccumulator;
|
|
246
248
|
};
|
|
247
249
|
|
|
248
250
|
//#endregion
|
|
249
|
-
//#region src/utils/mergeProps.ts
|
|
251
|
+
//#region src/utils/mergeProps/mergeProps.ts
|
|
250
252
|
/**
|
|
251
253
|
* Merges multiple sets of React props.
|
|
252
254
|
*
|
|
@@ -274,4 +276,4 @@ const mergeProps = (...propsObjectArray) => {
|
|
|
274
276
|
|
|
275
277
|
//#endregion
|
|
276
278
|
export { slotComponentSymbol as a, getRegularChildren as c, matchesSlotComponent as d, composeRefs as f, composeTwoEventHandlers as h, getSlotMap as i, getSingleSlot as l, composeEventHandlers as m, mergeTwoProps as n, withSlotNameAndSymbol as o, setRef as p, createSlotComponent as r, getMultipleSlots as s, mergeProps as t, matchesAnySlotComponent as u };
|
|
277
|
-
//# sourceMappingURL=utils-
|
|
279
|
+
//# sourceMappingURL=utils-DAG-7fTH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-DAG-7fTH.js","names":["result","ReactFragment","ReactFragment"],"sources":["../../src/utils/composeEventHandlers.ts","../../src/utils/composeRefs.ts","../../src/utils/getSlot/getSlot.ts","../../src/utils/getSlotMap/getSlotMap.ts","../../src/lib/utils/cn.ts","../../src/utils/mergeProps/utils.ts","../../src/utils/mergeProps/mergeTwoProps.ts","../../src/utils/mergeProps/mergeProps.ts"],"sourcesContent":["import { isObject, type AnyFunction } from \"@zayne-labs/toolkit-type-helpers\";\n\nconst isSyntheticEvent = (event: unknown): event is React.SyntheticEvent => {\n\treturn isObject(event) && Object.hasOwn(event, \"nativeEvent\");\n};\n\nexport const composeTwoEventHandlers = (\n\tformerHandler: AnyFunction | undefined,\n\tlatterHandler: AnyFunction | undefined\n) => {\n\tconst mergedEventHandler = (event: unknown) => {\n\t\tif (isSyntheticEvent(event)) {\n\t\t\tconst result = latterHandler?.(event) as unknown;\n\n\t\t\tif (!event.defaultPrevented) {\n\t\t\t\tformerHandler?.(event);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\n\t\tconst result = latterHandler?.(event) as unknown;\n\t\tformerHandler?.(event);\n\t\treturn result;\n\t};\n\n\treturn mergedEventHandler;\n};\n\nexport const composeEventHandlers = (...eventHandlerArray: Array<AnyFunction | undefined>) => {\n\tconst mergedEventHandler = (event: unknown) => {\n\t\tif (eventHandlerArray.length === 0) return;\n\n\t\tif (eventHandlerArray.length === 1) {\n\t\t\treturn eventHandlerArray[0]?.(event) as unknown;\n\t\t}\n\n\t\tlet accumulatedHandlers: AnyFunction | undefined;\n\n\t\tfor (const eventHandler of eventHandlerArray) {\n\t\t\tif (!eventHandler) continue;\n\n\t\t\taccumulatedHandlers = composeTwoEventHandlers(accumulatedHandlers, eventHandler);\n\t\t}\n\n\t\treturn accumulatedHandlers?.(event) as unknown;\n\t};\n\n\treturn mergedEventHandler;\n};\n","import { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { RefCallback } from \"react\";\n\nexport type PossibleRef<TRef extends HTMLElement> = React.Ref<TRef> | undefined;\n\n/**\n * @description Set a given ref to a given value.\n *\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nexport const setRef = <TRef extends HTMLElement>(\n\tref: PossibleRef<TRef>,\n\tnode: TRef | null\n): ReturnType<RefCallback<TRef>> => {\n\tif (!ref) return;\n\n\tif (isFunction(ref)) {\n\t\treturn ref(node);\n\t}\n\n\t// eslint-disable-next-line no-param-reassign -- Mutation is needed here\n\tref.current = node;\n};\n\n/**\n * @description A utility to combine refs. Accepts callback refs and RefObject(s)\n */\nexport const composeRefs = <TRef extends HTMLElement>(\n\t...refs: Array<PossibleRef<TRef>>\n): RefCallback<TRef> => {\n\tconst mergedRefCallBack: RefCallback<TRef> = (node) => {\n\t\tconst cleanupFnArray = refs.map((ref) => setRef(ref, node));\n\n\t\tconst cleanupFn = () => cleanupFnArray.forEach((cleanup) => cleanup?.());\n\n\t\treturn cleanupFn;\n\t};\n\n\treturn mergedRefCallBack;\n};\n","import { toArray } from \"@zayne-labs/toolkit-core\";\nimport {\n\tAssertionError,\n\tisArray,\n\tisFunction,\n\ttype AnyFunction,\n\ttype Prettify,\n\ttype UnknownObject,\n} from \"@zayne-labs/toolkit-type-helpers\";\nimport { isValidElement, Fragment as ReactFragment } from \"react\";\nimport type { InferProps } from \"../types\";\n\nexport type FunctionalComponent<TProps extends UnknownObject = never> = React.FunctionComponent<TProps>;\n\nconst isWithSlotSymbol = <TFunction extends AnyFunction>(\n\tcomponent: TFunction\n): component is Record<\"slotSymbol\", unknown> & TFunction => {\n\treturn \"slotSymbol\" in component && Boolean(component.slotSymbol);\n};\n\nconst isWithSlotReference = <TFunction extends AnyFunction>(\n\tcomponent: TFunction\n): component is Record<\"slotReference\", unknown> & TFunction => {\n\treturn \"slotReference\" in component && Boolean(component.slotReference);\n};\n/**\n * @description Checks if a react child (within the children array) matches the provided SlotComponent using multiple matching strategies:\n * 1. Matches by slot symbol property\n * 2. Matches by component name\n */\n\nexport const matchesSlotComponent = (child: React.ReactNode, SlotComponent: FunctionalComponent) => {\n\tif (!isValidElement(child) || !isFunction(child.type)) {\n\t\treturn false;\n\t}\n\n\tconst resolvedChildType =\n\t\tisWithSlotReference(child.type) ? (child.type.slotReference as FunctionalComponent) : child.type;\n\n\tconst hasMatchingSlotSymbol =\n\t\tisWithSlotSymbol(resolvedChildType)\n\t\t&& isWithSlotSymbol(SlotComponent)\n\t\t&& resolvedChildType.slotSymbol === SlotComponent.slotSymbol;\n\n\tif (hasMatchingSlotSymbol) {\n\t\treturn true;\n\t}\n\n\tif (child.type.name === SlotComponent.name) {\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n/**\n * @description Checks if a react child (within the children array) matches any of the provided SlotComponents.\n */\nexport const matchesAnySlotComponent = (child: React.ReactNode, SlotComponents: FunctionalComponent[]) => {\n\tconst matchesSlot = SlotComponents.some((SlotComponent) => matchesSlotComponent(child, SlotComponent));\n\n\treturn matchesSlot;\n};\n\ntype SlotOptions = {\n\t/**\n\t * @description The error message to throw when multiple slots are found for a given slot component\n\t */\n\terrorMessage?: string;\n\t/**\n\t * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component\n\t */\n\tthrowOnMultipleSlotMatch?: boolean;\n};\n\n/**\n * @description Counts how many times a given slot component appears in an array of children\n * @internal\n */\nconst calculateSlotOccurrences = (\n\tchildrenArray: React.ReactNode[],\n\tSlotComponent: FunctionalComponent\n) => {\n\tlet count = 0;\n\n\tfor (const child of childrenArray) {\n\t\tif (!matchesSlotComponent(child, SlotComponent)) continue;\n\n\t\tcount += 1;\n\t}\n\n\treturn count;\n};\n\n/**\n * @description Retrieves a single slot element from a collection of React children that matches the provided SlotComponent component.\n *\n * @throws { AssertionError } when throwOnMultipleSlotMatch is true and multiple slots are found\n */\nexport const getSingleSlot = (\n\tchildren: React.ReactNode,\n\tSlotComponent: FunctionalComponent,\n\toptions: SlotOptions = {}\n) => {\n\tconst {\n\t\terrorMessage = \"Only one instance of the SlotComponent is allowed\",\n\t\tthrowOnMultipleSlotMatch = false,\n\t} = options;\n\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment ?\n\t\t\tchildren.props.children\n\t\t:\tchildren;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tconst shouldThrow =\n\t\tthrowOnMultipleSlotMatch && calculateSlotOccurrences(childrenArray, SlotComponent) > 1;\n\n\tif (shouldThrow) {\n\t\tthrow new AssertionError(errorMessage);\n\t}\n\n\tconst slotElement = childrenArray.find((child) => matchesSlotComponent(child, SlotComponent));\n\n\treturn slotElement;\n};\n\n// NOTE - You can imitate const type parameter by extending readonly[] | []\n\ntype MultipleSlotsOptions = {\n\t/**\n\t * @description The error message to throw when multiple slots are found for a given slot component\n\t * If a string is provided, the same message will be used for all slot components\n\t * If an array is provided, each string in the array will be used as the errorMessage for the corresponding slot component\n\t */\n\terrorMessage?: string | string[];\n\t/**\n\t * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component\n\t * If a boolean is provided, the same value will be used for all slot components\n\t * If an array is provided, each boolean in the array will be used as the throwOnMultipleSlotMatch value for the corresponding slot component\n\t */\n\tthrowOnMultipleSlotMatch?: boolean | boolean[];\n};\n\ntype GetMultipleSlotsResult<TSlotComponents extends FunctionalComponent[]> = {\n\tregularChildren: React.ReactNode[];\n\tslots: { [Key in keyof TSlotComponents]: ReturnType<TSlotComponents[Key]> };\n};\n\n/**\n * @description The same as getSingleSlot, but for multiple slot components\n */\nexport const getMultipleSlots = <const TSlotComponents extends FunctionalComponent[]>(\n\tchildren: React.ReactNode,\n\tSlotComponents: TSlotComponents,\n\toptions?: MultipleSlotsOptions\n): Prettify<GetMultipleSlotsResult<TSlotComponents>> => {\n\tconst { errorMessage, throwOnMultipleSlotMatch } = options ?? {};\n\n\tconst slots = SlotComponents.map((SlotComponent, index) =>\n\t\tgetSingleSlot(children, SlotComponent, {\n\t\t\terrorMessage: isArray(errorMessage) ? errorMessage[index] : errorMessage,\n\t\t\tthrowOnMultipleSlotMatch:\n\t\t\t\tisArray(throwOnMultipleSlotMatch) ? throwOnMultipleSlotMatch[index] : throwOnMultipleSlotMatch,\n\t\t})\n\t);\n\n\tconst regularChildren = getRegularChildren(children, SlotComponents);\n\n\treturn { regularChildren, slots } as GetMultipleSlotsResult<TSlotComponents>;\n};\n\n/**\n * @description Returns all children that are not slot elements (i.e., don't match any of the provided slot components)\n */\nexport const getRegularChildren = (\n\tchildren: React.ReactNode,\n\tSlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]\n) => {\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment ?\n\t\t\tchildren.props.children\n\t\t:\tchildren;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tconst regularChildren = childrenArray.filter(\n\t\t(child) => !matchesAnySlotComponent(child, toArray(SlotComponentOrComponents))\n\t);\n\n\treturn regularChildren;\n};\n","import { toArray } from \"@zayne-labs/toolkit-core\";\nimport {\n\tisFunction,\n\ttype CallbackFn,\n\ttype EmptyObject,\n\ttype Prettify,\n\ttype UnionToIntersection,\n\ttype UnknownObject,\n} from \"@zayne-labs/toolkit-type-helpers\";\nimport { isValidElement, Fragment as ReactFragment } from \"react\";\nimport type { InferProps } from \"../types\";\n\ntype GetSlotName<TSlotComponentProps extends GetSlotComponentProps> =\n\tstring extends TSlotComponentProps[\"name\"] ? never\n\t: \"default\" extends TSlotComponentProps[\"name\"] ? never\n\t: TSlotComponentProps[\"name\"];\n\ntype GetSpecificSlotsType<TSlotComponentProps extends GetSlotComponentProps> = {\n\t// This conditional before the remapping will prevent an Indexed Record type from showing up if the props are not passed, enhancing type safety\n\t[TName in keyof TSlotComponentProps as GetSlotName<TSlotComponentProps>]: Extract<\n\t\tTSlotComponentProps[\"children\"],\n\t\tReact.ReactNode\n\t>;\n};\n\n/**\n * Maps slot names to their corresponding children types\n */\nexport type GetSlotMapResult<TSlotComponentProps extends GetSlotComponentProps> = UnionToIntersection<\n\tGetSpecificSlotsType<TSlotComponentProps>\n> & { default: React.ReactNode[] };\n\n/**\n * Symbol used to identify SlotComponent instances\n */\nexport const slotComponentSymbol = Symbol(\"slot-component\");\n\n/**\n * @description Creates a map of named slots from React children. Returns an object mapping slot names to their children,\n * with a default slot for unmatched children.\n *\n * @example\n * ```tsx\n * import { type GetSlotComponentProps, SlotComponent } from \"@zayne-labs/toolkit-react/utils\"\n *\n * type SlotProps = GetSlotComponentProps<\"header\" | \"footer\">;\n *\n * function Parent({ children }: { children: React.ReactNode }) {\n * const slots = getSlotMap<SlotProps>(children);\n *\n * return (\n * <div>\n * <header>{slots.header}</header>\n * <main>{slots.default}</main>\n * <footer>{slots.footer}</footer>\n * </div>\n * );\n * }\n * ```\n *\n * Usage:\n * ```tsx\n * <Parent>\n * <SlotComponent name=\"header\">Header Content</SlotComponent>\n * <div>Random stuff</div>\n * <SlotComponent name=\"footer\">Footer Content</SlotComponent>\n * </Parent>\n * ```\n */\nexport const getSlotMap = <TSlotComponentProps extends GetSlotComponentProps>(\n\tchildren: React.ReactNode\n): Prettify<GetSlotMapResult<TSlotComponentProps>> => {\n\tconst slots: Record<string, TSlotComponentProps[\"children\"]> & { default: React.ReactNode[] } = {\n\t\tdefault: [],\n\t};\n\n\tconst isFragment = isValidElement<InferProps<HTMLElement>>(children) && children.type === ReactFragment;\n\n\tconst actualChildren = isFragment ? children.props.children : children;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tfor (const child of childrenArray) {\n\t\tif (!isValidElement<TSlotComponentProps>(child) || !isFunction(child.type)) {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst childType = child.type as SlotWithNameAndSymbol;\n\n\t\tconst isSlotElement =\n\t\t\tchildType.slotSymbol === slotComponentSymbol && Boolean(childType.slotName ?? child.props.name);\n\n\t\tif (!isSlotElement) {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst slotName = childType.slotName ?? child.props.name;\n\n\t\tif (slotName === \"default\") {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tslots[slotName] = child;\n\t}\n\n\treturn slots as GetSlotMapResult<TSlotComponentProps>;\n};\n\n/**\n * @description Produce props for the SlotComponent\n *\n * @example\n * ```ts\n * // Pattern One (slot or slots have same children type, which is just React.ReactNode by default)\n * type SlotProps = GetSlotComponentProps<\"header\" | \"content\" | \"footer\">;\n *\n * // Pattern Two (some slots can have different children type)\n * type SlotProps = GetSlotComponentProps<\"header\", React.ReactNode> | GetSlotComponentProps<\"header\", (renderProp: RenderProp) => React.ReactNode>;\n * ```\n */\nexport type GetSlotComponentProps<\n\tTName extends string = string,\n\tTChildren extends CallbackFn<never, React.ReactNode> | React.ReactNode =\n\t\t| CallbackFn<never, React.ReactNode>\n\t\t| React.ReactNode,\n> = {\n\tchildren: TChildren;\n\t/**\n\t * Name of the slot where content should be rendered\n\t */\n\tname: TName;\n};\n\n/**\n * @description Creates a slot component\n */\nexport const createSlotComponent = <TSlotComponentProps extends GetSlotComponentProps>() => {\n\tconst SlotComponent = (props: TSlotComponentProps) => props.children as React.ReactNode;\n\n\tSlotComponent.slotSymbol = slotComponentSymbol;\n\n\treturn SlotComponent;\n};\n\ntype SlotWithNameAndSymbol<\n\tTSlotComponentProps extends GetSlotComponentProps = GetSlotComponentProps,\n\tTOtherProps extends UnknownObject = EmptyObject,\n> = {\n\t(props: Pick<TSlotComponentProps, \"children\"> & TOtherProps): React.ReactNode;\n\treadonly slotName?: TSlotComponentProps[\"name\"];\n\treadonly slotSymbol?: symbol;\n};\n\nfunction DefaultSlotComponent(props: Pick<GetSlotComponentProps, \"children\">): React.ReactNode {\n\treturn props.children as React.ReactNode;\n}\n\n/**\n * @description Adds a slot symbol and name to a slot component passed in\n */\nexport const withSlotNameAndSymbol = <\n\tTSlotComponentProps extends GetSlotComponentProps,\n\tTOtherProps extends UnknownObject = EmptyObject,\n>(\n\tname: TSlotComponentProps[\"name\"],\n\tSlotComponent: SlotWithNameAndSymbol<TSlotComponentProps, TOtherProps> = DefaultSlotComponent\n) => {\n\t/* eslint-disable no-param-reassign -- This is necessary */\n\t// @ts-expect-error -- This is necessary for the time being, to prevent type errors and accidental overrides on consumer side\n\tSlotComponent.slotSymbol = slotComponentSymbol;\n\t// @ts-expect-error -- This is necessary for the time being, to prevent type errors and accidental overrides on consumer side\n\tSlotComponent.slotName = name;\n\n\t/* eslint-enable no-param-reassign -- This is necessary */\n\n\treturn SlotComponent;\n};\n","import { twJoin, twMerge } from \"tailwind-merge\";\n\nexport const cnMerge: typeof twMerge = (...classNames) => twMerge(classNames);\n\nexport const cnJoin: typeof twJoin = (...classNames) => twJoin(classNames);\n","// == This approach is more efficient than using a regex.\nexport const isEventHandler = (key: string) => {\n\tconst thirdCharCode = key.codePointAt(2);\n\n\tif (thirdCharCode === undefined) {\n\t\treturn false;\n\t}\n\n\tconst isHandler =\n\t\t// eslint-disable-next-line ts-eslint/prefer-string-starts-ends-with -- Ignore\n\t\tkey[0] === \"o\" && key[1] === \"n\" && thirdCharCode >= 65 /* A */ && thirdCharCode <= 90; /* Z */\n\n\treturn isHandler;\n};\n\n// const mergeTwoClassNames = (formerClassName: string | undefined, latterClassName: string | undefined) => {\n// \tif (!latterClassName || !formerClassName) {\n// \t\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- Logical OR is fit for this case\n// \t\treturn latterClassName || formerClassName;\n// \t}\n\n// \t// eslint-disable-next-line prefer-template -- String concatenation is more performant than template literals in this case\n// \treturn formerClassName + \" \" + latterClassName;\n// };\n","import { isFunction, isObject, isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport { composeTwoEventHandlers } from \"../composeEventHandlers\";\nimport { isEventHandler } from \"./utils\";\n\nexport const mergeTwoProps = <TProps extends Record<never, never>>(\n\tformerProps: TProps | undefined,\n\tlatterProps: TProps | undefined\n): TProps => {\n\t// == If no props are provided, return an empty object\n\tif (!latterProps || !formerProps) {\n\t\treturn latterProps ?? formerProps ?? ({} as TProps);\n\t}\n\n\tconst propsAccumulator: Record<string, unknown> = {\n\t\t...formerProps,\n\t};\n\n\tfor (const [latterPropName, latterPropValue] of Object.entries(latterProps)) {\n\t\tconst accumulatedPropValue = propsAccumulator[latterPropName];\n\n\t\tif (\n\t\t\t(latterPropName === \"className\" || latterPropName === \"class\")\n\t\t\t&& isString(latterPropValue)\n\t\t\t&& isString(accumulatedPropValue)\n\t\t) {\n\t\t\tpropsAccumulator[latterPropName] = cnMerge(accumulatedPropValue, latterPropValue);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (latterPropName === \"style\" && isObject(latterPropValue) && isObject(accumulatedPropValue)) {\n\t\t\tpropsAccumulator[latterPropName] = {\n\t\t\t\t...accumulatedPropValue,\n\t\t\t\t...latterPropValue,\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (\n\t\t\tisFunction(latterPropValue)\n\t\t\t&& isFunction(accumulatedPropValue)\n\t\t\t&& isEventHandler(latterPropName)\n\t\t) {\n\t\t\tpropsAccumulator[latterPropName] = composeTwoEventHandlers(accumulatedPropValue, latterPropValue);\n\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == latterProps override by default\n\t\tpropsAccumulator[latterPropName] =\n\t\t\tlatterPropValue !== undefined ? latterPropValue : accumulatedPropValue;\n\t}\n\n\treturn propsAccumulator as TProps;\n};\n","import { mergeTwoProps } from \"./mergeTwoProps\";\n\ntype UnionToIntersection<TUnion> =\n\t(TUnion extends unknown ? (param: TUnion) => void : \"\") extends (param: infer TParam) => void ? TParam\n\t:\t\"\";\n\n/**\n * Merges multiple sets of React props.\n *\n * - It follows the Object.assign pattern where the rightmost object's fields overwrite\n * the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.\n * - Event handlers are merged such that they are called in sequence (the rightmost one being called first),\n * and allows the user to prevent the previous event handlers from being executed by calling the `preventDefault` method.\n * - It also merges the `className` and `style` props, whereby the classes are concatenated\n * and the rightmost styles overwrite the previous ones.\n *\n * @important **`ref` is not merged.**\n * @param props props to merge.\n * @returns the merged props.\n */\n\nconst mergeProps = <TProps extends Record<never, never>>(\n\t...propsObjectArray: Array<TProps | undefined>\n): UnionToIntersection<TProps> => {\n\tif (propsObjectArray.length === 0) {\n\t\treturn {} as never;\n\t}\n\n\tif (propsObjectArray.length === 1) {\n\t\treturn propsObjectArray[0] as never;\n\t}\n\n\tlet accumulatedProps: Record<string, unknown> = {};\n\n\tfor (const propsObject of propsObjectArray) {\n\t\tif (!propsObject) continue;\n\n\t\taccumulatedProps = mergeTwoProps(accumulatedProps, propsObject);\n\t}\n\n\treturn accumulatedProps as never;\n};\n\nexport { mergeProps };\n"],"mappings":";;;;;;AAEA,MAAM,oBAAoB,UAAkD;AAC3E,QAAO,SAAS,MAAM,IAAI,OAAO,OAAO,OAAO,cAAc;;AAG9D,MAAa,2BACZ,eACA,kBACI;CACJ,MAAM,sBAAsB,UAAmB;AAC9C,MAAI,iBAAiB,MAAM,EAAE;GAC5B,MAAMA,WAAS,gBAAgB,MAAM;AAErC,OAAI,CAAC,MAAM,iBACV,iBAAgB,MAAM;AAGvB,UAAOA;;EAGR,MAAM,SAAS,gBAAgB,MAAM;AACrC,kBAAgB,MAAM;AACtB,SAAO;;AAGR,QAAO;;AAGR,MAAa,wBAAwB,GAAG,sBAAsD;CAC7F,MAAM,sBAAsB,UAAmB;AAC9C,MAAI,kBAAkB,WAAW,EAAG;AAEpC,MAAI,kBAAkB,WAAW,EAChC,QAAO,kBAAkB,KAAK,MAAM;EAGrC,IAAI;AAEJ,OAAK,MAAM,gBAAgB,mBAAmB;AAC7C,OAAI,CAAC,aAAc;AAEnB,yBAAsB,wBAAwB,qBAAqB,aAAa;;AAGjF,SAAO,sBAAsB,MAAM;;AAGpC,QAAO;;;;;;;;;;ACtCR,MAAa,UACZ,KACA,SACmC;AACnC,KAAI,CAAC,IAAK;AAEV,KAAI,WAAW,IAAI,CAClB,QAAO,IAAI,KAAK;AAIjB,KAAI,UAAU;;;;;AAMf,MAAa,eACZ,GAAG,SACoB;CACvB,MAAM,qBAAwC,SAAS;EACtD,MAAM,iBAAiB,KAAK,KAAK,QAAQ,OAAO,KAAK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MAAI,CAAC,YAAa;AAElB,qBAAmB,cAAc,kBAAkB,YAAY;;AAGhE,QAAO"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { a as createReactStoreContext, i as UseBoundStore, t as Get } from "../../types-
|
|
1
|
+
import "../../index-B0Wqh8dy.js";
|
|
2
|
+
import "../../index-6fIqihyt.js";
|
|
3
|
+
import { a as createReactStoreContext, i as UseBoundStore, t as Get } from "../../types-Cl9wVD2w.js";
|
|
4
4
|
import { StoreApi } from "@zayne-labs/toolkit-core";
|
|
5
5
|
import { Mutate, StoreMutatorIdentifier } from "zustand";
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as useStore } from "../../hooks-
|
|
2
|
-
import { t as createReactStoreContext } from "../../createReactStoreContext-
|
|
1
|
+
import { m as useStore } from "../../hooks-ByaT0fZg.js";
|
|
2
|
+
import { t as createReactStoreContext } from "../../createReactStoreContext-BwiNZqMl.js";
|
|
3
3
|
import { createStore } from "@zayne-labs/toolkit-core";
|
|
4
4
|
|
|
5
5
|
//#region src/zustand/compatible/createReactStore.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../index-
|
|
2
|
-
import "../index-
|
|
3
|
-
import { a as createReactStoreContext, i as UseBoundStore, n as Mutate, r as StoreMutatorIdentifier, t as Get } from "../types-
|
|
1
|
+
import "../index-B0Wqh8dy.js";
|
|
2
|
+
import "../index-6fIqihyt.js";
|
|
3
|
+
import { a as createReactStoreContext, i as UseBoundStore, n as Mutate, r as StoreMutatorIdentifier, t as Get } from "../types-Cl9wVD2w.js";
|
|
4
4
|
import { StoreApi } from "@zayne-labs/toolkit-core";
|
|
5
5
|
|
|
6
6
|
//#region src/zustand/createReactStore.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as useStore } from "../hooks-
|
|
2
|
-
import { t as createReactStoreContext } from "../createReactStoreContext-
|
|
1
|
+
import { m as useStore } from "../hooks-ByaT0fZg.js";
|
|
2
|
+
import { t as createReactStoreContext } from "../createReactStoreContext-BwiNZqMl.js";
|
|
3
3
|
import { createStore } from "@zayne-labs/toolkit-core";
|
|
4
4
|
|
|
5
5
|
//#region src/zustand/createReactStore.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.18",
|
|
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-core": "0.12.
|
|
53
|
-
"@zayne-labs/toolkit-type-helpers": "0.12.
|
|
52
|
+
"@zayne-labs/toolkit-core": "0.12.18",
|
|
53
|
+
"@zayne-labs/toolkit-type-helpers": "0.12.18"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
@@ -58,16 +58,16 @@
|
|
|
58
58
|
"@size-limit/esbuild-why": "^12.0.0",
|
|
59
59
|
"@size-limit/preset-small-lib": "^12.0.0",
|
|
60
60
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
61
|
-
"@types/node": "^
|
|
61
|
+
"@types/node": "^25.0.3",
|
|
62
62
|
"@types/react": "^19.2.7",
|
|
63
|
-
"@zayne-labs/tsconfig": "0.11.
|
|
63
|
+
"@zayne-labs/tsconfig": "0.11.15",
|
|
64
64
|
"concurrently": "^9.2.1",
|
|
65
65
|
"cross-env": "^10.1.0",
|
|
66
|
-
"publint": "^0.3.
|
|
67
|
-
"react": "^19.2.
|
|
66
|
+
"publint": "^0.3.16",
|
|
67
|
+
"react": "^19.2.3",
|
|
68
68
|
"size-limit": "^12.0.0",
|
|
69
69
|
"tailwind-merge": "3.4.0",
|
|
70
|
-
"tsdown": "
|
|
70
|
+
"tsdown": "0.19.0-beta.1",
|
|
71
71
|
"typescript": "5.9.3",
|
|
72
72
|
"zustand": "^5.0.9"
|
|
73
73
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-DkhL0ElE.js","names":["useCustomContext: UseCustomContext<TContextValue, TStrict>","useAfterMountEffect: typeof useEffect","useLocationState","useStorageState"],"sources":["../../src/hooks/createCustomContext.ts","../../src/hooks/useCallbackRef.ts","../../src/hooks/effects/useAfterMountEffect.ts","../../src/hooks/effects/useAsyncEffect.ts","../../src/hooks/effects/useEffectOnce.ts","../../src/hooks/effects/useLifeCycle.ts","../../src/hooks/effects/useMountEffect.ts","../../src/hooks/effects/useUnMountEffect.ts","../../src/hooks/useAnimateElementRefs.ts","../../src/hooks/useAnimationInterval.ts","../../src/hooks/useClickOutside.ts","../../src/hooks/useComposeRefs.ts","../../src/hooks/useConstant.ts","../../src/hooks/useControllable.ts","../../src/hooks/useToggle.ts","../../src/hooks/useCopyToClipboard.ts","../../src/hooks/useDebounce.ts","../../src/hooks/useDisclosure.ts","../../src/hooks/useIsHydrated.ts","../../src/hooks/useStore.ts","../../src/hooks/useLocationState.ts","../../src/hooks/useScrollObserver.ts","../../src/hooks/useSearch.ts","../../src/hooks/useSearchParams.ts","../../src/hooks/useShallowCompare.ts","../../src/hooks/useStorageState.ts","../../src/hooks/useThrottle.ts"],"sourcesContent":["import { createContext, use } from \"react\";\n\nexport type CustomContextOptions<TContextValue, TStrict extends boolean> = {\n\tdefaultValue?: TContextValue | null;\n\terrorMessage?: string;\n\textendValue?: (contextValue: NoInfer<TContextValue> | null) => TContextValue | null;\n\thookName?: string;\n\tname?: string;\n\tproviderName?: string;\n\tstrict?: TStrict;\n};\n\nexport type UseCustomContext<TContextValue, TStrict extends boolean> = () => TStrict extends true ?\n\tTContextValue\n:\tTContextValue | null;\n\nexport const createCustomContext = <TContextValue = null, TStrict extends boolean = true>(\n\toptions: CustomContextOptions<TContextValue, TStrict> = {}\n) => {\n\tconst {\n\t\tdefaultValue = null,\n\t\terrorMessage,\n\t\textendValue,\n\t\thookName = \"useUnnamedContext\",\n\t\tproviderName = \"UnnamedContextProvider\",\n\t\tname = providerName.endsWith(\"Provider\") ? providerName.slice(0, -8) : \"UnnamedContext\",\n\t\tstrict = true,\n\t} = options;\n\n\tconst Context = createContext<TContextValue>(defaultValue as TContextValue);\n\n\tContext.displayName = name;\n\n\tconst useCustomContext: UseCustomContext<TContextValue, TStrict> = () => {\n\t\tconst contextValue = use(Context);\n\n\t\tconst extendedContextValue = extendValue?.(contextValue) ?? contextValue;\n\n\t\tif (strict && extendedContextValue === null) {\n\t\t\tthrow new ContextError(errorMessage ?? getErrorMessage(hookName, providerName));\n\t\t}\n\n\t\treturn extendedContextValue as NonNullable<typeof extendedContextValue>;\n\t};\n\n\treturn [Context, useCustomContext] as [\n\t\tProvider: typeof Context,\n\t\tuseCustomContext: typeof useCustomContext,\n\t];\n};\n\nexport class ContextError extends Error {\n\toverride name = \"ContextError\";\n}\n\nexport const getErrorMessage = (hook: string, provider: string) => {\n\treturn `${hook} returned \"null\". Did you forget to wrap the necessary components within ${provider}?`;\n};\n","import type { AnyFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useInsertionEffect, useRef } from \"react\";\n\n/**\n * @description\n * - Returns a stable function that always points to the latest version of the callback function.\n * - This is only is the callback passed is not null or undefined.\n */\n\nconst useCallbackRef = <TCallback = AnyFunction>(callbackFn: TCallback): TCallback => {\n\tconst callbackRef = useRef(callbackFn);\n\n\tuseInsertionEffect(() => {\n\t\t// == Doing this instead updating it during render cuz according to Dan Abramov, render should be pure\n\t\tcallbackRef.current = callbackFn;\n\t}, [callbackFn]);\n\n\tconst savedCallback = useCallback(\n\t\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- callbackRef.current can be null in some cases\n\t\t(...params: unknown[]) => (callbackRef.current as AnyFunction)?.(...params) as unknown,\n\t\t[]\n\t);\n\n\tconst callbackOrSavedCallback = callbackFn ? (savedCallback as TCallback) : callbackFn;\n\n\treturn callbackOrSavedCallback;\n};\n\nexport { useCallbackRef };\n","import { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nconst useAfterMountEffect: typeof useEffect = (callBackFn, deps) => {\n\tconst isFirstMount = useRef(true);\n\tconst stableCallback = useCallbackRef(callBackFn);\n\n\tuseEffect(() => {\n\t\tif (isFirstMount.current) {\n\t\t\tisFirstMount.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\tstableCallback();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableCallback is stable\n\t}, deps);\n};\nexport { useAfterMountEffect };\n","import { useEffect, useState } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nexport function useAsyncEffect(\n\teffect: () => Promise<ReturnType<React.EffectCallback>>,\n\tdeps?: React.DependencyList\n) {\n\tconst stableEffectCallback = useCallbackRef(effect);\n\tconst [destroy, setDestroy] = useState<ReturnType<React.EffectCallback>>();\n\n\tuseEffect(() => {\n\t\tconst e = stableEffectCallback();\n\n\t\tasync function execute() {\n\t\t\tsetDestroy(await e);\n\t\t}\n\n\t\tvoid execute();\n\n\t\treturn () => void destroy?.();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableEffectCallback is stable\n\t}, deps);\n}\n","import { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nconst useEffectOnce = (callBackFn: React.EffectCallback) => {\n\tconst stableCallback = useCallbackRef(callBackFn);\n\n\tconst effectGuardRef = useRef(false);\n\n\t// == savedCallback is always stable so no worries about re-execution of this effect\n\tuseEffect(() => {\n\t\tif (effectGuardRef.current) return;\n\n\t\teffectGuardRef.current = true;\n\n\t\treturn stableCallback();\n\t}, [stableCallback]);\n};\n\nexport { useEffectOnce };\n","import { useEffect } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nexport type Destructor = ReturnType<React.EffectCallback>;\n\ntype LifeCycleOptions = {\n\tonMount?: () => void;\n\tonUnmount?: Destructor;\n};\n\nconst useLifeCycle = ({ onMount, onUnmount }: LifeCycleOptions) => {\n\tconst stableOnMount = useCallbackRef(onMount);\n\tconst stableOnUnmount = useCallbackRef(onUnmount);\n\n\tuseEffect(() => {\n\t\tstableOnMount?.();\n\n\t\treturn stableOnUnmount;\n\t}, [stableOnMount, stableOnUnmount]);\n};\n\nexport { useLifeCycle };\n","import { useLifeCycle } from \"./useLifeCycle\";\n\nconst useMountEffect = (callBackFn: () => void) => {\n\tuseLifeCycle({ onMount: callBackFn });\n};\n\nexport { useMountEffect };\n","import { type Destructor, useLifeCycle } from \"./useLifeCycle\";\n\nconst useUnmountEffect = (cleanUpFn: Destructor) => useLifeCycle({ onUnmount: cleanUpFn });\n\nexport { useUnmountEffect };\n","import { on } from \"@zayne-labs/toolkit-core\";\nimport { isArray, type NonEmptyArray } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useRef } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype ElementsInfoArray<TTargetElement extends string> = NonEmptyArray<{\n\tanimationClass: string;\n\ttargetElement: TTargetElement;\n}>;\n\nconst removeClass = (target: HTMLElement, className: string) => () => target.classList.remove(className);\n\n/**\n * This is a custom React hook that adds and removes animation classes to specified HTML elements.\n * @param elementsInfoArray - An array of objects that contain information about the animation class and the target HTML element.\n * @returns - An object containing the refs of the animated elements and a function to handle the initiation and removal animation.\n */\n\nconst useAnimateElementRefs = <TTargetElement extends string>(\n\telementsInfoArray: ElementsInfoArray<TTargetElement>\n) => {\n\tconst elementsRef = useRef<Record<TTargetElement, HTMLElement | null>>({} as never);\n\n\tconst addAnimationClasses = useCallbackRef(() => {\n\t\tif (!isArray(elementsInfoArray)) {\n\t\t\tconsole.error(\"elementsInfo is not an Array\");\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const { animationClass, targetElement } of elementsInfoArray) {\n\t\t\tif (!elementsRef.current[targetElement]) {\n\t\t\t\tconsole.error(\"ElementError\", `\"${targetElement}\" element does not exist`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\telementsRef.current[targetElement].classList.add(animationClass);\n\t\t}\n\t});\n\n\tconst removeAnimationClasses = useCallbackRef(() => {\n\t\tif (!isArray(elementsInfoArray)) {\n\t\t\tconsole.error(\"elementsInfo is not an Array\");\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const { animationClass, targetElement } of elementsInfoArray) {\n\t\t\tif (!elementsRef.current[targetElement]) {\n\t\t\t\tconsole.error(\"ElementError\", `\"${targetElement}\" element does not exist`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ton(\n\t\t\t\t\"transitionend\",\n\t\t\t\telementsRef.current[targetElement],\n\t\t\t\tremoveClass(elementsRef.current[targetElement], animationClass)\n\t\t\t);\n\n\t\t\ton(\n\t\t\t\t\"animationend\",\n\t\t\t\telementsRef.current[targetElement],\n\t\t\t\tremoveClass(elementsRef.current[targetElement], animationClass)\n\t\t\t);\n\t\t}\n\t});\n\n\t// Add animation classes to elements and remove them after the animation ends\n\tconst handleElementsAnimation = useCallback(() => {\n\t\taddAnimationClasses();\n\n\t\tremoveAnimationClasses();\n\t}, [addAnimationClasses, removeAnimationClasses]);\n\n\t// eslint-disable-next-line react-hooks/refs -- Allow this for convenience\n\treturn { animatedElements: elementsRef.current, handleElementsAnimation };\n};\n\nexport { useAnimateElementRefs };\n","import { type AnimationIntervalOptions, setAnimationInterval } from \"@zayne-labs/toolkit-core\";\nimport type { Prettify } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useEffect, useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype AnimationOptions = Prettify<\n\tAnimationIntervalOptions & {\n\t\tintervalDuration: number | null;\n\t\tonAnimation: () => void;\n\t}\n>;\n\nconst useAnimationInterval = (options: AnimationOptions) => {\n\tconst { intervalDuration, onAnimation, once } = options;\n\n\tconst latestCallback = useCallbackRef(onAnimation);\n\n\tconst { start, stop } = useMemo(\n\t\t() => setAnimationInterval(latestCallback, intervalDuration, { once }),\n\t\t[intervalDuration, latestCallback, once]\n\t);\n\n\tuseEffect(() => {\n\t\tif (intervalDuration === null) return;\n\n\t\tstart();\n\n\t\treturn stop;\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- start and stop are stable\n\t}, [intervalDuration]);\n\n\treturn { start, stop };\n};\n\nexport { useAnimationInterval };\n","import { onClickOutside, toArray } from \"@zayne-labs/toolkit-core\";\nimport { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype UseClickOutsideOptions<TElement extends HTMLElement> = {\n\tenabled?: boolean;\n\tonClick: (event: MouseEvent | TouchEvent) => void;\n\tref?: Array<React.RefObject<TElement>> | React.RefObject<TElement>;\n};\n\nconst useClickOutside = <TElement extends HTMLElement>(options: UseClickOutsideOptions<TElement>) => {\n\tconst innerRef = useRef<TElement>(null);\n\n\tconst { enabled = true, onClick, ref: refOrRefArray = innerRef } = options;\n\n\tconst savedOnClick = useCallbackRef(onClick);\n\n\tuseEffect(() => {\n\t\tif (!enabled) return;\n\n\t\tconst elementArray = toArray(refOrRefArray).map((ref) => ref.current);\n\n\t\tconst cleanup = onClickOutside(elementArray, savedOnClick);\n\n\t\treturn () => cleanup();\n\t}, [enabled, refOrRefArray, savedOnClick]);\n\n\treturn {\n\t\tref: innerRef,\n\t};\n};\n\nexport { useClickOutside };\n","import { useMemo } from \"react\";\nimport { composeRefs, type PossibleRef } from \"@/utils\";\n\nconst useComposeRefs = <TRef extends HTMLElement>(...refs: Array<PossibleRef<TRef>>) => {\n\t// eslint-disable-next-line react-hooks/exhaustive-deps -- Allow\n\tconst mergedRef = useMemo(() => composeRefs(...refs), refs);\n\n\treturn mergedRef;\n};\n\nexport { useComposeRefs };\n","import { useRef } from \"react\";\n\nexport const useConstant = <TResult>(initFn: () => TResult): TResult => {\n\tconst resultRef = useRef<TResult | null>(null);\n\n\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- The current case is justified since it's optimizable by the react compiler\n\tif (resultRef.current === null) {\n\t\tresultRef.current = initFn();\n\t}\n\n\t// eslint-disable-next-line react-hooks/refs -- Allow this for convenience\n\treturn resultRef.current;\n};\n\nexport const useLazyRef = <TResult>(initFn: () => TResult): React.RefObject<TResult> => {\n\tconst resultRef = useRef<TResult>(null as never);\n\n\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- The current case is justified since it's optimizable by the react compiler\n\tif (resultRef.current === null) {\n\t\tresultRef.current = initFn();\n\t}\n\n\treturn resultRef;\n};\n","\"use client\";\n\nimport type { StateSetter } from \"@/utils\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype UseControllablePropOptions<TProp> = {\n\tprop: TProp | undefined;\n\tstate: TProp;\n};\n\n/**\n * @description Given a prop value and state value, the useControllableProp hook is used to determine whether a component is controlled or uncontrolled, and also returns the computed value.\n */\nexport const useControllableProp = <TProp>(options: UseControllablePropOptions<TProp>) => {\n\tconst { prop, state } = options;\n\n\tconst isControlled = prop !== undefined;\n\n\tconst value = isControlled ? prop : state;\n\n\tconst result = useMemo<[isControlled: typeof isControlled, value: typeof value]>(\n\t\t() => [isControlled, value],\n\t\t[isControlled, value]\n\t);\n\n\treturn result;\n};\n\ntype UseControllableStateOptions<TValue> = {\n\tdefaultValue?: TValue | (() => TValue);\n\tequalityFn?: (prevState: TValue, nextValue: TValue) => boolean;\n\tonChange?: (value: TValue) => void;\n\tvalue?: TValue;\n};\n\n/**\n * @description React hook to manage state that can be either controlled or uncontrolled.\n * - When `options.value` is provided, the hook operates in controlled mode.\n * In this mode, `value` always equals `options.value` and `setValue` will\n * invoke `options.onChange(next)` without mutating internal state.\n * - When `options.value` is not provided, the hook operates in uncontrolled\n * mode, initializing internal state from `options.defaultValue` and updating\n * it via `setValue`.\n * - All updates are gated by `options.equalityFn(prev, next)` which defaults\n * to `Object.is`.\n *\n * @param options - Configuration options for the hook.\n * @param options.value - Controlled value. If defined, the state is controlled.\n * @param options.defaultValue - Initial value for the uncontrolled state. Can be a\n * function for lazy initialization or a direct value.\n * @param options.onChange - Callback fired when a new value is requested. In\n * controlled mode, this is invoked instead of updating internal state. In\n * uncontrolled mode, it is called after the internal state updates.\n * @param options.equalityFn - Predicate that decides whether to commit an\n * update given `prevState` and `nextValue`. If the values are equal, the update\n * is skipped. Defaults to `Object.is`.\n * @returns A tuple `[value, setValue]` just like React.useState.\n *\n * @example\n * // Uncontrolled usage\n * const [value, setValue] = useControllableState({ defaultValue: 0 });\n *\n * @example\n * // Controlled usage\n * const [value, setValue] = useControllableState({\n * value: props.value,\n * onChange: props.onChange,\n * });\n */\nexport const useControllableState = <TValue>(options: UseControllableStateOptions<TValue>) => {\n\tconst { defaultValue, equalityFn = Object.is, onChange: onChangeProp, value: valueProp } = options;\n\n\tconst stableOnchangeProp = useCallbackRef(onChangeProp);\n\tconst stableEqualityFn = useCallbackRef(equalityFn);\n\n\tconst [unControlledState, setUncontrolledState] = useState(defaultValue as TValue);\n\n\tconst isControlled = valueProp !== undefined;\n\n\tconst currentValue = isControlled ? valueProp : unControlledState;\n\n\tconst setValue: StateSetter<TValue> = useCallback(\n\t\t(newValue) => {\n\t\t\tconst nextValue = isFunction(newValue) ? newValue(currentValue) : newValue;\n\n\t\t\tif (stableEqualityFn(currentValue, nextValue)) return;\n\n\t\t\t// == Always call onChangeProp whether the value is controlled or uncontrolled,\n\t\t\t// == just in case the onChangeProp is used to perform side effects\n\t\t\t// == without necessarily updating the controlled valueProp\n\t\t\tstableOnchangeProp?.(nextValue);\n\n\t\t\tif (isControlled) return;\n\n\t\t\tsetUncontrolledState(nextValue);\n\t\t},\n\t\t[isControlled, stableOnchangeProp, stableEqualityFn, currentValue]\n\t);\n\n\treturn [currentValue, setValue] as [value: typeof currentValue, setValue: typeof setValue];\n};\n","import { useCallback, useState } from \"react\";\n\ntype InitialState = boolean | (() => boolean);\n\nconst useToggle = (initialValue: InitialState = false) => {\n\tconst [value, setValue] = useState(initialValue);\n\n\tconst toggleValue = useCallback(<TValue>(newValue?: TValue) => {\n\t\tif (typeof newValue === \"boolean\") {\n\t\t\tsetValue(newValue);\n\t\t\treturn;\n\t\t}\n\n\t\tsetValue((prev) => !prev);\n\t}, []);\n\n\treturn [value, toggleValue] as [value: typeof value, toggleValue: typeof toggleValue];\n};\n\nexport { useToggle };\n","import {\n\ttype AllowedClipboardItems,\n\ttype CopyToClipboardOptions,\n\tcopyToClipboard,\n} from \"@zayne-labs/toolkit-core\";\nimport { useCallback, useRef, useState } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useToggle } from \"./useToggle\";\n\nconst useCopyToClipboard = (options: CopyToClipboardOptions & { timeout?: number } = {}) => {\n\tconst { mimeType, onCopied, onError, onSuccess, timeout = 1500 } = options;\n\n\tconst [value, setValue] = useState<AllowedClipboardItems>(\"\");\n\n\tconst [hasCopied, toggleHasCopied] = useToggle(false);\n\tconst timeoutRef = useRef<number | null>(null);\n\n\tconst savedOnError = useCallbackRef(onError);\n\tconst savedOnSuccess = useCallbackRef(onSuccess);\n\tconst savedOnCopied = useCallbackRef(onCopied);\n\n\tconst handleHasCopied = useCallback(() => {\n\t\ttoggleHasCopied(true);\n\n\t\ttimeoutRef.current && clearTimeout(timeoutRef.current);\n\n\t\ttimeoutRef.current = setTimeout(() => {\n\t\t\ttoggleHasCopied(false);\n\t\t}, timeout) as never;\n\t}, [toggleHasCopied, timeout]);\n\n\tconst handleCopy = useCallback(\n\t\t(valueToCopy: AllowedClipboardItems) => {\n\t\t\tsetValue(valueToCopy);\n\n\t\t\tvoid copyToClipboard(valueToCopy, {\n\t\t\t\tmimeType,\n\t\t\t\tonCopied: () => {\n\t\t\t\t\tsavedOnCopied?.();\n\t\t\t\t\thandleHasCopied();\n\t\t\t\t},\n\t\t\t\tonError: savedOnError,\n\t\t\t\tonSuccess: savedOnSuccess,\n\t\t\t});\n\t\t},\n\t\t[handleHasCopied, mimeType, savedOnCopied, savedOnError, savedOnSuccess]\n\t);\n\n\treturn { handleCopy, hasCopied, setValue, value };\n};\n\nexport { useCopyToClipboard };\n","import { debounce } from \"@zayne-labs/toolkit-core\";\nimport type { CallbackFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo, useState } from \"react\";\nimport { useUnmountEffect } from \"./effects/useUnMountEffect\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nexport const useDebouncedFn = <TParams>(callBackFn: CallbackFn<TParams>, delay: number | undefined) => {\n\tconst latestCallback = useCallbackRef(callBackFn);\n\n\tconst debouncedFn = useMemo(() => debounce(latestCallback, delay), [delay, latestCallback]);\n\n\tuseUnmountEffect(() => {\n\t\tdebouncedFn.cancel();\n\t\tdebouncedFn.cancelMaxWait();\n\t});\n\n\treturn debouncedFn;\n};\n\nexport const useDebouncedState = <TValue>(defaultValue: TValue, delay: number | undefined) => {\n\tconst [value, setValue] = useState(defaultValue);\n\n\tconst setDebouncedValue = useMemo(() => debounce(setValue, delay), [delay]);\n\n\tuseUnmountEffect(() => {\n\t\tsetDebouncedValue.cancel();\n\t\tsetDebouncedValue.cancelMaxWait();\n\t});\n\n\treturn [value, setDebouncedValue, setValue] as const;\n};\n","import { lockScroll } from \"@zayne-labs/toolkit-core\";\nimport { isBoolean } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useToggle } from \"./useToggle\";\n\ntype DisclosureOptions = {\n\thasScrollControl?: boolean;\n\tinitialState?: boolean | (() => boolean);\n};\n\nconst useDisclosure = (options: DisclosureOptions = {}) => {\n\tconst { hasScrollControl = false, initialState = false } = options;\n\tconst [isOpen, toggleIsOpen] = useToggle(initialState);\n\n\tconst onOpen = useCallbackRef(() => {\n\t\ttoggleIsOpen(true);\n\t\thasScrollControl && lockScroll({ lock: true });\n\t});\n\n\tconst onClose = useCallbackRef(() => {\n\t\ttoggleIsOpen(false);\n\t\thasScrollControl && lockScroll({ lock: false });\n\t});\n\n\tconst onToggle = useCallbackRef(<TValue>(value?: TValue) => {\n\t\tif (isBoolean(value)) {\n\t\t\ttoggleIsOpen(value);\n\t\t\thasScrollControl && lockScroll({ lock: value });\n\t\t\treturn;\n\t\t}\n\n\t\tisOpen ? onClose() : onOpen();\n\t});\n\n\tconst api = useMemo(() => ({ isOpen, onClose, onOpen, onToggle }), [isOpen, onClose, onOpen, onToggle]);\n\n\treturn api;\n};\nexport { useDisclosure };\n","import { useDeferredValue, useSyncExternalStore } from \"react\";\n\nconst noop = () => {};\n\nconst noopStore = {\n\tgetServerSnapshot: () => true,\n\tgetSnapshot: () => false,\n\tsubscribe: () => noop,\n};\n\n/**\n * @description Return a boolean indicating if the JS has been hydrated already.\n * When doing Server-Side Rendering, the result will always be false.\n * When doing Client-Side Rendering, the result will always be false on the\n * first render and true from then on. Even if a new component renders it will\n * always start with true.\n *\n * @see https://github.com/sergiodxa/remix-utils/blob/main/src/react/use-hydrated.ts\n *\n * @see https://github.com/sergiodxa/remix-utils/blob/main/src/react/use-hydrated.ts\n *\n * @example\n * **Example: Disable a button that needs JS to work.**\n * ```tsx\n * const isHydrated = useIsHydrated();\n *\n * return (\n * <button type=\"button\" disabled={!isHydrated} onClick={doSomethingCustom}>\n * Click me\n * </button>\n * );\n * ```\n */\nconst useIsHydrated = () => {\n\tconst isHydrated = useSyncExternalStore(\n\t\tnoopStore.subscribe,\n\t\tnoopStore.getSnapshot,\n\t\tnoopStore.getServerSnapshot\n\t);\n\n\t// == Using useDeferredValue to make the returned value for uSES play nicely with React's concurrent mode.\n\t// LINK - https://kurtextrem.de/posts/react-uses-hydration#-concurrent-usesyncexternalstore\n\t// TODO - Switch concurrent react stores once it's officially released - https://react.dev/blog/2025/04/23/react-labs-view-transitions-activity-and-more#concurrent-stores\n\tconst deferredIsHydrated = useDeferredValue(isHydrated);\n\n\treturn deferredIsHydrated;\n};\n\nexport { useIsHydrated };\n","import type { StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useDebugValue, useDeferredValue, useSyncExternalStore } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nconst identity = <TState>(value: TState) => value;\n\nconst useStore = <TState, TSlice = TState>(\n\tstore: StoreApi<TState>,\n\tselector: SelectorFn<TState, TSlice> = identity as never\n) => {\n\tconst stableSelector = useCallbackRef(selector);\n\n\tconst stableGetState = useCallback(() => stableSelector(store.getState()), [stableSelector, store]);\n\n\tconst stableGetInitialState = useCallback(\n\t\t() => stableSelector(store.getInitialState()),\n\t\t[stableSelector, store]\n\t);\n\n\tconst slice = useSyncExternalStore(store.subscribe, stableGetState, stableGetInitialState);\n\n\tuseDebugValue(slice);\n\n\t// == Using useDeferredValue to make the returned value for uSES play nicely with React's concurrent mode.\n\t// LINK - https://kurtextrem.de/posts/react-uses-hydration#-concurrent-usesyncexternalstore\n\t// TODO - Switch concurrent react stores once it's officially released - https://react.dev/blog/2025/04/23/react-labs-view-transitions-activity-and-more#concurrent-stores\n\tconst deferredSlice = useDeferredValue(slice);\n\n\treturn deferredSlice;\n};\n\nexport { useStore };\n","import {\n\tcreateLocationStore,\n\ttype LocationInfo,\n\ttype LocationStoreApi,\n\ttype LocationStoreOptions,\n} from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useStore } from \"./useStore\";\n\ntype UseLocationResult<TSlice> = [state: TSlice, actions: LocationStoreApi];\n\nexport const createUseLocationState = (options?: LocationStoreOptions) => {\n\tconst locationStore = createLocationStore(options);\n\n\ttype UseBoundLocationState = LocationStoreApi\n\t\t& (<TSlice = LocationInfo>(\n\t\t\tselector?: SelectorFn<LocationInfo, TSlice>\n\t\t) => UseLocationResult<TSlice>);\n\n\tconst useLocationState = <TSlice = LocationInfo>(\n\t\tselector?: SelectorFn<LocationInfo, TSlice>\n\t): UseLocationResult<TSlice> => {\n\t\tconst stateSlice = useStore(locationStore as never, selector);\n\n\t\treturn [stateSlice, locationStore];\n\t};\n\n\tObject.assign(useLocationState, locationStore);\n\n\treturn useLocationState as UseBoundLocationState;\n};\n\nexport const useLocationState = <TSlice = LocationInfo>(\n\tselector?: SelectorFn<LocationInfo, TSlice>,\n\toptions: LocationStoreOptions = {}\n): UseLocationResult<TSlice> => {\n\tconst { equalityFn } = options;\n\n\tconst savedEqualityFn = useCallbackRef(equalityFn);\n\n\tconst locationStore = useMemo(\n\t\t() => createLocationStore({ equalityFn: savedEqualityFn }),\n\t\t[savedEqualityFn]\n\t);\n\n\tconst stateSlice = useStore(locationStore as never, selector);\n\n\treturn [stateSlice, locationStore];\n};\n","import { createScrollObserver, type ScrollObserverOptions } from \"@zayne-labs/toolkit-core\";\nimport { type RefCallback, useMemo, useState } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nconst useScrollObserver = <TElement extends HTMLElement>(options: ScrollObserverOptions = {}) => {\n\tconst { onIntersectionChange, root, rootMargin = \"10px 0px 0px 0px\", threshold } = options;\n\n\tconst [isScrolled, setIsScrolled] = useState(false);\n\n\tconst savedOnIntersectionChange = useCallbackRef(onIntersectionChange);\n\n\tconst { elementObserver, handleElementObservation } = useMemo(() => {\n\t\treturn createScrollObserver({\n\t\t\tonIntersectionChange: (entry, observer) => {\n\t\t\t\tconst newIsScrolledState = !entry.isIntersecting;\n\n\t\t\t\tsetIsScrolled(newIsScrolledState);\n\n\t\t\t\t// eslint-disable-next-line no-param-reassign -- Mutation is fine here\n\t\t\t\t(entry.target as HTMLElement).dataset.scrolled = String(newIsScrolledState);\n\n\t\t\t\tsavedOnIntersectionChange?.(entry, observer);\n\t\t\t},\n\t\t\troot,\n\t\t\trootMargin,\n\t\t\tthreshold,\n\t\t});\n\t}, [root, rootMargin, savedOnIntersectionChange, threshold]);\n\n\tconst observedElementRef: RefCallback<TElement> = useCallbackRef((element) => {\n\t\tconst cleanupFn = handleElementObservation(element);\n\n\t\t// == React 18 may not call the cleanup function so we need to call it manually on element unmount\n\t\tif (!element) {\n\t\t\tcleanupFn?.();\n\t\t\treturn;\n\t\t}\n\n\t\treturn cleanupFn;\n\t});\n\n\treturn { elementObserver, isScrolled, observedElementRef };\n};\n\nexport { useScrollObserver };\n","import { isPlainObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useState } from \"react\";\nimport { useAfterMountEffect } from \"./effects/useAfterMountEffect\";\nimport { useDebouncedFn } from \"./useDebounce\";\n\nconst isSerializable = (item: unknown): item is boolean | number | string =>\n\ttypeof item === \"string\" || typeof item === \"number\" || typeof item === \"boolean\";\n\nconst checkObjectPropsForQuery = (item: Record<string, unknown>, query: string): boolean => {\n\tfor (const value of Object.values(item)) {\n\t\tif (isSerializable(value) && value.toString().toLowerCase().includes(query)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n};\n\nconst useSearch = <TData>(initialData: TData[], delay?: number) => {\n\tconst [searchQuery, setSearchQuery] = useState(\"\");\n\tconst [filteredData, setFilteredData] = useState(initialData);\n\tconst [isLoading, setIsLoading] = useState(false);\n\n\tconst handleDebouncedSearch = useDebouncedFn(() => {\n\t\tconst query = searchQuery.toLowerCase();\n\n\t\tconst filteredResults = initialData.filter((item) => {\n\t\t\tif (isSerializable(item)) {\n\t\t\t\treturn item.toString().toLowerCase().includes(query);\n\t\t\t}\n\n\t\t\tif (isPlainObject(item)) {\n\t\t\t\treturn checkObjectPropsForQuery(item, query);\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\n\t\tsetFilteredData(filteredResults);\n\t\tsetIsLoading(false);\n\t}, delay);\n\n\tuseAfterMountEffect(() => {\n\t\tsetIsLoading(true);\n\t\thandleDebouncedSearch();\n\t}, [searchQuery]);\n\n\treturn { data: filteredData, isLoading, query: searchQuery, setQuery: setSearchQuery };\n};\n\nexport { useSearch };\n","import {\n\tcreateSearchParams,\n\ttype LocationStoreOptions,\n\ttype URLSearchParamsInit,\n} from \"@zayne-labs/toolkit-core\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useLocationState } from \"./useLocationState\";\n\ntype UseSearchParamsOptions = LocationStoreOptions & {\n\taction?: \"push\" | \"replace\";\n};\n\nexport const useSearchParams = <TSearchParams extends URLSearchParamsInit>(\n\toptions?: UseSearchParamsOptions\n) => {\n\tconst { action = \"push\", ...restOfOptions } = options ?? {};\n\n\tconst [searchParams, actions] = useLocationState((state) => state.search, restOfOptions);\n\n\tconst setSearchParams = (\n\t\tnewQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)\n\t) => {\n\t\tconst params = isFunction(newQueryParams) ? newQueryParams(searchParams) : newQueryParams;\n\n\t\tconst nextSearchParams = createSearchParams(params);\n\n\t\tactions[action]({ search: nextSearchParams });\n\t};\n\n\treturn [searchParams, setSearchParams, actions.triggerPopstateEvent] as [\n\t\tsearchParams: typeof searchParams,\n\t\tsetSearchParams: typeof setSearchParams,\n\t\ttriggerPopstateEvent: typeof actions.triggerPopstateEvent,\n\t];\n};\n\nexport const useSearchParamsObject = <TSearchParams extends Record<string, string>>(\n\toptions?: UseSearchParamsOptions\n) => {\n\tconst [searchParams, setSearchParams, triggerPopstateEvent] = useSearchParams(options);\n\n\tconst searchParamsObject = Object.fromEntries(searchParams) as TSearchParams;\n\n\tconst setSearchParamsObject = (\n\t\tnewQueryParams: TSearchParams | ((prev: TSearchParams) => TSearchParams)\n\t) => {\n\t\tconst params = isFunction(newQueryParams) ? newQueryParams(searchParamsObject) : newQueryParams;\n\n\t\tsetSearchParams(params);\n\t};\n\n\treturn [searchParamsObject, setSearchParamsObject, triggerPopstateEvent] as [\n\t\tsearchParamsObject: typeof searchParamsObject,\n\t\tsetSearchParamsObject: typeof setSearchParamsObject,\n\t\ttriggerPopstateEvent: typeof triggerPopstateEvent,\n\t];\n};\n","import { shallowCompare } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useInsertionEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nexport const useShallowCompSelector = <TState, TResult>(\n\tselector: SelectorFn<TState, TResult> | undefined\n) => {\n\tconst prevStateRef = useRef<TResult>(undefined as never);\n\n\tconst shallowSelector = useCallbackRef((state: TState) => {\n\t\tconst nextState = selector?.(state);\n\n\t\tif (!nextState) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\tif (shallowCompare(prevStateRef.current, nextState)) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\treturn (prevStateRef.current = nextState);\n\t});\n\n\treturn shallowSelector;\n};\n\nexport const useShallowCompValue = <TValue>(value: TValue) => {\n\tconst prevValueRef = useRef<TValue>(value);\n\n\tuseInsertionEffect(() => {\n\t\tif (shallowCompare(prevValueRef.current, value)) return;\n\n\t\tprevValueRef.current = value;\n\t});\n\n\t// eslint-disable-next-line react-hooks/refs -- Allow this for convenience\n\treturn prevValueRef.current;\n};\n","import {\n\tcreateExternalStorageStore,\n\ttype StorageOptions,\n\ttype StorageStoreApi,\n} from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useStore } from \"./useStore\";\n\ntype UseStorageResult<TState, TSlice = TState> = [state: TSlice, actions: StorageStoreApi<TState>];\n\n/**\n * @description Creates a custom hook that returns a storage state and actions to modify it. You can use this if you need shared options.\n * @note You must use this if you want to be able to prevent syncing state across tabs.\n */\nexport const createUseStorageState = <TState>(baseOptions: StorageOptions<TState>) => {\n\tconst externalStore = createExternalStorageStore(baseOptions);\n\n\ttype UseBoundStorageState = StorageStoreApi<TState>\n\t\t& (<TSlice = TState>(selector?: SelectorFn<TState, TSlice>) => UseStorageResult<TState, TSlice>);\n\n\tconst useStorageState = <TSlice = TState>(\n\t\tselector?: SelectorFn<TState, TSlice>\n\t): UseStorageResult<TState, TSlice> => {\n\t\tconst stateInStorage = useStore(externalStore, selector);\n\n\t\treturn [stateInStorage, externalStore];\n\t};\n\n\tObject.assign(useStorageState, externalStore);\n\n\treturn useStorageState as UseBoundStorageState;\n};\n\ntype UseStorageStateOptions<TValue> = Omit<StorageOptions<TValue>, \"initialValue\" | \"key\">;\n\nexport const useStorageState = <TValue, TSlice = TValue>(\n\tkey: string,\n\tinitialValue?: TValue,\n\toptions: UseStorageStateOptions<TValue> & { select?: SelectorFn<TValue, TSlice> } = {}\n): UseStorageResult<TValue, TSlice> => {\n\tconst { equalityFn, logger, parser, partialize, select, serializer, storageArea, syncStateAcrossTabs } =\n\t\toptions;\n\n\tconst savedEquality = useCallbackRef(equalityFn);\n\tconst savedLogger = useCallbackRef(logger);\n\tconst savedParser = useCallbackRef(parser);\n\tconst savedPartialize = useCallbackRef(partialize);\n\tconst savedSerializer = useCallbackRef(serializer);\n\n\tconst externalStore = useMemo(() => {\n\t\treturn createExternalStorageStore({\n\t\t\tequalityFn: savedEquality,\n\t\t\tinitialValue,\n\t\t\tkey,\n\t\t\tlogger: savedLogger,\n\t\t\tparser: savedParser,\n\t\t\tpartialize: savedPartialize,\n\t\t\tserializer: savedSerializer,\n\t\t\tstorageArea,\n\t\t\tsyncStateAcrossTabs,\n\t\t});\n\t}, [\n\t\tinitialValue,\n\t\tkey,\n\t\tsavedEquality,\n\t\tsavedLogger,\n\t\tsavedParser,\n\t\tsavedPartialize,\n\t\tsavedSerializer,\n\t\tstorageArea,\n\t\tsyncStateAcrossTabs,\n\t]);\n\n\tconst stateInStorage = useStore(externalStore as never, select as never);\n\n\treturn [stateInStorage as never, externalStore];\n};\n","import { throttleByFrame, throttleBySetTimeout, throttleByTime } from \"@zayne-labs/toolkit-core\";\nimport type { CallbackFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { useUnmountEffect } from \"./effects\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useConstant } from \"./useConstant\";\n\nexport const useThrottleBySetTimeout = <TParams>(callbackFn: CallbackFn<TParams>, delay: number) => {\n\tconst latestCallback = useCallbackRef(callbackFn);\n\n\tconst throttledCallback = useMemo(\n\t\t() => throttleBySetTimeout(latestCallback, delay),\n\t\t[delay, latestCallback]\n\t);\n\n\tuseUnmountEffect(() => throttledCallback.cancelTimeout());\n\n\treturn throttledCallback;\n};\n\nexport const useThrottleByTimer = <TParams>(callbackFn: CallbackFn<TParams>, delay: number) => {\n\tconst latestCallback = useCallbackRef(callbackFn);\n\n\tconst throttledCallback = useMemo(() => throttleByTime(latestCallback, delay), [delay, latestCallback]);\n\n\treturn throttledCallback;\n};\n\nexport const useThrottleByFrame = <TParams>(callbackFn: CallbackFn<TParams>) => {\n\tconst latestCallback = useCallbackRef(callbackFn);\n\n\tconst throttledCallback = useConstant(() => throttleByFrame(latestCallback));\n\n\tuseUnmountEffect(() => throttledCallback.cancelAnimation());\n\n\treturn throttledCallback;\n};\n"],"mappings":";;;;;;AAgBA,MAAa,uBACZ,UAAwD,EAAE,KACtD;CACJ,MAAM,EACL,eAAe,MACf,cACA,aACA,WAAW,qBACX,eAAe,0BACf,OAAO,aAAa,SAAS,WAAW,GAAG,aAAa,MAAM,GAAG,GAAG,GAAG,kBACvE,SAAS,SACN;CAEJ,MAAM,UAAU,cAA6B,aAA8B;AAE3E,SAAQ,cAAc;CAEtB,MAAMA,yBAAmE;EACxE,MAAM,eAAe,IAAI,QAAQ;EAEjC,MAAM,uBAAuB,cAAc,aAAa,IAAI;AAE5D,MAAI,UAAU,yBAAyB,KACtC,OAAM,IAAI,aAAa,gBAAgB,gBAAgB,UAAU,aAAa,CAAC;AAGhF,SAAO;;AAGR,QAAO,CAAC,SAAS,iBAAiB;;AAMnC,IAAa,eAAb,cAAkC,MAAM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E7C,QAAOA;;AAKR,MAAa,mBACZ,KACA,cACA,UAAoF,EAAE,KAChD;CACtC,MAAM,EAAE,YAAY,QAAQ,QAAQ,YAAY,QAAQ,YAAY,aAAa,wBAChF;CAED,MAAM,gBAAgB,eAAe,WAAW;CAChD,MAAM,cAAc,eAAe,OAAO;CAC1C,MAAM,cAAc,eAAe,OAAO;CAC1C,MAAM,kBAAkB,eAAe,WAAW;CAClD,MAAM,kBAAkB,eAAe,WAAW;CAElD,MAAM,gBAAgB,cAAc;AACnC,SAAO,2BAA2B;GACjC,YAAY;GACZ;GACA;GACA,QAAQ;GACR,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ;GACA;GACA,CAAC;IACA;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,CAAC;AAIF,QAAO,CAFgB,SAAS,eAAwB,OAAgB,EAEvC,cAAc;;;;;ACtEhD,MAAa,2BAAoC,YAAiC,UAAkB;CACnG,MAAM,iBAAiB,eAAe,WAAW;CAEjD,MAAM,oBAAoB,cACnB,qBAAqB,gBAAgB,MAAM,EACjD,CAAC,OAAO,eAAe,CACvB;AAED,wBAAuB,kBAAkB,eAAe,CAAC;AAEzD,QAAO;;AAGR,MAAa,sBAA+B,YAAiC,UAAkB;CAC9F,MAAM,iBAAiB,eAAe,WAAW;AAIjD,QAF0B,cAAc,eAAe,gBAAgB,MAAM,EAAE,CAAC,OAAO,eAAe,CAAC;;AAKxG,MAAa,sBAA+B,eAAoC;CAC/E,MAAM,iBAAiB,eAAe,WAAW;CAEjD,MAAM,oBAAoB,kBAAkB,gBAAgB,eAAe,CAAC;AAE5E,wBAAuB,kBAAkB,iBAAiB,CAAC;AAE3D,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-BJUZGTbU.js","names":["result","accumulatedHandlers: AnyFunction | undefined","mergedRefCallBack: RefCallback<TRef>","ReactFragment","slots: Record<string, TSlotComponentProps[\"children\"]> & { default: React.ReactNode[] }","ReactFragment","cnMerge: typeof twMerge","accumulatedProps: Record<string, unknown>"],"sources":["../../src/utils/composeEventHandlers.ts","../../src/utils/composeRefs.ts","../../src/utils/getSlot/getSlot.ts","../../src/utils/getSlotMap/getSlotMap.ts","../../src/lib/utils/cn.ts","../../src/utils/mergeTwoProps.ts","../../src/utils/mergeProps.ts"],"sourcesContent":["import { type AnyFunction, isObject } from \"@zayne-labs/toolkit-type-helpers\";\n\nconst isSyntheticEvent = (event: unknown): event is React.SyntheticEvent => {\n\treturn isObject(event) && Object.hasOwn(event, \"nativeEvent\");\n};\n\nexport const composeTwoEventHandlers = (\n\tformerHandler: AnyFunction | undefined,\n\tlatterHandler: AnyFunction | undefined\n) => {\n\tconst mergedEventHandler = (event: unknown) => {\n\t\tif (isSyntheticEvent(event)) {\n\t\t\tconst result = latterHandler?.(event) as unknown;\n\n\t\t\tif (!event.defaultPrevented) {\n\t\t\t\tformerHandler?.(event);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\n\t\tconst result = latterHandler?.(event) as unknown;\n\t\tformerHandler?.(event);\n\t\treturn result;\n\t};\n\n\treturn mergedEventHandler;\n};\n\nexport const composeEventHandlers = (...eventHandlerArray: Array<AnyFunction | undefined>) => {\n\tconst mergedEventHandler = (event: unknown) => {\n\t\tif (eventHandlerArray.length === 0) return;\n\n\t\tif (eventHandlerArray.length === 1) {\n\t\t\treturn eventHandlerArray[0]?.(event) as unknown;\n\t\t}\n\n\t\tlet accumulatedHandlers: AnyFunction | undefined;\n\n\t\tfor (const eventHandler of eventHandlerArray) {\n\t\t\tif (!eventHandler) continue;\n\n\t\t\taccumulatedHandlers = composeTwoEventHandlers(accumulatedHandlers, eventHandler);\n\t\t}\n\n\t\treturn accumulatedHandlers?.(event) as unknown;\n\t};\n\n\treturn mergedEventHandler;\n};\n","import { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { RefCallback } from \"react\";\n\nexport type PossibleRef<TRef extends HTMLElement> = React.Ref<TRef> | undefined;\n\n/**\n * @description Set a given ref to a given value.\n *\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nexport const setRef = <TRef extends HTMLElement>(\n\tref: PossibleRef<TRef>,\n\tnode: TRef | null\n): ReturnType<RefCallback<TRef>> => {\n\tif (!ref) return;\n\n\tif (isFunction(ref)) {\n\t\treturn ref(node);\n\t}\n\n\t// eslint-disable-next-line no-param-reassign -- Mutation is needed here\n\tref.current = node;\n};\n\n/**\n * @description A utility to combine refs. Accepts callback refs and RefObject(s)\n */\nexport const composeRefs = <TRef extends HTMLElement>(\n\t...refs: Array<PossibleRef<TRef>>\n): RefCallback<TRef> => {\n\tconst mergedRefCallBack: RefCallback<TRef> = (node) => {\n\t\tconst cleanupFnArray = refs.map((ref) => setRef(ref, node));\n\n\t\tconst cleanupFn = () => cleanupFnArray.forEach((cleanup) => cleanup?.());\n\n\t\treturn cleanupFn;\n\t};\n\n\treturn mergedRefCallBack;\n};\n","import { toArray } from \"@zayne-labs/toolkit-core\";\nimport {\n\ttype AnyFunction,\n\tAssertionError,\n\tisArray,\n\tisFunction,\n\ttype Prettify,\n\ttype UnknownObject,\n} from \"@zayne-labs/toolkit-type-helpers\";\nimport { isValidElement, Fragment as ReactFragment } from \"react\";\nimport type { InferProps } from \"../types\";\n\nexport type FunctionalComponent<TProps extends UnknownObject = never> = React.FunctionComponent<TProps>;\n\nconst isWithSlotSymbol = <TFunction extends AnyFunction>(\n\tcomponent: TFunction\n): component is Record<\"slotSymbol\", unknown> & TFunction => {\n\treturn \"slotSymbol\" in component && Boolean(component.slotSymbol);\n};\n\nconst isWithSlotReference = <TFunction extends AnyFunction>(\n\tcomponent: TFunction\n): component is Record<\"slotReference\", unknown> & TFunction => {\n\treturn \"slotReference\" in component && Boolean(component.slotReference);\n};\n/**\n * @description Checks if a react child (within the children array) matches the provided SlotComponent using multiple matching strategies:\n * 1. Matches by slot symbol property\n * 2. Matches by component name\n */\n\nexport const matchesSlotComponent = (child: React.ReactNode, SlotComponent: FunctionalComponent) => {\n\tif (!isValidElement(child) || !isFunction(child.type)) {\n\t\treturn false;\n\t}\n\n\tconst resolvedChildType =\n\t\tisWithSlotReference(child.type) ? (child.type.slotReference as FunctionalComponent) : child.type;\n\n\tconst hasMatchingSlotSymbol =\n\t\tisWithSlotSymbol(resolvedChildType)\n\t\t&& isWithSlotSymbol(SlotComponent)\n\t\t&& resolvedChildType.slotSymbol === SlotComponent.slotSymbol;\n\n\tif (hasMatchingSlotSymbol) {\n\t\treturn true;\n\t}\n\n\tif (child.type.name === SlotComponent.name) {\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n/**\n * @description Checks if a react child (within the children array) matches any of the provided SlotComponents.\n */\nexport const matchesAnySlotComponent = (child: React.ReactNode, SlotComponents: FunctionalComponent[]) => {\n\tconst matchesSlot = SlotComponents.some((SlotComponent) => matchesSlotComponent(child, SlotComponent));\n\n\treturn matchesSlot;\n};\n\ntype SlotOptions = {\n\t/**\n\t * @description The error message to throw when multiple slots are found for a given slot component\n\t */\n\terrorMessage?: string;\n\t/**\n\t * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component\n\t */\n\tthrowOnMultipleSlotMatch?: boolean;\n};\n\n/**\n * @description Counts how many times a given slot component appears in an array of children\n * @internal\n */\nconst calculateSlotOccurrences = (\n\tchildrenArray: React.ReactNode[],\n\tSlotComponent: FunctionalComponent\n) => {\n\tlet count = 0;\n\n\tfor (const child of childrenArray) {\n\t\tif (!matchesSlotComponent(child, SlotComponent)) continue;\n\n\t\tcount += 1;\n\t}\n\n\treturn count;\n};\n\n/**\n * @description Retrieves a single slot element from a collection of React children that matches the provided SlotComponent component.\n *\n * @throws { AssertionError } when throwOnMultipleSlotMatch is true and multiple slots are found\n */\nexport const getSingleSlot = (\n\tchildren: React.ReactNode,\n\tSlotComponent: FunctionalComponent,\n\toptions: SlotOptions = {}\n) => {\n\tconst {\n\t\terrorMessage = \"Only one instance of the SlotComponent is allowed\",\n\t\tthrowOnMultipleSlotMatch = false,\n\t} = options;\n\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment ?\n\t\t\tchildren.props.children\n\t\t:\tchildren;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tconst shouldThrow =\n\t\tthrowOnMultipleSlotMatch && calculateSlotOccurrences(childrenArray, SlotComponent) > 1;\n\n\tif (shouldThrow) {\n\t\tthrow new AssertionError(errorMessage);\n\t}\n\n\tconst slotElement = childrenArray.find((child) => matchesSlotComponent(child, SlotComponent));\n\n\treturn slotElement;\n};\n\n// NOTE - You can imitate const type parameter by extending readonly[] | []\n\ntype MultipleSlotsOptions = {\n\t/**\n\t * @description The error message to throw when multiple slots are found for a given slot component\n\t * If a string is provided, the same message will be used for all slot components\n\t * If an array is provided, each string in the array will be used as the errorMessage for the corresponding slot component\n\t */\n\terrorMessage?: string | string[];\n\t/**\n\t * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component\n\t * If a boolean is provided, the same value will be used for all slot components\n\t * If an array is provided, each boolean in the array will be used as the throwOnMultipleSlotMatch value for the corresponding slot component\n\t */\n\tthrowOnMultipleSlotMatch?: boolean | boolean[];\n};\n\ntype GetMultipleSlotsResult<TSlotComponents extends FunctionalComponent[]> = {\n\tregularChildren: React.ReactNode[];\n\tslots: { [Key in keyof TSlotComponents]: ReturnType<TSlotComponents[Key]> };\n};\n\n/**\n * @description The same as getSingleSlot, but for multiple slot components\n */\nexport const getMultipleSlots = <const TSlotComponents extends FunctionalComponent[]>(\n\tchildren: React.ReactNode,\n\tSlotComponents: TSlotComponents,\n\toptions?: MultipleSlotsOptions\n): Prettify<GetMultipleSlotsResult<TSlotComponents>> => {\n\tconst { errorMessage, throwOnMultipleSlotMatch } = options ?? {};\n\n\tconst slots = SlotComponents.map((SlotComponent, index) =>\n\t\tgetSingleSlot(children, SlotComponent, {\n\t\t\terrorMessage: isArray(errorMessage) ? errorMessage[index] : errorMessage,\n\t\t\tthrowOnMultipleSlotMatch:\n\t\t\t\tisArray(throwOnMultipleSlotMatch) ? throwOnMultipleSlotMatch[index] : throwOnMultipleSlotMatch,\n\t\t})\n\t);\n\n\tconst regularChildren = getRegularChildren(children, SlotComponents);\n\n\treturn { regularChildren, slots } as GetMultipleSlotsResult<TSlotComponents>;\n};\n\n/**\n * @description Returns all children that are not slot elements (i.e., don't match any of the provided slot components)\n */\nexport const getRegularChildren = (\n\tchildren: React.ReactNode,\n\tSlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]\n) => {\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment ?\n\t\t\tchildren.props.children\n\t\t:\tchildren;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tconst regularChildren = childrenArray.filter(\n\t\t(child) => !matchesAnySlotComponent(child, toArray(SlotComponentOrComponents))\n\t);\n\n\treturn regularChildren;\n};\n","import { toArray } from \"@zayne-labs/toolkit-core\";\nimport {\n\ttype CallbackFn,\n\ttype EmptyObject,\n\tisFunction,\n\ttype Prettify,\n\ttype UnionToIntersection,\n\ttype UnknownObject,\n} from \"@zayne-labs/toolkit-type-helpers\";\nimport { isValidElement, Fragment as ReactFragment } from \"react\";\nimport type { InferProps } from \"../types\";\n\ntype GetSlotName<TSlotComponentProps extends GetSlotComponentProps> =\n\tstring extends TSlotComponentProps[\"name\"] ? never\n\t: \"default\" extends TSlotComponentProps[\"name\"] ? never\n\t: TSlotComponentProps[\"name\"];\n\ntype GetSpecificSlotsType<TSlotComponentProps extends GetSlotComponentProps> = {\n\t// This conditional before the remapping will prevent an Indexed Record type from showing up if the props are not passed, enhancing type safety\n\t[TName in keyof TSlotComponentProps as GetSlotName<TSlotComponentProps>]: Extract<\n\t\tTSlotComponentProps[\"children\"],\n\t\tReact.ReactNode\n\t>;\n};\n\n/**\n * Maps slot names to their corresponding children types\n */\nexport type GetSlotMapResult<TSlotComponentProps extends GetSlotComponentProps> = UnionToIntersection<\n\tGetSpecificSlotsType<TSlotComponentProps>\n> & { default: React.ReactNode[] };\n\n/**\n * Symbol used to identify SlotComponent instances\n */\nexport const slotComponentSymbol = Symbol(\"slot-component\");\n\n/**\n * @description Creates a map of named slots from React children. Returns an object mapping slot names to their children,\n * with a default slot for unmatched children.\n *\n * @example\n * ```tsx\n * import { type GetSlotComponentProps, SlotComponent } from \"@zayne-labs/toolkit-react/utils\"\n *\n * type SlotProps = GetSlotComponentProps<\"header\" | \"footer\">;\n *\n * function Parent({ children }: { children: React.ReactNode }) {\n * const slots = getSlotMap<SlotProps>(children);\n *\n * return (\n * <div>\n * <header>{slots.header}</header>\n * <main>{slots.default}</main>\n * <footer>{slots.footer}</footer>\n * </div>\n * );\n * }\n * ```\n *\n * Usage:\n * ```tsx\n * <Parent>\n * <SlotComponent name=\"header\">Header Content</SlotComponent>\n * <div>Random stuff</div>\n * <SlotComponent name=\"footer\">Footer Content</SlotComponent>\n * </Parent>\n * ```\n */\nexport const getSlotMap = <TSlotComponentProps extends GetSlotComponentProps>(\n\tchildren: React.ReactNode\n): Prettify<GetSlotMapResult<TSlotComponentProps>> => {\n\tconst slots: Record<string, TSlotComponentProps[\"children\"]> & { default: React.ReactNode[] } = {\n\t\tdefault: [],\n\t};\n\n\tconst isFragment = isValidElement<InferProps<HTMLElement>>(children) && children.type === ReactFragment;\n\n\tconst actualChildren = isFragment ? children.props.children : children;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tfor (const child of childrenArray) {\n\t\tif (!isValidElement<TSlotComponentProps>(child) || !isFunction(child.type)) {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst childType = child.type as SlotWithNameAndSymbol;\n\n\t\tconst isSlotElement =\n\t\t\tchildType.slotSymbol === slotComponentSymbol && Boolean(childType.slotName ?? child.props.name);\n\n\t\tif (!isSlotElement) {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst slotName = childType.slotName ?? child.props.name;\n\n\t\tif (slotName === \"default\") {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tslots[slotName] = child;\n\t}\n\n\treturn slots as GetSlotMapResult<TSlotComponentProps>;\n};\n\n/**\n * @description Produce props for the SlotComponent\n *\n * @example\n * ```ts\n * // Pattern One (slot or slots have same children type, which is just React.ReactNode by default)\n * type SlotProps = GetSlotComponentProps<\"header\" | \"content\" | \"footer\">;\n *\n * // Pattern Two (some slots can have different children type)\n * type SlotProps = GetSlotComponentProps<\"header\", React.ReactNode> | GetSlotComponentProps<\"header\", (renderProp: RenderProp) => React.ReactNode>;\n * ```\n */\nexport type GetSlotComponentProps<\n\tTName extends string = string,\n\tTChildren extends CallbackFn<never, React.ReactNode> | React.ReactNode =\n\t\t| CallbackFn<never, React.ReactNode>\n\t\t| React.ReactNode,\n> = {\n\tchildren: TChildren;\n\t/**\n\t * Name of the slot where content should be rendered\n\t */\n\tname: TName;\n};\n\n/**\n * @description Creates a slot component\n */\nexport const createSlotComponent = <TSlotComponentProps extends GetSlotComponentProps>() => {\n\tconst SlotComponent = (props: TSlotComponentProps) => props.children as React.ReactNode;\n\n\tSlotComponent.slotSymbol = slotComponentSymbol;\n\n\treturn SlotComponent;\n};\n\ntype SlotWithNameAndSymbol<\n\tTSlotComponentProps extends GetSlotComponentProps = GetSlotComponentProps,\n\tTOtherProps extends UnknownObject = EmptyObject,\n> = {\n\t(props: Pick<TSlotComponentProps, \"children\"> & TOtherProps): React.ReactNode;\n\treadonly slotName?: TSlotComponentProps[\"name\"];\n\treadonly slotSymbol?: symbol;\n};\n\nfunction DefaultSlotComponent(props: Pick<GetSlotComponentProps, \"children\">): React.ReactNode {\n\treturn props.children as React.ReactNode;\n}\n\n/**\n * @description Adds a slot symbol and name to a slot component passed in\n */\nexport const withSlotNameAndSymbol = <\n\tTSlotComponentProps extends GetSlotComponentProps,\n\tTOtherProps extends UnknownObject = EmptyObject,\n>(\n\tname: TSlotComponentProps[\"name\"],\n\tSlotComponent: SlotWithNameAndSymbol<TSlotComponentProps, TOtherProps> = DefaultSlotComponent\n) => {\n\t/* eslint-disable no-param-reassign -- This is necessary */\n\t// @ts-expect-error -- This is necessary for the time being, to prevent type errors and accidental overrides on consumer side\n\tSlotComponent.slotSymbol = slotComponentSymbol;\n\t// @ts-expect-error -- This is necessary for the time being, to prevent type errors and accidental overrides on consumer side\n\tSlotComponent.slotName = name;\n\n\t/* eslint-enable no-param-reassign -- This is necessary */\n\n\treturn SlotComponent;\n};\n","import { twJoin, twMerge } from \"tailwind-merge\";\n\nexport const cnMerge: typeof twMerge = (...classNames) => twMerge(classNames);\n\nexport const cnJoin: typeof twJoin = (...classNames) => twJoin(classNames);\n","import { type AnyFunction, isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport { composeTwoEventHandlers } from \"./composeEventHandlers\";\n\n// == This approach is more efficient than using a regex.\nconst isEventHandler = (key: string, value: unknown): value is AnyFunction => {\n\tconst thirdCharCode = key.codePointAt(2);\n\n\tif (!isFunction(value) || thirdCharCode === undefined) {\n\t\treturn false;\n\t}\n\n\tconst isHandler = key.startsWith(\"on\") && thirdCharCode >= 65 /* A */ && thirdCharCode <= 90; /* Z */\n\n\treturn isHandler;\n};\n\n// const mergeTwoClassNames = (formerClassName: string | undefined, latterClassName: string | undefined) => {\n// \tif (!latterClassName || !formerClassName) {\n// \t\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- Logical OR is fit for this case\n// \t\treturn latterClassName || formerClassName;\n// \t}\n\n// \t// eslint-disable-next-line prefer-template -- String concatenation is more performant than template literals in this case\n// \treturn formerClassName + \" \" + latterClassName;\n// };\n\nexport const mergeTwoProps = <TProps extends Record<never, never>>(\n\tformerProps: TProps | undefined,\n\tlatterProps: TProps | undefined\n): TProps => {\n\t// == If no props are provided, return an empty object\n\tif (!latterProps || !formerProps) {\n\t\treturn latterProps ?? formerProps ?? ({} as TProps);\n\t}\n\n\tconst propsAccumulator = { ...formerProps } as Record<string, unknown>;\n\n\tfor (const latterPropName of Object.keys(latterProps)) {\n\t\tconst formerPropValue = (formerProps as Record<string, unknown>)[latterPropName];\n\t\tconst latterPropValue = (latterProps as Record<string, unknown>)[latterPropName];\n\n\t\t// == If the prop is `className` or `class`, we merge them\n\t\tif (latterPropName === \"className\" || latterPropName === \"class\") {\n\t\t\tpropsAccumulator[latterPropName] = cnMerge(formerPropValue as string, latterPropValue as string);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == If the prop is `style`, we merge them\n\t\tif (latterPropName === \"style\") {\n\t\t\tpropsAccumulator[latterPropName] = {\n\t\t\t\t...(formerPropValue as object),\n\t\t\t\t...(latterPropValue as object),\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == If the handler exists on both, we compose them\n\t\tif (isEventHandler(latterPropName, latterPropValue)) {\n\t\t\tpropsAccumulator[latterPropName] = composeTwoEventHandlers(\n\t\t\t\tformerPropValue as AnyFunction | undefined,\n\t\t\t\tlatterPropValue\n\t\t\t);\n\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == latterProps override by default\n\t\tpropsAccumulator[latterPropName] = latterPropValue;\n\t}\n\n\treturn propsAccumulator as TProps;\n};\n","import { mergeTwoProps } from \"./mergeTwoProps\";\n\ntype UnionToIntersection<TUnion> =\n\t(TUnion extends unknown ? (param: TUnion) => void : \"\") extends (param: infer TParam) => void ? TParam\n\t:\t\"\";\n\n/**\n * Merges multiple sets of React props.\n *\n * - It follows the Object.assign pattern where the rightmost object's fields overwrite\n * the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.\n * - Event handlers are merged such that they are called in sequence (the rightmost one being called first),\n * and allows the user to prevent the previous event handlers from being executed by calling the `preventDefault` method.\n * - It also merges the `className` and `style` props, whereby the classes are concatenated\n * and the rightmost styles overwrite the previous ones.\n *\n * @important **`ref` is not merged.**\n * @param props props to merge.\n * @returns the merged props.\n */\n\nconst mergeProps = <TProps extends Record<never, never>>(\n\t...propsObjectArray: Array<TProps | undefined>\n): UnionToIntersection<TProps> => {\n\tif (propsObjectArray.length === 0) {\n\t\treturn {} as never;\n\t}\n\n\tif (propsObjectArray.length === 1) {\n\t\treturn propsObjectArray[0] as never;\n\t}\n\n\tlet accumulatedProps: Record<string, unknown> = {};\n\n\tfor (const propsObject of propsObjectArray) {\n\t\tif (!propsObject) continue;\n\n\t\taccumulatedProps = mergeTwoProps(accumulatedProps, propsObject);\n\t}\n\n\treturn accumulatedProps as never;\n};\n\nexport { mergeProps };\n"],"mappings":";;;;;;AAEA,MAAM,oBAAoB,UAAkD;AAC3E,QAAO,SAAS,MAAM,IAAI,OAAO,OAAO,OAAO,cAAc;;AAG9D,MAAa,2BACZ,eACA,kBACI;CACJ,MAAM,sBAAsB,UAAmB;AAC9C,MAAI,iBAAiB,MAAM,EAAE;GAC5B,MAAMA,WAAS,gBAAgB,MAAM;AAErC,OAAI,CAAC,MAAM,iBACV,iBAAgB,MAAM;AAGvB,UAAOA;;EAGR,MAAM,SAAS,gBAAgB,MAAM;AACrC,kBAAgB,MAAM;AACtB,SAAO;;AAGR,QAAO;;AAGR,MAAa,wBAAwB,GAAG,sBAAsD;CAC7F,MAAM,sBAAsB,UAAmB;AAC9C,MAAI,kBAAkB,WAAW,EAAG;AAEpC,MAAI,kBAAkB,WAAW,EAChC,QAAO,kBAAkB,KAAK,MAAM;EAGrC,IAAIC;AAEJ,OAAK,MAAM,gBAAgB,mBAAmB;AAC7C,OAAI,CAAC,aAAc;AAEnB,yBAAsB,wBAAwB,qBAAqB,aAAa;;AAGjF,SAAO,sBAAsB,MAAM;;AAGpC,QAAO;;;;;;;;;;ACtCR,MAAa,UACZ,KACA,SACmC;AACnC,KAAI,CAAC,IAAK;AAEV,KAAI,WAAW,IAAI,CAClB,QAAO,IAAI,KAAK;AAIjB,KAAI,UAAU;;;;;AAMf,MAAa,eACZ,GAAG,SACoB;CACvB,MAAMC,qBAAwC,SAAS;EACtD,MAAM,iBAAiB,KAAK,KAAK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