@zayne-labs/toolkit-react 0.11.19 → 0.11.21

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.
Files changed (127) hide show
  1. package/dist/esm/hooks/createCustomContext.d.ts +21 -0
  2. package/dist/esm/hooks/createCustomContext.js +25 -0
  3. package/dist/esm/hooks/createCustomContext.js.map +1 -0
  4. package/dist/esm/hooks/effects/useAfterMountEffect.d.ts +7 -0
  5. package/dist/esm/hooks/effects/useAfterMountEffect.js +19 -0
  6. package/dist/esm/hooks/effects/useAfterMountEffect.js.map +1 -0
  7. package/dist/esm/hooks/effects/useAsyncEffect.d.ts +5 -0
  8. package/dist/esm/hooks/effects/useAsyncEffect.js +20 -0
  9. package/dist/esm/hooks/effects/useAsyncEffect.js.map +1 -0
  10. package/dist/esm/hooks/effects/useEffectOnce.d.ts +5 -0
  11. package/dist/esm/hooks/effects/useEffectOnce.js +17 -0
  12. package/dist/esm/hooks/effects/useEffectOnce.js.map +1 -0
  13. package/dist/esm/hooks/effects/useLifeCycle.d.ts +13 -0
  14. package/dist/esm/hooks/effects/useLifeCycle.js +16 -0
  15. package/dist/esm/hooks/effects/useLifeCycle.js.map +1 -0
  16. package/dist/esm/hooks/effects/useMountEffect.d.ts +5 -0
  17. package/dist/esm/hooks/effects/useMountEffect.js +10 -0
  18. package/dist/esm/hooks/effects/useMountEffect.js.map +1 -0
  19. package/dist/esm/hooks/effects/useUnMountEffect.d.ts +7 -0
  20. package/dist/esm/hooks/effects/useUnMountEffect.js +8 -0
  21. package/dist/esm/hooks/effects/useUnMountEffect.js.map +1 -0
  22. package/dist/esm/hooks/index.d.ts +27 -2
  23. package/dist/esm/hooks/index.js +27 -2
  24. package/dist/esm/hooks/useAnimateElementRefs.d.ts +19 -0
  25. package/dist/esm/hooks/useAnimateElementRefs.js +54 -0
  26. package/dist/esm/hooks/useAnimateElementRefs.js.map +1 -0
  27. package/dist/esm/hooks/useAnimationInterval.d.ts +15 -0
  28. package/dist/esm/hooks/useAnimationInterval.js +27 -0
  29. package/dist/esm/hooks/useAnimationInterval.js.map +1 -0
  30. package/dist/esm/hooks/useCallbackRef.d.ts +13 -0
  31. package/dist/esm/hooks/useCallbackRef.js +19 -0
  32. package/dist/esm/hooks/useCallbackRef.js.map +1 -0
  33. package/dist/esm/hooks/useClickOutside.d.ts +14 -0
  34. package/dist/esm/hooks/useClickOutside.js +25 -0
  35. package/dist/esm/hooks/useClickOutside.js.map +1 -0
  36. package/dist/esm/hooks/useComposeRefs.d.ts +8 -0
  37. package/dist/esm/hooks/useComposeRefs.js +11 -0
  38. package/dist/esm/hooks/useComposeRefs.js.map +1 -0
  39. package/dist/esm/hooks/useConstant.d.ts +6 -0
  40. package/dist/esm/hooks/useConstant.js +17 -0
  41. package/dist/esm/hooks/useConstant.js.map +1 -0
  42. package/dist/esm/hooks/useControllable.d.ts +55 -0
  43. package/dist/esm/hooks/useControllable.js +79 -0
  44. package/dist/esm/hooks/useControllable.js.map +1 -0
  45. package/dist/esm/hooks/useCopyToClipboard.d.ts +15 -0
  46. package/dist/esm/hooks/useCopyToClipboard.js +49 -0
  47. package/dist/esm/hooks/useCopyToClipboard.js.map +1 -0
  48. package/dist/esm/hooks/useDebounce.d.ts +23 -0
  49. package/dist/esm/hooks/useDebounce.js +32 -0
  50. package/dist/esm/hooks/useDebounce.js.map +1 -0
  51. package/dist/esm/hooks/useDisclosure.d.ts +14 -0
  52. package/dist/esm/hooks/useDisclosure.js +42 -0
  53. package/dist/esm/hooks/useDisclosure.js.map +1 -0
  54. package/dist/esm/hooks/useIsHydrated.d.ts +28 -0
  55. package/dist/esm/hooks/useIsHydrated.js +39 -0
  56. package/dist/esm/hooks/useIsHydrated.js.map +1 -0
  57. package/dist/esm/hooks/useLocationState.d.ts +17 -0
  58. package/dist/esm/hooks/useLocationState.js +24 -0
  59. package/dist/esm/hooks/useLocationState.js.map +1 -0
  60. package/dist/esm/hooks/useScrollObserver.d.ts +11 -0
  61. package/dist/esm/hooks/useScrollObserver.js +44 -0
  62. package/dist/esm/hooks/useScrollObserver.js.map +1 -0
  63. package/dist/esm/hooks/useSearch.d.ts +12 -0
  64. package/dist/esm/hooks/useSearch.js +40 -0
  65. package/dist/esm/hooks/useSearch.js.map +1 -0
  66. package/dist/esm/hooks/useSearchParams.d.ts +12 -0
  67. package/dist/esm/hooks/useSearchParams.js +36 -0
  68. package/dist/esm/hooks/useSearchParams.js.map +1 -0
  69. package/dist/esm/hooks/useShallowCompare.d.ts +8 -0
  70. package/dist/esm/hooks/useShallowCompare.js +26 -0
  71. package/dist/esm/hooks/useShallowCompare.js.map +1 -0
  72. package/dist/esm/hooks/useStorageState.d.ts +20 -0
  73. package/dist/esm/hooks/useStorageState.js +54 -0
  74. package/dist/esm/hooks/useStorageState.js.map +1 -0
  75. package/dist/esm/hooks/useStore.d.ts +8 -0
  76. package/dist/esm/hooks/useStore.js +13 -0
  77. package/dist/esm/hooks/useStore.js.map +1 -0
  78. package/dist/esm/hooks/useThrottle.d.ts +15 -0
  79. package/dist/esm/hooks/useThrottle.js +27 -0
  80. package/dist/esm/hooks/useThrottle.js.map +1 -0
  81. package/dist/esm/hooks/useToggle.d.ts +6 -0
  82. package/dist/esm/hooks/useToggle.js +18 -0
  83. package/dist/esm/hooks/useToggle.js.map +1 -0
  84. package/dist/esm/utils/composeEventHandlers.d.ts +8 -0
  85. package/dist/esm/utils/composeEventHandlers.js +36 -0
  86. package/dist/esm/utils/composeEventHandlers.js.map +1 -0
  87. package/dist/esm/utils/composeRefs.d.ts +17 -0
  88. package/dist/esm/utils/composeRefs.js +28 -0
  89. package/dist/esm/utils/composeRefs.js.map +1 -0
  90. package/dist/esm/utils/getSlot/getSlot.d.ts +60 -0
  91. package/dist/esm/utils/getSlot/getSlot.js +78 -0
  92. package/dist/esm/utils/getSlot/getSlot.js.map +1 -0
  93. package/dist/esm/utils/getSlotMap/getSlotMap.d.ts +86 -0
  94. package/dist/esm/utils/getSlotMap/getSlotMap.js +87 -0
  95. package/dist/esm/utils/getSlotMap/getSlotMap.js.map +1 -0
  96. package/dist/esm/utils/index.d.ts +8 -1
  97. package/dist/esm/utils/index.js +6 -1
  98. package/dist/esm/utils/mergeProps.d.ts +20 -0
  99. package/dist/esm/utils/mergeProps.js +31 -0
  100. package/dist/esm/utils/mergeProps.js.map +1 -0
  101. package/dist/esm/utils/mergeTwoProps.d.ts +5 -0
  102. package/dist/esm/utils/mergeTwoProps.js +42 -0
  103. package/dist/esm/utils/mergeTwoProps.js.map +1 -0
  104. package/dist/esm/utils/types/common.d.ts +43 -0
  105. package/dist/esm/utils/types/polymorphism.d.ts +13 -0
  106. package/dist/esm/zustand/createReactZustandStore.js +8 -0
  107. package/dist/esm/zustand/createReactZustandStore.js.map +1 -0
  108. package/dist/esm/zustand/createZustandContext.d.ts +13 -0
  109. package/dist/esm/zustand/createZustandContext.js +21 -0
  110. package/dist/esm/zustand/createZustandContext.js.map +1 -0
  111. package/dist/esm/zustand/createZustandStoreWithCombine.d.ts +12 -0
  112. package/dist/esm/zustand/createZustandStoreWithCombine.js +14 -0
  113. package/dist/esm/zustand/createZustandStoreWithCombine.js.map +1 -0
  114. package/dist/esm/zustand/createZustandStoreWithSubscribe.d.ts +17 -0
  115. package/dist/esm/zustand/createZustandStoreWithSubscribe.js +16 -0
  116. package/dist/esm/zustand/createZustandStoreWithSubscribe.js.map +1 -0
  117. package/dist/esm/zustand/index.d.ts +4 -38
  118. package/dist/esm/zustand/index.js +4 -42
  119. package/dist/esm/zustand/types.d.ts +20 -0
  120. package/package.json +11 -16
  121. package/dist/esm/hooks-iZivekUZ.js +0 -635
  122. package/dist/esm/hooks-iZivekUZ.js.map +0 -1
  123. package/dist/esm/index-DlScRgBk.d.ts +0 -228
  124. package/dist/esm/index-ouFKofvj.d.ts +0 -293
  125. package/dist/esm/utils-Bvs8tFDM.js +0 -279
  126. package/dist/esm/utils-Bvs8tFDM.js.map +0 -1
  127. package/dist/esm/zustand/index.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks-iZivekUZ.js","names":["useCustomContext: UseCustomContext<TContextValue, TStrict>","useAfterMountEffect: typeof useEffect","setValue: StateSetter<TValue>","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/useComposeRefs.ts","../../src/hooks/useConstant.ts","../../src/hooks/useControllable.ts","../../src/hooks/useToggle.ts","../../src/hooks/useCopyToClipboard.ts","../../src/hooks/useDebounce.ts","../../src/hooks/useDisclosure.ts","../../src/hooks/useIsHydrated.ts","../../src/hooks/useStore.ts","../../src/hooks/useLocationState.ts","../../src/hooks/useScrollObserver.ts","../../src/hooks/useSearch.ts","../../src/hooks/useSearchParams.ts","../../src/hooks/useShallowCompare.ts","../../src/hooks/useStorageState.ts","../../src/hooks/useThrottle.ts"],"sourcesContent":["import { createContext, use } from \"react\";\n\nexport type CustomContextOptions<TContextValue, TStrict extends boolean> = {\n\tdefaultValue?: TContextValue | null;\n\terrorMessage?: string;\n\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, useInsertionEffect, 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\tuseInsertionEffect(() => {\n\t\t// == Doing this instead updating it during render cuz according to Dan Abramov, render should be pure\n\t\tcallbackRef.current = callbackFn;\n\t}, [callbackFn]);\n\n\tconst savedCallback = useCallback(\n\t\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- callbackRef.current can be null in some cases\n\t\t(...params: unknown[]) => (callbackRef.current as AnyFunction)?.(...params) as unknown,\n\t\t[]\n\t);\n\n\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 effectGuardRef = useRef(false);\n\n\t// == savedCallback is always stable so no worries about re-execution of this effect\n\tuseEffect(() => {\n\t\tif (effectGuardRef.current) return;\n\n\t\teffectGuardRef.current = true;\n\n\t\treturn stableCallback();\n\t\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 { useMemo } from \"react\";\nimport { composeRefs, type PossibleRef } from \"@/utils\";\n\nconst useComposeRefs = <TRef extends HTMLElement>(...refs: Array<PossibleRef<TRef>>) => {\n\t// eslint-disable-next-line react-hooks/exhaustive-deps -- Allow\n\tconst mergedRef = useMemo(() => composeRefs(...refs), refs);\n\n\treturn mergedRef;\n};\n\nexport { useComposeRefs };\n","import { useRef } from \"react\";\n\nexport const useConstant = <TResult>(initFn: () => TResult): TResult => {\n\tconst resultRef = useRef<TResult | null>(null);\n\n\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- The current case is justified since it's optimizable by the react compiler\n\tif (resultRef.current === null) {\n\t\tresultRef.current = initFn();\n\t}\n\n\treturn resultRef.current;\n};\n\nexport const useLazyRef = <TResult>(initFn: () => TResult): React.RefObject<TResult> => {\n\tconst resultRef = useRef<TResult>(null as never);\n\n\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- The current case is justified since it's optimizable by the react compiler\n\tif (resultRef.current === null) {\n\t\tresultRef.current = initFn();\n\t}\n\n\treturn resultRef;\n};\n","\"use client\";\n\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport type { StateSetter } from \"@/utils\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype UseControllablePropOptions<TProp> = {\n\tprop: TProp | undefined;\n\tstate: TProp;\n};\n\n/**\n * @description Given a prop value and state value, the useControllableProp hook is used to determine whether a component is controlled or uncontrolled, and also returns the computed value.\n */\nexport const useControllableProp = <TProp>(options: UseControllablePropOptions<TProp>) => {\n\tconst { prop, state } = options;\n\n\tconst isControlled = prop !== undefined;\n\n\tconst value = isControlled ? prop : state;\n\n\tconst result = useMemo<[isControlled: typeof isControlled, value: typeof value]>(\n\t\t() => [isControlled, value],\n\t\t[isControlled, value]\n\t);\n\n\treturn result;\n};\n\ntype UseControllableStateOptions<TValue> = {\n\tdefaultValue?: TValue | (() => TValue);\n\tequalityFn?: (prevState: TValue, nextValue: TValue) => boolean;\n\tonChange?: (value: TValue) => void;\n\tvalue?: TValue;\n};\n\n/**\n * @description React hook to manage state that can be either controlled or uncontrolled.\n * - When `options.value` is provided, the hook operates in controlled mode.\n * In this mode, `value` always equals `options.value` and `setValue` will\n * invoke `options.onChange(next)` without mutating internal state.\n * - When `options.value` is not provided, the hook operates in uncontrolled\n * mode, initializing internal state from `options.defaultValue` and updating\n * it via `setValue`.\n * - All updates are gated by `options.equalityFn(prev, next)` which defaults\n * to `Object.is`.\n *\n * @param options - Configuration options for the hook.\n * @param options.value - Controlled value. If defined, the state is controlled.\n * @param options.defaultValue - Initial value for the uncontrolled state. Can be a\n * function for lazy initialization or a direct value.\n * @param options.onChange - Callback fired when a new value is requested. In\n * controlled mode, this is invoked instead of updating internal state. In\n * uncontrolled mode, it is called after the internal state updates.\n * @param options.equalityFn - Predicate that decides whether to commit an\n * update given `prevState` and `nextValue`. If the values are equal, the update\n * is skipped. Defaults to `Object.is`.\n * @returns A tuple `[value, setValue]` just like React.useState.\n *\n * @example\n * // Uncontrolled usage\n * const [value, setValue] = useControllableState({ defaultValue: 0 });\n *\n * @example\n * // Controlled usage\n * const [value, setValue] = useControllableState({\n * value: props.value,\n * onChange: props.onChange,\n * });\n */\nexport const useControllableState = <TValue>(options: UseControllableStateOptions<TValue>) => {\n\tconst { defaultValue, equalityFn = Object.is, onChange: onChangeProp, value: valueProp } = options;\n\n\tconst savedOnchangeProp = useCallbackRef(onChangeProp);\n\tconst savedEqualityFn = useCallbackRef(equalityFn);\n\n\tconst [unControlledState, setUncontrolledState] = useState(defaultValue as TValue);\n\n\tconst isControlled = valueProp !== undefined;\n\n\tconst currentValue = isControlled ? valueProp : unControlledState;\n\n\tconst setValue: StateSetter<TValue> = useCallback(\n\t\t(newValue) => {\n\t\t\tconst nextValue = isFunction(newValue) ? newValue(currentValue) : newValue;\n\n\t\t\tif (savedEqualityFn(currentValue, nextValue)) return;\n\n\t\t\tif (isControlled) {\n\t\t\t\tsavedOnchangeProp(nextValue);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetUncontrolledState(nextValue);\n\t\t\t// == Always call onChangeProp even if the value is uncontrolled, just in case the onChangeProp is used to perform side effects without necessarily updating the controlled valueProp\n\t\t\tsavedOnchangeProp(nextValue);\n\t\t},\n\t\t[isControlled, savedOnchangeProp, savedEqualityFn, currentValue]\n\t);\n\n\treturn [currentValue, setValue] as [value: typeof currentValue, setValue: typeof setValue];\n};\n","import { useCallback, useState } from \"react\";\n\ntype InitialState = boolean | (() => boolean);\n\nconst useToggle = (initialValue: InitialState = false) => {\n\tconst [value, setValue] = useState(initialValue);\n\n\tconst toggleValue = useCallback(<TValue>(newValue?: TValue) => {\n\t\tif (typeof newValue === \"boolean\") {\n\t\t\tsetValue(newValue);\n\t\t\treturn;\n\t\t}\n\n\t\tsetValue((prev) => !prev);\n\t}, []);\n\n\treturn [value, toggleValue] as [value: typeof value, toggleValue: typeof toggleValue];\n};\n\nexport { useToggle };\n","import {\n\ttype AllowedClipboardItems,\n\ttype CopyToClipboardOptions,\n\tcopyToClipboard,\n} from \"@zayne-labs/toolkit-core\";\nimport { useCallback, useRef, useState } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useToggle } from \"./useToggle\";\n\nconst useCopyToClipboard = (options: CopyToClipboardOptions & { timeout?: number } = {}) => {\n\tconst { mimeType, onCopied, onError, onSuccess, timeout = 1500 } = options;\n\n\tconst [value, setValue] = useState<AllowedClipboardItems>(\"\");\n\n\tconst [hasCopied, toggleHasCopied] = useToggle(false);\n\tconst timeoutRef = useRef<number | null>(null);\n\n\tconst savedOnError = useCallbackRef(onError);\n\tconst savedOnSuccess = useCallbackRef(onSuccess);\n\tconst savedOnCopied = useCallbackRef(onCopied);\n\n\tconst handleHasCopied = useCallback(() => {\n\t\ttoggleHasCopied(true);\n\n\t\ttimeoutRef.current && clearTimeout(timeoutRef.current);\n\n\t\ttimeoutRef.current = setTimeout(() => {\n\t\t\ttoggleHasCopied(false);\n\t\t}, timeout) as never;\n\t}, [toggleHasCopied, timeout]);\n\n\tconst handleCopy = useCallback(\n\t\t(valueToCopy: AllowedClipboardItems) => {\n\t\t\tsetValue(valueToCopy);\n\n\t\t\tvoid copyToClipboard(valueToCopy, {\n\t\t\t\tmimeType,\n\t\t\t\tonCopied: () => {\n\t\t\t\t\tsavedOnCopied();\n\t\t\t\t\thandleHasCopied();\n\t\t\t\t},\n\t\t\t\tonError: savedOnError,\n\t\t\t\tonSuccess: savedOnSuccess,\n\t\t\t});\n\t\t},\n\t\t[handleHasCopied, mimeType, savedOnCopied, savedOnError, savedOnSuccess]\n\t);\n\n\treturn { handleCopy, hasCopied, setValue, value };\n};\n\nexport { useCopyToClipboard };\n","import { debounce } from \"@zayne-labs/toolkit-core\";\nimport type { CallbackFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo, useState } from \"react\";\nimport { useUnmountEffect } from \"./effects/useUnMountEffect\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nexport const useDebouncedFn = <TParams>(callBackFn: CallbackFn<TParams>, delay: number | undefined) => {\n\tconst latestCallback = useCallbackRef(callBackFn);\n\n\tconst debouncedFn = useMemo(() => debounce(latestCallback, delay), [delay, latestCallback]);\n\n\tuseUnmountEffect(() => {\n\t\tdebouncedFn.cancel();\n\t\tdebouncedFn.cancelMaxWait();\n\t});\n\n\treturn debouncedFn;\n};\n\nexport const useDebouncedState = <TValue>(defaultValue: TValue, delay: number | undefined) => {\n\tconst [value, setValue] = useState(defaultValue);\n\n\tconst setDebouncedValue = useMemo(() => debounce(setValue, delay), [delay]);\n\n\tuseUnmountEffect(() => {\n\t\tsetDebouncedValue.cancel();\n\t\tsetDebouncedValue.cancelMaxWait();\n\t});\n\n\treturn [value, setDebouncedValue, setValue] as const;\n};\n","import { lockScroll } from \"@zayne-labs/toolkit-core\";\nimport { isBoolean } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useToggle } from \"./useToggle\";\n\ntype DisclosureOptions = {\n\thasScrollControl?: boolean;\n\tinitialState?: boolean | (() => boolean);\n};\n\nconst useDisclosure = (options: DisclosureOptions = {}) => {\n\tconst { hasScrollControl = false, initialState = false } = options;\n\tconst [isOpen, toggleIsOpen] = useToggle(initialState);\n\n\tconst onOpen = useCallbackRef(() => {\n\t\ttoggleIsOpen(true);\n\t\thasScrollControl && lockScroll({ lock: true });\n\t});\n\n\tconst onClose = useCallbackRef(() => {\n\t\ttoggleIsOpen(false);\n\t\thasScrollControl && lockScroll({ lock: false });\n\t});\n\n\tconst onToggle = useCallbackRef(<TValue>(value?: TValue) => {\n\t\tif (isBoolean(value)) {\n\t\t\ttoggleIsOpen(value);\n\t\t\thasScrollControl && lockScroll({ lock: value });\n\t\t\treturn;\n\t\t}\n\n\t\tisOpen ? onClose() : onOpen();\n\t});\n\n\tconst api = useMemo(() => ({ isOpen, onClose, onOpen, onToggle }), [isOpen, onClose, onOpen, onToggle]);\n\n\treturn api;\n};\nexport { useDisclosure };\n","import { useSyncExternalStore } from \"react\";\n\nconst noop = () => {};\n\nconst noopStore = {\n\tgetServerSnapshot: () => true,\n\tgetSnapshot: () => false,\n\tsubscribe: () => noop,\n};\n\n/**\n * @description Return a boolean indicating if the JS has been hydrated already.\n * When doing Server-Side Rendering, the result will always be false.\n * When doing Client-Side Rendering, the result will always be false on the\n * first render and true from then on. Even if a new component renders it will\n * always start with true.\n *\n * @see https://github.com/sergiodxa/remix-utils/blob/main/src/react/use-hydrated.ts\n *\n * @see https://github.com/sergiodxa/remix-utils/blob/main/src/react/use-hydrated.ts\n *\n * @example\n * **Example: Disable a button that needs JS to work.**\n * ```tsx\n * const isHydrated = useIsHydrated();\n *\n * return (\n * <button type=\"button\" disabled={!isHydrated} onClick={doSomethingCustom}>\n * Click me\n * </button>\n * );\n * ```\n */\nconst useIsHydrated = () => {\n\tconst isHydrated = useSyncExternalStore(\n\t\tnoopStore.subscribe,\n\t\tnoopStore.getSnapshot,\n\t\tnoopStore.getServerSnapshot\n\t);\n\n\treturn isHydrated;\n};\n\nexport { useIsHydrated };\n","import type { StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useDebugValue, 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\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\nexport const useShallowCompSelector = <TState, TResult>(\n\tselector: SelectorFn<TState, TResult> | undefined\n) => {\n\tconst prevStateRef = useRef<TResult>(undefined as never);\n\n\tconst shallowSelector = useCallbackRef((state: TState) => {\n\t\tconst nextState = selector?.(state);\n\n\t\tif (!nextState) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\tif (shallowCompare(prevStateRef.current, nextState)) {\n\t\t\treturn prevStateRef.current;\n\t\t}\n\n\t\treturn (prevStateRef.current = nextState);\n\t});\n\n\treturn shallowSelector;\n};\n\nexport const useShallowCompValue = <TValue>(value: TValue) => {\n\tconst prevValueRef = useRef<TValue>(value);\n\n\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;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} from "react";
3
- import { AnyFunction, AnyObject, CallbackFn, EmptyObject, Prettify, UnionDiscriminator, UnionToIntersection, UnknownObject } from "@zayne-labs/toolkit-type-helpers";
4
-
5
- //#region src/utils/composeEventHandlers.d.ts
6
- declare const composeTwoEventHandlers: (formerHandler: AnyFunction | undefined, latterHandler: AnyFunction | undefined) => (event: unknown) => unknown;
7
- declare const composeEventHandlers: (...eventHandlerArray: Array<AnyFunction | undefined>) => (event: unknown) => unknown;
8
- //#endregion
9
- //#region src/utils/composeRefs.d.ts
10
- type PossibleRef<TRef extends HTMLElement> = React.Ref<TRef> | undefined;
11
- /**
12
- * @description Set a given ref to a given value.
13
- *
14
- * This utility takes care of different types of refs: callback refs and RefObject(s)
15
- */
16
- declare const setRef: <TRef extends HTMLElement>(ref: PossibleRef<TRef>, node: TRef | null) => ReturnType<RefCallback<TRef>>;
17
- /**
18
- * @description A utility to combine refs. Accepts callback refs and RefObject(s)
19
- */
20
- declare const composeRefs: <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) => react13.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[]) => react13.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>;
158
- //#endregion
159
- //#region src/utils/mergeProps.d.ts
160
- type UnionToIntersection$1<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : "") extends ((param: infer TParam) => void) ? TParam : "";
161
- /**
162
- * Merges multiple sets of React props.
163
- *
164
- * - It follows the Object.assign pattern where the rightmost object's fields overwrite
165
- * the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.
166
- * - Event handlers are merged such that they are called in sequence (the rightmost one being called first),
167
- * and allows the user to prevent the previous event handlers from being executed by calling the `preventDefault` method.
168
- * - It also merges the `className` and `style` props, whereby the classes are concatenated
169
- * and the rightmost styles overwrite the previous ones.
170
- *
171
- * @important **`ref` is not merged.**
172
- * @param props props to merge.
173
- * @returns the merged props.
174
- */
175
- declare const mergeProps: <TProps extends Record<never, never>>(...propsObjectArray: Array<TProps | undefined>) => UnionToIntersection$1<TProps>;
176
- //#endregion
177
- //#region src/utils/mergeTwoProps.d.ts
178
- declare const mergeTwoProps: <TProps extends Record<never, never>>(formerProps: TProps | undefined, latterProps: TProps | undefined) => TProps;
179
- //#endregion
180
- //#region src/utils/types/common.d.ts
181
- type ValidElementType = HTMLElement | React.ElementType;
182
- type ForwardedRefType<TElement extends ValidElementType> = TElement extends React.ElementType ? React.ForwardedRef<React.Ref<TElement>> : React.ForwardedRef<TElement>;
183
- type InferProps<TElement extends ValidElementType> = TElement extends React.ElementType ? React.ComponentProps<TElement> : React.HTMLAttributes<TElement>;
184
- type RemoveStringSignature<TObject extends object> = { [Key in keyof TObject as string extends Key ? never : Key]: TObject[Key] };
185
- type InferPropsStrict<TElement extends ValidElementType> = RemoveStringSignature<InferProps<TElement>>;
186
- type StateSetter<TSetter = unknown> = React.Dispatch<React.SetStateAction<TSetter>>;
187
- type CssWithCustomProperties<TExtra extends Record<string, string> = NonNullable<unknown>> = React.CSSProperties & Record<`--${string}`, string> & TExtra;
188
- type DefaultRenderItemErrorMessages = {
189
- children: "Hey, Sorry but the children prop is redundant since you're currently using the render prop to do the same thing";
190
- renderItem: "Hey, Sorry but the renderItem prop is redundant since you're currently using the children prop to do the same thing";
191
- };
192
- /**
193
- * @description Represents a set of props that can be used to render a component conditionally based on a discriminated union type.
194
- * This type allows for the use of either a render prop or children prop, but not both at the same time.
195
- * If both are provided, a TypeScript error will be thrown.
196
- * @template TErrorMessages An object of custom messages to display on the disallowed property.
197
- */
198
- type DiscriminatedRenderItemProps<TRenderItemPropType, TErrorMessages extends Record<keyof DefaultRenderItemErrorMessages, string> = DefaultRenderItemErrorMessages> = UnionDiscriminator<[{
199
- children: TRenderItemPropType;
200
- }, {
201
- renderItem: TRenderItemPropType;
202
- }], TErrorMessages>;
203
- type DefaultRenderErrorMessages = {
204
- children: "Hey, Sorry but the children prop is redundant since you're currently using the render prop to do the same thing";
205
- render: "Hey, Sorry but the render prop is redundant since you're currently using the children prop to do the same thing";
206
- };
207
- /**
208
- * @description Represents a set of props that can be used to render a component conditionally based on a discriminated union type.
209
- * This type allows for the use of either a render prop or children prop, but not both at the same time.
210
- * If both are provided, a TypeScript error will be thrown.
211
- * @template TErrorMessages An object of custom messages to display on the disallowed property.
212
- */
213
- type DiscriminatedRenderProps<TRenderPropType, TErrorMessages extends Record<keyof DefaultRenderErrorMessages, string> = DefaultRenderErrorMessages> = UnionDiscriminator<[{
214
- children: TRenderPropType;
215
- }, {
216
- render: TRenderPropType;
217
- }], TErrorMessages>;
218
- //#endregion
219
- //#region src/utils/types/polymorphism.d.ts
220
- type AsProp<TElement extends React.ElementType> = {
221
- as?: TElement;
222
- };
223
- type MergedGivenPropsWithAs<TElement extends React.ElementType, TProps> = Omit<AsProp<TElement>, keyof TProps> & TProps;
224
- type PolymorphicProps<TElement extends React.ElementType, TProps extends AnyObject = NonNullable<unknown>> = MergedGivenPropsWithAs<TElement, TProps> & Omit<InferProps<TElement>, keyof TProps>;
225
- type PolymorphicPropsStrict<TElement extends React.ElementType, TProps extends AnyObject = NonNullable<unknown>> = MergedGivenPropsWithAs<TElement, TProps> & Omit<InferPropsStrict<TElement>, keyof TProps>;
226
- //#endregion
227
- export { AsProp, CssWithCustomProperties, DefaultRenderErrorMessages, DefaultRenderItemErrorMessages, DiscriminatedRenderItemProps, DiscriminatedRenderProps, ForwardedRefType, FunctionalComponent, GetSlotComponentProps, GetSlotMapResult, InferProps, InferPropsStrict, PolymorphicProps, PolymorphicPropsStrict, PossibleRef, StateSetter, composeEventHandlers, composeRefs, composeTwoEventHandlers, createSlotComponent, getMultipleSlots, getRegularChildren, getSingleSlot, getSlotMap, matchesAnySlotComponent, matchesSlotComponent, mergeProps, mergeTwoProps, setRef, slotComponentSymbol, withSlotNameAndSymbol };
228
- //# sourceMappingURL=index-DlScRgBk.d.ts.map
@@ -1,293 +0,0 @@
1
- import { PossibleRef, StateSetter } from "./index-DlScRgBk.js";
2
- import * as react1 from "react";
3
- import { RefCallback, useEffect } from "react";
4
- import * as _zayne_labs_toolkit_core0 from "@zayne-labs/toolkit-core";
5
- import { AllowedClipboardItems, AnimationIntervalOptions, CopyToClipboardOptions, LocationInfo, LocationStoreApi, LocationStoreOptions, ScrollObserverOptions, StorageOptions, StorageStoreApi, StoreApi, URLSearchParamsInit } from "@zayne-labs/toolkit-core";
6
- import { AnyFunction, CallbackFn, NonEmptyArray, Prettify, SelectorFn } from "@zayne-labs/toolkit-type-helpers";
7
-
8
- //#region src/hooks/createCustomContext.d.ts
9
- type CustomContextOptions<TContextValue, TStrict extends boolean> = {
10
- defaultValue?: TContextValue | null;
11
- errorMessage?: string;
12
- extension?: (contextValue: NoInfer<TContextValue> | null) => TContextValue | null;
13
- hookName?: string;
14
- name?: string;
15
- providerName?: string;
16
- strict?: TStrict;
17
- };
18
- type UseCustomContext<TContextValue, TStrict extends boolean> = () => TStrict extends true ? TContextValue : TContextValue | null;
19
- declare const createCustomContext: <TContextValue = null, TStrict extends boolean = true>(options?: CustomContextOptions<TContextValue, TStrict>) => [Provider: react1.Context<TContextValue>, useCustomContext: UseCustomContext<TContextValue, TStrict>];
20
- declare class ContextError extends Error {
21
- name: string;
22
- }
23
- declare const getErrorMessage: (hook: string, provider: string) => string;
24
- //#endregion
25
- //#region src/hooks/effects/useAfterMountEffect.d.ts
26
- declare const useAfterMountEffect: typeof useEffect;
27
- //#endregion
28
- //#region src/hooks/effects/useAsyncEffect.d.ts
29
- declare function useAsyncEffect(effect: () => Promise<ReturnType<React.EffectCallback>>, deps?: React.DependencyList): void;
30
- //#endregion
31
- //#region src/hooks/effects/useEffectOnce.d.ts
32
- declare const useEffectOnce: (callBackFn: React.EffectCallback) => void;
33
- //#endregion
34
- //#region src/hooks/effects/useLifeCycle.d.ts
35
- type Destructor = ReturnType<React.EffectCallback>;
36
- type LifeCycleOptions = {
37
- onMount?: () => void;
38
- onUnmount?: Destructor;
39
- };
40
- declare const useLifeCycle: ({
41
- onMount,
42
- onUnmount
43
- }: LifeCycleOptions) => void;
44
- //#endregion
45
- //#region src/hooks/effects/useMountEffect.d.ts
46
- declare const useMountEffect: (callBackFn: () => void) => void;
47
- //#endregion
48
- //#region src/hooks/effects/useUnMountEffect.d.ts
49
- declare const useUnmountEffect: (cleanUpFn: Destructor) => void;
50
- //#endregion
51
- //#region src/hooks/useAnimateElementRefs.d.ts
52
- type ElementsInfoArray<TTargetElement extends string> = NonEmptyArray<{
53
- animationClass: string;
54
- targetElement: TTargetElement;
55
- }>;
56
- /**
57
- * This is a custom React hook that adds and removes animation classes to specified HTML elements.
58
- * @param elementsInfoArray - An array of objects that contain information about the animation class and the target HTML element.
59
- * @returns - An object containing the refs of the animated elements and a function to handle the initiation and removal animation.
60
- */
61
- declare const useAnimateElementRefs: <TTargetElement extends string>(elementsInfoArray: ElementsInfoArray<TTargetElement>) => {
62
- animatedElements: Record<TTargetElement, HTMLElement | null>;
63
- handleElementsAnimation: () => void;
64
- };
65
- //#endregion
66
- //#region src/hooks/useAnimationInterval.d.ts
67
- type AnimationOptions = Prettify<AnimationIntervalOptions & {
68
- intervalDuration: number | null;
69
- onAnimation: () => void;
70
- }>;
71
- declare const useAnimationInterval: (options: AnimationOptions) => {
72
- start: () => void;
73
- stop: () => void;
74
- };
75
- //#endregion
76
- //#region src/hooks/useCallbackRef.d.ts
77
- /**
78
- * Returns a stable function that always points to the latest version of the callback function.
79
- * @param callbackFn - The function to reference
80
- * @returns a stable function that always points to the latest version of the callback function
81
- */
82
- declare const useCallbackRef: <TCallback = AnyFunction>(callbackFn: TCallback | undefined) => TCallback;
83
- //#endregion
84
- //#region src/hooks/useClickOutside.d.ts
85
- type UseClickOutsideOptions<TElement extends HTMLElement> = {
86
- enabled?: boolean;
87
- onClick: (event: MouseEvent | TouchEvent) => void;
88
- ref?: Array<React.RefObject<TElement>> | React.RefObject<TElement>;
89
- };
90
- declare const useClickOutside: <TElement extends HTMLElement>(options: UseClickOutsideOptions<TElement>) => {
91
- ref: react1.RefObject<TElement | null>;
92
- };
93
- //#endregion
94
- //#region src/hooks/useComposeRefs.d.ts
95
- declare const useComposeRefs: <TRef extends HTMLElement>(...refs: Array<PossibleRef<TRef>>) => react1.RefCallback<TRef>;
96
- //#endregion
97
- //#region src/hooks/useConstant.d.ts
98
- declare const useConstant: <TResult>(initFn: () => TResult) => TResult;
99
- declare const useLazyRef: <TResult>(initFn: () => TResult) => React.RefObject<TResult>;
100
- //#endregion
101
- //#region src/hooks/useControllable.d.ts
102
- type UseControllablePropOptions<TProp> = {
103
- prop: TProp | undefined;
104
- state: TProp;
105
- };
106
- /**
107
- * @description Given a prop value and state value, the useControllableProp hook is used to determine whether a component is controlled or uncontrolled, and also returns the computed value.
108
- */
109
- declare const useControllableProp: <TProp>(options: UseControllablePropOptions<TProp>) => [isControlled: boolean, value: TProp];
110
- type UseControllableStateOptions<TValue> = {
111
- defaultValue?: TValue | (() => TValue);
112
- equalityFn?: (prevState: TValue, nextValue: TValue) => boolean;
113
- onChange?: (value: TValue) => void;
114
- value?: TValue;
115
- };
116
- /**
117
- * @description React hook to manage state that can be either controlled or uncontrolled.
118
- * - When `options.value` is provided, the hook operates in controlled mode.
119
- * In this mode, `value` always equals `options.value` and `setValue` will
120
- * invoke `options.onChange(next)` without mutating internal state.
121
- * - When `options.value` is not provided, the hook operates in uncontrolled
122
- * mode, initializing internal state from `options.defaultValue` and updating
123
- * it via `setValue`.
124
- * - All updates are gated by `options.equalityFn(prev, next)` which defaults
125
- * to `Object.is`.
126
- *
127
- * @param options - Configuration options for the hook.
128
- * @param options.value - Controlled value. If defined, the state is controlled.
129
- * @param options.defaultValue - Initial value for the uncontrolled state. Can be a
130
- * function for lazy initialization or a direct value.
131
- * @param options.onChange - Callback fired when a new value is requested. In
132
- * controlled mode, this is invoked instead of updating internal state. In
133
- * uncontrolled mode, it is called after the internal state updates.
134
- * @param options.equalityFn - Predicate that decides whether to commit an
135
- * update given `prevState` and `nextValue`. If the values are equal, the update
136
- * is skipped. Defaults to `Object.is`.
137
- * @returns A tuple `[value, setValue]` just like React.useState.
138
- *
139
- * @example
140
- * // Uncontrolled usage
141
- * const [value, setValue] = useControllableState({ defaultValue: 0 });
142
- *
143
- * @example
144
- * // Controlled usage
145
- * const [value, setValue] = useControllableState({
146
- * value: props.value,
147
- * onChange: props.onChange,
148
- * });
149
- */
150
- declare const useControllableState: <TValue>(options: UseControllableStateOptions<TValue>) => [value: TValue, setValue: StateSetter<TValue>];
151
- //#endregion
152
- //#region src/hooks/useCopyToClipboard.d.ts
153
- declare const useCopyToClipboard: (options?: CopyToClipboardOptions & {
154
- timeout?: number;
155
- }) => {
156
- handleCopy: (valueToCopy: AllowedClipboardItems) => void;
157
- hasCopied: boolean;
158
- setValue: react1.Dispatch<react1.SetStateAction<AllowedClipboardItems>>;
159
- value: AllowedClipboardItems;
160
- };
161
- //#endregion
162
- //#region src/hooks/useDebounce.d.ts
163
- declare const useDebouncedFn: <TParams>(callBackFn: CallbackFn<TParams>, delay: number | undefined) => {
164
- (...params: TParams[]): void;
165
- (params: TParams | TParams[], overrideOptions: {
166
- $delay: number;
167
- }): void;
168
- cancel: () => void;
169
- cancelMaxWait(): void;
170
- };
171
- declare const useDebouncedState: <TValue>(defaultValue: TValue, delay: number | undefined) => readonly [TValue, {
172
- (...params: react1.SetStateAction<TValue>[]): void;
173
- (params: react1.SetStateAction<TValue> | react1.SetStateAction<TValue>[], overrideOptions: {
174
- $delay: number;
175
- }): void;
176
- cancel: () => void;
177
- cancelMaxWait(): void;
178
- }, react1.Dispatch<react1.SetStateAction<TValue>>];
179
- //#endregion
180
- //#region src/hooks/useDisclosure.d.ts
181
- type DisclosureOptions = {
182
- hasScrollControl?: boolean;
183
- initialState?: boolean | (() => boolean);
184
- };
185
- declare const useDisclosure: (options?: DisclosureOptions) => {
186
- isOpen: boolean;
187
- onClose: () => void;
188
- onOpen: () => void;
189
- onToggle: <TValue>(value?: TValue) => void;
190
- };
191
- //#endregion
192
- //#region src/hooks/useIsHydrated.d.ts
193
- /**
194
- * @description Return a boolean indicating if the JS has been hydrated already.
195
- * When doing Server-Side Rendering, the result will always be false.
196
- * When doing Client-Side Rendering, the result will always be false on the
197
- * first render and true from then on. Even if a new component renders it will
198
- * always start with true.
199
- *
200
- * @see https://github.com/sergiodxa/remix-utils/blob/main/src/react/use-hydrated.ts
201
- *
202
- * @see https://github.com/sergiodxa/remix-utils/blob/main/src/react/use-hydrated.ts
203
- *
204
- * @example
205
- * **Example: Disable a button that needs JS to work.**
206
- * ```tsx
207
- * const isHydrated = useIsHydrated();
208
- *
209
- * return (
210
- * <button type="button" disabled={!isHydrated} onClick={doSomethingCustom}>
211
- * Click me
212
- * </button>
213
- * );
214
- * ```
215
- */
216
- declare const useIsHydrated: () => boolean;
217
- //#endregion
218
- //#region src/hooks/useLocationState.d.ts
219
- type UseLocationResult<TSlice> = [state: TSlice, actions: LocationStoreApi];
220
- declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<_zayne_labs_toolkit_core0.StoreApi<_zayne_labs_toolkit_core0.URLInfoObject>, "setState" | "resetState"> & {
221
- push: (url: string | _zayne_labs_toolkit_core0.PartialURLInfo, options?: {
222
- state?: _zayne_labs_toolkit_core0.PartialURLInfo["state"];
223
- }) => void;
224
- replace: LocationStoreApi["push"];
225
- triggerPopstateEvent: (nextLocationState?: LocationInfo["state"]) => void;
226
- } & (<TSlice = _zayne_labs_toolkit_core0.URLInfoObject>(selector?: SelectorFn<LocationInfo, TSlice>) => UseLocationResult<TSlice>);
227
- declare const useLocationState: <TSlice = LocationInfo>(selector?: SelectorFn<LocationInfo, TSlice>, options?: LocationStoreOptions) => UseLocationResult<TSlice>;
228
- //#endregion
229
- //#region src/hooks/useScrollObserver.d.ts
230
- declare const useScrollObserver: <TElement extends HTMLElement>(options?: ScrollObserverOptions) => {
231
- isScrolled: boolean;
232
- observedElementRef: RefCallback<TElement>;
233
- };
234
- //#endregion
235
- //#region src/hooks/useSearch.d.ts
236
- declare const useSearch: <TData>(initialData: TData[], delay?: number) => {
237
- data: TData[];
238
- isLoading: boolean;
239
- query: string;
240
- setQuery: react1.Dispatch<react1.SetStateAction<string>>;
241
- };
242
- //#endregion
243
- //#region src/hooks/useSearchParams.d.ts
244
- type UseSearchParamsOptions = LocationStoreOptions & {
245
- action?: "push" | "replace";
246
- };
247
- declare const useSearchParams: <TSearchParams extends URLSearchParamsInit>(options?: UseSearchParamsOptions) => readonly [URLSearchParams, {
248
- (newQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)): void;
249
- triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core0.LocationInfo["state"]) => void;
250
- }];
251
- declare const useSearchParamsObject: <TSearchParams extends Record<string, string>>(options?: UseSearchParamsOptions) => readonly [TSearchParams, {
252
- (newQueryParams: TSearchParams | ((prev: TSearchParams) => TSearchParams)): void;
253
- triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core0.LocationInfo["state"]) => void;
254
- }];
255
- //#endregion
256
- //#region src/hooks/useShallowCompare.d.ts
257
- declare const useShallowCompSelector: <TState, TResult>(selector: SelectorFn<TState, TResult> | undefined) => (state: TState) => TResult;
258
- declare const useShallowCompValue: <TValue>(value: TValue) => TValue;
259
- //#endregion
260
- //#region src/hooks/useStorageState.d.ts
261
- type UseStorageResult<TState, TSlice = TState> = [state: TSlice, actions: StorageStoreApi<TState>];
262
- /**
263
- * @description Creates a custom hook that returns a storage state and actions to modify it. You can use this if you need shared options.
264
- * @note You must use this if you want to be able to prevent syncing state across tabs.
265
- */
266
- declare const createUseStorageState: <TState>(baseOptions: StorageOptions<TState>) => _zayne_labs_toolkit_core0.StoreApi<TState> & {
267
- removeState: () => void;
268
- } & (<TSlice = TState>(selector?: SelectorFn<TState, TSlice>) => UseStorageResult<TState, TSlice>);
269
- type UseStorageStateOptions<TValue> = Omit<StorageOptions<TValue>, "initialValue" | "key">;
270
- declare const useStorageState: <TValue, TSlice = TValue>(key: string, initialValue?: TValue, options?: UseStorageStateOptions<TValue> & {
271
- select?: SelectorFn<TValue, TSlice>;
272
- }) => UseStorageResult<TValue, TSlice>;
273
- //#endregion
274
- //#region src/hooks/useStore.d.ts
275
- declare const useStore: <TState, TSlice = TState>(store: StoreApi<TState>, selector?: SelectorFn<TState, TSlice>) => TSlice;
276
- //#endregion
277
- //#region src/hooks/useThrottle.d.ts
278
- declare const useThrottleBySetTimeout: <TParams>(callbackFn: CallbackFn<TParams>, delay: number) => {
279
- (...params: TParams[]): void;
280
- cancelTimeout(): void;
281
- };
282
- declare const useThrottleByTimer: <TParams>(callbackFn: CallbackFn<TParams>, delay: number) => (...params: TParams[]) => void;
283
- declare const useThrottleByFrame: <TParams>(callbackFn: CallbackFn<TParams>) => {
284
- (...params: TParams[]): void;
285
- cancelAnimation(): void;
286
- };
287
- //#endregion
288
- //#region src/hooks/useToggle.d.ts
289
- type InitialState = boolean | (() => boolean);
290
- declare const useToggle: (initialValue?: InitialState) => [value: boolean, toggleValue: <TValue>(newValue?: TValue) => void];
291
- //#endregion
292
- export { ContextError, CustomContextOptions, UseCustomContext, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useComposeRefs, useConstant, useControllableProp, useControllableState, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsHydrated, useLazyRef, useLifeCycle, useLocationState, useMountEffect, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useShallowCompSelector, useShallowCompValue, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
293
- //# sourceMappingURL=index-ouFKofvj.d.ts.map