@contember/react-utils 2.1.0-alpha.36 → 2.1.0-alpha.39
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/development/index.cjs +86 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/index.js +86 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/src/context/createContext.cjs +10 -0
- package/dist/development/src/context/createContext.cjs.map +1 -0
- package/dist/development/src/context/createContext.js +10 -0
- package/dist/development/src/context/createContext.js.map +1 -0
- package/dist/development/src/context/createRequiredContext.cjs +18 -0
- package/dist/development/src/context/createRequiredContext.cjs.map +1 -0
- package/dist/development/src/context/createRequiredContext.js +18 -0
- package/dist/development/src/context/createRequiredContext.js.map +1 -0
- package/dist/development/src/debug-context/Constants.cjs +25 -0
- package/dist/development/src/debug-context/Constants.cjs.map +1 -0
- package/dist/development/src/debug-context/Constants.js +25 -0
- package/dist/development/src/debug-context/Constants.js.map +1 -0
- package/dist/development/src/debug-context/Context.cjs +72 -0
- package/dist/development/src/debug-context/Context.cjs.map +1 -0
- package/dist/development/src/debug-context/Context.js +72 -0
- package/dist/development/src/debug-context/Context.js.map +1 -0
- package/dist/development/src/hooks/unwrapRefValue.cjs +11 -0
- package/dist/development/src/hooks/unwrapRefValue.cjs.map +1 -0
- package/dist/development/src/hooks/unwrapRefValue.js +11 -0
- package/dist/development/src/hooks/unwrapRefValue.js.map +1 -0
- package/dist/development/src/hooks/useAbortController.cjs +17 -0
- package/dist/development/src/hooks/useAbortController.cjs.map +1 -0
- package/dist/development/src/hooks/useAbortController.js +17 -0
- package/dist/development/src/hooks/useAbortController.js.map +1 -0
- package/dist/development/src/hooks/useArrayMapMemo.cjs +11 -0
- package/dist/development/src/hooks/useArrayMapMemo.cjs.map +1 -0
- package/dist/development/src/hooks/useArrayMapMemo.js +11 -0
- package/dist/development/src/hooks/useArrayMapMemo.js.map +1 -0
- package/dist/development/src/hooks/useAutoHeightTextArea.cjs +43 -0
- package/dist/development/src/hooks/useAutoHeightTextArea.cjs.map +1 -0
- package/dist/development/src/hooks/useAutoHeightTextArea.js +43 -0
- package/dist/development/src/hooks/useAutoHeightTextArea.js.map +1 -0
- package/dist/development/src/hooks/useChildrenAsLabel.cjs +53 -0
- package/dist/development/src/hooks/useChildrenAsLabel.cjs.map +1 -0
- package/dist/development/src/hooks/useChildrenAsLabel.js +53 -0
- package/dist/development/src/hooks/useChildrenAsLabel.js.map +1 -0
- package/dist/development/src/hooks/useComposeRef.cjs +31 -0
- package/dist/development/src/hooks/useComposeRef.cjs.map +1 -0
- package/dist/development/src/hooks/useComposeRef.js +31 -0
- package/dist/development/src/hooks/useComposeRef.js.map +1 -0
- package/dist/development/src/hooks/useConstantLengthInvariant.cjs +15 -0
- package/dist/development/src/hooks/useConstantLengthInvariant.cjs.map +1 -0
- package/dist/development/src/hooks/useConstantLengthInvariant.js +15 -0
- package/dist/development/src/hooks/useConstantLengthInvariant.js.map +1 -0
- package/dist/development/src/hooks/useConstantValueInvariant.cjs +15 -0
- package/dist/development/src/hooks/useConstantValueInvariant.cjs.map +1 -0
- package/dist/development/src/hooks/useConstantValueInvariant.js +15 -0
- package/dist/development/src/hooks/useConstantValueInvariant.js.map +1 -0
- package/dist/development/src/hooks/useDebounce.cjs +15 -0
- package/dist/development/src/hooks/useDebounce.cjs.map +1 -0
- package/dist/development/src/hooks/useDebounce.js +15 -0
- package/dist/development/src/hooks/useDebounce.js.map +1 -0
- package/dist/development/src/hooks/useDebounceCallback.cjs +19 -0
- package/dist/development/src/hooks/useDebounceCallback.cjs.map +1 -0
- package/dist/development/src/hooks/useDebounceCallback.js +19 -0
- package/dist/development/src/hooks/useDebounceCallback.js.map +1 -0
- package/dist/development/src/hooks/useDocumentTitle.cjs +22 -0
- package/dist/development/src/hooks/useDocumentTitle.cjs.map +1 -0
- package/dist/development/src/hooks/useDocumentTitle.js +22 -0
- package/dist/development/src/hooks/useDocumentTitle.js.map +1 -0
- package/dist/development/src/hooks/useExpectSameValueReference.cjs +24 -0
- package/dist/development/src/hooks/useExpectSameValueReference.cjs.map +1 -0
- package/dist/development/src/hooks/useExpectSameValueReference.js +24 -0
- package/dist/development/src/hooks/useExpectSameValueReference.js.map +1 -0
- package/dist/development/src/hooks/useForceRender.cjs +9 -0
- package/dist/development/src/hooks/useForceRender.cjs.map +1 -0
- package/dist/development/src/hooks/useForceRender.js +9 -0
- package/dist/development/src/hooks/useForceRender.js.map +1 -0
- package/dist/development/src/hooks/useId.cjs +13 -0
- package/dist/development/src/hooks/useId.cjs.map +1 -0
- package/dist/development/src/hooks/useId.js +13 -0
- package/dist/development/src/hooks/useId.js.map +1 -0
- package/dist/development/src/hooks/useIsMounted.cjs +18 -0
- package/dist/development/src/hooks/useIsMounted.cjs.map +1 -0
- package/dist/development/src/hooks/useIsMounted.js +18 -0
- package/dist/development/src/hooks/useIsMounted.js.map +1 -0
- package/dist/development/src/hooks/useObjectMemo.cjs +27 -0
- package/dist/development/src/hooks/useObjectMemo.cjs.map +1 -0
- package/dist/development/src/hooks/useObjectMemo.js +27 -0
- package/dist/development/src/hooks/useObjectMemo.js.map +1 -0
- package/dist/development/src/hooks/useOnElementClickOutsideCallback.cjs +20 -0
- package/dist/development/src/hooks/useOnElementClickOutsideCallback.cjs.map +1 -0
- package/dist/development/src/hooks/useOnElementClickOutsideCallback.js +20 -0
- package/dist/development/src/hooks/useOnElementClickOutsideCallback.js.map +1 -0
- package/dist/development/src/hooks/useOnElementMouseEnterDelayedCallback.cjs +33 -0
- package/dist/development/src/hooks/useOnElementMouseEnterDelayedCallback.cjs.map +1 -0
- package/dist/development/src/hooks/useOnElementMouseEnterDelayedCallback.js +33 -0
- package/dist/development/src/hooks/useOnElementMouseEnterDelayedCallback.js.map +1 -0
- package/dist/development/src/hooks/useOnElementResize.cjs +42 -0
- package/dist/development/src/hooks/useOnElementResize.cjs.map +1 -0
- package/dist/development/src/hooks/useOnElementResize.js +42 -0
- package/dist/development/src/hooks/useOnElementResize.js.map +1 -0
- package/dist/development/src/hooks/useOnWindowResize.cjs +36 -0
- package/dist/development/src/hooks/useOnWindowResize.cjs.map +1 -0
- package/dist/development/src/hooks/useOnWindowResize.js +36 -0
- package/dist/development/src/hooks/useOnWindowResize.js.map +1 -0
- package/dist/development/src/hooks/usePreviousValue.cjs +12 -0
- package/dist/development/src/hooks/usePreviousValue.cjs.map +1 -0
- package/dist/development/src/hooks/usePreviousValue.js +12 -0
- package/dist/development/src/hooks/usePreviousValue.js.map +1 -0
- package/dist/development/src/hooks/useStoredState.cjs +100 -0
- package/dist/development/src/hooks/useStoredState.cjs.map +1 -0
- package/dist/development/src/hooks/useStoredState.js +100 -0
- package/dist/development/src/hooks/useStoredState.js.map +1 -0
- package/dist/development/src/hooks/useUpdatedRef.cjs +10 -0
- package/dist/development/src/hooks/useUpdatedRef.cjs.map +1 -0
- package/dist/development/src/hooks/useUpdatedRef.js +10 -0
- package/dist/development/src/hooks/useUpdatedRef.js.map +1 -0
- package/dist/development/src/hooks/useWindowSize.cjs +20 -0
- package/dist/development/src/hooks/useWindowSize.cjs.map +1 -0
- package/dist/development/src/hooks/useWindowSize.js +20 -0
- package/dist/development/src/hooks/useWindowSize.js.map +1 -0
- package/dist/development/src/referentiallyStable/emptyArray.cjs +5 -0
- package/dist/development/src/referentiallyStable/emptyArray.cjs.map +1 -0
- package/dist/development/src/referentiallyStable/emptyArray.js +5 -0
- package/dist/development/src/referentiallyStable/emptyArray.js.map +1 -0
- package/dist/development/src/referentiallyStable/emptyObject.cjs +5 -0
- package/dist/development/src/referentiallyStable/emptyObject.cjs.map +1 -0
- package/dist/development/src/referentiallyStable/emptyObject.js +5 -0
- package/dist/development/src/referentiallyStable/emptyObject.js.map +1 -0
- package/dist/development/src/referentiallyStable/identityFunction.cjs +5 -0
- package/dist/development/src/referentiallyStable/identityFunction.cjs.map +1 -0
- package/dist/development/src/referentiallyStable/identityFunction.js +5 -0
- package/dist/development/src/referentiallyStable/identityFunction.js.map +1 -0
- package/dist/development/src/referentiallyStable/noop.cjs +5 -0
- package/dist/development/src/referentiallyStable/noop.cjs.map +1 -0
- package/dist/development/src/referentiallyStable/noop.js +5 -0
- package/dist/development/src/referentiallyStable/noop.js.map +1 -0
- package/dist/development/src/referentiallyStable/returnFalse.cjs +5 -0
- package/dist/development/src/referentiallyStable/returnFalse.cjs.map +1 -0
- package/dist/development/src/referentiallyStable/returnFalse.js +5 -0
- package/dist/development/src/referentiallyStable/returnFalse.js.map +1 -0
- package/dist/development/src/referentiallyStable/returnTrue.cjs +5 -0
- package/dist/development/src/referentiallyStable/returnTrue.cjs.map +1 -0
- package/dist/development/src/referentiallyStable/returnTrue.js +5 -0
- package/dist/development/src/referentiallyStable/returnTrue.js.map +1 -0
- package/dist/development/src/referentiallyStable/useReferentiallyStableCallback.cjs +15 -0
- package/dist/development/src/referentiallyStable/useReferentiallyStableCallback.cjs.map +1 -0
- package/dist/development/src/referentiallyStable/useReferentiallyStableCallback.js +15 -0
- package/dist/development/src/referentiallyStable/useReferentiallyStableCallback.js.map +1 -0
- package/dist/production/index.cjs +86 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/index.js +86 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/src/context/createContext.cjs +10 -0
- package/dist/production/src/context/createContext.cjs.map +1 -0
- package/dist/production/src/context/createContext.js +10 -0
- package/dist/production/src/context/createContext.js.map +1 -0
- package/dist/production/src/context/createRequiredContext.cjs +18 -0
- package/dist/production/src/context/createRequiredContext.cjs.map +1 -0
- package/dist/production/src/context/createRequiredContext.js +18 -0
- package/dist/production/src/context/createRequiredContext.js.map +1 -0
- package/dist/production/src/debug-context/Constants.cjs +25 -0
- package/dist/production/src/debug-context/Constants.cjs.map +1 -0
- package/dist/production/src/debug-context/Constants.js +25 -0
- package/dist/production/src/debug-context/Constants.js.map +1 -0
- package/dist/production/src/debug-context/Context.cjs +68 -0
- package/dist/production/src/debug-context/Context.cjs.map +1 -0
- package/dist/production/src/debug-context/Context.js +68 -0
- package/dist/production/src/debug-context/Context.js.map +1 -0
- package/dist/production/src/hooks/unwrapRefValue.cjs +11 -0
- package/dist/production/src/hooks/unwrapRefValue.cjs.map +1 -0
- package/dist/production/src/hooks/unwrapRefValue.js +11 -0
- package/dist/production/src/hooks/unwrapRefValue.js.map +1 -0
- package/dist/production/src/hooks/useAbortController.cjs +17 -0
- package/dist/production/src/hooks/useAbortController.cjs.map +1 -0
- package/dist/production/src/hooks/useAbortController.js +17 -0
- package/dist/production/src/hooks/useAbortController.js.map +1 -0
- package/dist/production/src/hooks/useArrayMapMemo.cjs +9 -0
- package/dist/production/src/hooks/useArrayMapMemo.cjs.map +1 -0
- package/dist/production/src/hooks/useArrayMapMemo.js +9 -0
- package/dist/production/src/hooks/useArrayMapMemo.js.map +1 -0
- package/dist/production/src/hooks/useAutoHeightTextArea.cjs +43 -0
- package/dist/production/src/hooks/useAutoHeightTextArea.cjs.map +1 -0
- package/dist/production/src/hooks/useAutoHeightTextArea.js +43 -0
- package/dist/production/src/hooks/useAutoHeightTextArea.js.map +1 -0
- package/dist/production/src/hooks/useChildrenAsLabel.cjs +51 -0
- package/dist/production/src/hooks/useChildrenAsLabel.cjs.map +1 -0
- package/dist/production/src/hooks/useChildrenAsLabel.js +51 -0
- package/dist/production/src/hooks/useChildrenAsLabel.js.map +1 -0
- package/dist/production/src/hooks/useComposeRef.cjs +31 -0
- package/dist/production/src/hooks/useComposeRef.cjs.map +1 -0
- package/dist/production/src/hooks/useComposeRef.js +31 -0
- package/dist/production/src/hooks/useComposeRef.js.map +1 -0
- package/dist/production/src/hooks/useConstantLengthInvariant.cjs +6 -0
- package/dist/production/src/hooks/useConstantLengthInvariant.cjs.map +1 -0
- package/dist/production/src/hooks/useConstantLengthInvariant.js +6 -0
- package/dist/production/src/hooks/useConstantLengthInvariant.js.map +1 -0
- package/dist/production/src/hooks/useConstantValueInvariant.cjs +6 -0
- package/dist/production/src/hooks/useConstantValueInvariant.cjs.map +1 -0
- package/dist/production/src/hooks/useConstantValueInvariant.js +6 -0
- package/dist/production/src/hooks/useConstantValueInvariant.js.map +1 -0
- package/dist/production/src/hooks/useDebounce.cjs +15 -0
- package/dist/production/src/hooks/useDebounce.cjs.map +1 -0
- package/dist/production/src/hooks/useDebounce.js +15 -0
- package/dist/production/src/hooks/useDebounce.js.map +1 -0
- package/dist/production/src/hooks/useDebounceCallback.cjs +19 -0
- package/dist/production/src/hooks/useDebounceCallback.cjs.map +1 -0
- package/dist/production/src/hooks/useDebounceCallback.js +19 -0
- package/dist/production/src/hooks/useDebounceCallback.js.map +1 -0
- package/dist/production/src/hooks/useDocumentTitle.cjs +22 -0
- package/dist/production/src/hooks/useDocumentTitle.cjs.map +1 -0
- package/dist/production/src/hooks/useDocumentTitle.js +22 -0
- package/dist/production/src/hooks/useDocumentTitle.js.map +1 -0
- package/dist/production/src/hooks/useExpectSameValueReference.cjs +15 -0
- package/dist/production/src/hooks/useExpectSameValueReference.cjs.map +1 -0
- package/dist/production/src/hooks/useExpectSameValueReference.js +15 -0
- package/dist/production/src/hooks/useExpectSameValueReference.js.map +1 -0
- package/dist/production/src/hooks/useForceRender.cjs +9 -0
- package/dist/production/src/hooks/useForceRender.cjs.map +1 -0
- package/dist/production/src/hooks/useForceRender.js +9 -0
- package/dist/production/src/hooks/useForceRender.js.map +1 -0
- package/dist/production/src/hooks/useId.cjs +13 -0
- package/dist/production/src/hooks/useId.cjs.map +1 -0
- package/dist/production/src/hooks/useId.js +13 -0
- package/dist/production/src/hooks/useId.js.map +1 -0
- package/dist/production/src/hooks/useIsMounted.cjs +18 -0
- package/dist/production/src/hooks/useIsMounted.cjs.map +1 -0
- package/dist/production/src/hooks/useIsMounted.js +18 -0
- package/dist/production/src/hooks/useIsMounted.js.map +1 -0
- package/dist/production/src/hooks/useObjectMemo.cjs +27 -0
- package/dist/production/src/hooks/useObjectMemo.cjs.map +1 -0
- package/dist/production/src/hooks/useObjectMemo.js +27 -0
- package/dist/production/src/hooks/useObjectMemo.js.map +1 -0
- package/dist/production/src/hooks/useOnElementClickOutsideCallback.cjs +20 -0
- package/dist/production/src/hooks/useOnElementClickOutsideCallback.cjs.map +1 -0
- package/dist/production/src/hooks/useOnElementClickOutsideCallback.js +20 -0
- package/dist/production/src/hooks/useOnElementClickOutsideCallback.js.map +1 -0
- package/dist/production/src/hooks/useOnElementMouseEnterDelayedCallback.cjs +33 -0
- package/dist/production/src/hooks/useOnElementMouseEnterDelayedCallback.cjs.map +1 -0
- package/dist/production/src/hooks/useOnElementMouseEnterDelayedCallback.js +33 -0
- package/dist/production/src/hooks/useOnElementMouseEnterDelayedCallback.js.map +1 -0
- package/dist/production/src/hooks/useOnElementResize.cjs +42 -0
- package/dist/production/src/hooks/useOnElementResize.cjs.map +1 -0
- package/dist/production/src/hooks/useOnElementResize.js +42 -0
- package/dist/production/src/hooks/useOnElementResize.js.map +1 -0
- package/dist/production/src/hooks/useOnWindowResize.cjs +36 -0
- package/dist/production/src/hooks/useOnWindowResize.cjs.map +1 -0
- package/dist/production/src/hooks/useOnWindowResize.js +36 -0
- package/dist/production/src/hooks/useOnWindowResize.js.map +1 -0
- package/dist/production/src/hooks/usePreviousValue.cjs +12 -0
- package/dist/production/src/hooks/usePreviousValue.cjs.map +1 -0
- package/dist/production/src/hooks/usePreviousValue.js +12 -0
- package/dist/production/src/hooks/usePreviousValue.js.map +1 -0
- package/dist/production/src/hooks/useStoredState.cjs +100 -0
- package/dist/production/src/hooks/useStoredState.cjs.map +1 -0
- package/dist/production/src/hooks/useStoredState.js +100 -0
- package/dist/production/src/hooks/useStoredState.js.map +1 -0
- package/dist/production/src/hooks/useUpdatedRef.cjs +10 -0
- package/dist/production/src/hooks/useUpdatedRef.cjs.map +1 -0
- package/dist/production/src/hooks/useUpdatedRef.js +10 -0
- package/dist/production/src/hooks/useUpdatedRef.js.map +1 -0
- package/dist/production/src/hooks/useWindowSize.cjs +20 -0
- package/dist/production/src/hooks/useWindowSize.cjs.map +1 -0
- package/dist/production/src/hooks/useWindowSize.js +20 -0
- package/dist/production/src/hooks/useWindowSize.js.map +1 -0
- package/dist/production/src/referentiallyStable/emptyArray.cjs +5 -0
- package/dist/production/src/referentiallyStable/emptyArray.cjs.map +1 -0
- package/dist/production/src/referentiallyStable/emptyArray.js +5 -0
- package/dist/production/src/referentiallyStable/emptyArray.js.map +1 -0
- package/dist/production/src/referentiallyStable/emptyObject.cjs +5 -0
- package/dist/production/src/referentiallyStable/emptyObject.cjs.map +1 -0
- package/dist/production/src/referentiallyStable/emptyObject.js +5 -0
- package/dist/production/src/referentiallyStable/emptyObject.js.map +1 -0
- package/dist/production/src/referentiallyStable/identityFunction.cjs +5 -0
- package/dist/production/src/referentiallyStable/identityFunction.cjs.map +1 -0
- package/dist/production/src/referentiallyStable/identityFunction.js +5 -0
- package/dist/production/src/referentiallyStable/identityFunction.js.map +1 -0
- package/dist/production/src/referentiallyStable/noop.cjs +5 -0
- package/dist/production/src/referentiallyStable/noop.cjs.map +1 -0
- package/dist/production/src/referentiallyStable/noop.js +5 -0
- package/dist/production/src/referentiallyStable/noop.js.map +1 -0
- package/dist/production/src/referentiallyStable/returnFalse.cjs +5 -0
- package/dist/production/src/referentiallyStable/returnFalse.cjs.map +1 -0
- package/dist/production/src/referentiallyStable/returnFalse.js +5 -0
- package/dist/production/src/referentiallyStable/returnFalse.js.map +1 -0
- package/dist/production/src/referentiallyStable/returnTrue.cjs +5 -0
- package/dist/production/src/referentiallyStable/returnTrue.cjs.map +1 -0
- package/dist/production/src/referentiallyStable/returnTrue.js +5 -0
- package/dist/production/src/referentiallyStable/returnTrue.js.map +1 -0
- package/dist/production/src/referentiallyStable/useReferentiallyStableCallback.cjs +15 -0
- package/dist/production/src/referentiallyStable/useReferentiallyStableCallback.cjs.map +1 -0
- package/dist/production/src/referentiallyStable/useReferentiallyStableCallback.js +15 -0
- package/dist/production/src/referentiallyStable/useReferentiallyStableCallback.js.map +1 -0
- package/dist/types/context/createContext.d.ts +3 -0
- package/dist/types/context/createContext.d.ts.map +1 -0
- package/dist/types/context/createRequiredContext.d.ts +3 -0
- package/dist/types/context/createRequiredContext.d.ts.map +1 -0
- package/dist/types/context/index.d.ts +3 -0
- package/dist/types/context/index.d.ts.map +1 -0
- package/dist/types/debug-context/Constants.d.ts +6 -0
- package/dist/types/debug-context/Constants.d.ts.map +1 -0
- package/dist/types/debug-context/Context.d.ts +15 -0
- package/dist/types/debug-context/Context.d.ts.map +1 -0
- package/dist/types/debug-context/Types.d.ts +13 -0
- package/dist/types/debug-context/Types.d.ts.map +1 -0
- package/dist/types/debug-context/index.d.ts +4 -0
- package/dist/types/debug-context/index.d.ts.map +1 -0
- package/dist/types/hooks/index.d.ts +25 -0
- package/dist/types/hooks/index.d.ts.map +1 -0
- package/dist/types/hooks/unwrapRefValue.d.ts +9 -0
- package/dist/types/hooks/unwrapRefValue.d.ts.map +1 -0
- package/dist/types/hooks/useAbortController.d.ts +2 -0
- package/dist/types/hooks/useAbortController.d.ts.map +1 -0
- package/dist/types/hooks/useArrayMapMemo.d.ts +10 -0
- package/dist/types/hooks/useArrayMapMemo.d.ts.map +1 -0
- package/dist/types/hooks/useAutoHeightTextArea.d.ts +3 -0
- package/dist/types/hooks/useAutoHeightTextArea.d.ts.map +1 -0
- package/dist/types/hooks/useChildrenAsLabel.d.ts +16 -0
- package/dist/types/hooks/useChildrenAsLabel.d.ts.map +1 -0
- package/dist/types/hooks/useComposeRef.d.ts +16 -0
- package/dist/types/hooks/useComposeRef.d.ts.map +1 -0
- package/dist/types/hooks/useConstantLengthInvariant.d.ts +2 -0
- package/dist/types/hooks/useConstantLengthInvariant.d.ts.map +1 -0
- package/dist/types/hooks/useConstantValueInvariant.d.ts +2 -0
- package/dist/types/hooks/useConstantValueInvariant.d.ts.map +1 -0
- package/dist/types/hooks/useDebounce.d.ts +2 -0
- package/dist/types/hooks/useDebounce.d.ts.map +1 -0
- package/dist/types/hooks/useDebounceCallback.d.ts +2 -0
- package/dist/types/hooks/useDebounceCallback.d.ts.map +1 -0
- package/dist/types/hooks/useDocumentTitle.d.ts +2 -0
- package/dist/types/hooks/useDocumentTitle.d.ts.map +1 -0
- package/dist/types/hooks/useExpectSameValueReference.d.ts +24 -0
- package/dist/types/hooks/useExpectSameValueReference.d.ts.map +1 -0
- package/dist/types/hooks/useForceRender.d.ts +2 -0
- package/dist/types/hooks/useForceRender.d.ts.map +1 -0
- package/dist/types/hooks/useId.d.ts +10 -0
- package/dist/types/hooks/useId.d.ts.map +1 -0
- package/dist/types/hooks/useIsMounted.d.ts +2 -0
- package/dist/types/hooks/useIsMounted.d.ts.map +1 -0
- package/dist/types/hooks/useObjectMemo.d.ts +2 -0
- package/dist/types/hooks/useObjectMemo.d.ts.map +1 -0
- package/dist/types/hooks/useOnElementClickOutsideCallback.d.ts +3 -0
- package/dist/types/hooks/useOnElementClickOutsideCallback.d.ts.map +1 -0
- package/dist/types/hooks/useOnElementMouseEnterDelayedCallback.d.ts +14 -0
- package/dist/types/hooks/useOnElementMouseEnterDelayedCallback.d.ts.map +1 -0
- package/dist/types/hooks/useOnElementResize.d.ts +3 -0
- package/dist/types/hooks/useOnElementResize.d.ts.map +1 -0
- package/dist/types/hooks/useOnWindowResize.d.ts +2 -0
- package/dist/types/hooks/useOnWindowResize.d.ts.map +1 -0
- package/dist/types/hooks/usePreviousValue.d.ts +2 -0
- package/dist/types/hooks/usePreviousValue.d.ts.map +1 -0
- package/dist/types/hooks/useStoredState.d.ts +18 -0
- package/dist/types/hooks/useStoredState.d.ts.map +1 -0
- package/dist/types/hooks/useUpdatedRef.d.ts +8 -0
- package/dist/types/hooks/useUpdatedRef.d.ts.map +1 -0
- package/dist/types/hooks/useWindowSize.d.ts +5 -0
- package/dist/types/hooks/useWindowSize.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/referentiallyStable/emptyArray.d.ts +2 -0
- package/dist/types/referentiallyStable/emptyArray.d.ts.map +1 -0
- package/dist/types/referentiallyStable/emptyObject.d.ts +2 -0
- package/dist/types/referentiallyStable/emptyObject.d.ts.map +1 -0
- package/dist/types/referentiallyStable/identityFunction.d.ts +2 -0
- package/dist/types/referentiallyStable/identityFunction.d.ts.map +1 -0
- package/dist/types/referentiallyStable/index.d.ts +8 -0
- package/dist/types/referentiallyStable/index.d.ts.map +1 -0
- package/dist/types/referentiallyStable/noop.d.ts +2 -0
- package/dist/types/referentiallyStable/noop.d.ts.map +1 -0
- package/dist/types/referentiallyStable/returnFalse.d.ts +2 -0
- package/dist/types/referentiallyStable/returnFalse.d.ts.map +1 -0
- package/dist/types/referentiallyStable/returnTrue.d.ts +2 -0
- package/dist/types/referentiallyStable/returnTrue.d.ts.map +1 -0
- package/dist/types/referentiallyStable/useReferentiallyStableCallback.d.ts +3 -0
- package/dist/types/referentiallyStable/useReferentiallyStableCallback.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dist/types/types/PropsWithRequiredChildren.d.ts +5 -0
- package/dist/types/types/PropsWithRequiredChildren.d.ts.map +1 -0
- package/dist/types/types/Serializable.d.ts +4 -0
- package/dist/types/types/Serializable.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const urlStateStorage = {
|
|
5
|
+
getItem(key) {
|
|
6
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
7
|
+
const value = searchParams.get(key[1]);
|
|
8
|
+
return value !== null && value !== void 0 ? JSON.parse(value) : null;
|
|
9
|
+
},
|
|
10
|
+
setItem(key, value) {
|
|
11
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
12
|
+
searchParams.set(key[1], JSON.stringify(value));
|
|
13
|
+
const newUrl = `${window.location.pathname}?${searchParams.toString()}`;
|
|
14
|
+
window.history.replaceState({}, "", newUrl);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const createStateStorageFromNativeStorage = (getStorage) => {
|
|
18
|
+
return {
|
|
19
|
+
getItem(key) {
|
|
20
|
+
const value = getStorage().getItem(key.join("-"));
|
|
21
|
+
return value !== null ? JSON.parse(value) : null;
|
|
22
|
+
},
|
|
23
|
+
setItem(key, value) {
|
|
24
|
+
getStorage().setItem(key.join("-"), JSON.stringify(value));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const sessionStateStorage = createStateStorageFromNativeStorage(() => sessionStorage);
|
|
29
|
+
const localStateStorage = createStateStorageFromNativeStorage(() => localStorage);
|
|
30
|
+
const nullStorage = {
|
|
31
|
+
getItem() {
|
|
32
|
+
return null;
|
|
33
|
+
},
|
|
34
|
+
setItem() {
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const builtInStorages = {
|
|
38
|
+
url: urlStateStorage,
|
|
39
|
+
session: sessionStateStorage,
|
|
40
|
+
local: localStateStorage,
|
|
41
|
+
null: nullStorage
|
|
42
|
+
};
|
|
43
|
+
const useStoredState = (storageOrName, key, initializeValue) => {
|
|
44
|
+
const storage = React.useMemo(() => {
|
|
45
|
+
return getStateStorage(storageOrName);
|
|
46
|
+
}, [storageOrName]);
|
|
47
|
+
const [value, setValue] = React.useState(() => {
|
|
48
|
+
const value2 = storage.getItem(key);
|
|
49
|
+
return initializeValue(value2);
|
|
50
|
+
});
|
|
51
|
+
return [
|
|
52
|
+
value,
|
|
53
|
+
React.useCallback((value2) => {
|
|
54
|
+
setValue((current) => {
|
|
55
|
+
const newValue = typeof value2 === "function" ? value2(current) : value2;
|
|
56
|
+
storage.setItem(key, newValue);
|
|
57
|
+
return newValue;
|
|
58
|
+
});
|
|
59
|
+
}, [key, storage])
|
|
60
|
+
];
|
|
61
|
+
};
|
|
62
|
+
const useSessionStorageState = (key, initializeValue) => {
|
|
63
|
+
return useStoredState(sessionStateStorage, key, initializeValue);
|
|
64
|
+
};
|
|
65
|
+
const useLocalStorageState = (key, initializeValue) => {
|
|
66
|
+
return useStoredState(localStateStorage, key, initializeValue);
|
|
67
|
+
};
|
|
68
|
+
const getStateStorage = (storageOrName) => {
|
|
69
|
+
if (Array.isArray(storageOrName)) {
|
|
70
|
+
return createFallbackStorage(storageOrName.map((it) => typeof it === "string" ? builtInStorages[it] : it));
|
|
71
|
+
}
|
|
72
|
+
return typeof storageOrName === "string" ? builtInStorages[storageOrName] : storageOrName;
|
|
73
|
+
};
|
|
74
|
+
const createFallbackStorage = (storageTypes) => {
|
|
75
|
+
return {
|
|
76
|
+
getItem(key) {
|
|
77
|
+
for (const storage of storageTypes) {
|
|
78
|
+
const value = storage.getItem(key);
|
|
79
|
+
if (value !== null) {
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
},
|
|
85
|
+
setItem(key, value) {
|
|
86
|
+
for (const storage of storageTypes) {
|
|
87
|
+
storage.setItem(key, value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
exports.getStateStorage = getStateStorage;
|
|
93
|
+
exports.localStateStorage = localStateStorage;
|
|
94
|
+
exports.nullStorage = nullStorage;
|
|
95
|
+
exports.sessionStateStorage = sessionStateStorage;
|
|
96
|
+
exports.urlStateStorage = urlStateStorage;
|
|
97
|
+
exports.useLocalStorageState = useLocalStorageState;
|
|
98
|
+
exports.useSessionStorageState = useSessionStorageState;
|
|
99
|
+
exports.useStoredState = useStoredState;
|
|
100
|
+
//# sourceMappingURL=useStoredState.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStoredState.cjs","sources":["../../../../../packages/react-utils/src/hooks/useStoredState.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react'\nimport { Serializable } from '../types'\n\nexport type SetState<V extends Serializable> = (value: V | ((current: V) => V)) => void\nexport type StateStorageKey = [uniquePrefix: string, key: string]\n\nexport type ValueInitializer<V extends Serializable> = (storedValue: V | undefined) => V\n\nexport interface StateStorage {\n\tgetItem(key: StateStorageKey): Serializable\n\n\tsetItem(key: StateStorageKey, value: Serializable): void\n}\n\nexport const urlStateStorage: StateStorage = {\n\tgetItem(key) {\n\t\tconst searchParams = new URLSearchParams(window.location.search)\n\t\tconst value = searchParams.get(key[1])\n\t\treturn value !== null && value !== undefined ? JSON.parse(value) : null\n\t},\n\tsetItem(key, value) {\n\t\tconst searchParams = new URLSearchParams(window.location.search)\n\t\tsearchParams.set(key[1], JSON.stringify(value))\n\t\tconst newUrl = `${window.location.pathname}?${searchParams.toString()}`\n\t\twindow.history.replaceState({}, '', newUrl)\n\t},\n}\n\nconst createStateStorageFromNativeStorage = (getStorage: () => Storage): StateStorage => {\n\treturn {\n\t\tgetItem(key) {\n\t\t\tconst value = getStorage().getItem(key.join('-'))\n\t\t\treturn value !== null ? JSON.parse(value) : null\n\t\t},\n\t\tsetItem(key, value) {\n\t\t\tgetStorage().setItem(key.join('-'), JSON.stringify(value))\n\t\t},\n\t}\n}\n\nexport const sessionStateStorage = createStateStorageFromNativeStorage(() => sessionStorage)\nexport const localStateStorage = createStateStorageFromNativeStorage(() => localStorage)\nexport const nullStorage: StateStorage = {\n\tgetItem() {\n\t\treturn null\n\t},\n\tsetItem() {\n\t},\n}\n\nconst builtInStorages = {\n\turl: urlStateStorage,\n\tsession: sessionStateStorage,\n\tlocal: localStateStorage,\n\tnull: nullStorage,\n}\n\nexport type StateStorageOrName = StateStorage | 'url' | 'session' | 'local' | 'null'\n\nexport const useStoredState = <V extends Serializable>(\n\tstorageOrName: StateStorageOrName | StateStorageOrName[],\n\tkey: StateStorageKey,\n\tinitializeValue: ValueInitializer<V>,\n): [V, SetState<V>] => {\n\tconst storage = useMemo(() => {\n\t\treturn getStateStorage(storageOrName)\n\t}, [storageOrName])\n\n\tconst [value, setValue] = useState<V>(() => {\n\t\tconst value = storage.getItem(key)\n\t\treturn initializeValue(value as V)\n\t})\n\treturn [\n\t\tvalue,\n\t\tuseCallback(value => {\n\t\t\tsetValue(current => {\n\t\t\t\tconst newValue = typeof value === 'function' ? (value as (current: V) => V)(current) : value\n\t\t\t\tstorage.setItem(key, newValue)\n\t\t\t\treturn newValue\n\t\t\t})\n\t\t}, [key, storage]),\n\t]\n}\n\nexport const useSessionStorageState = <V extends Serializable>(key: StateStorageKey, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\treturn useStoredState<V>(sessionStateStorage, key, initializeValue)\n}\n\nexport const useLocalStorageState = <V extends Serializable>(key: StateStorageKey, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\treturn useStoredState<V>(localStateStorage, key, initializeValue)\n}\n\nexport const getStateStorage = (storageOrName: StateStorageOrName | StateStorageOrName[]) => {\n\tif (Array.isArray(storageOrName)) {\n\t\treturn createFallbackStorage(storageOrName.map(it => typeof it === 'string' ? builtInStorages[it] : it))\n\t}\n\treturn typeof storageOrName === 'string' ? builtInStorages[storageOrName] : storageOrName\n}\n\nconst createFallbackStorage = (storageTypes: StateStorage[]): StateStorage => {\n\treturn {\n\t\tgetItem(key) {\n\t\t\tfor (const storage of storageTypes) {\n\t\t\t\tconst value = storage.getItem(key)\n\t\t\t\tif (value !== null) {\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\tsetItem(key, value) {\n\t\t\tfor (const storage of storageTypes) {\n\t\t\t\tstorage.setItem(key, value)\n\t\t\t}\n\t\t},\n\t}\n}\n"],"names":["useMemo","useState","value","useCallback"],"mappings":"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"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { useMemo, useState, useCallback } from "react";
|
|
2
|
+
const urlStateStorage = {
|
|
3
|
+
getItem(key) {
|
|
4
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
5
|
+
const value = searchParams.get(key[1]);
|
|
6
|
+
return value !== null && value !== void 0 ? JSON.parse(value) : null;
|
|
7
|
+
},
|
|
8
|
+
setItem(key, value) {
|
|
9
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
10
|
+
searchParams.set(key[1], JSON.stringify(value));
|
|
11
|
+
const newUrl = `${window.location.pathname}?${searchParams.toString()}`;
|
|
12
|
+
window.history.replaceState({}, "", newUrl);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const createStateStorageFromNativeStorage = (getStorage) => {
|
|
16
|
+
return {
|
|
17
|
+
getItem(key) {
|
|
18
|
+
const value = getStorage().getItem(key.join("-"));
|
|
19
|
+
return value !== null ? JSON.parse(value) : null;
|
|
20
|
+
},
|
|
21
|
+
setItem(key, value) {
|
|
22
|
+
getStorage().setItem(key.join("-"), JSON.stringify(value));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const sessionStateStorage = createStateStorageFromNativeStorage(() => sessionStorage);
|
|
27
|
+
const localStateStorage = createStateStorageFromNativeStorage(() => localStorage);
|
|
28
|
+
const nullStorage = {
|
|
29
|
+
getItem() {
|
|
30
|
+
return null;
|
|
31
|
+
},
|
|
32
|
+
setItem() {
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const builtInStorages = {
|
|
36
|
+
url: urlStateStorage,
|
|
37
|
+
session: sessionStateStorage,
|
|
38
|
+
local: localStateStorage,
|
|
39
|
+
null: nullStorage
|
|
40
|
+
};
|
|
41
|
+
const useStoredState = (storageOrName, key, initializeValue) => {
|
|
42
|
+
const storage = useMemo(() => {
|
|
43
|
+
return getStateStorage(storageOrName);
|
|
44
|
+
}, [storageOrName]);
|
|
45
|
+
const [value, setValue] = useState(() => {
|
|
46
|
+
const value2 = storage.getItem(key);
|
|
47
|
+
return initializeValue(value2);
|
|
48
|
+
});
|
|
49
|
+
return [
|
|
50
|
+
value,
|
|
51
|
+
useCallback((value2) => {
|
|
52
|
+
setValue((current) => {
|
|
53
|
+
const newValue = typeof value2 === "function" ? value2(current) : value2;
|
|
54
|
+
storage.setItem(key, newValue);
|
|
55
|
+
return newValue;
|
|
56
|
+
});
|
|
57
|
+
}, [key, storage])
|
|
58
|
+
];
|
|
59
|
+
};
|
|
60
|
+
const useSessionStorageState = (key, initializeValue) => {
|
|
61
|
+
return useStoredState(sessionStateStorage, key, initializeValue);
|
|
62
|
+
};
|
|
63
|
+
const useLocalStorageState = (key, initializeValue) => {
|
|
64
|
+
return useStoredState(localStateStorage, key, initializeValue);
|
|
65
|
+
};
|
|
66
|
+
const getStateStorage = (storageOrName) => {
|
|
67
|
+
if (Array.isArray(storageOrName)) {
|
|
68
|
+
return createFallbackStorage(storageOrName.map((it) => typeof it === "string" ? builtInStorages[it] : it));
|
|
69
|
+
}
|
|
70
|
+
return typeof storageOrName === "string" ? builtInStorages[storageOrName] : storageOrName;
|
|
71
|
+
};
|
|
72
|
+
const createFallbackStorage = (storageTypes) => {
|
|
73
|
+
return {
|
|
74
|
+
getItem(key) {
|
|
75
|
+
for (const storage of storageTypes) {
|
|
76
|
+
const value = storage.getItem(key);
|
|
77
|
+
if (value !== null) {
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
},
|
|
83
|
+
setItem(key, value) {
|
|
84
|
+
for (const storage of storageTypes) {
|
|
85
|
+
storage.setItem(key, value);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export {
|
|
91
|
+
getStateStorage,
|
|
92
|
+
localStateStorage,
|
|
93
|
+
nullStorage,
|
|
94
|
+
sessionStateStorage,
|
|
95
|
+
urlStateStorage,
|
|
96
|
+
useLocalStorageState,
|
|
97
|
+
useSessionStorageState,
|
|
98
|
+
useStoredState
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=useStoredState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStoredState.js","sources":["../../../../../packages/react-utils/src/hooks/useStoredState.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react'\nimport { Serializable } from '../types'\n\nexport type SetState<V extends Serializable> = (value: V | ((current: V) => V)) => void\nexport type StateStorageKey = [uniquePrefix: string, key: string]\n\nexport type ValueInitializer<V extends Serializable> = (storedValue: V | undefined) => V\n\nexport interface StateStorage {\n\tgetItem(key: StateStorageKey): Serializable\n\n\tsetItem(key: StateStorageKey, value: Serializable): void\n}\n\nexport const urlStateStorage: StateStorage = {\n\tgetItem(key) {\n\t\tconst searchParams = new URLSearchParams(window.location.search)\n\t\tconst value = searchParams.get(key[1])\n\t\treturn value !== null && value !== undefined ? JSON.parse(value) : null\n\t},\n\tsetItem(key, value) {\n\t\tconst searchParams = new URLSearchParams(window.location.search)\n\t\tsearchParams.set(key[1], JSON.stringify(value))\n\t\tconst newUrl = `${window.location.pathname}?${searchParams.toString()}`\n\t\twindow.history.replaceState({}, '', newUrl)\n\t},\n}\n\nconst createStateStorageFromNativeStorage = (getStorage: () => Storage): StateStorage => {\n\treturn {\n\t\tgetItem(key) {\n\t\t\tconst value = getStorage().getItem(key.join('-'))\n\t\t\treturn value !== null ? JSON.parse(value) : null\n\t\t},\n\t\tsetItem(key, value) {\n\t\t\tgetStorage().setItem(key.join('-'), JSON.stringify(value))\n\t\t},\n\t}\n}\n\nexport const sessionStateStorage = createStateStorageFromNativeStorage(() => sessionStorage)\nexport const localStateStorage = createStateStorageFromNativeStorage(() => localStorage)\nexport const nullStorage: StateStorage = {\n\tgetItem() {\n\t\treturn null\n\t},\n\tsetItem() {\n\t},\n}\n\nconst builtInStorages = {\n\turl: urlStateStorage,\n\tsession: sessionStateStorage,\n\tlocal: localStateStorage,\n\tnull: nullStorage,\n}\n\nexport type StateStorageOrName = StateStorage | 'url' | 'session' | 'local' | 'null'\n\nexport const useStoredState = <V extends Serializable>(\n\tstorageOrName: StateStorageOrName | StateStorageOrName[],\n\tkey: StateStorageKey,\n\tinitializeValue: ValueInitializer<V>,\n): [V, SetState<V>] => {\n\tconst storage = useMemo(() => {\n\t\treturn getStateStorage(storageOrName)\n\t}, [storageOrName])\n\n\tconst [value, setValue] = useState<V>(() => {\n\t\tconst value = storage.getItem(key)\n\t\treturn initializeValue(value as V)\n\t})\n\treturn [\n\t\tvalue,\n\t\tuseCallback(value => {\n\t\t\tsetValue(current => {\n\t\t\t\tconst newValue = typeof value === 'function' ? (value as (current: V) => V)(current) : value\n\t\t\t\tstorage.setItem(key, newValue)\n\t\t\t\treturn newValue\n\t\t\t})\n\t\t}, [key, storage]),\n\t]\n}\n\nexport const useSessionStorageState = <V extends Serializable>(key: StateStorageKey, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\treturn useStoredState<V>(sessionStateStorage, key, initializeValue)\n}\n\nexport const useLocalStorageState = <V extends Serializable>(key: StateStorageKey, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\treturn useStoredState<V>(localStateStorage, key, initializeValue)\n}\n\nexport const getStateStorage = (storageOrName: StateStorageOrName | StateStorageOrName[]) => {\n\tif (Array.isArray(storageOrName)) {\n\t\treturn createFallbackStorage(storageOrName.map(it => typeof it === 'string' ? builtInStorages[it] : it))\n\t}\n\treturn typeof storageOrName === 'string' ? builtInStorages[storageOrName] : storageOrName\n}\n\nconst createFallbackStorage = (storageTypes: StateStorage[]): StateStorage => {\n\treturn {\n\t\tgetItem(key) {\n\t\t\tfor (const storage of storageTypes) {\n\t\t\t\tconst value = storage.getItem(key)\n\t\t\t\tif (value !== null) {\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\tsetItem(key, value) {\n\t\t\tfor (const storage of storageTypes) {\n\t\t\t\tstorage.setItem(key, value)\n\t\t\t}\n\t\t},\n\t}\n}\n"],"names":["value"],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
function useUpdatedRef(value) {
|
|
5
|
+
const ref = React.useRef(value);
|
|
6
|
+
ref.current = value;
|
|
7
|
+
return ref;
|
|
8
|
+
}
|
|
9
|
+
exports.useUpdatedRef = useUpdatedRef;
|
|
10
|
+
//# sourceMappingURL=useUpdatedRef.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUpdatedRef.cjs","sources":["../../../../../packages/react-utils/src/hooks/useUpdatedRef.ts"],"sourcesContent":["import { useRef } from 'react'\n\n/**\n * Returns a stable mutable object with value that is updated upon each call\n *\n * @param value - Value that could update after initial call\n * @returns Mutable ref object with updated value\n */\nexport function useUpdatedRef<T>(value: T) {\n\tconst ref = useRef(value)\n\tref.current = value\n\n\treturn ref\n}\n"],"names":["useRef"],"mappings":";;;AAQO,SAAS,cAAiB,OAAU;AAC1C,QAAM,MAAMA,MAAAA,OAAO,KAAK;AACxB,MAAI,UAAU;AAEd,SAAO;AACR;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUpdatedRef.js","sources":["../../../../../packages/react-utils/src/hooks/useUpdatedRef.ts"],"sourcesContent":["import { useRef } from 'react'\n\n/**\n * Returns a stable mutable object with value that is updated upon each call\n *\n * @param value - Value that could update after initial call\n * @returns Mutable ref object with updated value\n */\nexport function useUpdatedRef<T>(value: T) {\n\tconst ref = useRef(value)\n\tref.current = value\n\n\treturn ref\n}\n"],"names":[],"mappings":";AAQO,SAAS,cAAiB,OAAU;AAC1C,QAAM,MAAM,OAAO,KAAK;AACxB,MAAI,UAAU;AAEd,SAAO;AACR;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const useOnWindowResize = require("./useOnWindowResize.cjs");
|
|
5
|
+
function useWindowSize() {
|
|
6
|
+
const [width, setWidth] = React.useState(window.innerWidth);
|
|
7
|
+
const [height, setHeight] = React.useState(window.innerHeight);
|
|
8
|
+
useOnWindowResize.useOnWindowResize(() => {
|
|
9
|
+
const { innerHeight, innerWidth } = window;
|
|
10
|
+
if (innerHeight !== height) {
|
|
11
|
+
setHeight(innerHeight);
|
|
12
|
+
}
|
|
13
|
+
if (innerWidth !== width) {
|
|
14
|
+
setWidth(innerWidth);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return React.useMemo(() => ({ height, width }), [height, width]);
|
|
18
|
+
}
|
|
19
|
+
exports.useWindowSize = useWindowSize;
|
|
20
|
+
//# sourceMappingURL=useWindowSize.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWindowSize.cjs","sources":["../../../../../packages/react-utils/src/hooks/useWindowSize.ts"],"sourcesContent":["import { useMemo, useState } from 'react'\nimport { useOnWindowResize } from './useOnWindowResize'\n\nexport function useWindowSize() {\n\tconst [width, setWidth] = useState(window.innerWidth)\n\tconst [height, setHeight] = useState(window.innerHeight)\n\n\tuseOnWindowResize(() => {\n\t\tconst { innerHeight, innerWidth } = window\n\t\tif (innerHeight !== height) {\n\t\t\tsetHeight(innerHeight)\n\t\t}\n\n\t\tif (innerWidth !== width) {\n\t\t\tsetWidth(innerWidth)\n\t\t}\n\t})\n\n\treturn useMemo(() => ({ height, width }), [height, width])\n}\n"],"names":["useState","useOnWindowResize","useMemo"],"mappings":";;;;AAGO,SAAS,gBAAgB;AAC/B,QAAM,CAAC,OAAO,QAAQ,IAAIA,MAAAA,SAAS,OAAO,UAAU;AACpD,QAAM,CAAC,QAAQ,SAAS,IAAIA,MAAAA,SAAS,OAAO,WAAW;AAEvDC,oBAAAA,kBAAkB,MAAM;AACvB,UAAM,EAAE,aAAa,WAAA,IAAe;AACpC,QAAI,gBAAgB,QAAQ;AAC3B,gBAAU,WAAW;AAAA,IACtB;AAEA,QAAI,eAAe,OAAO;AACzB,eAAS,UAAU;AAAA,IACpB;AAAA,EACD,CAAC;AAED,SAAOC,MAAAA,QAAQ,OAAO,EAAE,QAAQ,UAAU,CAAC,QAAQ,KAAK,CAAC;AAC1D;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useState, useMemo } from "react";
|
|
2
|
+
import { useOnWindowResize } from "./useOnWindowResize.js";
|
|
3
|
+
function useWindowSize() {
|
|
4
|
+
const [width, setWidth] = useState(window.innerWidth);
|
|
5
|
+
const [height, setHeight] = useState(window.innerHeight);
|
|
6
|
+
useOnWindowResize(() => {
|
|
7
|
+
const { innerHeight, innerWidth } = window;
|
|
8
|
+
if (innerHeight !== height) {
|
|
9
|
+
setHeight(innerHeight);
|
|
10
|
+
}
|
|
11
|
+
if (innerWidth !== width) {
|
|
12
|
+
setWidth(innerWidth);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return useMemo(() => ({ height, width }), [height, width]);
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
useWindowSize
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useWindowSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWindowSize.js","sources":["../../../../../packages/react-utils/src/hooks/useWindowSize.ts"],"sourcesContent":["import { useMemo, useState } from 'react'\nimport { useOnWindowResize } from './useOnWindowResize'\n\nexport function useWindowSize() {\n\tconst [width, setWidth] = useState(window.innerWidth)\n\tconst [height, setHeight] = useState(window.innerHeight)\n\n\tuseOnWindowResize(() => {\n\t\tconst { innerHeight, innerWidth } = window\n\t\tif (innerHeight !== height) {\n\t\t\tsetHeight(innerHeight)\n\t\t}\n\n\t\tif (innerWidth !== width) {\n\t\t\tsetWidth(innerWidth)\n\t\t}\n\t})\n\n\treturn useMemo(() => ({ height, width }), [height, width])\n}\n"],"names":[],"mappings":";;AAGO,SAAS,gBAAgB;AAC/B,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,OAAO,UAAU;AACpD,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,OAAO,WAAW;AAEvD,oBAAkB,MAAM;AACvB,UAAM,EAAE,aAAa,WAAA,IAAe;AACpC,QAAI,gBAAgB,QAAQ;AAC3B,gBAAU,WAAW;AAAA,IACtB;AAEA,QAAI,eAAe,OAAO;AACzB,eAAS,UAAU;AAAA,IACpB;AAAA,EACD,CAAC;AAED,SAAO,QAAQ,OAAO,EAAE,QAAQ,UAAU,CAAC,QAAQ,KAAK,CAAC;AAC1D;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emptyArray.cjs","sources":["../../../../../packages/react-utils/src/referentiallyStable/emptyArray.ts"],"sourcesContent":["export const emptyArray = Object.freeze<any>([]) as any[]\n"],"names":[],"mappings":";;AAAO,MAAM,aAAa,OAAO,OAAY,CAAA,CAAE;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emptyArray.js","sources":["../../../../../packages/react-utils/src/referentiallyStable/emptyArray.ts"],"sourcesContent":["export const emptyArray = Object.freeze<any>([]) as any[]\n"],"names":[],"mappings":"AAAO,MAAM,aAAa,OAAO,OAAY,CAAA,CAAE;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emptyObject.cjs","sources":["../../../../../packages/react-utils/src/referentiallyStable/emptyObject.ts"],"sourcesContent":["export const emptyObject = Object.freeze({})\n"],"names":[],"mappings":";;AAAO,MAAM,cAAc,OAAO,OAAO,CAAA,CAAE;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emptyObject.js","sources":["../../../../../packages/react-utils/src/referentiallyStable/emptyObject.ts"],"sourcesContent":["export const emptyObject = Object.freeze({})\n"],"names":[],"mappings":"AAAO,MAAM,cAAc,OAAO,OAAO,CAAA,CAAE;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identityFunction.cjs","sources":["../../../../../packages/react-utils/src/referentiallyStable/identityFunction.ts"],"sourcesContent":["export const identityFunction = <Value>(value: Value) => value\n"],"names":[],"mappings":";;AAAO,MAAM,mBAAmB,CAAQ,UAAiB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identityFunction.js","sources":["../../../../../packages/react-utils/src/referentiallyStable/identityFunction.ts"],"sourcesContent":["export const identityFunction = <Value>(value: Value) => value\n"],"names":[],"mappings":"AAAO,MAAM,mBAAmB,CAAQ,UAAiB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.cjs","sources":["../../../../../packages/react-utils/src/referentiallyStable/noop.ts"],"sourcesContent":["export const noop = () => undefined\n"],"names":[],"mappings":";;AAAO,MAAM,OAAO,MAAM;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.js","sources":["../../../../../packages/react-utils/src/referentiallyStable/noop.ts"],"sourcesContent":["export const noop = () => undefined\n"],"names":[],"mappings":"AAAO,MAAM,OAAO,MAAM;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"returnFalse.cjs","sources":["../../../../../packages/react-utils/src/referentiallyStable/returnFalse.ts"],"sourcesContent":["export const returnFalse = () => false\n"],"names":[],"mappings":";;AAAO,MAAM,cAAc,MAAM;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"returnFalse.js","sources":["../../../../../packages/react-utils/src/referentiallyStable/returnFalse.ts"],"sourcesContent":["export const returnFalse = () => false\n"],"names":[],"mappings":"AAAO,MAAM,cAAc,MAAM;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"returnTrue.cjs","sources":["../../../../../packages/react-utils/src/referentiallyStable/returnTrue.ts"],"sourcesContent":["export const returnTrue = () => true\n"],"names":[],"mappings":";;AAAO,MAAM,aAAa,MAAM;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"returnTrue.js","sources":["../../../../../packages/react-utils/src/referentiallyStable/returnTrue.ts"],"sourcesContent":["export const returnTrue = () => true\n"],"names":[],"mappings":"AAAO,MAAM,aAAa,MAAM;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const useReferentiallyStableCallback = (callback) => {
|
|
5
|
+
const ref = React.useRef(callback);
|
|
6
|
+
ref.current = callback;
|
|
7
|
+
return React.useCallback(
|
|
8
|
+
((...args) => {
|
|
9
|
+
return ref.current(...args);
|
|
10
|
+
}),
|
|
11
|
+
[]
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
exports.useReferentiallyStableCallback = useReferentiallyStableCallback;
|
|
15
|
+
//# sourceMappingURL=useReferentiallyStableCallback.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReferentiallyStableCallback.cjs","sources":["../../../../../packages/react-utils/src/referentiallyStable/useReferentiallyStableCallback.ts"],"sourcesContent":["import { useCallback, useRef } from 'react'\n\nexport type NoConstructor<T extends Function> = T extends new(...args: unknown[]) => unknown ? never\n\t: T\n// TODO: Should be possible to remove when React.useEvent() lands\nexport const useReferentiallyStableCallback = <T extends Function>(callback: NoConstructor<T>): T => {\n\tconst ref = useRef(callback)\n\tref.current = callback\n\treturn useCallback<T>(\n\t\t((...args: any[]) => {\n\t\t\treturn ref.current(...args)\n\t\t}) as unknown as T,\n\t\t[],\n\t)\n}\n"],"names":["useRef","useCallback"],"mappings":";;;AAKO,MAAM,iCAAiC,CAAqB,aAAkC;AACpG,QAAM,MAAMA,MAAAA,OAAO,QAAQ;AAC3B,MAAI,UAAU;AACd,SAAOC,MAAAA;AAAAA,KACL,IAAI,SAAgB;AACpB,aAAO,IAAI,QAAQ,GAAG,IAAI;AAAA,IAC3B;AAAA,IACA,CAAA;AAAA,EAAC;AAEH;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useRef, useCallback } from "react";
|
|
2
|
+
const useReferentiallyStableCallback = (callback) => {
|
|
3
|
+
const ref = useRef(callback);
|
|
4
|
+
ref.current = callback;
|
|
5
|
+
return useCallback(
|
|
6
|
+
((...args) => {
|
|
7
|
+
return ref.current(...args);
|
|
8
|
+
}),
|
|
9
|
+
[]
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
useReferentiallyStableCallback
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useReferentiallyStableCallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReferentiallyStableCallback.js","sources":["../../../../../packages/react-utils/src/referentiallyStable/useReferentiallyStableCallback.ts"],"sourcesContent":["import { useCallback, useRef } from 'react'\n\nexport type NoConstructor<T extends Function> = T extends new(...args: unknown[]) => unknown ? never\n\t: T\n// TODO: Should be possible to remove when React.useEvent() lands\nexport const useReferentiallyStableCallback = <T extends Function>(callback: NoConstructor<T>): T => {\n\tconst ref = useRef(callback)\n\tref.current = callback\n\treturn useCallback<T>(\n\t\t((...args: any[]) => {\n\t\t\treturn ref.current(...args)\n\t\t}) as unknown as T,\n\t\t[],\n\t)\n}\n"],"names":[],"mappings":";AAKO,MAAM,iCAAiC,CAAqB,aAAkC;AACpG,QAAM,MAAM,OAAO,QAAQ;AAC3B,MAAI,UAAU;AACd,SAAO;AAAA,KACL,IAAI,SAAgB;AACpB,aAAO,IAAI,QAAQ,GAAG,IAAI;AAAA,IAC3B;AAAA,IACA,CAAA;AAAA,EAAC;AAEH;"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const Context = require("./src/debug-context/Context.cjs");
|
|
4
|
+
const createContext = require("./src/context/createContext.cjs");
|
|
5
|
+
const createRequiredContext = require("./src/context/createRequiredContext.cjs");
|
|
6
|
+
const emptyArray = require("./src/referentiallyStable/emptyArray.cjs");
|
|
7
|
+
const emptyObject = require("./src/referentiallyStable/emptyObject.cjs");
|
|
8
|
+
const useChildrenAsLabel = require("./src/hooks/useChildrenAsLabel.cjs");
|
|
9
|
+
const useStoredState = require("./src/hooks/useStoredState.cjs");
|
|
10
|
+
const identityFunction = require("./src/referentiallyStable/identityFunction.cjs");
|
|
11
|
+
const Constants = require("./src/debug-context/Constants.cjs");
|
|
12
|
+
const noop = require("./src/referentiallyStable/noop.cjs");
|
|
13
|
+
const returnFalse = require("./src/referentiallyStable/returnFalse.cjs");
|
|
14
|
+
const returnTrue = require("./src/referentiallyStable/returnTrue.cjs");
|
|
15
|
+
const unwrapRefValue = require("./src/hooks/unwrapRefValue.cjs");
|
|
16
|
+
const useAbortController = require("./src/hooks/useAbortController.cjs");
|
|
17
|
+
const useArrayMapMemo = require("./src/hooks/useArrayMapMemo.cjs");
|
|
18
|
+
const useAutoHeightTextArea = require("./src/hooks/useAutoHeightTextArea.cjs");
|
|
19
|
+
const useComposeRef = require("./src/hooks/useComposeRef.cjs");
|
|
20
|
+
const useConstantLengthInvariant = require("./src/hooks/useConstantLengthInvariant.cjs");
|
|
21
|
+
const useConstantValueInvariant = require("./src/hooks/useConstantValueInvariant.cjs");
|
|
22
|
+
const useDebounce = require("./src/hooks/useDebounce.cjs");
|
|
23
|
+
const useDebounceCallback = require("./src/hooks/useDebounceCallback.cjs");
|
|
24
|
+
const useDocumentTitle = require("./src/hooks/useDocumentTitle.cjs");
|
|
25
|
+
const useExpectSameValueReference = require("./src/hooks/useExpectSameValueReference.cjs");
|
|
26
|
+
const useForceRender = require("./src/hooks/useForceRender.cjs");
|
|
27
|
+
const useId = require("./src/hooks/useId.cjs");
|
|
28
|
+
const useIsMounted = require("./src/hooks/useIsMounted.cjs");
|
|
29
|
+
const useObjectMemo = require("./src/hooks/useObjectMemo.cjs");
|
|
30
|
+
const useOnElementClickOutsideCallback = require("./src/hooks/useOnElementClickOutsideCallback.cjs");
|
|
31
|
+
const useOnElementMouseEnterDelayedCallback = require("./src/hooks/useOnElementMouseEnterDelayedCallback.cjs");
|
|
32
|
+
const useOnElementResize = require("./src/hooks/useOnElementResize.cjs");
|
|
33
|
+
const useOnWindowResize = require("./src/hooks/useOnWindowResize.cjs");
|
|
34
|
+
const usePreviousValue = require("./src/hooks/usePreviousValue.cjs");
|
|
35
|
+
const useReferentiallyStableCallback = require("./src/referentiallyStable/useReferentiallyStableCallback.cjs");
|
|
36
|
+
const useUpdatedRef = require("./src/hooks/useUpdatedRef.cjs");
|
|
37
|
+
const useWindowSize = require("./src/hooks/useWindowSize.cjs");
|
|
38
|
+
exports.DebugChildren = Context.DebugChildren;
|
|
39
|
+
exports.ScopedConsoleContext = Context.ScopedConsoleContext;
|
|
40
|
+
exports.useScopedConsoleRef = Context.useScopedConsoleRef;
|
|
41
|
+
exports.createContext = createContext.createContext;
|
|
42
|
+
exports.createRequiredContext = createRequiredContext.createRequiredContext;
|
|
43
|
+
exports.emptyArray = emptyArray.emptyArray;
|
|
44
|
+
exports.emptyObject = emptyObject.emptyObject;
|
|
45
|
+
exports.getChildrenAsLabel = useChildrenAsLabel.getChildrenAsLabel;
|
|
46
|
+
exports.useChildrenAsLabel = useChildrenAsLabel.useChildrenAsLabel;
|
|
47
|
+
exports.getStateStorage = useStoredState.getStateStorage;
|
|
48
|
+
exports.localStateStorage = useStoredState.localStateStorage;
|
|
49
|
+
exports.nullStorage = useStoredState.nullStorage;
|
|
50
|
+
exports.sessionStateStorage = useStoredState.sessionStateStorage;
|
|
51
|
+
exports.urlStateStorage = useStoredState.urlStateStorage;
|
|
52
|
+
exports.useLocalStorageState = useStoredState.useLocalStorageState;
|
|
53
|
+
exports.useSessionStorageState = useStoredState.useSessionStorageState;
|
|
54
|
+
exports.useStoredState = useStoredState.useStoredState;
|
|
55
|
+
exports.identityFunction = identityFunction.identityFunction;
|
|
56
|
+
exports.isNoopScopedConsole = Constants.isNoopScopedConsole;
|
|
57
|
+
exports.noopLog = Constants.noopLog;
|
|
58
|
+
exports.noopLogged = Constants.noopLogged;
|
|
59
|
+
exports.noopScopedConsole = Constants.noopScopedConsole;
|
|
60
|
+
exports.noop = noop.noop;
|
|
61
|
+
exports.returnFalse = returnFalse.returnFalse;
|
|
62
|
+
exports.returnTrue = returnTrue.returnTrue;
|
|
63
|
+
exports.unwrapRefValue = unwrapRefValue.unwrapRefValue;
|
|
64
|
+
exports.useAbortController = useAbortController.useAbortController;
|
|
65
|
+
exports.useArrayMapMemo = useArrayMapMemo.useArrayMapMemo;
|
|
66
|
+
exports.useAutoHeightTextArea = useAutoHeightTextArea.useAutoHeightTextArea;
|
|
67
|
+
exports.useComposeRef = useComposeRef.useComposeRef;
|
|
68
|
+
exports.useConstantLengthInvariant = useConstantLengthInvariant.useConstantLengthInvariant;
|
|
69
|
+
exports.useConstantValueInvariant = useConstantValueInvariant.useConstantValueInvariant;
|
|
70
|
+
exports.useDebounce = useDebounce.useDebounce;
|
|
71
|
+
exports.useDebounceCallback = useDebounceCallback.useDebounceCallback;
|
|
72
|
+
exports.useDocumentTitle = useDocumentTitle.useDocumentTitle;
|
|
73
|
+
exports.useExpectSameValueReference = useExpectSameValueReference.useExpectSameValueReference;
|
|
74
|
+
exports.useForceRender = useForceRender.useForceRender;
|
|
75
|
+
exports.useId = useId.useId;
|
|
76
|
+
exports.useIsMounted = useIsMounted.useIsMounted;
|
|
77
|
+
exports.useObjectMemo = useObjectMemo.useObjectMemo;
|
|
78
|
+
exports.useOnElementClickOutsideCallback = useOnElementClickOutsideCallback.useOnElementClickOutsideCallback;
|
|
79
|
+
exports.useOnElementMouseEnterDelayedCallback = useOnElementMouseEnterDelayedCallback.useOnElementMouseEnterDelayedCallback;
|
|
80
|
+
exports.useOnElementResize = useOnElementResize.useOnElementResize;
|
|
81
|
+
exports.useOnWindowResize = useOnWindowResize.useOnWindowResize;
|
|
82
|
+
exports.usePreviousValue = usePreviousValue.usePreviousValue;
|
|
83
|
+
exports.useReferentiallyStableCallback = useReferentiallyStableCallback.useReferentiallyStableCallback;
|
|
84
|
+
exports.useUpdatedRef = useUpdatedRef.useUpdatedRef;
|
|
85
|
+
exports.useWindowSize = useWindowSize.useWindowSize;
|
|
86
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|