@zayne-labs/toolkit-react 0.9.12 → 0.9.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/{chunk-U2YL6UOG.js → chunk-EBM5P324.js} +2 -2
- package/dist/esm/chunk-EBM5P324.js.map +1 -0
- package/dist/esm/hooks/index.js +1 -1
- package/dist/esm/utils/index.d.ts +10 -56
- package/dist/esm/utils/index.js +22 -23
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/zustand/index.js +1 -1
- package/package.json +5 -4
- package/dist/esm/chunk-U2YL6UOG.js.map +0 -1
@@ -490,5 +490,5 @@ var useThrottleByFrame = (callbackFn) => {
|
|
490
490
|
};
|
491
491
|
|
492
492
|
export { ContextError, createCustomContext, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsServer, useLifeCycle, useLocation, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
|
493
|
-
//# sourceMappingURL=chunk-
|
494
|
-
//# sourceMappingURL=chunk-
|
493
|
+
//# sourceMappingURL=chunk-EBM5P324.js.map
|
494
|
+
//# sourceMappingURL=chunk-EBM5P324.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"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/useConstant.ts","../../src/hooks/useAnimationInterval.ts","../../src/hooks/useClickOutside.ts","../../src/hooks/useCopyToClipboard.ts","../../src/hooks/useDebounce.ts","../../src/hooks/useToggle.ts","../../src/hooks/useDisclosure.ts","../../src/hooks/useIsServer.ts","../../src/hooks/useStore.ts","../../src/hooks/useLocation.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/useStorageState.ts","../../src/hooks/useThrottle.ts"],"names":["useRef","useEffect","useCallback","useState","useSyncExternalStore","on"],"mappings":";;;;;AAGa,IAAA,YAAA,GAAN,cAA2B,KAAM,CAAA;AAAA,EAC9B,IAAO,GAAA,cAAA;AAAA,EAEhB,eAAe,IAAgC,EAAA;AAC9C,IAAA,KAAA,CAAM,GAAG,IAAI,CAAA;AAEb,IAAM,KAAA,CAAA,iBAAA,CAAkB,IAAM,EAAA,IAAA,CAAK,WAAW,CAAA;AAAA;AAEhD;AAEa,IAAA,eAAA,GAAkB,CAAC,IAAA,EAAc,QAAqB,KAAA;AAClE,EAAO,OAAA,CAAA,EAAG,IAAI,CAAA,yEAAA,EAA4E,QAAQ,CAAA,CAAA,CAAA;AACnG;AAgBA,IAAM,mBAAsB,GAAA,CAC3B,OAAwD,GAAA,EACpD,KAAA;AACJ,EAAM,MAAA;AAAA,IACL,YAAe,GAAA,IAAA;AAAA,IACf,YAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAW,GAAA,mBAAA;AAAA,IACX,YAAe,GAAA,wBAAA;AAAA,IACf,IAAA,GAAO,aAAa,QAAS,CAAA,UAAU,IAAI,YAAa,CAAA,KAAA,CAAM,CAAG,EAAA,EAAE,CAAI,GAAA,gBAAA;AAAA,IACvE,MAAS,GAAA;AAAA,GACN,GAAA,OAAA;AAEJ,EAAM,MAAA,OAAA,GAAU,cAAoC,YAAY,CAAA;AAEhE,EAAA,OAAA,CAAQ,WAAc,GAA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AA;AACnG,EAAM,MAAA,cAAA,GAAiB,eAAe,UAAU,CAAA;AAEhD,EAAA,MAAM,oBAAoB,WAAY,CAAA,MAAM,oBAAqB,CAAA,cAAA,EAAgB,KAAK,CAAC,CAAA;AAEvF,EAAiB,gBAAA,CAAA,MAAM,iBAAkB,CAAA,aAAA,EAAe,CAAA;AAExD,EAAO,OAAA,iBAAA;AACR;AAEa,IAAA,kBAAA,GAAqB,CAAU,UAAA,EAAiC,KAAkB,KAAA;AAC9F,EAAM,MAAA,cAAA,GAAiB,eAAe,UAAU,CAAA;AAEhD,EAAA,MAAM,oBAAoB,WAAY,CAAA,MAAM,cAAe,CAAA,cAAA,EAAgB,KAAK,CAAC,CAAA;AAEjF,EAAO,OAAA,iBAAA;AACR;AAEa,IAAA,kBAAA,GAAqB,CAAU,UAAoC,KAAA;AAC/E,EAAM,MAAA,cAAA,GAAiB,eAAe,UAAU,CAAA;AAEhD,EAAA,MAAM,iBAAoB,GAAA,WAAA,CAAY,MAAM,eAAA,CAAgB,cAAc,CAAC,CAAA;AAE3E,EAAiB,gBAAA,CAAA,MAAM,iBAAkB,CAAA,eAAA,EAAiB,CAAA;AAE1D,EAAO,OAAA,iBAAA;AACR","file":"chunk-EBM5P324.js","sourcesContent":["import { defineEnum } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createContext, use } from \"react\";\n\nexport class ContextError extends Error {\n\toverride name = \"ContextError\";\n\n\tconstructor(...args: Parameters<typeof Error>) {\n\t\tsuper(...args);\n\n\t\tError.captureStackTrace(this, this.constructor);\n\t}\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\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\ntype UseCustomContextResult<TContextValue, TStrict extends boolean> = TStrict extends true\n\t? TContextValue\n\t: TContextValue | null;\n\nconst createCustomContext = <TContextValue, 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 | null>(defaultValue);\n\n\tContext.displayName = name;\n\n\tconst useCustomContext = (): UseCustomContextResult<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 defineEnum([Context.Provider, useCustomContext]);\n};\n\nexport { createCustomContext };\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 { useRef } from \"react\";\n\nconst useConstant = <TResult>(initCallbackFn: () => 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 { useConstant };\n","import { type AnimationIntervalOptions, setAnimationInterval } from \"@zayne-labs/toolkit-core\";\nimport type { Prettify } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useEffect } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useConstant } from \"./useConstant\";\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\t// prettier-ignore\n\tconst { start, stop } = useConstant(() => setAnimationInterval(latestCallback, intervalDuration, { once }));\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 } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\n\ntype UseClickOutsideOptions = {\n\tenabled?: boolean;\n};\n\nconst useClickOutside = <TElement extends HTMLElement>(\n\trefOrRefArray: Array<React.RefObject<TElement>> | React.RefObject<TElement>,\n\tcallback: (event: MouseEvent | TouchEvent) => void,\n\toptions?: UseClickOutsideOptions\n) => {\n\tconst { enabled = true } = options ?? {};\n\n\tconst savedCallback = useCallbackRef(callback);\n\n\tuseEffect(() => {\n\t\tif (!enabled) return;\n\n\t\tconst controller = new AbortController();\n\n\t\tconst elementArray = toArray(refOrRefArray).map((ref) => ref.current);\n\n\t\tonClickOutside(elementArray, savedCallback, { signal: controller.signal });\n\n\t\treturn () => {\n\t\t\tcontroller.abort();\n\t\t};\n\t}, [enabled, refOrRefArray, savedCallback]);\n};\n\nexport { useClickOutside };\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 { useState } from \"react\";\nimport { useUnmountEffect } from \"./effects/useUnMountEffect\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useConstant } from \"./useConstant\";\n\nexport const useDebouncedFn = <TParams>(callBackFn: CallbackFn<TParams>, delay: number | undefined) => {\n\tconst latestCallback = useCallbackRef(callBackFn);\n\n\tconst debouncedFn = useConstant(() => debounce(latestCallback, delay));\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 = useConstant(() => debounce(setValue, 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 { 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 handleScrollControl = useCallbackRef(\n\t\t(state: boolean) => hasScrollControl && lockScroll({ isActive: state })\n\t);\n\n\tconst onOpen = useCallbackRef(<TValue>(value?: TValue) => {\n\t\tconst booleanValue = typeof value === \"boolean\" && value ? value : true;\n\t\ttoggleIsOpen(booleanValue);\n\t\thandleScrollControl(booleanValue);\n\t});\n\n\tconst onClose = useCallbackRef(<TValue>(value?: TValue) => {\n\t\tconst booleanValue = typeof value === \"boolean\" && !value ? value : false;\n\n\t\ttoggleIsOpen(booleanValue);\n\t\thandleScrollControl(booleanValue);\n\t});\n\n\tconst onToggle = useCallbackRef(<TValue>(value?: TValue) => {\n\t\tif (typeof value === \"boolean\") {\n\t\t\tvalue ? onOpen(value) : onClose(value);\n\t\t\treturn;\n\t\t}\n\n\t\tisOpen ? onClose() : onOpen();\n\t});\n\n\treturn { isOpen, onClose, onOpen, onToggle };\n};\n\nexport { useDisclosure };\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 { useDebugValue, useSyncExternalStore } from \"react\";\n\nconst useStore = <TState, TSlice>(store: StoreApi<TState>, selector: SelectorFn<TState, TSlice>) => {\n\tconst slice = useSyncExternalStore(\n\t\tstore.subscribe,\n\t\t() => selector(store.getState()),\n\t\t() => selector(store.getInitialState())\n\t);\n\n\tuseDebugValue(slice);\n\n\treturn slice;\n};\n\nexport { useStore };\n","import {\n\ttype LocationInfo,\n\ttype LocationStoreOptions,\n\tcreateLocationStore,\n} from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useConstant } from \"./useConstant\";\nimport { useStore } from \"./useStore\";\n\ntype LocationStore = ReturnType<typeof createLocationStore>;\n\ntype UseLocationResult<TSlice> = [\n\tstate: TSlice,\n\tsetState: {\n\t\tpush: LocationStore[\"push\"];\n\t\treplace: LocationStore[\"replace\"];\n\t\ttriggerPopstate: LocationStore[\"triggerPopstateEvent\"];\n\t},\n];\n\nconst useLocation = <TSlice = LocationInfo>(\n\tselector: SelectorFn<LocationInfo, TSlice>,\n\toptions?: LocationStoreOptions\n) => {\n\tconst locationStore = useConstant(() => createLocationStore(options));\n\n\tconst stateSlice = useStore(locationStore as never, selector);\n\n\treturn [\n\t\tstateSlice,\n\t\t{\n\t\t\tpush: locationStore.push,\n\t\t\treplace: locationStore.replace,\n\t\t\ttriggerPopstate: locationStore.triggerPopstateEvent,\n\t\t},\n\t] as UseLocationResult<TSlice>;\n};\n\nexport { useLocation };\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 { type ScrollObserverOptions, createScrollObserver } from \"@zayne-labs/toolkit-core\";\nimport { type RefCallback, useState } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useConstant } from \"./useConstant\";\n\nconst useScrollObserver = <TElement extends HTMLElement>(options: ScrollObserverOptions = {}) => {\n\tconst { onIntersection, rootMargin = \"10px 0px 0px 0px\", ...restOfOptions } = options;\n\n\tconst [isScrolled, setIsScrolled] = useState(false);\n\n\tconst savedOnIntersection = useCallbackRef(onIntersection);\n\n\tconst { handleObservation } = useConstant(() => {\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\trootMargin,\n\t\t\t...restOfOptions,\n\t\t});\n\t});\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 { useLocation } from \"./useLocation\";\n\ntype UseSearchParamsOptions = {\n\taction?: \"push\" | \"replace\";\n\tlocationOptions?: LocationStoreOptions;\n};\n\nexport const useSearchParams = <TSearchParams extends URLSearchParamsInit>(\n\toptions?: UseSearchParamsOptions\n) => {\n\tconst { action = \"push\", locationOptions } = options ?? {};\n\n\tconst [searchParams, setLocation] = useLocation((state) => state.search, locationOptions);\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\tif (Object.is(searchParams.toString(), nextSearchParams.toString())) return;\n\n\t\tsetLocation[action]({ search: nextSearchParams });\n\t};\n\n\tsetSearchParams.triggerPopstate = setLocation.triggerPopstate;\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\treturn [searchParamsObject, setSearchParamsObject] as const;\n};\n","import {\n\ttype SetStorageState,\n\ttype StorageOptions,\n\tcreateExternalStorageStore,\n} from \"@zayne-labs/toolkit-core\";\nimport { type SelectorFn, isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useConstant } from \"./useConstant\";\nimport { useStore } from \"./useStore\";\n\ntype UseStorageStateOptions<TValue, TSlice = TValue> = StorageOptions<TValue> & {\n\tselect?: SelectorFn<TValue, TSlice>;\n};\n\ntype StorageStoreApi<TValue> = ReturnType<typeof createExternalStorageStore<TValue>>;\n\ntype ParamsOne<TValue, TSlice> = [\n\tkey: string,\n\tinitialValue?: TValue,\n\toptions?: Omit<UseStorageStateOptions<TValue, TSlice>, \"initialValue\" | \"key\">,\n];\n\ntype ParamsTwo<TValue, TSlice> = [options: UseStorageStateOptions<TValue, TSlice>];\n\ntype UseStorageStateParams<TValue, TSlice> = ParamsOne<TValue, TSlice> | ParamsTwo<TValue, TSlice>;\n\n// TODO: Add createImpl that returns a hook for react later\nconst useStorageState = <TValue, TSlice = TValue>(...params: UseStorageStateParams<TValue, TSlice>) => {\n\tconst [keyOrOptions, $initialValue, options] = params;\n\n\tconst _key = isString(keyOrOptions) ? keyOrOptions : keyOrOptions.key;\n\tconst _initialValue = isString(keyOrOptions) ? $initialValue : keyOrOptions.initialValue;\n\n\tconst {\n\t\tinitialValue = _initialValue,\n\t\tkey = _key,\n\t\tselect = (value: TValue) => value,\n\t\t...restOfOptions\n\t} = isString(keyOrOptions)\n\t\t? ((options as UseStorageStateOptions<TValue, TSlice> | undefined) ?? {})\n\t\t: keyOrOptions;\n\n\tconst externalStore = useConstant(() =>\n\t\tcreateExternalStorageStore({ initialValue, key, ...restOfOptions })\n\t);\n\n\tconst stateInStorage = useStore(externalStore as never, select as never);\n\n\treturn [stateInStorage, externalStore.setState, externalStore] as [\n\t\tstate: TValue,\n\t\tsetState: SetStorageState<TValue>,\n\t\tstoreApi: StorageStoreApi<TValue>,\n\t];\n};\n\nexport { useStorageState };\n","import { throttleByFrame, throttleBySetTimeout, throttleByTime } from \"@zayne-labs/toolkit-core\";\nimport type { CallbackFn } from \"@zayne-labs/toolkit-type-helpers\";\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 = useConstant(() => throttleBySetTimeout(latestCallback, delay));\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 = useConstant(() => throttleByTime(latestCallback, delay));\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"]}
|
package/dist/esm/hooks/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export { ContextError, createCustomContext, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsServer, useLifeCycle, useLocation, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect } from '../chunk-
|
1
|
+
export { ContextError, createCustomContext, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsServer, useLifeCycle, useLocation, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect } from '../chunk-EBM5P324.js';
|
2
2
|
//# sourceMappingURL=index.js.map
|
3
3
|
//# sourceMappingURL=index.js.map
|
@@ -70,10 +70,6 @@ declare const getMultipleSlots: <const TSlotComponents extends FunctionalCompone
|
|
70
70
|
*/
|
71
71
|
declare const getRegularChildren: <TChildren extends React.ReactNode>(children: TChildren, SlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]) => TChildren extends unknown[] ? TChildren : TChildren[];
|
72
72
|
|
73
|
-
/**
|
74
|
-
* Possible children types that can be passed to a slot
|
75
|
-
*/
|
76
|
-
type PossibleSlotChildrenType = React.ReactNode | React.ReactNode[];
|
77
73
|
/**
|
78
74
|
* Maps slot names to their corresponding children types
|
79
75
|
*/
|
@@ -122,67 +118,25 @@ declare const getSlotMap: <TSlotComponentProps extends GetSlotComponentProps>(ch
|
|
122
118
|
/**
|
123
119
|
* @description Produce props for the SlotComponent
|
124
120
|
*/
|
125
|
-
type GetSlotComponentProps<TName extends string = string, TChildren extends
|
121
|
+
type GetSlotComponentProps<TName extends string = string, TChildren extends React.ReactNode = React.ReactNode> = {
|
126
122
|
/** Content to render in the slot */
|
127
123
|
children: TChildren;
|
128
124
|
/** Name of the slot where content should be rendered */
|
129
125
|
name: TName;
|
130
126
|
};
|
131
|
-
/**
|
132
|
-
* @description Function used to create a slot component that defines named slots in a parent component. This component created doesn't render anything,
|
133
|
-
* it's used purely for slot definition.
|
134
|
-
*
|
135
|
-
* @example
|
136
|
-
* ```tsx
|
137
|
-
* import { type GetSlotComponentProps, createSlotComponent, SlotComponent } from "@zayne-labs/toolkit-react/utils"
|
138
|
-
*
|
139
|
-
* type SlotProps = GetSlotComponentProps<"header" | "footer">;
|
140
|
-
*
|
141
|
-
* function Parent({ children }: { children: React.ReactNode }) {
|
142
|
-
* const slots = getSlotMap<SlotProps>(children);
|
143
|
-
*
|
144
|
-
* return (
|
145
|
-
* <div>
|
146
|
-
* <header>{slots.header}</header>
|
147
|
-
* <main>{slots.default}</main>
|
148
|
-
* <footer>{slots.footer}</footer>
|
149
|
-
* </div>
|
150
|
-
* );
|
151
|
-
* }
|
152
|
-
*
|
153
|
-
* Parent.Slot = createSlotComponent<SlotProps>();
|
154
|
-
* // OR
|
155
|
-
* Parent.Slot = SlotComponent<SlotProps>
|
156
|
-
* ```
|
157
|
-
*
|
158
|
-
*
|
159
|
-
* @example
|
160
|
-
* Usage:
|
161
|
-
```tsx
|
162
|
-
* function App() {
|
163
|
-
* return (
|
164
|
-
* <Parent>
|
165
|
-
* <Parent.Slot name="header">Header Content</Parent.Slot>
|
166
|
-
* <div>Default Content</div>
|
167
|
-
* <Parent.Slot name="footer">Footer Content</Parent.Slot>
|
168
|
-
* </Parent>
|
169
|
-
* );
|
170
|
-
* }
|
171
|
-
* ```
|
172
|
-
*/
|
173
|
-
declare const createSlotComponent: <TBaseSlotComponentProps extends GetSlotComponentProps>() => {
|
174
|
-
<TSlotComponentProps extends TBaseSlotComponentProps>(props: TSlotComponentProps): React.ReactNode;
|
175
|
-
slotSymbol: typeof slotComponentSymbol;
|
176
|
-
slotName: string;
|
177
|
-
};
|
178
127
|
/**
|
179
128
|
* @description Slot component created by createSlotComponent
|
180
129
|
*/
|
181
|
-
declare const
|
182
|
-
|
130
|
+
declare const createSlotComponent: <TSlotComponentProps extends GetSlotComponentProps>() => {
|
131
|
+
(props: TSlotComponentProps): react.ReactNode;
|
183
132
|
slotSymbol: typeof slotComponentSymbol;
|
184
|
-
slotName: string;
|
185
133
|
};
|
134
|
+
type WithSlotSymbolAndName<TSlotComponentProps extends Pick<GetSlotComponentProps, "name"> = Pick<GetSlotComponentProps, "name">, TActualProps extends UnknownObject = UnknownObject> = {
|
135
|
+
(props: Pick<GetSlotComponentProps, "children"> & TActualProps): React.ReactNode;
|
136
|
+
slotName?: TSlotComponentProps["name"];
|
137
|
+
slotSymbol?: typeof slotComponentSymbol;
|
138
|
+
};
|
139
|
+
declare const withSlotSymbolAndName: <TSlotComponentProps extends Pick<GetSlotComponentProps, "name">, TActualProps extends UnknownObject = UnknownObject>(name: TSlotComponentProps["name"], SlotComponent: WithSlotSymbolAndName<TSlotComponentProps, TActualProps>) => WithSlotSymbolAndName<TSlotComponentProps, TActualProps>;
|
186
140
|
|
187
141
|
type UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : "") extends (param: infer TParam) => void ? TParam : "";
|
188
142
|
type UnknownProps$1 = Record<never, never>;
|
@@ -218,4 +172,4 @@ type InferRestOfProps<TElement extends React.ElementType, TProps> = Omit<React.C
|
|
218
172
|
type MergedPropsWithAs<TElement extends React.ElementType, TProps> = Prettify<Omit<AsProp<TElement>, keyof TProps> & TProps>;
|
219
173
|
type PolymorphicProps<TElement extends React.ElementType, TProps extends AnyObject = NonNullable<unknown>> = MergedPropsWithAs<TElement, TProps> & InferRestOfProps<TElement, TProps>;
|
220
174
|
|
221
|
-
export { type AsProp, type DiscriminatedRenderProps, type ForwardedRefType, type FunctionalComponent, type GetSlotComponentProps, type InferProps, type MyCustomCss, type PolymorphicProps,
|
175
|
+
export { type AsProp, type DiscriminatedRenderProps, type ForwardedRefType, type FunctionalComponent, type GetSlotComponentProps, type InferProps, type MyCustomCss, type PolymorphicProps, type StateSetter, composeEventHandlers, composeRefs, createSlotComponent, getMultipleSlots, getRegularChildren, getSingleSlot, getSlotMap, matchesAnySlotComponent, matchesSlotComponent, mergeProps, mergeTwoProps, setRef, slotComponentSymbol, withSlotSymbolAndName };
|
package/dist/esm/utils/index.js
CHANGED
@@ -28,48 +28,48 @@ var composeEventHandlers = (eventHandlers) => {
|
|
28
28
|
const mergedEventHandler = (event) => eventHandlers.forEach((handler) => handler?.(event));
|
29
29
|
return mergedEventHandler;
|
30
30
|
};
|
31
|
-
var matchesSlotComponent = (child,
|
31
|
+
var matchesSlotComponent = (child, SlotComponent) => {
|
32
32
|
if (!isValidElement(child)) {
|
33
33
|
return false;
|
34
34
|
}
|
35
|
-
if (child.type?.slotSymbol &&
|
35
|
+
if (child.type?.slotSymbol && SlotComponent?.slotSymbol && Object.is(child.type?.slotSymbol, SlotComponent?.slotSymbol)) {
|
36
36
|
return true;
|
37
37
|
}
|
38
|
-
if (child.type.name ===
|
38
|
+
if (child.type.name === SlotComponent.name) {
|
39
39
|
return true;
|
40
40
|
}
|
41
41
|
return false;
|
42
42
|
};
|
43
43
|
var matchesAnySlotComponent = (child, SlotComponents) => {
|
44
|
-
const matchesSlot = SlotComponents.some((
|
44
|
+
const matchesSlot = SlotComponents.some((SlotComponent) => matchesSlotComponent(child, SlotComponent));
|
45
45
|
return matchesSlot;
|
46
46
|
};
|
47
|
-
var calculateSlotOccurrences = (childrenArray,
|
47
|
+
var calculateSlotOccurrences = (childrenArray, SlotComponent) => {
|
48
48
|
let count = 0;
|
49
49
|
for (const child of childrenArray) {
|
50
|
-
if (!matchesSlotComponent(child,
|
50
|
+
if (!matchesSlotComponent(child, SlotComponent)) continue;
|
51
51
|
count += 1;
|
52
52
|
}
|
53
53
|
return count;
|
54
54
|
};
|
55
|
-
var getSingleSlot = (children,
|
55
|
+
var getSingleSlot = (children, SlotComponent, options = {}) => {
|
56
56
|
const {
|
57
57
|
errorMessage = "Only one instance of the SlotComponent is allowed",
|
58
58
|
throwOnMultipleSlotMatch = false
|
59
59
|
} = options;
|
60
60
|
const actualChildren = isValidElement(children) && children.type === Fragment ? children.props.children : children;
|
61
61
|
const childrenArray = toArray(actualChildren);
|
62
|
-
const shouldThrow = throwOnMultipleSlotMatch && calculateSlotOccurrences(childrenArray,
|
62
|
+
const shouldThrow = throwOnMultipleSlotMatch && calculateSlotOccurrences(childrenArray, SlotComponent) > 1;
|
63
63
|
if (shouldThrow) {
|
64
64
|
throw new AssertionError(errorMessage);
|
65
65
|
}
|
66
|
-
const slotElement = childrenArray.find((child) => matchesSlotComponent(child,
|
66
|
+
const slotElement = childrenArray.find((child) => matchesSlotComponent(child, SlotComponent));
|
67
67
|
return slotElement;
|
68
68
|
};
|
69
69
|
var getMultipleSlots = (children, SlotComponents, options) => {
|
70
70
|
const { errorMessage, throwOnMultipleSlotMatch } = options ?? {};
|
71
71
|
const slots = SlotComponents.map(
|
72
|
-
(
|
72
|
+
(SlotComponent, index) => getSingleSlot(children, SlotComponent, {
|
73
73
|
errorMessage: isArray(errorMessage) ? errorMessage[index] : errorMessage,
|
74
74
|
throwOnMultipleSlotMatch: isArray(throwOnMultipleSlotMatch) ? throwOnMultipleSlotMatch[index] : throwOnMultipleSlotMatch
|
75
75
|
})
|
@@ -89,30 +89,29 @@ var slotComponentSymbol = Symbol("slot-component");
|
|
89
89
|
var getSlotMap = (children) => {
|
90
90
|
const actualChildren = isValidElement(children) && children.type === Fragment ? children.props.children : children;
|
91
91
|
const childrenArray = toArray(actualChildren);
|
92
|
-
const slots = {
|
93
|
-
default: []
|
94
|
-
};
|
92
|
+
const slots = { default: [] };
|
95
93
|
for (const child of childrenArray) {
|
96
|
-
const isSlotElementWithName = isValidElement(child) && child.type.slotSymbol === slotComponentSymbol && Boolean(child.
|
94
|
+
const isSlotElementWithName = isValidElement(child) && child.type.slotSymbol === slotComponentSymbol && Boolean(child.type.slotName ?? child.props.name);
|
97
95
|
const isRegularElementWithSlotName = isValidElement(child) && Boolean(child.props["data-slot-name"]);
|
98
96
|
if (!isSlotElementWithName && !isRegularElementWithSlotName) {
|
99
97
|
slots.default.push(child);
|
100
98
|
continue;
|
101
99
|
}
|
102
|
-
const slotName = isSlotElementWithName ? child.
|
100
|
+
const slotName = isSlotElementWithName ? child.type.slotName ?? child.props.name : child.props["data-slot-name"];
|
103
101
|
slots[slotName] = child.props.children;
|
104
102
|
}
|
105
103
|
return slots;
|
106
104
|
};
|
107
105
|
var createSlotComponent = () => {
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
106
|
+
const SlotComponent = (props) => props.children;
|
107
|
+
SlotComponent.slotSymbol = slotComponentSymbol;
|
108
|
+
return SlotComponent;
|
109
|
+
};
|
110
|
+
var withSlotSymbolAndName = (name, SlotComponent) => {
|
111
|
+
SlotComponent.slotSymbol = slotComponentSymbol;
|
112
|
+
SlotComponent.slotName = name;
|
113
|
+
return SlotComponent;
|
114
114
|
};
|
115
|
-
var SlotComponent = createSlotComponent();
|
116
115
|
var handleMergePropsIntoResult = (mergedResult, propsObject) => {
|
117
116
|
for (const propName of Object.keys(mergedResult)) {
|
118
117
|
const mergedResultValue = mergedResult[propName];
|
@@ -173,6 +172,6 @@ var mergeTwoProps = (slotProps, childProps) => {
|
|
173
172
|
return { ...slotProps, ...overrideProps };
|
174
173
|
};
|
175
174
|
|
176
|
-
export {
|
175
|
+
export { composeEventHandlers, composeRefs, createSlotComponent, getMultipleSlots, getRegularChildren, getSingleSlot, getSlotMap, matchesAnySlotComponent, matchesSlotComponent, mergeProps, mergeTwoProps, setRef, slotComponentSymbol, withSlotSymbolAndName };
|
177
176
|
//# sourceMappingURL=index.js.map
|
178
177
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/composeRefs.ts","../../../src/utils/composeEventHandlers.ts","../../../src/utils/getSlotElement.ts","../../../src/utils/getSlotMap.ts","../../../src/utils/mergeProps.ts","../../../src/utils/mergeTwoProps.ts"],"names":["SlotComponent","ReactFragment","isValidElement","toArray","isFunction","isPlainObject","mergeClassNames","mergeFunctions"],"mappings":";;;;;AAUa,IAAA,MAAA,GAAS,CAAO,GAAA,EAAwB,IAA8C,KAAA;AAClG,EAAA,IAAI,CAAC,GAAK,EAAA;AAEV,EAAI,IAAA,UAAA,CAAW,GAAG,CAAG,EAAA;AACpB,IAAA,OAAO,IAAI,IAAI,CAAA;AAAA;AAIhB,EAAA,GAAA,CAAI,OAAU,GAAA,IAAA;AACf;AAKa,IAAA,WAAA,GAAc,CAC1B,IACuB,KAAA;AACvB,EAAM,MAAA,iBAAA,GAAuC,CAAC,IAAS,KAAA;AACtD,IAAM,MAAA,cAAA,GAAiB,KAAK,GAAI,CAAA,CAAC,QAAQ,MAAO,CAAA,GAAA,EAAK,IAAI,CAAC,CAAA;AAE1D,IAAA,MAAM,YAAY,MAAM,cAAA,CAAe,QAAQ,CAAC,OAAA,KAAY,WAAW,CAAA;AAGvE,IAAA,IAAI,CAAC,IAAM,EAAA;AACV,MAAU,SAAA,EAAA;AACV,MAAA;AAAA;AAGD,IAAO,OAAA,SAAA;AAAA,GACR;AAEA,EAAO,OAAA,iBAAA;AACR;;;ACtCa,IAAA,oBAAA,GAAuB,CACnC,aACyC,KAAA;AAEzC,EAAM,MAAA,kBAAA,GAA0D,CAAC,KAAU,KAAA,aAAA,CAAc,QAAQ,CAAC,OAAA,KAAY,OAAU,GAAA,KAAK,CAAC,CAAA;AAE9H,EAAO,OAAA,kBAAA;AACR;ACEa,IAAA,oBAAA,GAAuB,CAAC,KAAA,EAAwBA,cAAuC,KAAA;AACnG,EAAI,IAAA,CAAC,cAAe,CAAA,KAAK,CAAG,EAAA;AAC3B,IAAO,OAAA,KAAA;AAAA;AAKR,EAAA,IACE,KAAM,CAAA,IAAA,EAAmB,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,aAAaF,UAAW,CAAA,aAAa,CAAKA,IAAAA,UAAAA,CAAW,cAAc,CAAG,EAAA;AACzE,MAAA,aAAA,CAAc,QAAQ,CAAA,GAAIG,cAAe,CAAA,cAAA,EAAgB,aAAa,CAAA;AAAA;AACvE;AAGD,EAAA,OAAO,EAAE,GAAG,SAAW,EAAA,GAAG,aAAc,EAAA;AACzC","file":"index.js","sourcesContent":["import { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\r\nimport type { RefCallback } from \"react\";\r\n\r\ntype PossibleRef<TRef> = React.Ref<TRef> | undefined;\r\n\r\n/**\r\n * @description Set a given ref to a given value.\r\n *\r\n * This utility takes care of different types of refs: callback refs and RefObject(s)\r\n */\r\nexport const setRef = <TRef>(ref: PossibleRef<TRef>, node: TRef): ReturnType<RefCallback<TRef>> => {\r\n\tif (!ref) return;\r\n\r\n\tif (isFunction(ref)) {\r\n\t\treturn ref(node);\r\n\t}\r\n\r\n\t// eslint-disable-next-line no-param-reassign -- Mutation is needed here\r\n\tref.current = node;\r\n};\r\n\r\n/**\r\n * @description A utility to combine refs. Accepts callback refs and RefObject(s)\r\n */\r\nexport const composeRefs = <TRef extends HTMLElement>(\r\n\trefs: Array<PossibleRef<TRef>>\r\n): RefCallback<TRef> => {\r\n\tconst mergedRefCallBack: RefCallback<TRef> = (node) => {\r\n\t\tconst cleanupFnArray = refs.map((ref) => setRef(ref, node));\r\n\r\n\t\tconst cleanupFn = () => cleanupFnArray.forEach((cleanup) => cleanup?.());\r\n\r\n\t\t// == React 18 may not call the cleanup function so we need to call it manually on element unmount\r\n\t\tif (!node) {\r\n\t\t\tcleanupFn();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\treturn cleanupFn;\r\n\t};\r\n\r\n\treturn mergedRefCallBack;\r\n};\r\n","type PossibleEventHandler<TSyntheticEvent extends React.SyntheticEvent> =\n\t| React.EventHandler<TSyntheticEvent>\n\t| undefined;\n\nexport const composeEventHandlers = <TSyntheticEvent extends React.SyntheticEvent>(\n\teventHandlers: Array<PossibleEventHandler<TSyntheticEvent>>\n): React.EventHandler<TSyntheticEvent> => {\n\t// prettier-ignore\n\tconst mergedEventHandler: React.EventHandler<TSyntheticEvent> = (event) => eventHandlers.forEach((handler) => handler?.(event));\n\n\treturn mergedEventHandler;\n};\n","import { toArray } from \"@zayne-labs/toolkit-core\";\nimport { AssertionError, type UnknownObject, isArray } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, isValidElement } from \"react\";\nimport type { InferProps } from \"./types\";\n\nexport type FunctionalComponent<TProps extends UnknownObject = never> = React.FunctionComponent<TProps>;\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)) {\n\t\treturn false;\n\t}\n\n\ttype WithSlot = { readonly slotSymbol?: unique symbol } | undefined;\n\n\tif (\n\t\t(child.type as WithSlot)?.slotSymbol\n\t\t&& (SlotComponent as WithSlot)?.slotSymbol\n\t\t&& Object.is((child.type as WithSlot)?.slotSymbol, (SlotComponent as WithSlot)?.slotSymbol)\n\t) {\n\t\treturn true;\n\t}\n\n\tif ((child.type as FunctionalComponent).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 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\t? children.props.children\n\t\t\t: children;\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\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) => {\n\ttype SlotsType = { [Key in keyof TSlotComponents]: ReturnType<TSlotComponents[Key]> };\n\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: isArray(throwOnMultipleSlotMatch)\n\t\t\t\t? throwOnMultipleSlotMatch[index]\n\t\t\t\t: throwOnMultipleSlotMatch,\n\t\t})\n\t) as SlotsType;\n\n\tconst regularChildren = getRegularChildren(children, SlotComponents);\n\n\treturn { regularChildren, slots };\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 = <TChildren extends React.ReactNode>(\n\tchildren: TChildren,\n\tSlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]\n) => {\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment\n\t\t\t? children.props.children\n\t\t\t: children;\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 as TChildren extends unknown[] ? TChildren : TChildren[];\n};\n","import { toArray } from \"@zayne-labs/toolkit-core\";\r\nimport type { UnionToIntersection } from \"@zayne-labs/toolkit-type-helpers\";\r\nimport { Fragment as ReactFragment, isValidElement } from \"react\";\r\nimport type { InferProps } from \"./types\";\r\n\r\n/**\r\n * Possible children types that can be passed to a slot\r\n */\r\ntype PossibleSlotChildrenType = React.ReactNode | React.ReactNode[];\r\n\r\n/**\r\n * Maps slot names to their corresponding children types\r\n */\r\ntype GetSlotMapResult<TSlotComponentProps extends GetSlotComponentProps> = UnionToIntersection<{\r\n\t[TName in keyof TSlotComponentProps as TSlotComponentProps[\"name\"]]: TSlotComponentProps[\"children\"];\r\n}>;\r\n\r\n/**\r\n * Symbol used to identify SlotComponent instances\r\n */\r\nexport const slotComponentSymbol = Symbol(\"slot-component\");\r\n\r\n/**\r\n * @description Creates a map of named slots from React children. Returns an object mapping slot names to their children,\r\n * with a default slot for unmatched children.\r\n *\r\n * @example\r\n * ```tsx\r\n * import { type GetSlotComponentProps, SlotComponent } from \"@zayne-labs/toolkit-react/utils\"\r\n *\r\n * type SlotProps = GetSlotComponentProps<\"header\" | \"footer\">;\r\n *\r\n * function Parent({ children }: { children: React.ReactNode }) {\r\n * const slots = getSlotMap<SlotProps>(children);\r\n *\r\n * return (\r\n * <div>\r\n * <header>{slots.header}</header>\r\n * <main>{slots.default}</main>\r\n * <footer>{slots.footer}</footer>\r\n * </div>\r\n * );\r\n * }\r\n * ```\r\n *\r\n * Usage:\r\n * ```tsx\r\n * <Parent>\r\n * <SlotComponent name=\"header\">Header Content</SlotComponent>\r\n * <div>Random stuff</div>\r\n * <SlotComponent name=\"footer\">Footer Content</SlotComponent>\r\n * </Parent>\r\n * ```\r\n */\r\nexport const getSlotMap = <TSlotComponentProps extends GetSlotComponentProps>(\r\n\tchildren: React.ReactNode\r\n) => {\r\n\tconst actualChildren =\r\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment\r\n\t\t\t? children.props.children\r\n\t\t\t: children;\r\n\r\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\r\n\r\n\tconst slots: Record<string, PossibleSlotChildrenType> & { default: React.ReactNode[] } = {\r\n\t\tdefault: [],\r\n\t};\r\n\r\n\tfor (const child of childrenArray) {\r\n\t\ttype SlotElementProps = TSlotComponentProps & { \"data-slot-name\": never };\r\n\r\n\t\ttype RegularElementProps = Pick<TSlotComponentProps, \"children\"> & {\r\n\t\t\t\"data-slot-name\": string;\r\n\t\t\tname: never;\r\n\t\t};\r\n\r\n\t\tconst isSlotElementWithName =\r\n\t\t\tisValidElement<SlotElementProps>(child)\r\n\t\t\t&& (child.type as typeof SlotComponent).slotSymbol === slotComponentSymbol\r\n\t\t\t&& Boolean(child.props.name || (child.type as typeof SlotComponent).slotName);\r\n\r\n\t\tconst isRegularElementWithSlotName =\r\n\t\t\tisValidElement<RegularElementProps>(child) && Boolean(child.props[\"data-slot-name\"]);\r\n\r\n\t\tif (!isSlotElementWithName && !isRegularElementWithSlotName) {\r\n\t\t\tslots.default.push(child);\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tconst slotName = isSlotElementWithName\r\n\t\t\t? child.props.name || (child.type as typeof SlotComponent).slotName\r\n\t\t\t: child.props[\"data-slot-name\"];\r\n\r\n\t\tslots[slotName] = child.props.children;\r\n\t}\r\n\r\n\treturn slots as GetSlotMapResult<TSlotComponentProps> & { default: React.ReactNode[] };\r\n};\r\n\r\n/**\r\n * @description Produce props for the SlotComponent\r\n */\r\nexport type GetSlotComponentProps<\r\n\tTName extends string = string,\r\n\tTChildren extends PossibleSlotChildrenType = PossibleSlotChildrenType,\r\n> = {\r\n\t/** Content to render in the slot */\r\n\tchildren: TChildren;\r\n\t/** Name of the slot where content should be rendered */\r\n\tname: TName;\r\n};\r\n\r\n/**\r\n * @description Function used to create a slot component that defines named slots in a parent component. This component created doesn't render anything,\r\n * it's used purely for slot definition.\r\n *\r\n * @example\r\n * ```tsx\r\n * import { type GetSlotComponentProps, createSlotComponent, SlotComponent } from \"@zayne-labs/toolkit-react/utils\"\r\n *\r\n * type SlotProps = GetSlotComponentProps<\"header\" | \"footer\">;\r\n *\r\n * function Parent({ children }: { children: React.ReactNode }) {\r\n * const slots = getSlotMap<SlotProps>(children);\r\n *\r\n * return (\r\n * <div>\r\n * <header>{slots.header}</header>\r\n * <main>{slots.default}</main>\r\n * <footer>{slots.footer}</footer>\r\n * </div>\r\n * );\r\n * }\r\n *\r\n * Parent.Slot = createSlotComponent<SlotProps>();\r\n * // OR\r\n * Parent.Slot = SlotComponent<SlotProps>\r\n * ```\r\n *\r\n *\r\n * @example\r\n * Usage:\r\n\t```tsx\r\n * function App() {\r\n * return (\r\n * <Parent>\r\n * <Parent.Slot name=\"header\">Header Content</Parent.Slot>\r\n * <div>Default Content</div>\r\n * <Parent.Slot name=\"footer\">Footer Content</Parent.Slot>\r\n * </Parent>\r\n * );\r\n * }\r\n * ```\r\n */\r\n\r\nexport const createSlotComponent = <TBaseSlotComponentProps extends GetSlotComponentProps>() => {\r\n\tfunction SlotComponent<TSlotComponentProps extends TBaseSlotComponentProps>(\r\n\t\tprops: TSlotComponentProps\r\n\t): React.ReactNode {\r\n\t\treturn props as unknown as React.ReactNode;\r\n\t}\r\n\r\n\tSlotComponent.slotSymbol = slotComponentSymbol;\r\n\tSlotComponent.slotName = \"\";\r\n\r\n\treturn SlotComponent;\r\n};\r\n\r\n/**\r\n * @description Slot component created by createSlotComponent\r\n */\r\nexport const SlotComponent = createSlotComponent();\r\n","import { mergeClassNames, mergeFunctions } from \"@zayne-labs/toolkit-core\";\nimport { isFunction, isPlainObject } from \"@zayne-labs/toolkit-type-helpers\";\n\n// const CSS_REGEX = /((?:--)?(?:\\w+-?)+)\\s*:\\s*([^;]*)/g;\n\n// const serialize = (style: string): Record<string, string> => {\n// \tconst res: Record<string, string> = {};\n// \tlet match: RegExpExecArray | null;\n// \twhile ((match = CSS_REGEX.exec(style))) {\n// \t\tres[match[1]!] = match[2]!;\n// \t}\n// \treturn res;\n// };\n\n// const css = (\n// \ta: Record<string, string> | string | undefined,\n// \tb: Record<string, string> | string | undefined\n// ): Record<string, string> | string => {\n// \tif (isString(a)) {\n// \t\tif (isString(b)) return `${a};${b}`;\n// \t\ta = serialize(a);\n// \t} else if (isString(b)) {\n// \t\tb = serialize(b);\n// \t}\n// \treturn Object.assign({}, a ?? {}, b ?? {});\n// };\n\ntype UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : \"\") extends (\n\tparam: infer TParam\n) => void\n\t? TParam\n\t: \"\";\n\n/* eslint-disable no-param-reassign -- Mutation is fine here since it's an internally managed object */\nconst handleMergePropsIntoResult = (\n\tmergedResult: Record<string, unknown>,\n\tpropsObject: Record<string, unknown>\n) => {\n\tfor (const propName of Object.keys(mergedResult)) {\n\t\tconst mergedResultValue = mergedResult[propName];\n\t\tconst propsObjectValue = propsObject[propName];\n\n\t\tif (propName === \"className\" || propName === \"class\") {\n\t\t\tmergedResult[propName] = mergeClassNames(mergedResultValue as string, propsObjectValue as string);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (propName === \"style\" && isPlainObject(mergedResultValue) && isPlainObject(propsObjectValue)) {\n\t\t\t// mergedResult[propName] = css(mergedResultValue, propsObjectValue);\n\t\t\tmergedResult[propName] = { ...mergedResultValue, ...propsObjectValue };\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isHandler = propName.startsWith(\"on\");\n\n\t\tif (isHandler && isFunction(mergedResultValue) && isFunction(propsObjectValue)) {\n\t\t\tmergedResult[propName] = mergeFunctions(propsObjectValue, mergedResultValue);\n\t\t\tcontinue;\n\t\t}\n\n\t\tmergedResult[propName] = propsObjectValue !== undefined ? propsObjectValue : mergedResultValue;\n\t}\n};\n\nconst addMissingPropsToResult = (\n\tmergedResult: Record<string, unknown>,\n\tpropsObject: Record<string, unknown>\n) => {\n\tfor (const propName of Object.keys(propsObject)) {\n\t\tif (mergedResult[propName] === undefined) {\n\t\t\tmergedResult[propName] = propsObject[propName];\n\t\t}\n\t}\n};\n/* eslint-enable no-param-reassign -- Mutation is fine here since it's an internally managed object */\n\ntype UnknownProps = Record<never, never>;\n\nconst mergeProps = <TProps extends UnknownProps>(\n\t...parameters: Array<TProps | undefined>\n): UnionToIntersection<TProps> => {\n\tconst mergedResult: Record<string, unknown> = {};\n\n\tfor (const propsObject of parameters) {\n\t\tif (!propsObject) continue;\n\n\t\thandleMergePropsIntoResult(mergedResult, propsObject);\n\n\t\t// == Add props from propsObject that are not in the mergedResult\n\t\taddMissingPropsToResult(mergedResult, propsObject);\n\t}\n\n\treturn mergedResult as never;\n};\n\nexport { mergeProps };\n","import { mergeClassNames, mergeFunctions } from \"@zayne-labs/toolkit-core\";\nimport { isFunction, isPlainObject } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype UnknownProps = Record<never, never>;\n\nconst mergeTwoProps = <TProps extends UnknownProps>(\n\tslotProps: TProps | undefined,\n\tchildProps: TProps | undefined\n): TProps => {\n\tif (!slotProps || !childProps) {\n\t\treturn childProps ?? slotProps ?? ({} as TProps);\n\t}\n\n\t// == all child props should override slotProps\n\tconst overrideProps = { ...childProps } as Record<string, unknown>;\n\n\tfor (const propName of Object.keys(slotProps)) {\n\t\tconst slotPropValue = (slotProps as Record<string, unknown>)[propName];\n\t\tconst childPropValue = (childProps as Record<string, unknown>)[propName];\n\n\t\t// == if it's `style`, we merge them\n\t\tif (propName === \"style\" && isPlainObject(slotPropValue) && isPlainObject(childPropValue)) {\n\t\t\toverrideProps[propName] = { ...slotPropValue, ...childPropValue };\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == if it's `className` or `class`, we merge them\n\t\tif (propName === \"className\" || propName === \"class\") {\n\t\t\toverrideProps[propName] = mergeClassNames(slotPropValue as string, childPropValue as string);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isHandler = propName.startsWith(\"on\");\n\n\t\t// == if the handler exists on both, we compose them\n\t\tif (isHandler && isFunction(slotPropValue) && isFunction(childPropValue)) {\n\t\t\toverrideProps[propName] = mergeFunctions(childPropValue, slotPropValue);\n\t\t}\n\t}\n\n\treturn { ...slotProps, ...overrideProps };\n};\n\nexport { mergeTwoProps };\n"]}
|
1
|
+
{"version":3,"sources":["../../../src/utils/composeRefs.ts","../../../src/utils/composeEventHandlers.ts","../../../src/utils/getSlotElement.ts","../../../src/utils/getSlotMap.ts","../../../src/utils/mergeProps.ts","../../../src/utils/mergeTwoProps.ts"],"names":["ReactFrag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AA,UAAAA,CAAW,cAAc,CAAG,EAAA;AACzE,MAAA,aAAA,CAAc,QAAQ,CAAA,GAAIG,cAAe,CAAA,cAAA,EAAgB,aAAa,CAAA;AAAA;AACvE;AAGD,EAAA,OAAO,EAAE,GAAG,SAAW,EAAA,GAAG,aAAc,EAAA;AACzC","file":"index.js","sourcesContent":["import { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { RefCallback } from \"react\";\n\ntype PossibleRef<TRef> = 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>(ref: PossibleRef<TRef>, node: TRef): 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\trefs: 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\t// == React 18 may not call the cleanup function so we need to call it manually on element unmount\n\t\tif (!node) {\n\t\t\tcleanupFn();\n\t\t\treturn;\n\t\t}\n\n\t\treturn cleanupFn;\n\t};\n\n\treturn mergedRefCallBack;\n};\n","type PossibleEventHandler<TSyntheticEvent extends React.SyntheticEvent> =\n\t| React.EventHandler<TSyntheticEvent>\n\t| undefined;\n\nexport const composeEventHandlers = <TSyntheticEvent extends React.SyntheticEvent>(\n\teventHandlers: Array<PossibleEventHandler<TSyntheticEvent>>\n): React.EventHandler<TSyntheticEvent> => {\n\t// prettier-ignore\n\tconst mergedEventHandler: React.EventHandler<TSyntheticEvent> = (event) => eventHandlers.forEach((handler) => handler?.(event));\n\n\treturn mergedEventHandler;\n};\n","import { toArray } from \"@zayne-labs/toolkit-core\";\nimport { AssertionError, type UnknownObject, isArray } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, isValidElement } from \"react\";\nimport type { InferProps } from \"./types\";\n\nexport type FunctionalComponent<TProps extends UnknownObject = never> = React.FunctionComponent<TProps>;\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)) {\n\t\treturn false;\n\t}\n\n\ttype WithSlot = { readonly slotSymbol?: unique symbol } | undefined;\n\n\tif (\n\t\t(child.type as WithSlot)?.slotSymbol\n\t\t&& (SlotComponent as WithSlot)?.slotSymbol\n\t\t&& Object.is((child.type as WithSlot)?.slotSymbol, (SlotComponent as WithSlot)?.slotSymbol)\n\t) {\n\t\treturn true;\n\t}\n\n\tif ((child.type as FunctionalComponent).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 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\t? children.props.children\n\t\t\t: children;\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\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) => {\n\ttype SlotsType = { [Key in keyof TSlotComponents]: ReturnType<TSlotComponents[Key]> };\n\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: isArray(throwOnMultipleSlotMatch)\n\t\t\t\t? throwOnMultipleSlotMatch[index]\n\t\t\t\t: throwOnMultipleSlotMatch,\n\t\t})\n\t) as SlotsType;\n\n\tconst regularChildren = getRegularChildren(children, SlotComponents);\n\n\treturn { regularChildren, slots };\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 = <TChildren extends React.ReactNode>(\n\tchildren: TChildren,\n\tSlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]\n) => {\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment\n\t\t\t? children.props.children\n\t\t\t: children;\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 as TChildren extends unknown[] ? TChildren : TChildren[];\n};\n","import { toArray } from \"@zayne-labs/toolkit-core\";\nimport type { UnionToIntersection, UnknownObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, isValidElement } from \"react\";\nimport type { InferProps } from \"./types\";\n\n/**\n * Maps slot names to their corresponding children types\n */\ntype GetSlotMapResult<TSlotComponentProps extends GetSlotComponentProps> = UnionToIntersection<{\n\t[TName in keyof TSlotComponentProps as TSlotComponentProps[\"name\"]]: TSlotComponentProps[\"children\"];\n}>;\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) => {\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment\n\t\t\t? children.props.children\n\t\t\t: children;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tconst slots: Record<string, React.ReactNode> & { default: React.ReactNode[] } = { default: [] };\n\n\tfor (const child of childrenArray) {\n\t\ttype SlotElementProps = TSlotComponentProps & { \"data-slot-name\": never };\n\n\t\ttype RegularElementProps = Pick<TSlotComponentProps, \"children\"> & {\n\t\t\t\"data-slot-name\": string;\n\t\t\tname: never;\n\t\t};\n\n\t\tconst isSlotElementWithName =\n\t\t\tisValidElement<SlotElementProps>(child)\n\t\t\t&& (child.type as SlotComponentType).slotSymbol === slotComponentSymbol\n\t\t\t&& Boolean((child.type as WithSlotSymbolAndName).slotName ?? child.props.name);\n\n\t\tconst isRegularElementWithSlotName =\n\t\t\tisValidElement<RegularElementProps>(child) && Boolean(child.props[\"data-slot-name\"]);\n\n\t\tif (!isSlotElementWithName && !isRegularElementWithSlotName) {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst slotName = isSlotElementWithName\n\t\t\t? ((child.type as WithSlotSymbolAndName).slotName ?? child.props.name)\n\t\t\t: child.props[\"data-slot-name\"];\n\n\t\tslots[slotName] = child.props.children;\n\t}\n\n\treturn slots as GetSlotMapResult<TSlotComponentProps> & { default: React.ReactNode[] };\n};\n\n/**\n * @description Produce props for the SlotComponent\n */\nexport type GetSlotComponentProps<\n\tTName extends string = string,\n\tTChildren extends React.ReactNode = React.ReactNode,\n> = {\n\t/** Content to render in the slot */\n\tchildren: TChildren;\n\t/** Name of the slot where content should be rendered */\n\tname: TName;\n};\n\n/**\n * @description Slot component created by createSlotComponent\n */\n\nexport const createSlotComponent = <TSlotComponentProps extends GetSlotComponentProps>() => {\n\tconst SlotComponent = (props: TSlotComponentProps) => props.children;\n\n\tSlotComponent.slotSymbol = slotComponentSymbol;\n\n\treturn SlotComponent;\n};\n\ntype SlotComponentType = ReturnType<typeof createSlotComponent>;\n\ntype WithSlotSymbolAndName<\n\tTSlotComponentProps extends Pick<GetSlotComponentProps, \"name\"> = Pick<GetSlotComponentProps, \"name\">,\n\tTActualProps extends UnknownObject = UnknownObject,\n> = {\n\t(props: Pick<GetSlotComponentProps, \"children\"> & TActualProps): React.ReactNode;\n\tslotName?: TSlotComponentProps[\"name\"];\n\tslotSymbol?: typeof slotComponentSymbol;\n};\n\nexport const withSlotSymbolAndName = <\n\tTSlotComponentProps extends Pick<GetSlotComponentProps, \"name\">,\n\tTActualProps extends UnknownObject = UnknownObject,\n>(\n\tname: TSlotComponentProps[\"name\"],\n\tSlotComponent: WithSlotSymbolAndName<TSlotComponentProps, TActualProps>\n) => {\n\t/* eslint-disable no-param-reassign -- This is necessary */\n\tSlotComponent.slotSymbol = slotComponentSymbol;\n\tSlotComponent.slotName = name;\n\t/* eslint-enable no-param-reassign -- This is necessary */\n\n\treturn SlotComponent;\n};\n","import { mergeClassNames, mergeFunctions } from \"@zayne-labs/toolkit-core\";\nimport { isFunction, isPlainObject } from \"@zayne-labs/toolkit-type-helpers\";\n\n// const CSS_REGEX = /((?:--)?(?:\\w+-?)+)\\s*:\\s*([^;]*)/g;\n\n// const serialize = (style: string): Record<string, string> => {\n// \tconst res: Record<string, string> = {};\n// \tlet match: RegExpExecArray | null;\n// \twhile ((match = CSS_REGEX.exec(style))) {\n// \t\tres[match[1]!] = match[2]!;\n// \t}\n// \treturn res;\n// };\n\n// const css = (\n// \ta: Record<string, string> | string | undefined,\n// \tb: Record<string, string> | string | undefined\n// ): Record<string, string> | string => {\n// \tif (isString(a)) {\n// \t\tif (isString(b)) return `${a};${b}`;\n// \t\ta = serialize(a);\n// \t} else if (isString(b)) {\n// \t\tb = serialize(b);\n// \t}\n// \treturn Object.assign({}, a ?? {}, b ?? {});\n// };\n\ntype UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : \"\") extends (\n\tparam: infer TParam\n) => void\n\t? TParam\n\t: \"\";\n\n/* eslint-disable no-param-reassign -- Mutation is fine here since it's an internally managed object */\nconst handleMergePropsIntoResult = (\n\tmergedResult: Record<string, unknown>,\n\tpropsObject: Record<string, unknown>\n) => {\n\tfor (const propName of Object.keys(mergedResult)) {\n\t\tconst mergedResultValue = mergedResult[propName];\n\t\tconst propsObjectValue = propsObject[propName];\n\n\t\tif (propName === \"className\" || propName === \"class\") {\n\t\t\tmergedResult[propName] = mergeClassNames(mergedResultValue as string, propsObjectValue as string);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (propName === \"style\" && isPlainObject(mergedResultValue) && isPlainObject(propsObjectValue)) {\n\t\t\t// mergedResult[propName] = css(mergedResultValue, propsObjectValue);\n\t\t\tmergedResult[propName] = { ...mergedResultValue, ...propsObjectValue };\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isHandler = propName.startsWith(\"on\");\n\n\t\tif (isHandler && isFunction(mergedResultValue) && isFunction(propsObjectValue)) {\n\t\t\tmergedResult[propName] = mergeFunctions(propsObjectValue, mergedResultValue);\n\t\t\tcontinue;\n\t\t}\n\n\t\tmergedResult[propName] = propsObjectValue !== undefined ? propsObjectValue : mergedResultValue;\n\t}\n};\n\nconst addMissingPropsToResult = (\n\tmergedResult: Record<string, unknown>,\n\tpropsObject: Record<string, unknown>\n) => {\n\tfor (const propName of Object.keys(propsObject)) {\n\t\tif (mergedResult[propName] === undefined) {\n\t\t\tmergedResult[propName] = propsObject[propName];\n\t\t}\n\t}\n};\n/* eslint-enable no-param-reassign -- Mutation is fine here since it's an internally managed object */\n\ntype UnknownProps = Record<never, never>;\n\nconst mergeProps = <TProps extends UnknownProps>(\n\t...parameters: Array<TProps | undefined>\n): UnionToIntersection<TProps> => {\n\tconst mergedResult: Record<string, unknown> = {};\n\n\tfor (const propsObject of parameters) {\n\t\tif (!propsObject) continue;\n\n\t\thandleMergePropsIntoResult(mergedResult, propsObject);\n\n\t\t// == Add props from propsObject that are not in the mergedResult\n\t\taddMissingPropsToResult(mergedResult, propsObject);\n\t}\n\n\treturn mergedResult as never;\n};\n\nexport { mergeProps };\n","import { mergeClassNames, mergeFunctions } from \"@zayne-labs/toolkit-core\";\nimport { isFunction, isPlainObject } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype UnknownProps = Record<never, never>;\n\nconst mergeTwoProps = <TProps extends UnknownProps>(\n\tslotProps: TProps | undefined,\n\tchildProps: TProps | undefined\n): TProps => {\n\tif (!slotProps || !childProps) {\n\t\treturn childProps ?? slotProps ?? ({} as TProps);\n\t}\n\n\t// == all child props should override slotProps\n\tconst overrideProps = { ...childProps } as Record<string, unknown>;\n\n\tfor (const propName of Object.keys(slotProps)) {\n\t\tconst slotPropValue = (slotProps as Record<string, unknown>)[propName];\n\t\tconst childPropValue = (childProps as Record<string, unknown>)[propName];\n\n\t\t// == if it's `style`, we merge them\n\t\tif (propName === \"style\" && isPlainObject(slotPropValue) && isPlainObject(childPropValue)) {\n\t\t\toverrideProps[propName] = { ...slotPropValue, ...childPropValue };\n\t\t\tcontinue;\n\t\t}\n\n\t\t// == if it's `className` or `class`, we merge them\n\t\tif (propName === \"className\" || propName === \"class\") {\n\t\t\toverrideProps[propName] = mergeClassNames(slotPropValue as string, childPropValue as string);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isHandler = propName.startsWith(\"on\");\n\n\t\t// == if the handler exists on both, we compose them\n\t\tif (isHandler && isFunction(slotPropValue) && isFunction(childPropValue)) {\n\t\t\toverrideProps[propName] = mergeFunctions(childPropValue, slotPropValue);\n\t\t}\n\t}\n\n\treturn { ...slotProps, ...overrideProps };\n};\n\nexport { mergeTwoProps };\n"]}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zayne-labs/toolkit-react",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.9.
|
4
|
+
"version": "0.9.14",
|
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",
|
@@ -50,8 +50,8 @@
|
|
50
50
|
}
|
51
51
|
},
|
52
52
|
"dependencies": {
|
53
|
-
"@zayne-labs/toolkit-core": "0.9.
|
54
|
-
"@zayne-labs/toolkit-type-helpers": "0.9.
|
53
|
+
"@zayne-labs/toolkit-core": "0.9.14",
|
54
|
+
"@zayne-labs/toolkit-type-helpers": "0.9.14"
|
55
55
|
},
|
56
56
|
"devDependencies": {
|
57
57
|
"@arethetypeswrong/cli": "^0.17.4",
|
@@ -76,7 +76,8 @@
|
|
76
76
|
},
|
77
77
|
"publishConfig": {
|
78
78
|
"access": "public",
|
79
|
-
"registry": "https://registry.npmjs.org/"
|
79
|
+
"registry": "https://registry.npmjs.org/",
|
80
|
+
"provenance": true
|
80
81
|
},
|
81
82
|
"size-limit": [
|
82
83
|
{
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"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/useConstant.ts","../../src/hooks/useAnimationInterval.ts","../../src/hooks/useClickOutside.ts","../../src/hooks/useCopyToClipboard.ts","../../src/hooks/useDebounce.ts","../../src/hooks/useToggle.ts","../../src/hooks/useDisclosure.ts","../../src/hooks/useIsServer.ts","../../src/hooks/useStore.ts","../../src/hooks/useLocation.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/useStorageState.ts","../../src/hooks/useThrottle.ts"],"names":["useRef","useEffect","useCallback","useState","useSyncExternalStore","on"],"mappings":";;;;;AAGa,IAAA,YAAA,GAAN,cAA2B,KAAM,CAAA;AAAA,EAC9B,IAAO,GAAA,cAAA;AAAA,EAEhB,eAAe,IAAgC,EAAA;AAC9C,IAAA,KAAA,CAAM,GAAG,IAAI,CAAA;AAEb,IAAM,KAAA,CAAA,iBAAA,CAAkB,IAAM,EAAA,IAAA,CAAK,WAAW,CAAA;AAAA;AAEhD;AAEa,IAAA,eAAA,GAAkB,CAAC,IAAA,EAAc,QAAqB,KAAA;AAClE,EAAO,OAAA,CAAA,EAAG,IAAI,CAAA,yEAAA,EAA4E,QAAQ,CAAA,CAAA,CAAA;AACnG;AAgBA,IAAM,mBAAsB,GAAA,CAC3B,OAAwD,GAAA,EACpD,KAAA;AACJ,EAAM,MAAA;AAAA,IACL,YAAe,GAAA,IAAA;AAAA,IACf,YAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAW,GAAA,mBAAA;AAAA,IACX,YAAe,GAAA,wBAAA;AAAA,IACf,IAAA,GAAO,aAAa,QAAS,CAAA,UAAU,IAAI,YAAa,CAAA,KAAA,CAAM,CAAG,EAAA,EAAE,CAAI,GAA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AA;AAEvE,EAAA,OAAO,CAAC,cAAA,EAAgB,aAAc,CAAA,QAAA,EAAU,aAAa,CAAA;AAK9D;AC9Ca,IAAA,uBAAA,GAA0B,CAAU,UAAA,EAAiC,KAAkB,KAAA;AACnG,EAAM,MAAA,cAAA,GAAiB,eAAe,UAAU,CAAA;AAEhD,EAAA,MAAM,oBAAoB,WAAY,CAAA,MAAM,oBAAqB,CAAA,cAAA,EAAgB,KAAK,CAAC,CAAA;AAEvF,EAAiB,gBAAA,CAAA,MAAM,iBAAkB,CAAA,aAAA,EAAe,CAAA;AAExD,EAAO,OAAA,iBAAA;AACR;AAEa,IAAA,kBAAA,GAAqB,CAAU,UAAA,EAAiC,KAAkB,KAAA;AAC9F,EAAM,MAAA,cAAA,GAAiB,eAAe,UAAU,CAAA;AAEhD,EAAA,MAAM,oBAAoB,WAAY,CAAA,MAAM,cAAe,CAAA,cAAA,EAAgB,KAAK,CAAC,CAAA;AAEjF,EAAO,OAAA,iBAAA;AACR;AAEa,IAAA,kBAAA,GAAqB,CAAU,UAAoC,KAAA;AAC/E,EAAM,MAAA,cAAA,GAAiB,eAAe,UAAU,CAAA;AAEhD,EAAA,MAAM,iBAAoB,GAAA,WAAA,CAAY,MAAM,eAAA,CAAgB,cAAc,CAAC,CAAA;AAE3E,EAAiB,gBAAA,CAAA,MAAM,iBAAkB,CAAA,eAAA,EAAiB,CAAA;AAE1D,EAAO,OAAA,iBAAA;AACR","file":"chunk-U2YL6UOG.js","sourcesContent":["import { defineEnum } from \"@zayne-labs/toolkit-type-helpers\";\r\nimport { createContext, use } from \"react\";\r\n\r\nexport class ContextError extends Error {\r\n\toverride name = \"ContextError\";\r\n\r\n\tconstructor(...args: Parameters<typeof Error>) {\r\n\t\tsuper(...args);\r\n\r\n\t\tError.captureStackTrace(this, this.constructor);\r\n\t}\r\n}\r\n\r\nexport const getErrorMessage = (hook: string, provider: string) => {\r\n\treturn `${hook} returned \"null\". Did you forget to wrap the necessary components within ${provider}?`;\r\n};\r\n\r\nexport type CustomContextOptions<TContextValue, TStrict extends boolean> = {\r\n\tdefaultValue?: TContextValue | null;\r\n\terrorMessage?: string;\r\n\textension?: (contextValue: NoInfer<TContextValue> | null) => TContextValue | null;\r\n\thookName?: string;\r\n\tname?: string;\r\n\tproviderName?: string;\r\n\tstrict?: TStrict;\r\n};\r\n\r\ntype UseCustomContextResult<TContextValue, TStrict extends boolean> = TStrict extends true\r\n\t? TContextValue\r\n\t: TContextValue | null;\r\n\r\nconst createCustomContext = <TContextValue, TStrict extends boolean = true>(\r\n\toptions: CustomContextOptions<TContextValue, TStrict> = {}\r\n) => {\r\n\tconst {\r\n\t\tdefaultValue = null,\r\n\t\terrorMessage,\r\n\t\textension,\r\n\t\thookName = \"useUnnamedContext\",\r\n\t\tproviderName = \"UnnamedContextProvider\",\r\n\t\tname = providerName.endsWith(\"Provider\") ? providerName.slice(0, -8) : \"UnnamedContext\",\r\n\t\tstrict = true,\r\n\t} = options;\r\n\r\n\tconst Context = createContext<TContextValue | null>(defaultValue);\r\n\r\n\tContext.displayName = name;\r\n\r\n\tconst useCustomContext = (): UseCustomContextResult<TContextValue, TStrict> => {\r\n\t\tconst contextValue = use(Context);\r\n\r\n\t\tconst extendedContextValue = extension?.(contextValue) ?? contextValue;\r\n\r\n\t\tif (strict && extendedContextValue === null) {\r\n\t\t\tthrow new ContextError(errorMessage ?? getErrorMessage(hookName, providerName));\r\n\t\t}\r\n\r\n\t\treturn extendedContextValue as NonNullable<typeof extendedContextValue>;\r\n\t};\r\n\r\n\treturn defineEnum([Context.Provider, useCustomContext]);\r\n};\r\n\r\nexport { createCustomContext };\r\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\";\r\nimport { useCallbackRef } from \"../useCallbackRef\";\r\n\r\nexport function useAsyncEffect(\r\n\teffect: () => Promise<ReturnType<React.EffectCallback>>,\r\n\tdeps?: React.DependencyList\r\n) {\r\n\tconst stableEffectCallback = useCallbackRef(effect);\r\n\tconst [destroy, setDestroy] = useState<ReturnType<React.EffectCallback>>();\r\n\r\n\tuseEffect(() => {\r\n\t\tconst e = stableEffectCallback();\r\n\r\n\t\tasync function execute() {\r\n\t\t\tsetDestroy(await e);\r\n\t\t}\r\n\r\n\t\tvoid execute();\r\n\r\n\t\treturn () => void destroy?.();\r\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- stableEffectCallback is stable\r\n\t}, deps);\r\n}\r\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 { useRef } from \"react\";\r\n\r\nconst useConstant = <TResult>(initCallbackFn: () => TResult) => {\r\n\tconst resultRef = useRef<TResult | null>(null);\r\n\r\n\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- The current case is justified since it's optimizable by the react compiler\r\n\tif (resultRef.current === null) {\r\n\t\tresultRef.current = initCallbackFn();\r\n\t}\r\n\r\n\treturn resultRef.current;\r\n};\r\n\r\nexport { useConstant };\r\n","import { type AnimationIntervalOptions, setAnimationInterval } from \"@zayne-labs/toolkit-core\";\nimport type { Prettify } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useEffect } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useConstant } from \"./useConstant\";\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\t// prettier-ignore\n\tconst { start, stop } = useConstant(() => setAnimationInterval(latestCallback, intervalDuration, { once }));\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\";\r\nimport { useEffect } from \"react\";\r\nimport { useCallbackRef } from \"./useCallbackRef\";\r\n\r\ntype UseClickOutsideOptions = {\r\n\tenabled?: boolean;\r\n};\r\n\r\nconst useClickOutside = <TElement extends HTMLElement>(\r\n\trefOrRefArray: Array<React.RefObject<TElement>> | React.RefObject<TElement>,\r\n\tcallback: (event: MouseEvent | TouchEvent) => void,\r\n\toptions?: UseClickOutsideOptions\r\n) => {\r\n\tconst { enabled = true } = options ?? {};\r\n\r\n\tconst savedCallback = useCallbackRef(callback);\r\n\r\n\tuseEffect(() => {\r\n\t\tif (!enabled) return;\r\n\r\n\t\tconst controller = new AbortController();\r\n\r\n\t\tconst elementArray = toArray(refOrRefArray).map((ref) => ref.current);\r\n\r\n\t\tonClickOutside(elementArray, savedCallback, { signal: controller.signal });\r\n\r\n\t\treturn () => {\r\n\t\t\tcontroller.abort();\r\n\t\t};\r\n\t}, [enabled, refOrRefArray, savedCallback]);\r\n};\r\n\r\nexport { useClickOutside };\r\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 { useState } from \"react\";\nimport { useUnmountEffect } from \"./effects/useUnMountEffect\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useConstant } from \"./useConstant\";\n\nexport const useDebouncedFn = <TParams>(callBackFn: CallbackFn<TParams>, delay: number | undefined) => {\n\tconst latestCallback = useCallbackRef(callBackFn);\n\n\tconst debouncedFn = useConstant(() => debounce(latestCallback, delay));\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 = useConstant(() => debounce(setValue, 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 { 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 handleScrollControl = useCallbackRef(\n\t\t(state: boolean) => hasScrollControl && lockScroll({ isActive: state })\n\t);\n\n\tconst onOpen = useCallbackRef(<TValue>(value?: TValue) => {\n\t\tconst booleanValue = typeof value === \"boolean\" && value ? value : true;\n\t\ttoggleIsOpen(booleanValue);\n\t\thandleScrollControl(booleanValue);\n\t});\n\n\tconst onClose = useCallbackRef(<TValue>(value?: TValue) => {\n\t\tconst booleanValue = typeof value === \"boolean\" && !value ? value : false;\n\n\t\ttoggleIsOpen(booleanValue);\n\t\thandleScrollControl(booleanValue);\n\t});\n\n\tconst onToggle = useCallbackRef(<TValue>(value?: TValue) => {\n\t\tif (typeof value === \"boolean\") {\n\t\t\tvalue ? onOpen(value) : onClose(value);\n\t\t\treturn;\n\t\t}\n\n\t\tisOpen ? onClose() : onOpen();\n\t});\n\n\treturn { isOpen, onClose, onOpen, onToggle };\n};\n\nexport { useDisclosure };\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 { useDebugValue, useSyncExternalStore } from \"react\";\n\nconst useStore = <TState, TSlice>(store: StoreApi<TState>, selector: SelectorFn<TState, TSlice>) => {\n\tconst slice = useSyncExternalStore(\n\t\tstore.subscribe,\n\t\t() => selector(store.getState()),\n\t\t() => selector(store.getInitialState())\n\t);\n\n\tuseDebugValue(slice);\n\n\treturn slice;\n};\n\nexport { useStore };\n","import {\n\ttype LocationInfo,\n\ttype LocationStoreOptions,\n\tcreateLocationStore,\n} from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useConstant } from \"./useConstant\";\nimport { useStore } from \"./useStore\";\n\ntype LocationStore = ReturnType<typeof createLocationStore>;\n\ntype UseLocationResult<TSlice> = [\n\tstate: TSlice,\n\tsetState: {\n\t\tpush: LocationStore[\"push\"];\n\t\treplace: LocationStore[\"replace\"];\n\t\ttriggerPopstate: LocationStore[\"triggerPopstateEvent\"];\n\t},\n];\n\nconst useLocation = <TSlice = LocationInfo>(\n\tselector: SelectorFn<LocationInfo, TSlice>,\n\toptions?: LocationStoreOptions\n) => {\n\tconst locationStore = useConstant(() => createLocationStore(options));\n\n\tconst stateSlice = useStore(locationStore as never, selector);\n\n\treturn [\n\t\tstateSlice,\n\t\t{\n\t\t\tpush: locationStore.push,\n\t\t\treplace: locationStore.replace,\n\t\t\ttriggerPopstate: locationStore.triggerPopstateEvent,\n\t\t},\n\t] as UseLocationResult<TSlice>;\n};\n\nexport { useLocation };\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 { type ScrollObserverOptions, createScrollObserver } from \"@zayne-labs/toolkit-core\";\nimport { type RefCallback, useState } from \"react\";\nimport { useCallbackRef } from \"./useCallbackRef\";\nimport { useConstant } from \"./useConstant\";\n\nconst useScrollObserver = <TElement extends HTMLElement>(options: ScrollObserverOptions = {}) => {\n\tconst { onIntersection, rootMargin = \"10px 0px 0px 0px\", ...restOfOptions } = options;\n\n\tconst [isScrolled, setIsScrolled] = useState(false);\n\n\tconst savedOnIntersection = useCallbackRef(onIntersection);\n\n\tconst { handleObservation } = useConstant(() => {\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\trootMargin,\n\t\t\t...restOfOptions,\n\t\t});\n\t});\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 { useLocation } from \"./useLocation\";\n\ntype UseSearchParamsOptions = {\n\taction?: \"push\" | \"replace\";\n\tlocationOptions?: LocationStoreOptions;\n};\n\nexport const useSearchParams = <TSearchParams extends URLSearchParamsInit>(\n\toptions?: UseSearchParamsOptions\n) => {\n\tconst { action = \"push\", locationOptions } = options ?? {};\n\n\tconst [searchParams, setLocation] = useLocation((state) => state.search, locationOptions);\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\tif (Object.is(searchParams.toString(), nextSearchParams.toString())) return;\n\n\t\tsetLocation[action]({ search: nextSearchParams });\n\t};\n\n\tsetSearchParams.triggerPopstate = setLocation.triggerPopstate;\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\treturn [searchParamsObject, setSearchParamsObject] as const;\n};\n","import {\n\ttype SetStorageState,\n\ttype StorageOptions,\n\tcreateExternalStorageStore,\n} from \"@zayne-labs/toolkit-core\";\nimport { type SelectorFn, isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useConstant } from \"./useConstant\";\nimport { useStore } from \"./useStore\";\n\ntype UseStorageStateOptions<TValue, TSlice = TValue> = StorageOptions<TValue> & {\n\tselect?: SelectorFn<TValue, TSlice>;\n};\n\ntype StorageStoreApi<TValue> = ReturnType<typeof createExternalStorageStore<TValue>>;\n\ntype ParamsOne<TValue, TSlice> = [\n\tkey: string,\n\tinitialValue?: TValue,\n\toptions?: Omit<UseStorageStateOptions<TValue, TSlice>, \"initialValue\" | \"key\">,\n];\n\ntype ParamsTwo<TValue, TSlice> = [options: UseStorageStateOptions<TValue, TSlice>];\n\ntype UseStorageStateParams<TValue, TSlice> = ParamsOne<TValue, TSlice> | ParamsTwo<TValue, TSlice>;\n\n// TODO: Add createImpl that returns a hook for react later\nconst useStorageState = <TValue, TSlice = TValue>(...params: UseStorageStateParams<TValue, TSlice>) => {\n\tconst [keyOrOptions, $initialValue, options] = params;\n\n\tconst _key = isString(keyOrOptions) ? keyOrOptions : keyOrOptions.key;\n\tconst _initialValue = isString(keyOrOptions) ? $initialValue : keyOrOptions.initialValue;\n\n\tconst {\n\t\tinitialValue = _initialValue,\n\t\tkey = _key,\n\t\tselect = (value: TValue) => value,\n\t\t...restOfOptions\n\t} = isString(keyOrOptions)\n\t\t? ((options as UseStorageStateOptions<TValue, TSlice> | undefined) ?? {})\n\t\t: keyOrOptions;\n\n\tconst externalStore = useConstant(() =>\n\t\tcreateExternalStorageStore({ initialValue, key, ...restOfOptions })\n\t);\n\n\tconst stateInStorage = useStore(externalStore as never, select as never);\n\n\treturn [stateInStorage, externalStore.setState, externalStore] as [\n\t\tstate: TValue,\n\t\tsetState: SetStorageState<TValue>,\n\t\tstoreApi: StorageStoreApi<TValue>,\n\t];\n};\n\nexport { useStorageState };\n","import { throttleByFrame, throttleBySetTimeout, throttleByTime } from \"@zayne-labs/toolkit-core\";\nimport type { CallbackFn } from \"@zayne-labs/toolkit-type-helpers\";\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 = useConstant(() => throttleBySetTimeout(latestCallback, delay));\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 = useConstant(() => throttleByTime(latestCallback, delay));\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"]}
|