@zayne-labs/toolkit-react 0.12.26 → 0.12.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { L as createCustomContext, f as useStore } from "./hooks-Bnl6vTAe.js";
1
+ import { L as createCustomContext, f as useStore } from "./hooks-CFOuTa7v.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-DngAVFv_.js.map
19
+ //# sourceMappingURL=createReactStoreContext-CRXOHc-r.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createReactStoreContext-DngAVFv_.js","names":[],"sources":["../../src/zustand/createReactStoreContext.ts"],"sourcesContent":["import type { StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createElement } from \"react\";\nimport { createCustomContext, useStore, type CustomContextOptions } from \"../hooks\";\n\nconst createReactStoreContext = <\n\tTState extends Record<string, unknown>,\n\tTStore extends StoreApi<TState> = StoreApi<TState>,\n>(\n\toptions?: CustomContextOptions<TStore, true>\n) => {\n\tconst [Provider, useCustomContext] = createCustomContext(options);\n\n\ttype ZustandStoreContextProviderProps = {\n\t\tchildren: React.ReactNode;\n\t\tstore: TStore;\n\t};\n\n\tfunction ZustandStoreContextProvider(props: ZustandStoreContextProviderProps) {\n\t\tconst { children, store } = props;\n\n\t\treturn createElement(Provider, { value: store }, children);\n\t}\n\n\tconst useZustandStoreContext = <TResult = TState>(selector?: SelectorFn<TState, TResult>): TResult => {\n\t\tconst zustandStore = useCustomContext();\n\n\t\treturn useStore(zustandStore, selector as never);\n\t};\n\n\treturn [ZustandStoreContextProvider, useZustandStoreContext] as [\n\t\tZustandStoreContextProvider: typeof ZustandStoreContextProvider,\n\t\tuseZustandStoreContext: typeof useZustandStoreContext,\n\t];\n};\n\nexport { createReactStoreContext };\n"],"mappings":";;;;AAKA,MAAM,2BAIL,YACI;CACJ,MAAM,CAAC,UAAU,oBAAoB,oBAAoB,QAAQ;CAOjE,SAAS,4BAA4B,OAAyC;EAC7E,MAAM,EAAE,UAAU,UAAU;AAE5B,SAAO,cAAc,UAAU,EAAE,OAAO,OAAO,EAAE,SAAS;;CAG3D,MAAM,0BAA4C,aAAoD;AAGrG,SAAO,SAFc,kBAAkB,EAET,SAAkB;;AAGjD,QAAO,CAAC,6BAA6B,uBAAuB"}
1
+ {"version":3,"file":"createReactStoreContext-CRXOHc-r.js","names":[],"sources":["../../src/zustand/createReactStoreContext.ts"],"sourcesContent":["import type { StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createElement } from \"react\";\nimport { createCustomContext, useStore, type CustomContextOptions } from \"../hooks\";\n\nconst createReactStoreContext = <\n\tTState extends Record<string, unknown>,\n\tTStore extends StoreApi<TState> = StoreApi<TState>,\n>(\n\toptions?: CustomContextOptions<TStore, true>\n) => {\n\tconst [Provider, useCustomContext] = createCustomContext(options);\n\n\ttype ZustandStoreContextProviderProps = {\n\t\tchildren: React.ReactNode;\n\t\tstore: TStore;\n\t};\n\n\tfunction ZustandStoreContextProvider(props: ZustandStoreContextProviderProps) {\n\t\tconst { children, store } = props;\n\n\t\treturn createElement(Provider, { value: store }, children);\n\t}\n\n\tconst useZustandStoreContext = <TResult = TState>(selector?: SelectorFn<TState, TResult>): TResult => {\n\t\tconst zustandStore = useCustomContext();\n\n\t\treturn useStore(zustandStore, selector as never);\n\t};\n\n\treturn [ZustandStoreContextProvider, useZustandStoreContext] as [\n\t\tZustandStoreContextProvider: typeof ZustandStoreContextProvider,\n\t\tuseZustandStoreContext: typeof useZustandStoreContext,\n\t];\n};\n\nexport { createReactStoreContext };\n"],"mappings":";;;;AAKA,MAAM,2BAIL,YACI;CACJ,MAAM,CAAC,UAAU,oBAAoB,oBAAoB,QAAQ;CAOjE,SAAS,4BAA4B,OAAyC;EAC7E,MAAM,EAAE,UAAU,UAAU;AAE5B,SAAO,cAAc,UAAU,EAAE,OAAO,OAAO,EAAE,SAAS;;CAG3D,MAAM,0BAA4C,aAAoD;AAGrG,SAAO,SAFc,kBAAkB,EAET,SAAkB;;AAGjD,QAAO,CAAC,6BAA6B,uBAAuB"}
@@ -1,3 +1,3 @@
1
- import { A as useUnmountEffect, B as getErrorMessage, C as useConstant, D as useCallbackRef, E as useClickOutside, F as useAfterMountEffect, I as ContextError, L as CustomContextOptions, M as useLifeCycle, N as useEffectOnce, O as useAnimationInterval, P as useAsyncEffect, R as UseCustomContext, S as useControllableState, T as useComposeRefs, _ as useDisclosure, a as useStore, b as useCopyToClipboard, c as useCompareSelector, d as useSearchParamsObject, f as useSearch, g as useIsHydrated, h as useLocationState, i as useThrottleByTimer, j as useMountEffect, k as useAnimateElementRefs, l as useCompareValue, m as createUseLocationState, n as useThrottleByFrame, o as createUseStorageState, p as useScrollObserver, r as useThrottleBySetTimeout, s as useStorageState, t as useToggle, u as useSearchParams, v as useDebouncedFn, w as useLazyRef, x as useControllableProp, y as useDebouncedState, z as createCustomContext } from "../index-Dn_4KqsP.js";
2
- import "../index-AlRgt-4I.js";
1
+ import { A as useUnmountEffect, B as getErrorMessage, C as useConstant, D as useCallbackRef, E as useClickOutside, F as useAfterMountEffect, I as ContextError, L as CustomContextOptions, M as useLifeCycle, N as useEffectOnce, O as useAnimationInterval, P as useAsyncEffect, R as UseCustomContext, S as useControllableState, T as useComposeRefs, _ as useDisclosure, a as useStore, b as useCopyToClipboard, c as useCompareSelector, d as useSearchParamsObject, f as useSearch, g as useIsHydrated, h as useLocationState, i as useThrottleByTimer, j as useMountEffect, k as useAnimateElementRefs, l as useCompareValue, m as createUseLocationState, n as useThrottleByFrame, o as createUseStorageState, p as useScrollObserver, r as useThrottleBySetTimeout, s as useStorageState, t as useToggle, u as useSearchParams, v as useDebouncedFn, w as useLazyRef, x as useControllableProp, y as useDebouncedState, z as createCustomContext } from "../index-C4ao8dq4.js";
2
+ import "../index-6fIqihyt.js";
3
3
  export { ContextError, CustomContextOptions, UseCustomContext, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useCompareSelector, useCompareValue, useComposeRefs, useConstant, useControllableProp, useControllableState, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
@@ -1,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 useSearch, d as useLocationState, f as useStore, g as useDisclosure, h as useIsHydrated, i as createUseStorageState, j as useLifeCycle, k as useUnmountEffect, l as useScrollObserver, m as useCompareValue, n as useThrottleBySetTimeout, o as useSearchParams, p as useCompareSelector, r as useThrottleByTimer, s as useSearchParamsObject, t as useThrottleByFrame, u as createUseLocationState, v as useDebouncedState, w as useLazyRef, x as useControllableProp, y as useCopyToClipboard } from "../hooks-Bnl6vTAe.js";
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 useSearch, d as useLocationState, f as useStore, g as useDisclosure, h as useIsHydrated, i as createUseStorageState, j as useLifeCycle, k as useUnmountEffect, l as useScrollObserver, m as useCompareValue, n as useThrottleBySetTimeout, o as useSearchParams, p as useCompareSelector, r as useThrottleByTimer, s as useSearchParamsObject, t as useThrottleByFrame, u as createUseLocationState, v as useDebouncedState, w as useLazyRef, x as useControllableProp, y as useCopyToClipboard } from "../hooks-CFOuTa7v.js";
2
2
 
3
3
  export { ContextError, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useCompareSelector, useCompareValue, useComposeRefs, useConstant, useControllableProp, useControllableState, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
@@ -595,33 +595,34 @@ const createUseStorageState = (baseOptions) => {
595
595
  Object.assign(useStorageState, externalStore);
596
596
  return useStorageState;
597
597
  };
598
- const useStorageState = (key, initialValue, options = {}) => {
598
+ const useStorageState = (key, defaultValue, options = {}) => {
599
599
  const { equalityFn, logger, parser, partialize, select, serializer, storageArea, syncStateAcrossTabs } = options;
600
- const savedEquality = useCallbackRef(equalityFn);
601
- const savedLogger = useCallbackRef(logger);
602
- const savedParser = useCallbackRef(parser);
603
- const savedPartialize = useCallbackRef(partialize);
604
- const savedSerializer = useCallbackRef(serializer);
600
+ const shallowComparedDefaultValue = useCompareValue(defaultValue);
601
+ const stableEqualityFn = useCallbackRef(equalityFn);
602
+ const stableLogger = useCallbackRef(logger);
603
+ const stableParser = useCallbackRef(parser);
604
+ const stablePartialize = useCallbackRef(partialize);
605
+ const stableSerializer = useCallbackRef(serializer);
605
606
  const externalStore = useMemo(() => {
606
607
  return createExternalStorageStore({
607
- equalityFn: savedEquality,
608
- initialValue,
608
+ defaultValue: shallowComparedDefaultValue,
609
+ equalityFn: stableEqualityFn,
609
610
  key,
610
- logger: savedLogger,
611
- parser: savedParser,
612
- partialize: savedPartialize,
613
- serializer: savedSerializer,
611
+ logger: stableLogger,
612
+ parser: stableParser,
613
+ partialize: stablePartialize,
614
+ serializer: stableSerializer,
614
615
  storageArea,
615
616
  syncStateAcrossTabs
616
617
  });
617
618
  }, [
618
- initialValue,
619
+ shallowComparedDefaultValue,
619
620
  key,
620
- savedEquality,
621
- savedLogger,
622
- savedParser,
623
- savedPartialize,
624
- savedSerializer,
621
+ stableEqualityFn,
622
+ stableLogger,
623
+ stableParser,
624
+ stablePartialize,
625
+ stableSerializer,
625
626
  storageArea,
626
627
  syncStateAcrossTabs
627
628
  ]);
@@ -649,4 +650,4 @@ const useThrottleByFrame = (callbackFn) => {
649
650
 
650
651
  //#endregion
651
652
  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, useSearch as c, useLocationState as d, useStore as f, useDisclosure as g, useIsHydrated as h, createUseStorageState as i, useLifeCycle as j, useUnmountEffect as k, useScrollObserver as l, useCompareValue as m, useThrottleBySetTimeout as n, useSearchParams as o, useCompareSelector as p, useThrottleByTimer as r, useSearchParamsObject as s, useThrottleByFrame as t, createUseLocationState as u, useDebouncedState as v, useLazyRef as w, useControllableProp as x, useCopyToClipboard as y };
652
- //# sourceMappingURL=hooks-Bnl6vTAe.js.map
653
+ //# sourceMappingURL=hooks-CFOuTa7v.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks-Bnl6vTAe.js","names":[],"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/useCompare.ts","../../src/hooks/useStore.ts","../../src/hooks/useLocationState.ts","../../src/hooks/useScrollObserver.ts","../../src/hooks/useSearch.ts","../../src/hooks/useSearchParams.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<TProp> = {\n\tdefaultProp?: TProp | (() => TProp);\n\tisControlled?: boolean;\n\tonChange?: (prop: TProp) => void;\n\tprop?: TProp;\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 stableOnPropChange = useCallbackRef(onChange);\n\n\tconst [unControlledState, setUncontrolledState] = useState(defaultProp as TProp);\n\n\tconst state = (isControlled ? prop : unControlledState) as TProp;\n\n\tconst setState: StateSetter<TProp> = useCallback(\n\t\t(newValue) => {\n\t\t\tconst nextValue = isFunction(newValue) ? newValue(state) : newValue;\n\n\t\t\tif (isControlled) {\n\t\t\t\tstableOnPropChange?.(nextValue);\n\t\t\t} else {\n\t\t\t\tsetUncontrolledState(nextValue);\n\t\t\t\tstableOnPropChange?.(nextValue);\n\t\t\t}\n\t\t},\n\t\t[state, isControlled, stableOnPropChange]\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 noopStore = {\n\tgetServerSnapshot: () => false,\n\tgetSnapshot: () => true,\n\t// eslint-disable-next-line unicorn/consistent-function-scoping -- Ignore\n\tsubscribe: () => () => {},\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 { deepCompare, shallowCompare, type CompareFnOptions } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useInsertionEffect, useRef } from \"react\";\n\ntype UseCompareSelectorOptions = {\n\tcompareFnOptions?: CompareFnOptions;\n\ttype?: \"deep\" | \"shallow\";\n};\n\nexport const useCompareSelector = <TState, TResult>(\n\tselector: SelectorFn<TState, TResult> | undefined,\n\toptions: UseCompareSelectorOptions = {}\n) => {\n\tconst { compareFnOptions, type = \"shallow\" } = options;\n\n\tconst prevStateRef = useRef<TResult>(undefined as never);\n\n\tconst compareFn = type === \"shallow\" ? shallowCompare : deepCompare;\n\n\tconst compareSelector = (state: TState): TResult => {\n\t\tconst nextState = selector?.(state);\n\n\t\tif (!nextState) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\tif (compareFn(prevStateRef.current, nextState, compareFnOptions)) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\treturn (prevStateRef.current = nextState);\n\t};\n\n\treturn compareSelector;\n};\n\nexport const useCompareValue = <TValue>(value: TValue, options: UseCompareSelectorOptions = {}) => {\n\tconst { compareFnOptions, type = \"shallow\" } = options;\n\n\tconst prevValueRef = useRef<TValue>(value);\n\n\tconst compareFn = type === \"shallow\" ? shallowCompare : deepCompare;\n\n\tuseInsertionEffect(() => {\n\t\tif (compareFn(prevValueRef.current, value, compareFnOptions)) 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 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 { useCompareValue } from \"./useCompare\";\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 { defaultValues, equalityFn } = options;\n\n\tconst stableEqualityFn = useCallbackRef(equalityFn);\n\tconst stableDefaultValues = useCompareValue(defaultValues, { compareFnOptions: { maxDepth: 2 } });\n\n\tconst locationStore = useMemo(\n\t\t() => createLocationStore({ defaultValues: stableDefaultValues, equalityFn: stableEqualityFn }),\n\t\t[stableEqualityFn, stableDefaultValues]\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<TSearchParams extends URLSearchParamsInit> = Omit<\n\tLocationStoreOptions,\n\t\"defaultValues\"\n> & {\n\taction?: \"push\" | \"replace\";\n\tdefaultValues?: TSearchParams;\n};\n\nexport const useSearchParams = <TSearchParams extends URLSearchParamsInit>(\n\toptions?: UseSearchParamsOptions<TSearchParams>\n) => {\n\tconst { action = \"push\", defaultValues, ...restOfOptions } = options ?? {};\n\n\tconst [searchParams, actions] = useLocationState((state) => state.search, {\n\t\t...restOfOptions,\n\t\tdefaultValues: { search: defaultValues },\n\t});\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 = <\n\tTSearchParams extends Extract<URLSearchParamsInit, Record<string, string | string[]>>,\n>(\n\toptions?: UseSearchParamsOptions<TSearchParams>\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 {\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,SAAO;;AAGR,QAAO,CAAC,SAAS,iBAAiB;;AAMnC,IAAa,eAAb,cAAkC,MAAM;CACvC,AAAS,OA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e,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
+ {"version":3,"file":"hooks-CFOuTa7v.js","names":[],"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/useCompare.ts","../../src/hooks/useStore.ts","../../src/hooks/useLocationState.ts","../../src/hooks/useScrollObserver.ts","../../src/hooks/useSearch.ts","../../src/hooks/useSearchParams.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<TProp> = {\n\tdefaultProp?: TProp | (() => TProp);\n\tisControlled?: boolean;\n\tonChange?: (prop: TProp) => void;\n\tprop?: TProp;\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 stableOnPropChange = useCallbackRef(onChange);\n\n\tconst [unControlledState, setUncontrolledState] = useState(defaultProp as TProp);\n\n\tconst state = (isControlled ? prop : unControlledState) as TProp;\n\n\tconst setState: StateSetter<TProp> = useCallback(\n\t\t(newValue) => {\n\t\t\tconst nextValue = isFunction(newValue) ? newValue(state) : newValue;\n\n\t\t\tif (isControlled) {\n\t\t\t\tstableOnPropChange?.(nextValue);\n\t\t\t} else {\n\t\t\t\tsetUncontrolledState(nextValue);\n\t\t\t\tstableOnPropChange?.(nextValue);\n\t\t\t}\n\t\t},\n\t\t[state, isControlled, stableOnPropChange]\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 noopStore = {\n\tgetServerSnapshot: () => false,\n\tgetSnapshot: () => true,\n\t// eslint-disable-next-line unicorn/consistent-function-scoping -- Ignore\n\tsubscribe: () => () => {},\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 { deepCompare, shallowCompare, type CompareFnOptions } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useInsertionEffect, useRef } from \"react\";\n\ntype UseCompareSelectorOptions = {\n\tcompareFnOptions?: CompareFnOptions;\n\ttype?: \"deep\" | \"shallow\";\n};\n\nexport const useCompareSelector = <TState, TResult>(\n\tselector: SelectorFn<TState, TResult> | undefined,\n\toptions: UseCompareSelectorOptions = {}\n) => {\n\tconst { compareFnOptions, type = \"shallow\" } = options;\n\n\tconst prevStateRef = useRef<TResult>(undefined as never);\n\n\tconst compareFn = type === \"shallow\" ? shallowCompare : deepCompare;\n\n\tconst compareSelector = (state: TState): TResult => {\n\t\tconst nextState = selector?.(state);\n\n\t\tif (!nextState) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\tif (compareFn(prevStateRef.current, nextState, compareFnOptions)) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\treturn (prevStateRef.current = nextState);\n\t};\n\n\treturn compareSelector;\n};\n\nexport const useCompareValue = <TValue>(value: TValue, options: UseCompareSelectorOptions = {}) => {\n\tconst { compareFnOptions, type = \"shallow\" } = options;\n\n\tconst prevValueRef = useRef<TValue>(value);\n\n\tconst compareFn = type === \"shallow\" ? shallowCompare : deepCompare;\n\n\tuseInsertionEffect(() => {\n\t\tif (compareFn(prevValueRef.current, value, compareFnOptions)) 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 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 LocationStoreApi,\n\ttype LocationStoreInfo,\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 { useCompareValue } from \"./useCompare\";\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 = LocationStoreInfo>(\n\t\t\tselector?: SelectorFn<LocationStoreInfo, TSlice>\n\t\t) => UseLocationResult<TSlice>);\n\n\tconst useLocationState = <TSlice = LocationStoreInfo>(\n\t\tselector?: SelectorFn<LocationStoreInfo, 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 = LocationStoreInfo>(\n\tselector?: SelectorFn<LocationStoreInfo, TSlice>,\n\toptions: LocationStoreOptions = {}\n): UseLocationResult<TSlice> => {\n\tconst { defaultValues, equalityFn } = options;\n\n\tconst stableEqualityFn = useCallbackRef(equalityFn);\n\tconst stableDefaultValues = useCompareValue(defaultValues, { compareFnOptions: { maxDepth: 2 } });\n\n\tconst locationStore = useMemo(\n\t\t() => createLocationStore({ defaultValues: stableDefaultValues, equalityFn: stableEqualityFn }),\n\t\t[stableEqualityFn, stableDefaultValues]\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<TSearchParams extends URLSearchParamsInit> = Omit<\n\tLocationStoreOptions,\n\t\"defaultValues\"\n> & {\n\taction?: \"push\" | \"replace\";\n\tdefaultValues?: TSearchParams;\n};\n\nexport const useSearchParams = <TSearchParams extends URLSearchParamsInit>(\n\toptions?: UseSearchParamsOptions<TSearchParams>\n) => {\n\tconst { action = \"push\", defaultValues, ...restOfOptions } = options ?? {};\n\n\tconst [searchParams, actions] = useLocationState((state) => state.search, {\n\t\t...restOfOptions,\n\t\tdefaultValues: { search: defaultValues },\n\t});\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 = <\n\tTSearchParams extends Extract<URLSearchParamsInit, Record<string, string | string[]>>,\n>(\n\toptions?: UseSearchParamsOptions<TSearchParams>\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 {\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 { useCompareValue } from \"./useCompare\";\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\tdefaultValue?: 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 shallowComparedDefaultValue = useCompareValue(defaultValue);\n\tconst stableEqualityFn = useCallbackRef(equalityFn);\n\tconst stableLogger = useCallbackRef(logger);\n\tconst stableParser = useCallbackRef(parser);\n\tconst stablePartialize = useCallbackRef(partialize);\n\tconst stableSerializer = useCallbackRef(serializer);\n\n\tconst externalStore = useMemo(() => {\n\t\treturn createExternalStorageStore({\n\t\t\tdefaultValue: shallowComparedDefaultValue,\n\t\t\tequalityFn: stableEqualityFn,\n\t\t\tkey,\n\t\t\tlogger: stableLogger,\n\t\t\tparser: stableParser,\n\t\t\tpartialize: stablePartialize,\n\t\t\tserializer: stableSerializer,\n\t\t\tstorageArea,\n\t\t\tsyncStateAcrossTabs,\n\t\t});\n\t}, [\n\t\tshallowComparedDefaultValue,\n\t\tkey,\n\t\tstableEqualityFn,\n\t\tstableLogger,\n\t\tstableParser,\n\t\tstablePartialize,\n\t\tstableSerializer,\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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AY;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;;;;;ACxEhD,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"}
@@ -33,12 +33,12 @@ declare const matchesSlotComponent: (child: React.ReactNode, SlotComponent: Func
33
33
  declare const matchesAnySlotComponent: (child: React.ReactNode, SlotComponents: FunctionalComponent[]) => boolean;
34
34
  type SlotOptions = {
35
35
  /**
36
- * @description The error message to throw when multiple slots are found for a given slot component
37
- */
36
+ * @description The error message to throw when multiple slots are found for a given slot component
37
+ */
38
38
  errorMessage?: string;
39
39
  /**
40
- * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component
41
- */
40
+ * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component
41
+ */
42
42
  throwOnMultipleSlotMatch?: boolean;
43
43
  };
44
44
  /**
@@ -49,16 +49,16 @@ type SlotOptions = {
49
49
  declare const getSingleSlot: (children: React.ReactNode, SlotComponent: FunctionalComponent, options?: SlotOptions) => react13.ReactNode;
50
50
  type MultipleSlotsOptions = {
51
51
  /**
52
- * @description The error message to throw when multiple slots are found for a given slot component
53
- * If a string is provided, the same message will be used for all slot components
54
- * If an array is provided, each string in the array will be used as the errorMessage for the corresponding slot component
55
- */
52
+ * @description The error message to throw when multiple slots are found for a given slot component
53
+ * If a string is provided, the same message will be used for all slot components
54
+ * If an array is provided, each string in the array will be used as the errorMessage for the corresponding slot component
55
+ */
56
56
  errorMessage?: string | string[];
57
57
  /**
58
- * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component
59
- * If a boolean is provided, the same value will be used for all slot components
60
- * If an array is provided, each boolean in the array will be used as the throwOnMultipleSlotMatch value for the corresponding slot component
61
- */
58
+ * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component
59
+ * If a boolean is provided, the same value will be used for all slot components
60
+ * If an array is provided, each boolean in the array will be used as the throwOnMultipleSlotMatch value for the corresponding slot component
61
+ */
62
62
  throwOnMultipleSlotMatch?: boolean | boolean[];
63
63
  };
64
64
  type GetMultipleSlotsResult<TSlotComponents extends FunctionalComponent[]> = {
@@ -135,8 +135,8 @@ declare const getSlotMap: <TSlotComponentProps extends GetSlotComponentProps>(ch
135
135
  type GetSlotComponentProps<TName extends string = string, TChildren extends CallbackFn<never, React.ReactNode> | React.ReactNode = CallbackFn<never, React.ReactNode> | React.ReactNode> = {
136
136
  children: TChildren;
137
137
  /**
138
- * Name of the slot where content should be rendered
139
- */
138
+ * Name of the slot where content should be rendered
139
+ */
140
140
  name: TName;
141
141
  };
142
142
  /**
@@ -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-AlRgt-4I.d.ts.map
228
+ //# sourceMappingURL=index-6fIqihyt.d.ts.map
@@ -1,8 +1,8 @@
1
- import { D as PossibleRef, f as StateSetter } from "./index-AlRgt-4I.js";
2
- import * as react1 from "react";
1
+ import { D as PossibleRef, f as StateSetter } from "./index-6fIqihyt.js";
2
+ import * as react0 from "react";
3
3
  import { RefCallback, useEffect } from "react";
4
4
  import * as _zayne_labs_toolkit_core2 from "@zayne-labs/toolkit-core";
5
- import { AllowedClipboardItems, AnimationIntervalOptions, CompareFnOptions, CopyToClipboardOptions, LocationInfo, LocationStoreApi, LocationStoreOptions, ScrollObserverOptions, StorageOptions, StorageStoreApi, StoreApi, URLSearchParamsInit } from "@zayne-labs/toolkit-core";
5
+ import { AllowedClipboardItems, AnimationIntervalOptions, CompareFnOptions, CopyToClipboardOptions, LocationStoreApi, LocationStoreInfo, 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
 
8
8
  //#region src/hooks/createCustomContext.d.ts
@@ -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: react1.Context<TContextValue>, useCustomContext: UseCustomContext<TContextValue, TStrict>];
19
+ declare const createCustomContext: <TContextValue = null, TStrict extends boolean = true>(options?: CustomContextOptions<TContextValue, TStrict>) => [Provider: react0.Context<TContextValue>, useCustomContext: UseCustomContext<TContextValue, TStrict>];
20
20
  declare class ContextError extends Error {
21
21
  name: string;
22
22
  }
@@ -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: react1.RefObject<TElement | null>;
91
+ ref: react0.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>>) => react1.RefCallback<TRef>;
95
+ declare const useComposeRefs: <TRef extends HTMLElement>(...refs: Array<PossibleRef<TRef>>) => react0.RefCallback<TRef>;
96
96
  //#endregion
97
97
  //#region src/hooks/useConstant.d.ts
98
98
  declare const useConstant: <TResult>(initFn: () => TResult) => TResult;
@@ -150,7 +150,7 @@ declare const useCopyToClipboard: (options?: CopyToClipboardOptions & {
150
150
  }) => {
151
151
  handleCopy: (valueToCopy: AllowedClipboardItems) => void;
152
152
  hasCopied: boolean;
153
- setValue: react1.Dispatch<react1.SetStateAction<AllowedClipboardItems>>;
153
+ setValue: react0.Dispatch<react0.SetStateAction<AllowedClipboardItems>>;
154
154
  value: AllowedClipboardItems;
155
155
  };
156
156
  //#endregion
@@ -164,13 +164,13 @@ declare const useDebouncedFn: <TParams>(callBackFn: CallbackFn<TParams>, delay:
164
164
  cancelMaxWait(): void;
165
165
  };
166
166
  declare const useDebouncedState: <TValue>(defaultValue: TValue, delay: number | undefined) => readonly [TValue, {
167
- (...params: react1.SetStateAction<TValue>[]): void;
168
- (params: react1.SetStateAction<TValue> | react1.SetStateAction<TValue>[], overrideOptions: {
167
+ (...params: react0.SetStateAction<TValue>[]): void;
168
+ (params: react0.SetStateAction<TValue> | react0.SetStateAction<TValue>[], overrideOptions: {
169
169
  $delay: number;
170
170
  }): void;
171
171
  cancel: () => void;
172
172
  cancelMaxWait(): void;
173
- }, react1.Dispatch<react1.SetStateAction<TValue>>];
173
+ }, react0.Dispatch<react0.SetStateAction<TValue>>];
174
174
  //#endregion
175
175
  //#region src/hooks/useDisclosure.d.ts
176
176
  type DisclosureOptions = {
@@ -213,14 +213,14 @@ declare const useIsHydrated: () => boolean;
213
213
  //#region src/hooks/useLocationState.d.ts
214
214
  type UseLocationResult<TSlice> = [state: TSlice, actions: LocationStoreApi];
215
215
  declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<_zayne_labs_toolkit_core2.StoreApi<_zayne_labs_toolkit_core2.URLInfoObject>, "resetState" | "setState"> & {
216
- push: (url: string | _zayne_labs_toolkit_core2.PartialURLInfo, options?: {
216
+ push: (newURL: string | _zayne_labs_toolkit_core2.PartialURLInfo, options?: {
217
217
  shouldNotifySync?: boolean;
218
218
  state?: _zayne_labs_toolkit_core2.PartialURLInfo["state"];
219
219
  }) => void;
220
220
  replace: LocationStoreApi["push"];
221
- triggerPopstateEvent: (nextLocationState?: LocationInfo["state"]) => void;
222
- } & (<TSlice = _zayne_labs_toolkit_core2.URLInfoObject>(selector?: SelectorFn<LocationInfo, TSlice>) => UseLocationResult<TSlice>);
223
- declare const useLocationState: <TSlice = LocationInfo>(selector?: SelectorFn<LocationInfo, TSlice>, options?: LocationStoreOptions) => UseLocationResult<TSlice>;
221
+ triggerPopstateEvent: (nextLocationState?: LocationStoreInfo["state"]) => void;
222
+ } & (<TSlice = _zayne_labs_toolkit_core2.URLInfoObject>(selector?: SelectorFn<LocationStoreInfo, TSlice>) => UseLocationResult<TSlice>);
223
+ declare const useLocationState: <TSlice = LocationStoreInfo>(selector?: SelectorFn<LocationStoreInfo, TSlice>, options?: LocationStoreOptions) => UseLocationResult<TSlice>;
224
224
  //#endregion
225
225
  //#region src/hooks/useScrollObserver.d.ts
226
226
  declare const useScrollObserver: <TElement extends HTMLElement>(options?: ScrollObserverOptions) => {
@@ -234,7 +234,7 @@ declare const useSearch: <TData>(initialData: TData[], delay?: number) => {
234
234
  data: TData[];
235
235
  isLoading: boolean;
236
236
  query: string;
237
- setQuery: react1.Dispatch<react1.SetStateAction<string>>;
237
+ setQuery: react0.Dispatch<react0.SetStateAction<string>>;
238
238
  };
239
239
  //#endregion
240
240
  //#region src/hooks/useSearchParams.d.ts
@@ -242,8 +242,8 @@ type UseSearchParamsOptions<TSearchParams extends URLSearchParamsInit> = Omit<Lo
242
242
  action?: "push" | "replace";
243
243
  defaultValues?: TSearchParams;
244
244
  };
245
- declare const useSearchParams: <TSearchParams extends URLSearchParamsInit>(options?: UseSearchParamsOptions<TSearchParams>) => [searchParams: URLSearchParams, setSearchParams: (newQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core2.LocationInfo["state"]) => void];
246
- declare const useSearchParamsObject: <TSearchParams extends Extract<URLSearchParamsInit, Record<string, string | string[]>>>(options?: UseSearchParamsOptions<TSearchParams>) => [searchParamsObject: TSearchParams, setSearchParamsObject: (newQueryParams: TSearchParams | ((prev: TSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core2.LocationInfo["state"]) => void];
245
+ declare const useSearchParams: <TSearchParams extends URLSearchParamsInit>(options?: UseSearchParamsOptions<TSearchParams>) => [searchParams: URLSearchParams, setSearchParams: (newQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core2.LocationStoreInfo["state"]) => void];
246
+ declare const useSearchParamsObject: <TSearchParams extends Extract<URLSearchParamsInit, Record<string, string | string[]>>>(options?: UseSearchParamsOptions<TSearchParams>) => [searchParamsObject: TSearchParams, setSearchParamsObject: (newQueryParams: TSearchParams | ((prev: TSearchParams) => TSearchParams)) => void, triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core2.LocationStoreInfo["state"]) => void];
247
247
  //#endregion
248
248
  //#region src/hooks/useCompare.d.ts
249
249
  type UseCompareSelectorOptions = {
@@ -259,11 +259,31 @@ type UseStorageResult<TState, TSlice = TState> = [state: TSlice, actions: Storag
259
259
  * @description Creates a custom hook that returns a storage state and actions to modify it. You can use this if you need shared options.
260
260
  * @note You must use this if you want to be able to prevent syncing state across tabs.
261
261
  */
262
- declare const createUseStorageState: <TState>(baseOptions: StorageOptions<TState>) => _zayne_labs_toolkit_core2.StoreApi<TState> & {
262
+ declare const createUseStorageState: <TState>(baseOptions: StorageOptions<TState>) => Omit<_zayne_labs_toolkit_core2.StoreApi<TState>, "setState"> & {
263
263
  removeState: () => void;
264
+ setState: {
265
+ (stateUpdate: Partial<TState> | ((prevState: TState) => Partial<TState>), options?: ({
266
+ onNotifySync?: ((previousState: TState) => void) | undefined;
267
+ onNotifyViaBatch?: ((previousStateSnapshot: TState) => void) | undefined;
268
+ shouldNotifySync?: boolean | undefined;
269
+ } & {
270
+ storageAction?: "remove-item" | "set-item";
271
+ } & {
272
+ shouldReplace?: false;
273
+ }) | undefined): void;
274
+ (stateUpdate: TState | ((prevState: TState) => TState), options?: ({
275
+ onNotifySync?: ((previousState: TState) => void) | undefined;
276
+ onNotifyViaBatch?: ((previousStateSnapshot: TState) => void) | undefined;
277
+ shouldNotifySync?: boolean | undefined;
278
+ } & {
279
+ storageAction?: "remove-item" | "set-item";
280
+ } & {
281
+ shouldReplace: true;
282
+ }) | undefined): void;
283
+ };
264
284
  } & (<TSlice = TState>(selector?: SelectorFn<TState, TSlice>) => UseStorageResult<TState, TSlice>);
265
285
  type UseStorageStateOptions<TValue> = Omit<StorageOptions<TValue>, "initialValue" | "key">;
266
- declare const useStorageState: <TValue, TSlice = TValue>(key: string, initialValue?: TValue, options?: UseStorageStateOptions<TValue> & {
286
+ declare const useStorageState: <TValue, TSlice = TValue>(key: string, defaultValue?: TValue, options?: UseStorageStateOptions<TValue> & {
267
287
  select?: SelectorFn<TValue, TSlice>;
268
288
  }) => UseStorageResult<TValue, TSlice>;
269
289
  //#endregion
@@ -286,4 +306,4 @@ type InitialState = boolean | (() => boolean);
286
306
  declare const useToggle: (initialValue?: InitialState) => [value: boolean, toggleValue: <TValue>(newValue?: TValue) => void];
287
307
  //#endregion
288
308
  export { useUnmountEffect as A, getErrorMessage as B, useConstant as C, useCallbackRef as D, useClickOutside as E, useAfterMountEffect as F, ContextError as I, CustomContextOptions as L, useLifeCycle as M, useEffectOnce as N, useAnimationInterval as O, useAsyncEffect as P, UseCustomContext as R, useControllableState as S, useComposeRefs as T, useDisclosure as _, useStore as a, useCopyToClipboard as b, useCompareSelector as c, useSearchParamsObject as d, useSearch as f, useIsHydrated as g, useLocationState as h, useThrottleByTimer as i, useMountEffect as j, useAnimateElementRefs as k, useCompareValue as l, createUseLocationState as m, useThrottleByFrame as n, createUseStorageState as o, useScrollObserver as p, useThrottleBySetTimeout as r, useStorageState as s, useToggle as t, useSearchParams as u, useDebouncedFn as v, useLazyRef as w, useControllableProp as x, useDebouncedState as y, createCustomContext as z };
289
- //# sourceMappingURL=index-Dn_4KqsP.d.ts.map
309
+ //# sourceMappingURL=index-C4ao8dq4.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { L as CustomContextOptions } from "./index-C4ao8dq4.js";
2
+ import * as react11 from "react";
3
+ import { StoreApi } from "@zayne-labs/toolkit-core";
4
+ import { SelectorFn } from "@zayne-labs/toolkit-type-helpers";
5
+
6
+ //#region src/zustand/createReactStoreContext.d.ts
7
+ declare const createReactStoreContext: <TState extends Record<string, unknown>, TStore extends StoreApi<TState> = StoreApi<TState>>(options?: CustomContextOptions<TStore, true>) => [ZustandStoreContextProvider: (props: {
8
+ children: React.ReactNode;
9
+ store: TStore;
10
+ }) => react11.FunctionComponentElement<react11.ProviderProps<TStore>>, useZustandStoreContext: <TResult = TState>(selector?: SelectorFn<TState, TResult>) => TResult];
11
+ //#endregion
12
+ //#region src/zustand/types.d.ts
13
+ type Get<T, K, F> = K extends keyof T ? T[K] : F;
14
+ type ExtractState<TStoreApi> = TStoreApi extends {
15
+ getState: () => infer TState;
16
+ } ? TState : never;
17
+ type ReadonlyStoreApi<TState> = Pick<StoreApi<TState>, "getInitialState" | "getState" | "subscribe">;
18
+ type UseBoundStore<TStoreApi extends ReadonlyStoreApi<unknown>> = TStoreApi & {
19
+ (): ExtractState<TStoreApi>;
20
+ <U>(selector: (state: ExtractState<TStoreApi>) => U): U;
21
+ };
22
+ //#endregion
23
+ export { UseBoundStore as n, createReactStoreContext as r, Get as t };
24
+ //# sourceMappingURL=types-44QWzWYw.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-AlRgt-4I.js";
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 };
@@ -1,6 +1,6 @@
1
- import "../../index-Dn_4KqsP.js";
2
- import "../../index-AlRgt-4I.js";
3
- import { a as createReactStoreContext, i as UseBoundStore, t as Get } from "../../types-DYzvHb2z.js";
1
+ import "../../index-C4ao8dq4.js";
2
+ import "../../index-6fIqihyt.js";
3
+ import { n as UseBoundStore, r as createReactStoreContext, t as Get } from "../../types-44QWzWYw.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 { f as useStore } from "../../hooks-Bnl6vTAe.js";
2
- import { t as createReactStoreContext } from "../../createReactStoreContext-DngAVFv_.js";
1
+ import { f as useStore } from "../../hooks-CFOuTa7v.js";
2
+ import { t as createReactStoreContext } from "../../createReactStoreContext-CRXOHc-r.js";
3
3
  import { createStore } from "@zayne-labs/toolkit-core";
4
4
 
5
5
  //#region src/zustand/compatible/createReactStore.ts
@@ -1,17 +1,14 @@
1
- import "../index-Dn_4KqsP.js";
2
- import "../index-AlRgt-4I.js";
3
- import { a as createReactStoreContext, i as UseBoundStore, n as Mutate, r as StoreMutatorIdentifier, t as Get } from "../types-DYzvHb2z.js";
4
- import { StoreApi } from "@zayne-labs/toolkit-core";
1
+ import "../index-C4ao8dq4.js";
2
+ import "../index-6fIqihyt.js";
3
+ import { n as UseBoundStore, r as createReactStoreContext } from "../types-44QWzWYw.js";
4
+ import { StateInitializer, StoreApi } from "@zayne-labs/toolkit-core";
5
5
 
6
6
  //#region src/zustand/createReactStore.d.ts
7
- type StateCreator<T, Mis extends Array<[StoreMutatorIdentifier, unknown]> = [], Mos extends Array<[StoreMutatorIdentifier, unknown]> = [], U = T> = {
8
- $$storeMutators?: Mos;
9
- } & ((setState: Get<Mutate<StoreApi<T>, Mis>, "setState", never>, getState: Get<Mutate<StoreApi<T>, Mis>, "getState", never>, store: Mutate<StoreApi<T>, Mis>) => U);
10
7
  type CreateReactStore = {
11
- <T, Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(initializer: StateCreator<T, [], Mos>): UseBoundStore<Mutate<StoreApi<T>, Mos>>;
12
- <T>(): <Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(initializer: StateCreator<T, [], Mos>) => UseBoundStore<Mutate<StoreApi<T>, Mos>>;
8
+ <TState>(initializer: StateInitializer<TState>): UseBoundStore<StoreApi<TState>>;
9
+ <TState>(): (initializer: StateInitializer<TState>) => UseBoundStore<StoreApi<TState>>;
13
10
  };
14
11
  declare const createReactStore: CreateReactStore;
15
12
  //#endregion
16
- export { StateCreator, createReactStore, createReactStoreContext };
13
+ export { createReactStore, createReactStoreContext };
17
14
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
- import { f as useStore } from "../hooks-Bnl6vTAe.js";
2
- import { t as createReactStoreContext } from "../createReactStoreContext-DngAVFv_.js";
1
+ import { f as useStore } from "../hooks-CFOuTa7v.js";
2
+ import { t as createReactStoreContext } from "../createReactStoreContext-CRXOHc-r.js";
3
3
  import { createStore } from "@zayne-labs/toolkit-core";
4
4
 
5
5
  //#region src/zustand/createReactStore.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/zustand/createReactStore.ts"],"sourcesContent":["import { createStore, type StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useStore } from \"../hooks\";\nimport type { Get, Mutate, StoreMutatorIdentifier, UseBoundStore } from \"./types\";\n\nexport type StateCreator<\n\tT,\n\tMis extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\tMos extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\tU = T,\n> = { $$storeMutators?: Mos } & ((\n\tsetState: Get<Mutate<StoreApi<T>, Mis>, \"setState\", never>,\n\tgetState: Get<Mutate<StoreApi<T>, Mis>, \"getState\", never>,\n\tstore: Mutate<StoreApi<T>, Mis>\n) => U);\n\ntype CreateReactStore = {\n\t<T, Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t): UseBoundStore<Mutate<StoreApi<T>, Mos>>;\n\t<T>(): <Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t) => UseBoundStore<Mutate<StoreApi<T>, Mos>>;\n};\n\nconst createReactStoreImpl = <TState>(createState: StateCreator<TState>) => {\n\tconst store = createStore(createState);\n\n\tconst useBoundStore = (selector?: SelectorFn<TState, unknown>) => useStore(store, selector);\n\n\tObject.assign(useBoundStore, store);\n\n\treturn useBoundStore;\n};\n\nexport const createReactStore = (<TState>(stateInitializer: StateCreator<TState> | undefined) =>\n\tstateInitializer ? createReactStoreImpl(stateInitializer) : createReactStoreImpl) as CreateReactStore;\n"],"mappings":";;;;;AAyBA,MAAM,wBAAgC,gBAAsC;CAC3E,MAAM,QAAQ,YAAY,YAAY;CAEtC,MAAM,iBAAiB,aAA2C,SAAS,OAAO,SAAS;AAE3F,QAAO,OAAO,eAAe,MAAM;AAEnC,QAAO;;AAGR,MAAa,qBAA6B,qBACzC,mBAAmB,qBAAqB,iBAAiB,GAAG"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/zustand/createReactStore.ts"],"sourcesContent":["import { createStore, type StateInitializer, type StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useStore } from \"../hooks\";\nimport type { UseBoundStore } from \"./types\";\n\ntype CreateReactStore = {\n\t<TState>(initializer: StateInitializer<TState>): UseBoundStore<StoreApi<TState>>;\n\t<TState>(): (initializer: StateInitializer<TState>) => UseBoundStore<StoreApi<TState>>;\n};\n\nconst createReactStoreImpl = <TState>(createState: StateInitializer<TState>) => {\n\tconst store = createStore(createState);\n\n\tconst useBoundStore = (selector?: SelectorFn<TState, unknown>) => useStore(store, selector);\n\n\tObject.assign(useBoundStore, store);\n\n\treturn useBoundStore;\n};\n\nexport const createReactStore = (<TState>(stateInitializer: StateInitializer<TState> | undefined) =>\n\tstateInitializer ? createReactStoreImpl(stateInitializer) : createReactStoreImpl) as CreateReactStore;\n"],"mappings":";;;;;AAUA,MAAM,wBAAgC,gBAA0C;CAC/E,MAAM,QAAQ,YAAY,YAAY;CAEtC,MAAM,iBAAiB,aAA2C,SAAS,OAAO,SAAS;AAE3F,QAAO,OAAO,eAAe,MAAM;AAEnC,QAAO;;AAGR,MAAa,qBAA6B,qBACzC,mBAAmB,qBAAqB,iBAAiB,GAAG"}
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.26",
4
+ "version": "0.12.28",
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.26",
53
- "@zayne-labs/toolkit-type-helpers": "0.12.26"
52
+ "@zayne-labs/toolkit-core": "0.12.28",
53
+ "@zayne-labs/toolkit-type-helpers": "0.12.28"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@arethetypeswrong/cli": "^0.18.2",
@@ -59,15 +59,15 @@
59
59
  "@size-limit/preset-small-lib": "^12.0.0",
60
60
  "@total-typescript/ts-reset": "^0.6.1",
61
61
  "@types/node": "^25.0.9",
62
- "@types/react": "^19.2.8",
63
- "@zayne-labs/tsconfig": "0.11.18",
62
+ "@types/react": "^19.2.9",
63
+ "@zayne-labs/tsconfig": "0.11.21",
64
64
  "concurrently": "^9.2.1",
65
65
  "cross-env": "^10.1.0",
66
66
  "publint": "^0.3.16",
67
67
  "react": "^19.2.3",
68
68
  "size-limit": "^12.0.0",
69
69
  "tailwind-merge": "3.4.0",
70
- "tsdown": "0.20.0-beta.3",
70
+ "tsdown": "0.20.0-beta.4",
71
71
  "typescript": "5.9.3",
72
72
  "zustand": "^5.0.10"
73
73
  },
@@ -79,7 +79,7 @@
79
79
  "size-limit": [
80
80
  {
81
81
  "path": "./src/hooks/index.ts",
82
- "limit": "6 kb"
82
+ "limit": "6.5 kb"
83
83
  },
84
84
  {
85
85
  "path": "./src/utils/index.ts",
@@ -87,7 +87,11 @@
87
87
  },
88
88
  {
89
89
  "path": "./src/zustand/index.ts",
90
- "limit": "2 kb"
90
+ "limit": "2.5 kb"
91
+ },
92
+ {
93
+ "path": "./src/zustand/compatible/index.ts",
94
+ "limit": "2.5 kb"
91
95
  }
92
96
  ],
93
97
  "scripts": {
@@ -1,27 +0,0 @@
1
- import { L as CustomContextOptions } from "./index-Dn_4KqsP.js";
2
- import * as react0 from "react";
3
- import { StoreApi } from "@zayne-labs/toolkit-core";
4
- import { SelectorFn } from "@zayne-labs/toolkit-type-helpers";
5
-
6
- //#region src/zustand/createReactStoreContext.d.ts
7
- declare const createReactStoreContext: <TState extends Record<string, unknown>, TStore extends StoreApi<TState> = StoreApi<TState>>(options?: CustomContextOptions<TStore, true>) => [ZustandStoreContextProvider: (props: {
8
- children: React.ReactNode;
9
- store: TStore;
10
- }) => react0.FunctionComponentElement<react0.ProviderProps<TStore>>, useZustandStoreContext: <TResult = TState>(selector?: SelectorFn<TState, TResult>) => TResult];
11
- //#endregion
12
- //#region src/zustand/types.d.ts
13
- type Get<T, K, F> = K extends keyof T ? T[K] : F;
14
- type ExtractState<S> = S extends {
15
- getState: () => infer T;
16
- } ? T : never;
17
- type Mutate<S, Ms> = number extends Ms["length" & keyof Ms] ? S : Ms extends [] ? S : Ms extends [[infer Mi, infer Ma], ...infer Mrs] ? Mutate<StoreMutators<S, Ma>[Mi & StoreMutatorIdentifier], Mrs> : never;
18
- type UseBoundStore<S extends ReadonlyStoreApi<unknown>> = S & {
19
- (): ExtractState<S>;
20
- <U>(selector: (state: ExtractState<S>) => U): U;
21
- };
22
- type ReadonlyStoreApi<T> = Pick<StoreApi<T>, "getInitialState" | "getState" | "subscribe">;
23
- interface StoreMutators<S, A> {}
24
- type StoreMutatorIdentifier = keyof StoreMutators<unknown, unknown>;
25
- //#endregion
26
- export { createReactStoreContext as a, UseBoundStore as i, Mutate as n, StoreMutatorIdentifier as r, Get as t };
27
- //# sourceMappingURL=types-DYzvHb2z.d.ts.map