@zayne-labs/toolkit-react 0.10.26 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import { ContextError, CustomContextOptions, UseCustomContext, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect } from "../index-C_W9xsBU.js";
2
- export { ContextError, CustomContextOptions, UseCustomContext, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
1
+ import { ContextError, CustomContextOptions, UseCustomContext, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect } from "../index-DUGJrMJn.js";
2
+ export { ContextError, CustomContextOptions, UseCustomContext, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
@@ -1,3 +1,3 @@
1
- import { ContextError, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect } from "../hooks-Bnw2bN-M.js";
1
+ import { ContextError, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect } from "../hooks-BHS1sAKT.js";
2
2
 
3
- export { ContextError, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
3
+ export { ContextError, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
@@ -34,8 +34,7 @@ const useCallbackRef = (callbackFn) => {
34
34
  useLayoutEffect(() => {
35
35
  callbackRef.current = callbackFn;
36
36
  }, [callbackFn]);
37
- const savedCallback = useCallback((...params) => callbackRef.current?.(...params), []);
38
- return savedCallback;
37
+ return useCallback((...params) => callbackRef.current?.(...params), []);
39
38
  };
40
39
 
41
40
  //#endregion
@@ -274,7 +273,7 @@ const useDisclosure = (options = {}) => {
274
273
  }
275
274
  isOpen ? onClose() : onOpen();
276
275
  });
277
- const api = useMemo(() => ({
276
+ return useMemo(() => ({
278
277
  isOpen,
279
278
  onClose,
280
279
  onOpen,
@@ -285,7 +284,6 @@ const useDisclosure = (options = {}) => {
285
284
  onOpen,
286
285
  onToggle
287
286
  ]);
288
- return api;
289
287
  };
290
288
 
291
289
  //#endregion
@@ -316,8 +314,7 @@ const emptySubscribe = () => noop;
316
314
  * ```
317
315
  */
318
316
  const useIsHydrated = () => {
319
- const isHydrated = useSyncExternalStore(emptySubscribe, () => true, () => false);
320
- return isHydrated;
317
+ return useSyncExternalStore(emptySubscribe, () => true, () => false);
321
318
  };
322
319
 
323
320
  //#endregion
@@ -333,8 +330,7 @@ const noopStore = {
333
330
  * until after hydration.
334
331
  */
335
332
  const useIsServer = () => {
336
- const isServer = useSyncExternalStore(noopStore.subscribe, noopStore.getSnapshot, noopStore.getServerSnapshot);
337
- return isServer;
333
+ return useSyncExternalStore(noopStore.subscribe, noopStore.getSnapshot, noopStore.getServerSnapshot);
338
334
  };
339
335
 
340
336
  //#endregion
@@ -351,8 +347,7 @@ const useStore = (store, selector = identity) => {
351
347
  const createUseLocationState = (options) => {
352
348
  const locationStore = createLocationStore(options);
353
349
  const useLocationState$1 = (selector) => {
354
- const stateSlice = useStore(locationStore, selector);
355
- return [stateSlice, locationStore];
350
+ return [useStore(locationStore, selector), locationStore];
356
351
  };
357
352
  Object.assign(useLocationState$1, locationStore);
358
353
  return useLocationState$1;
@@ -361,114 +356,7 @@ const useLocationState = (selector, options = {}) => {
361
356
  const { equalityFn } = options;
362
357
  const savedEqualityFn = useCallbackRef(equalityFn);
363
358
  const locationStore = useMemo(() => createLocationStore({ equalityFn: savedEqualityFn }), [savedEqualityFn]);
364
- const stateSlice = useStore(locationStore, selector);
365
- return [stateSlice, locationStore];
366
- };
367
-
368
- //#endregion
369
- //#region src/hooks/usePresence/useAnimationPresence.ts
370
- const useAnimationPresence = (options = {}) => {
371
- const { defaultValue = true, duration, onExitComplete } = options;
372
- const [isShown, setIsShown] = useState(defaultValue);
373
- const [isMounted, setDebouncedIsMounted, setRegularIsMounted] = useDebouncedState(defaultValue, duration);
374
- const elementRef = useRef(null);
375
- const stableOnExitComplete = useCallbackRef(onExitComplete);
376
- useEffect(() => {
377
- !isMounted && stableOnExitComplete();
378
- }, [isMounted]);
379
- const handleIsMountedWithoutRef = (value) => {
380
- if (value) {
381
- setRegularIsMounted(true);
382
- return;
383
- }
384
- setDebouncedIsMounted(false);
385
- };
386
- const handleIsMountedWithRef = (value) => {
387
- if (value) {
388
- setRegularIsMounted(true);
389
- return;
390
- }
391
- on("animationend", elementRef.current, () => {
392
- setDebouncedIsMounted.cancel();
393
- setRegularIsMounted(false);
394
- });
395
- };
396
- const toggleVisibility = useCallbackRef((newValue) => {
397
- const handleSetIsMounted = !duration ? handleIsMountedWithRef : handleIsMountedWithoutRef;
398
- if (typeof newValue === "boolean") {
399
- setIsShown(newValue);
400
- handleSetIsMounted(newValue);
401
- return;
402
- }
403
- setIsShown(!isShown);
404
- handleSetIsMounted(!isShown);
405
- });
406
- return {
407
- isPresent: isMounted,
408
- isVisible: isShown,
409
- toggleVisibility,
410
- ...duration === void 0 && { elementRef }
411
- };
412
- };
413
-
414
- //#endregion
415
- //#region src/hooks/usePresence/useTransitionPresence.ts
416
- const useTransitionPresence = (options = {}) => {
417
- const { defaultValue = true, duration, onExitComplete } = options;
418
- const [isShown, setIsShown] = useState(defaultValue);
419
- const [isMounted, setDebouncedIsMounted, setRegularIsMounted] = useDebouncedState(defaultValue, duration);
420
- const elementRef = useRef(null);
421
- const stableOnExitComplete = useCallbackRef(onExitComplete);
422
- const handleIsMountedWithoutRef = (value) => {
423
- if (value) {
424
- setDebouncedIsMounted(value, { $delay: 0 });
425
- return;
426
- }
427
- setDebouncedIsMounted(false);
428
- };
429
- const handleIsMountedWithRef = (value) => {
430
- if (value) {
431
- setDebouncedIsMounted(value, { $delay: 0 });
432
- return;
433
- }
434
- on("transitionend", elementRef.current, () => {
435
- setDebouncedIsMounted.cancel();
436
- setRegularIsMounted(false);
437
- });
438
- };
439
- const toggleVisibility = useCallbackRef((newValue) => {
440
- const handleSetIsMounted = !duration ? handleIsMountedWithRef : handleIsMountedWithoutRef;
441
- if (typeof newValue === "boolean") {
442
- setIsShown(newValue);
443
- handleSetIsMounted(newValue);
444
- return;
445
- }
446
- setIsShown(!isShown);
447
- handleSetIsMounted(!isShown);
448
- });
449
- useEffect(() => {
450
- !isMounted && stableOnExitComplete();
451
- }, [isMounted]);
452
- return {
453
- isPresent: isMounted || isShown,
454
- isVisible: isMounted && isShown,
455
- toggleVisibility,
456
- ...duration === void 0 && { elementRef }
457
- };
458
- };
459
-
460
- //#endregion
461
- //#region src/hooks/usePresence/usePresence.ts
462
- /**
463
- * usePresence hook provides a way to animate an element, before removing it from the DOM.
464
- * @param defaultValue - The default value for the presence state. Defaults to `true`.
465
- * @param options - The options for the usePresence hook.
466
- * @returns A object containing the boolean that should be used to conditionally render the element (isPresent), another boolean used to toggle the animation classes, and a function to toggle the state.
467
- */
468
- const usePresence = (options = {}) => {
469
- const { type = "transition",...restOfOptions } = options;
470
- const useSpecificPresence = type === "transition" ? useTransitionPresence : useAnimationPresence;
471
- return useSpecificPresence(restOfOptions);
359
+ return [useStore(locationStore, selector), locationStore];
472
360
  };
473
361
 
474
362
  //#endregion
@@ -592,8 +480,7 @@ const useShallowComparedValue = (value) => {
592
480
  const createUseStorageState = (baseOptions) => {
593
481
  const externalStore = createExternalStorageStore(baseOptions);
594
482
  const useStorageState$1 = (selector) => {
595
- const stateInStorage = useStore(externalStore, selector);
596
- return [stateInStorage, externalStore];
483
+ return [useStore(externalStore, selector), externalStore];
597
484
  };
598
485
  Object.assign(useStorageState$1, externalStore);
599
486
  return useStorageState$1;
@@ -628,8 +515,7 @@ const useStorageState = (key, initialValue, options) => {
628
515
  storageArea,
629
516
  syncStateAcrossTabs
630
517
  ]);
631
- const stateInStorage = useStore(externalStore, select);
632
- return [stateInStorage, externalStore];
518
+ return [useStore(externalStore, select), externalStore];
633
519
  };
634
520
 
635
521
  //#endregion
@@ -642,8 +528,7 @@ const useThrottleBySetTimeout = (callbackFn, delay) => {
642
528
  };
643
529
  const useThrottleByTimer = (callbackFn, delay) => {
644
530
  const latestCallback = useCallbackRef(callbackFn);
645
- const throttledCallback = useMemo(() => throttleByTime(latestCallback, delay), [delay, latestCallback]);
646
- return throttledCallback;
531
+ return useMemo(() => throttleByTime(latestCallback, delay), [delay, latestCallback]);
647
532
  };
648
533
  const useThrottleByFrame = (callbackFn) => {
649
534
  const latestCallback = useCallbackRef(callbackFn);
@@ -653,5 +538,5 @@ const useThrottleByFrame = (callbackFn) => {
653
538
  };
654
539
 
655
540
  //#endregion
656
- export { ContextError, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
657
- //# sourceMappingURL=hooks-Bnw2bN-M.js.map
541
+ export { ContextError, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
542
+ //# sourceMappingURL=hooks-BHS1sAKT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks-BHS1sAKT.js","names":["useCustomContext: UseCustomContext<TContextValue, TStrict>","useAfterMountEffect: typeof useEffect","useLocationState","observedElementRef: RefCallback<TElement>","useStorageState"],"sources":["../../src/hooks/createCustomContext.ts","../../src/hooks/useCallbackRef.ts","../../src/hooks/effects/useAfterMountEffect.ts","../../src/hooks/effects/useAsyncEffect.ts","../../src/hooks/effects/useEffectOnce.ts","../../src/hooks/effects/useLifeCycle.ts","../../src/hooks/effects/useMountEffect.ts","../../src/hooks/effects/useUnMountEffect.ts","../../src/hooks/useAnimateElementRefs.ts","../../src/hooks/useAnimationInterval.ts","../../src/hooks/useClickOutside.ts","../../src/hooks/useConstant.ts","../../src/hooks/useCopyToClipboard.ts","../../src/hooks/useDebounce.ts","../../src/hooks/useToggle.ts","../../src/hooks/useDisclosure.ts","../../src/hooks/useIsHydrated.ts","../../src/hooks/useIsServer.ts","../../src/hooks/useStore.ts","../../src/hooks/useLocationState.ts","../../src/hooks/useScrollObserver.ts","../../src/hooks/useSearch.ts","../../src/hooks/useSearchParams.ts","../../src/hooks/useShallowCompare.ts","../../src/hooks/useStorageState.ts","../../src/hooks/useThrottle.ts"],"sourcesContent":["import { createContext, use } from \"react\";\n\nexport type CustomContextOptions<TContextValue, TStrict extends boolean> = {\n\tdefaultValue?: TContextValue | null;\n\terrorMessage?: string;\n\textension?: (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\textension,\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 = extension?.(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, useLayoutEffect, useRef } from \"react\";\n\n/**\n * Returns a stable function that always points to the latest version of the callback function.\n * @param callbackFn - The function to reference\n * @returns a stable function that always points to the latest version of the callback function\n */\n\nconst useCallbackRef = <TCallback = AnyFunction>(callbackFn: TCallback | undefined) => {\n\tconst callbackRef = useRef(callbackFn);\n\n\tuseLayoutEffect(() => {\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\treturn savedCallback as TCallback;\n};\n\nexport { useCallbackRef };\n","import { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nconst useAfterMountEffect: typeof useEffect = (callBackFn, deps) => {\n\tconst isFirstMount = useRef(true);\n\tconst stableCallback = useCallbackRef(callBackFn);\n\n\tuseEffect(() => {\n\t\tif (isFirstMount.current) {\n\t\t\tisFirstMount.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\tstableCallback();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableCallback is stable\n\t}, deps);\n};\nexport { useAfterMountEffect };\n","import { useEffect, useState } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nexport function useAsyncEffect(\n\teffect: () => Promise<ReturnType<React.EffectCallback>>,\n\tdeps?: React.DependencyList\n) {\n\tconst stableEffectCallback = useCallbackRef(effect);\n\tconst [destroy, setDestroy] = useState<ReturnType<React.EffectCallback>>();\n\n\tuseEffect(() => {\n\t\tconst e = stableEffectCallback();\n\n\t\tasync function execute() {\n\t\t\tsetDestroy(await e);\n\t\t}\n\n\t\tvoid execute();\n\n\t\treturn () => void destroy?.();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableEffectCallback is stable\n\t}, deps);\n}\n","import { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nconst useEffectOnce = (callBackFn: React.EffectCallback) => {\n\tconst stableCallback = useCallbackRef(callBackFn);\n\n\tconst effectGuard = useRef(false);\n\n\t// == savedCallback is always stable so no worries about re-execution of this effect\n\tuseEffect(() => {\n\t\tif (effectGuard.current) return;\n\n\t\teffectGuard.current = true;\n\n\t\treturn stableCallback();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableCallback is stable\n\t}, []);\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\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableOnMount and stableOnUnmount are stable\n\t}, []);\n};\n\nexport { useLifeCycle };\n","import { useLifeCycle } from \"./useLifeCycle\";\n\nconst useMountEffect = (callBackFn: () => void) => {\n\tuseLifeCycle({ onMount: callBackFn });\n};\n\nexport { useMountEffect };\n","import { type Destructor, useLifeCycle } from \"./useLifeCycle\";\n\nconst useUnmountEffect = (cleanUpFn: Destructor) => useLifeCycle({ onUnmount: cleanUpFn });\n\nexport { useUnmountEffect };\n","import { on } from \"@zayne-labs/toolkit-core\";\nimport { type NonEmptyArray, isArray } 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\treturn { animatedElements: elementsRef.current, handleElementsAnimation };\n};\n\nexport { useAnimateElementRefs };\n","import { type AnimationIntervalOptions, setAnimationInterval } from \"@zayne-labs/toolkit-core\";\nimport type { Prettify } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useEffect, useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype AnimationOptions = Prettify<\n\tAnimationIntervalOptions & {\n\t\tintervalDuration: number | null;\n\t\tonAnimation: () => void;\n\t}\n>;\n\nconst useAnimationInterval = (options: AnimationOptions) => {\n\tconst { intervalDuration, onAnimation, once } = options;\n\n\tconst latestCallback = useCallbackRef(onAnimation);\n\n\tconst { start, stop } = useMemo(\n\t\t() => setAnimationInterval(latestCallback, intervalDuration, { once }),\n\t\t[intervalDuration, latestCallback, once]\n\t);\n\n\tuseEffect(() => {\n\t\tif (intervalDuration === null) return;\n\n\t\tstart();\n\n\t\treturn stop;\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- start and stop are stable\n\t}, [intervalDuration]);\n\n\treturn { start, stop };\n};\n\nexport { useAnimationInterval };\n","import { onClickOutside, toArray } from \"@zayne-labs/toolkit-core\";\nimport { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype UseClickOutsideOptions<TElement extends HTMLElement> = {\n\tenabled?: boolean;\n\tonClick: (event: MouseEvent | TouchEvent) => void;\n\tref?: Array<React.RefObject<TElement>> | React.RefObject<TElement>;\n};\n\nconst useClickOutside = <TElement extends HTMLElement>(options: UseClickOutsideOptions<TElement>) => {\n\tconst innerRef = useRef<TElement>(null);\n\n\tconst { enabled = true, onClick, ref: refOrRefArray = innerRef } = options;\n\n\tconst savedOnClick = useCallbackRef(onClick);\n\n\tuseEffect(() => {\n\t\tif (!enabled) return;\n\n\t\tconst elementArray = toArray(refOrRefArray).map((ref) => ref.current);\n\n\t\tconst cleanup = onClickOutside(elementArray, savedOnClick);\n\n\t\treturn () => cleanup();\n\t}, [enabled, refOrRefArray, savedOnClick]);\n\n\treturn {\n\t\tref: innerRef,\n\t};\n};\n\nexport { useClickOutside };\n","import { useRef } from \"react\";\n\nexport const useConstant = <TResult>(initCallbackFn: () => 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 = initCallbackFn();\n\t}\n\n\treturn resultRef.current;\n};\n\nexport const useLazyRef = <TResult>(initCallbackFn: () => TResult): React.RefObject<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 = initCallbackFn();\n\t}\n\n\treturn resultRef as React.RefObject<TResult>;\n};\n","import { copyToClipboard } from \"@zayne-labs/toolkit-core\";\nimport { useState } from \"react\";\n\nconst useCopyToClipboard = () => {\n\tconst [state, setState] = useState(\"\");\n\n\tconst handleCopy = (value: string) => {\n\t\tsetState(value);\n\t\tvoid copyToClipboard(value);\n\t};\n\n\treturn { copiedValue: state, handleCopy };\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 { useCallback, useState } from \"react\";\n\ntype InitialState = boolean | (() => boolean);\n\nconst useToggle = (initialValue: InitialState = false) => {\n\tconst [value, setValue] = useState(initialValue);\n\n\tconst toggle = 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, toggle] as const;\n};\n\nexport { useToggle };\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 { useSyncExternalStore } from \"react\";\n\nconst noop = () => {};\n\nconst emptySubscribe = () => noop;\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 */\nexport const useIsHydrated = () => {\n\tconst isHydrated = useSyncExternalStore(\n\t\temptySubscribe,\n\t\t() => true,\n\t\t() => false\n\t);\n\n\treturn isHydrated;\n};\n","import { useSyncExternalStore } from \"react\";\n\nconst noopStore = {\n\tgetServerSnapshot: () => true,\n\tgetSnapshot: () => false,\n\t// eslint-disable-next-line unicorn/consistent-function-scoping -- It's fine\n\tsubscribe: () => () => {},\n};\n\n/**\n * @description Returns whether the component is currently being server side rendered or\n * hydrated on the client. Can be used to delay browser-specific rendering\n * until after hydration.\n */\nconst useIsServer = () => {\n\tconst isServer = useSyncExternalStore(\n\t\tnoopStore.subscribe,\n\t\tnoopStore.getSnapshot,\n\t\tnoopStore.getServerSnapshot\n\t);\n\n\treturn isServer;\n};\n\nexport { useIsServer };\n","import type { StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useDebugValue, useSyncExternalStore } from \"react\";\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 slice = useSyncExternalStore(\n\t\tstore.subscribe,\n\t\tuseCallback(() => selector(store.getState()), [store, selector]),\n\t\tuseCallback(() => selector(store.getInitialState()), [store, selector])\n\t);\n\n\tuseDebugValue(slice);\n\n\treturn slice;\n};\n\nexport { useStore };\n","import {\n\tcreateLocationStore,\n\ttype LocationInfo,\n\ttype LocationStoreApi,\n\ttype LocationStoreOptions,\n} from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useStore } from \"./useStore\";\n\ntype UseLocationResult<TSlice> = [state: TSlice, actions: LocationStoreApi];\n\nexport const createUseLocationState = (options?: LocationStoreOptions) => {\n\tconst locationStore = createLocationStore(options);\n\n\ttype UseBoundLocationState = LocationStoreApi\n\t\t& (<TSlice = LocationInfo>(\n\t\t\tselector?: SelectorFn<LocationInfo, TSlice>\n\t\t) => UseLocationResult<TSlice>);\n\n\tconst useLocationState = <TSlice = LocationInfo>(\n\t\tselector?: SelectorFn<LocationInfo, TSlice>\n\t): UseLocationResult<TSlice> => {\n\t\tconst stateSlice = useStore(locationStore as never, selector);\n\n\t\treturn [stateSlice, locationStore];\n\t};\n\n\tObject.assign(useLocationState, locationStore);\n\n\treturn useLocationState as UseBoundLocationState;\n};\n\nexport const useLocationState = <TSlice = LocationInfo>(\n\tselector?: SelectorFn<LocationInfo, TSlice>,\n\toptions: LocationStoreOptions = {}\n): UseLocationResult<TSlice> => {\n\tconst { equalityFn } = options;\n\n\tconst savedEqualityFn = useCallbackRef(equalityFn);\n\n\tconst locationStore = useMemo(\n\t\t() => createLocationStore({ equalityFn: savedEqualityFn }),\n\t\t[savedEqualityFn]\n\t);\n\n\tconst stateSlice = useStore(locationStore as never, selector);\n\n\treturn [stateSlice, locationStore];\n};\n","import { createScrollObserver, type ScrollObserverOptions } from \"@zayne-labs/toolkit-core\";\nimport { type RefCallback, useMemo, useState } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nconst useScrollObserver = <TElement extends HTMLElement>(options: ScrollObserverOptions = {}) => {\n\tconst { onIntersection, root, rootMargin = \"10px 0px 0px 0px\", threshold } = options;\n\n\tconst [isScrolled, setIsScrolled] = useState(false);\n\n\tconst savedOnIntersection = useCallbackRef(onIntersection);\n\n\tconst { handleObservation } = useMemo(() => {\n\t\treturn createScrollObserver({\n\t\t\tonIntersection: (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\tsavedOnIntersection(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, savedOnIntersection, threshold]);\n\n\tconst observedElementRef: RefCallback<TElement> = useCallbackRef((element) => {\n\t\tconst cleanupFn = handleObservation(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 { 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\ttype LocationStoreOptions,\n\ttype URLSearchParamsInit,\n\tcreateSearchParams,\n} from \"@zayne-labs/toolkit-core\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useLocationState } from \"./useLocationState\";\n\ntype UseSearchParamsOptions = LocationStoreOptions & {\n\taction?: \"push\" | \"replace\";\n};\n\nexport const useSearchParams = <TSearchParams extends URLSearchParamsInit>(\n\toptions?: UseSearchParamsOptions\n) => {\n\tconst { action = \"push\", ...restOfOptions } = options ?? {};\n\n\tconst [searchParams, actions] = useLocationState((state) => state.search, restOfOptions);\n\n\tconst setSearchParams = (\n\t\tnewQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)\n\t) => {\n\t\tconst params = isFunction(newQueryParams) ? newQueryParams(searchParams) : newQueryParams;\n\n\t\tconst nextSearchParams = createSearchParams(params);\n\n\t\tactions[action]({ search: nextSearchParams });\n\t};\n\n\tsetSearchParams.triggerPopstateEvent = actions.triggerPopstateEvent;\n\n\treturn [searchParams, setSearchParams] as const;\n};\n\nexport const useSearchParamsObject = <TSearchParams extends Record<string, string>>(\n\toptions?: UseSearchParamsOptions\n) => {\n\tconst [searchParams, setSearchParams] = 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\tsetSearchParamsObject.triggerPopstateEvent = setSearchParams.triggerPopstateEvent;\n\n\treturn [searchParamsObject, setSearchParamsObject] as const;\n};\n","import { shallowCompare } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useRef } from \"react\";\n\nexport const useShallowComparedSelector = <TState, TResult>(selector: SelectorFn<TState, TResult>) => {\n\tconst prevStateRef = useRef<TResult>(undefined as never);\n\n\tconst shallowSelector = (state: TState) => {\n\t\tconst nextState = selector(state);\n\n\t\tif (shallowCompare(prevStateRef.current, nextState)) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\treturn (prevStateRef.current = nextState);\n\t};\n\n\treturn shallowSelector;\n};\n\nexport const useShallowComparedValue = <TValue>(value: TValue) => {\n\tconst prevValueRef = useRef<TValue>(value);\n\n\tif (shallowCompare(prevValueRef.current, value)) {\n\t\treturn prevValueRef.current;\n\t}\n\n\treturn (prevValueRef.current = value);\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,WACA,WAAW,qBACX,eAAe,0BACf,OAAO,aAAa,SAAS,WAAW,GAAG,aAAa,MAAM,GAAG,GAAG,GAAG,kBACvE,SAAS,SACN;CAEJ,MAAM,UAAU,cAA6B,aAA8B;AAE3E,SAAQ,cAAc;CAEtB,MAAMA,yBAAmE;EACxE,MAAM,eAAe,IAAI,QAAQ;EAEjC,MAAM,uBAAuB,YAAY,aAAa,IAAI;AAE1D,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,OAAO;;AAGjB,MAAa,mBAAmB,MAAc,aAAqB;AAClE,QAAO,GAAG,KAAK,2EAA2E,SAAS;;;;;;;;;;AC/CpG,MAAM,kBAA2C,eAAsC;CACtF,MAAM,cAAc,OAAO,WAAW;AAEtC,uBAAsB;AAErB,cAAY,UAAU;IACpB,CAAC,WAAW,CAAC;AAQhB,QANsB,aAEpB,GAAG,WAAuB,YAAY,UAA0B,GAAG,OAAO,EAC3E,EAAE,CACF;;;;;AClBF,MAAMC,uBAAyC,YAAY,SAAS;CACnE,MAAM,eAAe,OAAO,KAAK;CACjC,MAAM,iBAAiB,eAAe,WAAW;AAEjD,iBAAgB;AACf,MAAI,aAAa,SAAS;AACzB,gBAAa,UAAU;AACvB;;AAGD,kBAAgB;IAEd,KAAK;;;;;ACZT,SAAgB,eACf,QACA,MACC;CACD,MAAM,uBAAuB,eAAe,OAAO;CACnD,MAAM,CAAC,SAAS,cAAc,UAA4C;AAE1E,iBAAgB;EACf,MAAM,IAAI,sBAAsB;EAEhC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,cAAc,eAAe,gBAAgB,MAAM,EAAE,CAAC,OAAO,eAAe,CAAC;;AAKxG,MAAa,sBAA+B,eAAoC;CAC/E,MAAM,iBAAiB,eAAe,WAAW;CAEjD,MAAM,oBAAoB,kBAAkB,gBAAgB,eAAe,CAAC;AAE5E,wBAAuB,kBAAkB,iBAAiB,CAAC;AAE3D,QAAO"}
@@ -1,4 +1,4 @@
1
- import * as react0 from "react";
1
+ import * as react1 from "react";
2
2
  import { RefCallback, useEffect } from "react";
3
3
  import * as _zayne_labs_toolkit_core0 from "@zayne-labs/toolkit-core";
4
4
  import { AnimationIntervalOptions, LocationInfo, LocationStoreApi, LocationStoreOptions, ScrollObserverOptions, StorageOptions, StorageStoreApi, StoreApi, URLSearchParamsInit } from "@zayne-labs/toolkit-core";
@@ -15,7 +15,7 @@ type CustomContextOptions<TContextValue, TStrict extends boolean> = {
15
15
  strict?: TStrict;
16
16
  };
17
17
  type UseCustomContext<TContextValue, TStrict extends boolean> = () => TStrict extends true ? TContextValue : TContextValue | null;
18
- declare const createCustomContext: <TContextValue = null, TStrict extends boolean = true>(options?: CustomContextOptions<TContextValue, TStrict>) => [Provider: react0.Context<TContextValue>, useCustomContext: UseCustomContext<TContextValue, TStrict>];
18
+ declare const createCustomContext: <TContextValue = null, TStrict extends boolean = true>(options?: CustomContextOptions<TContextValue, TStrict>) => [Provider: react1.Context<TContextValue>, useCustomContext: UseCustomContext<TContextValue, TStrict>];
19
19
  declare class ContextError extends Error {
20
20
  name: string;
21
21
  }
@@ -87,7 +87,7 @@ type UseClickOutsideOptions<TElement extends HTMLElement> = {
87
87
  ref?: Array<React.RefObject<TElement>> | React.RefObject<TElement>;
88
88
  };
89
89
  declare const useClickOutside: <TElement extends HTMLElement>(options: UseClickOutsideOptions<TElement>) => {
90
- ref: react0.RefObject<TElement | null>;
90
+ ref: react1.RefObject<TElement | null>;
91
91
  };
92
92
  //#endregion
93
93
  //#region src/hooks/useConstant.d.ts
@@ -110,13 +110,13 @@ declare const useDebouncedFn: <TParams>(callBackFn: CallbackFn<TParams>, delay:
110
110
  cancelMaxWait(): void;
111
111
  };
112
112
  declare const useDebouncedState: <TValue>(defaultValue: TValue, delay: number | undefined) => readonly [TValue, {
113
- (...params: react0.SetStateAction<TValue>[]): void;
114
- (params: react0.SetStateAction<TValue> | react0.SetStateAction<TValue>[], overrideOptions: {
113
+ (...params: react1.SetStateAction<TValue>[]): void;
114
+ (params: react1.SetStateAction<TValue> | react1.SetStateAction<TValue>[], overrideOptions: {
115
115
  $delay: number;
116
116
  }): void;
117
117
  cancel: () => void;
118
118
  cancelMaxWait(): void;
119
- }, react0.Dispatch<react0.SetStateAction<TValue>>];
119
+ }, react1.Dispatch<react1.SetStateAction<TValue>>];
120
120
  //#endregion
121
121
  //#region src/hooks/useDisclosure.d.ts
122
122
  type DisclosureOptions = {
@@ -166,7 +166,7 @@ declare const useIsServer: () => boolean;
166
166
  //#endregion
167
167
  //#region src/hooks/useLocationState.d.ts
168
168
  type UseLocationResult<TSlice> = [state: TSlice, actions: LocationStoreApi];
169
- declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<_zayne_labs_toolkit_core0.StoreApi<_zayne_labs_toolkit_core0.URLInfoObject>, "resetState" | "setState"> & {
169
+ declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<_zayne_labs_toolkit_core0.StoreApi<_zayne_labs_toolkit_core0.URLInfoObject>, "setState" | "resetState"> & {
170
170
  push: (url: string | _zayne_labs_toolkit_core0.PartialURLInfo, options?: {
171
171
  state?: _zayne_labs_toolkit_core0.PartialURLInfo["state"];
172
172
  }) => void;
@@ -175,47 +175,6 @@ declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<_
175
175
  } & (<TSlice = _zayne_labs_toolkit_core0.URLInfoObject>(selector?: SelectorFn<LocationInfo, TSlice>) => UseLocationResult<TSlice>);
176
176
  declare const useLocationState: <TSlice = LocationInfo>(selector?: SelectorFn<LocationInfo, TSlice>, options?: LocationStoreOptions) => UseLocationResult<TSlice>;
177
177
  //#endregion
178
- //#region src/hooks/useToggle.d.ts
179
- type InitialState = boolean | (() => boolean);
180
- declare const useToggle: (initialValue?: InitialState) => readonly [boolean, <TValue>(newValue?: TValue) => void];
181
- //#endregion
182
- //#region src/hooks/usePresence/types.d.ts
183
- type UsePresenceOptions<TDuration extends number | undefined> = {
184
- defaultValue?: boolean;
185
- /**
186
- * @description The duration of the animation or transition
187
- */
188
- duration?: TDuration;
189
- /**
190
- * @description A callback function that will be called when the animation or transition ends
191
- */
192
- onExitComplete?: () => void;
193
- };
194
- type UsePresenceResult<TElement, TDuration> = Prettify<(TDuration extends undefined ? {
195
- elementRef: React.RefObject<TElement>;
196
- } : unknown) & {
197
- isPresent: boolean;
198
- isVisible: boolean;
199
- toggleVisibility: ReturnType<typeof useToggle>[1];
200
- }>;
201
- type TypeOption = {
202
- /**
203
- * @description The type of animation, whether animation or transition
204
- * @default "transition"
205
- */
206
- type?: "animation" | "transition";
207
- };
208
- type UsePresence = <TElement extends HTMLElement, TDuration extends number | undefined = undefined>(options?: Prettify<TypeOption & UsePresenceOptions<TDuration>>) => UsePresenceResult<TElement, TDuration>;
209
- //#endregion
210
- //#region src/hooks/usePresence/usePresence.d.ts
211
- /**
212
- * usePresence hook provides a way to animate an element, before removing it from the DOM.
213
- * @param defaultValue - The default value for the presence state. Defaults to `true`.
214
- * @param options - The options for the usePresence hook.
215
- * @returns A object containing the boolean that should be used to conditionally render the element (isPresent), another boolean used to toggle the animation classes, and a function to toggle the state.
216
- */
217
- declare const usePresence: UsePresence;
218
- //#endregion
219
178
  //#region src/hooks/useScrollObserver.d.ts
220
179
  declare const useScrollObserver: <TElement extends HTMLElement>(options?: ScrollObserverOptions) => {
221
180
  isScrolled: boolean;
@@ -227,7 +186,7 @@ declare const useSearch: <TData>(initialData: TData[], delay?: number) => {
227
186
  data: TData[];
228
187
  isLoading: boolean;
229
188
  query: string;
230
- setQuery: react0.Dispatch<react0.SetStateAction<string>>;
189
+ setQuery: react1.Dispatch<react1.SetStateAction<string>>;
231
190
  };
232
191
  //#endregion
233
192
  //#region src/hooks/useSearchParams.d.ts
@@ -275,5 +234,9 @@ declare const useThrottleByFrame: <TParams>(callbackFn: CallbackFn<TParams>) =>
275
234
  cancelAnimation(): void;
276
235
  };
277
236
  //#endregion
278
- export { ContextError, CustomContextOptions, UseCustomContext, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
279
- //# sourceMappingURL=index-C_W9xsBU.d.ts.map
237
+ //#region src/hooks/useToggle.d.ts
238
+ type InitialState = boolean | (() => boolean);
239
+ declare const useToggle: (initialValue?: InitialState) => readonly [boolean, <TValue>(newValue?: TValue) => void];
240
+ //#endregion
241
+ export { ContextError, CustomContextOptions, UseCustomContext, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useIsServer, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowComparedSelector, useShallowComparedValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
242
+ //# sourceMappingURL=index-DUGJrMJn.d.ts.map
@@ -1,5 +1,6 @@
1
+ import * as react10 from "react";
1
2
  import { RefCallback } from "react";
2
- import { AnyFunction, AnyObject, Prettify, UnionDiscriminator } from "@zayne-labs/toolkit-type-helpers";
3
+ import { AnyFunction, AnyObject, CallbackFn, EmptyObject, Prettify, UnionDiscriminator, UnionToIntersection, UnknownObject } from "@zayne-labs/toolkit-type-helpers";
3
4
 
4
5
  //#region src/utils/composeEventHandlers.d.ts
5
6
  declare const composeTwoEventHandlers: (formerHandler: AnyFunction | undefined, latterHandler: AnyFunction | undefined) => (event: unknown) => unknown;
@@ -17,10 +18,146 @@ declare const setRef: <TRef extends HTMLElement>(ref: PossibleRef<TRef>, node: T
17
18
  * @description A utility to combine refs. Accepts callback refs and RefObject(s)
18
19
  */
19
20
  declare const composeRefs: <TRef extends HTMLElement>(...refs: Array<PossibleRef<TRef>>) => RefCallback<TRef>;
20
- declare const useComposeRefs: <TRef extends HTMLElement>(...refs: Array<PossibleRef<TRef>>) => () => RefCallback<TRef>;
21
+ //#endregion
22
+ //#region src/utils/getSlot/getSlot.d.ts
23
+ type FunctionalComponent<TProps extends UnknownObject = never> = React.FunctionComponent<TProps>;
24
+ /**
25
+ * @description Checks if a react child (within the children array) matches the provided SlotComponent using multiple matching strategies:
26
+ * 1. Matches by slot symbol property
27
+ * 2. Matches by component name
28
+ */
29
+ declare const matchesSlotComponent: (child: React.ReactNode, SlotComponent: FunctionalComponent) => boolean;
30
+ /**
31
+ * @description Checks if a react child (within the children array) matches any of the provided SlotComponents.
32
+ */
33
+ declare const matchesAnySlotComponent: (child: React.ReactNode, SlotComponents: FunctionalComponent[]) => boolean;
34
+ type SlotOptions = {
35
+ /**
36
+ * @description The error message to throw when multiple slots are found for a given slot component
37
+ */
38
+ errorMessage?: string;
39
+ /**
40
+ * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component
41
+ */
42
+ throwOnMultipleSlotMatch?: boolean;
43
+ };
44
+ /**
45
+ * @description Retrieves a single slot element from a collection of React children that matches the provided SlotComponent component.
46
+ *
47
+ * @throws { AssertionError } when throwOnMultipleSlotMatch is true and multiple slots are found
48
+ */
49
+ declare const getSingleSlot: (children: React.ReactNode, SlotComponent: FunctionalComponent, options?: SlotOptions) => react10.ReactNode;
50
+ type MultipleSlotsOptions = {
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
+ */
56
+ errorMessage?: string | string[];
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
+ */
62
+ throwOnMultipleSlotMatch?: boolean | boolean[];
63
+ };
64
+ type GetMultipleSlotsResult<TSlotComponents extends FunctionalComponent[]> = {
65
+ regularChildren: React.ReactNode[];
66
+ slots: { [Key in keyof TSlotComponents]: ReturnType<TSlotComponents[Key]> };
67
+ };
68
+ /**
69
+ * @description The same as getSingleSlot, but for multiple slot components
70
+ */
71
+ declare const getMultipleSlots: <const TSlotComponents extends FunctionalComponent[]>(children: React.ReactNode, SlotComponents: TSlotComponents, options?: MultipleSlotsOptions) => Prettify<GetMultipleSlotsResult<TSlotComponents>>;
72
+ /**
73
+ * @description Returns all children that are not slot elements (i.e., don't match any of the provided slot components)
74
+ */
75
+ declare const getRegularChildren: (children: React.ReactNode, SlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]) => react10.ReactNode[];
76
+ //#endregion
77
+ //#region src/utils/getSlotMap/getSlotMap.d.ts
78
+ type GetSlotName<TSlotComponentProps extends GetSlotComponentProps> = string extends TSlotComponentProps["name"] ? never : "default" extends TSlotComponentProps["name"] ? never : TSlotComponentProps["name"];
79
+ type GetSpecificSlotsType<TSlotComponentProps extends GetSlotComponentProps> = { [TName in keyof TSlotComponentProps as GetSlotName<TSlotComponentProps>]: Extract<TSlotComponentProps["children"], React.ReactNode> };
80
+ /**
81
+ * Maps slot names to their corresponding children types
82
+ */
83
+ type GetSlotMapResult<TSlotComponentProps extends GetSlotComponentProps> = UnionToIntersection<GetSpecificSlotsType<TSlotComponentProps>> & {
84
+ default: React.ReactNode[];
85
+ };
86
+ /**
87
+ * Symbol used to identify SlotComponent instances
88
+ */
89
+ declare const slotComponentSymbol: unique symbol;
90
+ /**
91
+ * @description Creates a map of named slots from React children. Returns an object mapping slot names to their children,
92
+ * with a default slot for unmatched children.
93
+ *
94
+ * @example
95
+ * ```tsx
96
+ * import { type GetSlotComponentProps, SlotComponent } from "@zayne-labs/toolkit-react/utils"
97
+ *
98
+ * type SlotProps = GetSlotComponentProps<"header" | "footer">;
99
+ *
100
+ * function Parent({ children }: { children: React.ReactNode }) {
101
+ * const slots = getSlotMap<SlotProps>(children);
102
+ *
103
+ * return (
104
+ * <div>
105
+ * <header>{slots.header}</header>
106
+ * <main>{slots.default}</main>
107
+ * <footer>{slots.footer}</footer>
108
+ * </div>
109
+ * );
110
+ * }
111
+ * ```
112
+ *
113
+ * Usage:
114
+ * ```tsx
115
+ * <Parent>
116
+ * <SlotComponent name="header">Header Content</SlotComponent>
117
+ * <div>Random stuff</div>
118
+ * <SlotComponent name="footer">Footer Content</SlotComponent>
119
+ * </Parent>
120
+ * ```
121
+ */
122
+ declare const getSlotMap: <TSlotComponentProps extends GetSlotComponentProps>(children: React.ReactNode) => Prettify<GetSlotMapResult<TSlotComponentProps>>;
123
+ /**
124
+ * @description Produce props for the SlotComponent
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * // Pattern One (slot or slots have same children type, which is just React.ReactNode by default)
129
+ * type SlotProps = GetSlotComponentProps<"header" | "content" | "footer">;
130
+ *
131
+ * // Pattern Two (some slots can have different children type)
132
+ * type SlotProps = GetSlotComponentProps<"header", React.ReactNode> | GetSlotComponentProps<"header", (renderProp: RenderProp) => React.ReactNode>;
133
+ * ```
134
+ */
135
+ type GetSlotComponentProps<TName extends string = string, TChildren extends CallbackFn<never, React.ReactNode> | React.ReactNode = CallbackFn<never, React.ReactNode> | React.ReactNode> = {
136
+ children: TChildren;
137
+ /**
138
+ * Name of the slot where content should be rendered
139
+ */
140
+ name: TName;
141
+ };
142
+ /**
143
+ * @description Creates a slot component
144
+ */
145
+ declare const createSlotComponent: <TSlotComponentProps extends GetSlotComponentProps>() => {
146
+ (props: TSlotComponentProps): React.ReactNode;
147
+ slotSymbol: typeof slotComponentSymbol;
148
+ };
149
+ type SlotWithNameAndSymbol<TSlotComponentProps extends GetSlotComponentProps = GetSlotComponentProps, TOtherProps extends UnknownObject = EmptyObject> = {
150
+ (props: Pick<TSlotComponentProps, "children"> & TOtherProps): React.ReactNode;
151
+ readonly slotName?: TSlotComponentProps["name"];
152
+ readonly slotSymbol?: symbol;
153
+ };
154
+ /**
155
+ * @description Adds a slot symbol and name to a slot component passed in
156
+ */
157
+ declare const withSlotNameAndSymbol: <TSlotComponentProps extends GetSlotComponentProps, TOtherProps extends UnknownObject = EmptyObject>(name: TSlotComponentProps["name"], SlotComponent?: SlotWithNameAndSymbol<TSlotComponentProps, TOtherProps>) => SlotWithNameAndSymbol<TSlotComponentProps, TOtherProps>;
21
158
  //#endregion
22
159
  //#region src/utils/mergeProps.d.ts
23
- type UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : "") extends ((param: infer TParam) => void) ? TParam : "";
160
+ type UnionToIntersection$1<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : "") extends ((param: infer TParam) => void) ? TParam : "";
24
161
  /**
25
162
  * Merges multiple sets of React props.
26
163
  *
@@ -35,7 +172,7 @@ type UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) =>
35
172
  * @param props props to merge.
36
173
  * @returns the merged props.
37
174
  */
38
- declare const mergeProps: <TProps extends Record<never, never>>(...propsObjectArray: Array<TProps | undefined>) => UnionToIntersection<TProps>;
175
+ declare const mergeProps: <TProps extends Record<never, never>>(...propsObjectArray: Array<TProps | undefined>) => UnionToIntersection$1<TProps>;
39
176
  //#endregion
40
177
  //#region src/utils/mergeTwoProps.d.ts
41
178
  declare const mergeTwoProps: <TProps extends Record<never, never>>(formerProps: TProps | undefined, latterProps: TProps | undefined) => TProps;
@@ -84,5 +221,5 @@ type InferRemainingProps<TElement extends React.ElementType, TProps> = Omit<Infe
84
221
  type MergedGivenPropsWithAs<TElement extends React.ElementType, TProps> = Prettify<Omit<AsProp<TElement>, keyof TProps> & TProps>;
85
222
  type PolymorphicProps<TElement extends React.ElementType, TProps extends AnyObject = NonNullable<unknown>> = MergedGivenPropsWithAs<TElement, TProps> & InferRemainingProps<TElement, TProps>;
86
223
  //#endregion
87
- export { AsProp, CssWithCustomProperties, DefaultRenderErrorMessages, DefaultRenderItemErrorMessages, DiscriminatedRenderItemProps, DiscriminatedRenderProps, ForwardedRefType, InferProps, PolymorphicProps, StateSetter, composeEventHandlers, composeRefs, composeTwoEventHandlers, mergeProps, mergeTwoProps, setRef, useComposeRefs };
224
+ export { AsProp, CssWithCustomProperties, DefaultRenderErrorMessages, DefaultRenderItemErrorMessages, DiscriminatedRenderItemProps, DiscriminatedRenderProps, ForwardedRefType, FunctionalComponent, GetSlotComponentProps, GetSlotMapResult, InferProps, PolymorphicProps, PossibleRef, StateSetter, composeEventHandlers, composeRefs, composeTwoEventHandlers, createSlotComponent, getMultipleSlots, getRegularChildren, getSingleSlot, getSlotMap, matchesAnySlotComponent, matchesSlotComponent, mergeProps, mergeTwoProps, setRef, slotComponentSymbol, withSlotNameAndSymbol };
88
225
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,6 @@
1
- import { useCallback } from "react";
2
- import { isFunction, isObject } from "@zayne-labs/toolkit-type-helpers";
1
+ import { Fragment, isValidElement } from "react";
2
+ import { toArray } from "@zayne-labs/toolkit-core";
3
+ import { AssertionError, isArray, isFunction, isObject } from "@zayne-labs/toolkit-type-helpers";
3
4
 
4
5
  //#region src/utils/composeEventHandlers.ts
5
6
  const isSyntheticEvent = (event) => {
@@ -55,9 +56,158 @@ const composeRefs = (...refs) => {
55
56
  };
56
57
  return mergedRefCallBack;
57
58
  };
58
- const useComposeRefs = (...refs) => {
59
- const mergedRef = useCallback(() => composeRefs(...refs), refs);
60
- return mergedRef;
59
+
60
+ //#endregion
61
+ //#region src/utils/getSlot/getSlot.ts
62
+ const isWithSlotSymbol = (component) => {
63
+ return "slotSymbol" in component && Boolean(component.slotSymbol);
64
+ };
65
+ const isWithSlotReference = (component) => {
66
+ return "slotReference" in component && Boolean(component.slotReference);
67
+ };
68
+ /**
69
+ * @description Checks if a react child (within the children array) matches the provided SlotComponent using multiple matching strategies:
70
+ * 1. Matches by slot symbol property
71
+ * 2. Matches by component name
72
+ */
73
+ const matchesSlotComponent = (child, SlotComponent) => {
74
+ if (!isValidElement(child) || !isFunction(child.type)) return false;
75
+ const resolvedChildType = isWithSlotReference(child.type) ? child.type.slotReference : child.type;
76
+ if (isWithSlotSymbol(resolvedChildType) && isWithSlotSymbol(SlotComponent) && resolvedChildType.slotSymbol === SlotComponent.slotSymbol) return true;
77
+ if (child.type.name === SlotComponent.name) return true;
78
+ return false;
79
+ };
80
+ /**
81
+ * @description Checks if a react child (within the children array) matches any of the provided SlotComponents.
82
+ */
83
+ const matchesAnySlotComponent = (child, SlotComponents) => {
84
+ return SlotComponents.some((SlotComponent) => matchesSlotComponent(child, SlotComponent));
85
+ };
86
+ /**
87
+ * @description Counts how many times a given slot component appears in an array of children
88
+ * @internal
89
+ */
90
+ const calculateSlotOccurrences = (childrenArray, SlotComponent) => {
91
+ let count = 0;
92
+ for (const child of childrenArray) {
93
+ if (!matchesSlotComponent(child, SlotComponent)) continue;
94
+ count += 1;
95
+ }
96
+ return count;
97
+ };
98
+ /**
99
+ * @description Retrieves a single slot element from a collection of React children that matches the provided SlotComponent component.
100
+ *
101
+ * @throws { AssertionError } when throwOnMultipleSlotMatch is true and multiple slots are found
102
+ */
103
+ const getSingleSlot = (children, SlotComponent, options = {}) => {
104
+ const { errorMessage = "Only one instance of the SlotComponent is allowed", throwOnMultipleSlotMatch = false } = options;
105
+ const actualChildren = isValidElement(children) && children.type === Fragment ? children.props.children : children;
106
+ const childrenArray = toArray(actualChildren);
107
+ if (throwOnMultipleSlotMatch && calculateSlotOccurrences(childrenArray, SlotComponent) > 1) throw new AssertionError(errorMessage);
108
+ return childrenArray.find((child) => matchesSlotComponent(child, SlotComponent));
109
+ };
110
+ /**
111
+ * @description The same as getSingleSlot, but for multiple slot components
112
+ */
113
+ const getMultipleSlots = (children, SlotComponents, options) => {
114
+ const { errorMessage, throwOnMultipleSlotMatch } = options ?? {};
115
+ const slots = SlotComponents.map((SlotComponent, index) => getSingleSlot(children, SlotComponent, {
116
+ errorMessage: isArray(errorMessage) ? errorMessage[index] : errorMessage,
117
+ throwOnMultipleSlotMatch: isArray(throwOnMultipleSlotMatch) ? throwOnMultipleSlotMatch[index] : throwOnMultipleSlotMatch
118
+ }));
119
+ return {
120
+ regularChildren: getRegularChildren(children, SlotComponents),
121
+ slots
122
+ };
123
+ };
124
+ /**
125
+ * @description Returns all children that are not slot elements (i.e., don't match any of the provided slot components)
126
+ */
127
+ const getRegularChildren = (children, SlotComponentOrComponents) => {
128
+ const actualChildren = isValidElement(children) && children.type === Fragment ? children.props.children : children;
129
+ return toArray(actualChildren).filter((child) => !matchesAnySlotComponent(child, toArray(SlotComponentOrComponents)));
130
+ };
131
+
132
+ //#endregion
133
+ //#region src/utils/getSlotMap/getSlotMap.ts
134
+ /**
135
+ * Symbol used to identify SlotComponent instances
136
+ */
137
+ const slotComponentSymbol = Symbol("slot-component");
138
+ /**
139
+ * @description Creates a map of named slots from React children. Returns an object mapping slot names to their children,
140
+ * with a default slot for unmatched children.
141
+ *
142
+ * @example
143
+ * ```tsx
144
+ * import { type GetSlotComponentProps, SlotComponent } from "@zayne-labs/toolkit-react/utils"
145
+ *
146
+ * type SlotProps = GetSlotComponentProps<"header" | "footer">;
147
+ *
148
+ * function Parent({ children }: { children: React.ReactNode }) {
149
+ * const slots = getSlotMap<SlotProps>(children);
150
+ *
151
+ * return (
152
+ * <div>
153
+ * <header>{slots.header}</header>
154
+ * <main>{slots.default}</main>
155
+ * <footer>{slots.footer}</footer>
156
+ * </div>
157
+ * );
158
+ * }
159
+ * ```
160
+ *
161
+ * Usage:
162
+ * ```tsx
163
+ * <Parent>
164
+ * <SlotComponent name="header">Header Content</SlotComponent>
165
+ * <div>Random stuff</div>
166
+ * <SlotComponent name="footer">Footer Content</SlotComponent>
167
+ * </Parent>
168
+ * ```
169
+ */
170
+ const getSlotMap = (children) => {
171
+ const slots = { default: [] };
172
+ const actualChildren = isValidElement(children) && children.type === Fragment ? children.props.children : children;
173
+ const childrenArray = toArray(actualChildren);
174
+ for (const child of childrenArray) {
175
+ if (!isValidElement(child) || !isFunction(child.type)) {
176
+ slots.default.push(child);
177
+ continue;
178
+ }
179
+ const childType = child.type;
180
+ if (!(childType.slotSymbol === slotComponentSymbol && Boolean(childType.slotName ?? child.props.name))) {
181
+ slots.default.push(child);
182
+ continue;
183
+ }
184
+ const slotName = childType.slotName ?? child.props.name;
185
+ if (slotName === "default") {
186
+ slots.default.push(child);
187
+ continue;
188
+ }
189
+ slots[slotName] = child;
190
+ }
191
+ return slots;
192
+ };
193
+ /**
194
+ * @description Creates a slot component
195
+ */
196
+ const createSlotComponent = () => {
197
+ const SlotComponent = (props) => props.children;
198
+ SlotComponent.slotSymbol = slotComponentSymbol;
199
+ return SlotComponent;
200
+ };
201
+ function DefaultSlotComponent(props) {
202
+ return props.children;
203
+ }
204
+ /**
205
+ * @description Adds a slot symbol and name to a slot component passed in
206
+ */
207
+ const withSlotNameAndSymbol = (name, SlotComponent = DefaultSlotComponent) => {
208
+ SlotComponent.slotSymbol = slotComponentSymbol;
209
+ SlotComponent.slotName = name;
210
+ return SlotComponent;
61
211
  };
62
212
 
63
213
  //#endregion
@@ -65,8 +215,7 @@ const useComposeRefs = (...refs) => {
65
215
  const isEventHandler = (key, value) => {
66
216
  const thirdCharCode = key.codePointAt(2);
67
217
  if (!isFunction(value) || thirdCharCode === void 0) return false;
68
- const isHandler = key.startsWith("on") && thirdCharCode >= 65 && thirdCharCode <= 90;
69
- return isHandler;
218
+ return key.startsWith("on") && thirdCharCode >= 65 && thirdCharCode <= 90;
70
219
  };
71
220
  const mergeTwoClassNames = (formerClassName, latterClassName) => {
72
221
  if (!latterClassName || !formerClassName) return latterClassName || formerClassName;
@@ -126,5 +275,5 @@ const mergeProps = (...propsObjectArray) => {
126
275
  };
127
276
 
128
277
  //#endregion
129
- export { composeEventHandlers, composeRefs, composeTwoEventHandlers, mergeProps, mergeTwoProps, setRef, useComposeRefs };
278
+ export { composeEventHandlers, composeRefs, composeTwoEventHandlers, createSlotComponent, getMultipleSlots, getRegularChildren, getSingleSlot, getSlotMap, matchesAnySlotComponent, matchesSlotComponent, mergeProps, mergeTwoProps, setRef, slotComponentSymbol, withSlotNameAndSymbol };
130
279
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["result","accumulatedHandlers: AnyFunction | undefined","mergedRefCallBack: RefCallback<TRef>","accumulatedProps: Record<string, unknown>"],"sources":["../../../src/utils/composeEventHandlers.ts","../../../src/utils/composeRefs.ts","../../../src/utils/mergeTwoProps.ts","../../../src/utils/mergeProps.ts"],"sourcesContent":["import { type AnyFunction, isObject } from \"@zayne-labs/toolkit-type-helpers\";\n\nconst isSyntheticEvent = (event: unknown): event is React.SyntheticEvent => {\n\treturn isObject(event) && Object.hasOwn(event, \"nativeEvent\");\n};\n\nexport const composeTwoEventHandlers = (\n\tformerHandler: AnyFunction | undefined,\n\tlatterHandler: AnyFunction | undefined\n) => {\n\tconst mergedEventHandler = (event: unknown) => {\n\t\tif (isSyntheticEvent(event)) {\n\t\t\tconst result = latterHandler?.(event) as unknown;\n\n\t\t\tif (!event.defaultPrevented) {\n\t\t\t\tformerHandler?.(event);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\n\t\tconst result = latterHandler?.(event) as unknown;\n\t\tformerHandler?.(event);\n\t\treturn result;\n\t};\n\n\treturn mergedEventHandler;\n};\n\nexport const composeEventHandlers = (...eventHandlerArray: Array<AnyFunction | undefined>) => {\n\tconst mergedEventHandler = (event: unknown) => {\n\t\tif (eventHandlerArray.length === 0) return;\n\n\t\tif (eventHandlerArray.length === 1) {\n\t\t\treturn eventHandlerArray[0]?.(event) as unknown;\n\t\t}\n\n\t\tlet accumulatedHandlers: AnyFunction | undefined;\n\n\t\tfor (const eventHandler of eventHandlerArray) {\n\t\t\tif (!eventHandler) continue;\n\n\t\t\taccumulatedHandlers = composeTwoEventHandlers(accumulatedHandlers, eventHandler);\n\t\t}\n\n\t\treturn accumulatedHandlers?.(event) as unknown;\n\t};\n\n\treturn mergedEventHandler;\n};\n","import { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { type RefCallback, useCallback } from \"react\";\n\ntype PossibleRef<TRef extends HTMLElement> = React.Ref<TRef> | undefined;\n\n/**\n * @description Set a given ref to a given value.\n *\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nexport const setRef = <TRef extends HTMLElement>(\n\tref: PossibleRef<TRef>,\n\tnode: TRef | null\n): ReturnType<RefCallback<TRef>> => {\n\tif (!ref) return;\n\n\tif (isFunction(ref)) {\n\t\treturn ref(node);\n\t}\n\n\t// eslint-disable-next-line no-param-reassign -- Mutation is needed here\n\tref.current = node;\n};\n\n/**\n * @description A utility to combine refs. Accepts callback refs and RefObject(s)\n */\nexport const composeRefs = <TRef extends HTMLElement>(\n\t...refs: Array<PossibleRef<TRef>>\n): RefCallback<TRef> => {\n\tconst mergedRefCallBack: RefCallback<TRef> = (node) => {\n\t\tconst cleanupFnArray = refs.map((ref) => setRef(ref, node));\n\n\t\tconst cleanupFn = () => cleanupFnArray.forEach((cleanup) => cleanup?.());\n\n\t\treturn cleanupFn;\n\t};\n\n\treturn mergedRefCallBack;\n};\n\nexport const useComposeRefs = <TRef extends HTMLElement>(...refs: Array<PossibleRef<TRef>>) => {\n\t// eslint-disable-next-line react-hooks/exhaustive-deps -- Allow\n\tconst mergedRef = useCallback(() => composeRefs(...refs), refs);\n\n\treturn mergedRef;\n};\n","import { type AnyFunction, isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { composeTwoEventHandlers } from \"./composeEventHandlers\";\n\n// == This approach is more efficient than using a regex.\nconst isEventHandler = (key: string, value: unknown): value is AnyFunction => {\n\tconst thirdCharCode = key.codePointAt(2);\n\n\tif (!isFunction(value) || thirdCharCode === undefined) {\n\t\treturn false;\n\t}\n\n\tconst isHandler = key.startsWith(\"on\") && thirdCharCode >= 65 /* A */ && thirdCharCode <= 90; /* Z */\n\n\treturn isHandler;\n};\n\nconst mergeTwoClassNames = (formerClassName: string | undefined, latterClassName: string | undefined) => {\n\tif (!latterClassName || !formerClassName) {\n\t\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- Logical OR is fit for this case\n\t\treturn latterClassName || formerClassName;\n\t}\n\n\t// eslint-disable-next-line prefer-template -- String concatenation is more performant than template literals in this case\n\treturn formerClassName + \" \" + latterClassName;\n};\n\nexport const mergeTwoProps = <TProps extends Record<never, never>>(\n\tformerProps: TProps | undefined,\n\tlatterProps: TProps | undefined\n): TProps => {\n\t// == If no props are provided, return an empty object\n\tif (!latterProps || !formerProps) {\n\t\treturn latterProps ?? formerProps ?? ({} as TProps);\n\t}\n\n\tconst propsAccumulator = { ...formerProps } as Record<string, unknown>;\n\n\tfor (const latterPropName of Object.keys(latterProps)) {\n\t\tconst formerPropValue = (formerProps as Record<string, unknown>)[latterPropName];\n\t\tconst latterPropValue = (latterProps as Record<string, unknown>)[latterPropName];\n\n\t\t// == If the prop is `className` or `class`, we merge them\n\t\tif (latterPropName === \"className\" || latterPropName === \"class\") {\n\t\t\tpropsAccumulator[latterPropName] = mergeTwoClassNames(\n\t\t\t\tformerPropValue as string,\n\t\t\t\tlatterPropValue as string\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == If the prop is `style`, we merge them\n\t\tif (latterPropName === \"style\") {\n\t\t\tpropsAccumulator[latterPropName] = {\n\t\t\t\t...(formerPropValue as object),\n\t\t\t\t...(latterPropValue as object),\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == If the handler exists on both, we compose them\n\t\tif (isEventHandler(latterPropName, latterPropValue)) {\n\t\t\tpropsAccumulator[latterPropName] = composeTwoEventHandlers(\n\t\t\t\tformerPropValue as AnyFunction | undefined,\n\t\t\t\tlatterPropValue\n\t\t\t);\n\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == latterProps override by default\n\t\tpropsAccumulator[latterPropName] = latterPropValue;\n\t}\n\n\treturn propsAccumulator as TProps;\n};\n","import { mergeTwoProps } from \"./mergeTwoProps\";\n\ntype UnionToIntersection<TUnion> =\n\t(TUnion extends unknown ? (param: TUnion) => void : \"\") extends (param: infer TParam) => void ? TParam\n\t:\t\"\";\n\n/**\n * Merges multiple sets of React props.\n *\n * - It follows the Object.assign pattern where the rightmost object's fields overwrite\n * the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.\n * - Event handlers are merged such that they are called in sequence (the rightmost one being called first),\n * and allows the user to prevent the previous event handlers from being executed by calling the `preventDefault` method.\n * - It also merges the `className` and `style` props, whereby the classes are concatenated\n * and the rightmost styles overwrite the previous ones.\n *\n * @important **`ref` is not merged.**\n * @param props props to merge.\n * @returns the merged props.\n */\n\nconst mergeProps = <TProps extends Record<never, never>>(\n\t...propsObjectArray: Array<TProps | undefined>\n): UnionToIntersection<TProps> => {\n\tif (propsObjectArray.length === 0) {\n\t\treturn {} as never;\n\t}\n\n\tif (propsObjectArray.length === 1) {\n\t\treturn propsObjectArray[0] as never;\n\t}\n\n\tlet accumulatedProps: Record<string, unknown> = {};\n\n\tfor (const propsObject of propsObjectArray) {\n\t\tif (!propsObject) continue;\n\n\t\taccumulatedProps = mergeTwoProps(accumulatedProps, propsObject);\n\t}\n\n\treturn accumulatedProps as never;\n};\n\nexport { mergeProps };\n"],"mappings":";;;;AAEA,MAAM,oBAAoB,UAAkD;AAC3E,QAAO,SAAS,UAAU,OAAO,OAAO,OAAO;;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O,kBAAkB,MAAM;;AAGhC,MAAa,iBACZ,aACA,gBACY;AAEZ,KAAI,CAAC,eAAe,CAAC,YACpB,QAAO,eAAe,eAAgB;CAGvC,MAAM,mBAAmB,EAAE,GAAG;AAE9B,MAAK,MAAM,kBAAkB,OAAO,KAAK,cAAc;EACtD,MAAM,kBAAmB,YAAwC;EACjE,MAAM,kBAAmB,YAAwC;AAGjE,MAAI,mBAAmB,eAAe,mBAAmB,SAAS;AACjE,oBAAiB,kBAAkB,mBAClC,iBACA;AAED;;AAID,MAAI,mBAAmB,SAAS;AAC/B,oBAAiB,kBAAkB;IAClC,GAAI;IACJ,GAAI;;AAEL;;AAID,MAAI,eAAe,gBAAgB,kBAAkB;AACpD,oBAAiB,kBAAkB,wBAClC,iBACA;AAGD;;AAID,mBAAiB,kBAAkB;;AAGpC,QAAO;;;;;;;;;;;;;;;;;;;ACpDR,MAAM,cACL,GAAG,qBAC8B;AACjC,KAAI,iBAAiB,WAAW,EAC/B,QAAO;AAGR,KAAI,iBAAiB,WAAW,EAC/B,QAAO,iBAAiB;CAGzB,IAAIC,mBAA4C;AAEhD,MAAK,MAAM,eAAe,kBAAkB;AAC3C,MAAI,CAAC,YAAa;AAElB,qBAAmB,cAAc,kBAAkB;;AAGpD,QAAO"}
1
+ {"version":3,"file":"index.js","names":["result","accumulatedHandlers: AnyFunction | undefined","mergedRefCallBack: RefCallback<TRef>","ReactFragment","slots: Record<string, TSlotComponentProps[\"children\"]> & { default: React.ReactNode[] }","ReactFragment","accumulatedProps: Record<string, unknown>"],"sources":["../../../src/utils/composeEventHandlers.ts","../../../src/utils/composeRefs.ts","../../../src/utils/getSlot/getSlot.ts","../../../src/utils/getSlotMap/getSlotMap.ts","../../../src/utils/mergeTwoProps.ts","../../../src/utils/mergeProps.ts"],"sourcesContent":["import { type AnyFunction, isObject } from \"@zayne-labs/toolkit-type-helpers\";\n\nconst isSyntheticEvent = (event: unknown): event is React.SyntheticEvent => {\n\treturn isObject(event) && Object.hasOwn(event, \"nativeEvent\");\n};\n\nexport const composeTwoEventHandlers = (\n\tformerHandler: AnyFunction | undefined,\n\tlatterHandler: AnyFunction | undefined\n) => {\n\tconst mergedEventHandler = (event: unknown) => {\n\t\tif (isSyntheticEvent(event)) {\n\t\t\tconst result = latterHandler?.(event) as unknown;\n\n\t\t\tif (!event.defaultPrevented) {\n\t\t\t\tformerHandler?.(event);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\n\t\tconst result = latterHandler?.(event) as unknown;\n\t\tformerHandler?.(event);\n\t\treturn result;\n\t};\n\n\treturn mergedEventHandler;\n};\n\nexport const composeEventHandlers = (...eventHandlerArray: Array<AnyFunction | undefined>) => {\n\tconst mergedEventHandler = (event: unknown) => {\n\t\tif (eventHandlerArray.length === 0) return;\n\n\t\tif (eventHandlerArray.length === 1) {\n\t\t\treturn eventHandlerArray[0]?.(event) as unknown;\n\t\t}\n\n\t\tlet accumulatedHandlers: AnyFunction | undefined;\n\n\t\tfor (const eventHandler of eventHandlerArray) {\n\t\t\tif (!eventHandler) continue;\n\n\t\t\taccumulatedHandlers = composeTwoEventHandlers(accumulatedHandlers, eventHandler);\n\t\t}\n\n\t\treturn accumulatedHandlers?.(event) as unknown;\n\t};\n\n\treturn mergedEventHandler;\n};\n","import { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { RefCallback } from \"react\";\n\nexport type PossibleRef<TRef extends HTMLElement> = React.Ref<TRef> | undefined;\n\n/**\n * @description Set a given ref to a given value.\n *\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nexport const setRef = <TRef extends HTMLElement>(\n\tref: PossibleRef<TRef>,\n\tnode: TRef | null\n): ReturnType<RefCallback<TRef>> => {\n\tif (!ref) return;\n\n\tif (isFunction(ref)) {\n\t\treturn ref(node);\n\t}\n\n\t// eslint-disable-next-line no-param-reassign -- Mutation is needed here\n\tref.current = node;\n};\n\n/**\n * @description A utility to combine refs. Accepts callback refs and RefObject(s)\n */\nexport const composeRefs = <TRef extends HTMLElement>(\n\t...refs: Array<PossibleRef<TRef>>\n): RefCallback<TRef> => {\n\tconst mergedRefCallBack: RefCallback<TRef> = (node) => {\n\t\tconst cleanupFnArray = refs.map((ref) => setRef(ref, node));\n\n\t\tconst cleanupFn = () => cleanupFnArray.forEach((cleanup) => cleanup?.());\n\n\t\treturn cleanupFn;\n\t};\n\n\treturn mergedRefCallBack;\n};\n","import { toArray } from \"@zayne-labs/toolkit-core\";\nimport {\n\ttype AnyFunction,\n\tAssertionError,\n\tisArray,\n\tisFunction,\n\ttype Prettify,\n\ttype UnknownObject,\n} from \"@zayne-labs/toolkit-type-helpers\";\nimport { isValidElement, Fragment as ReactFragment } from \"react\";\nimport type { InferProps } from \"../types\";\n\nexport type FunctionalComponent<TProps extends UnknownObject = never> = React.FunctionComponent<TProps>;\n\nconst isWithSlotSymbol = <TFunction extends AnyFunction>(\n\tcomponent: TFunction\n): component is Record<\"slotSymbol\", unknown> & TFunction => {\n\treturn \"slotSymbol\" in component && Boolean(component.slotSymbol);\n};\n\nconst isWithSlotReference = <TFunction extends AnyFunction>(\n\tcomponent: TFunction\n): component is Record<\"slotReference\", unknown> & TFunction => {\n\treturn \"slotReference\" in component && Boolean(component.slotReference);\n};\n/**\n * @description Checks if a react child (within the children array) matches the provided SlotComponent using multiple matching strategies:\n * 1. Matches by slot symbol property\n * 2. Matches by component name\n */\n\nexport const matchesSlotComponent = (child: React.ReactNode, SlotComponent: FunctionalComponent) => {\n\tif (!isValidElement(child) || !isFunction(child.type)) {\n\t\treturn false;\n\t}\n\n\tconst resolvedChildType =\n\t\tisWithSlotReference(child.type) ? (child.type.slotReference as FunctionalComponent) : child.type;\n\n\tconst hasMatchingSlotSymbol =\n\t\tisWithSlotSymbol(resolvedChildType)\n\t\t&& isWithSlotSymbol(SlotComponent)\n\t\t&& resolvedChildType.slotSymbol === SlotComponent.slotSymbol;\n\n\tif (hasMatchingSlotSymbol) {\n\t\treturn true;\n\t}\n\n\tif (child.type.name === SlotComponent.name) {\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n/**\n * @description Checks if a react child (within the children array) matches any of the provided SlotComponents.\n */\nexport const matchesAnySlotComponent = (child: React.ReactNode, SlotComponents: FunctionalComponent[]) => {\n\tconst matchesSlot = SlotComponents.some((SlotComponent) => matchesSlotComponent(child, SlotComponent));\n\n\treturn matchesSlot;\n};\n\ntype SlotOptions = {\n\t/**\n\t * @description The error message to throw when multiple slots are found for a given slot component\n\t */\n\terrorMessage?: string;\n\t/**\n\t * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component\n\t */\n\tthrowOnMultipleSlotMatch?: boolean;\n};\n\n/**\n * @description Counts how many times a given slot component appears in an array of children\n * @internal\n */\nconst calculateSlotOccurrences = (\n\tchildrenArray: React.ReactNode[],\n\tSlotComponent: FunctionalComponent\n) => {\n\tlet count = 0;\n\n\tfor (const child of childrenArray) {\n\t\tif (!matchesSlotComponent(child, SlotComponent)) continue;\n\n\t\tcount += 1;\n\t}\n\n\treturn count;\n};\n\n/**\n * @description Retrieves a single slot element from a collection of React children that matches the provided SlotComponent component.\n *\n * @throws { AssertionError } when throwOnMultipleSlotMatch is true and multiple slots are found\n */\nexport const getSingleSlot = (\n\tchildren: React.ReactNode,\n\tSlotComponent: FunctionalComponent,\n\toptions: SlotOptions = {}\n) => {\n\tconst {\n\t\terrorMessage = \"Only one instance of the SlotComponent is allowed\",\n\t\tthrowOnMultipleSlotMatch = false,\n\t} = options;\n\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment ?\n\t\t\tchildren.props.children\n\t\t:\tchildren;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tconst shouldThrow =\n\t\tthrowOnMultipleSlotMatch && calculateSlotOccurrences(childrenArray, SlotComponent) > 1;\n\n\tif (shouldThrow) {\n\t\tthrow new AssertionError(errorMessage);\n\t}\n\n\tconst slotElement = childrenArray.find((child) => matchesSlotComponent(child, SlotComponent));\n\n\treturn slotElement;\n};\n\n// NOTE - You can imitate const type parameter by extending readonly[] | []\n\ntype MultipleSlotsOptions = {\n\t/**\n\t * @description The error message to throw when multiple slots are found for a given slot component\n\t * If a string is provided, the same message will be used for all slot components\n\t * If an array is provided, each string in the array will be used as the errorMessage for the corresponding slot component\n\t */\n\terrorMessage?: string | string[];\n\t/**\n\t * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component\n\t * If a boolean is provided, the same value will be used for all slot components\n\t * If an array is provided, each boolean in the array will be used as the throwOnMultipleSlotMatch value for the corresponding slot component\n\t */\n\tthrowOnMultipleSlotMatch?: boolean | boolean[];\n};\n\ntype GetMultipleSlotsResult<TSlotComponents extends FunctionalComponent[]> = {\n\tregularChildren: React.ReactNode[];\n\tslots: { [Key in keyof TSlotComponents]: ReturnType<TSlotComponents[Key]> };\n};\n\n/**\n * @description The same as getSingleSlot, but for multiple slot components\n */\nexport const getMultipleSlots = <const TSlotComponents extends FunctionalComponent[]>(\n\tchildren: React.ReactNode,\n\tSlotComponents: TSlotComponents,\n\toptions?: MultipleSlotsOptions\n): Prettify<GetMultipleSlotsResult<TSlotComponents>> => {\n\tconst { errorMessage, throwOnMultipleSlotMatch } = options ?? {};\n\n\tconst slots = SlotComponents.map((SlotComponent, index) =>\n\t\tgetSingleSlot(children, SlotComponent, {\n\t\t\terrorMessage: isArray(errorMessage) ? errorMessage[index] : errorMessage,\n\t\t\tthrowOnMultipleSlotMatch:\n\t\t\t\tisArray(throwOnMultipleSlotMatch) ? throwOnMultipleSlotMatch[index] : throwOnMultipleSlotMatch,\n\t\t})\n\t);\n\n\tconst regularChildren = getRegularChildren(children, SlotComponents);\n\n\treturn { regularChildren, slots } as GetMultipleSlotsResult<TSlotComponents>;\n};\n\n/**\n * @description Returns all children that are not slot elements (i.e., don't match any of the provided slot components)\n */\nexport const getRegularChildren = (\n\tchildren: React.ReactNode,\n\tSlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]\n) => {\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment ?\n\t\t\tchildren.props.children\n\t\t:\tchildren;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tconst regularChildren = childrenArray.filter(\n\t\t(child) => !matchesAnySlotComponent(child, toArray(SlotComponentOrComponents))\n\t);\n\n\treturn regularChildren;\n};\n","import { toArray } from \"@zayne-labs/toolkit-core\";\nimport {\n\ttype CallbackFn,\n\ttype EmptyObject,\n\tisFunction,\n\ttype Prettify,\n\ttype UnionToIntersection,\n\ttype UnknownObject,\n} from \"@zayne-labs/toolkit-type-helpers\";\nimport { isValidElement, Fragment as ReactFragment } from \"react\";\nimport type { InferProps } from \"../types\";\n\ntype GetSlotName<TSlotComponentProps extends GetSlotComponentProps> =\n\tstring extends TSlotComponentProps[\"name\"] ? never\n\t: \"default\" extends TSlotComponentProps[\"name\"] ? never\n\t: TSlotComponentProps[\"name\"];\n\ntype GetSpecificSlotsType<TSlotComponentProps extends GetSlotComponentProps> = {\n\t// This conditional before the remapping will prevent an Indexed Record type from showing up if the props are not passed, enhancing type safety\n\t[TName in keyof TSlotComponentProps as GetSlotName<TSlotComponentProps>]: Extract<\n\t\tTSlotComponentProps[\"children\"],\n\t\tReact.ReactNode\n\t>;\n};\n\n/**\n * Maps slot names to their corresponding children types\n */\nexport type GetSlotMapResult<TSlotComponentProps extends GetSlotComponentProps> = UnionToIntersection<\n\tGetSpecificSlotsType<TSlotComponentProps>\n> & { default: React.ReactNode[] };\n\n/**\n * Symbol used to identify SlotComponent instances\n */\nexport const slotComponentSymbol = Symbol(\"slot-component\");\n\n/**\n * @description Creates a map of named slots from React children. Returns an object mapping slot names to their children,\n * with a default slot for unmatched children.\n *\n * @example\n * ```tsx\n * import { type GetSlotComponentProps, SlotComponent } from \"@zayne-labs/toolkit-react/utils\"\n *\n * type SlotProps = GetSlotComponentProps<\"header\" | \"footer\">;\n *\n * function Parent({ children }: { children: React.ReactNode }) {\n * const slots = getSlotMap<SlotProps>(children);\n *\n * return (\n * <div>\n * <header>{slots.header}</header>\n * <main>{slots.default}</main>\n * <footer>{slots.footer}</footer>\n * </div>\n * );\n * }\n * ```\n *\n * Usage:\n * ```tsx\n * <Parent>\n * <SlotComponent name=\"header\">Header Content</SlotComponent>\n * <div>Random stuff</div>\n * <SlotComponent name=\"footer\">Footer Content</SlotComponent>\n * </Parent>\n * ```\n */\nexport const getSlotMap = <TSlotComponentProps extends GetSlotComponentProps>(\n\tchildren: React.ReactNode\n): Prettify<GetSlotMapResult<TSlotComponentProps>> => {\n\tconst slots: Record<string, TSlotComponentProps[\"children\"]> & { default: React.ReactNode[] } = {\n\t\tdefault: [],\n\t};\n\n\tconst isFragment = isValidElement<InferProps<HTMLElement>>(children) && children.type === ReactFragment;\n\n\tconst actualChildren = isFragment ? children.props.children : children;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tfor (const child of childrenArray) {\n\t\tif (!isValidElement<TSlotComponentProps>(child) || !isFunction(child.type)) {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst childType = child.type as SlotWithNameAndSymbol;\n\n\t\tconst isSlotElement =\n\t\t\tchildType.slotSymbol === slotComponentSymbol && Boolean(childType.slotName ?? child.props.name);\n\n\t\tif (!isSlotElement) {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst slotName = childType.slotName ?? child.props.name;\n\n\t\tif (slotName === \"default\") {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tslots[slotName] = child;\n\t}\n\n\treturn slots as GetSlotMapResult<TSlotComponentProps>;\n};\n\n/**\n * @description Produce props for the SlotComponent\n *\n * @example\n * ```ts\n * // Pattern One (slot or slots have same children type, which is just React.ReactNode by default)\n * type SlotProps = GetSlotComponentProps<\"header\" | \"content\" | \"footer\">;\n *\n * // Pattern Two (some slots can have different children type)\n * type SlotProps = GetSlotComponentProps<\"header\", React.ReactNode> | GetSlotComponentProps<\"header\", (renderProp: RenderProp) => React.ReactNode>;\n * ```\n */\nexport type GetSlotComponentProps<\n\tTName extends string = string,\n\tTChildren extends CallbackFn<never, React.ReactNode> | React.ReactNode =\n\t\t| CallbackFn<never, React.ReactNode>\n\t\t| React.ReactNode,\n> = {\n\tchildren: TChildren;\n\t/**\n\t * Name of the slot where content should be rendered\n\t */\n\tname: TName;\n};\n\n/**\n * @description Creates a slot component\n */\nexport const createSlotComponent = <TSlotComponentProps extends GetSlotComponentProps>() => {\n\tconst SlotComponent = (props: TSlotComponentProps) => props.children as React.ReactNode;\n\n\tSlotComponent.slotSymbol = slotComponentSymbol;\n\n\treturn SlotComponent;\n};\n\ntype SlotWithNameAndSymbol<\n\tTSlotComponentProps extends GetSlotComponentProps = GetSlotComponentProps,\n\tTOtherProps extends UnknownObject = EmptyObject,\n> = {\n\t(props: Pick<TSlotComponentProps, \"children\"> & TOtherProps): React.ReactNode;\n\treadonly slotName?: TSlotComponentProps[\"name\"];\n\treadonly slotSymbol?: symbol;\n};\n\nfunction DefaultSlotComponent(props: Pick<GetSlotComponentProps, \"children\">): React.ReactNode {\n\treturn props.children as React.ReactNode;\n}\n\n/**\n * @description Adds a slot symbol and name to a slot component passed in\n */\nexport const withSlotNameAndSymbol = <\n\tTSlotComponentProps extends GetSlotComponentProps,\n\tTOtherProps extends UnknownObject = EmptyObject,\n>(\n\tname: TSlotComponentProps[\"name\"],\n\tSlotComponent: SlotWithNameAndSymbol<TSlotComponentProps, TOtherProps> = DefaultSlotComponent\n) => {\n\t/* eslint-disable no-param-reassign -- This is necessary */\n\t// @ts-expect-error -- This is necessary for the time being, to prevent type errors and accidental overrides on consumer side\n\tSlotComponent.slotSymbol = slotComponentSymbol;\n\t// @ts-expect-error -- This is necessary for the time being, to prevent type errors and accidental overrides on consumer side\n\tSlotComponent.slotName = name;\n\n\t/* eslint-enable no-param-reassign -- This is necessary */\n\n\treturn SlotComponent;\n};\n","import { type AnyFunction, isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { composeTwoEventHandlers } from \"./composeEventHandlers\";\n\n// == This approach is more efficient than using a regex.\nconst isEventHandler = (key: string, value: unknown): value is AnyFunction => {\n\tconst thirdCharCode = key.codePointAt(2);\n\n\tif (!isFunction(value) || thirdCharCode === undefined) {\n\t\treturn false;\n\t}\n\n\tconst isHandler = key.startsWith(\"on\") && thirdCharCode >= 65 /* A */ && thirdCharCode <= 90; /* Z */\n\n\treturn isHandler;\n};\n\nconst mergeTwoClassNames = (formerClassName: string | undefined, latterClassName: string | undefined) => {\n\tif (!latterClassName || !formerClassName) {\n\t\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- Logical OR is fit for this case\n\t\treturn latterClassName || formerClassName;\n\t}\n\n\t// eslint-disable-next-line prefer-template -- String concatenation is more performant than template literals in this case\n\treturn formerClassName + \" \" + latterClassName;\n};\n\nexport const mergeTwoProps = <TProps extends Record<never, never>>(\n\tformerProps: TProps | undefined,\n\tlatterProps: TProps | undefined\n): TProps => {\n\t// == If no props are provided, return an empty object\n\tif (!latterProps || !formerProps) {\n\t\treturn latterProps ?? formerProps ?? ({} as TProps);\n\t}\n\n\tconst propsAccumulator = { ...formerProps } as Record<string, unknown>;\n\n\tfor (const latterPropName of Object.keys(latterProps)) {\n\t\tconst formerPropValue = (formerProps as Record<string, unknown>)[latterPropName];\n\t\tconst latterPropValue = (latterProps as Record<string, unknown>)[latterPropName];\n\n\t\t// == If the prop is `className` or `class`, we merge them\n\t\tif (latterPropName === \"className\" || latterPropName === \"class\") {\n\t\t\tpropsAccumulator[latterPropName] = mergeTwoClassNames(\n\t\t\t\tformerPropValue as string,\n\t\t\t\tlatterPropValue as string\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == If the prop is `style`, we merge them\n\t\tif (latterPropName === \"style\") {\n\t\t\tpropsAccumulator[latterPropName] = {\n\t\t\t\t...(formerPropValue as object),\n\t\t\t\t...(latterPropValue as object),\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == If the handler exists on both, we compose them\n\t\tif (isEventHandler(latterPropName, latterPropValue)) {\n\t\t\tpropsAccumulator[latterPropName] = composeTwoEventHandlers(\n\t\t\t\tformerPropValue as AnyFunction | undefined,\n\t\t\t\tlatterPropValue\n\t\t\t);\n\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == latterProps override by default\n\t\tpropsAccumulator[latterPropName] = latterPropValue;\n\t}\n\n\treturn propsAccumulator as TProps;\n};\n","import { mergeTwoProps } from \"./mergeTwoProps\";\n\ntype UnionToIntersection<TUnion> =\n\t(TUnion extends unknown ? (param: TUnion) => void : \"\") extends (param: infer TParam) => void ? TParam\n\t:\t\"\";\n\n/**\n * Merges multiple sets of React props.\n *\n * - It follows the Object.assign pattern where the rightmost object's fields overwrite\n * the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.\n * - Event handlers are merged such that they are called in sequence (the rightmost one being called first),\n * and allows the user to prevent the previous event handlers from being executed by calling the `preventDefault` method.\n * - It also merges the `className` and `style` props, whereby the classes are concatenated\n * and the rightmost styles overwrite the previous ones.\n *\n * @important **`ref` is not merged.**\n * @param props props to merge.\n * @returns the merged props.\n */\n\nconst mergeProps = <TProps extends Record<never, never>>(\n\t...propsObjectArray: Array<TProps | undefined>\n): UnionToIntersection<TProps> => {\n\tif (propsObjectArray.length === 0) {\n\t\treturn {} as never;\n\t}\n\n\tif (propsObjectArray.length === 1) {\n\t\treturn propsObjectArray[0] as never;\n\t}\n\n\tlet accumulatedProps: Record<string, unknown> = {};\n\n\tfor (const propsObject of propsObjectArray) {\n\t\tif (!propsObject) continue;\n\n\t\taccumulatedProps = mergeTwoProps(accumulatedProps, propsObject);\n\t}\n\n\treturn accumulatedProps as never;\n};\n\nexport { mergeProps };\n"],"mappings":";;;;;AAEA,MAAM,oBAAoB,UAAkD;AAC3E,QAAO,SAAS,MAAM,IAAI,OAAO,OAAO,OAAO,cAAc;;AAG9D,MAAa,2BACZ,eACA,kBACI;CAC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AC,gBAExB,QAAO,mBAAmB;AAI3B,QAAO,kBAAkB,MAAM;;AAGhC,MAAa,iBACZ,aACA,gBACY;AAEZ,KAAI,CAAC,eAAe,CAAC,YACpB,QAAO,eAAe,eAAgB,EAAE;CAGzC,MAAM,mBAAmB,EAAE,GAAG,aAAa;AAE3C,MAAK,MAAM,kBAAkB,OAAO,KAAK,YAAY,EAAE;EACtD,MAAM,kBAAmB,YAAwC;EACjE,MAAM,kBAAmB,YAAwC;AAGjE,MAAI,mBAAmB,eAAe,mBAAmB,SAAS;AACjE,oBAAiB,kBAAkB,mBAClC,iBACA,gBACA;AACD;;AAID,MAAI,mBAAmB,SAAS;AAC/B,oBAAiB,kBAAkB;IAClC,GAAI;IACJ,GAAI;IACJ;AACD;;AAID,MAAI,eAAe,gBAAgB,gBAAgB,EAAE;AACpD,oBAAiB,kBAAkB,wBAClC,iBACA,gBACA;AAED;;AAID,mBAAiB,kBAAkB;;AAGpC,QAAO;;;;;;;;;;;;;;;;;;;ACpDR,MAAM,cACL,GAAG,qBAC8B;AACjC,KAAI,iBAAiB,WAAW,EAC/B,QAAO,EAAE;AAGV,KAAI,iBAAiB,WAAW,EAC/B,QAAO,iBAAiB;CAGzB,IAAIC,mBAA4C,EAAE;AAElD,MAAK,MAAM,eAAe,kBAAkB;AAC3C,MAAI,CAAC,YAAa;AAElB,qBAAmB,cAAc,kBAAkB,YAAY;;AAGhE,QAAO"}
@@ -1,5 +1,5 @@
1
- import { CustomContextOptions } from "../index-C_W9xsBU.js";
2
- import * as react6 from "react";
1
+ import { CustomContextOptions } from "../index-DUGJrMJn.js";
2
+ import * as react0 from "react";
3
3
  import { StoreApi } from "@zayne-labs/toolkit-core";
4
4
  import { AnyObject, Prettify, SelectorFn } from "@zayne-labs/toolkit-type-helpers";
5
5
  import * as zustand0 from "zustand";
@@ -9,7 +9,7 @@ import { Mutate, StateCreator as StateCreator$1, StoreMutatorIdentifier, UseBoun
9
9
  declare const createZustandContext: <TState extends Record<string, unknown>, TStore extends StoreApi<TState> = StoreApi<TState>>(options?: CustomContextOptions<TStore, true>) => [ZustandStoreContextProvider: (props: {
10
10
  children: React.ReactNode;
11
11
  store: TStore;
12
- }) => react6.FunctionComponentElement<react6.ProviderProps<TStore>>, useZustandStoreContext: <TResult = TState>(selector?: SelectorFn<TState, TResult>) => TResult];
12
+ }) => react0.FunctionComponentElement<react0.ProviderProps<TStore>>, useZustandStoreContext: <TResult = TState>(selector?: SelectorFn<TState, TResult>) => TResult];
13
13
  //#endregion
14
14
  //#region src/zustand/createZustandStoreWithCombine.d.ts
15
15
  type Write<TInitialState, TExtraState> = Prettify<Omit<TInitialState, keyof TExtraState> & TExtraState>;
@@ -1,4 +1,4 @@
1
- import { createCustomContext, useStore } from "../hooks-Bnw2bN-M.js";
1
+ import { createCustomContext, useStore } from "../hooks-BHS1sAKT.js";
2
2
  import { createElement } from "react";
3
3
  import { createStore } from "@zayne-labs/toolkit-core";
4
4
  import { create, createStore as createStore$1 } from "zustand";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createStore"],"sources":["../../../src/zustand/createZustandContext.ts","../../../src/zustand/createZustandStoreWithCombine.ts","../../../src/zustand/createZustandStoreWithSubscribe.ts"],"sourcesContent":["import type { StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createElement } from \"react\";\nimport { type CustomContextOptions, createCustomContext, useStore } from \"../hooks\";\n\nconst createZustandContext = <\n\tTState extends Record<string, unknown>,\n\tTStore extends StoreApi<TState> = StoreApi<TState>,\n>(\n\toptions?: CustomContextOptions<TStore, true>\n) => {\n\tconst [Provider, useCustomContext] = createCustomContext(options);\n\n\ttype ZustandStoreContextProviderProps = {\n\t\tchildren: React.ReactNode;\n\t\tstore: TStore;\n\t};\n\n\tfunction ZustandStoreContextProvider(props: ZustandStoreContextProviderProps) {\n\t\tconst { children, store } = props;\n\n\t\treturn createElement(Provider, { value: store }, children);\n\t}\n\n\tconst useZustandStoreContext = <TResult = TState>(selector?: SelectorFn<TState, TResult>): TResult => {\n\t\tconst zustandStore = useCustomContext();\n\n\t\treturn useStore(zustandStore, selector);\n\t};\n\n\treturn [ZustandStoreContextProvider, useZustandStoreContext] as [\n\t\tZustandStoreContextProvider: typeof ZustandStoreContextProvider,\n\t\tuseZustandStoreContext: typeof useZustandStoreContext,\n\t];\n};\n\nexport { createZustandContext };\n","import type { AnyFunction, AnyObject, Prettify } from \"@zayne-labs/toolkit-type-helpers\";\nimport { create, createStore, type StateCreator, type StoreMutatorIdentifier } from \"zustand\";\n\ntype Write<TInitialState, TExtraState> = Prettify<Omit<TInitialState, keyof TExtraState> & TExtraState>;\n\nexport const combine =\n\t<\n\t\tTInitialState extends AnyObject,\n\t\tTExtraState extends AnyObject,\n\t\tMps extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\t\tMcs extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\t>(\n\t\tinitialState: TInitialState,\n\t\tstoreCreator: StateCreator<TInitialState, Mps, Mcs, TExtraState>\n\t): StateCreator<Write<TInitialState, TExtraState>, Mps, Mcs> =>\n\t// eslint-disable-next-line ts-eslint/no-unsafe-return -- We don't know what the storeCreator will return\n\t(...params) => ({\n\t\t...initialState,\n\t\t...(storeCreator as AnyFunction)(...params),\n\t});\n\nexport const createStoreWithCombine = <TInitialState extends AnyObject, TExtraState extends AnyObject>(\n\t...params: Parameters<typeof combine<TInitialState, TExtraState>>\n) => createStore(combine(...params));\n\nexport const createWithCombine = <TInitialState extends AnyObject, TExtraState extends AnyObject>(\n\t...params: Parameters<typeof combine<TInitialState, TExtraState>>\n) => create(combine(...params));\n","import { createStore, type StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { Mutate, StoreMutatorIdentifier, UseBoundStore } from \"zustand\";\nimport { useStore } from \"../hooks\";\n\ntype Get<T, K, F> = K extends keyof T ? T[K] : F;\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 CreateStoreWithSubscribe = {\n\t<T, Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t): Mutate<StoreApi<T>, Mos>;\n\n\t<T>(): <Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t) => Mutate<StoreApi<T>, Mos>;\n};\n\nexport const createStoreWithSubscribe = (<TState>(stateInitializer: StateCreator<TState> | undefined) =>\n\tstateInitializer ? createStore(stateInitializer) : createStore) as CreateStoreWithSubscribe;\n\ntype CreateWithSubscribe = {\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 createWithSubscribeImpl = <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 createWithSubscribe = (<TState>(stateInitializer: StateCreator<TState> | undefined) =>\n\tstateInitializer ?\n\t\tcreateWithSubscribeImpl(stateInitializer)\n\t:\tcreateWithSubscribeImpl) as CreateWithSubscribe;\n"],"mappings":";;;;;;AAKA,MAAM,wBAIL,YACI;CACJ,MAAM,CAAC,UAAU,oBAAoB,oBAAoB;CAOzD,SAAS,4BAA4B,OAAyC;EAC7E,MAAM,EAAE,UAAU,UAAU;AAE5B,SAAO,cAAc,UAAU,EAAE,OAAO,SAAS;;CAGlD,MAAM,0BAA4C,aAAoD;EACrG,MAAM,eAAe;AAErB,SAAO,SAAS,cAAc;;AAG/B,QAAO,CAAC,6BAA6B;;;;;ACzBtC,MAAa,WAOX,cACA,kBAGA,GAAG,YAAY;CACf,GAAG;CACH,GAAI,aAA6B,GAAG;;AAGtC,MAAa,0BACZ,GAAG,WACCA,cAAY,QAAQ,GAAG;AAE5B,MAAa,qBACZ,GAAG,WACC,OAAO,QAAQ,GAAG;;;;ACCvB,MAAa,6BAAqC,qBACjD,mBAAmB,YAAY,oBAAoB;AAWpD,MAAM,2BAAmC,gBAAsC;CAC9E,MAAM,QAAQ,YAAY;CAE1B,MAAM,iBAAiB,aAA2C,SAAS,OAAO;AAElF,QAAO,OAAO,eAAe;AAE7B,QAAO;;AAGR,MAAa,wBAAgC,qBAC5C,mBACC,wBAAwB,oBACvB"}
1
+ {"version":3,"file":"index.js","names":["createStore"],"sources":["../../../src/zustand/createZustandContext.ts","../../../src/zustand/createZustandStoreWithCombine.ts","../../../src/zustand/createZustandStoreWithSubscribe.ts"],"sourcesContent":["import type { StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createElement } from \"react\";\nimport { type CustomContextOptions, createCustomContext, useStore } from \"../hooks\";\n\nconst createZustandContext = <\n\tTState extends Record<string, unknown>,\n\tTStore extends StoreApi<TState> = StoreApi<TState>,\n>(\n\toptions?: CustomContextOptions<TStore, true>\n) => {\n\tconst [Provider, useCustomContext] = createCustomContext(options);\n\n\ttype ZustandStoreContextProviderProps = {\n\t\tchildren: React.ReactNode;\n\t\tstore: TStore;\n\t};\n\n\tfunction ZustandStoreContextProvider(props: ZustandStoreContextProviderProps) {\n\t\tconst { children, store } = props;\n\n\t\treturn createElement(Provider, { value: store }, children);\n\t}\n\n\tconst useZustandStoreContext = <TResult = TState>(selector?: SelectorFn<TState, TResult>): TResult => {\n\t\tconst zustandStore = useCustomContext();\n\n\t\treturn useStore(zustandStore, selector);\n\t};\n\n\treturn [ZustandStoreContextProvider, useZustandStoreContext] as [\n\t\tZustandStoreContextProvider: typeof ZustandStoreContextProvider,\n\t\tuseZustandStoreContext: typeof useZustandStoreContext,\n\t];\n};\n\nexport { createZustandContext };\n","import type { AnyFunction, AnyObject, Prettify } from \"@zayne-labs/toolkit-type-helpers\";\nimport { create, createStore, type StateCreator, type StoreMutatorIdentifier } from \"zustand\";\n\ntype Write<TInitialState, TExtraState> = Prettify<Omit<TInitialState, keyof TExtraState> & TExtraState>;\n\nexport const combine =\n\t<\n\t\tTInitialState extends AnyObject,\n\t\tTExtraState extends AnyObject,\n\t\tMps extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\t\tMcs extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\t>(\n\t\tinitialState: TInitialState,\n\t\tstoreCreator: StateCreator<TInitialState, Mps, Mcs, TExtraState>\n\t): StateCreator<Write<TInitialState, TExtraState>, Mps, Mcs> =>\n\t// eslint-disable-next-line ts-eslint/no-unsafe-return -- We don't know what the storeCreator will return\n\t(...params) => ({\n\t\t...initialState,\n\t\t...(storeCreator as AnyFunction)(...params),\n\t});\n\nexport const createStoreWithCombine = <TInitialState extends AnyObject, TExtraState extends AnyObject>(\n\t...params: Parameters<typeof combine<TInitialState, TExtraState>>\n) => createStore(combine(...params));\n\nexport const createWithCombine = <TInitialState extends AnyObject, TExtraState extends AnyObject>(\n\t...params: Parameters<typeof combine<TInitialState, TExtraState>>\n) => create(combine(...params));\n","import { createStore, type StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { Mutate, StoreMutatorIdentifier, UseBoundStore } from \"zustand\";\nimport { useStore } from \"../hooks\";\n\ntype Get<T, K, F> = K extends keyof T ? T[K] : F;\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 CreateStoreWithSubscribe = {\n\t<T, Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t): Mutate<StoreApi<T>, Mos>;\n\n\t<T>(): <Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t) => Mutate<StoreApi<T>, Mos>;\n};\n\nexport const createStoreWithSubscribe = (<TState>(stateInitializer: StateCreator<TState> | undefined) =>\n\tstateInitializer ? createStore(stateInitializer) : createStore) as CreateStoreWithSubscribe;\n\ntype CreateWithSubscribe = {\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 createWithSubscribeImpl = <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 createWithSubscribe = (<TState>(stateInitializer: StateCreator<TState> | undefined) =>\n\tstateInitializer ?\n\t\tcreateWithSubscribeImpl(stateInitializer)\n\t:\tcreateWithSubscribeImpl) as CreateWithSubscribe;\n"],"mappings":";;;;;;AAKA,MAAM,wBAIL,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;EACrG,MAAM,eAAe,kBAAkB;AAEvC,SAAO,SAAS,cAAc,SAAS;;AAGxC,QAAO,CAAC,6BAA6B,uBAAuB;;;;;ACzB7D,MAAa,WAOX,cACA,kBAGA,GAAG,YAAY;CACf,GAAG;CACH,GAAI,aAA6B,GAAG,OAAO;CAC3C;AAEF,MAAa,0BACZ,GAAG,WACCA,cAAY,QAAQ,GAAG,OAAO,CAAC;AAEpC,MAAa,qBACZ,GAAG,WACC,OAAO,QAAQ,GAAG,OAAO,CAAC;;;;ACC/B,MAAa,6BAAqC,qBACjD,mBAAmB,YAAY,iBAAiB,GAAG;AAWpD,MAAM,2BAAmC,gBAAsC;CAC9E,MAAM,QAAQ,YAAY,YAAY;CAEtC,MAAM,iBAAiB,aAA2C,SAAS,OAAO,SAAS;AAE3F,QAAO,OAAO,eAAe,MAAM;AAEnC,QAAO;;AAGR,MAAa,wBAAgC,qBAC5C,mBACC,wBAAwB,iBAAiB,GACxC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zayne-labs/toolkit-react",
3
3
  "type": "module",
4
- "version": "0.10.26",
4
+ "version": "0.11.1",
5
5
  "description": "A collection of utility functions, types and composables used by my other projects. Nothing too fancy but can be useful.",
6
6
  "author": "Ryan Zayne",
7
7
  "license": "MIT",
@@ -47,24 +47,24 @@
47
47
  }
48
48
  },
49
49
  "dependencies": {
50
- "@zayne-labs/toolkit-core": "0.10.26",
51
- "@zayne-labs/toolkit-type-helpers": "0.10.26"
50
+ "@zayne-labs/toolkit-core": "0.11.1",
51
+ "@zayne-labs/toolkit-type-helpers": "0.11.1"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@arethetypeswrong/cli": "^0.18.2",
55
- "@changesets/cli": "^2.29.6",
55
+ "@changesets/cli": "^2.29.7",
56
56
  "@size-limit/esbuild-why": "^11.2.0",
57
57
  "@size-limit/preset-small-lib": "^11.2.0",
58
58
  "@total-typescript/ts-reset": "^0.6.1",
59
- "@types/node": "^24.3.1",
60
- "@types/react": "^19.1.12",
61
- "@zayne-labs/tsconfig": "0.9.14",
59
+ "@types/node": "^24.3.3",
60
+ "@types/react": "^19.1.13",
61
+ "@zayne-labs/tsconfig": "0.9.15",
62
62
  "concurrently": "^9.2.1",
63
63
  "cross-env": "^10.0.0",
64
64
  "publint": "^0.3.12",
65
65
  "react": "^19.1.1",
66
66
  "size-limit": "^11.2.0",
67
- "tsdown": "^0.14.2",
67
+ "tsdown": "^0.15.1",
68
68
  "typescript": "5.9.2",
69
69
  "zustand": "^5.0.8"
70
70
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks-Bnw2bN-M.js","names":["useCustomContext: UseCustomContext<TContextValue, TStrict>","useAfterMountEffect: typeof useEffect","useLocationState","useAnimationPresence: UseSpecificPresence","useTransitionPresence: UseSpecificPresence","usePresence: UsePresence","observedElementRef: RefCallback<TElement>","useStorageState"],"sources":["../../src/hooks/createCustomContext.ts","../../src/hooks/useCallbackRef.ts","../../src/hooks/effects/useAfterMountEffect.ts","../../src/hooks/effects/useAsyncEffect.ts","../../src/hooks/effects/useEffectOnce.ts","../../src/hooks/effects/useLifeCycle.ts","../../src/hooks/effects/useMountEffect.ts","../../src/hooks/effects/useUnMountEffect.ts","../../src/hooks/useAnimateElementRefs.ts","../../src/hooks/useAnimationInterval.ts","../../src/hooks/useClickOutside.ts","../../src/hooks/useConstant.ts","../../src/hooks/useCopyToClipboard.ts","../../src/hooks/useDebounce.ts","../../src/hooks/useToggle.ts","../../src/hooks/useDisclosure.ts","../../src/hooks/useIsHydrated.ts","../../src/hooks/useIsServer.ts","../../src/hooks/useStore.ts","../../src/hooks/useLocationState.ts","../../src/hooks/usePresence/useAnimationPresence.ts","../../src/hooks/usePresence/useTransitionPresence.ts","../../src/hooks/usePresence/usePresence.ts","../../src/hooks/useScrollObserver.ts","../../src/hooks/useSearch.ts","../../src/hooks/useSearchParams.ts","../../src/hooks/useShallowCompare.ts","../../src/hooks/useStorageState.ts","../../src/hooks/useThrottle.ts"],"sourcesContent":["import { createContext, use } from \"react\";\n\nexport type CustomContextOptions<TContextValue, TStrict extends boolean> = {\n\tdefaultValue?: TContextValue | null;\n\terrorMessage?: string;\n\textension?: (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\textension,\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 = extension?.(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, useLayoutEffect, useRef } from \"react\";\n\n/**\n * Returns a stable function that always points to the latest version of the callback function.\n * @param callbackFn - The function to reference\n * @returns a stable function that always points to the latest version of the callback function\n */\n\nconst useCallbackRef = <TCallback = AnyFunction>(callbackFn: TCallback | undefined) => {\n\tconst callbackRef = useRef(callbackFn);\n\n\tuseLayoutEffect(() => {\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\treturn savedCallback as TCallback;\n};\n\nexport { useCallbackRef };\n","import { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nconst useAfterMountEffect: typeof useEffect = (callBackFn, deps) => {\n\tconst isFirstMount = useRef(true);\n\tconst stableCallback = useCallbackRef(callBackFn);\n\n\tuseEffect(() => {\n\t\tif (isFirstMount.current) {\n\t\t\tisFirstMount.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\tstableCallback();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableCallback is stable\n\t}, deps);\n};\nexport { useAfterMountEffect };\n","import { useEffect, useState } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nexport function useAsyncEffect(\n\teffect: () => Promise<ReturnType<React.EffectCallback>>,\n\tdeps?: React.DependencyList\n) {\n\tconst stableEffectCallback = useCallbackRef(effect);\n\tconst [destroy, setDestroy] = useState<ReturnType<React.EffectCallback>>();\n\n\tuseEffect(() => {\n\t\tconst e = stableEffectCallback();\n\n\t\tasync function execute() {\n\t\t\tsetDestroy(await e);\n\t\t}\n\n\t\tvoid execute();\n\n\t\treturn () => void destroy?.();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableEffectCallback is stable\n\t}, deps);\n}\n","import { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\n\nconst useEffectOnce = (callBackFn: React.EffectCallback) => {\n\tconst stableCallback = useCallbackRef(callBackFn);\n\n\tconst effectGuard = useRef(false);\n\n\t// == savedCallback is always stable so no worries about re-execution of this effect\n\tuseEffect(() => {\n\t\tif (effectGuard.current) return;\n\n\t\teffectGuard.current = true;\n\n\t\treturn stableCallback();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableCallback is stable\n\t}, []);\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\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableOnMount and stableOnUnmount are stable\n\t}, []);\n};\n\nexport { useLifeCycle };\n","import { useLifeCycle } from \"./useLifeCycle\";\n\nconst useMountEffect = (callBackFn: () => void) => {\n\tuseLifeCycle({ onMount: callBackFn });\n};\n\nexport { useMountEffect };\n","import { type Destructor, useLifeCycle } from \"./useLifeCycle\";\n\nconst useUnmountEffect = (cleanUpFn: Destructor) => useLifeCycle({ onUnmount: cleanUpFn });\n\nexport { useUnmountEffect };\n","import { on } from \"@zayne-labs/toolkit-core\";\nimport { type NonEmptyArray, isArray } 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\treturn { animatedElements: elementsRef.current, handleElementsAnimation };\n};\n\nexport { useAnimateElementRefs };\n","import { type AnimationIntervalOptions, setAnimationInterval } from \"@zayne-labs/toolkit-core\";\nimport type { Prettify } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useEffect, useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype AnimationOptions = Prettify<\n\tAnimationIntervalOptions & {\n\t\tintervalDuration: number | null;\n\t\tonAnimation: () => void;\n\t}\n>;\n\nconst useAnimationInterval = (options: AnimationOptions) => {\n\tconst { intervalDuration, onAnimation, once } = options;\n\n\tconst latestCallback = useCallbackRef(onAnimation);\n\n\tconst { start, stop } = useMemo(\n\t\t() => setAnimationInterval(latestCallback, intervalDuration, { once }),\n\t\t[intervalDuration, latestCallback, once]\n\t);\n\n\tuseEffect(() => {\n\t\tif (intervalDuration === null) return;\n\n\t\tstart();\n\n\t\treturn stop;\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- start and stop are stable\n\t}, [intervalDuration]);\n\n\treturn { start, stop };\n};\n\nexport { useAnimationInterval };\n","import { onClickOutside, toArray } from \"@zayne-labs/toolkit-core\";\nimport { useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype UseClickOutsideOptions<TElement extends HTMLElement> = {\n\tenabled?: boolean;\n\tonClick: (event: MouseEvent | TouchEvent) => void;\n\tref?: Array<React.RefObject<TElement>> | React.RefObject<TElement>;\n};\n\nconst useClickOutside = <TElement extends HTMLElement>(options: UseClickOutsideOptions<TElement>) => {\n\tconst innerRef = useRef<TElement>(null);\n\n\tconst { enabled = true, onClick, ref: refOrRefArray = innerRef } = options;\n\n\tconst savedOnClick = useCallbackRef(onClick);\n\n\tuseEffect(() => {\n\t\tif (!enabled) return;\n\n\t\tconst elementArray = toArray(refOrRefArray).map((ref) => ref.current);\n\n\t\tconst cleanup = onClickOutside(elementArray, savedOnClick);\n\n\t\treturn () => cleanup();\n\t}, [enabled, refOrRefArray, savedOnClick]);\n\n\treturn {\n\t\tref: innerRef,\n\t};\n};\n\nexport { useClickOutside };\n","import { useRef } from \"react\";\n\nexport const useConstant = <TResult>(initCallbackFn: () => 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 = initCallbackFn();\n\t}\n\n\treturn resultRef.current;\n};\n\nexport const useLazyRef = <TResult>(initCallbackFn: () => TResult): React.RefObject<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 = initCallbackFn();\n\t}\n\n\treturn resultRef as React.RefObject<TResult>;\n};\n","import { copyToClipboard } from \"@zayne-labs/toolkit-core\";\nimport { useState } from \"react\";\n\nconst useCopyToClipboard = () => {\n\tconst [state, setState] = useState(\"\");\n\n\tconst handleCopy = (value: string) => {\n\t\tsetState(value);\n\t\tvoid copyToClipboard(value);\n\t};\n\n\treturn { copiedValue: state, handleCopy };\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 { useCallback, useState } from \"react\";\n\ntype InitialState = boolean | (() => boolean);\n\nconst useToggle = (initialValue: InitialState = false) => {\n\tconst [value, setValue] = useState(initialValue);\n\n\tconst toggle = 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, toggle] as const;\n};\n\nexport { useToggle };\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 { useSyncExternalStore } from \"react\";\n\nconst noop = () => {};\n\nconst emptySubscribe = () => noop;\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 */\nexport const useIsHydrated = () => {\n\tconst isHydrated = useSyncExternalStore(\n\t\temptySubscribe,\n\t\t() => true,\n\t\t() => false\n\t);\n\n\treturn isHydrated;\n};\n","import { useSyncExternalStore } from \"react\";\n\nconst noopStore = {\n\tgetServerSnapshot: () => true,\n\tgetSnapshot: () => false,\n\t// eslint-disable-next-line unicorn/consistent-function-scoping -- It's fine\n\tsubscribe: () => () => {},\n};\n\n/**\n * @description Returns whether the component is currently being server side rendered or\n * hydrated on the client. Can be used to delay browser-specific rendering\n * until after hydration.\n */\nconst useIsServer = () => {\n\tconst isServer = useSyncExternalStore(\n\t\tnoopStore.subscribe,\n\t\tnoopStore.getSnapshot,\n\t\tnoopStore.getServerSnapshot\n\t);\n\n\treturn isServer;\n};\n\nexport { useIsServer };\n","import type { StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useDebugValue, useSyncExternalStore } from \"react\";\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 slice = useSyncExternalStore(\n\t\tstore.subscribe,\n\t\tuseCallback(() => selector(store.getState()), [store, selector]),\n\t\tuseCallback(() => selector(store.getInitialState()), [store, selector])\n\t);\n\n\tuseDebugValue(slice);\n\n\treturn slice;\n};\n\nexport { useStore };\n","import {\n\tcreateLocationStore,\n\ttype LocationInfo,\n\ttype LocationStoreApi,\n\ttype LocationStoreOptions,\n} from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useStore } from \"./useStore\";\n\ntype UseLocationResult<TSlice> = [state: TSlice, actions: LocationStoreApi];\n\nexport const createUseLocationState = (options?: LocationStoreOptions) => {\n\tconst locationStore = createLocationStore(options);\n\n\ttype UseBoundLocationState = LocationStoreApi\n\t\t& (<TSlice = LocationInfo>(\n\t\t\tselector?: SelectorFn<LocationInfo, TSlice>\n\t\t) => UseLocationResult<TSlice>);\n\n\tconst useLocationState = <TSlice = LocationInfo>(\n\t\tselector?: SelectorFn<LocationInfo, TSlice>\n\t): UseLocationResult<TSlice> => {\n\t\tconst stateSlice = useStore(locationStore as never, selector);\n\n\t\treturn [stateSlice, locationStore];\n\t};\n\n\tObject.assign(useLocationState, locationStore);\n\n\treturn useLocationState as UseBoundLocationState;\n};\n\nexport const useLocationState = <TSlice = LocationInfo>(\n\tselector?: SelectorFn<LocationInfo, TSlice>,\n\toptions: LocationStoreOptions = {}\n): UseLocationResult<TSlice> => {\n\tconst { equalityFn } = options;\n\n\tconst savedEqualityFn = useCallbackRef(equalityFn);\n\n\tconst locationStore = useMemo(\n\t\t() => createLocationStore({ equalityFn: savedEqualityFn }),\n\t\t[savedEqualityFn]\n\t);\n\n\tconst stateSlice = useStore(locationStore as never, selector);\n\n\treturn [stateSlice, locationStore];\n};\n","import { on } from \"@zayne-labs/toolkit-core\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\nimport { useDebouncedState } from \"../useDebounce\";\nimport type { UseSpecificPresence } from \"./types\";\n\nconst useAnimationPresence: UseSpecificPresence = (options = {}) => {\n\tconst { defaultValue = true, duration, onExitComplete } = options;\n\n\tconst [isShown, setIsShown] = useState(defaultValue);\n\n\tconst [isMounted, setDebouncedIsMounted, setRegularIsMounted] = useDebouncedState(\n\t\tdefaultValue,\n\t\tduration\n\t);\n\tconst elementRef = useRef<HTMLElement>(null);\n\n\tconst stableOnExitComplete = useCallbackRef(onExitComplete);\n\n\tuseEffect(() => {\n\t\t!isMounted && stableOnExitComplete();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableOnExitComplete is stable\n\t}, [isMounted]);\n\n\tconst handleIsMountedWithoutRef = (value: boolean) => {\n\t\tif (value) {\n\t\t\tsetRegularIsMounted(true);\n\t\t\treturn;\n\t\t}\n\n\t\tsetDebouncedIsMounted(false);\n\t};\n\n\tconst handleIsMountedWithRef = (value: boolean) => {\n\t\tif (value) {\n\t\t\tsetRegularIsMounted(true);\n\t\t\treturn;\n\t\t}\n\n\t\ton(\"animationend\", elementRef.current, () => {\n\t\t\tsetDebouncedIsMounted.cancel();\n\t\t\tsetRegularIsMounted(false);\n\t\t});\n\t};\n\n\tconst toggleVisibility = useCallbackRef(<TValue>(newValue?: TValue) => {\n\t\tconst handleSetIsMounted = !duration ? handleIsMountedWithRef : handleIsMountedWithoutRef;\n\n\t\tif (typeof newValue === \"boolean\") {\n\t\t\tsetIsShown(newValue);\n\t\t\thandleSetIsMounted(newValue);\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsShown(!isShown);\n\t\thandleSetIsMounted(!isShown);\n\t});\n\n\treturn {\n\t\tisPresent: isMounted,\n\t\tisVisible: isShown,\n\t\ttoggleVisibility,\n\t\t...(duration === undefined && { elementRef }),\n\t} as never;\n};\n\nexport { useAnimationPresence };\n","import { on } from \"@zayne-labs/toolkit-core\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { useCallbackRef } from \"../useCallbackRef\";\nimport { useDebouncedState } from \"../useDebounce\";\nimport type { UseSpecificPresence } from \"./types\";\n\nconst useTransitionPresence: UseSpecificPresence = (options = {}) => {\n\tconst { defaultValue = true, duration, onExitComplete } = options;\n\n\tconst [isShown, setIsShown] = useState(defaultValue);\n\n\tconst [isMounted, setDebouncedIsMounted, setRegularIsMounted] = useDebouncedState(\n\t\tdefaultValue,\n\t\tduration\n\t);\n\tconst elementRef = useRef<HTMLElement>(null);\n\tconst stableOnExitComplete = useCallbackRef(onExitComplete);\n\n\tconst handleIsMountedWithoutRef = (value: boolean) => {\n\t\tif (value) {\n\t\t\tsetDebouncedIsMounted(value, { $delay: 0 });\n\t\t\treturn;\n\t\t}\n\n\t\tsetDebouncedIsMounted(false);\n\t};\n\n\tconst handleIsMountedWithRef = (value: boolean) => {\n\t\tif (value) {\n\t\t\tsetDebouncedIsMounted(value, { $delay: 0 });\n\t\t\treturn;\n\t\t}\n\n\t\ton(\"transitionend\", elementRef.current, () => {\n\t\t\tsetDebouncedIsMounted.cancel();\n\t\t\tsetRegularIsMounted(false);\n\t\t});\n\t};\n\n\tconst toggleVisibility = useCallbackRef(<TValue>(newValue?: TValue) => {\n\t\tconst handleSetIsMounted = !duration ? handleIsMountedWithRef : handleIsMountedWithoutRef;\n\n\t\tif (typeof newValue === \"boolean\") {\n\t\t\tsetIsShown(newValue);\n\t\t\thandleSetIsMounted(newValue);\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsShown(!isShown);\n\t\thandleSetIsMounted(!isShown);\n\t});\n\n\tuseEffect(() => {\n\t\t!isMounted && stableOnExitComplete();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableOnExitComplete is stable\n\t}, [isMounted]);\n\n\treturn {\n\t\tisPresent: isMounted || isShown,\n\t\tisVisible: isMounted && isShown,\n\t\ttoggleVisibility,\n\t\t...(duration === undefined && { elementRef }),\n\t} as never;\n};\n\nexport { useTransitionPresence };\n","import type { UsePresence } from \"./types\";\nimport { useAnimationPresence } from \"./useAnimationPresence\";\nimport { useTransitionPresence } from \"./useTransitionPresence\";\n\n/**\n * usePresence hook provides a way to animate an element, before removing it from the DOM.\n * @param defaultValue - The default value for the presence state. Defaults to `true`.\n * @param options - The options for the usePresence hook.\n * @returns A object containing the boolean that should be used to conditionally render the element (isPresent), another boolean used to toggle the animation classes, and a function to toggle the state.\n */\n\nconst usePresence: UsePresence = (options = {}) => {\n\tconst { type = \"transition\", ...restOfOptions } = options;\n\n\tconst useSpecificPresence = type === \"transition\" ? useTransitionPresence : useAnimationPresence;\n\n\treturn useSpecificPresence(restOfOptions);\n};\n\nexport { usePresence };\n","import { createScrollObserver, type ScrollObserverOptions } from \"@zayne-labs/toolkit-core\";\nimport { type RefCallback, useMemo, useState } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nconst useScrollObserver = <TElement extends HTMLElement>(options: ScrollObserverOptions = {}) => {\n\tconst { onIntersection, root, rootMargin = \"10px 0px 0px 0px\", threshold } = options;\n\n\tconst [isScrolled, setIsScrolled] = useState(false);\n\n\tconst savedOnIntersection = useCallbackRef(onIntersection);\n\n\tconst { handleObservation } = useMemo(() => {\n\t\treturn createScrollObserver({\n\t\t\tonIntersection: (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\tsavedOnIntersection(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, savedOnIntersection, threshold]);\n\n\tconst observedElementRef: RefCallback<TElement> = useCallbackRef((element) => {\n\t\tconst cleanupFn = handleObservation(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 { 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\ttype LocationStoreOptions,\n\ttype URLSearchParamsInit,\n\tcreateSearchParams,\n} from \"@zayne-labs/toolkit-core\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useLocationState } from \"./useLocationState\";\n\ntype UseSearchParamsOptions = LocationStoreOptions & {\n\taction?: \"push\" | \"replace\";\n};\n\nexport const useSearchParams = <TSearchParams extends URLSearchParamsInit>(\n\toptions?: UseSearchParamsOptions\n) => {\n\tconst { action = \"push\", ...restOfOptions } = options ?? {};\n\n\tconst [searchParams, actions] = useLocationState((state) => state.search, restOfOptions);\n\n\tconst setSearchParams = (\n\t\tnewQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)\n\t) => {\n\t\tconst params = isFunction(newQueryParams) ? newQueryParams(searchParams) : newQueryParams;\n\n\t\tconst nextSearchParams = createSearchParams(params);\n\n\t\tactions[action]({ search: nextSearchParams });\n\t};\n\n\tsetSearchParams.triggerPopstateEvent = actions.triggerPopstateEvent;\n\n\treturn [searchParams, setSearchParams] as const;\n};\n\nexport const useSearchParamsObject = <TSearchParams extends Record<string, string>>(\n\toptions?: UseSearchParamsOptions\n) => {\n\tconst [searchParams, setSearchParams] = 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\tsetSearchParamsObject.triggerPopstateEvent = setSearchParams.triggerPopstateEvent;\n\n\treturn [searchParamsObject, setSearchParamsObject] as const;\n};\n","import { shallowCompare } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useRef } from \"react\";\n\nexport const useShallowComparedSelector = <TState, TResult>(selector: SelectorFn<TState, TResult>) => {\n\tconst prevStateRef = useRef<TResult>(undefined as never);\n\n\tconst shallowSelector = (state: TState) => {\n\t\tconst nextState = selector(state);\n\n\t\tif (shallowCompare(prevStateRef.current, nextState)) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\treturn (prevStateRef.current = nextState);\n\t};\n\n\treturn shallowSelector;\n};\n\nexport const useShallowComparedValue = <TValue>(value: TValue) => {\n\tconst prevValueRef = useRef<TValue>(value);\n\n\tif (shallowCompare(prevValueRef.current, value)) {\n\t\treturn prevValueRef.current;\n\t}\n\n\treturn (prevValueRef.current = value);\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,OACpD;CACJ,MAAM,EACL,eAAe,MACf,cACA,WACA,WAAW,qBACX,eAAe,0BACf,OAAO,aAAa,SAAS,cAAc,aAAa,MAAM,GAAG,MAAM,kBACvE,SAAS,SACN;CAEJ,MAAM,UAAU,cAA6B;AAE7C,SAAQ,cAAc;CAEtB,MAAMA,yBAAmE;EACxE,MAAM,eAAe,IAAI;EAEzB,MAAM,uBAAuB,YAAY,iBAAiB;AAE1D,MAAI,UAAU,yBAAyB,KACtC,OAAM,IAAI,aAAa,gBAAgB,gBAAgB,UAAU;AAGlE,SAAO;;AAGR,QAAO,CAAC,SAAS;;AAMlB,IAAa,eAAb,cAAkC,MAAM;CACvC,AAAS,OAAO;;AAGjB,MAAa,mBAAmB,MAAc,aAAqB;AAClE,QAAO,GAAG,KAAK,2EAA2E,SAAS;;;;;;;;;;AC/CpG,MAAM,kBAA2C,eAAsC;CACtF,MAAM,cAAc,OAAO;AAE3B,uBAAsB;AAErB,cAAY,UAAU;IACpB,CAAC;CAEJ,MAAM,gBAAgB,aAEpB,GAAG,WAAuB,YAAY,UAA0B,GAAG,SACpE;AAGD,QAAO;;;;;ACpBR,MAAMC,uBAAyC,YAAY,SAAS;CACnE,MAAM,eAAe,OAAO;CAC5B,MAAM,iBAAiB,eAAe;AAEtC,iBAAgB;AACf,MAAI,aAAa,SAAS;AACzB,gBAAa,UAAU;AACvB;;AAGD;IAEE;;;;;ACZJ,SAAgB,eACf,QACA,MACC;CACD,MAAM,uBAAuB,eAAe;CA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